[clang] [compiler-rt] [Sanitizers] the access size (8 bytes) exceeds the max lock-free size (4 bytes) for 32-bit (PR #125388)
Hubert Tong via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 6 14:48:40 PST 2025
================
@@ -338,6 +338,13 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-lpthread");
}
const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
+
+// Required for 64-bit atomic operations used in sanitizer runtimes
+// (e.g., sanitizer_common's atomic utilities). On 32-bit AIX, these
+// are not natively supported, necessitating linkage with -latomic.
+ if (Sanitize.hasAnySanitizer() && IsArch32Bit) {
+ CmdArgs.push_back("-latomic");
----------------
hubert-reinterpretcast wrote:
> Please let me know if there are additional points to consider.
The addition of `-latomic` is not actually required _even on AIX_ if the only sanitizer runtimes that are linked in are purely shared libraries.
The addition of `-latomic` for 32-bit AIX belongs in `clang::tools::driver::linkSanitizerRuntimeDeps` because the wider logic is already present to call that function only when sanitizer runtimes that contain static components are linked in.
See
https://github.com/llvm/llvm-project/blob/f7294776570e125b94bb5625905cbc57a4956760/clang/lib/Driver/ToolChains/Gnu.cpp#L541
https://github.com/llvm/llvm-project/blob/f7294776570e125b94bb5625905cbc57a4956760/clang/lib/Driver/ToolChains/Gnu.cpp#L585-L586
https://github.com/llvm/llvm-project/blob/f7294776570e125b94bb5625905cbc57a4956760/clang/lib/Driver/ToolChains/CommonArgs.cpp#L1607-L1608
https://github.com/llvm/llvm-project/blob/f7294776570e125b94bb5625905cbc57a4956760/clang/lib/Driver/ToolChains/CommonArgs.cpp#L1678
https://github.com/llvm/llvm-project/pull/125388
More information about the llvm-commits
mailing list