The default bug view has changed. See this FAQ.

Add -Qunused-arguments to Clang compiler flags

RESOLVED FIXED in mozilla12

Status

()

Core
Build Config
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: gps, Assigned: gps)

Tracking

(Blocks: 1 bug, {dev-doc-complete})

Trunk
mozilla12
dev-doc-complete
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [inbound])

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

5 years ago
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.
(Assignee)

Comment 1

5 years ago
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.
Assignee: nobody → gps
Status: NEW → ASSIGNED
Attachment #588198 - Flags: review?(ted.mielczarek)
(Assignee)

Comment 2

5 years ago
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-

Comment 5

5 years ago
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.
(Assignee)

Comment 6

5 years ago
Created attachment 590768 [details] [diff] [review]
Add -Qunused-arguments to Clang compiler flags, v2

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+
(Assignee)

Comment 7

5 years ago
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.
Keywords: dev-doc-needed → dev-doc-complete
Whiteboard: [inbound]
(Assignee)

Updated

5 years ago
Blocks: 720503
(Assignee)

Comment 8

5 years ago
https://hg.mozilla.org/mozilla-central/rev/92844ace31ec
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla12
You need to log in before you can comment on or make changes to this bug.