summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik de Castro Lopo <erikd@mega-nerd.com>2016-03-13 15:28:11 +1100
committerErik de Castro Lopo <erikd@mega-nerd.com>2016-03-17 07:43:09 +1100
commit46f9a476e17714e27d893b491cc0dcf68c745249 (patch)
tree58d1da65acc2a712e76fe8f2f52d29cb7bf36e39
parent5d98b8bf249fab9bb0be6c5d4e8ddd4578994abb (diff)
downloadhaskell-46f9a476e17714e27d893b491cc0dcf68c745249.tar.gz
DriverPipeline: Fix 'unused arguments' warnings from Clang
When using Clang as the C compiler, over 100 tests were failing due to Clang reporting that some command line arguments were not being used. These warnings only occur when Clang is compiling assembler files which happens in two places, one of which already conditionally adding `-Qunused-arguments` to the command line when the compiler was Clang. This fixes the other. Test Plan: validate with clang as the C compiler Reviewers: bgamari, hvr, austin, rwbarton Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1998 GHC Trac Issues: #11684
-rw-r--r--compiler/main/DriverPipeline.hs32
1 files changed, 24 insertions, 8 deletions
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index c384248ba1..41a7c5bb42 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -1574,16 +1574,32 @@ mkExtraObj dflags extn xs
= do cFile <- newTempName dflags extn
oFile <- newTempName dflags "o"
writeFile cFile xs
- let rtsDetails = getPackageDetails dflags rtsUnitId
- pic_c_flags = picCCOpts dflags
+ ccInfo <- liftIO $ getCompilerInfo dflags
SysTools.runCc dflags
- ([Option "-c",
- FileOption "" cFile,
- Option "-o",
- FileOption "" oFile]
- ++ map (FileOption "-I") (includeDirs rtsDetails)
- ++ map Option pic_c_flags)
+ ([Option "-c",
+ FileOption "" cFile,
+ Option "-o",
+ FileOption "" oFile]
+ ++ if extn /= "s"
+ then cOpts
+ else asmOpts ccInfo)
return oFile
+ where
+ -- Pass a different set of options to the C compiler depending one whether
+ -- we're compiling C or assembler. When compiling C, we pass the usual
+ -- set of include directories and PIC flags.
+ cOpts = map Option (picCCOpts dflags)
+ ++ map (FileOption "-I")
+ (includeDirs $ getPackageDetails dflags rtsUnitId)
+
+ -- When compiling assembler code, we drop the usual C options, and if the
+ -- compiler is Clang, we add an extra argument to tell Clang to ignore
+ -- unused command line options. See trac #11684.
+ asmOpts ccInfo =
+ if any (ccInfo ==) [Clang, AppleClang, AppleClang51]
+ then [Option "-Qunused-arguments"]
+ else []
+
-- When linking a binary, we need to create a C main() function that
-- starts everything off. This used to be compiled statically as part