Jump to page: 1 2
Thread overview
Cannot link with libphobos2.a with GCC 6.2 on Ubuntu 16.10
Oct 13, 2016
Nordlöw
Oct 13, 2016
Nordlöw
Oct 13, 2016
Matthias Klumpp
Oct 13, 2016
Nordlöw
Oct 13, 2016
Nordlöw
Oct 17, 2016
Martin Nowak
Oct 24, 2016
Martin Nowak
Oct 13, 2016
Adam D. Ruppe
Oct 13, 2016
Nordlöw
Oct 14, 2016
Nordlöw
Oct 16, 2016
tcak
Oct 16, 2016
tcak
Oct 16, 2016
Nordlöw
Oct 16, 2016
Nordlöw
Oct 17, 2016
tcak
Oct 17, 2016
Nordlöw
Oct 17, 2016
Nordlöw
Oct 17, 2016
Jacob Carlborg
October 13, 2016
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.
October 13, 2016
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.
October 13, 2016
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.
October 13, 2016
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?
October 13, 2016
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?
October 13, 2016
Try `-defaultlib=libphobos2.so` with your dmd command line. The .so version is pic compiled.

Or you can recompile the whole lib.
October 13, 2016
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?
October 14, 2016
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.
October 16, 2016
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.
October 16, 2016
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.
« First   ‹ Prev
1 2