LLVM: Enable shared lib support on Linux x64
authorDavid Terei <davidterei@gmail.com>
Fri, 13 Aug 2010 19:15:34 +0000 (19:15 +0000)
committerDavid Terei <davidterei@gmail.com>
Fri, 13 Aug 2010 19:15:34 +0000 (19:15 +0000)
compiler/main/DriverPipeline.hs
compiler/main/DynFlags.hs

index 113348f..af6849f 100644 (file)
@@ -38,7 +38,7 @@ import Module
 import UniqFM           ( eltsUFM )
 import ErrUtils
 import DynFlags
-import StaticFlags      ( v_Ld_inputs, opt_Static, WayName(..) )
+import StaticFlags      ( v_Ld_inputs, opt_PIC, opt_Static, WayName(..) )
 import Config
 import Panic
 import Util
@@ -1289,11 +1289,15 @@ runPhase LlvmLlc _stop hsc_env _basename _suff input_fn get_output_fn maybe_loc
 #else
     let nphase = As
 #endif
+    let rmodel | opt_PIC        = "pic"
+               | not opt_Static = "dynamic-no-pic"
+               | otherwise      = "static"
 
     output_fn <- get_output_fn dflags nphase maybe_loc
 
     SysTools.runLlvmLlc dflags
                 ([ SysTools.Option (llvmOpts !! opt_lvl),
+                    SysTools.Option $ "-relocation-model=" ++ rmodel,
                     SysTools.FileOption "" input_fn,
                     SysTools.Option "-o", SysTools.FileOption "" output_fn]
                 ++ map SysTools.Option lc_opts)
index 85554cb..da1e4c7 100644 (file)
@@ -1934,11 +1934,16 @@ parseDynamicFlags_ dflags0 args pkg_flags = do
   -- unless there is no NCG on this platform.  The latter case is
   -- checked when the -fPIC flag is parsed.
   --
-  let (pic_warns, dflags2) =
-        if opt_PIC && hscTarget dflags1 == HscC && cGhcUnregisterised == "NO"
-          then ([L noSrcSpan $ "Warning: -fvia-C is incompatible with -fPIC; ignoring -fvia-C"],
+  let (pic_warns, dflags2)
+        | opt_PIC && hscTarget dflags1 == HscC && cGhcUnregisterised == "NO"
+        = ([L noSrcSpan $ "Warning: -fvia-C is incompatible with -fPIC; ignoring -fvia-C"],
                 dflags1{ hscTarget = HscAsm })
-          else ([], dflags1)
+#if !(x86_64_TARGET_ARCH && linux_TARGET_OS)
+        | (not opt_Static || opt_PIC) && hscTarget dflags1 == HscLlvm
+        = ([L noSrcSpan $ "Warning: -fllvm is incompatible with -fPIC and -dynamic on this"
+                ++ "platform; ignoring -fllvm"], dflags1{ hscTarget = HscAsm })
+#endif
+        | otherwise = ([], dflags1)
 
   return (dflags2, leftover, pic_warns ++ warns)