Suppress clang warnings in third-party code: libopus and libtheora

RESOLVED FIXED in Firefox 31

Status

()

defect
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: cpeterson, Assigned: cpeterson)

Tracking

(Blocks 1 bug)

unspecified
mozilla31
x86
macOS
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox30 wontfix, firefox31 fixed)

Details

Attachments

(1 attachment)

Assignee

Description

5 years ago
clang reports the following warnings in a --disable-optimize build for OS X:

The libtheora code has a comment saying, "It's better to live with the spurious warnings."

media/libopus/celt/pitch.c:262:4 [-Wdeclaration-after-statement] ISO C90 forbids mixed declarations and code
media/libopus/src/opus_decoder.c:37:10 [-W#pragma-messages] You appear to be compiling without optimization, if so opus will be very slow.

media/libtheora/lib/state.c:717:4 [-Wtype-limits] comparison of unsigned expression < 0 is always false                                                                     
media/libtheora/lib/state.c:718:4 [-Wtype-limits] comparison of unsigned expression < 0 is always false
Attachment #8395179 - Flags: review?(tterribe)
Comment on attachment 8395179 [details] [diff] [review]
suppress-libopus-libtheora-warnings.patch

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

> media/libopus/celt/pitch.c:262:4 [-Wdeclaration-after-statement] ISO C90 forbids mixed declarations and code

This one was fixed upstream in January, FWIW.

::: media/libopus/moz.build
@@ +70,5 @@
> +
> +# Suppress warnings in third-party code.
> +if CONFIG['GNU_CC']:
> +    CFLAGS += ['-Wno-declaration-after-statement']
> +    if CONFIG['CLANG_CXX']:

Is CLANG_CXX really a proper subset of GNU_CC? That seems moderately crazy.
Attachment #8395179 - Flags: review?(tterribe) → review+
Assignee

Comment 2

5 years ago
(In reply to Timothy B. Terriberry (:derf) from comment #1)
> > +# Suppress warnings in third-party code.
> > +if CONFIG['GNU_CC']:
> > +    CFLAGS += ['-Wno-declaration-after-statement']
> > +    if CONFIG['CLANG_CXX']:
> 
> Is CLANG_CXX really a proper subset of GNU_CC? That seems moderately crazy.

Proper subset in what way? The flags or the CXX/CC suffix? The CLANG_CC macro is defined in some mach files, but only CLANG_CXX is defined in moz.build files. (See bug 981507.) Both GNU_CC and GNU_CXX are defined moz.build files.

clang does not understand all gcc -W flags, but it does understand -Wno-declaration-after-statement. In another patch from my "suppress clang and gcc warnings in third-party code" series, I had to `if not CONFIG['CLANG_CXX'] then pass clang-incompatible gcc flags`.
> Proper subset in what way?

I meant that CLANG_CXX is set only if GNU_CC is set.
Assignee

Comment 4

5 years ago
(In reply to Timothy B. Terriberry (:derf) from comment #3)
> > Proper subset in what way?
> 
> I meant that CLANG_CXX is set only if GNU_CC is set.

clang pretends to be gcc in many cases, including defining preprocessor macros like __GNUC__ and this affects our moz.build macros. We have to check !clang for gcc-specific features, e.g. https://hg.mozilla.org/mozilla-central/file/c69c55582faa/mfbt/Compiler.h#l12
https://hg.mozilla.org/mozilla-central/rev/fabc466d8703
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla31
You need to log in before you can comment on or make changes to this bug.