[commit: ghc] master: Ensure that we always link against libm (0e3c101)

git at git.haskell.org git at git.haskell.org
Sat Jul 29 14:34:30 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/0e3c10160472df082fd3decd98c2489a2f8e68bd/ghc

>---------------------------------------------------------------

commit 0e3c10160472df082fd3decd98c2489a2f8e68bd
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Fri Jul 28 13:41:04 2017 -0400

    Ensure that we always link against libm
    
    ld.gold is particularly picky that we declare all of our link
    dependencies on Nix. See #14022.
    
    Test Plan: Validate on Nix
    
    Reviewers: austin
    
    Subscribers: hvr, rwbarton, thomie
    
    GHC Trac Issues: #14022
    
    Differential Revision: https://phabricator.haskell.org/D3787


>---------------------------------------------------------------

0e3c10160472df082fd3decd98c2489a2f8e68bd
 compiler/main/DriverPipeline.hs |  1 +
 compiler/main/SysTools.hs       | 14 ++++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index 3fc35e5..7f70377 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -1932,6 +1932,7 @@ linkBinary' staticLink dflags o_files dep_packages = do
                       ++ [ SysTools.Option "-o"
                          , SysTools.FileOption "" output_fn
                          ]
+                      ++ libmLinkOpts
                       ++ map SysTools.Option (
                          []
 
diff --git a/compiler/main/SysTools.hs b/compiler/main/SysTools.hs
index 3d16124..c73e47c 100644
--- a/compiler/main/SysTools.hs
+++ b/compiler/main/SysTools.hs
@@ -39,6 +39,9 @@ module SysTools (
 
         Option(..),
 
+        -- platform-specifics
+        libmLinkOpts,
+
         -- frameworks
         getPkgFrameworkOpts,
         getFrameworkOpts
@@ -1537,6 +1540,7 @@ linkDynLib dflags0 o_files dep_packages
 
             runLink dflags (
                     map Option verbFlags
+                 ++ libmLinkOpts
                  ++ [ Option "-o"
                     , FileOption "" output_fn
                     ]
@@ -1556,6 +1560,16 @@ linkDynLib dflags0 o_files dep_packages
                  ++ map Option pkg_link_opts
               )
 
+-- | Some platforms require that we explicitly link against @libm@ if any
+-- math-y things are used (which we assume to include all programs). See #14022.
+libmLinkOpts :: [Option]
+libmLinkOpts =
+#if defined(HAVE_LIBM)
+  [Option "-lm"]
+#else
+  []
+#endif
+
 getPkgFrameworkOpts :: DynFlags -> Platform -> [InstalledUnitId] -> IO [String]
 getPkgFrameworkOpts dflags platform dep_packages
   | platformUsesFrameworks platform = do



More information about the ghc-commits mailing list