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

musl-gcc: goldilocks_gen_tables is not a statically linked executable when --enable-static and --disable-shared is passed to ./configure #13

Open
odiferousmint opened this issue Sep 2, 2019 · 1 comment
Assignees
Milestone

Comments

@odiferousmint
Copy link

odiferousmint commented Sep 2, 2019

Hello.

Due to goldilocks_gen_tables being a dynamically linked executable, it cannot be executed when compiled with musl-gcc:

$ ./configure --enable-static --disable-shared CC=musl-gcc --host amd64 && make -j2

Result:

[...]
libtool: link: musl-gcc -std=c99 -fno-strict-aliasing -pedantic -Wall -Wextra -Werror -Wunreachable-code -Wmissing-declarations -Wunused-function -Wno-overlength-strings -I../src -I../src/include -I../src/public_include -I../src/arch_x86_64 -I../src/include/arch_x86_64 -O2 -maes -ffunction-sections -fdata-sections -fvisibility=hidden -fomit-frame-pointer -fPIC -g -O2 -o goldilocks_gen_tables goldilocks_gen_tables-utils.o goldilocks_gen_tables-goldilocks_gen_tables.o arch_x86_64/goldilocks_gen_tables-f_impl.o goldilocks_gen_tables-f_arithmetic.o goldilocks_gen_tables-f_generic.o goldilocks_gen_tables-goldilocks.o goldilocks_gen_tables-scalar.o 
./goldilocks_gen_tables > GEN/decaf_tables.c || (rm GEN/decaf_tables.c; exit 1)
/bin/sh: ./goldilocks_gen_tables: No such file or directory
make[2]: *** [Makefile:1078: GEN/decaf_tables.c] Error 1
make[2]: Leaving directory '/tmp/libgoldilocks/src'
make[1]: *** [Makefile:419: all-recursive] Error 1
make[1]: Leaving directory '/tmp/libgoldilocks'
make: *** [Makefile:350: all] Error 2

The solution is adding -static to create a statically linked executable instead of a dynamically linked one:

cd src && musl-gcc -static -std=c99 -fno-strict-aliasing -pedantic -Wall -Wextra -Werror -Wunreachable-code -Wmissing-declarations -Wunused-function -Wno-overlength-strings -I../src -I../src/include -I../src/public_include -I../src/arch_x86_64 -I../src/include/arch_x86_64 -O2 -maes -ffunction-sections -fdata-sections -fvisibility=hidden -fomit-frame-pointer -fPIC -g -O2 -o goldilocks_gen_tables goldilocks_gen_tables-utils.o goldilocks_gen_tables-goldilocks_gen_tables.o arch_x86_64/goldilocks_gen_tables-f_impl.o goldilocks_gen_tables-f_arithmetic.o goldilocks_gen_tables-f_generic.o goldilocks_gen_tables-goldilocks.o goldilocks_gen_tables-scalar.o

It seems to be the case that if we append -static, everything seems to work, the executable can be executed (it cannot if we omit -static, ldd shows invalid ELF header), and all tests pass.

The issue arises only when CC is set to musl-gcc. It works with gcc.

I apologize for the long title, I could not come up with a shorter one that summarizes the issue. :/

@claucece
Copy link
Member

claucece commented Dec 4, 2019

Hi, @odiferousmint !

Thanks for this! I'll look it this week ;)

Thanks!

@claucece claucece self-assigned this Dec 4, 2019
@claucece claucece added this to the February milestone Feb 6, 2020
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

2 participants