Skip to content

native: Explicitly opt in to GNUisms rather than setting std=gnu11 #18681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

chrysn
Copy link
Member

@chrysn chrysn commented Oct 3, 2022

Native used to default to std=gnu11 rather than std=c11 like the rest of RIOT. This changes the makefiles to use the same std as other boards, and sets (and documents) the relevant defines to keep using the GNU features that native (esp. async_read; the rest would be POSIX only) needs.

This eases experimentation with newer standards, as setting std=c2x now works consistently across boards, for example as needed to test #18650.

This eases experimentation with newer standards, as setting std=c2x now
works consistently across boards.
@chrysn chrysn added Area: build system Area: Build system Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Oct 3, 2022
@github-actions github-actions bot added Area: boards Area: Board ports Platform: native Platform: This PR/issue effects the native platform labels Oct 3, 2022
@chrysn chrysn removed Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer Area: boards Area: Board ports labels Oct 3, 2022
@github-actions github-actions bot added Area: boards Area: Board ports Area: cpu Area: CPU/MCU ports and removed Area: build system Area: Build system labels Oct 3, 2022
@chrysn
Copy link
Member Author

chrysn commented Oct 3, 2022

Some builds failed with

 ----------------------------- Captured stderr call -----------------------------
/home/runner/work/RIOT/RIOT/cpu/native/irq_cpu.c:33: error: "__USE_GNU" redefined [-Werror]
   33 | #define __USE_GNU

-- the defines have been removed.

It's generally (according to feature_test_macros(7)) preferable to provide these defines at the command line rather than around individual includes, for any other preceding include might already have transitively included that same file without the defines around it, negating their effect.

@chrysn chrysn added State: archived State: The PR has been archived for possible future re-adaptation and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Oct 3, 2022
@chrysn
Copy link
Member Author

chrysn commented Oct 3, 2022

OK, I'm leaving this rabbit hole for now. Right now we have a wild mix of files that require -std=gnuxx, C files that set _GNU_SOURCE, header files that set GNU_SOURCE (?), and all without any larger semblance of a consistent plan.

I think it would be prudent to

  • consistently ifndef ... define the required properties on compilation units where it's needed
  • revisit whether the GNU_SOURCE (and XOPEN_SOURCE) declarations in header files even do anything reliably (given that such a header could be included from a compilation unit that previously included the relevant headers without the declarations)

and then look at whether we really need to set anything but std=cxx on native in the first place.

(and I think this is best restarted when FreeBSD and MacOS are testable in CI, otherwise this'll be a nightmare to test)

@RIOT-OS RIOT-OS deleted a comment from riot-ci Oct 5, 2022
@riot-ci
Copy link

riot-ci commented Oct 5, 2022

Murdock results

FAILED

f1dbc39 fixup! native: Explicitly opt in to GNUisms rather than setting std=gnu11

Build failures (21)
Application Target Toolchain Runtime (s) Worker
examples/asymcute_mqttsn native gnu 0.92 riotbuild
examples/ccn-lite-relay native gnu 5.06 mobi3
examples/dtls-sock native gnu 2.38 mobi7
examples/gnrc_lorawan native gnu 0.94 riotbuild
examples/lua_REPL native gnu 6.79 mobi3
examples/micropython native gnu 7.58 riotbuild
examples/ndn-ping native gnu 3.96 riotbuild
examples/wasm native gnu 2.64 breeze
tests/bench_msg_pingpong native gnu 1.17 mobi3
tests/bench_xtimer native gnu 1.24 mobi3
tests/bloom_bytes native gnu 1.38 comsys
tests/candev native gnu 2.76 mobi3
tests/congure_reno native gnu 2.18 breeze
tests/cpp_ctors native gnu 1.37 breeze
tests/deferred_yield_higher native gnu 0.85 mobi3
tests/devfs native gnu 1.15 mobi7
tests/driver_at25xxx native gnu 3.04 mobi7
tests/driver_at86rf2xx native gnu 1.38 mobi3
tests/driver_ds3234 native gnu 1.19 breeze
tests/driver_encx24j600 native gnu 3.29 mobi7

and 409 more build failures...

Artifacts

This only reflects a subset of all builds from https://ci-prod.riot-os.org. Please refer to https://ci.riot-os.org for a complete build for now.

@aabadie aabadie added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Oct 5, 2022
@maribu maribu added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Nov 21, 2022
@maribu
Copy link
Member

maribu commented Nov 22, 2022

Please squash at will an ping me when Murdock is happy. I will only need a quick look to ACK this.

@chrysn
Copy link
Member Author

chrysn commented Nov 29, 2022

I think this eneavour would need a more systematic reboot, distinguishing where we have GNUisms inside compilation units (and how to set CFLAGS for these specifically), or whether any are part of our headers (ugh). This issue probably best serves as inspiration for where to find them, or as a starting point. I can't drive this to completion right now, anyone with the energy to continue this is welcome to take anything in here they deem usable.

@Teufelchen1 Teufelchen1 marked this pull request as draft March 19, 2024 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: boards Area: Board ports Area: cpu Area: CPU/MCU ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: native Platform: This PR/issue effects the native platform State: archived State: The PR has been archived for possible future re-adaptation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants