Skip to content

Add /INFERASANLIBS to the Clang ARM64 workarounds - #6163

Merged
Stephan T. Lavavej (StephanTLavavej) merged 1 commit into
microsoft:mainfrom
StephanTLavavej:inferasanlibs
Mar 16, 2026
Merged

Add /INFERASANLIBS to the Clang ARM64 workarounds#6163
Stephan T. Lavavej (StephanTLavavej) merged 1 commit into
microsoft:mainfrom
StephanTLavavej:inferasanlibs

Conversation

@StephanTLavavej

Copy link
Copy Markdown
Member

Followup to #6157's sub-commit "Tests: Enable ASan annotation tests for ARM64, except Clang."

The MSVC-internal test harness lacks this workaround:

# clang doesn't know how to link in the VS version of the asan runtime automatically
if 'asan' in self.config.available_features and 'clang' in self.config.available_features:
self.linkFlags.append("/INFERASANLIBS")

And to work around llvm/llvm-project#184902 everywhere (GitHub and MSVC), I had to avoid all #include directives (which could drag in global initializers that would then crash due to the compiler bug), which also avoided picking up:

#elif defined(__clang__) // ^^^ defined(__SANITIZE_ADDRESS__) / defined(__clang__) vvv
#if __has_feature(address_sanitizer)
#define _ACTIVATE_STRING_ANNOTATION
#define _INSERT_STRING_ANNOTATION
#define _ACTIVATE_VECTOR_ANNOTATION
#define _INSERT_VECTOR_ANNOTATION
#pragma comment(linker, "/INFERASANLIBS")
#endif // __has_feature(address_sanitizer)
#endif // ^^^ defined(__clang__) ^^^

The result is that these tests, newly enabled for ARM64, became successfully empty-ish for GitHub (compiled with -fsanitize=address and linked with /INFERASANLIBS), but failed to link for the MSVC-internal test harness (compiled with -fsanitize=address, but not linked with /INFERASANLIBS).

Adding these pragmas to the workaround paths should get the Clang ARM64 configurations passing internally. Reverse-mirrored from MSVC-PR-718376 where I'm verifying that.

(This wasn't noticed until after merging, because the MSVC-internal test harness doesn't run ARM64 by default for PRs, only in CIs. Why yes I am having an excellent Monday, why do you ask.)

@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) added the test Related to test code label Mar 16, 2026
@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) added ARM64 Related to the ARM64 architecture ASan Address Sanitizer labels Mar 16, 2026
@github-project-automation github-project-automation Bot moved this to Initial Review in STL Code Reviews Mar 16, 2026
@AlexGuteniev

Copy link
Copy Markdown
Contributor

But should you then undo the Github harness change to also rely on the pragma, like the internal harness?

@StephanTLavavej

Copy link
Copy Markdown
Member Author

I don't understand nearly enough about what's going on with the blizzard of ASan configurations and options to mess with this any more than I absolutely have to.

@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) moved this from Initial Review to Merging in STL Code Reviews Mar 16, 2026
@StephanTLavavej
Stephan T. Lavavej (StephanTLavavej) merged commit 2626cf1 into microsoft:main Mar 16, 2026
49 checks passed
@github-project-automation github-project-automation Bot moved this from Merging to Done in STL Code Reviews Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ARM64 Related to the ARM64 architecture ASan Address Sanitizer test Related to test code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants