Skip to content

Commit 4c7b349

Browse files
committed
Force link sanitizer rtlib with -fsanitize-link-runtime
Link runtimes
1 parent 86dc26e commit 4c7b349

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

clang/lib/Driver/SanitizerArgs.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,8 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
11601160
LinkRuntimes =
11611161
Args.hasFlag(options::OPT_fsanitize_link_runtime,
11621162
options::OPT_fno_sanitize_link_runtime, LinkRuntimes) &&
1163-
!Args.hasArg(options::OPT_r);
1163+
Args.hasFlag(options::OPT_fsanitize_link_runtime, options::OPT_r,
1164+
LinkRuntimes);
11641165

11651166
// Parse -link-cxx-sanitizer flag.
11661167
LinkCXXRuntimes = D.CCCIsCXX();

clang/test/Driver/sanitizer-ld.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,14 @@
13781378
//
13791379
// CHECK-RELOCATABLE-LINK-ASAN-UBSAN-RTLIB-NOT: "{{.*}}(asan|ubsan){{.*}}"
13801380

1381+
// RUN: %clang -fsanitize=address -r -fsanitize-link-runtime -### %s 2>&1 \
1382+
// RUN: --target=x86_64-unknown-linux -fuse-ld=ld \
1383+
// RUN: -resource-dir=%S/Inputs/resource_dir \
1384+
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
1385+
// RUN: | FileCheck %s --check-prefix=CHECK-RELOCATABLE-LINK-FORCE-LINK-ASAN
1386+
//
1387+
// CHECK-RELOCATABLE-LINK-FORCE-LINK-ASAN: "{{.*}}asan{{.*}}"
1388+
13811389
// RUN: %clang -fsanitize=thread -r -### %s 2>&1 \
13821390
// RUN: --target=x86_64-unknown-linux -fuse-ld=ld \
13831391
// RUN: -resource-dir=%S/Inputs/resource_dir \

0 commit comments

Comments
 (0)