Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support extra compiler flags during building (#39191)
Many Linux distributions like to use an extra set of compiler flags (via `CFLAGS`, `CXXFLAGS` and `LDFLAGS`) to produce builds that are hardened against vulnerabilities and exploits. The flags sometimes also enable extra warnings to inform packagers about potential memory issues. This pach adds support for that to dotnet/runtime. The obvious method to make this work is to just export the `CFLAGS`, `CXXFLAGS`, and `LDFLAGS` directly. This, however, enables those flags during configure-time (aka `cmake` without `--build` too). That means several cmake configure tests get executed with unexpected compiler flags. These configure tests can then report incorrect results. For example, https://bugzilla.redhat.com/show_bug.cgi?id=1712158 demonstrates an issue where the check for `strerror_r` in the runtime comes to the wrong conclusion because `-Wall` is enabled and a variable is unused. A slightly longer fix is to support another set of environment variables, and use them to set `CFLAGS`, `CXXFLAGS`, `LDFLAGS`, but only for the invocation of `cmake --build`/`make`. See #35727 for the complete details. Fixes #35727
- Loading branch information