Skip to content
Snippets Groups Projects
Commit 7eea38c8 authored by Cheng Shao's avatar Cheng Shao Committed by Marge Bot
Browse files

driver: fix wasm backend sysroot lookup logic when -flto is passed

For the wasm target, the driver calls `wasm32-wasi-clang
--print-search-dirs` and finds the sysroot directory that contains
libc.so etc, then passes the directory path to dyld. However, when GHC
is configured with -flto as a part of C/C++ compiler flags, the clang
driver would insert a llvm-lto specific directory in the
--print-search-dirs output and the driver didn't take that into
account. This patch fixes it and always selects the non-lto sysroot
directory to be passed to dyld. This is one small step towards
supporting building all cbits with lto for wasm.
parent cb60da24
No related branches found
No related tags found
No related merge requests found
...@@ -717,11 +717,7 @@ setTopSessionDynFlags dflags = do ...@@ -717,11 +717,7 @@ setTopSessionDynFlags dflags = do
#if defined(wasm32_HOST_ARCH) #if defined(wasm32_HOST_ARCH)
let libdir = sorry "cannot spawn child process on wasm" let libdir = sorry "cannot spawn child process on wasm"
#else #else
libdir <- liftIO $ do libdir <- liftIO $ last <$> Loader.getGccSearchDirectory logger dflags "libraries"
libdirs <- Loader.getGccSearchDirectory logger dflags "libraries"
case libdirs of
[_, libdir] -> pure libdir
_ -> panic "corrupted wasi-sdk installation"
#endif #endif
let profiled = ways dflags `hasWay` WayProf let profiled = ways dflags `hasWay` WayProf
way_tag = if profiled then "_p" else "" way_tag = if profiled then "_p" else ""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment