[commit: ghc] master: DriverPipeline: Fix 'unused arguments' warnings from Clang (46f9a47)
git at git.haskell.org
git at git.haskell.org
Wed Mar 16 20:41:17 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/46f9a476e17714e27d893b491cc0dcf68c745249/ghc
>---------------------------------------------------------------
commit 46f9a476e17714e27d893b491cc0dcf68c745249
Author: Erik de Castro Lopo <erikd at mega-nerd.com>
Date: Sun Mar 13 15:28:11 2016 +1100
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
>---------------------------------------------------------------
46f9a476e17714e27d893b491cc0dcf68c745249
compiler/main/DriverPipeline.hs | 32 ++++++++++++++++++++++++--------
1 file changed, 24 insertions(+), 8 deletions(-)
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index c384248..41a7c5b 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
More information about the ghc-commits
mailing list