llvm-project/lld/test/lit.cfg.py
Rui Ueyama 5cd9c6bcd8 Support RISC-V
Patch by PkmX.

This patch makes lld recognize RISC-V target and implements basic
relocation for RV32/RV64 (and RVC). This should be necessary for static
linking ELF applications.

The ABI documentation for RISC-V can be found at:
https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md.
Note that the documentation is far from complete so we had to figure out
some details from bfd.

The patch should be pretty straightforward. Some highlights:

 - A new relocation Expr R_RISCV_PC_INDIRECT is added. This is needed as
   the low part of a PC-relative relocation is linked to the corresponding
   high part (auipc), see:
   https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md#pc-relative-symbol-addresses

 - LLVM's MC support for RISC-V is very incomplete (we are working on
   this), so tests are given in objectyaml format with the original
   assembly included in the comments. Once we have complete support for
   RISC-V in MC, we can switch to llvm-as/llvm-objdump.

 - We don't support linker relaxation for now as it requires greater
   changes to lld that is beyond the scope of this patch. Once this is
   accepted we can start to work on adding relaxation to lld.

Differential Revision: https://reviews.llvm.org/D39322

llvm-svn: 339364
2018-08-09 17:59:56 +00:00

101 lines
3.3 KiB
Python

# -*- Python -*-
import os
import platform
import re
import subprocess
import locale
import lit.formats
import lit.util
from lit.llvm import llvm_config
# Configuration file for the 'lit' test runner.
# name: The name of this test suite.
config.name = 'lld'
# testFormat: The test format to use to interpret tests.
#
# For now we require '&&' between commands, until they get globally killed and
# the test runner updated.
config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
# suffixes: A list of file extensions to treat as test files.
config.suffixes = ['.ll', '.s', '.test', '.yaml', '.objtxt']
# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
# subdirectories contain auxiliary inputs for various tests in their parent
# directories.
config.excludes = ['Inputs']
# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(__file__)
config.test_exec_root = os.path.join(config.lld_obj_root, 'test')
llvm_config.use_default_substitutions()
llvm_config.use_lld()
tool_patterns = [
'llc', 'llvm-as', 'llvm-mc', 'llvm-nm', 'llvm-objdump', 'llvm-pdbutil',
'llvm-dwarfdump', 'llvm-readelf', 'llvm-readobj', 'obj2yaml', 'yaml2obj',
'opt', 'llvm-dis']
llvm_config.add_tool_substitutions(tool_patterns)
# When running under valgrind, we mangle '-vg' onto the end of the triple so we
# can check it with XFAIL and XTARGET.
if lit_config.useValgrind:
config.target_triple += '-vg'
# Running on ELF based *nix
if platform.system() in ['FreeBSD', 'Linux']:
config.available_features.add('system-linker-elf')
# Set if host-cxxabi's demangler can handle target's symbols.
if platform.system() not in ['Windows']:
config.available_features.add('demangler')
llvm_config.feature_config(
[('--build-mode', {'DEBUG': 'debug'}),
('--assertion-mode', {'ON': 'asserts'}),
('--targets-built', {'AArch64': 'aarch64',
'AMDGPU': 'amdgpu',
'ARM': 'arm',
'AVR': 'avr',
'Hexagon': 'hexagon',
'Mips': 'mips',
'PowerPC': 'ppc',
'RISCV': 'riscv',
'Sparc': 'sparc',
'WebAssembly': 'wasm',
'X86': 'x86'})
])
# Set a fake constant version so that we get consistent output.
config.environment['LLD_VERSION'] = 'LLD 1.0'
config.environment['LLD_IN_TEST'] = '1'
# Indirectly check if the mt.exe Microsoft utility exists by searching for
# cvtres, which always accompanies it. Alternatively, check if we can use
# libxml2 to merge manifests.
if (lit.util.which('cvtres', config.environment['PATH'])) or \
(config.llvm_libxml2_enabled == '1'):
config.available_features.add('manifest_tool')
if (config.llvm_libxml2_enabled == '1'):
config.available_features.add('libxml2')
if config.have_dia_sdk:
config.available_features.add("diasdk")
tar_executable = lit.util.which('tar', config.environment['PATH'])
if tar_executable:
tar_version = subprocess.Popen(
[tar_executable, '--version'], stdout=subprocess.PIPE, env={'LANG': 'C'})
if 'GNU tar' in tar_version.stdout.read().decode():
config.available_features.add('gnutar')
tar_version.wait()