Thread overview
linking issue
Nov 09, 2015
Ellery Newcomer
Nov 09, 2015
David Nadlinger
Nov 10, 2015
Ellery Newcomer
November 09, 2015
Hi

I apologize in advance for not whittling this down more.

In travis, the shiny new pyd build for ldc is failing:

https://travis-ci.org/ariovistus/pyd/jobs/90001771

circa line 489:

ImportError: /usr/lib/python3/dist-packages/numpy/core/multiarray.cpython-32mu.so: undefined symbol: PyExc_SystemError

a similar build with dmd works fine:

https://travis-ci.org/ariovistus/pyd/jobs/90001737

So what is happening is the main python library is static, so the symbol ends up in the executable and the numpy shared library can't seem to see it at run time (with the ldc build).

The symbol certainly seems to exist:

$ nm ./extra | grep PyExc_SystemError
00000000008d0220 D PyExc_SystemError
00000000008d39e0 d _PyExc_SystemError

in both dmd-generated and ldc-generated executables.

The linkage attributes are different, for reasons derived from the fact that usually these symbols live in libpythonxx.so:

// dmd:
extern(C) extern __gshared PyObject* PyExc_SystemError;

// ldc:
extern(C) extern export __gshared PyObject* PyExc_SystemError;


Anyone know what might be the problem?
November 09, 2015
On 9 Nov 2015, at 3:32, Ellery Newcomer via digitalmars-d-ldc wrote:
> So what is happening is the main python library is static, so the symbol ends up in the executable and the numpy shared library can't seem to see it at run time (with the ldc build).
> […]
> Anyone know what might be the problem?

Did you try adding -rdynamic to the linker command line (e.g. using "-L-rdynamic" if you are linking with LDC)?

It is required to make all the symbols be written into ".dynsym". Otherwise, they might just as well be removed entirely in our case (due to --gc-sections).

 — David
November 10, 2015
On Monday, 9 November 2015 at 14:45:51 UTC, David Nadlinger wrote:
>
> Did you try adding -rdynamic to the linker command line (e.g. using "-L-rdynamic" if you are linking with LDC)?
>
> It is required to make all the symbols be written into ".dynsym". Otherwise, they might just as well be removed entirely in our case (due to --gc-sections).
>
>  — David

Hey, that does it! Or at least it would, if I could convince ldc to position it before everything else. seems to be position sensitive, and ldc seems to be reordering flags for me.

is there a trick to do this, or is it back to gcc for link?