Index: tools/llvm-config/llvm-config.cpp =================================================================== --- tools/llvm-config/llvm-config.cpp +++ tools/llvm-config/llvm-config.cpp @@ -257,6 +257,26 @@ GetComponentNames, nullptr, nullptr, DirSep); } +/// Remove all arguments beside -I, -D & -std from the args flags +/// This is mostly done to get rid of the warnings as they should +/// be managed by the downstream projects +/// +/// \param flag the raw list of flags +static std::string ignoreArguments(const char *flag) { + StringRef FlagStr(flag); + SmallVector Opts; + FlagStr.trim().split(Opts, ' '); + std::string args = ""; + for (StringRef Opt : Opts) { + if (Opt.startswith("-I") || Opt.startswith("-D") || Opt.startswith("-std")) { + args += Opt; + args += " "; + } + } + return args; +} + + int main(int argc, char **argv) { std::vector Components; bool PrintLibs = false, PrintLibNames = false, PrintLibFiles = false; @@ -487,11 +507,11 @@ } else if (Arg == "--cmakedir") { OS << ActiveCMakeDir << '\n'; } else if (Arg == "--cppflags") { - OS << ActiveIncludeOption << ' ' << LLVM_CPPFLAGS << '\n'; + OS << ActiveIncludeOption << ' ' << ignoreArguments(LLVM_CPPFLAGS) << '\n'; } else if (Arg == "--cflags") { - OS << ActiveIncludeOption << ' ' << LLVM_CFLAGS << '\n'; + OS << ActiveIncludeOption << ' ' << ignoreArguments(LLVM_CFLAGS) << '\n'; } else if (Arg == "--cxxflags") { - OS << ActiveIncludeOption << ' ' << LLVM_CXXFLAGS << '\n'; + OS << ActiveIncludeOption << ' ' << ignoreArguments(LLVM_CXXFLAGS) << '\n'; } else if (Arg == "--ldflags") { OS << ((HostTriple.isWindowsMSVCEnvironment()) ? "-LIBPATH:" : "-L") << ActiveLibDir << ' ' << LLVM_LDFLAGS << '\n';