Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 05b5e35

Browse files
committed
Merging r326358: Fix libexecinfo detection on FreeBSD and NetBSD.
------------------------------------------------------------------------ r326358 | dim | 2018-02-28 12:04:21 -0800 (Wed, 28 Feb 2018) | 29 lines Changed paths: M /llvm/trunk/lib/Support/CMakeLists.txt Fix llvm-config --system-libs output on FreeBSD and NetBSD Summary: For various reasons, CMake's detection mechanism for `backtrace()` returns an absolute path `/usr/lib/libexecinfo.so` on FreeBSD and NetBSD. Since `tools/llvm-config/CMakeLists.txt` only checks if system libraries start with `-`, this causes `llvm-config --system-libs` to produce the following incorrect output: ``` -lrt -l/usr/lib/libexecinfo.so -ltinfo -lpthread -lz -lm ``` Fix it by removing the path and the `lib` prefix, to make it look like a regular short library name, suitable for appending to a `-l` link flag. This also fixes the `Bindings/Go/go.test` test case, since that always died with "unable to find library -l/usr/lib/libexecinfo.so". Reviewers: chandlerc, emaste, joerg, krytarowski Reviewed By: krytarowski Subscribers: hans, bdrewery, mgorny, hintonda, llvm-commits Differential Revision: https://reviews.llvm.org/D42702 ------------------------------------------------------------------------
1 parent 9f81bea commit 05b5e35

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/Support/CMakeLists.txt

+7-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ elseif( CMAKE_HOST_UNIX )
1212
if( HAVE_LIBDL )
1313
set(system_libs ${system_libs} ${CMAKE_DL_LIBS})
1414
endif()
15-
if( HAVE_BACKTRACE )
16-
set(system_libs ${system_libs} ${Backtrace_LIBRARIES})
15+
if( HAVE_BACKTRACE AND NOT "${Backtrace_LIBRARIES}" STREQUAL "" )
16+
# On BSDs, CMake returns a fully qualified path to the backtrace library.
17+
# We need to remove the path and the 'lib' prefix, to make it look like a
18+
# regular short library name, suitable for appending to a -l link flag.
19+
get_filename_component(Backtrace_LIBFILE ${Backtrace_LIBRARIES} NAME_WE)
20+
STRING(REGEX REPLACE "^lib" "" Backtrace_LIBFILE ${Backtrace_LIBFILE})
21+
set(system_libs ${system_libs} ${Backtrace_LIBFILE})
1722
endif()
1823
if(LLVM_ENABLE_TERMINFO)
1924
if(HAVE_TERMINFO)

0 commit comments

Comments
 (0)