Skip to content

Commit

Permalink
[libc++] Make sure we include %{flags} when building with the new format
Browse files Browse the repository at this point in the history
Otherwise, we're missing some flags like the flags that are used by
sanitizer builds and the 32-bit builds. In the long term, I think it
would be better to have only %{compile_flags} and %{link_flags}, but
for the benefit of adopting the new format by default, I think it's OK
to add %{flags} to it.
  • Loading branch information
ldionne committed Apr 6, 2020
1 parent 38e0720 commit 4e52944
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
Expand Up @@ -16,7 +16,7 @@
// appear first in the command-line or not.

// FILE_DEPENDENCIES: %t.exe
// RUN: %{cxx} %{compile_flags} %{link_flags} -o %t.exe %s
// RUN: %{cxx} %{flags} %{compile_flags} %{link_flags} -o %t.exe %s
// RUN: %{exec} %t.exe 0
// RUN: %{exec} ! %t.exe 1

Expand Down
Expand Up @@ -8,12 +8,13 @@

// Make sure we have access to the following substitutions at all times:
// - %{cxx}
// - %{flags}
// - %{compile_flags}
// - %{link_flags}
// - %{exec}

// FILE_DEPENDENCIES: %t.exe
// RUN: %{cxx} %{compile_flags} %{link_flags} -o %t.exe %s
// RUN: %{cxx} %{flags} %{compile_flags} %{link_flags} -o %t.exe %s
// RUN: %{exec} %t.exe "HELLO"

#include <cassert>
Expand Down
27 changes: 14 additions & 13 deletions libcxx/utils/libcxx/test/newformat.py
Expand Up @@ -41,12 +41,13 @@ class CxxStandardLibraryTest(lit.formats.TestFormat):
%{cxx} - A command that can be used to invoke the compiler
%{compile_flags} - Flags to use when compiling a test case
%{link_flags} - Flags to use when linking a test case
%{flags} - Flags to use either when compiling or linking a test case
%{exec} - A command to prefix the execution of executables
Note that when building an executable (as opposed to only compiling a source
file), both %{compile_flags} and %{link_flags} will be used in the same
command line. In other words, the test format doesn't perform separate
compilation and linking steps in this case.
file), all three of ${flags}, %{compile_flags} and %{link_flags} will be used
in the same command line. In other words, the test format doesn't perform
separate compilation and linking steps in this case.
In addition to everything that's supported in Lit ShTests, this test format
Expand Down Expand Up @@ -103,7 +104,7 @@ def getTestsInDirectory(self, testSuite, pathInSuite, litConfig, localConfig):

def _checkSubstitutions(self, substitutions):
substitutions = [s for (s, _) in substitutions]
for s in ['%{cxx}', '%{compile_flags}', '%{link_flags}', '%{exec}']:
for s in ['%{cxx}', '%{compile_flags}', '%{link_flags}', '%{flags}', '%{exec}']:
assert s in substitutions, "Required substitution {} was not provided".format(s)

# Determine whether -verify should be used for a given test. We use -verify
Expand Down Expand Up @@ -135,36 +136,36 @@ def execute(self, test, litConfig):
return self._executeShTest(test, litConfig, steps)
elif filename.endswith('.compile.pass.cpp'):
steps = [
"%dbg(COMPILED WITH) %{cxx} %s %{compile_flags} -fsyntax-only"
"%dbg(COMPILED WITH) %{cxx} %s %{flags} %{compile_flags} -fsyntax-only"
]
return self._executeShTest(test, litConfig, steps)
elif filename.endswith('.compile.fail.cpp'):
steps = [
"%dbg(COMPILED WITH) %{cxx} %s %{compile_flags} -fsyntax-only " + VERIFY_FLAGS
"%dbg(COMPILED WITH) %{cxx} %s %{flags} %{compile_flags} -fsyntax-only " + VERIFY_FLAGS
]
return self._executeShTest(test, litConfig, steps)
elif filename.endswith('.link.pass.cpp'):
steps = [
"%dbg(COMPILED WITH) %{cxx} %s %{compile_flags} %{link_flags} -o %t.exe"
"%dbg(COMPILED WITH) %{cxx} %s %{flags} %{compile_flags} %{link_flags} -o %t.exe"
]
return self._executeShTest(test, litConfig, steps)
elif filename.endswith('.link.fail.cpp'):
steps = [
"%dbg(COMPILED WITH) %{cxx} %s %{compile_flags} -c -o %t.o",
"%dbg(LINKED WITH) ! %{cxx} %t.o %{link_flags} -o %t.exe"
"%dbg(COMPILED WITH) %{cxx} %s %{flags} %{compile_flags} -c -o %t.o",
"%dbg(LINKED WITH) ! %{cxx} %t.o %{flags} %{link_flags} -o %t.exe"
]
return self._executeShTest(test, litConfig, steps)
elif filename.endswith('.run.fail.cpp'):
steps = [
"%dbg(COMPILED WITH) %{cxx} %s %{compile_flags} %{link_flags} -o %t.exe",
"%dbg(COMPILED WITH) %{cxx} %s %{flags} %{compile_flags} %{link_flags} -o %t.exe",
"%dbg(EXECUTED AS) %{exec} ! %t.exe"
]
return self._executeShTest(test, litConfig, steps, fileDependencies=['%t.exe'])
# Make sure to check these ones last, since they will match other
# suffixes above too.
elif filename.endswith('.pass.cpp') or filename.endswith('.pass.mm'):
steps = [
"%dbg(COMPILED WITH) %{cxx} %s %{compile_flags} %{link_flags} -o %t.exe",
"%dbg(COMPILED WITH) %{cxx} %s %{flags} %{compile_flags} %{link_flags} -o %t.exe",
"%dbg(EXECUTED AS) %{exec} %t.exe"
]
return self._executeShTest(test, litConfig, steps, fileDependencies=['%t.exe'])
Expand All @@ -173,11 +174,11 @@ def execute(self, test, litConfig):
elif filename.endswith('.fail.cpp') or filename.endswith('.fail.mm'):
if self._useVerify(test, litConfig):
steps = [
"%dbg(COMPILED WITH) %{cxx} %s %{compile_flags} -fsyntax-only " + VERIFY_FLAGS
"%dbg(COMPILED WITH) %{cxx} %s %{flags} %{compile_flags} -fsyntax-only " + VERIFY_FLAGS
]
else:
steps = [
"%dbg(COMPILED WITH) ! %{cxx} %s %{compile_flags} -fsyntax-only"
"%dbg(COMPILED WITH) ! %{cxx} %s %{flags} %{compile_flags} -fsyntax-only"
]
return self._executeShTest(test, litConfig, steps)
else:
Expand Down

0 comments on commit 4e52944

Please sign in to comment.