fix: robust linking of cyclically dependent libraries
This commit is contained in:
parent
b0e8183663
commit
fe03e70a8a
2 changed files with 9 additions and 3 deletions
|
|
@ -311,6 +311,14 @@ find_package(PythonInterp)
|
|||
|
||||
include_directories(${CMAKE_BINARY_DIR}/include)
|
||||
|
||||
# libleancpp and the stdlib libraries are cyclically dependent. This works by default on macOS, which also doesn't like
|
||||
# the linker flags necessary on other platforms.
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
set(LEANC_STATIC_LINKER_FLAGS "-lleancpp" "-lInit" "-lStd" "-lLean")
|
||||
else()
|
||||
set(LEANC_STATIC_LINKER_FLAGS "-Wl,--start-group" "-lleancpp" "-lInit" "-lStd" "-lLean" "-Wl,--end-group")
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
set(LEANC_SHARED_LINKER_FLAGS "${LEANC_SHARED_LINKER_FLAGS} -fPIC")
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -16,9 +16,7 @@ bindir=$(dirname $0)
|
|||
|
||||
cflags=("-I$bindir/../include")
|
||||
ldflags=("-L$bindir/../lib/lean" "-lgmp" @LEANC_EXTRA_FLAGS@)
|
||||
# static linker flags
|
||||
# NOTE: libleancpp and libInit are cyclically dependent
|
||||
ldflags_ext=("-lleancpp" "-lInit" "-lStd" "-lLean" "-lleancpp" "-lInit" "-lStd" "-lLean" "-lStd")
|
||||
ldflags_ext=(@LEANC_STATIC_LINKER_FLAGS@)
|
||||
for arg in "$@"; do
|
||||
# passed -shared ~> switch to shared linker flags
|
||||
[[ $arg == "-shared" ]] && ldflags_ext=(@LEANC_SHARED_LINKER_FLAGS@)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue