Skip to content

Commit b6d1532

Browse files
authored
Merge pull request #109 from jchecahi/s390x-compatibility-fixes
S390x compatibility fixes
2 parents d822092 + 73acffe commit b6d1532

File tree

9 files changed

+39
-12
lines changed

9 files changed

+39
-12
lines changed

.github/workflows/fedora.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
fedora-version: [37, rawhide]
12+
fedora-version: [38, 39, rawhide]
1313
container:
1414
image: "fedora:${{matrix.fedora-version}}"
1515
# These options are required to be able to run lldb inside the container

CMakeLists.txt

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
cmake_minimum_required(VERSION 3.4.3)
2-
project(LLVMToolchainIntegrationTestSuite VERSION 1.0 LANGUAGES NONE)
3-
4-
enable_language(C)
5-
enable_language(CXX)
62

73
message(STATUS "Checking for lit")
84
find_program(LIT lit)
@@ -18,6 +14,16 @@ macro(find_program_or_warn OUT_VAR name)
1814
endif()
1915
endmacro()
2016

17+
macro(find_library_or_warn OUT_VAR name)
18+
cmake_parse_arguments(MY_FIND "" "" "HINTS" ${ARGN} )
19+
20+
message(STATUS "Checking for ${name}")
21+
find_library(${OUT_VAR} ${name} HINTS ${MY_FIND_HINTS})
22+
if (NOT ${OUT_VAR})
23+
message(WARNING "${name} not found. Disabling tests related to ${name}")
24+
endif()
25+
endmacro()
26+
2127
find_program_or_warn(CLANGXX_BINARY clang++)
2228
find_program_or_warn(CLANG_BINARY clang)
2329
find_program_or_warn(CLANG_TIDY_BINARY clang-tidy)
@@ -39,12 +45,24 @@ find_program_or_warn(SCANVIEW scan-view)
3945
find_program_or_warn(SCANBUILDPY scan-build-py)
4046
find_program_or_warn(MLIRTRANSLATE mlir-translate)
4147

48+
set(CMAKE_C_COMPILER ${CLANG_BINARY})
49+
set(CMAKE_CXX_COMPILER ${CLANGXX_BINARY})
50+
51+
project(LLVMToolchainIntegrationTestSuite VERSION 1.0 LANGUAGES NONE)
52+
53+
enable_language(C)
54+
enable_language(CXX)
4255

4356
option(ENABLE_COMPILER_RT "assume compiler-rt is available" ON)
4457
option(ENABLE_LIBCXX "assume libc++ is available" ON)
4558
option(ENABLE_STATIC_LIBCXX "assume libc++.a is available" ON)
4659
option(ENABLE_LIBUNWIND "assume libunwind is available" ON)
4760

61+
# Detect if libomp is supported. Ubuntu stores the symlink library under a
62+
# version-dependent directory so we need to provide a hint to CMake to find it.
63+
string(REGEX MATCH "^[0-9]+" LLVM_MAJOR ${CMAKE_C_COMPILER_VERSION})
64+
find_library_or_warn(LIBOMP libomp.so HINTS /usr/lib/llvm-${LLVM_MAJOR}/lib/)
65+
4866
message(STATUS "Checking kernel support for tagged address ABI")
4967
try_run(
5068
_TEST_RUN_RESULT

README.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ Sensible configuration variables
3939

4040
- ``ENABLE_COMPILER_RT``: ON (the default) if we assume compiler-rt is available
4141
- ``ENABLE_LIBCXX``: ON (the default) if we assume libc++ is available
42-
- ``ENABLE_UNWIND``: ON (the default) if we assume libunwind is available
42+
- ``ENABLE_STATIC_LIBCXX``: ON (the default) if we assume libc++.a is available
43+
- ``ENABLE_LIBUNWIND``: ON (the default) if we assume libunwind is available
4344
- ``ENABLE_HWASAN``: Run hwasan tests. Autodetected based on the host system.
45+
- ``ENABLE_LIBOMP``: Run libomp tests. Autodetected based on the system. It can
46+
be manually forced via `-DENABLE_LIBOMP=<ON|OFF>` at cmake configure time
4447

4548
Writing new tests
4649
-----------------

tests/basic_openmp.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
//
33
// RUN: %clang -fopenmp %s -o %t
44
// RUN: %t | grep "Num Threads: 1"
5-
// REQUIRES: clang
6-
// XFAIL: s390x
5+
// REQUIRES: clang, libomp
76

87
#include <omp.h>
98
#include <stdio.h>

tests/lit.site.cfg.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ def enable_program(name, binary):
1818
config.available_features.add(name)
1919
config.substitutions.append(('%'+name, binary))
2020

21+
def enable_library(name, library):
22+
if os.path.exists(library):
23+
config.available_features.add(name)
2124

2225
# The order matters, e.g. substitution for clang-format-diff
2326
# must appear before clang-format, because the latter is a prefix of the former.
@@ -45,6 +48,8 @@ enable_program('scan-view', "@SCANVIEW@")
4548
enable_program('opt', "@OPT_BINARY@")
4649
enable_program('mlir-translate', "@MLIRTRANSLATE@")
4750

51+
enable_library('libomp', "@LIBOMP@")
52+
4853
config.substitutions.append(('%cmake', '@CMAKE_COMMAND@'))
4954

5055
enable_feature("compiler-rt", "@ENABLE_COMPILER_RT@")

tests/openmp_headers.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// Test OpenMP headers install
22
//
33
// RUN: %clang -fopenmp -E %s -o %t
4-
// REQUIRES: clang
5-
// XFAIL: s390x
4+
// REQUIRES: clang, libomp
65

76
#include <omp.h>
87
#if _OPENMP >= 201811

tests/openmp_tools.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// RUN: %clang -fopenmp -DTOOLS %s -shared -o %t_Tools.so
33
// RUN: %clang -fopenmp -UTOOLS %s -o %t
44
// RUN: OMP_TOOL_LIBRARIES=%t_Tools.so %t | grep "INIT"
5-
// REQUIRES: clang
6-
// XFAIL: s390x
5+
// REQUIRES: clang, libomp
76
#ifdef TOOLS
87

98
// OpenMP Tools are only supported starting OpenMP 5

tests/whole-toolchain.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// REQUIRES: clang, lld, compiler-rt
33
// RUN: %clang -fuse-ld=lld -rtlib=compiler-rt %s -o %t
44
// RUN: %t | grep "Hello World"
5+
// s390x now runs but fails because it does not support compiler-rt builtins.
6+
// XFAIL: s390x
57

68
#include<stdio.h>
79
int main(int argc, char **argv) {

tests/whole-toolchain.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
// alternative would be to force usage of LLVM unwinder when building compiler-rt.
66
// RUN: %clangxx -fuse-ld=lld -rtlib=compiler-rt -stdlib=libc++ -lgcc_eh %s -o %t
77
// RUN: %t | grep "Hello World"
8+
// s390x now runs but fails because it does not support compiler-rt builtins.
9+
// XFAIL: s390x
810

911
#include <iostream>
1012
int main(int argc, char **argv) {

0 commit comments

Comments
 (0)