Closed Bug 1653182 Opened 4 years ago Closed 4 years ago

Compile modules/libmar code as C11

Categories

(Firefox Build System :: General, task, P3)

task

Tracking

(firefox-esr68 wontfix, firefox-esr78 wontfix, firefox78 wontfix, firefox79 wontfix, firefox80 wontfix, firefox81 fixed)

RESOLVED FIXED
81 Branch
Tracking Status
firefox-esr68 --- wontfix
firefox-esr78 --- wontfix
firefox78 --- wontfix
firefox79 --- wontfix
firefox80 --- wontfix
firefox81 --- fixed

People

(Reporter: cpeterson, Assigned: cpeterson)

References

Details

Attachments

(2 files, 1 obsolete file)

Compiling C code as C11 (-std=gnu11) instead of C99 (-std=gnu99) brings our C code into the 21st century and unlocks some C11 language features, such as support for static_assert (bug 1652914 will retire MFBT's MOZ_STATIC_ASSERT macro).

Compiler support for -std=c11 was added in gcc 4.6 and clang 3.1.

Summary of C11's changes from C99:

https://en.wikipedia.org/wiki/C11_(C_standard_revision)

We can't compile as C18 yet because we still support gcc 7.1 (bug 1536848) and clang 5.0 (bug 1579189). Compiler support for -std=c17 (aka C18) was added in gcc 8.1 and clang 7.0. If -std isn't specified, gcc 8.1+ and clang 7.0+ default to C18. Compiling as C18 is not needed because C18 is just a "bug fix" release that corrects defects in the C11 spec without introducing new language features and gcc and clang also implement those C18 corrections in -std=c11 mode.

List of C11 defects fixed in C18:

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2244.htm

Mostly green Try test run:

https://treeherder.mozilla.org/#/jobs?repo=try&revision=c0a1866b9574c3612b8fb6e58fb6725013e5eb43

Compiling C code as C11 (-std=gnu11) instead of C99 (-std=gnu99) brings our C code into the 21st century and unlocks some C11 language features, such as support for static_assert (bug 1652914).

Compiler support for -std=c11 was added in gcc 4.6 and clang 3.1.

We can't compile as C18 yet because we still support gcc 7.1 (bug 1536848) and clang 5.0 (bug 1579189). Compiler support for -std=c17 (aka C18) was added in gcc 8.1 and clang 7.0. If -std isn't specified, gcc 8.1+ and clang 7.0+ default to C18. Compiling as C18 is not needed because C18 is just a "bug fix" release that corrects defects in the C11 spec without introducing new language features and gcc and clang also implement those C18 corrections in -std=c11 mode.

Attachment #9163948 - Attachment description: Bug 1653182 - Compile C code as C11. r?froydnj → Bug 1653182 - Compile C code as C11. r?#firefox-build-system-reviewers

Compile libmar as C11 so we can replace MOZ_STATIC_ASSERT() with static_assert() (bug 1652914).

mozilla-central's default C dialect was upgraded to C99 in 2013 by bug 719659, making the netwerk/{sctp,srtp}/ code's -std=gnu99 redundant. The netwerk/{sctp,srtp}/ code opted into C99 (bug 783843) in 2012 when the tree's default was still C89.

Depends on D85119

I posted new patches that just compile modules/libmar, instead of all C code in mozilla-central, as C11. This is lower risk, though the moz.build changes for libmar are a little ugly because these files are compiled for both host (mar signing utils) and target (Firefox).

Summary: Compile C code as C11 → Compile modules/libmar code as C11
Attachment #9163948 - Attachment is obsolete: true
Attachment #9166497 - Attachment description: Bug 1653182 - Part 1: Compile libmar as C11. r?#firefox-build-system-reviewers → Bug 1653182 - Part 1: Compile libmar as C11. r?nalexander
Attachment #9166498 - Attachment description: Bug 1653182 - Part 2: Remove redundant -std=gnu99 from netwerk/sctp and srtp. r?#firefox-build-system-reviewers → Bug 1653182 - Part 2: Remove redundant -std=gnu99 from netwerk/sctp and srtp. r=froydnj
Pushed by cpeterson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e43755e21036 Part 1: Compile libmar as C11. r=nalexander,mhowell
Pushed by cpeterson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3ebab9ec3685 Part 1: Compile libmar as C11. r=nalexander,mhowell https://hg.mozilla.org/integration/autoland/rev/33d2a9c85210 Part 2: Remove redundant -std=gnu99 from netwerk/sctp and srtp. r=froydnj
Alias: C11
Backout by cbrindusan@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/0e4bc84faa30 Backed out changeset 3ebab9ec3685 as requested by cpeterson for being a duplicate patch. CLOSED TREE
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 81 Branch
Regressions: 1656285
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: