- ++ [ SysTools.Option "-c"
- , SysTools.FileOption "" input_fn
- , SysTools.Option "-o"
- , SysTools.FileOption "" output_fn
- ])
-
- return (StopLn, dflags, maybe_loc, output_fn)
-
-
-runPhase SplitAs stop dflags basename _suff _input_fn get_output_fn maybe_loc
- = do
- output_fn <- get_output_fn dflags StopLn maybe_loc
-
- let (base_o, _) = splitFilename output_fn
- split_odir = base_o ++ "_split"
- osuf = objectSuf dflags
-
- createDirectoryHierarchy split_odir
-
- -- remove M_split/ *.o, because we're going to archive M_split/ *.o
- -- later and we don't want to pick up any old objects.
- fs <- getDirectoryContents split_odir
- mapM_ removeFile $ map (split_odir `joinFileName`)
- $ filter (osuf `isSuffixOf`) fs
-
- let as_opts = getOpts dflags opt_a
-
- (split_s_prefix, n) <- readIORef v_Split_info
-
- let split_s n = split_s_prefix ++ "__" ++ show n `joinFileExt` "s"
- split_obj n = split_odir `joinFileName`
- filenameOf base_o ++ "__" ++ show n
- `joinFileExt` osuf
-
- let assemble_file n
- = SysTools.runAs dflags
- (map SysTools.Option as_opts ++
- [ SysTools.Option "-c"
- , SysTools.Option "-o"
- , SysTools.FileOption "" (split_obj n)
- , SysTools.FileOption "" (split_s n)
- ])
-
- mapM_ assemble_file [1..n]
-
- -- and join the split objects into a single object file:
- let ld_r args = SysTools.runLink dflags ([
- SysTools.Option "-nostdlib",
- SysTools.Option "-nodefaultlibs",
- SysTools.Option "-Wl,-r",
- SysTools.Option ld_x_flag,
- SysTools.Option "-o",
- SysTools.FileOption "" output_fn ] ++ args)
+ ++ [ SysTools.Option "-c"
+ , SysTools.FileOption "" input_fn
+ , SysTools.Option "-o"
+ , SysTools.FileOption "" output_fn
+ ]
+ ++ map SysTools.Option md_c_flags)
+
+ return (StopLn, dflags, maybe_loc, output_fn)
+
+
+runPhase SplitAs _stop hsc_env _basename _suff _input_fn get_output_fn maybe_loc
+ = liftIO $ do
+ let dflags = hsc_dflags hsc_env
+ output_fn <- get_output_fn dflags StopLn maybe_loc
+
+ let base_o = dropExtension output_fn
+ osuf = objectSuf dflags
+ split_odir = base_o ++ "_" ++ osuf ++ "_split"
+
+ createDirectoryHierarchy split_odir
+
+ -- remove M_split/ *.o, because we're going to archive M_split/ *.o
+ -- later and we don't want to pick up any old objects.
+ fs <- getDirectoryContents split_odir
+ mapM_ removeFile $ map (split_odir </>) $ filter (osuf `isSuffixOf`) fs
+
+ let as_opts = getOpts dflags opt_a
+
+ let (split_s_prefix, n) = case splitInfo dflags of
+ Nothing -> panic "No split info"
+ Just x -> x
+
+ let split_s n = split_s_prefix ++ "__" ++ show n <.> "s"
+ split_obj n = split_odir </>
+ takeFileName base_o ++ "__" ++ show n <.> osuf
+
+ let (md_c_flags, _) = machdepCCOpts dflags
+ let assemble_file n
+ = SysTools.runAs dflags
+ (map SysTools.Option as_opts ++
+#ifdef sparc_TARGET_ARCH
+ -- We only support SparcV9 and better because V8 lacks an atomic CAS
+ -- instruction so we have to make sure that the assembler accepts the
+ -- instruction set. Note that the user can still override this
+ -- (e.g., -mcpu=ultrasparc). GCC picks the "best" -mcpu flag
+ -- regardless of the ordering.
+ --
+ -- This is a temporary hack.
+ [ SysTools.Option "-mcpu=v9" ] ++
+#endif
+ [ SysTools.Option "-c"
+ , SysTools.Option "-o"
+ , SysTools.FileOption "" (split_obj n)
+ , SysTools.FileOption "" (split_s n)
+ ]
+ ++ map SysTools.Option md_c_flags)
+
+ mapM_ assemble_file [1..n]
+
+ -- and join the split objects into a single object file:
+ let ld_r args = SysTools.runLink dflags ([
+ SysTools.Option "-nostdlib",
+ SysTools.Option "-nodefaultlibs",
+ SysTools.Option "-Wl,-r",
+ SysTools.Option ld_x_flag,
+ SysTools.Option "-o",
+ SysTools.FileOption "" output_fn ]
+ ++ map SysTools.Option md_c_flags
+ ++ args)