diff options
-rw-r--r-- | doc/manual/castxml.1.rst | 2 | ||||
-rw-r--r-- | src/Options.h | 3 | ||||
-rw-r--r-- | src/RunClang.cxx | 2 | ||||
-rw-r--r-- | src/castxml.cxx | 6 | ||||
-rw-r--r-- | test/CMakeLists.txt | 2 | ||||
-rw-r--r-- | test/expect/cmd.cc-gnu-tgt-explicit.stderr.txt | 2 | ||||
-rw-r--r-- | test/expect/cmd.cc-msvc-tgt-explicit.stderr.txt | 2 |
7 files changed, 17 insertions, 2 deletions
diff --git a/doc/manual/castxml.1.rst b/doc/manual/castxml.1.rst index ca555f9..a1a0172 100644 --- a/doc/manual/castxml.1.rst +++ b/doc/manual/castxml.1.rst @@ -43,6 +43,8 @@ Remaining options are given to the internal Clang compiler. ``<cc>`` names a compiler (e.g. ``/usr/bin/gcc`` or ``cl``) and ``<cc-opt>...`` specifies options that may affect its target (e.g. ``-m32``). + The target platform detected from the given compiler may be + overridden by a separate Clang ``-target`` option. ``--castxml-gccxml`` Generate XML output in a format close to that of `gccxml`_. diff --git a/src/Options.h b/src/Options.h index 376af4d..7d9c5f5 100644 --- a/src/Options.h +++ b/src/Options.h @@ -22,10 +22,11 @@ struct Options { - Options(): PPOnly(false), GccXml(false), HaveCC(false) {} + Options(): PPOnly(false), GccXml(false), HaveCC(false), HaveTarget(false) {} bool PPOnly; bool GccXml; bool HaveCC; + bool HaveTarget; struct Include { Include(std::string const& d, bool f = false): Directory(d), Framework(f) {} diff --git a/src/RunClang.cxx b/src/RunClang.cxx index e305c0b..1d38de4 100644 --- a/src/RunClang.cxx +++ b/src/RunClang.cxx @@ -363,7 +363,7 @@ int runClang(const char* const* argBeg, if(opts.HaveCC) { // Configure target to match that of given compiler. - if(!opts.Triple.empty()) { + if(!opts.HaveTarget && !opts.Triple.empty()) { args.push_back("-target"); args.push_back(opts.Triple.c_str()); } diff --git a/src/castxml.cxx b/src/castxml.cxx index b085991..cb0570b 100644 --- a/src/castxml.cxx +++ b/src/castxml.cxx @@ -229,6 +229,12 @@ int main(int argc_in, const char** argv_in) clang_args.push_back(argv[i]); } else { clang_args.push_back(argv[i]); + if (strcmp(argv[i], "-target") == 0 || + strcmp(argv[i], "--target") == 0 || + strncmp(argv[i], "-target=", 8) == 0 || + strncmp(argv[i], "--target=", 9) == 0) { + opts.HaveTarget = true; + } } } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6698ed8..e51570a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -130,6 +130,7 @@ castxml_test_cmd(cc-gnu-c-cmd --castxml-cc-gnu $<TARGET_FILE:cc-gnu> ${empty_c} castxml_test_cmd(cc-gnu-cxx-E --castxml-cc-gnu $<TARGET_FILE:cc-gnu> ${empty_cxx} -E -dM) castxml_test_cmd(cc-gnu-cxx-cmd --castxml-cc-gnu $<TARGET_FILE:cc-gnu> ${empty_cxx} "-###") castxml_test_cmd(cc-gnu-tgt-amd64 --castxml-cc-gnu "(" $<TARGET_FILE:cc-gnu> --cc-define=__amd64__ ")" ${empty_cxx} "-###") +castxml_test_cmd(cc-gnu-tgt-explicit --castxml-cc-gnu "(" $<TARGET_FILE:cc-gnu> ")" -target explicit-target-triple ${empty_cxx} "-###") castxml_test_cmd(cc-gnu-tgt-i386 --castxml-cc-gnu "(" $<TARGET_FILE:cc-gnu> --cc-define=__i386__ ")" ${empty_cxx} "-###") castxml_test_cmd(cc-gnu-tgt-mingw --castxml-cc-gnu "(" $<TARGET_FILE:cc-gnu> --cc-define=_WIN32 --cc-define=__MINGW32__ ")" ${empty_cxx} "-###") castxml_test_cmd(cc-gnu-tgt-win --castxml-cc-gnu "(" $<TARGET_FILE:cc-gnu> --cc-define=_WIN32 ")" ${empty_cxx} "-###") @@ -143,6 +144,7 @@ castxml_test_cmd(cc-msvc-c-cmd --castxml-cc-msvc $<TARGET_FILE:cc-msvc> ${empty_ castxml_test_cmd(cc-msvc-cxx-E --castxml-cc-msvc $<TARGET_FILE:cc-msvc> ${empty_cxx} -E -dM) castxml_test_cmd(cc-msvc-cxx-cmd --castxml-cc-msvc $<TARGET_FILE:cc-msvc> ${empty_cxx} "-###") castxml_test_cmd(cc-msvc-tgt-amd64 --castxml-cc-msvc "(" $<TARGET_FILE:cc-msvc> --cc-define=_M_AMD64 ")" ${empty_cxx} "-###") +castxml_test_cmd(cc-msvc-tgt-explicit --castxml-cc-msvc "(" $<TARGET_FILE:cc-msvc> ")" -target explicit-target-triple ${empty_cxx} "-###") castxml_test_cmd(cc-msvc-tgt-i386 --castxml-cc-msvc "(" $<TARGET_FILE:cc-msvc> --cc-define=_M_IX86 ")" ${empty_cxx} "-###") castxml_test_cmd(cc-msvc-tgt-win --castxml-cc-msvc "(" $<TARGET_FILE:cc-msvc> --cc-define=_WIN32 ")" ${empty_cxx} "-###") castxml_test_cmd(cc-msvc-tgt-x86_64 --castxml-cc-msvc "(" $<TARGET_FILE:cc-msvc> --cc-define=_M_X64 ")" ${empty_cxx} "-###") diff --git a/test/expect/cmd.cc-gnu-tgt-explicit.stderr.txt b/test/expect/cmd.cc-gnu-tgt-explicit.stderr.txt new file mode 100644 index 0000000..c00c761 --- /dev/null +++ b/test/expect/cmd.cc-gnu-tgt-explicit.stderr.txt @@ -0,0 +1,2 @@ +Target: explicit-target-triple +. diff --git a/test/expect/cmd.cc-msvc-tgt-explicit.stderr.txt b/test/expect/cmd.cc-msvc-tgt-explicit.stderr.txt new file mode 100644 index 0000000..c00c761 --- /dev/null +++ b/test/expect/cmd.cc-msvc-tgt-explicit.stderr.txt @@ -0,0 +1,2 @@ +Target: explicit-target-triple +. |