summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorBen Gamari <ben@well-typed.com>2022-05-19 16:38:25 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-07-16 23:50:36 -0400
commit5781a36022bd1f1e7344d3f6530c163dd2587e78 (patch)
tree0e461260b6cb5d74a34fa49acad3b489adaecf08 /m4
parent2cd75550cad93b84a4ef831c5dc8f40071c3a903 (diff)
downloadhaskell-5781a36022bd1f1e7344d3f6530c163dd2587e78.tar.gz
Statically-link against libc++ on Windows
Unfortunately on Windows we have no RPATH-like facility, making dynamic linking extremely fragile. Since we cannot assume that the user will add their GHC installation to `$PATH` (and therefore their DLL search path) we cannot assume that the loader will be able to locate our `libc++.dll`. To avoid this, we instead statically link against `libc++.a` on Windows. Fixes #21435.
Diffstat (limited to 'm4')
-rw-r--r--m4/fp_setup_windows_toolchain.m47
1 files changed, 7 insertions, 0 deletions
diff --git a/m4/fp_setup_windows_toolchain.m4 b/m4/fp_setup_windows_toolchain.m4
index 15b85b2bb2..e1a2244c37 100644
--- a/m4/fp_setup_windows_toolchain.m4
+++ b/m4/fp_setup_windows_toolchain.m4
@@ -78,6 +78,7 @@ AC_DEFUN([FP_SETUP_WINDOWS_TOOLCHAIN],[
# for the runtime, libc++ and libc++abi for the C++ standard library
# implementation, and libunwind for C++ unwinding.
mingwbin="$hardtop/inplace/mingw/bin/"
+ mingwlib="$hardtop/inplace/mingw/lib/"
CC="${mingwbin}clang.exe"
CXX="${mingwbin}clang++.exe"
@@ -94,6 +95,12 @@ AC_DEFUN([FP_SETUP_WINDOWS_TOOLCHAIN],[
CONF_GCC_LINKER_OPTS_STAGE1="-fuse-ld=lld $cflags"
CONF_GCC_LINKER_OPTS_STAGE2="-fuse-ld=lld $cflags"
+ # N.BOn Windows we can't easily dynamically-link against libc++ since there is
+ # no RPATH support, meaning that the loader will have no way of finding our
+ # libc++.dll
+ CXX_STD_LIB_LIBS=":libc++.a :libc++abi.a"
+ CXX_STD_LIB_LIB_DIRS="\$topdir"
+
LD="${mingwbin}ld.lld.exe"
NM="${mingwbin}llvm-nm.exe"
AR="${mingwbin}llvm-ar.exe"