[Git][ghc/ghc][master] driver: fix wasm backend sysroot lookup logic when -flto is passed

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Sat Feb 22 12:41:58 UTC 2025



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
7eea38c8 by Cheng Shao at 2025-02-22T07:41:37-05:00
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.

- - - - -


1 changed file:

- compiler/GHC.hs


Changes:

=====================================
compiler/GHC.hs
=====================================
@@ -717,11 +717,7 @@ setTopSessionDynFlags dflags = do
 #if defined(wasm32_HOST_ARCH)
         let libdir = sorry "cannot spawn child process on wasm"
 #else
-        libdir <- liftIO $ do
-          libdirs <- Loader.getGccSearchDirectory logger dflags "libraries"
-          case libdirs of
-            [_, libdir] -> pure libdir
-            _ -> panic "corrupted wasi-sdk installation"
+        libdir <- liftIO $ last <$> Loader.getGccSearchDirectory logger dflags "libraries"
 #endif
         let profiled = ways dflags `hasWay` WayProf
             way_tag = if profiled then "_p" else ""



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7eea38c838c9d839e9efea0e6d9f79034e99fa4f

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7eea38c838c9d839e9efea0e6d9f79034e99fa4f
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20250222/c0316f4c/attachment-0001.html>


More information about the ghc-commits mailing list