Skip to content

[sanitizer] Reject unsupported -static at link time #83524

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler-rt/lib/hwasan/hwasan_interceptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ void InitializeInterceptors() {
CHECK_EQ(inited, 0);

# if HWASAN_WITH_INTERCEPTORS
__interception::DoesNotSupportStaticLinking();
InitializeCommonInterceptors();

(void)(read_iovec);
Expand Down
1 change: 1 addition & 0 deletions compiler-rt/lib/lsan/lsan_interceptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ namespace __lsan {
void InitializeInterceptors() {
// Fuchsia doesn't use interceptors that require any setup.
#if !SANITIZER_FUCHSIA
__interception::DoesNotSupportStaticLinking();
InitializeSignalInterceptors();

INTERCEPT_FUNCTION(malloc);
Expand Down
2 changes: 2 additions & 0 deletions compiler-rt/lib/msan/msan_interceptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1762,6 +1762,8 @@ void InitializeInterceptors() {
static int inited = 0;
CHECK_EQ(inited, 0);

__interception::DoesNotSupportStaticLinking();

new(interceptor_ctx()) InterceptorContext();

InitializeCommonInterceptors();
Expand Down
2 changes: 2 additions & 0 deletions compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2861,6 +2861,8 @@ void InitializeInterceptors() {
REAL(memcpy) = internal_memcpy;
#endif

__interception::DoesNotSupportStaticLinking();

new(interceptor_ctx()) InterceptorContext();

InitializeCommonInterceptors();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// UNSUPPORTED: hwasan, ubsan
Copy link
Contributor

Choose a reason for hiding this comment

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

What is special about these two sanitizers (why doesn't it also apply to lsan/msan/tsan)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess hwasan, ubsan can be with or without interceptors

hwasan on non-android linux will be with interceptors

Copy link
Member Author

@MaskRay MaskRay Mar 8, 2024

Choose a reason for hiding this comment

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

Right. The test is only for sanitizers that are guaranteed to use interceptors that are incompatible with -static links. I unsupport hwasan/ubsan because they may not use interceptors.

(hwasan has other incompatibility with static linking, but that's not as fundamental as interceptors).

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, thanks for explaining!

// RUN: not %clangxx -static %s -o /dev/null