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

Backport ASAN build fixes from rustls-ffi #10

Merged
merged 3 commits into from
Apr 25, 2024

Conversation

cpu
Copy link
Member

@cpu cpu commented Apr 23, 2024

See rustls/rustls-ffi#423 & rustls/rustls-ffi#425

I think the main bit of use for this repo is that it enables ASAN for GCC builds. Since we're not using clang in CI this should be a helpful test improvement.

cpu added 3 commits April 23, 2024 09:48
Previously if `$CC` was `clang` the `Makefile` would configure `CFLAGS`
and `LDFLAGS` with address sanitizer (ASAN) enabled.

We only want this to happen for _debug_ builds that are using `clang`,
since it's generally considered bad practice to ship sanitizer builds as
release artifacts.

This commit updates the logic to require `PROFILE=debug`, and then
switches CI to use that profile when running tests. The Valgrind test
continues to use `PROFILE=release` because ASAN and Valgrind will
conflict, raising the error "ASan runtime does not come first in initial
library list;". It may be possible to use both with more
care/configuration, but for now we'll just use valgrind with a release
build.
Previously the `Makefile` conditionally enabled address sanitizer (ASAN)
based on whether the compiler was `clang`. Since GCC has supported
address sanitizer since GCC 4.8[0] we can remove this check and always
use ASAN for both supported compilers.

The only snag is that I observed linker errors about undefined
references to `__ubsan_handle_type_mismatch` unless I fix the `LDFLAGS`
to also include `-fsanitize=undefined`. This was already included in the
`CFLAGS`.

[0]: https://github.com/google/sanitizers/wiki/AddressSanitizer#getting-addresssanitizer
@cpu cpu self-assigned this Apr 23, 2024
@cpu cpu merged commit 479ffd1 into rustls:main Apr 25, 2024
10 checks passed
@cpu cpu deleted the cpu-backport-asan-fixes branch April 25, 2024 17:21
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.

2 participants