Skip to content

Commit 7c94a22

Browse files
[Clang][Driver] Link nsan runtime (#97364)
Link nsan runtime.
1 parent 0a369b0 commit 7c94a22

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,6 +1469,8 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
14691469
if (SanArgs.linkCXXRuntimes())
14701470
StaticRuntimes.push_back("msan_cxx");
14711471
}
1472+
if (SanArgs.needsNsanRt())
1473+
StaticRuntimes.push_back("nsan");
14721474
if (!SanArgs.needsSharedRt() && SanArgs.needsTsanRt()) {
14731475
StaticRuntimes.push_back("tsan");
14741476
if (SanArgs.linkCXXRuntimes())

clang/test/Driver/sanitizer-ld.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,18 @@
627627
// CHECK-COV-LINUX: "-lpthread"
628628
// CHECK-COV-LINUX: "-lresolv"
629629

630+
// RUN: %clang -### %s 2>&1 \
631+
// RUN: --target=x86_64-unknown-linux -fuse-ld=ld -fsanitize=numerical \
632+
// RUN: -resource-dir=%S/Inputs/resource_dir \
633+
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
634+
// RUN: | FileCheck --check-prefix=CHECK-NSAN-LINUX %s
635+
//
636+
// CHECK-NSAN-LINUX: "{{.*}}ld{{(.exe)?}}"
637+
// CHECK-NSAN-LINUX-NOT: "-lc"
638+
// CHECK-NSAN-LINUX-NOT: libclang_rt.ubsan
639+
// CHECK-NSAN-LINUX: libclang_rt.nsan.a"
640+
// CHECK-NSAN-LINUX: "-lpthread" "-lrt" "-lm" "-ldl" "-lresolv"
641+
630642
// CFI by itself does not link runtime libraries.
631643
// RUN: not %clang -fsanitize=cfi -### %s 2>&1 \
632644
// RUN: --target=x86_64-unknown-linux -fuse-ld=ld -rtlib=platform \

0 commit comments

Comments
 (0)