Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__gmp_modlimb_invert_table can not be used when making a shared object #286

Open
madebr opened this issue Apr 25, 2020 · 3 comments
Open

Comments

@madebr
Copy link

madebr commented Apr 25, 2020

Building a shared z3 library with mpir as a replacement for gmp fails because __gmp_modlimb_invert_table does not support relocation.

The link error is:

/usr/bin/ld: /home/maarten/.conan/data/mpir/3.0.0/_/_/package/b911f48570f9bb2902d9e83b2b9ebf9d376c8c56/lib/libgmp.a(modexact_1c_odd.o): relocation R_X86_64_PC32 against symbol `__gmp_modlimb_invert_table' can not be used when making a shared object; recompile with -fPIC

Reference to the source:
https://github.com/wbhart/mpir/blob/master/mpn/x86_64/modexact_1c_odd.as#L58-L88

@ZHOUYue67
Copy link

I have the exact same issue when building a shared library depending on CGAL & MPIR.

@amakhno
Copy link

amakhno commented Oct 20, 2020

Hi!
The same bug here

@leleliu008
Copy link

I greped the source code and found that some NASM assembly code using %ifdef PIC

./mpn/x86_64w/sqr_basecase.asm:11:	%ifdef PIC
./mpn/x86_64w/sqr_basecase.asm:20:	%ifdef PIC
./mpn/x86_64/netburst/sub_n.as:122:%ifdef PIC
./mpn/x86_64/netburst/sub_n.as:134:%ifdef PIC
./mpn/x86_64/netburst/add_n.as:122:%ifdef PIC
./mpn/x86_64/netburst/add_n.as:134:%ifdef PIC
./mpn/x86_64/modexact_1c_odd.as:107:%ifdef PIC

but build system doesn't pass -D PIC to yasm command, so we make sure -D PIC is passed to yasm command by:

YASM="$(command -v yasm)"                                                                                                                        

cat > yasm <<EOF                                                                                                                          
#!/bin/sh
exec "$YASM" -D PIC "\$@"
EOF

chmod +x yasm

export PATH="$PWD:$PATH"

resolved this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants