Monero: Fails to compile against musl libc

Created on 16 May 2017  路  28Comments  路  Source: monero-project/monero

Running Void Linux, with musl libc. Build fails due to musl's lack of execinfo.h.

In file included from /tmp/monero-0.10.3.1/contrib/epee/include/misc_log_ex.h:61:0,
                 from /tmp/monero-0.10.3.1/contrib/epee/include/serialization/keyvalue_serialization.h:31,
                 from /tmp/monero-0.10.3.1/src/p2p/p2p_protocol_defs.h:34,
                 from /tmp/monero-0.10.3.1/src/common/util.h:43,
                 from /tmp/monero-0.10.3.1/src/common/base58.cpp:39:
/tmp/monero-0.10.3.1/external/easylogging++/easylogging++.h:345:25: fatal error: execinfo.h: No such file or directory
 #   include <execinfo.h>
                         ^
compilation terminated.
make[3]: *** [src/common/CMakeFiles/obj_common.dir/build.make:63: src/common/CMakeFiles/obj_common.dir/base58.cpp.o] Error 1
make[2]: *** [CMakeFiles/Makefile2:486: src/common/CMakeFiles/obj_common.dir/all] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [Makefile:141: all] Error 2
make: *** [Makefile:59: release-all] Error 2

Most helpful comment

apk add libexecinfo-dev

this also does not help and without patch it fails on linking

[ 80%] Linking CXX executable ../../bin/monero-blockchain-export
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: ../../external/easylogging++/libeasylogging.a(easylogging++.cc.o): in function `el::base::debug::StackTrace::generateNew()':
easylogging++.cc:(.text+0xd51d): undefined reference to `backtrace'
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: easylogging++.cc:(.text+0xd529): undefined reference to `backtrace_symbols'
collect2: error: ld returned 1 exit status

Ref https://travis-ci.org/alpinelinux/aports/builds/445387732

All 28 comments

This is the same case for OpenBSD.

https://build.getmonero.org/builders/monero-static-openbsd-amd64/builds/4/steps/compile/logs/stdio

There are several platforms without execinfo. I think @moneromooo-monero said its used by easylogging to get stack trace info and so maybe we should just include it on glibc linux.

Can you try replacing it with elf.h and see if that builds ?

@moneromooo-monero OpenBSD doesn't have an elf.h but it does have sys/exec_elf.h, which looks about the same. If I use that instead of execinfo.h I get "use of undeclared identifier" errors for val, backtrace, and backtrace_symbols.

@wang-gretzky What about on Void Linux?

Do you see these symbols anywhere ? If not, then I guess this can be disabled for that platform.

Do you see these symbols anywhere ?

No.

I added a package to AlpineLinux. Alpine uses musl: https://git.alpinelinux.org/cgit/aports/tree/testing/monero
There are some glitches to enable musl support. See the patches.

Interesting, I thought __has_include was a CLANG only thing. Looks like it's in GCC 5 now.
Also, ideally, the CMakeLists.txt patch should be unnecessary if the easylogging one is applied. What are the errors if it is omitted ?

Just to avoid a lot of warnings

In file included from /home/andre/aports/testing/monero/src/monero-0.10.3.1/contrib/epee/include/misc_log_ex.h:61:0,
                 from /home/andre/aports/testing/monero/src/monero-0.10.3.1/contrib/epee/include/serialization/keyvalue_serialization.h:31,
                 from /home/andre/aports/testing/monero/src/monero-0.10.3.1/src/cryptonote_basic/cryptonote_basic.h:46,
                 from /home/andre/aports/testing/monero/src/monero-0.10.3.1/src/blockchain_utilities/bootstrap_file.h:37,
                 from /home/andre/aports/testing/monero/src/monero-0.10.3.1/src/blockchain_utilities/blockchain_export.cpp:29:
/home/andre/aports/testing/monero/src/monero-0.10.3.1/external/easylogging++/easylogging++.h:205:11: warning: #warning "Stack trace not available for this compiler"; [-Wcpp]
 #         warning "Stack trace not available for this compiler";
           ^~~~~~~

_has_include will be in C++17

Ah, that makes sense, thanks.

I've updated the patch to remove the warning except once.

This is what I get with #2235. I wonder if we might revive it since #2249 has been abandoned. I can give you access to an openbsd box.

```[ 43%] Building CXX object external/easylogging++/CMakeFiles/easylogging.dir/easylogging++.cc.o
In file included from /home/vagrant/monero/external/easylogging++/easylogging++.cc:18:
/home/vagrant/monero/external/easylogging++/easylogging++.h:216:13: warning: "Stack trace not available for this compiler"; [-W#warnings]

warning "Stack trace not available for this compiler";

        ^

/home/vagrant/monero/external/easylogging++/easylogging++.cc:718:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
/home/vagrant/monero/external/easylogging++/easylogging++.cc:1038:8: error: use of undeclared identifier 'val'
if ((val == nullptr) || ((strcmp(val, "") == 0))) {
^
/home/vagrant/monero/external/easylogging++/easylogging++.cc:1038:36: error: use of undeclared identifier 'val'
if ((val == nullptr) || ((strcmp(val, "") == 0))) {
^
/home/vagrant/monero/external/easylogging++/easylogging++.cc:1052:22: error: use of undeclared identifier 'val'
return std::string(val);
^
2 warnings and 3 errors generated.
```

Sure, I'll fix if I have access to one.

I think it's fixed with ston1th's latest commits.

@moneromooo-monero unfortunately my commits just fixed the OpenBSD part, not the musl libc.

I just fired an Alpine Linux VM to test some solutions (maybe a generic one) using __has_include and/or __GNU_LIBRARY__.

@ston1th We have a builder for alpine, looks like its close, needs a -lz maybe?
https://build.getmonero.org/builders/monero-static-alpine-3.5-x86_64/builds/1146/steps/compile/logs/stdio

@danrmiller
Huh I'm bit confused now.
I tried to build master on Alpine 3.6 and got the <execinfo.h> error. I try a clean VM later on.

Anyway.. yes I think there needs to be a -lz.
But I'm not sure this will fix these two errors:

[ 91%] Linking CXX executable ../../bin/monero-wallet-rpc
../../external/easylogging++/libeasylogging.a(easylogging++.cc.o): In function `el::base::debug::StackTrace::generateNew()':
easylogging++.cc:(.text+0xc7da): undefined reference to `backtrace'
easylogging++.cc:(.text+0xc7e6): undefined reference to `backtrace_symbols'

@moneromooo-monero I looked through https://github.com/monero-project/monero/pull/2235 and I would like to add those two (#2235-R17, #2235-R212) so we don't spam the build logs with warnings if execinfo is not available.

2900 is merged.

apk add libexecinfo-dev

Is this still happening ?

meanwhile it happened again http://build.alpinelinux.org/buildlogs/build-edge-armhf/testing/monero/monero-0.13.0.2-r0.log

[  5%] No download step for 'generate_translations_header'
-- The most recent tag was at c93942e1ed
-- You are ahead of or behind a tagged release
In file included from /home/buildozer/aports/testing/monero/src/monero-0.13.0.2/external/easylogging++/easylogging++.cc:18:
/home/buildozer/aports/testing/monero/src/monero-0.13.0.2/external/easylogging++/easylogging++.h:216:10: warning: #warning "Stack trace not available for this compiler"; [-Wcpp]
 #        warning "Stack trace not available for this compiler";
          ^~~~~~~

apk add libexecinfo-dev

this also does not help and without patch it fails on linking

[ 80%] Linking CXX executable ../../bin/monero-blockchain-export
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: ../../external/easylogging++/libeasylogging.a(easylogging++.cc.o): in function `el::base::debug::StackTrace::generateNew()':
easylogging++.cc:(.text+0xd51d): undefined reference to `backtrace'
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: easylogging++.cc:(.text+0xd529): undefined reference to `backtrace_symbols'
collect2: error: ld returned 1 exit status

Ref https://travis-ci.org/alpinelinux/aports/builds/445387732

I can confirm this, but I think the issue might be upstream. Currently using a patch as a workaround.

Edit: If libunwind is present, a completely different set of errors is reported, so the suggestion in the linked issue seems fruitless.

We're back to this failing for 0.15.x.x. I haven't figured out a patch yet.

This disables the ~stack traces~ crash logs. Best compromise I can come up with right now.

export CXXFLAGS="${CXXFLAGS} -DELPP_FEATURE_CRASH_LOG"

This enables crash logs. Did you mean -U ?

It builds successfully on Alpine with -DELPP_FEATURE_CRASH_LOG, so I guess it does disable crash logs @moneromooo-monero

For posterity (because this issue comes up first in a number of search results for musl-related linking errors, especially related to easylogging), the switch that did it for me was -DSTACK_TRACE:BOOL=OFF (every other patch or switch suggested in this thread either did not work or gives a 404).

Sorry for the necrobump

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zeshanvirk picture zeshanvirk  路  6Comments

artyomsol picture artyomsol  路  5Comments

bianchimro picture bianchimro  路  5Comments

yagamidev picture yagamidev  路  4Comments

Gingeropolous picture Gingeropolous  路  5Comments