ERROR: Unable to load dependent library ... libopenlibm.so

I am trying to bisect an issue with Julia, it is fixed in master and present in v11.4. My problem is that if I try to compile anything in the release-1.11 branch, I get an error like

ERROR: Unable to load dependent library /home/tamas/src/julia-git/usr/bin/../lib/libopenlibm.so
Message:/home/tamas/src/julia-git/usr/bin/../lib/libopenlibm.so: cannot enable executable stack as shared object requires: Invalid argument
make[1]: *** [sysimage.mk:64: /home/tamas/src/julia-git/usr/lib/julia/corecompiler.ji] Error 1
make: *** [Makefile:103: julia-sysimg-ji] Error 2

I found a related topic pointing to a PR and of course it is fixed in master, but how can I work around this to compile 1.11.4?

You need to manually clear the executable stack flag from the library. Two options were mentioned over at Crash under glibc 2.41 due to libopenlibm having an executable stack · Issue #57250 · JuliaLang/julia · GitHub

If you have the execstack program on your system:

execstack -c /your/path/to/lib/libopenlibm.so

If you have patchelf:

patchelf --clear-execstack /your/path/to/lib/libopenlibm.so

I did not have either on my system, so I installed the first. Worked like a charm!

1 Like

It is unclear where in the compilation process I should apply this though (I want to automate it for bisection). The best I would come up with is

#!/bin/sh
make cleanall
make
patchelf --clear-execstack  /home/tamas/src/julia-git/usr/bin/../lib/libopenlibm.so
make

ie calling make twice, because it updates the binary then fails.

Calling make twice might be the most reliable among quick solutions. I can only think of

echo "
install-openlibm: $(build_prefix)/manifest/openlibm
    patchelf --clear-execstack /home/tamas/src/julia-git/usr/bin/../lib/libopenlibm.so
" >> deps/openlibm.mk

but that’s pretty ugly.