From 60873542e8edf0ee593fde2b6544770d8036728f Mon Sep 17 00:00:00 2001 From: David Terei Date: Fri, 13 Aug 2010 19:15:34 +0000 Subject: [PATCH] LLVM: Enable shared lib support on Linux x64 --- compiler/main/DriverPipeline.hs | 6 +++++- compiler/main/DynFlags.hs | 13 +++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index 113348f..af6849f 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -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) diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 85554cb..da1e4c7 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -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) -- 1.7.10.4