[commit: ghc] ghc-8.2: Ensure that we always link against libm (71797e5)

git at git.haskell.org git at git.haskell.org
Fri Aug 25 19:11:56 UTC 2017


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

On branch  : ghc-8.2
Link       : http://ghc.haskell.org/trac/ghc/changeset/71797e5ec7376247dd1c85e442d0529d88eb4286/ghc

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

commit 71797e5ec7376247dd1c85e442d0529d88eb4286
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
    
    (cherry picked from commit 0e3c10160472df082fd3decd98c2489a2f8e68bd)


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

71797e5ec7376247dd1c85e442d0529d88eb4286
 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 df1ffd5..5accdcb 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -1919,6 +1919,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 fd3faf1..5601e2a 100644
--- a/compiler/main/SysTools.hs
+++ b/compiler/main/SysTools.hs
@@ -45,6 +45,9 @@ module SysTools (
 
         Option(..),
 
+        -- platform-specifics
+        libmLinkOpts,
+
         -- frameworks
         getPkgFrameworkOpts,
         getFrameworkOpts
@@ -1736,6 +1739,7 @@ linkDynLib dflags0 o_files dep_packages
 
             runLink dflags (
                     map Option verbFlags
+                 ++ libmLinkOpts
                  ++ [ Option "-o"
                     , FileOption "" output_fn
                     ]
@@ -1755,6 +1759,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