From a67cef4aee0ce6d0ad5eba7631dd5908e12a5353 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 27 Apr 2020 09:58:14 -0400 Subject: Detect: Add MSVC target triple component When `_MSC_VER` is among compiler predefines, the target ABI is MSVC. --- src/Detect.cxx | 3 +++ test/expect/cmd.cc-msvc-tgt-amd64.stderr.txt | 3 ++- test/expect/cmd.cc-msvc-tgt-i386.stderr.txt | 3 ++- test/expect/cmd.cc-msvc-tgt-win.stderr.txt | 2 +- test/expect/cmd.cc-msvc-tgt-x86_64.stderr.txt | 3 ++- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Detect.cxx b/src/Detect.cxx index ec3c6ce..fa88499 100644 --- a/src/Detect.cxx +++ b/src/Detect.cxx @@ -96,6 +96,9 @@ static void setTriple(Options& opts) triple.setVendorName("pc"); triple.setOSName("windows"); } + if (pd.find("#define _MSC_VER ") != pd.npos) { + triple.setEnvironmentName("msvc"); + } if (pd.find("#define __MINGW32__ 1") != pd.npos) { triple.setEnvironmentName("gnu"); } diff --git a/test/expect/cmd.cc-msvc-tgt-amd64.stderr.txt b/test/expect/cmd.cc-msvc-tgt-amd64.stderr.txt index c3aedee..94d0708 100644 --- a/test/expect/cmd.cc-msvc-tgt-amd64.stderr.txt +++ b/test/expect/cmd.cc-msvc-tgt-amd64.stderr.txt @@ -1,3 +1,4 @@ Target: amd64-[^ -]+ +]+-msvc[^ +]* . diff --git a/test/expect/cmd.cc-msvc-tgt-i386.stderr.txt b/test/expect/cmd.cc-msvc-tgt-i386.stderr.txt index cb02cd7..618b26f 100644 --- a/test/expect/cmd.cc-msvc-tgt-i386.stderr.txt +++ b/test/expect/cmd.cc-msvc-tgt-i386.stderr.txt @@ -1,3 +1,4 @@ Target: i386-[^ -]+ +]+-msvc[^ +]* . diff --git a/test/expect/cmd.cc-msvc-tgt-win.stderr.txt b/test/expect/cmd.cc-msvc-tgt-win.stderr.txt index 05f7eea..93064ab 100644 --- a/test/expect/cmd.cc-msvc-tgt-win.stderr.txt +++ b/test/expect/cmd.cc-msvc-tgt-win.stderr.txt @@ -1,4 +1,4 @@ Target: [^ --]+-pc-windows[^ +-]+-pc-windows-msvc[^ ]* . diff --git a/test/expect/cmd.cc-msvc-tgt-x86_64.stderr.txt b/test/expect/cmd.cc-msvc-tgt-x86_64.stderr.txt index 17ecd16..fad6c0a 100644 --- a/test/expect/cmd.cc-msvc-tgt-x86_64.stderr.txt +++ b/test/expect/cmd.cc-msvc-tgt-x86_64.stderr.txt @@ -1,3 +1,4 @@ Target: x86_64-[^ -]+ +]+-msvc[^ +]* . -- cgit v0.12 From 1e424683de433de4496b8626bd34719b9bc638d8 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 27 Apr 2020 10:01:49 -0400 Subject: test: Run cc-msvc-builtin-1923 test with suitable target triple The test added by commit 4ef8cb85 (test: Add case for __builtin_assume_aligned declaration in MSVC header, 2020-04-03, v0.3.3~2^2) uses the MSVC `__cdecl` calling convention specifier. That is not supported by all target ABIs, so update the test to run CastXML using the `x86_64-pc-windows-msvc` target triple. Fixes: #165 --- test/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4b6139d..8dd7eee 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -400,7 +400,9 @@ castxml_test_cmd(cc-msvc-std-explicit --castxml-cc-msvc "(" $ -msc=1800 ")" ${empty_cxx} -E -dM) castxml_test_cmd(cc-msvc-builtin-1900-E --castxml-cc-msvc "(" $ -msc=1900 ")" ${empty_cxx} -E -dM) castxml_test_cmd(cc-msvc-builtin-1900 --castxml-cc-msvc "(" $ -msc=1900 ")" ${input}/make_integer_seq.cxx) -castxml_test_cmd(cc-msvc-builtin-1923 --castxml-cc-msvc "(" $ -msc=1923 ")" ${input}/assume_aligned.cxx) +if(";${LLVM_TARGETS_TO_BUILD};" MATCHES ";X86;") + castxml_test_cmd(cc-msvc-builtin-1923 --castxml-cc-msvc "(" $ -msc=1923 --cc-define=_M_X64 ")" ${input}/assume_aligned.cxx) +endif() castxml_test_cmd(cc-msvc-c-bad-cmd --castxml-cc-msvc-c "(" cc-msvc-c-bad-cmd ")" ${empty_c}) castxml_test_cmd(cc-msvc-c-src-c-E --castxml-cc-msvc-c $ ${empty_c} -E -dM) castxml_test_cmd(cc-msvc-c-src-c-cmd --castxml-cc-msvc-c $ ${empty_c} "-###") -- cgit v0.12