From c2cd83e7d85c11e6a33e1cde263eb2312566d535 Mon Sep 17 00:00:00 2001 From: Manuel M T Chakravarty Date: Thu, 17 Sep 2009 04:41:21 +0000 Subject: [PATCH] Fix build on Mac OS 10.6 (Snow Leopard) - We have -m32 as machine-dependent option for gcc for a 32 bit build - Like on OpenBSD, SL requires -fno-stack-protector to avoid triggering the stack smashing checks inserted by gcc by default on this platform. --- compiler/main/DriverPipeline.hs | 10 ++-------- compiler/main/DynFlags.hs | 14 ++++++++++++-- rts/ghc.mk | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index 1e342a0..c095abc 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -988,7 +988,8 @@ runPhase cc_phase _stop hsc_env _basename _suff input_fn get_output_fn maybe_loc -- Also useful for plain .c files, just in case GHC saw a -- -x c option. [ SysTools.Option "-x", if cc_phase `eqPhase` Ccpp - then SysTools.Option "c++" else SysTools.Option "c"] ++ + then SysTools.Option "c++" + else SysTools.Option "c"] ++ [ SysTools.FileOption "" input_fn , SysTools.Option "-o" , SysTools.FileOption "" output_fn @@ -1005,13 +1006,6 @@ runPhase cc_phase _stop hsc_env _basename _suff input_fn get_output_fn maybe_loc -- This is a temporary hack. ++ ["-mcpu=v9"] #endif -#if defined(darwin_TARGET_OS) && defined(i386_TARGET_ARCH) - -- By default, gcc on OS X will generate SSE - -- instructions, which need things 16-byte aligned, - -- but we don't 16-byte align things. Thus drop - -- back to generic i686 compatibility. Trac #2983. - ++ ["-march=i686"] -#endif ++ (if hcc && mangle then md_regd_c_flags else []) diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 850a306..46c9d20 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -2293,10 +2293,20 @@ machdepCCOpts _dflags -- -fomit-frame-pointer : *must* in .hc files; because we're stealing -- the fp (%ebp) for our register maps. = let n_regs = stolen_x86_regs _dflags - sta = opt_Static in - ( [ if sta then "-DDONT_WANT_WIN32_DLL_SUPPORT" else "" + ( +#if darwin_TARGET_OS + -- By default, gcc on OS X will generate SSE + -- instructions, which need things 16-byte aligned, + -- but we don't 16-byte align things. Thus drop + -- back to generic i686 compatibility. Trac #2983. + -- + -- Since Snow Leopard (10.6), gcc defaults to x86_64. + ["-march=i686", "-m32"], +#else + [ if opt_Static then "-DDONT_WANT_WIN32_DLL_SUPPORT" else "" ], +#endif [ "-fno-defer-pop", "-fomit-frame-pointer", -- we want -fno-builtin, because when gcc inlines diff --git a/rts/ghc.mk b/rts/ghc.mk index 9c33896..970adaa 100644 --- a/rts/ghc.mk +++ b/rts/ghc.mk @@ -191,7 +191,7 @@ rts_HC_OPTS += $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS)) rts_LD_OPTS += $(addprefix -optl, $(MACOSX_DEPLOYMENT_LD_OPTS)) # Otherwise the stack-smash handler gets triggered. -ifeq "$(TargetOS_CPP)" "openbsd" +ifneq "$(findstring $(TargetOS_CPP), darwin openbsd)" "" rts_HC_OPTS += -optc-fno-stack-protector endif -- 1.7.10.4