From 431e40e1a2f795d5069d97661b7cd55f3e3b05bf Mon Sep 17 00:00:00 2001 From: Duncan Coutts Date: Fri, 1 May 2009 12:14:45 +0000 Subject: [PATCH] Make ghc -dynamic imply -fPIC for C code As is already the case for ghc -fPIC. This is needed because ghc -dynamic means to generate code that is capable of being linked to Haskell shared libs and for C code the equivalent is -fPIC. Normally C code does not need -fPIC merely to link to shared libs however Haskell shared libs do not follow common conventions. In particular the static data cannot be referenced statically because it cannot be copied by the static linker. The linker cannot copy them because we do not specify a .size for the _closure entries (in the .data section) though in principle we could. --- compiler/main/DynFlags.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 2c6163c..8bf069c 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -72,7 +72,7 @@ import PackageConfig import PrelNames ( mAIN, main_RDR_Unqual ) import RdrName ( RdrName, mkRdrUnqual ) import OccName ( mkVarOccFS ) -#ifdef i386_TARGET_ARCH +#if defined(i386_TARGET_ARCH) || ! defined(mingw32_TARGET_OS) import StaticFlags ( opt_Static ) #endif import StaticFlags ( opt_PIC, WayName(..), v_Ways, v_Build_tag, @@ -2305,7 +2305,7 @@ picCCOpts _dflags | otherwise = [] #else - | opt_PIC + | opt_PIC || not opt_Static = ["-fPIC", "-U __PIC__", "-D__PIC__"] | otherwise = [] -- 1.7.10.4