0

The previous question that gives a bit of background to this one: undefined reference to symbol 'clock_gettime@@GLIBC_2.4 In rust static library for musl target

Now when compiling the c++ program i get the error:

/mnt/HDD/Project/inkbox-build/inkbox/compiled-binaries/arm-kobo-linux-gnueabihf/bin/../lib/gcc/arm-kobo-linux-gnueabihf/11.2.0/../../../../arm-kobo-linux-gnueabihf/bin/ld.bfd: /mnt/HDD/Project/inkbox-build/inkbox/inkbox-toreader/libs/Libretranslate-rs-to-cpp/lib//libLibretranslate_rs_to_cpp.a(armcap.o): in function `OPENSSL_cpuid_setup':
armcap.c:(.text.startup.OPENSSL_cpuid_setup+0xa2): undefined reference to `sigsetjmp'
/mnt/HDD/Project/inkbox-build/inkbox/compiled-binaries/arm-kobo-linux-gnueabihf/bin/../lib/gcc/arm-kobo-linux-gnueabihf/11.2.0/../../../../arm-kobo-linux-gnueabihf/bin/ld.bfd: armcap.c:(.text.startup.OPENSSL_cpuid_setup+0xae): undefined reference to `sigsetjmp'
/mnt/HDD/Project/inkbox-build/inkbox/compiled-binaries/arm-kobo-linux-gnueabihf/bin/../lib/gcc/arm-kobo-linux-gnueabihf/11.2.0/../../../../arm-kobo-linux-gnueabihf/bin/ld.bfd: armcap.c:(.text.startup.OPENSSL_cpuid_setup+0xf4): undefined reference to `sigsetjmp'
/mnt/HDD/Project/inkbox-build/inkbox/compiled-binaries/arm-kobo-linux-gnueabihf/bin/../lib/gcc/arm-kobo-linux-gnueabihf/11.2.0/../../../../arm-kobo-linux-gnueabihf/bin/ld.bfd: armcap.c:(.text.startup.OPENSSL_cpuid_setup+0x100): undefined reference to `sigsetjmp'
/mnt/HDD/Project/inkbox-build/inkbox/compiled-binaries/arm-kobo-linux-gnueabihf/bin/../lib/gcc/arm-kobo-linux-gnueabihf/11.2.0/../../../../arm-kobo-linux-gnueabihf/bin/ld.bfd: armcap.c:(.text.startup.OPENSSL_cpuid_setup+0x10c): undefined reference to `sigsetjmp'
/mnt/HDD/Project/inkbox-build/inkbox/compiled-binaries/arm-kobo-linux-gnueabihf/bin/../lib/gcc/arm-kobo-linux-gnueabihf/11.2.0/../../../../arm-kobo-linux-gnueabihf/bin/ld.bfd: /mnt/HDD/Project/inkbox-build/inkbox/inkbox-toreader/libs/Libretranslate-rs-to-cpp/lib//libLibretranslate_rs_to_cpp.a(armcap.o):armcap.c:(.text.startup.OPENSSL_cpuid_setup+0x118): more undefined references to `sigsetjmp' follow
collect2: error: ld returned 1 exit status
make: *** [Makefile:505: build/inkbox] Error 1

The only thing i could find was: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59188

Specifically from there:

glibc (at least the 2.17 I have around) doesn't have sigsetjmp function at all,
it only conditionally has sigsetjmp as a macro

So what do I do with that? I don't even have such an old GLIBC

I was able to compile the rust library even with zig with a local not vendored openssl build:

OPENSSL_DIR=/home/build/inkbox/openssl/ cargo zigbuild --target armv7-unknown-linux-musleabihf

but the issue remains the same

Szybet
  • 5
  • 1
  • 1
    If you're compiling for musl, why are you referencing glibc issues? The most obvious explanation is that that function is not implemented in musl. Except that it clearly is: see the arch-specific directories in https://git.musl-libc.org/cgit/musl/tree/src/signal – Botje Aug 24 '23 at 09:43
  • rust library is compiled in musl and the cpp program that is calling the library is glibc. Yes I know it's bad, nothing to do about it - and glibc is complaining, not musl - the library compiles fine – Szybet Aug 24 '23 at 10:14
  • You can't use a musl-compiled library in a glibc-compiled program (nor the other way round). Your program and all the libraries it uses must use the same libc. – Jmb Aug 24 '23 at 12:14
  • I already use one lib like that. Propably i god lucky to not make any conflicts then... – Szybet Aug 24 '23 at 12:19

1 Answers1

0

glibc (in past at least) did not have the function sigsetjmp. It had a macro defined conditionally like

#ifdef __USE_POSIX
# define sigsetjmp(env, savemask) __sigsetjmp (env, savemask)
#endif

You either do not #include <setjmp.h> somewhere and the compiler uses the implicitly declared int sigsetjmp(), or the macro __USE_POSIX is not defined while compiling the C code in the file armcap.c.

If that does not fix the issue, you can define your own int sigsetjmp(sigjmp_buf env, int savemask) like in this topic: undefined reference to `siglongjmp' error when compiling android cocos2dx project for x86 architecture.

273K
  • 29,503
  • 10
  • 41
  • 64
  • This seems like a pretty good solution - I ended up flushing the code using this in openssl – Szybet Aug 26 '23 at 19:40