Skip to content

Commit dae7e2d

Browse files
authored
[libunwind] Pass -Wl,--export-dynamic on all supported platforms (llvm#67205)
I was trying to run the tests on FreeBSD and noticed that we weren't printing symbol names. It turns out this is because of the missing -Wl,--export-dynamic flag. Instead of hardcoding the name of the flag and only passing it for Linux hosts, use a pre-existing CMake variable instead. I was not aware of this flag, but it appears to have been supported for the past 16 years (with support for more platforms added later): https://gitlab.kitware.com/cmake/cmake/-/commit/66d1930f5674f08e09f455b3f0777f2de3e0717e
1 parent 2f23666 commit dae7e2d

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

libunwind/test/configs/llvm-libunwind-merged.cfg.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ link_flags = []
1111
if @LIBUNWIND_ENABLE_CET@:
1212
compile_flags.append('-fcf-protection=full')
1313

14-
if '@CMAKE_SYSTEM_NAME@' == 'Linux':
15-
link_flags.append('-Wl,--export-dynamic')
14+
# On ELF platforms, add -Wl,--export-dynamic if supported by the linker.
15+
if len('@CMAKE_EXE_EXPORTS_CXX_FLAG@'):
16+
link_flags.append('@CMAKE_EXE_EXPORTS_CXX_FLAG@')
1617

1718
if '@CMAKE_DL_LIBS@':
1819
link_flags.append('-l@CMAKE_DL_LIBS@')

libunwind/test/configs/llvm-libunwind-shared.cfg.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ link_flags = []
1010
if @LIBUNWIND_ENABLE_CET@:
1111
compile_flags.append('-fcf-protection=full')
1212

13-
if '@CMAKE_SYSTEM_NAME@' == 'Linux':
14-
link_flags.append('-Wl,--export-dynamic')
13+
# On ELF platforms, add -Wl,--export-dynamic if supported by the linker.
14+
if len('@CMAKE_EXE_EXPORTS_CXX_FLAG@'):
15+
link_flags.append('@CMAKE_EXE_EXPORTS_CXX_FLAG@')
1516

1617
if '@CMAKE_DL_LIBS@':
1718
link_flags.append('-l@CMAKE_DL_LIBS@')

libunwind/test/configs/llvm-libunwind-static.cfg.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ if @LIBUNWIND_ENABLE_THREADS@:
1313
if @LIBUNWIND_ENABLE_CET@:
1414
compile_flags.append('-fcf-protection=full')
1515

16-
if '@CMAKE_SYSTEM_NAME@' == 'Linux':
17-
link_flags.append('-Wl,--export-dynamic')
16+
# On ELF platforms, add -Wl,--export-dynamic if supported by the linker.
17+
if len('@CMAKE_EXE_EXPORTS_CXX_FLAG@'):
18+
link_flags.append('@CMAKE_EXE_EXPORTS_CXX_FLAG@')
1819

1920
if '@CMAKE_DL_LIBS@':
2021
link_flags.append('-l@CMAKE_DL_LIBS@')

0 commit comments

Comments
 (0)