Skip to content

Commit d07a1b8

Browse files
kaadambryanpkc
authored andcommitted
Add Flang include directory to MSVC toolchain
1 parent dd1efa0 commit d07a1b8

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

clang/lib/Driver/ToolChains/MSVC.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,42 @@ void MSVCToolChain::AddSystemIncludeWithSubfolder(
712712
addSystemInclude(DriverArgs, CC1Args, path);
713713
}
714714

715+
#ifdef ENABLE_CLASSIC_FLANG
716+
/// Convert path list to Fortran frontend argument
717+
static void AddFlangSysIncludeArg(const ArgList &DriverArgs,
718+
ArgStringList &Flang1Args,
719+
ToolChain::path_list IncludePathList) {
720+
std::string ArgValue; // Path argument value
721+
722+
// Make up argument value consisting of paths separated by colons
723+
bool first = true;
724+
for (auto P : IncludePathList) {
725+
if (first) {
726+
first = false;
727+
} else {
728+
ArgValue += ";";
729+
}
730+
ArgValue += P;
731+
}
732+
733+
// Add the argument
734+
Flang1Args.push_back("-stdinc");
735+
Flang1Args.push_back(DriverArgs.MakeArgString(ArgValue));
736+
}
737+
738+
void MSVCToolChain::AddFlangSystemIncludeArgs(const ArgList &DriverArgs,
739+
ArgStringList &Flang1Args) const {
740+
path_list IncludePathList;
741+
const Driver &D = getDriver();
742+
if (DriverArgs.hasArg(options::OPT_nostdinc))
743+
return;
744+
SmallString<128> P(D.InstalledDir);
745+
llvm::sys::path::append(P, "../include");
746+
IncludePathList.push_back(P.c_str());
747+
AddFlangSysIncludeArg(DriverArgs, Flang1Args, IncludePathList);
748+
}
749+
#endif
750+
715751
void MSVCToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
716752
ArgStringList &CC1Args) const {
717753
if (DriverArgs.hasArg(options::OPT_nostdinc))

clang/lib/Driver/ToolChains/MSVC.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public ToolChain {
8484
return VSLayout == llvm::ToolsetLayout::VS2017OrNewer;
8585
}
8686

87+
#ifdef ENABLE_CLASSIC_FLANG
88+
void
89+
AddFlangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
90+
llvm::opt::ArgStringList &Flang1Args) const override;
91+
#endif
92+
8793
void
8894
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
8995
llvm::opt::ArgStringList &CC1Args) const override;

0 commit comments

Comments
 (0)