Skip to content

Conversation

@LeonardHerbst
Copy link
Contributor

Contribution description

The CXXFLAGS are now also exported in vars.inc.mk.
The unwanted C++ flags (CXXUWFLAGS) and additional C++ flags (CXXEXFLAGS) were already being exported there, but the CXXFLAGS were missing.
Previously, the CXXFLAGS were set in Makefile.base and therefore could not be used by packages.
The CXXFLAGS are still constructed by filtering out the unwanted C++ flags from the regular CFLAGS and adding the additional C++ flags.
Since both of these variables are processed in cflags.inc.mk, it should be safe to construct the CXXFLAGS afterwards.

Testing procedure

The CXXFLAGS were used to generate the compile commands and compile C++ sources.
The CXXFLAGS are still included in the output of make compile-commands.
Both tests/build_system/cpp_ext and tests/build_system/cpp_exclude still pass.

Exporting the `CXXFLAGS`.
Inlcude the `CXXFLAGS` in the cmake toolchain file generated by the `dist/tools/cmake/generate-xcompile-toolchiab.sh` script.
@github-actions github-actions bot added Area: build system Area: Build system Area: tools Area: Supplementary tools labels Aug 22, 2025
@crasbe crasbe added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Aug 22, 2025
@riot-ci
Copy link

riot-ci commented Aug 22, 2025

Murdock results

FAILED

218fa70 dist/tools/cmake: include CXXFLAGS in the generated toolchian

Success Failures Total Runtime
325 0 9543 02m:00s

Artifacts

@crasbe
Copy link
Contributor

crasbe commented Aug 26, 2025

Unfortunately moving the flag declaration like this can (and evidently has) unwanted side effects due to the grown nature of our make system :/

Apparently there is some flag missing at some place which leads to this (seemingly) unrelated build failure.
I can't really tell you which route would be the best way forward here tbh.

@LeonardHerbst
Copy link
Contributor Author

The CXXFLAGS cannot simply be exported. They must dynamically reflect changes made to the CFLAGS (since they are constructed by filtering out CXXUWFLAGS and adding CXXEXFLAGS). This relies on the CXXFLAGS being evaluated lazily.

When make is called recursively, the CXXFLAGS are evaluated too early. The sub-make process only inherits the environment variable and therefore misses the flags added to the CFLAGS in the package/module/etc.

@LeonardHerbst LeonardHerbst deleted the cxx_xcompile branch September 18, 2025 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: build system Area: Build system Area: tools Area: Supplementary tools CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants