-
Notifications
You must be signed in to change notification settings - Fork 332
tests: fix build on musl-based systems #775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
4c46335 to
8e04ef6
Compare
|
Only mkosi/boot fedora* checks fail. All are as follows: This is unrelated to the test build in the PR, but rather to recent changes in f44 that may be possible in binutils (2.45.50-3.fc44). |
|
I checked the previous version in f44, downgrading from 2.45.50-3.fc44 to 2.45-1.fc43 fixes objcopy. |
include/test.mk
Outdated
| BACKTRACE_DEFINES ?= | ||
|
|
||
| INCL_LIBUNWIND = '\#include <libunwind.h>' | ||
| HAVE_LIBUNWIND := $(shell echo $(INCL_LIBUNWIND) | $(CC) -E - >/dev/null 2>&1 && echo 1 || echo 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I understand this means it will end up linking with libunwind even if it just happens to be installed, even when using glibc? If so, that's not great, could it be made in an explicit makefile env var to set instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, this is a safer option, BTW. So when building for musl to enable backtrace in the tests, USE_LIBUNWIND should be explicitly passed:
ifneq ($(origin USE_LIBUNWIND), undefined)
ARCH_DEFINES += -DHAVE_LIBUNWIND
LIBS += -lunwind
endif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made a few changes to the naming and rearranged the ifdef checks. Now, only providing ENABLE_LIBUNWIND explicitly enables linking with libunwind and the use of fallback behavior in print_traceback().
Musl libc does not provide the backtrace functions in its implementation. These functions are typically provided by glibc's <execinfo.h>. As a fallback for musl-based systems, support linking against the external libunwind library and using dladdr() to obtain similar stack trace info. Note that the usage of dladdr() is similar to that of backtrace_symbols in glibc, and it can be used with glibc as well. Signed-off-by: Alexey Kodanev <[email protected]>
GNUC_PREREQ macro is provided by shim.h and implements the same functionality. Signed-off-by: Alexey Kodanev <[email protected]>
8e04ef6 to
6f6e71c
Compare
This PR addresses two issues related to glibc-specific usage in the tests to ensure they can be built with musl libc too:
__GNUC_PREREQmacro fromfeatures.h- replaced with GNUC_PREREQ that is provided byshim.hand implements the same functionality.execinfo.h(backtrace functions) - musl libc does not provide the backtrace functions in its implementation. These functions are typically provided by glibc'sexecinfo.h. As a fallback for musl-based systems, support linking against the external libunwind library and using dladdr() to obtain similar stack trace info. Note that the usage of dladdr() is similar to that of backtrace_symbols in glibc, and it can be used with glibc as well.