Last Comment Bug 717713 - Add -Qunused-arguments to Clang compiler flags
: Add -Qunused-arguments to Clang compiler flags
Status: RESOLVED FIXED
[inbound]
: dev-doc-complete
Product: Core
Classification: Components
Component: Build Config (show other bugs)
: Trunk
: All All
: -- normal (vote)
: mozilla12
Assigned To: Gregory Szorc [:gps]
:
: Gregory Szorc [:gps]
Mentors:
Depends on:
Blocks: 720503 clang
  Show dependency treegraph
 
Reported: 2012-01-12 12:04 PST by Gregory Szorc [:gps]
Modified: 2012-01-24 12:24 PST (History)
6 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Add -Qunused-arguments to Clang compiler flags, v1 (3.07 KB, patch)
2012-01-12 14:57 PST, Gregory Szorc [:gps]
ted: review-
Details | Diff | Splinter Review
Add -Qunused-arguments to Clang compiler flags, v2 (2.51 KB, patch)
2012-01-23 10:12 PST, Gregory Szorc [:gps]
ted: review+
Details | Diff | Splinter Review

Description Gregory Szorc [:gps] 2012-01-12 12:04:38 PST
I currently have CC and CXX pointing to clang and clang++. m-c builds fine (even with Clang's trunk). However, the Clang driver is pretty verbose by default and reports which CLI arguments went unused during invocation. e.g.

clang-3: warning: argument unused during compilation: '-I /Users/gps/src/services-central/browser/components/build/../shell/src'
clang-3: warning: argument unused during compilation: '-I /Users/gps/src/services-central/browser/components/build/../feeds/src'
clang-3: warning: argument unused during compilation: '-I /Users/gps/src/services-central/browser/components/build/../places/src'
clang-3: warning: argument unused during compilation: '-I /Users/gps/src/services-central/browser/components/build/../privatebrowsing/src'
clang-3: warning: argument unused during compilation: '-I /Users/gps/src/services-central/browser/components/build/../about'
clang-3: warning: argument unused during compilation: '-I /Users/gps/src/services-central/browser/components/build/../dirprovider'
clang-3: warning: argument unused during compilation: '-I /Users/gps/src/services-central/browser/components/build/../migration/src'
clang-3: warning: argument unused during compilation: '-I /Users/gps/src/services-central/browser/components/build'
clang-3: warning: argument unused during compilation: '-I .'
clang-3: warning: argument unused during compilation: '-I ../../../dist/include'
clang-3: warning: argument unused during compilation: '-I ../../../dist/include/nsprpub'
clang-3: warning: argument unused during compilation: '-I /Users/gps/src/services-central/obj-ff-dbg/dist/include/nspr'
clang-3: warning: argument unused during compilation: '-I /Users/gps/src/services-central/obj-ff-dbg/dist/include/nss'
clang-3: warning: argument unused during compilation: '-include ../../../mozilla-config.h'
clang-3: warning: argument unused during compilation: '-std=gnu++0x'
clang-3: warning: argument unused during compilation: '-pthread'

You see spew like this for nearly every compiler invocation, even with make -s.

The easy way to fix this is to add -Qunused-arguments to CFLAGS and CXXFLAGS. I do this locally in my .mozconfig and it works fine. But, I think it would be helpful if it were a built-in default.

The only downside is this could silence legit warnings (perhaps you think that argument you just added should be doing something). So, if this is marked WONTFIX or if you'd want this to be an optional feature (perhaps on by default and disabled via configure --show-unused-arguments-warnings or something), I'd understand.
Comment 1 Gregory Szorc [:gps] 2012-01-12 14:57:19 PST
Created attachment 588198 [details] [diff] [review]
Add -Qunused-arguments to Clang compiler flags, v1

Here's my first stab at it. I got the main and js configure. I still see the warnings for NSPR, but its configure if off-limits, right? Are there any other configure scripts I should hit?

Also, I'm not sure if I defined the check in the proper place or if I assigned to the proper variable. But, the change does seem to work :)

I should also mention that the reported problem is much worse with ccache enabled. This is because under the hood ccache is invoking ${compiler} -E and it is often this invocation that produces most of the unused argument warnings.
Comment 2 Gregory Szorc [:gps] 2012-01-13 14:58:41 PST
https://developer.mozilla.org/en/ccache can be updated after this lands (remove -Qunused-arguments).
Comment 3 Ted Mielczarek [:ted.mielczarek] 2012-01-17 05:42:24 PST
You can fix NSPR's configure, you'll just have to do it in a separate NSPR bug.
Comment 4 Ted Mielczarek [:ted.mielczarek] 2012-01-18 11:39:47 PST
Comment on attachment 588198 [details] [diff] [review]
Add -Qunused-arguments to Clang compiler flags, v1

Review of attachment 588198 [details] [diff] [review]:
-----------------------------------------------------------------

I really don't think we need an --enable flag for this. Just set the flags unconditionally if building with clang.
Comment 5 Nomis101 2012-01-19 13:11:16 PST
Isn't Qunused-arguments also needed for CPPFLAGS? Googling gives me a lot of "CPPFLAGS=-Qunused-arguments". On the other hand I've never seen to add it for CXXFLAGS. -Qunused-arguments seems only usefull for CPPFLAGS and CFLAGS.
Comment 6 Gregory Szorc [:gps] 2012-01-23 10:12:06 PST
Created attachment 590768 [details] [diff] [review]
Add -Qunused-arguments to Clang compiler flags, v2

Removed configure option. Added argument to CPPFLAGS.
Comment 7 Gregory Szorc [:gps] 2012-01-23 13:40:17 PST
Pushed to inbound: https://hg.mozilla.org/integration/mozilla-inbound/rev/92844ace31ec

Updated https://developer.mozilla.org/en/ccache.

I'll file a follow-up bug for NSPR.
Comment 8 Gregory Szorc [:gps] 2012-01-24 12:24:14 PST
https://hg.mozilla.org/mozilla-central/rev/92844ace31ec

Note You need to log in before you can comment on or make changes to this bug.