dslm4515 / CMLFS

Clang-Built Musl Linux From Scratch
MIT License
106 stars 18 forks source link

Libexecinfo still required #52

Closed dslm4515 closed 1 year ago

dslm4515 commented 3 years ago

LLVM of cgnutools still looks for headers for libexecinfo:

[ 15%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/Signals.cpp.o
In file included from /mnt/cmlfs/sources/llvm/lib/Support/Unix/Unix.h:21,
                 from /mnt/cmlfs/sources/llvm/lib/Support/Unix/Signals.inc:35,
                 from /mnt/cmlfs/sources/llvm/lib/Support/Signals.cpp:225:
/mnt/cmlfs/sources/llvm/build/include/llvm/Config/config.h:25:26: fatal error: execinfo.h: No such 
file or directory
   25 | #define BACKTRACE_HEADER <execinfo.h>
      |                          ^
compilation terminated.
make[2]: *** [lib/Support/CMakeFiles/LLVMSupport.dir/build.make:1882: lib/Support/CMakeFiles/LLVMSu
pport.dir/Signals.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/mnt/cmlfs/sources/llvm/build'
make[1]: *** [CMakeFiles/Makefile2:6560: lib/Support/CMakeFiles/LLVMSupport.dir/all] Error 2
make[1]: Leaving directory '/mnt/cmlfs/sources/llvm/build'
make: *** [Makefile:156: all] Error 2
make: Leaving directory '/mnt/cmlfs/sources/llvm/build'

even though i have it turned off:

export BUILD_OFF+="-DLLVM_ENABLE_BACKTRACES=OFF "
dslm4515 commented 3 years ago

Perhaps, libexecinfo must be built if host is musl based

dslm4515 commented 3 years ago

So i copy /usr/include/execinfo.h from host to /cgnutools/include/. Issue goes away but another pops up:

[ 13%] Linking CXX shared library ../libLLVMSupport.so
/mnt/cmlfs/cgnutools/bin/../lib/gcc/x86_64-cmlfs-linux-musl/11.2.0/../../../../x86_64-cmlfs-linux-musl/bin/ld: cannot find -lexecinfo
collect2: error: ld returned 1 exit status
make[2]: *** [lib/Support/CMakeFiles/LLVMSupport.dir/build.make:2242: lib/libLLVMSupport.so.12] Error 1
make[2]: Leaving directory '/mnt/cmlfs/sources/llvm/build'
make[1]: *** [CMakeFiles/Makefile2:6560: lib/Support/CMakeFiles/LLVMSupport.dir/all] Error 2
make[1]: Leaving directory '/mnt/cmlfs/sources/llvm/build'
make: *** [Makefile:156: all] Error 2
make: Leaving directory '/mnt/cmlfs/sources/llvm/build'

Looks like libexecinfo.so is expected in /cgnutools/lib

owl4ce commented 3 years ago

Oh I see, forgot this one, I use glibc host.

dslm4515 commented 3 years ago

I'll add a note to clarify libexecinfo is optional for Glibc hosts but required for musl-based hosts

dslm4515 commented 1 year ago

Perhaps, libexecinfo must be built if host is musl based

Just built cgnutools with LLVM-15.0.5 on a glibc system and LLVM build still failed to compile due to unresolved symbols that start with backtrace ... Build succeeded when added -Wl,--as-needed -lexecinfo to CXXFLAGS & CFLAGS

dslm4515 commented 1 year ago

Example of "undefined reference to backtrace symbols":

[1/1610] Linking CXX shared library lib/clang/15.0.5/lib/x86_64-pc-linux-musl/libclang_rt.scudo_minimal.so
FAILED: lib/clang/15.0.5/lib/x86_64-pc-linux-musl/libclang_rt.scudo_minimal.so 
: && /cgnutools/bin/x86_64-cmlfs-linux-musl-g++ -fPIC -g -g1 -Wl,--as-needed -lexecinfo -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -std=c++14 -Wno-unused-parameter -O3 -DNDEBUG  -Wl,-dynamic-linker /cgnutools/lib/ld-musl-x86_64.so.1 -Wl,--as-needed -lexecinfo -Wl,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,/mnt/cmlfs/sources/llvm-rl/build/./lib   -m64 -Wl,-z,text -Wl,--gc-sections -shared -Wl,-soname,libclang_rt.scudo_minimal.so -o lib/clang/15.0.5/lib/x86_64-pc-linux-musl/libclang_rt.scudo_minimal.so projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_allocator.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_common.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_deadlock_detector1.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_deadlock_detector2.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_errno.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_file.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_flags.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_flag_parser.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_fuchsia.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_libc.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_libignore.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_linux.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_linux_s390.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_mac.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_mutex.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_netbsd.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_platform_limits_freebsd.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_platform_limits_linux.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_platform_limits_netbsd.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_platform_limits_posix.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_platform_limits_solaris.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_posix.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_printf.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_procmaps_common.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_procmaps_bsd.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_procmaps_fuchsia.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_procmaps_linux.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_procmaps_mac.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_procmaps_solaris.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_solaris.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_stoptheworld_fuchsia.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_stoptheworld_mac.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_stoptheworld_win.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_suppressions.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_tls_get_addr.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonNoTermination.x86_64.dir/sanitizer_thread_registry.cpp.o projects/compiler-rt/lib/sanitizer_con_libcdep.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_allocator_checks.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_linux_libcdep.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_mac_libcdep.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_posix_libcdep.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_stoptheworld_linux_libcdep.cpp.o projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_stoptheworld_netbsd_libcdep.cpp.o projects/compiler-rt/lib/interception/CMakeFiles/RTInterception.x86_64.dir/interception_linux.cpp.o projects/compiler-rt/lib/interception/CMakeFiles/RTInterception.x86_64.dir/interception_mac.cpp.o projects/compiler-rt/lib/interception/CMakeFiles/RTInterception.x86_64.dir/interception_win.cpp.o projects/compiler-rt/lib/interception/CMakeFiles/RTInterception.x86_64.dir/interception_type_test.cpp.o projects/compiler-rt/lib/gwp_asan/CMakeFiles/RTGwpAsan.x86_64.dir/common.cpp.o projects/compiler-rt/lib/gwp_asan/CMakeFiles/RTGwpAsan.x86_64.dir/crash_handler.cpp.o projects/compiler-rt/lib/gwp_asan/CMakeFiles/RTGwpAsan.x86_64.dir/platform_specific/common_posix.cpp.o projects/compiler-rt/lib/gwp_asan/CMakeFiles/RTGwpAsan.x86_64.dir/platform_specific/guarded_pool_allocator_posix.cpp.o projects/compiler-rt/lib/gwp_asan/CMakeFiles/RTGwpAsan.x86_64.dir/platform_specific/mutex_posix.cpp.o projects/compiler-rt/lib/gwp_asan/CMakeFiles/RTGwpAsan.x86_64.dir/platform_specific/utilities_posix.cpp.o projects/compiler-rt/lib/gwp_asan/CMakeFiles/RTGwpAsan.x86_64.dir/guarded_pool_allocator.cpp.o projects/compiler-rt/lib/gwp_asan/CMakeFiles/RTGwpAsan.x86_64.dir/stack_trace_compressor.cpp.o projects/compiler-rt/lib/gwp_asan/CMakeFiles/RTGwpAsanOptionsParser.x86_64.dir/optional/options_parser.cpp.o projects/compiler-rt/lib/gwp_asan/CMakeFiles/RTGwpAsanBacktraceLibc.x86_64.dir/optional/backtrace_linux_libc.cpp.o projects/compiler-rt/lib/gwp_asan/CMakeFiles/RTGwpAsanSegvHandler.x86_64.dir/optional/segv_handler_posix.cpp.o projects/compiler-rt/lib/scudo/CMakeFiles/clang_rt.scudo_minimal-dynamic-x86_64.dir/scudo_allocator.cpp.o projects/compiler-rt/lib/scudo/CMakeFiles/clang_rt.scudo_minimal-dynamic-x86_64.dir/scudo_crc32.cpp.o projects/compiler-rt/lib/scudo/CMakeFiles/clang_rt.scudo_minimal-dynamic-x86_64.dir/scudo_errors.cpp.o projects/compiler-rt/lib/scudo/CMakeFiles/clang_rt.scudo_minimal-dynamic-x86_64.dir/scudo_flags.cpp.o projects/compiler-rt/lib/scudo/CMakeFiles/clang_rt.scudo_minimal-dynamic-x86_64.dir/scudo_malloc.cpp.o projects/compiler-rt/lib/scudo/CMakeFiles/clang_rt.scudo_minimal-dynamic-x86_64.dir/scudo_termination.cpp.o projects/compiler-rt/lib/scudo/CMakeFiles/clang_rt.scudo_minimal-dynamic-x86_64.dir/scudo_tsd_exclusive.cpp.o projects/compiler-rt/lib/scudo/CMakeFiles/clang_rt.scudo_minimal-dynamic-x86_64.dir/scudo_tsd_shared.cpp.o projects/compiler-rt/lib/scudo/CMakeFiles/clang_rt.scudo_minimal-dynamic-x86_64.dir/scudo_utils.cpp.o projects/compiler-rt/lib/scudo/CMakeFiles/clang_rt.scudo_minimal-dynamic-x86_64.dir/scudo_new_delete.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib"  -lgcc_s  -lc  -ldl  -lrt  -lpthread && :
/mnt/cmlfs/cgnutools/bin/../lib/gcc/x86_64-cmlfs-linux-musl/12.2.0/../../../../x86_64-cmlfs-linux-musl/bin/ld: projects/compiler-rt/lib/gwp_asan/CMakeFiles/RTGwpAsanBacktraceLibc.x86_64.dir/optional/backtrace_linux_libc.cpp.o: in function `(anonymous namespace)::SegvBacktrace(unsigned long*, unsigned long, void*)':
/mnt/cmlfs/sources/llvm-rl/compiler-rt/lib/gwp_asan/optional/backtrace_linux_libc.cpp:25: undefined reference to `backtrace'
/mnt/cmlfs/cgnutools/bin/../lib/gcc/x86_64-cmlfs-linux-musl/12.2.0/../../../../x86_64-cmlfs-linux-musl/bin/ld: projects/compiler-rt/lib/gwp_asan/CMakeFiles/RTGwpAsanBacktraceLibc.x86_64.dir/optional/backtrace_linux_libc.cpp.o: in function `(anonymous namespace)::Backtrace(unsigned long*, unsigned long)':
/mnt/cmlfs/sources/llvm-rl/compiler-rt/lib/gwp_asan/optional/backtrace_linux_libc.cpp:25: undefined reference to `backtrace'
/mnt/cmlfs/cgnutools/bin/../lib/gcc/x86_64-cmlfs-linux-musl/12.2.0/../../../../x86_64-cmlfs-linux-musl/bin/ld: projects/compiler-rt/lib/gwp_asan/CMakeFiles/RTGwpAsanBacktraceLibc.x86_64.dir/optional/backtrace_linux_libc.cpp.o: in function `(anonymous namespace)::PrintBacktrace(unsigned long*, unsigned long, void (*)(char const*, ...))':
/mnt/cmlfs/sources/llvm-rl/compiler-rt/lib/gwp_asan/optional/backtrace_linux_libc.cpp:44: undefined reference to `backtrace_symbols'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
dslm4515 commented 1 year ago

running ccmake build then pressing c (configure) then g (generate) allows build to continue

dslm4515 commented 1 year ago

... Other times, same error persists even with doing the above:

/mnt/cmlfs/cgnutools/bin/../lib/gcc/x86_64-cmlfs-linux-musl/12.2.0/../../../../x86_64-cmlfs-linux-musl/bin/ld: projects/compiler-rt/lib/gwp_asan/CMakeFiles/RTGwpAsanBacktraceLibc.x86_64.dir/optional/backtrace_linux_libc.cpp.o: in function `(anonymous namespace)::SegvBacktrace(unsigned long*, unsigned long, void*)':
/mnt/cmlfs/sources/llvm-rl/compiler-rt/lib/gwp_asan/optional/backtrace_linux_libc.cpp:25: undefined reference to `backtrace'
/mnt/cmlfs/cgnutools/bin/../lib/gcc/x86_64-cmlfs-linux-musl/12.2.0/../../../../x86_64-cmlfs-linux-musl/bin/ld: projects/compiler-rt/lib/gwp_asan/CMakeFiles/RTGwpAsanBacktraceLibc.x86_64.dir/optional/backtrace_linux_libc.cpp.o: in function `(anonymous namespace)::Backtrace(unsigned long*, unsigned long)':
/mnt/cmlfs/sources/llvm-rl/compiler-rt/lib/gwp_asan/optional/backtrace_linux_libc.cpp:25: undefined reference to `backtrace'
/mnt/cmlfs/cgnutools/bin/../lib/gcc/x86_64-cmlfs-linux-musl/12.2.0/../../../../x86_64-cmlfs-linux-musl/bin/ld: projects/compiler-rt/lib/gwp_asan/CMakeFiles/RTGwpAsanBacktraceLibc.x86_64.dir/optional/backtrace_linux_libc.cpp.o: in function `(anonymous namespace)::PrintBacktrace(unsigned long*, unsigned long, void (*)(char const*, ...))':
/mnt/cmlfs/sources/llvm-rl/compiler-rt/lib/gwp_asan/optional/backtrace_linux_libc.cpp:44: undefined reference to `backtrace_symbols'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

I cannot think of how else to tell GCC [of cgnutools] to link /cgnutools/lib/libexecinfo.so for those "undefined references to `backtrace' "

dslm4515 commented 1 year ago

For the above [compiler-rt], i had to add the following cmake options:

-DCOMPILER_RT_BUILD_GWP_ASAN=OFF  \ 
-DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
-DCOMPILER_RT_BUILD_ORC=OFF

Now compiler-rt builds without undefined references to backtrace errors

dslm4515 commented 1 year ago

Final system's LLVM builds fine with stage0 clang from cgnutools