diff --git a/clang/test/Driver/clang-offload-bundler.c b/clang/test/Driver/clang-offload-bundler.c --- a/clang/test/Driver/clang-offload-bundler.c +++ b/clang/test/Driver/clang-offload-bundler.c @@ -70,9 +70,9 @@ // RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -outputs=%t.i,%t.tgt1 -inputs=%t.bundle.i -unbundle 2>&1 | FileCheck %s --check-prefix CK-ERR4 // CK-ERR4: error: number of output files and targets should match in unbundling mode -// RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -inputs=%t.i,%t.tgt1,%t.tgt2.notexist -outputs=%t.bundle.i 2>&1 | FileCheck %s -DFILE=%t.tgt2.notexist --check-prefix CK-ERR5 -// RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -outputs=%t.i,%t.tgt1,%t.tgt2 -inputs=%t.bundle.i.notexist -unbundle 2>&1 | FileCheck %s -DFILE=%t.bundle.i.notexist --check-prefix CK-ERR5 -// CK-ERR5: error: '[[FILE]]': {{N|n}}o such file or directory +// RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -inputs=%t.i,%t.tgt1,%t.tgt2.notexist -outputs=%t.bundle.i 2>&1 | FileCheck %s -DFILE=%t.tgt2.notexist -DMSG=%errc_ENOENT --check-prefix CK-ERR5 +// RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -outputs=%t.i,%t.tgt1,%t.tgt2 -inputs=%t.bundle.i.notexist -unbundle 2>&1 | FileCheck %s -DFILE=%t.bundle.i.notexist -DMSG=%errc_ENOENT --check-prefix CK-ERR5 +// CK-ERR5: error: '[[FILE]]': [[MSG]] // RUN: not clang-offload-bundler -type=invalid -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -inputs=%t.i,%t.tgt1,%t.tgt2 -outputs=%t.bundle.i 2>&1 | FileCheck %s -DTYPE=invalid --check-prefix CK-ERR6 // CK-ERR6: error: '[[TYPE]]': invalid file type specified diff --git a/clang/test/Frontend/output-failures.c b/clang/test/Frontend/output-failures.c --- a/clang/test/Frontend/output-failures.c +++ b/clang/test/Frontend/output-failures.c @@ -1,4 +1,4 @@ // RUN: not %clang_cc1 -emit-llvm -o %t.doesnotexist/somename %s 2> %t -// RUN: FileCheck -check-prefix=OUTPUTFAIL -input-file=%t %s +// RUN: FileCheck -check-prefix=OUTPUTFAIL -DMSG=%errc_ENOENT -input-file=%t %s -// OUTPUTFAIL: error: unable to open output file '{{.*}}doesnotexist{{.}}somename': '{{[nN]}}o such file or directory' +// OUTPUTFAIL: error: unable to open output file '{{.*}}doesnotexist{{.}}somename': '[[MSG]]' diff --git a/clang/test/Frontend/stats-file.c b/clang/test/Frontend/stats-file.c --- a/clang/test/Frontend/stats-file.c +++ b/clang/test/Frontend/stats-file.c @@ -4,5 +4,5 @@ // ... here come some json values ... // CHECK: } -// RUN: %clang_cc1 -emit-llvm -o %t -stats-file=%t.doesnotexist/bla %s 2>&1 | FileCheck -check-prefix=OUTPUTFAIL %s -// OUTPUTFAIL: warning: unable to open statistics output file '{{.*}}doesnotexist{{.}}bla': '{{[Nn]}}o such file or directory' +// RUN: %clang_cc1 -emit-llvm -o %t -stats-file=%t.doesnotexist/bla %s 2>&1 | FileCheck -DMSG=%errc_ENOENT -check-prefix=OUTPUTFAIL %s +// OUTPUTFAIL: warning: unable to open statistics output file '{{.*}}doesnotexist{{.}}bla': '[[MSG]]' diff --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt --- a/lld/CMakeLists.txt +++ b/lld/CMakeLists.txt @@ -111,6 +111,10 @@ set(LLD_INCLUDE_DIR ${LLD_SOURCE_DIR}/include ) set(LLD_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) +if (LLD_BUILT_STANDALONE) + set(LLVM_HOST_TRIPLE ${TARGET_TRIPLE}) +endif() + set(LLD_VENDOR ${PACKAGE_VENDOR} CACHE STRING "Vendor-specific text for showing with version information.") diff --git a/lld/test/ELF/basic.s b/lld/test/ELF/basic.s --- a/lld/test/ELF/basic.s +++ b/lld/test/ELF/basic.s @@ -219,8 +219,8 @@ # INVRSP: invalid response file quoting: patatino # RUN: not ld.lld %t.foo -o /dev/null 2>&1 | \ -# RUN: FileCheck --check-prefix=MISSING %s -# MISSING: cannot open {{.*}}.foo: {{[Nn]}}o such file or directory +# RUN: FileCheck -DMSG=%errc_ENOENT --check-prefix=MISSING %s +# MISSING: cannot open {{.*}}.foo: [[MSG]] # RUN: not ld.lld -o /dev/null 2>&1 | \ # RUN: FileCheck --check-prefix=NO_INPUT %s diff --git a/lld/test/lit.site.cfg.py.in b/lld/test/lit.site.cfg.py.in --- a/lld/test/lit.site.cfg.py.in +++ b/lld/test/lit.site.cfg.py.in @@ -11,6 +11,7 @@ config.lld_obj_root = "@LLD_BINARY_DIR@" config.lld_libs_dir = "@LLVM_LIBRARY_OUTPUT_INTDIR@" config.lld_tools_dir = "@LLVM_RUNTIME_OUTPUT_INTDIR@" +config.host_triple = "@LLVM_HOST_TRIPLE@" config.target_triple = "@TARGET_TRIPLE@" config.python_executable = "@Python3_EXECUTABLE@" config.have_zlib = @LLVM_ENABLE_ZLIB@ diff --git a/llvm/docs/TestingGuide.rst b/llvm/docs/TestingGuide.rst --- a/llvm/docs/TestingGuide.rst +++ b/llvm/docs/TestingGuide.rst @@ -537,6 +537,14 @@ Example: ``%:s: C\Desktop Files\foo_test.s.tmp`` +``%errc_`` + + Some error messages may be substituted to allow different spellings + based on the host platform. + + Example (%errc_ENOENT): ``No such file or directory`` + + Example (%errc_ENOENT): ``no such file or directory`` **LLVM-specific substitutions:** diff --git a/llvm/test/Object/archive-extract.test b/llvm/test/Object/archive-extract.test --- a/llvm/test/Object/archive-extract.test +++ b/llvm/test/Object/archive-extract.test @@ -57,5 +57,5 @@ RUN: llvm-ar p %p/Inputs/thin.a evenlen | FileCheck %s --check-prefix=EVENLEN EVENLEN: evenlen -RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s --check-prefix=MISSING -MISSING: error: {{N|n}}o such file or directory +RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s --DMSG=%errc_ENOENT --check-prefix=MISSING +MISSING: error: [[MSG]] diff --git a/llvm/test/Object/directory.ll b/llvm/test/Object/directory.ll --- a/llvm/test/Object/directory.ll +++ b/llvm/test/Object/directory.ll @@ -1,6 +1,6 @@ ;RUN: rm -rf %t && mkdir -p %t -;RUN: not llvm-ar r %t/test.a . 2>&1 | FileCheck %s -;CHECK: .: {{I|i}}s a directory +;RUN: not llvm-ar r %t/test.a . 2>&1 | FileCheck -DMSG=%errc_EISDIR %s +;CHECK: .: [[MSG]] ;RUN: rm -f %t/test.a ;RUN: touch %t/a-very-long-file-name diff --git a/llvm/test/tools/llvm-ar/move.test b/llvm/test/tools/llvm-ar/move.test --- a/llvm/test/tools/llvm-ar/move.test +++ b/llvm/test/tools/llvm-ar/move.test @@ -82,9 +82,9 @@ ## Member does not exist: # RUN: llvm-ar rc %t/missing.a %t/1.o %t/2.o %t/3.o # RUN: not llvm-ar m %t/missing.a %t/missing.txt 2>&1 \ -# RUN: | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt +# RUN: | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt -DMSG=%errc_ENOENT -# MISSING-FILE: error: [[FILE]]: {{[nN]}}o such file or directory +# MISSING-FILE: error: [[FILE]]: [[MSG]] --- !ELF FileHeader: diff --git a/llvm/utils/lit/lit/llvm/config.py b/llvm/utils/lit/lit/llvm/config.py --- a/llvm/utils/lit/lit/llvm/config.py +++ b/llvm/utils/lit/lit/llvm/config.py @@ -345,6 +345,21 @@ self.config.substitutions.extend(substitutions) return True + def add_err_msg_substitutions(self): + triple = "" + if hasattr(self.config, 'host_triple'): + triple = self.config.host_triple + + if (re.match(r's390x-.*-zos', triple)): + self.config.substitutions.append(('%errc_ENOENT', '\'EDC5129I No such file or directory.\'')) + self.config.substitutions.append(('%errc_EISDIR', '\'EDC5123I Is a directory.\'')) + elif (re.match(r'.*windows.*', triple)): + self.config.substitutions.append(('%errc_ENOENT', '\'no such file or directory\'')) + self.config.substitutions.append(('%errc_EISDIR', '\'is a directory\'')) + else: + self.config.substitutions.append(('%errc_ENOENT', '\'No such file or directory\'')) + self.config.substitutions.append(('%errc_EISDIR', '\'Is a directory\'')) + def use_default_substitutions(self): tool_patterns = [ ToolSubst('FileCheck', unresolved='fatal'), @@ -358,6 +373,8 @@ self.add_tool_substitutions( tool_patterns, [self.config.llvm_tools_dir]) + self.add_err_msg_substitutions() + def use_llvm_tool(self, name, search_env=None, required=False, quiet=False): """Find the executable program 'name', optionally using the specified environment variable as an override before searching the