Hi, On musl, gl_multithreaded() returns false in a statically linked program that creates threads, with both -static and -static-pie. Locks guarded by thread-optim, such as libunistring's struniq(), are then skipped while threads are running.
gnulib's own test shows it. With gnulib master 0727e5ff1e on Alpine Linux 3.24 (musl, gcc 15, x86_64): gnulib-tool --create-testdir --dir=td --single-configure thread-optim mkdir b && cd b ../td/configure CFLAGS="-O2 -static-pie" LDFLAGS="-static-pie" make && make -C gltests check TESTS=test-thread-optim2 test-thread-optim2 fails at test-thread-optim2.c:43 with -static-pie and with "-static -no-pie", and passes when dynamically linked. libunistring 1.5 fails the same way. glibc is unaffected. The cause appears to be in inspect_one_GOT() in lib/thread-optim.c, which treats a program as statically linked only if it has no PT_DYNAMIC and an empty dlpi_name: - With -static, musl's dl_iterate_phdr() names the program "/proc/self/exe", so the name is not empty. - With -static-pie, the program has a PT_DYNAMIC for its own relocations, but no GOT entry for pthread_create to find. A workaround is to configure with ac_cv_func_dl_iterate_phdr=no. Thanks, Mike -- Mike Love <[email protected]> ------------------ @grepular:matrix.org https://www.linkedin.com/in/grepular ------- https://www.grepular.com https://bsky.app/profile/grepular.com ----- @[email protected] https://www.emailprivacytester.com ------ https://gitlab.com/grepular https://www.parsemail.org --------- https://hub.docker.com/u/grepular
signature.asc
Description: This is a digitally signed message part
