RejectedSoftware Forums

Sign up

CentOS6 x86_64

I have a linker error, when compiling small vibe.d project with DUB:

dmd -of/tmp/dub/2648184025/mart /tmp/dub/2648184025/temp.o -L-Wl,-z,relro -L-L/usr/lib6464 -L-lssl -L-lcrypto -L-ldl -L-lz -L-levent_pthreads -L-levent -g
/usr/bin/ld: unrecognized option '-Wl,-z,relro'

DUB is built from the sources (the latest master branch)
DMD version:

$ dmd -v
DMD64 D Compiler v2.062

ld version:

$ ld -v
GNU ld version 2.20.51.0.2-5.34.el6 20100205

gcc version:

gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)

Re: CentOS6 x86_64

Looks like pkg-config bug:

$ pkg-config --libs libssl
-Wl,-z,relro -L/usr/lib6464 -lssl -lcrypto -ldl -lz

Is there any workaround?

Re: CentOS6 x86_64

This is not a bug, because these flags for GCC, which translate '-Wl,-z,relro' to correct '-z relro' linker flag.
I believe that DUB should scan all linker flags received from pkg-config, and translate -Wl flags to the right DMD flags.

Re: CentOS6 x86_64

Finally, I do it myself.
May be this is not very good solution, but it works. :)

 source/dub/compilers/dmd.d |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source/dub/compilers/dmd.d b/source/dub/compilers/dmd.d
index fad3269..edaa79e 100644
--- a/source/dub/compilers/dmd.d
+++ b/source/dub/compilers/dmd.d
@@ -123,7 +123,7 @@ class DmdCompiler : Compiler {
 	{
 		import std.string;
 		auto tpath = Path(settings.targetPath) ~ getTargetFileName(settings, platform);
-		auto args = ["dmd", "-of"~tpath.toNativeString()] ~ objects ~ settings.lflags.map!(l => "-L"~l)().array() ~ settings.sourceFiles;
+		auto args = ["dmd", "-of"~tpath.toNativeString()] ~ objects ~ settings.lflags.map!(l => "-L" ~ (l.find("-Wl,") == l ? l.replace("-Wl,", "").replace(",", " -L") : l))().array() ~ settings.sourceFiles;
 		args ~= settings.dflags.filter!(f => f == "-g" || f == "-gc")().array();
 		logDebug("%s", args.join(" "));
 		auto res = spawnProcess(args).wait();

Re: CentOS6 x86_64

On Sat, 04 May 2013 19:10:36 GMT, Jack Applegame wrote:

Finally, I do it myself.
May be this is not very good solution, but it works. :)

 source/dub/compilers/dmd.d |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source/dub/compilers/dmd.d b/source/dub/compilers/dmd.d
index fad3269..edaa79e 100644
--- a/source/dub/compilers/dmd.d
+++ b/source/dub/compilers/dmd.d
@@ -123,7 +123,7 @@ class DmdCompiler : Compiler {
 	{
 		import std.string;
 		auto tpath = Path(settings.targetPath) ~ getTargetFileName(settings, platform);
-		auto args = ["dmd", "-of"~tpath.toNativeString()] ~ objects ~ settings.lflags.map!(l => "-L"~l)().array() ~ settings.sourceFiles;
+		auto args = ["dmd", "-of"~tpath.toNativeString()] ~ objects ~ settings.lflags.map!(l => "-L" ~ (l.find("-Wl,") == l ? l.replace("-Wl,", "").replace(",", " -L") : l))().array() ~ settings.sourceFiles;
 		args ~= settings.dflags.filter!(f => f == "-g" || f == "-gc")().array();
 		logDebug("%s", args.join(" "));
 		auto res = spawnProcess(args).wait();


Thanks for tracking this down so far! I'll patch the source later today when I'm back at the PC.

Re: CentOS6 x86_64

git HEAD now contains a fixed version (hopefully, because I couldn't yet test on CentOS/64 and CentOS/32 doesn't generate those -Wl flags). I made the fix at an earlier stage, though, right after invoking "pkg-config" and applied that to all three supported compilers.