Compile modules/libmar code as C11
Categories
(Firefox Build System :: General, task, P3)
Tracking
(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
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 1•4 years ago
|
||
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.
Updated•4 years ago
|
Assignee | ||
Comment 2•4 years ago
|
||
Compile libmar as C11 so we can replace MOZ_STATIC_ASSERT() with static_assert() (bug 1652914).
Assignee | ||
Comment 3•4 years ago
|
||
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
Assignee | ||
Comment 4•4 years ago
•
|
||
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).
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Updated•4 years ago
|
Comment 8•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/e43755e21036
https://hg.mozilla.org/mozilla-central/rev/33d2a9c85210
Description
•