From d9337fa39cd6282b9e33a43539e51ce80677dbb3 Mon Sep 17 00:00:00 2001 From: Sebastian Ullrich Date: Thu, 22 Jul 2021 16:10:01 +0200 Subject: [PATCH] chore: fix multiple definitions on Windows --- src/CMakeLists.txt | 3 +-- src/bin/leanc.in | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9cf58e9bcd..52c0f1cb16 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -321,8 +321,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") set(LEANC_SHARED_LINKER_FLAGS "${LEANC_SHARED_LINKER_FLAGS} -Wl,--export-all") set(LEANSHARED_LINKER_FLAGS "${LEANSHARED_LINKER_FLAGS} -Wl,--export-all") else() - set(LEANC_STATIC_LINKER_FLAGS "${LEANC_STATIC_LINKER_FLAGS} -ldl") - set(LEANC_SHARED_LINKER_FLAGS "${LEANC_SHARED_LINKER_FLAGS} -ldl") + set(LEANC_EXTRA_FLAGS "${LEANC_EXTRA_FLAGS} -ldl") endif() # On Windows, add bcrypt for random number generation diff --git a/src/bin/leanc.in b/src/bin/leanc.in index 3212193b60..ed51f1b4ff 100755 --- a/src/bin/leanc.in +++ b/src/bin/leanc.in @@ -23,6 +23,8 @@ args=("$@") for arg in "$@"; do # passed -shared ~> switch to shared linker flags [[ $arg == "-shared" ]] && ldflags_ext=(@LEANC_SHARED_LINKER_FLAGS@) && args=("-x" "c" "$@" "-x" "none") + # linking against libleanshared explicitly ~> do not link against static stdlib + [[ $arg == "-lleanshared" ]] && ldflags_ext=() # Note the `-x c` for treating all input as C code [[ $arg == "-c" ]] && ldflags=() && ldflags_ext=() && args=("-x" "c" "$@" "-x" "none") [[ $arg == "--print-cflags" ]] && echo "${cflags[@]}" && exit