Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
L
libgoldilocks
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1
    • Issues 1
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 1
    • Merge Requests 1
  • Operations
    • Operations
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
  • OTRv4
  • libgoldilocks
  • Issues
  • #13

Closed
Open
Opened Sep 02, 2019 by Jurre van Bergen@DrWhaxOwner

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

Created by: odiferousmint

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. :/

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: otrv4/libgoldilocks#13