[clang] [Clang][Driver] Link nsan runtime (PR #97364)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 1 16:34:41 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Alexander Shaposhnikov (alexander-shaposhnikov)
<details>
<summary>Changes</summary>
Link nsan runtime.
---
Full diff: https://github.com/llvm/llvm-project/pull/97364.diff
2 Files Affected:
- (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+2)
- (modified) clang/test/Driver/sanitizer-ld.c (+14)
``````````diff
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 2a4c1369f5a73..be4d7d2cffb16 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1469,6 +1469,8 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
if (SanArgs.linkCXXRuntimes())
StaticRuntimes.push_back("msan_cxx");
}
+ if (SanArgs.needsNsanRt())
+ StaticRuntimes.push_back("nsan");
if (!SanArgs.needsSharedRt() && SanArgs.needsTsanRt()) {
StaticRuntimes.push_back("tsan");
if (SanArgs.linkCXXRuntimes())
diff --git a/clang/test/Driver/sanitizer-ld.c b/clang/test/Driver/sanitizer-ld.c
index 1dc8b446d7b6d..38769ba01ed04 100644
--- a/clang/test/Driver/sanitizer-ld.c
+++ b/clang/test/Driver/sanitizer-ld.c
@@ -627,6 +627,20 @@
// CHECK-COV-LINUX: "-lpthread"
// CHECK-COV-LINUX: "-lresolv"
+// RUN: %clang -### %s 2>&1 \
+// RUN: --target=x86_64-unknown-linux -fuse-ld=ld -fsanitize=numerical \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-NSAN-LINUX %s
+//
+// CHECK-NSAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-NSAN-LINUX-NOT: "-lc"
+// CHECK-NSAN-LINUX-NOT: libclang_rt.ubsan
+// CHECK-NSAN-LINUX: libclang_rt.nsan.a"
+// CHECK-NSAN-LINUX: "-lpthread"
+// CHECK-NSAN-LINUX: "-ldl"
+// CHECK-NSAN-LINUX: "-lresolv"
+
// CFI by itself does not link runtime libraries.
// RUN: not %clang -fsanitize=cfi -### %s 2>&1 \
// RUN: --target=x86_64-unknown-linux -fuse-ld=ld -rtlib=platform \
``````````
</details>
https://github.com/llvm/llvm-project/pull/97364
More information about the cfe-commits
mailing list