diff options
author | Alexander Potapenko <glider@google.com> | 2012-09-20 10:10:01 +0000 |
---|---|---|
committer | Alexander Potapenko <glider@google.com> | 2012-09-20 10:10:01 +0000 |
commit | 087c65fb270d7f465f221b543731f89343032e90 (patch) | |
tree | 781803d4bda1a69d774e8095c510d7d40028966c | |
parent | b3278162bd6d34783607d4bfe8814df73e8ef8c1 (diff) |
Disable source fortification on Darwin with AddressSanitizer.
ASan doesn't play well with -D_FORTIFY_SOURCE, which is enabled by default starting at OS X 10.7
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164299 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Basic/Targets.cpp | 3 | ||||
-rw-r--r-- | test/Driver/darwin-asan-nofortify.c | 5 | ||||
-rw-r--r-- | test/lit.cfg | 4 |
3 files changed, 12 insertions, 0 deletions
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 3720d47e55..d5cb514b03 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -92,6 +92,9 @@ static void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts, Builder.defineMacro("__APPLE__"); Builder.defineMacro("__MACH__"); Builder.defineMacro("OBJC_NEW_PROPERTIES"); + // AddressSanitizer doesn't play well with source fortification, which is on + // by default on Darwin. + if (Opts.AddressSanitizer) Builder.defineMacro("_FORTIFY_SOURCE", "0"); if (!Opts.ObjCAutoRefCount) { // __weak is always defined, for use in blocks and with objc pointers. diff --git a/test/Driver/darwin-asan-nofortify.c b/test/Driver/darwin-asan-nofortify.c new file mode 100644 index 0000000000..59f00ff98b --- /dev/null +++ b/test/Driver/darwin-asan-nofortify.c @@ -0,0 +1,5 @@ +// Make sure AddressSanitizer disables _FORTIFY_SOURCE on Darwin. + +// REQUIRES: system-darwin +// RUN: %clang -faddress-sanitizer %s -E -dM -o - | FileCheck %s +// CHECK: #define _FORTIFY_SOURCE 0 diff --git a/test/lit.cfg b/test/lit.cfg index d7c3de4a3d..b2d666d564 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -222,6 +222,10 @@ if platform.system() not in ['FreeBSD']: if platform.system() not in ['Windows'] or lit.getBashPath() != '': config.available_features.add('shell') +# For tests that require Darwin to run. +if platform.system() in ['Darwin']: + config.available_features.add('system-darwin') + # ANSI escape sequences in non-dumb terminal if platform.system() not in ['Windows']: config.available_features.add('ansi-escape-sequences') |