strange -fPIC compilation error

Lodovico Giaretta via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Oct 30 16:03:43 PDT 2016


On Sunday, 30 October 2016 at 18:02:28 UTC, Charles Hixson wrote:
>  dmd --version
> DMD64 D Compiler v2.071.2
> Copyright (c) 1999-2015 by Digital Mars written by Walter Bright
> on debian testing.
>
> dub is installed via apt-get.
>
> Should I revert to an earlier version?  Or what?
>
> The program:
>
>
> import    std.stdio;
>
> void    main()
> {    //int[]    t1;
>
>     //t1    ~=    1;
>     //t1    ~=    2;
>     //writeln ("t1 = ", t1);
> }
>
> fails with the 442 lines of error:
>
> /usr/bin/ld: test.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(exception_224_3b4.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(exception_227_4a2.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(exception_229_5cc.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(dmain2_626_47b.o): 
> relocation R_X86_64_32 against symbol 
> `_D6object9Throwable7__ClassZ' can not be used when making a 
> shared object; recompile with -fPIC
> /usr/bin/ld: 
> /usr/lib/x86_64-linux-gnu/libphobos2.a(dmain2_628_776.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(dwarfeh_62b_6b9.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(aaA_51a_53e.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: final link failed: Nonrepresentable section on 
> output
> collect2: error: ld returned 1 exit status
> --- errorlevel 1

Are you on Ubuntu 16.10, or some other system with an hardened 
toolchain? If that's the case, you should compile with `-fPIC 
-defaultlib=libphobos2.so`. You can put those options in your 
dmd.conf configuration file, so that you don't have to type them 
every time.


More information about the Digitalmars-d-learn mailing list