Closed Bug 717713 Opened 12 years ago Closed 12 years ago

Add -Qunused-arguments to Clang compiler flags

Categories

(Firefox Build System :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla12

People

(Reporter: gps, Assigned: gps)

References

(Blocks 1 open bug)

Details

(Keywords: dev-doc-complete, Whiteboard: [inbound])

Attachments

(1 file, 1 obsolete file)

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.
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.
Assignee: nobody → gps
Status: NEW → ASSIGNED
Attachment #588198 - Flags: review?(ted.mielczarek)
https://developer.mozilla.org/en/ccache can be updated after this lands (remove -Qunused-arguments).
Keywords: dev-doc-needed
You can fix NSPR's configure, you'll just have to do it in a separate NSPR bug.
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.
Attachment #588198 - Flags: review?(ted.mielczarek) → review-
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.
Removed configure option. Added argument to CPPFLAGS.
Attachment #588198 - Attachment is obsolete: true
Attachment #590768 - Flags: review?(ted.mielczarek)
Attachment #590768 - Attachment is patch: true
Attachment #590768 - Flags: review?(ted.mielczarek) → review+
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.
Whiteboard: [inbound]
Blocks: 720503
https://hg.mozilla.org/mozilla-central/rev/92844ace31ec
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla12
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: