[Git][ghc/ghc][master] Fix linking against libm by moving the -lm option
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 016fa306 by Samuel Thibault at 2026-02-18T05:08:35-05:00 Fix linking against libm by moving the -lm option For those systems that need -lm for getting math functions, this is currently added on the link line very early, before the object files being linked together. Newer toolchains enable --as-needed by default, which means -lm is ignored at that point because no object requires a math function yet. With such toolchains, we thus have to add -lm after the objects, so the linker actually includes libm in the link. - - - - - 1 changed file: - compiler/GHC/Linker/Dynamic.hs Changes: ===================================== compiler/GHC/Linker/Dynamic.hs ===================================== @@ -227,7 +227,6 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages runLink logger tmpfs linker_config ( map Option verbFlags - ++ libmLinkOpts platform ++ [ Option "-o" , FileOption "" output_fn ] @@ -260,6 +259,7 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages -- driver is a more pragmatic solution. ++ [ Option "-Wl,--Bsymbolic,--experimental-pic,--unresolved-symbols=import-dynamic" | arch == ArchWasm32 ] ++ extra_ld_inputs + ++ libmLinkOpts platform ++ map Option lib_path_opts ++ map Option pkg_lib_path_opts ++ map Option pkg_link_opts View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/016fa306cd8afdaac56ebdebe44a4472... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/016fa306cd8afdaac56ebdebe44a4472... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)