dub icon indicating copy to clipboard operation
dub copied to clipboard

relocation R_X86_64_32 against `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC

Open timotheecour opened this issue 9 years ago • 8 comments

seems a bit different from https://github.com/dlang/dub/issues/352

dub.json:

{
  "name": "foo",
  "targetType": "dynamicLibrary",
  // doesn't help: "dflags": ["-fPIC"],
  "targetPath":"$build_D",
  "authors": ["foo" ],
  "description": "foo",
  "copyright": "foo",
  "dependencies": {
        "msgpack-rpc": "~>0.1.2",
  },
  "license": "proprietary"
}

source/app.d: void test(){import msgpackrpc;}

dub -v --force :

/usr/bin/ld: ../../../.dub/packages/msgpack-rpc-0.1.2/msgpack-rpc/libmsgpack-rpc.a(package.o): relocation R_X86_64_32 against `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC
../../../.dub/packages/msgpack-rpc-0.1.2/msgpack-rpc/libmsgpack-rpc.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status

timotheecour avatar Sep 24 '16 02:09 timotheecour

AFAIR this error means that dmd and phobos got out of sync on your installation.

mihails-strasuns avatar Sep 24 '16 09:09 mihails-strasuns

It builds fine for me (Linux x64), except that what should presumably be symbolic links (libphobos2.so -> libphobos2.so.0.71.1) were text files in my DVM based DMD installation.

s-ludwig avatar Sep 26 '16 12:09 s-ludwig

Using fresh dub/dmd/libphobos installed from Manjaro x64 package manager these errors happen.

dub init somename -t vibe.d dub build

https://dpaste.de/SOSA/raw

EDIT: it was caused by hardening-wrapper, removing it fixes build. http://stackoverflow.com/a/32170761

wyrex avatar Oct 01 '16 16:10 wyrex

Also happens with:

  • libmir (from git 4193f3bdbdd2150c3c407ba5194b6e265b1d2f61)
  • dproto-2.1.0
Linking...
/usr/bin/ld: ../../.dub/packages/dproto-2.1.0/dproto/libdproto.a(attributes.o): relocation R_X86_64_32 against `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC
../../.dub/packages/dproto-2.1.0/dproto/libdproto.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
Linking...
/usr/bin/ld: /home/timothee/git_clone/mir//libmir.a(selection.o): relocation R_X86_64_32 against `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC
/home/timothee/git_clone/mir//libmir.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
--- errorlevel 1
dmd failed with exit code 1.

timotheecour avatar Oct 04 '16 23:10 timotheecour

maybe @msoucy has some idea on the dproto package?

timotheecour avatar Oct 04 '16 23:10 timotheecour

Can't say I've ever seen that before, sorry

msoucy avatar Oct 05 '16 00:10 msoucy

could this explain?

dub build --config=config_with_shared_lib --compiler=path_to_dmd_that_has_shared_libphobos

Dynamic libraries are not yet supported as dependencies - building as static library.

Are dynamic libraries even supported at all via dub? If not what would need to be changed? I really need to build some shared library so it can be dlopen'd inside another C++ application

Maybe related: https://github.com/dlang/dub/issues/571 https://github.com/dlang/dub/pull/821 https://github.com/dlang/dub/issues/629 https://github.com/dlang/dub/issues/613 https://github.com/dlang/dub/issues/591 https://github.com/dlang/dub/issues/571

http://forum.dlang.org/post/[email protected] : Dub shared library issue

timotheecour avatar Oct 05 '16 19:10 timotheecour

This should be solved now, can we close?

rikkimax avatar Feb 08 '22 01:02 rikkimax