Skip to content

chore: propagate sanitizer flags from rust toolchain invokation to native builds - #134

Merged
uklotzde merged 4 commits into
HMIProject:mainfrom
cartercanedy:cc/propagate-sanitizer-flags
Oct 20, 2026
Merged

uklotzde merged 4 commits into
HMIProject:mainfrom
cartercanedy:cc/propagate-sanitizer-flags

Conversation

@cartercanedy

Copy link
Copy Markdown
Contributor

The CARGO_CFG_SANITIZER environment variable is set when -Zsanitizer=address is set in RUSTFLAGS. Properly setting the sanitizer flags for the C builds enables cross-language-boundary detection of use-after-frees, and will enable more comprehensive detection of invalid memory operations when consumers enable ASAN in their code.

see HMIProject/open62541#355 & HMIProject/open62541#359 for context.

@cartercanedy

Copy link
Copy Markdown
Contributor Author

@sgoll @uklotzde how are you guys feeling about this?

@uklotzde
uklotzde requested review from sgoll and a lite review from Copilot October 19, 2026 14:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Register the sanitizer environment variable for Cargo reruns to ensure native artifacts rebuild correctly.

1 open issue
What changed in this PR

Adds AddressSanitizer flag propagation from Rust builds to bundled C libraries.

Changes:

  • Applies sanitizer flags to CMake and cc builds.
  • Documents ASAN usage and compiler compatibility.
  • Records the feature in the changelog.
File Description
README.md Adds ASAN usage instructions.
CHANGELOG.md Records sanitizer support.
build.rs Propagates sanitizer flags to native builds.

Review effort: Lite

Comment thread build.rs
@uklotzde

Copy link
Copy Markdown
Collaborator

Please also fix the formatting issues.

Comment thread build.rs Outdated
Comment thread build.rs Outdated
Co-authored-by: Sebastian Goll <1277035+sgoll@users.noreply.github.com>

@sgoll sgoll left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for working on this 👍

@uklotzde
uklotzde merged commit 632b528 into HMIProject:main Oct 20, 2026
23 checks passed
@cartercanedy
cartercanedy deleted the cc/propagate-sanitizer-flags branch October 21, 2026 19:42
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.

4 participants