Skip to content
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

druntime: Cherry-pick libunwind-based backtrace alternative and use it for musl targets #3641

Merged
merged 2 commits into from
Jan 16, 2021

Conversation

kinke
Copy link
Member

@kinke kinke commented Jan 10, 2021

@kinke kinke force-pushed the backtrace branch 5 times, most recently from b5b916b to 4cbc535 Compare January 12, 2021 20:11
@kinke kinke changed the title druntime: Integrate backtrace refactoring and fixes for libunwind druntime: Cherry-pick libunwind-based backtrace code and use it for musl targets Jan 13, 2021
@kinke kinke changed the title druntime: Cherry-pick libunwind-based backtrace code and use it for musl targets druntime: Cherry-pick libunwind-based backtrace alternative and use it for musl targets Jan 13, 2021
@Geod24
Copy link
Contributor

Geod24 commented Jan 14, 2021

Scanning dependencies of target druntime-ldc-unittest-debug
[ 74%] Building C object runtime/CMakeFiles/druntime-ldc-unittest-debug.dir/druntime/src/core/stdc/errno.c.o
[ 74%] Building C object runtime/CMakeFiles/druntime-ldc-unittest-debug.dir/druntime/src/ldc/arm_unwind.c.o
[ 74%] Building C object runtime/CMakeFiles/druntime-ldc-unittest-debug.dir/druntime/src/ldc/msvc.c.o
[ 74%] Building ASM object runtime/CMakeFiles/druntime-ldc-unittest-debug.dir/druntime/src/core/threadasm.S.o
[ 74%] Building ASM object runtime/CMakeFiles/druntime-ldc-unittest-debug.dir/druntime/src/ldc/eh_asm.S.o
[ 74%] Linking D static library ../lib/libdruntime-ldc-unittest-debug.a
[ 74%] Building C object runtime/CMakeFiles/phobos2-ldc-unittest-shared.dir/phobos/etc/c/zlib/inftrees.c.o
[ 74%] Built target druntime-ldc-unittest-debug
[ 74%] Building C object runtime/CMakeFiles/phobos2-ldc-unittest-shared.dir/phobos/etc/c/zlib/trees.c.o
[ 74%] Building C object runtime/CMakeFiles/phobos2-ldc-unittest-shared.dir/phobos/etc/c/zlib/uncompr.c.o
[ 74%] Building C object runtime/CMakeFiles/phobos2-ldc-unittest-shared.dir/phobos/etc/c/zlib/zutil.c.o
Scanning dependencies of target druntime-test-runner
[ 74%] Linking C executable druntime-test-runner
[ 74%] Linking C shared library ../lib/libphobos2-ldc-unittest-shared.so
/usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /home/effortman/projects/bpfk/docker-ldc/ldc/src/ldc/lib/libdruntime-ldc-unittest.a(handler.o): in function `_D4core8internal9backtrace7handler16LibunwindHandler6__ctorMFNbNimZCQCoQCmQCgQBzQBu':
handler.d:(.text._D4core8internal9backtrace7handler16LibunwindHandler6__ctorMFNbNimZCQCoQCmQCgQBzQBu+0x7b): undefined reference to `unw_getcontext'
/usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: handler.d:(.text._D4core8internal9backtrace7handler16LibunwindHandler6__ctorMFNbNimZCQCoQCmQCgQBzQBu+0x86): undefined reference to `unw_init_local'
/usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: handler.d:(.text._D4core8internal9backtrace7handler16LibunwindHandler6__ctorMFNbNimZCQCoQCmQCgQBzQBu+0xa4): undefined reference to `unw_step'
/usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: handler.d:(.text._D4core8internal9backtrace7handler16LibunwindHandler6__ctorMFNbNimZCQCoQCmQCgQBzQBu+0xf6): undefined reference to `unw_get_proc_name'
/usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: handler.d:(.text._D4core8internal9backtrace7handler16LibunwindHandler6__ctorMFNbNimZCQCoQCmQCgQBzQBu+0x126): undefined reference to `unw_get_proc_info'
/usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: handler.d:(.text._D4core8internal9backtrace7handler16LibunwindHandler6__ctorMFNbNimZCQCoQCmQCgQBzQBu+0x142): undefined reference to `unw_step'
collect2: error: ld returned 1 exit status
make[3]: *** [runtime/CMakeFiles/druntime-test-runner.dir/build.make:137: runtime/druntime-test-runner] Error 1
make[2]: *** [CMakeFiles/Makefile2:1200: runtime/CMakeFiles/druntime-test-runner.dir/all] Error 2
make[2]: *** Waiting for unfinished jobs....
[ 80%] Built target phobos2-ldc-unittest-shared
make[1]: *** [CMakeFiles/Makefile2:510: runtime/CMakeFiles/all-test-runners.dir/rule] Error 2
make: *** [Makefile:333: all-test-runners] Error 2

Fails to link, and I'm a bit puzzled why. It obviously checks out your branch link and the config file is minimally modified although in a relevant way.

@kinke
Copy link
Member Author

kinke commented Jan 14, 2021

Thx for checking - C_SYSTEM_LIBS (link) will most likely need to be specified manually for the CMake invocation for musl (adding -DC_SYSTEM_LIBS="unwind;m;pthread;rt;dl") unless you know of a way to detect musl in CMake.

@Geod24
Copy link
Contributor

Geod24 commented Jan 15, 2021

adding -DC_SYSTEM_LIBS="unwind;m;pthread;rt;dl"

This seems to have done the trick. Compilation has succeeded and I'm now running tests (but since I'm on Mac, it takes a while).

@Geod24
Copy link
Contributor

Geod24 commented Jan 15, 2021

All tests passed.

@kinke
Copy link
Member Author

kinke commented Jan 15, 2021

Btw, you could replace the ldc2.conf patch by providing -DADDITIONAL_DEFAULT_LDC_SWITCHES=' "-linker=bfd", "-link-defaultlib-shared"' in the CMake cmdline.

@kinke kinke merged commit 65b0fb8 into ldc-developers:master Jan 16, 2021
@kinke kinke deleted the backtrace branch January 16, 2021 13:02
@Geod24
Copy link
Contributor

Geod24 commented Jan 20, 2021

@kinke : Any plan for a second beta / a release date ?

@Geod24
Copy link
Contributor

Geod24 commented Jan 20, 2021

Btw, you could replace [...]

Good to know, thanks! I'll try to rework it when I update the package.

@kinke
Copy link
Member Author

kinke commented Jan 20, 2021

A 2nd beta isn't planned ATM (this being the only change from beta1); final release probably soon after v2.095.1.

algitbot pushed a commit to alpinelinux/aports that referenced this pull request Feb 22, 2021
The patches have been integrated upstream,
and the LDC maintainer suggested to get rid of the conf patch in:
ldc-developers/ldc#3641 (comment)
Additionally, the default EH mechanism has been switched to llvm-libunwind,
as libexecinfo is buggy and somemtimes leads to crashes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants