Index: lib/Driver/ToolChains/Clang.cpp =================================================================== --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -4049,7 +4049,8 @@ ABICompatArg->render(Args, CmdArgs); // Add runtime flag for PS4 when PGO, coverage, or sanitizers are enabled. - if (RawTriple.isPS4CPU()) { + if (RawTriple.isPS4CPU() && + !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) { PS4cpu::addProfileRTArgs(TC, Args, CmdArgs); PS4cpu::addSanitizerArgs(TC, CmdArgs); } Index: lib/Driver/ToolChains/PS4CPU.cpp =================================================================== --- lib/Driver/ToolChains/PS4CPU.cpp +++ lib/Driver/ToolChains/PS4CPU.cpp @@ -121,7 +121,8 @@ assert(Output.isNothing() && "Invalid output."); } - AddPS4SanitizerArgs(ToolChain, CmdArgs); + if(!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) + AddPS4SanitizerArgs(ToolChain, CmdArgs); Args.AddAllArgs(CmdArgs, options::OPT_L); Args.AddAllArgs(CmdArgs, options::OPT_T_Group); @@ -190,7 +191,8 @@ assert(Output.isNothing() && "Invalid output."); } - AddPS4SanitizerArgs(ToolChain, CmdArgs); + if(!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) + AddPS4SanitizerArgs(ToolChain, CmdArgs); if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) { const char *crt1 = nullptr; Index: test/Driver/fsanitize.c =================================================================== --- test/Driver/fsanitize.c +++ test/Driver/fsanitize.c @@ -735,6 +735,10 @@ // CHECK-ASAN-PS4: --dependent-lib=libSceDbgAddressSanitizer_stub_weak.a // CHECK-ASAN-PS4-NOT: {{(\.(o|bc)"? |-l).*-lSceDbgAddressSanitizer_stub_weak}} // CHECK-ASAN-PS4: -lSceDbgAddressSanitizer_stub_weak +// RUN: %clang -target x86_64-scei-ps4 -fsanitize=address -nostdlib %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-NOLIB-PS4 +// RUN: %clang -target x86_64-scei-ps4 -fsanitize=address -nodefaultlibs %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-NOLIB-PS4 +// RUN: %clang -target x86_64-scei-ps4 -fsanitize=address -nodefaultlibs -nostdlib %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-NOLIB-PS4 +// CHECK-ASAN-NOLIB-PS4-NOT: SceDbgAddressSanitizer_stub_weak // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-minimal-runtime %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-MINIMAL // CHECK-ASAN-MINIMAL: error: invalid argument '-fsanitize-minimal-runtime' not allowed with '-fsanitize=address' Index: test/Driver/sanitizer-ld.c =================================================================== --- test/Driver/sanitizer-ld.c +++ test/Driver/sanitizer-ld.c @@ -673,6 +673,13 @@ // CHECK-AUBSAN-PS4: "{{.*}}ld{{(.gold)?(.exe)?}}" // CHECK-AUBSAN-PS4: -lSceDbgAddressSanitizer_stub_weak +// RUN: %clang -fsanitize=address,undefined %s -### -o %t.o 2>&1 \ +// RUN: -target x86_64-scei-ps4 -fuse-ld=ld \ +// RUN: -shared \ +// RUN: -nostdlib \ +// RUN: | FileCheck --check-prefix=CHECK-NOLIB-PS4 %s +// CHECK-NOLIB-PS4-NOT: SceDbgAddressSanitizer_stub_weak + // RUN: %clang -fsanitize=efficiency-cache-frag %s -### -o %t.o 2>&1 \ // RUN: -target x86_64-unknown-linux -fuse-ld=ld \ // RUN: | FileCheck --check-prefix=CHECK-ESAN-LINUX %s