diff options
| author | Matt Beaumont-Gay <matthewbg@google.com> | 2012-12-04 21:18:26 +0000 |
|---|---|---|
| committer | Matt Beaumont-Gay <matthewbg@google.com> | 2012-12-04 21:18:26 +0000 |
| commit | 35439dff76c4c6ccbed39182ba818ecbca179dac (patch) | |
| tree | d40e3f1a40007b499a390e1f141e3683154f8841 /clang/test | |
| parent | f75e74f67eef1f2effccb5e6668b640437c7eb61 (diff) | |
| download | bcm5719-llvm-35439dff76c4c6ccbed39182ba818ecbca179dac.tar.gz bcm5719-llvm-35439dff76c4c6ccbed39182ba818ecbca179dac.zip | |
Currently, with -fsanitize=address, the driver appends libclang_rt.asan.a to
the link command. This all works fine when the driver is also responsible for
adding -lstdc++ to the link command. But, if -lstdc++ (or libstdc++.a, etc) is
passed explicitly to the driver, the ASan runtime will appear in the link
command after the standard library, leading to multiple-definition errors for
the global 'operator new' and 'operator delete'. Fix this in a painfully
simple way, by inserting libclang_rt.asan.a at the start of the link command
instead of the end.
If we need to do something more clever, we can walk the link command looking
for something that resembles libstdc++ and insert libclang_rt.asan.a as late
as possible, but the simple solution works for now.
llvm-svn: 169310
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Driver/asan-ld.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/test/Driver/asan-ld.c b/clang/test/Driver/asan-ld.c index 9d8cbeca0d5..b90082a2629 100644 --- a/clang/test/Driver/asan-ld.c +++ b/clang/test/Driver/asan-ld.c @@ -24,7 +24,17 @@ // CHECK-LINUX-CXX: "-ldl" // CHECK-LINUX-CXX: "-export-dynamic" // CHECK-LINUX-CXX: stdc++ + +// RUN: %clang -no-canonical-prefixes %s -### -o /dev/null -fsanitize=address \ +// RUN: -target i386-unknown-linux --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: -lstdc++ -static 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-LINUX-CXX-STATIC %s // +// CHECK-LINUX-CXX-STATIC: "{{.*}}ld{{(.exe)?}}" +// CHECK-LINUX-CXX-STATIC-NOT: stdc++ +// CHECK-LINUX-CXX-STATIC: libclang_rt.asan-i386.a" +// CHECK-LINUX-CXX-STATIC: stdc++ + // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target arm-linux-androideabi -fsanitize=address \ // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ |

