diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -273,6 +273,8 @@ : Error<"%0 is not supported with -fembed-bitcode">; def err_drv_bitcode_unsupported_on_toolchain : Error< "-fembed-bitcode is not supported on versions of iOS prior to 6.0">; +def err_drv_stack_clash_protection_unsupported_on_toolchain : Error< + "-fstack-clash-protection is not supported on Windows or Mac OS X">; def err_drv_invalid_malign_branch_EQ : Error< "invalid argument '%0' to -malign-branch=; each element must be one of: %1">; diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -3077,12 +3077,14 @@ } } -static void RenderSCPOptions(const ToolChain &TC, const ArgList &Args, - ArgStringList &CmdArgs) { +static void RenderSCPOptions(const Driver &D, const ToolChain &TC, + const ArgList &Args, ArgStringList &CmdArgs) { const llvm::Triple &EffectiveTriple = TC.getEffectiveTriple(); - if (!EffectiveTriple.isOSLinux()) + if (EffectiveTriple.isOSWindows() || EffectiveTriple.isOSDarwin()) { + D.Diag(diag::err_drv_stack_clash_protection_unsupported_on_toolchain); return; + } if (!EffectiveTriple.isX86() && !EffectiveTriple.isSystemZ() && !EffectiveTriple.isPPC64()) @@ -4045,7 +4047,7 @@ // A header module compilation doesn't have a main input file, so invent a // fake one as a placeholder. - const char *ModuleName = [&]{ + const char *ModuleName = [&] { auto *ModuleNameArg = Args.getLastArg(options::OPT_fmodule_name_EQ); return ModuleNameArg ? ModuleNameArg->getValue() : ""; }(); @@ -5551,7 +5553,7 @@ CmdArgs.push_back(Args.MakeArgString("-mspeculative-load-hardening")); RenderSSPOptions(D, TC, Args, CmdArgs, KernelOrKext); - RenderSCPOptions(TC, Args, CmdArgs); + RenderSCPOptions(D, TC, Args, CmdArgs); RenderTrivialAutoVarInitOptions(D, TC, Args, CmdArgs); // Translate -mstackrealign