diff options
author | Justin Lebar <jlebar@google.com> | 2017-02-19 19:05:32 +0000 |
---|---|---|
committer | Justin Lebar <jlebar@google.com> | 2017-02-19 19:05:32 +0000 |
commit | 63152d10c9fc88c9d9e942b46ef2cd3d254ff452 (patch) | |
tree | f10fff3d32a580a9d8f3222663ef44ec74382bec /clang/lib/Driver/Tools.cpp | |
parent | 4271186f9ce80be777e9b84fe0bc02798df65663 (diff) | |
download | llvm-63152d10c9fc88c9d9e942b46ef2cd3d254ff452.zip llvm-63152d10c9fc88c9d9e942b46ef2cd3d254ff452.tar.gz llvm-63152d10c9fc88c9d9e942b46ef2cd3d254ff452.tar.bz2 |
[CUDA] Don't pass -stack-protector to NVPTX compilations.
We can't support stack-protector on NVPTX because NVPTX doesn't expose a
stack to the compiler!
Fixes PR32009.
llvm-svn: 295609
Diffstat (limited to 'clang/lib/Driver/Tools.cpp')
-rw-r--r-- | clang/lib/Driver/Tools.cpp | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index bc0796f..9a8eebc 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -5544,25 +5544,29 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // -stack-protector=0 is default. unsigned StackProtectorLevel = 0; - if (Arg *A = Args.getLastArg(options::OPT_fno_stack_protector, - options::OPT_fstack_protector_all, - options::OPT_fstack_protector_strong, - options::OPT_fstack_protector)) { - if (A->getOption().matches(options::OPT_fstack_protector)) { - StackProtectorLevel = std::max<unsigned>( - LangOptions::SSPOn, - getToolChain().GetDefaultStackProtectorLevel(KernelOrKext)); - } else if (A->getOption().matches(options::OPT_fstack_protector_strong)) - StackProtectorLevel = LangOptions::SSPStrong; - else if (A->getOption().matches(options::OPT_fstack_protector_all)) - StackProtectorLevel = LangOptions::SSPReq; - } else { - StackProtectorLevel = - getToolChain().GetDefaultStackProtectorLevel(KernelOrKext); - // Only use a default stack protector on Darwin in case -ffreestanding - // is not specified. - if (Triple.isOSDarwin() && !IsHosted) - StackProtectorLevel = 0; + // NVPTX doesn't support stack protectors; from the compiler's perspective, it + // doesn't even have a stack! + if (!Triple.isNVPTX()) { + if (Arg *A = Args.getLastArg(options::OPT_fno_stack_protector, + options::OPT_fstack_protector_all, + options::OPT_fstack_protector_strong, + options::OPT_fstack_protector)) { + if (A->getOption().matches(options::OPT_fstack_protector)) { + StackProtectorLevel = std::max<unsigned>( + LangOptions::SSPOn, + getToolChain().GetDefaultStackProtectorLevel(KernelOrKext)); + } else if (A->getOption().matches(options::OPT_fstack_protector_strong)) + StackProtectorLevel = LangOptions::SSPStrong; + else if (A->getOption().matches(options::OPT_fstack_protector_all)) + StackProtectorLevel = LangOptions::SSPReq; + } else { + StackProtectorLevel = + getToolChain().GetDefaultStackProtectorLevel(KernelOrKext); + // Only use a default stack protector on Darwin in case -ffreestanding + // is not specified. + if (Triple.isOSDarwin() && !IsHosted) + StackProtectorLevel = 0; + } } if (StackProtectorLevel) { CmdArgs.push_back("-stack-protector"); |