Author: Alexander Shaposhnikov Date: 2024-07-02T17:34:44-07:00 New Revision: 7c94a227bccf4d067a65f4ed88aa415fd1de9d81
URL: https://github.com/llvm/llvm-project/commit/7c94a227bccf4d067a65f4ed88aa415fd1de9d81 DIFF: https://github.com/llvm/llvm-project/commit/7c94a227bccf4d067a65f4ed88aa415fd1de9d81.diff LOG: [Clang][Driver] Link nsan runtime (#97364) Link nsan runtime. Added: Modified: clang/lib/Driver/ToolChains/CommonArgs.cpp clang/test/Driver/sanitizer-ld.c Removed: ################################################################################ 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..93702f456229f 100644 --- a/clang/test/Driver/sanitizer-ld.c +++ b/clang/test/Driver/sanitizer-ld.c @@ -627,6 +627,18 @@ // 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: "{{.*}}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" "-lrt" "-lm" "-ldl" "-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 \ _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits