Don't use getPackageLinkOpts on iOS; fixes #7720.
authorIan Lynagh <ian@well-typed.com>
Sat, 27 Apr 2013 11:45:04 +0000 (12:45 +0100)
committerIan Lynagh <ian@well-typed.com>
Sat, 27 Apr 2013 12:11:03 +0000 (13:11 +0100)
On iOS, binaries are really static libraries, so we don't want to use
flags like -lm when linking them.

compiler/main/DriverPipeline.hs
compiler/utils/Platform.hs

index 1328ffe..6c4bff9 100644 (file)
@@ -1819,7 +1819,13 @@ linkBinary dflags o_files dep_packages = do
     extraLinkObj <- mkExtraObjToLinkIntoBinary dflags
     noteLinkObjs <- mkNoteObjsToLinkIntoBinary dflags dep_packages
 
-    pkg_link_opts <- getPackageLinkOpts dflags dep_packages
+    pkg_link_opts <- if platformBinariesAreStaticLibs platform
+                     then -- If building an executable really means
+                          -- making a static library (e.g. iOS), then
+                          -- we don't want the options (like -lm)
+                          -- that getPackageLinkOpts gives us. #7720
+                          return []
+                     else getPackageLinkOpts dflags dep_packages
 
     pkg_framework_path_opts <-
         if platformUsesFrameworks platform
index 213a63e..617e691 100644 (file)
@@ -13,6 +13,7 @@ module Platform (
         isARM,
         osElfTarget,
         platformUsesFrameworks,
+        platformBinariesAreStaticLibs,
 )
 
 where
@@ -135,3 +136,10 @@ osUsesFrameworks _        = False
 platformUsesFrameworks :: Platform -> Bool
 platformUsesFrameworks = osUsesFrameworks . platformOS
 
+osBinariesAreStaticLibs :: OS -> Bool
+osBinariesAreStaticLibs OSiOS = True
+osBinariesAreStaticLibs _     = False
+
+platformBinariesAreStaticLibs :: Platform -> Bool
+platformBinariesAreStaticLibs = osBinariesAreStaticLibs . platformOS
+