Fix build on Mac OS 10.6 (Snow Leopard)
authorManuel M T Chakravarty <chak@cse.unsw.edu.au>
Thu, 17 Sep 2009 04:41:21 +0000 (04:41 +0000)
committerManuel M T Chakravarty <chak@cse.unsw.edu.au>
Thu, 17 Sep 2009 04:41:21 +0000 (04:41 +0000)
- 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
compiler/main/DynFlags.hs
rts/ghc.mk

index 1e342a0..c095abc 100644 (file)
@@ -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 [])
index 850a306..46c9d20 100644 (file)
@@ -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
index 9c33896..970adaa 100644 (file)
@@ -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