Re: Cannot link with libphobos2.a with GCC 6.2 on Ubuntu 16.10
On Monday, 17 October 2016 at 11:55:03 UTC, Martin Nowak wrote: Please update the bug report. https://issues.dlang.org/show_bug.cgi?id=5278 Updated, but do I seriously have to do everything? I'm not even an Ubuntu user.
Re: Cannot link with libphobos2.a with GCC 6.2 on Ubuntu 16.10
On Thursday, 13 October 2016 at 18:35:43 UTC, Matthias Klumpp wrote: The new toolchains of Ubuntu (and Debian soon too) default to PIE code, so in order to link correctly, the project needs to be compiled with PIE/PIC to work. Please update the bug report. https://issues.dlang.org/show_bug.cgi?id=5278
Re: Cannot link with libphobos2.a with GCC 6.2 on Ubuntu 16.10
On 2016-10-17 10:55, Nordlöw wrote: It's the target `idgen` that fails for me. "idgen" is a separate target [1]. It's a tool that generates some code. [1] https://github.com/dlang/dmd/blob/master/src/posix.mak#L389 -- /Jacob Carlborg
Re: Cannot link with libphobos2.a with GCC 6.2 on Ubuntu 16.10
On Monday, 17 October 2016 at 08:39:55 UTC, Nordlöw wrote: I you only tell me what to do I can make a PR to DMD that fixes these things. It's the target `idgen` that fails for me.
Re: Cannot link with libphobos2.a with GCC 6.2 on Ubuntu 16.10
On Monday, 17 October 2016 at 05:55:55 UTC, tcak wrote: So, I added -defaultlib=libphobos2.so -fPIC Where did you add it? To the command-line or Makefile? And which Make variable did you change? I've tried make -f posix.mak MODEL_FLAG="-fPIC" but C++ compilations still fail with complaining about libphobos2.a not being compiled with -fPIC flag. -defaultlib is a DMD flag so that has not effect with the C++ compilations. This must be fixed in the DMD Makefiles! I you only tell me what to do I can make a PR to DMD that fixes these things.
Re: Cannot link with libphobos2.a with GCC 6.2 on Ubuntu 16.10
On Sunday, 16 October 2016 at 22:36:15 UTC, Nordlöw wrote: On Sunday, 16 October 2016 at 22:00:48 UTC, Nordlöw wrote: Which flag(s) in `src/posix.mak` did you change? Does make -f posix.mak MODEL_FLAG=-fPIC work? I'm sitting on a 16.04 system right now (which I don't dare to upgrade until this is fixed) so I'm just guessing. Well, I haven't made any changes anywhere at all. I always download the deb file and install it. My program was compiling on 16.04, and wasn't compiling on 16.10. So, I added -defaultlib=libphobos2.so -fPIC while compiling. That's it. But as you can guess, now I have to copy the libphobos on other computers as well as the executable. (libphotos2.so.0.71 is 9 MiB)
Re: Cannot link with libphobos2.a with GCC 6.2 on Ubuntu 16.10
On Sunday, 16 October 2016 at 22:00:48 UTC, Nordlöw wrote: Which flag(s) in `src/posix.mak` did you change? Does make -f posix.mak MODEL_FLAG=-fPIC work? I'm sitting on a 16.04 system right now (which I don't dare to upgrade until this is fixed) so I'm just guessing.
Re: Cannot link with libphobos2.a with GCC 6.2 on Ubuntu 16.10
On Sunday, 16 October 2016 at 20:01:21 UTC, tcak wrote: Hmm. As the error message says, I compiled the program by adding "-fPIC", it really has stopped giving error messages. That came to me weird. Which flag(s) in `src/posix.mak` did you change?
Re: Cannot link with libphobos2.a with GCC 6.2 on Ubuntu 16.10
On Sunday, 16 October 2016 at 17:42:44 UTC, tcak wrote: On Thursday, 13 October 2016 at 17:02:32 UTC, Nordlöw wrote: [...] I have upgraded my Ubuntu to 16.10 yesterday as well, and I am getting following error: /usr/bin/ld: obj/Debug/program.o: relocation R_X86_64_32 against symbol `_D9Exception7__ClassZ' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(object_1_257.o): relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC ... I guess the problem is same. Even though I have added "-defaultlib=libphobos2.so" to compiler options, problem persists. Hmm. As the error message says, I compiled the program by adding "-fPIC", it really has stopped giving error messages. That came to me weird.
Re: Cannot link with libphobos2.a with GCC 6.2 on Ubuntu 16.10
On Thursday, 13 October 2016 at 17:02:32 UTC, Nordlöw wrote: I just upgraded my Ubuntu to 16.10 and now my rebuilding of dmd from git master fails as /usr/bin/ld: idgen.o: relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(object_a_66e.o): relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC What's wrong? Am I using the wrong GCC version? Should I use GCC 5 instead? GCC 6.2 is default on 16.10. I have upgraded my Ubuntu to 16.10 yesterday as well, and I am getting following error: /usr/bin/ld: obj/Debug/program.o: relocation R_X86_64_32 against symbol `_D9Exception7__ClassZ' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(object_1_257.o): relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC ... I guess the problem is same. Even though I have added "-defaultlib=libphobos2.so" to compiler options, problem persists.
Re: Cannot link with libphobos2.a with GCC 6.2 on Ubuntu 16.10
On Thursday, 13 October 2016 at 19:11:36 UTC, Adam D. Ruppe wrote: Try `-defaultlib=libphobos2.so` with your dmd command line. The .so version is pic compiled. Or you can recompile the whole lib. I don't know how to do that from the command line. I don't want to hand modify the Makefile because I want this automatic. Instead I tried make -f posix.mak AUTO_BOOTSTRAP=1 but that fails as ++ -c -Wno-deprecated -Wstrict-aliasing -fno-exceptions -fno-rtti -D__pascal= -DMARS=1 -DTARGET_LINUX=1 -DDM_TARGET_CPU_X86=1 -m64 -Iroot -Itk -Ibackend -I. -DDMDV2=1 -MMD -MF cgsched.deps backend/cgsched.c backend/cg87.c: In function ‘unsigned char loadconst(elem*, int)’: backend/cg87.c:716:46: error: narrowing conversion of ‘238’ from ‘int’ to ‘char’ inside { } [-Wnarrowing] {0xEE,0xE8,0xEB,0xE9,0xEA,0xEC,0xED,0}; ^ backend/cg87.c:716:46: error: narrowing conversion of ‘232’ from ‘int’ to ‘char’ inside { } [-Wnarrowing] backend/cg87.c:716:46: error: narrowing conversion of ‘235’ from ‘int’ to ‘char’ inside { } [-Wnarrowing] backend/cg87.c:716:46: error: narrowing conversion of ‘233’ from ‘int’ to ‘char’ inside { } [-Wnarrowing] backend/cg87.c:716:46: error: narrowing conversion of ‘234’ from ‘int’ to ‘char’ inside { } [-Wnarrowing] backend/cg87.c:716:46: error: narrowing conversion of ‘236’ from ‘int’ to ‘char’ inside { } [-Wnarrowing] backend/cg87.c:716:46: error: narrowing conversion of ‘237’ from ‘int’ to ‘char’ inside { } [-Wnarrowing] posix.mak:446: receptet för målet ”cg87.o” misslyckades on Ubuntu 16.10. It seems we need fix the implicit conversion in cg87.c to match stricter type-checking in GCC 6.2.
Re: Cannot link with libphobos2.a with GCC 6.2 on Ubuntu 16.10
On Thursday, 13 October 2016 at 19:11:36 UTC, Adam D. Ruppe wrote: Try `-defaultlib=libphobos2.so` with your dmd command line. The .so version is pic compiled. Building DMD fails to how do I modify the call make -f posix.mak under the dmd checkout?
Re: Cannot link with libphobos2.a with GCC 6.2 on Ubuntu 16.10
Try `-defaultlib=libphobos2.so` with your dmd command line. The .so version is pic compiled. Or you can recompile the whole lib.
Re: Cannot link with libphobos2.a with GCC 6.2 on Ubuntu 16.10
On Thursday, 13 October 2016 at 18:35:43 UTC, Matthias Klumpp wrote: The new toolchains of Ubuntu (and Debian soon too) default to PIE code, so in order to link correctly, the project needs to be compiled with PIE/PIC to work. So how do I do this? Instructions? Can I bootstrap DMD or do I need to cross-compile to the new PIE/PIC?
Re: Cannot link with libphobos2.a with GCC 6.2 on Ubuntu 16.10
On Thursday, 13 October 2016 at 19:01:55 UTC, Nordlöw wrote: Can I bootstrap DMD or do I need to cross-compile to the new PIE/PIC? Is this what AUTO_BOOTSTRAP=1 is for and what does it do?
Re: Cannot link with libphobos2.a with GCC 6.2 on Ubuntu 16.10
On Thursday, 13 October 2016 at 17:07:19 UTC, Nordlöw wrote: On Thursday, 13 October 2016 at 17:02:32 UTC, Nordlöw wrote: Am I using the wrong GCC version? Should I use GCC 5 instead? GCC 6.2 is default on 16.10. Compiling DMD with GCC 5 as make -f posix.mak HOST_CXX=g++-5 also fails with same errors. The new toolchains of Ubuntu (and Debian soon too) default to PIE code, so in order to link correctly, the project needs to be compiled with PIE/PIC to work.
Re: Cannot link with libphobos2.a with GCC 6.2 on Ubuntu 16.10
On Thursday, 13 October 2016 at 17:02:32 UTC, Nordlöw wrote: Am I using the wrong GCC version? Should I use GCC 5 instead? GCC 6.2 is default on 16.10. Compiling DMD with GCC 5 as make -f posix.mak HOST_CXX=g++-5 also fails with same errors.