Skip to content
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

Merged
merged 2 commits into from
Aug 3, 2023
Merged

Flag usage recommendations #165

merged 2 commits into from
Aug 3, 2023

Conversation

thomasnyman
Copy link
Contributor

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.

@thomasnyman
Copy link
Contributor Author

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.
Copy link
Contributor Author

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)

@thomasnyman thomasnyman force-pushed the flag-usage-recommendations branch 2 times, most recently from a099cc0 to b758084 Compare August 2, 2023 11:42
@thomasnyman
Copy link
Contributor Author

Rebased to main and incorporated feedback from the C/C++ Compiler BP Guide call on 2023-06-21.

@thomasnyman
Copy link
Contributor Author

Minor further tweaks to avoid referring to only GCC.

Copy link
Contributor

@gkunz gkunz left a 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.

thomasnyman and others added 2 commits August 3, 2023 18:41
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]>
@thomasnyman
Copy link
Contributor Author

Squashed requested changes to original commit.

@thomasnyman thomasnyman merged commit 082fb74 into main Aug 3, 2023
4 checks passed
@thomasnyman
Copy link
Contributor Author

Merged as per discussion in C/C++ Compiler Guide BP call 2023-08-02.

@thomasnyman thomasnyman deleted the flag-usage-recommendations branch August 3, 2023 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants