https://github.com/arichardson created https://github.com/llvm/llvm-project/pull/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 >From 6f459b7cf539c17192e765578ac9f938e4f3af3f Mon Sep 17 00:00:00 2001 From: Alex Richardson <alexrichard...@google.com> Date: Fri, 22 Sep 2023 16:11:49 -0700 Subject: [PATCH] [libunwind] Pass -Wl,--export-dynamic on all supported platforms 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 --- libunwind/test/configs/llvm-libunwind-merged.cfg.in | 6 ++++-- libunwind/test/configs/llvm-libunwind-shared.cfg.in | 6 ++++-- libunwind/test/configs/llvm-libunwind-static.cfg.in | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/libunwind/test/configs/llvm-libunwind-merged.cfg.in b/libunwind/test/configs/llvm-libunwind-merged.cfg.in index 10650f7edf66a2f..e6fafd1edd9756f 100644 --- a/libunwind/test/configs/llvm-libunwind-merged.cfg.in +++ b/libunwind/test/configs/llvm-libunwind-merged.cfg.in @@ -11,8 +11,10 @@ link_flags = [] if @LIBUNWIND_ENABLE_CET@: compile_flags.append('-fcf-protection=full') -if '@CMAKE_SYSTEM_NAME@' == 'Linux': - link_flags.append('-Wl,--export-dynamic') +# Add -Wl,--export-dynamic if supported by the linker (this CMake variable will +# be empty for Apple platforms). +if len('@CMAKE_EXE_EXPORTS_CXX_FLAG@'): + link_flags.append('@CMAKE_EXE_EXPORTS_CXX_FLAG@') if '@CMAKE_DL_LIBS@': link_flags.append('-l@CMAKE_DL_LIBS@') diff --git a/libunwind/test/configs/llvm-libunwind-shared.cfg.in b/libunwind/test/configs/llvm-libunwind-shared.cfg.in index 97185e57234ff7f..f2e98c7a388dd32 100644 --- a/libunwind/test/configs/llvm-libunwind-shared.cfg.in +++ b/libunwind/test/configs/llvm-libunwind-shared.cfg.in @@ -10,8 +10,10 @@ link_flags = [] if @LIBUNWIND_ENABLE_CET@: compile_flags.append('-fcf-protection=full') -if '@CMAKE_SYSTEM_NAME@' == 'Linux': - link_flags.append('-Wl,--export-dynamic') +# Add -Wl,--export-dynamic if supported by the linker (this CMake variable will +# be empty for Apple platforms). +if len('@CMAKE_EXE_EXPORTS_CXX_FLAG@'): + link_flags.append('@CMAKE_EXE_EXPORTS_CXX_FLAG@') if '@CMAKE_DL_LIBS@': link_flags.append('-l@CMAKE_DL_LIBS@') diff --git a/libunwind/test/configs/llvm-libunwind-static.cfg.in b/libunwind/test/configs/llvm-libunwind-static.cfg.in index fc6a18d057f3884..1fbdec249855d4a 100644 --- a/libunwind/test/configs/llvm-libunwind-static.cfg.in +++ b/libunwind/test/configs/llvm-libunwind-static.cfg.in @@ -13,8 +13,10 @@ if @LIBUNWIND_ENABLE_THREADS@: if @LIBUNWIND_ENABLE_CET@: compile_flags.append('-fcf-protection=full') -if '@CMAKE_SYSTEM_NAME@' == 'Linux': - link_flags.append('-Wl,--export-dynamic') +# Add -Wl,--export-dynamic if supported by the linker (this CMake variable will +# be empty for Apple platforms). +if len('@CMAKE_EXE_EXPORTS_CXX_FLAG@'): + link_flags.append('@CMAKE_EXE_EXPORTS_CXX_FLAG@') if '@CMAKE_DL_LIBS@': link_flags.append('-l@CMAKE_DL_LIBS@') _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits