-
Notifications
You must be signed in to change notification settings - Fork 133
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
Flag usage recommendations #165
Conversation
7733e47
to
95bc03b
Compare
95bc03b
to
7e1183f
Compare
Updated PR with rebase with respect to main after renaming files |
@@ -76,9 +76,15 @@ The recommendations in Table 1 and Table 2 are primarily applicable to compiling | |||
|
|||
For historical reasons, the GCC compiler and Binutils upstream projects do not enable optimization or security hardening options by default. While some aspects of the default options can be changed when building GCC and Binutils from source, the defaults used in the toolchains shipped with GNU/Linux distributions vary. Distributions may also ship multiple versions of toolchains with different defaults. Consequently, developers need to pay attention to compiler and linker options flags, and manage them according to their need of optimization, level of warning and error detection, and security hardening of the project. | |||
|
|||
You can typically find the default flags used by GCC on your system by examining the output of the `gcc -v` command. Examining the `Configured with:` section, in the `gcc -v` output, can be useful for understanding how GCC is set up on your system and what options were chosen by the distribution's maintainers during the build process. It can also be useful for diagnosing issues with GCC or for troubleshooting problems that may arise during the compilation of software. | |||
You can typically find the default flags used by GCC on your system by examining the output of the `gcc -v` command. Examining the `Configured with:` section, in the `gcc -v` output, can be useful for understanding how GCC is set up on your system and what options were chosen by the distribution's maintainers during the build process. It can also be useful for diagnosing issues with GCC or for troubleshooting problems that may arise during the compilation of software. For example, issues caused by interactions between order-sensitive flags. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should include the corresponding flag for Clang (and possible the Microsoft compiler?)
Possible also the relevant variant for debugging issues with macros (gcc -O2 -dM -E - < /dev/null
)
a099cc0
to
b758084
Compare
Rebased to main and incorporated feedback from the C/C++ Compiler BP Guide call on 2023-06-21. |
b758084
to
cb7e700
Compare
Minor further tweaks to avoid referring to only GCC. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally looks good to me - except for the footnote syntax fix.
docs/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.md
Outdated
Show resolved
Hide resolved
With the caveat that distributions may recommend their own ways of incorporating build flags together with links to guidance for a few Linux distributions. Co-authored-by: Georg Kunz <[email protected]> Signed-off-by: Thomas Nyman <[email protected]>
…acros Signed-off-by: Thomas Nyman <[email protected]>
96a0a94
to
750ae2f
Compare
Squashed requested changes to original commit. |
Merged as per discussion in C/C++ Compiler Guide BP call 2023-08-02. |
In PR #132 (comment) @david-a-wheeler noted that we need to note somewhere that the option flags are order-sensitive. Another feedback from the C/C++ Compiler BP Guide calls was to add the recommendation to to explicitly enable hardening flag in a projects build system rather then relying on flags configured in the local GCC profile. This PR adds text to address these concerns.