Skip to content

Add clang hardening flags that we added for gcc#83

Merged
derobins merged 7 commits into
developfrom
derobins/clang-hardening
Nov 24, 2025
Merged

Add clang hardening flags that we added for gcc#83
derobins merged 7 commits into
developfrom
derobins/clang-hardening

Conversation

@derobins
Copy link
Copy Markdown
Collaborator

@derobins derobins commented Nov 23, 2025

  • Fixes missing ${} when passing compiler version around
  • Add to clang flags:
    • -fstack-clash-protection
    • -fstack-protector-strong
    • -fstrict-flex-arrays=3
    • -D_FORTIFY_SOURCE=3
    • -Wconversion
    • -Wformat-security
  • Add to gcc flags:
    • -Wbidi-chars=any
  • Only use _FORTIFY_SOURCE when -O2 or higher

* -fstack-clash-protection
* -fstack-protector-strong
* -fstrict-flex-arrays=3
* -D_FORTIFY_SOURCE=3
* -Wconversion
* -Wformat-security
Copilot AI review requested due to automatic review settings November 23, 2025 18:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds compiler hardening flags to the Clang configuration that were previously added for GCC, improving security and code safety through stack protection, strict flex arrays, source fortification, and additional security-related warnings.

Key Changes:

  • Added stack protection flags (-fstack-clash-protection, -fstack-protector-strong)
  • Enabled strict flex array checking and fortification (-fstrict-flex-arrays=3, -D_FORTIFY_SOURCE=3)
  • Added security-focused warning flags (-Wconversion, -Wformat-security)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings November 23, 2025 19:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmake/AISClangCompilerOptions.cmake Outdated
get_ais_gnu_warning_flags(compiler_flags ${compiler_version})
elseif(compiler_id STREQUAL "Clang")
get_ais_clang_warning_flags(compiler_flags compiler_version)
get_ais_clang_warning_flags(compiler_flags ${compiler_version})
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. This has probably been broken for a while...

Prevents trojan code injection
Copilot AI review requested due to automatic review settings November 23, 2025 20:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmake/AISGNUCompilerOptions.cmake Outdated
@derobins derobins merged commit d8b1487 into develop Nov 24, 2025
33 checks passed
@derobins derobins deleted the derobins/clang-hardening branch November 24, 2025 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants