Index: include/clang/Driver/SanitizerArgs.h =================================================================== --- include/clang/Driver/SanitizerArgs.h +++ include/clang/Driver/SanitizerArgs.h @@ -38,6 +38,7 @@ bool AsanGlobalsDeadStripping = false; bool LinkCXXRuntimes = false; bool NeedPIE = false; + bool SafeStackRuntime = false; bool Stats = false; bool TsanMemoryAccess = true; bool TsanFuncEntryExit = true; @@ -58,9 +59,7 @@ } bool needsUbsanRt() const; bool needsDfsanRt() const { return Sanitizers.has(SanitizerKind::DataFlow); } - bool needsSafeStackRt() const { - return Sanitizers.has(SanitizerKind::SafeStack); - } + bool needsSafeStackRt() const { return SafeStackRuntime; } bool needsCfiRt() const; bool needsCfiDiagRt() const; bool needsStatsRt() const { return Stats; } Index: lib/Driver/SanitizerArgs.cpp =================================================================== --- lib/Driver/SanitizerArgs.cpp +++ lib/Driver/SanitizerArgs.cpp @@ -605,6 +605,11 @@ AsanUseAfterScope = false; } + if (AllAddedKinds & SafeStack) { + // SafeStack runtime is built into the system on Fuchsia. + SafeStackRuntime = !TC.getTriple().isOSFuchsia(); + } + // Parse -link-cxx-sanitizer flag. LinkCXXRuntimes = Args.hasArg(options::OPT_fsanitize_link_cxx_runtime) || D.CCCIsCXX(); Index: test/Driver/fuchsia.c =================================================================== --- test/Driver/fuchsia.c +++ test/Driver/fuchsia.c @@ -45,6 +45,8 @@ // RUN: -fsanitize=safe-stack 2>&1 \ // RUN: | FileCheck %s -check-prefix=CHECK-SAFESTACK // CHECK-SAFESTACK: "-fsanitize=safe-stack" +// CHECK-SAFESTACK-NOT: "{{.*[/\\]}}libclang_rt.safestack-x86_64.a" +// CHECK-SAFESTACK-NOT: "__safestack_init" // RUN: %clang %s -### --target=x86_64-unknown-fuchsia \ // RUN: -fsanitize=address 2>&1 \