Skip to content

Commit 3ecd38c

Browse files
authored
[libomptarget] Build plugins-nextgen for SystemZ (llvm#83978)
The plugin was not getting built as the build_generic_elf64 macro assumes the LLVM triple processor name matches the CMake processor name, which is unfortunately not the case for SystemZ. Fix this by providing two separate arguments instead. Actually building the plugin exposed a number of other issues causing various test failures. Specifically, I've had to add the SystemZ target to - CompilerInvocation::ParseLangArgs - linkDevice in ClangLinuxWrapper.cpp - OMPContext::OMPContext (to set the device_kind_cpu trait) - LIBOMPTARGET_ALL_TARGETS in libomptarget/CMakeLists.txt - a check_plugin_target call in libomptarget/src/CMakeLists.txt Finally, I've had to set a number of test cases to UNSUPPORTED on s390x-ibm-linux-gnu; all these tests were already marked as UNSUPPORTED for x86_64-pc-linux-gnu and aarch64-unknown-linux-gnu and are failing on s390x for what seem to be the same reason. In addition, this also requires support for BE ELF files in plugins-nextgen: llvm#83976
1 parent 15b7b31 commit 3ecd38c

37 files changed

+71
-9
lines changed

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4012,6 +4012,7 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
40124012

40134013
if (TT.getArch() == llvm::Triple::UnknownArch ||
40144014
!(TT.getArch() == llvm::Triple::aarch64 || TT.isPPC() ||
4015+
TT.getArch() == llvm::Triple::systemz ||
40154016
TT.getArch() == llvm::Triple::nvptx ||
40164017
TT.getArch() == llvm::Triple::nvptx64 ||
40174018
TT.getArch() == llvm::Triple::amdgcn ||

clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ Expected<StringRef> linkDevice(ArrayRef<StringRef> InputFiles,
552552
case Triple::aarch64_be:
553553
case Triple::ppc64:
554554
case Triple::ppc64le:
555+
case Triple::systemz:
555556
return generic::clang(InputFiles, Args);
556557
default:
557558
return createStringError(inconvertibleErrorCode(),

llvm/lib/Frontend/OpenMP/OMPContext.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ OMPContext::OMPContext(bool IsDeviceCompilation, Triple TargetTriple) {
4444
case Triple::ppcle:
4545
case Triple::ppc64:
4646
case Triple::ppc64le:
47+
case Triple::systemz:
4748
case Triple::x86:
4849
case Triple::x86_64:
4950
ActiveTraits.set(unsigned(TraitProperty::device_kind_cpu));

openmp/libomptarget/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} x86_64-pc-linux-gnu-L
5656
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} nvptx64-nvidia-cuda")
5757
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} nvptx64-nvidia-cuda-LTO")
5858
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} nvptx64-nvidia-cuda-JIT-LTO")
59+
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} s390x-ibm-linux-gnu")
60+
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} s390x-ibm-linux-gnu-LTO")
5961

6062
# Once the plugins for the different targets are validated, they will be added to
6163
# the list of supported targets in the current system.

openmp/libomptarget/plugins-nextgen/CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@
1212

1313
add_subdirectory(common)
1414

15-
# void build_generic_elf64(string tmachine, string tmachine_name, string tmachine_libname, string elf_machine_id);
15+
# void build_generic_elf64(string tmachine, string tmachine_name, string tmachine_libname,
16+
# string tmachine_llvm, string tmachine_triple, string elf_machine_id);
1617
# - build a plugin for an ELF based generic 64-bit target based on libffi.
1718
# - tmachine: name of the machine processor as used in the cmake build system.
1819
# - tmachine_name: name of the machine to be printed with the debug messages.
1920
# - tmachine_libname: machine name to be appended to the plugin library name.
20-
macro(build_generic_elf64 tmachine tmachine_name tmachine_libname tmachine_triple elf_machine_id)
21+
# - tmachine_llvm: LLVM triple for the processor
22+
# - tmachine_triple: GNU target triple
23+
macro(build_generic_elf64 tmachine tmachine_name tmachine_libname tmachine_llvm tmachine_triple elf_machine_id)
2124
if(CMAKE_SYSTEM_PROCESSOR MATCHES "${tmachine}$")
2225
# Define macro to be used as prefix of the runtime messages for this target.
2326
add_definitions("-DTARGET_NAME=${tmachine_name}")
@@ -30,7 +33,7 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "${tmachine}$")
3033
add_definitions("-DTARGET_ELF_ID=${elf_machine_id}")
3134

3235
# Define target triple
33-
add_definitions("-DLIBOMPTARGET_NEXTGEN_GENERIC_PLUGIN_TRIPLE=${tmachine}")
36+
add_definitions("-DLIBOMPTARGET_NEXTGEN_GENERIC_PLUGIN_TRIPLE=${tmachine_llvm}")
3437

3538
add_llvm_library("omptarget.rtl.${tmachine_libname}"
3639
SHARED

openmp/libomptarget/plugins-nextgen/aarch64/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
##===----------------------------------------------------------------------===##
1212

1313
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
14-
build_generic_elf64("aarch64" "aarch64" "aarch64" "aarch64-unknown-linux-gnu" "183")
14+
build_generic_elf64("aarch64" "aarch64" "aarch64" "aarch64" "aarch64-unknown-linux-gnu" "183")
1515
else()
1616
libomptarget_say("Not building aarch64 NextGen offloading plugin: machine not found in the system.")
1717
endif()

openmp/libomptarget/plugins-nextgen/ppc64/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
##===----------------------------------------------------------------------===##
1212

1313
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
14-
build_generic_elf64("ppc64" "PPC64" "ppc64" "powerpc64-ibm-linux-gnu" "21")
14+
build_generic_elf64("ppc64" "PPC64" "ppc64" "ppc64" "powerpc64-ibm-linux-gnu" "21")
1515
else()
1616
libomptarget_say("Not building ppc64 NextGen offloading plugin: machine not found in the system.")
1717
endif()

openmp/libomptarget/plugins-nextgen/ppc64le/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
##===----------------------------------------------------------------------===##
1212

1313
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
14-
build_generic_elf64("ppc64le" "PPC64le" "ppc64" "powerpc64le-ibm-linux-gnu" "21")
14+
build_generic_elf64("ppc64le" "PPC64le" "ppc64" "ppc64le" "powerpc64le-ibm-linux-gnu" "21")
1515
else()
1616
libomptarget_say("Not building ppc64le NextGen offloading plugin: machine not found in the system.")
1717
endif()

openmp/libomptarget/plugins-nextgen/s390x/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
##===----------------------------------------------------------------------===##
1212

1313
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
14-
build_generic_elf64("SystemZ" "S390X" "s390x" "s390x-ibm-linux-gnu" "22")
14+
build_generic_elf64("s390x" "S390X" "s390x" "systemz" "s390x-ibm-linux-gnu" "22")
1515
else()
1616
libomptarget_say("Not building s390x NextGen offloading plugin: machine not found in the system.")
1717
endif()

openmp/libomptarget/plugins-nextgen/x86_64/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
##===----------------------------------------------------------------------===##
1212

1313
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
14-
build_generic_elf64("x86_64" "x86_64" "x86_64" "x86_64-pc-linux-gnu" "62")
14+
build_generic_elf64("x86_64" "x86_64" "x86_64" "x86_64" "x86_64-pc-linux-gnu" "62")
1515
else()
1616
libomptarget_say("Not building x86_64 NextGen offloading plugin: machine not found in the system.")
1717
endif()

0 commit comments

Comments
 (0)