diff --git a/libcxx/test/configs/cmake-bridge.cfg.in b/libcxx/test/configs/cmake-bridge.cfg.in --- a/libcxx/test/configs/cmake-bridge.cfg.in +++ b/libcxx/test/configs/cmake-bridge.cfg.in @@ -2,6 +2,8 @@ @SERIALIZED_LIT_PARAMS@ +import lit + # # This file performs the bridge between the CMake configuration and the Lit # configuration files by setting up the LitConfig object and various Lit @@ -23,7 +25,7 @@ config.test_exec_root = '@CMAKE_BINARY_DIR@' # Add substitutions for bootstrapping the test suite configuration -config.substitutions.append(('%{cxx}', '@CMAKE_CXX_COMPILER@')) +config.substitutions.append(('%{cxx}', lit.TestRunner.quote('@CMAKE_CXX_COMPILER@'))) config.substitutions.append(('%{libcxx}', '@LIBCXX_SOURCE_DIR@')) config.substitutions.append(('%{install}', '@CMAKE_BINARY_DIR@')) config.substitutions.append(('%{include}', '%{install}/@LIBCXX_INSTALL_INCLUDE_DIR@')) diff --git a/libcxx/test/configs/llvm-libc++-mingw.cfg.in b/libcxx/test/configs/llvm-libc++-mingw.cfg.in new file mode 100644 --- /dev/null +++ b/libcxx/test/configs/llvm-libc++-mingw.cfg.in @@ -0,0 +1,32 @@ +# This testing configuration handles running the test suite against LLVM's libc++ +# using either a DLL or a static library, with MinGW/Clang on Windows. + +lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg') + +config.substitutions.append(('%{flags}', '')) +config.substitutions.append(('%{compile_flags}', + '%{user_compile_flags} -nostdinc++ -isystem %{include} -isystem %{target-include} -I %{libcxx}/test/support' +)) +config.substitutions.append(('%{link_flags}', + '%{user_link_flags} -nostdlib++ -L %{lib} -lc++' +)) +config.substitutions.append(('%{exec}', + '%{executor} --execdir %T --env PATH=%{lib} -- ' +)) + +# LIBCXX-WINDOWS-FIXME is the feature name used to XFAIL the +# initial Windows failures until they can be properly diagnosed +# and fixed. This allows easier detection of new test failures +# and regressions. Note: New failures should not be suppressed +# using this feature. (Also see llvm.org/PR32730) +config.available_features.add('LIBCXX-WINDOWS-FIXME') + +import os, site +site.addsitedir(os.path.join('@LIBCXX_SOURCE_DIR@', 'utils')) +import libcxx.test.params, libcxx.test.newconfig +libcxx.test.newconfig.configure( + libcxx.test.params.DEFAULT_PARAMETERS, + libcxx.test.features.DEFAULT_FEATURES, + config, + lit_config +) diff --git a/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in b/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in new file mode 100644 --- /dev/null +++ b/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in @@ -0,0 +1,32 @@ +# This testing configuration handles running the test suite against LLVM's libc++ +# using a DLL, with Clang-cl on Windows. + +lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg') + +config.substitutions.append(('%{flags}', '--driver-mode=g++')) +config.substitutions.append(('%{compile_flags}', + '%{user_compile_flags} -nostdinc++ -isystem %{include} -isystem %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX' +)) +config.substitutions.append(('%{link_flags}', + '%{user_link_flags} -nostdlib -L %{lib} -lc++ -lmsvcrt -lmsvcprt -loldnames' +)) +config.substitutions.append(('%{exec}', + '%{executor} --execdir %T --env PATH=%{lib} -- ' +)) + +# LIBCXX-WINDOWS-FIXME is the feature name used to XFAIL the +# initial Windows failures until they can be properly diagnosed +# and fixed. This allows easier detection of new test failures +# and regressions. Note: New failures should not be suppressed +# using this feature. (Also see llvm.org/PR32730) +config.available_features.add('LIBCXX-WINDOWS-FIXME') + +import os, site +site.addsitedir(os.path.join('@LIBCXX_SOURCE_DIR@', 'utils')) +import libcxx.test.params, libcxx.test.newconfig +libcxx.test.newconfig.configure( + libcxx.test.params.DEFAULT_PARAMETERS, + libcxx.test.features.DEFAULT_FEATURES, + config, + lit_config +) diff --git a/libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in b/libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in new file mode 100644 --- /dev/null +++ b/libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in @@ -0,0 +1,32 @@ +# This testing configuration handles running the test suite against LLVM's libc++ +# using a static library, with Clang-cl on Windows. + +lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg') + +config.substitutions.append(('%{flags}', '--driver-mode=g++')) +config.substitutions.append(('%{compile_flags}', + '%{user_compile_flags} -nostdinc++ -isystem %{include} -isystem %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX' +)) +config.substitutions.append(('%{link_flags}', + '%{user_link_flags} -nostdlib -L %{lib} -llibc++ -lmsvcrt -lmsvcprt -loldnames' +)) +config.substitutions.append(('%{exec}', + '%{executor} --execdir %T --env PATH=%{lib} -- ' +)) + +# LIBCXX-WINDOWS-FIXME is the feature name used to XFAIL the +# initial Windows failures until they can be properly diagnosed +# and fixed. This allows easier detection of new test failures +# and regressions. Note: New failures should not be suppressed +# using this feature. (Also see llvm.org/PR32730) +config.available_features.add('LIBCXX-WINDOWS-FIXME') + +import os, site +site.addsitedir(os.path.join('@LIBCXX_SOURCE_DIR@', 'utils')) +import libcxx.test.params, libcxx.test.newconfig +libcxx.test.newconfig.configure( + libcxx.test.params.DEFAULT_PARAMETERS, + libcxx.test.features.DEFAULT_FEATURES, + config, + lit_config +) diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot --- a/libcxx/utils/ci/run-buildbot +++ b/libcxx/utils/ci/run-buildbot @@ -598,13 +598,15 @@ # correctly when libc++ visibility attributes indicate dllimport linkage # anyway), thus just disable the experimental library. Remove this # setting when cmake and the test driver does the right thing automatically. - generate-cmake-libcxx-win -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF + generate-cmake-libcxx-win -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF \ + -DLIBCXX_TEST_CONFIG="llvm-libc++-shared-clangcl.cfg.in" echo "+++ Running the libc++ tests" ${NINJA} -vC "${BUILD_DIR}" check-cxx ;; clang-cl-static) clean - generate-cmake-libcxx-win -DLIBCXX_ENABLE_SHARED=OFF + generate-cmake-libcxx-win -DLIBCXX_ENABLE_SHARED=OFF \ + -DLIBCXX_TEST_CONFIG="llvm-libc++-static-clangcl.cfg.in" echo "+++ Running the libc++ tests" ${NINJA} -vC "${BUILD_DIR}" check-cxx ;; @@ -618,6 +620,7 @@ generate-cmake \ -DCMAKE_C_COMPILER=x86_64-w64-mingw32-clang \ -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-clang++ \ + -DLIBCXX_TEST_CONFIG="llvm-libc++-mingw.cfg.in" \ -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake" echo "+++ Running the libc++ tests" ${NINJA} -vC "${BUILD_DIR}" check-cxx @@ -627,6 +630,7 @@ generate-cmake \ -DCMAKE_C_COMPILER=x86_64-w64-mingw32-clang \ -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-clang++ \ + -DLIBCXX_TEST_CONFIG="llvm-libc++-mingw.cfg.in" \ -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake" \ -DLIBCXX_ENABLE_SHARED=OFF \ -DLIBUNWIND_ENABLE_SHARED=OFF diff --git a/libcxx/utils/libcxx/test/format.py b/libcxx/utils/libcxx/test/format.py --- a/libcxx/utils/libcxx/test/format.py +++ b/libcxx/utils/libcxx/test/format.py @@ -21,7 +21,7 @@ This is done by checking whether the %{cxx} substitution in that configuration supports certain compiler flags. """ - command = "%{{cxx}} -xc++ {} -Werror -fsyntax-only -Xclang -verify-ignore-unexpected".format(os.devnull) + command = "%{{cxx}} %{{flags}} %{{compile_flags}} -xc++ {} -Werror -fsyntax-only -Xclang -verify-ignore-unexpected".format(os.devnull) command = lit.TestRunner.applySubstitutions([command], config.substitutions, recursion_limit=config.recursiveExpansionLimit)[0] devNull = open(os.devnull, 'w') diff --git a/llvm/utils/lit/lit/LitConfig.py b/llvm/utils/lit/lit/LitConfig.py --- a/llvm/utils/lit/lit/LitConfig.py +++ b/llvm/utils/lit/lit/LitConfig.py @@ -169,6 +169,11 @@ line = inspect.getlineno(f) sys.stderr.write('%s: %s:%d: %s: %s\n' % (self.progname, file, line, kind, message)) + if self.isWindows: + # In an msys terminal, the writes to sys.stderr aren't visible + # on screen immediately. Flush them here to avoid broken/misoredered + # output. + sys.stderr.flush() def note(self, message): if not self.quiet: diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py --- a/llvm/utils/lit/lit/TestRunner.py +++ b/llvm/utils/lit/lit/TestRunner.py @@ -7,6 +7,7 @@ import re import stat import platform +import shlex import shutil import tempfile import threading @@ -239,6 +240,11 @@ return ''.join(result) +def quote(arg): + if kIsWindows: + return quote_windows_command([arg]) + return shlex.quote(arg) + # args are from 'export' or 'env' command. # Skips the command, and parses its arguments. # Modifies env accordingly.