Skip to content

Instantly share code, notes, and snippets.

@jwakely
Forked from ldionne/README.md
Last active June 15, 2021 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwakely/d557713c2c18ba4d000746f0a6a1f9a5 to your computer and use it in GitHub Desktop.
Save jwakely/d557713c2c18ba4d000746f0a6a1f9a5 to your computer and use it in GitHub Desktop.
From-scratch Lit configuration for Wakely

The simplest approach is to just replace libcxx/test/lit.cfg.py with the lit.cfg.py file below, then you can just run the tests in-place via a command like:

$LLVM_SOURCE_ROOT/llvm/utils/lit/lit.py -s -i -j4 std/utilities/ratio

Alternatively, put the libstdcxx.cfg.in file in libcxx/test/configs/libstdcxx.cfg.in. Then, configure the LLVM tree with -DLIBCXX_TEST_CONFIG=<path-to-libstdcxx.cfg.in>.

Then, you should be able to use ./build/bin/llvm-lit -sv <whatever>.

@AUTO_GEN_COMMENT@
LIBCXX_ROOT = "@LIBCXX_SOURCE_DIR@"
INSTALL_ROOT = "@CMAKE_BINARY_DIR@"
EXEC_ROOT = "@LIBCXX_BINARY_DIR@"
import os
import pipes
import site
import sys
site.addsitedir(os.path.join(LIBCXX_ROOT, 'utils'))
import libcxx.test.features
import libcxx.test.format
import libcxx.test.newconfig
import libcxx.test.params
# Configure basic properties of the test suite
config.name = 'libstdc++-trunk-shared'
config.test_source_root = os.path.join(LIBCXX_ROOT, 'test')
config.test_format = libcxx.test.format.CxxStandardLibraryTest()
config.recursiveExpansionLimit = 10
config.test_exec_root = EXEC_ROOT
# Configure basic substitutions
runPy = os.path.join(LIBCXX_ROOT, 'utils', 'run.py')
config.substitutions.append(('%{cxx}', <your-compiler>))
config.substitutions.append(('%{flags}', <your-common-link-and-compile-flags>))
config.substitutions.append(('%{compile_flags}', <your-compile-flags>))
config.substitutions.append(('%{link_flags}', <your-link-flags>))
config.substitutions.append(('%{exec}', '{} {} --execdir %T -- '.format(pipes.quote(sys.executable), pipes.quote(runPy))))
# Add parameters and features to the config
libcxx.test.newconfig.configure(
libcxx.test.params.DEFAULT_PARAMETERS,
libcxx.test.features.DEFAULT_FEATURES,
config,
lit_config
)
# Example of a lit config to run with GCC and libstdc++.
# I replaced `libcxx/test/lit.cfg.py` by this file.
# path to libcxx sources
LIBCXX_ROOT = "/home/jwakely/src/llvm/libcxx"
EXEC_ROOT = "/tmp/libcxx-exec"
# Path to installed GCC
GCC_ROOT = '/home/jwakely/gcc/latest'
import os
import pipes
import site
import sys
site.addsitedir(os.path.join(LIBCXX_ROOT, 'utils'))
import libcxx.test.features
import libcxx.test.format
import libcxx.test.newconfig
import libcxx.test.params
# Configure basic properties of the test suite
config.name = 'libstdc++-trunk-shared'
config.stdlib = 'libstdc++'
config.test_source_root = os.path.join(LIBCXX_ROOT, 'test')
config.test_format = libcxx.test.format.CxxStandardLibraryTest()
config.recursiveExpansionLimit = 10
config.test_exec_root = EXEC_ROOT
# Configure basic substitutions
runPy = os.path.join(LIBCXX_ROOT, 'utils', 'run.py')
config.substitutions.append(('%{cxx}', '{}/bin/g++'.format(GCC_ROOT)))
config.substitutions.append(('%{flags}', ''))
config.substitutions.append(('%{compile_flags}', '-I {}'.format(os.path.join(LIBCXX_ROOT, 'test', 'support'))))
config.substitutions.append(('%{link_flags}', '-Wl,-rpath,{}/lib64'.format(GCC_ROOT)))
config.substitutions.append(('%{exec}', '{} {} --execdir %T -- '.format(pipes.quote(sys.executable), pipes.quote(runPy))))
# Add parameters and features to the config
libcxx.test.newconfig.configure(
libcxx.test.params.DEFAULT_PARAMETERS,
libcxx.test.features.DEFAULT_FEATURES,
config,
lit_config
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment