diff options
author | Justin Lebar <jlebar@google.com> | 2016-11-18 00:41:27 +0000 |
---|---|---|
committer | Justin Lebar <jlebar@google.com> | 2016-11-18 00:41:27 +0000 |
commit | f91086b0a88e672ff5a796855057fc313fd10f7d (patch) | |
tree | b058b81d75738ddf155dc8bbc91feefdc325f2b5 /clang/lib/Frontend/CompilerInstance.cpp | |
parent | 66c4fd7987d216e91d219e5e8437673a7b0167f8 (diff) | |
download | bcm5719-llvm-f91086b0a88e672ff5a796855057fc313fd10f7d.tar.gz bcm5719-llvm-f91086b0a88e672ff5a796855057fc313fd10f7d.zip |
[CUDA] Initialize our header search using the host triple.
Summary:
This used to work because system headers are found in a (somewhat)
predictable set of locations on Linux. But this is not the case on
MacOS; without this change, we don't look in the right places for our
headers when doing device-side compilation on Mac.
Reviewers: tra
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D26776
llvm-svn: 287286
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index b96dc70cf5b..6fb880f7867 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -334,9 +334,16 @@ void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) { InitializePreprocessor(*PP, PPOpts, getPCHContainerReader(), getFrontendOpts()); - // Initialize the header search object. + // Initialize the header search object. In CUDA compilations, we use the aux + // triple (the host triple) to initialize our header search, since we need to + // find the host headers in order to compile the CUDA code. + const llvm::Triple *HeaderSearchTriple = &PP->getTargetInfo().getTriple(); + if (PP->getTargetInfo().getTriple().getOS() == llvm::Triple::CUDA && + PP->getAuxTargetInfo()) + HeaderSearchTriple = &PP->getAuxTargetInfo()->getTriple(); + ApplyHeaderSearchOptions(PP->getHeaderSearchInfo(), getHeaderSearchOpts(), - PP->getLangOpts(), PP->getTargetInfo().getTriple()); + PP->getLangOpts(), *HeaderSearchTriple); PP->setPreprocessedOutput(getPreprocessorOutputOpts().ShowCPP); |