Skip to content

Commit

Permalink
Revert "[driver] Fix sanitizer libc++ runtime linking (llvm#120370)"
Browse files Browse the repository at this point in the history
This reverts commit 9af5de3.

Reason: buildbot breakage
(https://lab.llvm.org/buildbot/#/builders/24/builds/3394/steps/10/logs/stdio)
"Unexpectedly Passed Tests (1):
   llvm-libc++-shared.cfg.in :: libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp"
  • Loading branch information
thurstond committed Dec 19, 2024
1 parent f334db9 commit 60a2f32
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 79 deletions.
9 changes: 4 additions & 5 deletions clang/lib/Driver/SanitizerArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1098,11 +1098,10 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
options::OPT_fno_sanitize_link_runtime, LinkRuntimes);

// Parse -link-cxx-sanitizer flag.
LinkCXXRuntimes =
D.CCCIsCXX() && !Args.hasArg(clang::driver::options::OPT_nostdlibxx);
LinkCXXRuntimes =
Args.hasFlag(options::OPT_fsanitize_link_cxx_runtime,
options::OPT_fno_sanitize_link_cxx_runtime, LinkCXXRuntimes);
LinkCXXRuntimes = Args.hasArg(options::OPT_fsanitize_link_cxx_runtime,
options::OPT_fno_sanitize_link_cxx_runtime,
LinkCXXRuntimes) ||
D.CCCIsCXX();

NeedsMemProfRt = Args.hasFlag(options::OPT_fmemory_profile,
options::OPT_fmemory_profile_EQ,
Expand Down
83 changes: 10 additions & 73 deletions clang/test/Driver/sanitizer-ld.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,81 +132,18 @@
// RUN: -resource-dir=%S/Inputs/empty_resource_dir \
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
// RUN: | FileCheck --check-prefix=CHECK-ASAN-LINUX-CXX %s

// RUN: %clangxx -### %s 2>&1 \
// RUN: --target=i386-unknown-linux -fuse-ld=ld -stdlib=platform -fsanitize=address \
// RUN: -resource-dir=%S/Inputs/empty_resource_dir \
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
// RUN: -fsanitize-link-c++-runtime \
// RUN: | FileCheck --check-prefix=CHECK-ASAN-LINUX-CXX %s

//
// CHECK-ASAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
// CHECK-ASAN-LINUX-CXX-NOT: "-lc"
// CHECK-ASAN-LINUX-CXX: "--whole-archive" "{{.*}}libclang_rt.asan.a" "--no-whole-archive"
// CHECK-ASAN-LINUX-CXX: "--whole-archive" "{{.*}}libclang_rt.asan_cxx.a" "--no-whole-archive"
// CHECK-ASAN-LINUX-CXX-NOT: "--dynamic-list"
// CHECK-ASAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
// CHECK-ASAN-LINUX-CXX-SAME: "--whole-archive" "{{.*}}libclang_rt.asan.a" "--no-whole-archive"
// CHECK-ASAN-LINUX-CXX-SAME: "--whole-archive" "{{.*}}libclang_rt.asan_cxx.a" "--no-whole-archive"
// CHECK-ASAN-LINUX-CXX-SAME: "--export-dynamic"
// CHECK-ASAN-LINUX-CXX-SAME: stdc++
// CHECK-ASAN-LINUX-CXX-SAME: "-lpthread"
// CHECK-ASAN-LINUX-CXX-SAME: "-lrt"
// CHECK-ASAN-LINUX-CXX-SAME: "-ldl"
// CHECK-ASAN-LINUX-CXX-SAME: "-lresolv"

// RUN: %clang -### %s 2>&1 \
// RUN: --target=i386-unknown-linux -fuse-ld=ld -stdlib=platform -fsanitize=address \
// RUN: -resource-dir=%S/Inputs/empty_resource_dir \
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
// RUN: -fno-sanitize-link-c++-runtime \
// RUN: | FileCheck --check-prefix=CHECK-ASAN-LINUX-CNOCXX %s

// CHECK-ASAN-LINUX-CNOCXX-NOT: "-lc"
// CHECK-ASAN-LINUX-CNOCXX-NOT: libclang_rt.asan_cxx
// CHECK-ASAN-LINUX-CNOCXX-NOT: "--dynamic-list"
// CHECK-ASAN-LINUX-CNOCXX-NOT: stdc++
// CHECK-ASAN-LINUX-CNOCXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
// CHECK-ASAN-LINUX-CNOCXX-SAME: "--whole-archive" "{{.*}}libclang_rt.asan.a" "--no-whole-archive"
// CHECK-ASAN-LINUX-CNOCXX-SAME: "--export-dynamic"
// CHECK-ASAN-LINUX-CNOCXX-SAME: "-lpthread"
// CHECK-ASAN-LINUX-CNOCXX-SAME: "-lrt"
// CHECK-ASAN-LINUX-CNOCXX-SAME: "-ldl"
// CHECK-ASAN-LINUX-CNOCXX-SAME: "-lresolv"

// RUN: %clangxx -### %s 2>&1 \
// RUN: --target=i386-unknown-linux -fuse-ld=ld -stdlib=platform -fsanitize=address \
// RUN: -resource-dir=%S/Inputs/empty_resource_dir \
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
// RUN: -fno-sanitize-link-c++-runtime \
// RUN: | FileCheck --check-prefix=CHECK-ASAN-LINUX-NOCXX %s

// CHECK-ASAN-LINUX-NOCXX-NOT: "-lc"
// CHECK-ASAN-LINUX-NOCXX-NOT: libclang_rt.asan_cxx
// CHECK-ASAN-LINUX-NOCXX-NOT: "--dynamic-list"
// CHECK-ASAN-LINUX-NOCXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
// CHECK-ASAN-LINUX-NOCXX-SAME: "--whole-archive" "{{.*}}libclang_rt.asan.a" "--no-whole-archive"
// CHECK-ASAN-LINUX-NOCXX-SAME: "--export-dynamic"
// CHECK-ASAN-LINUX-NOCXX-SAME: stdc++
// CHECK-ASAN-LINUX-NOCXX-SAME: "-lpthread"
// CHECK-ASAN-LINUX-NOCXX-SAME: "-lrt"
// CHECK-ASAN-LINUX-NOCXX-SAME: "-ldl"
// CHECK-ASAN-LINUX-NOCXX-SAME: "-lresolv"

// RUN: %clangxx -### %s 2>&1 \
// RUN: --target=i386-unknown-linux -fuse-ld=ld -stdlib=platform -fsanitize=address \
// RUN: -resource-dir=%S/Inputs/empty_resource_dir \
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
// RUN: -nostdlib++ \
// RUN: | FileCheck --check-prefix=CHECK-ASAN-LINUX-NOSTDCXX %s

// CHECK-ASAN-LINUX-NOSTDCXX-NOT: "-lc"
// CHECK-ASAN-LINUX-NOSTDCXX-NOT: libclang_rt.asan_cxx
// CHECK-ASAN-LINUX-NOSTDCXX-NOT: "--dynamic-list"
// CHECK-ASAN-LINUX-NOSTDCXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
// CHECK-ASAN-LINUX-NOSTDCXX-SAME: "--whole-archive" "{{.*}}libclang_rt.asan.a" "--no-whole-archive"
// CHECK-ASAN-LINUX-NOSTDCXX-SAME: "--export-dynamic"
// CHECK-ASAN-LINUX-NOSTDCXX-SAME: "-lpthread"
// CHECK-ASAN-LINUX-NOSTDCXX-SAME: "-lrt"
// CHECK-ASAN-LINUX-NOSTDCXX-SAME: "-ldl"
// CHECK-ASAN-LINUX-NOSTDCXX-SAME: "-lresolv"
// CHECK-ASAN-LINUX-CXX: "--export-dynamic"
// CHECK-ASAN-LINUX-CXX: stdc++
// CHECK-ASAN-LINUX-CXX: "-lpthread"
// CHECK-ASAN-LINUX-CXX: "-lrt"
// CHECK-ASAN-LINUX-CXX: "-ldl"
// CHECK-ASAN-LINUX-CXX: "-lresolv"

// RUN: %clang -### %s -o /dev/null -fsanitize=address \
// RUN: --target=i386-unknown-linux -fuse-ld=ld -stdlib=platform \
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/hwasan/TestCases/sizes.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This test requires operator new to be intercepted by the hwasan runtime,
// so we need to avoid linking against libc++.
// RUN: %clangxx_hwasan %s -nostdlib++ -lstdc++ -fsanitize-link-c++-runtime -o %t || %clangxx_hwasan %s -o %t
// RUN: %clangxx_hwasan %s -nostdlib++ -lstdc++ -o %t || %clangxx_hwasan %s -o %t
// RUN: %env_hwasan_opts=allocator_may_return_null=0 not %run %t malloc 2>&1 | FileCheck %s --check-prefix=CHECK-max
// RUN: %env_hwasan_opts=allocator_may_return_null=1 %run %t malloc 2>&1
// RUN: %env_hwasan_opts=allocator_may_return_null=0 not %run %t malloc max 2>&1 | FileCheck %s --check-prefix=CHECK-max
Expand Down

0 comments on commit 60a2f32

Please sign in to comment.