From 1ef9def6447291b2d05e61b78ae56690b62a1f0e Mon Sep 17 00:00:00 2001 From: Pedro Navarro Date: Wed, 17 May 2017 14:24:45 -0700 Subject: [PATCH] Add -foc-intrinsic-path to let the use specify a custom location for clang's intrinsic headers. This path is relative to clang's binary dir (which can be set with -foc-compiler-path) --- wrapper/main.cpp | 13 ++++++++++++- wrapper/target.cpp | 4 ++++ wrapper/target.h | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/wrapper/main.cpp b/wrapper/main.cpp index 7bc1047..405fae7 100644 --- a/wrapper/main.cpp +++ b/wrapper/main.cpp @@ -172,6 +172,11 @@ bool compilerpath(Target &target, const char *, const char *path, char **) { return true; } +bool intrinsicpath(Target &target, const char *, const char *path, char **) { + target.intrinsicpath = path; + return true; +} + bool runprog(Target &target, const char *, const char *progname, char **cargs) { auto *prog = program::getprog(progname); @@ -263,7 +268,13 @@ constexpr struct Opt { {"-icxx-isystem", checkincludepath, true, true}, {"-cxx-isystem", checkincludepath, true, true}, {"-I", checkincludepath, true, true}, - {"-foc-compiler-path", compilerpath, true, false, "="} // sets a custom path for the compiler + + // sets a custom path for the compiler + {"-foc-compiler-path", compilerpath, true, false, "="}, + + // specifies an additional directory to search when looking for clang's + // intrinsic paths + {"-foc-intrinsic-path", intrinsicpath, true, false, "="} }; bool parse(int argc, char **argv, Target &target) { diff --git a/wrapper/target.cpp b/wrapper/target.cpp index 81d369b..48f0c48 100644 --- a/wrapper/target.cpp +++ b/wrapper/target.cpp @@ -409,6 +409,10 @@ do { \ TRYDIR2("/../include/clang"); TRYDIR2("/usr/include/clang"); + if (!intrinsicpath.empty()) { + TRYDIR2(intrinsicpath); + } + return false; #undef TRYDIR #undef TRYDIR2 diff --git a/wrapper/target.h b/wrapper/target.h index 9c96679..88074f9 100644 --- a/wrapper/target.h +++ b/wrapper/target.h @@ -149,6 +149,7 @@ struct Target { string_vector args; const char *language; char execpath[PATH_MAX + 1]; + std::string intrinsicpath; }; } // namespace target