|
| 1 | +if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux") |
| 2 | + return() |
| 3 | +endif() |
| 4 | + |
| 5 | + # build_generic_elf64("s390x" "S390X" "s390x" "systemz" "s390x-ibm-linux-gnu" "22") |
| 6 | + # build_generic_elf64("aarch64" "aarch64" "aarch64" "aarch64" "aarch64-unknown-linux-gnu" "183") |
| 7 | + # build_generic_elf64("ppc64" "PPC64" "ppc64" "ppc64" "powerpc64-ibm-linux-gnu" "21") |
| 8 | + # build_generic_elf64("x86_64" "x86_64" "x86_64" "x86_64" "x86_64-pc-linux-gnu" "62") |
| 9 | + # build_generic_elf64("ppc64le" "PPC64le" "ppc64" "ppc64le" "powerpc64le-ibm-linux-gnu" "21") |
| 10 | +set(supported_targets x86_64 aarch64 ppc64 ppc64le s390x) |
| 11 | +if(NOT ${CMAKE_SYSTEM_PROCESSOR} IN_LIST supported_targets) |
| 12 | + libomptarget_say("Not building ${machine} NextGen offloading plugin") |
| 13 | + return() |
| 14 | +endif() |
| 15 | + |
| 16 | +set(machine ${CMAKE_SYSTEM_PROCESSOR}) |
| 17 | +if(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le$") |
| 18 | + set(machine ppc64) |
| 19 | +endif() |
| 20 | + |
| 21 | +add_llvm_library(omptarget.rtl.${machine} SHARED |
| 22 | + src/rtl.cpp |
| 23 | + ADDITIONAL_HEADER_DIRS |
| 24 | + ${LIBOMPTARGET_INCLUDE_DIR} |
| 25 | + LINK_LIBS PRIVATE |
| 26 | + PluginCommon |
| 27 | + ${OPENMP_PTHREAD_LIB} |
| 28 | + NO_INSTALL_RPATH |
| 29 | + BUILDTREE_ONLY |
| 30 | +) |
| 31 | + |
| 32 | +if(LIBOMPTARGET_DEP_LIBFFI_FOUND) |
| 33 | + libomptarget_say("Building ${machine} plugin linked with libffi") |
| 34 | + if(FFI_STATIC_LIBRARIES) |
| 35 | + target_link_libraries(omptarget.rtl.${machine} PRIVATE FFI::ffi_static) |
| 36 | + else() |
| 37 | + target_link_libraries(omptarget.rtl.${machine} PRIVATE FFI::ffi) |
| 38 | + endif() |
| 39 | +else() |
| 40 | + libomptarget_say("Building ${machine} plugin for dlopened libffi") |
| 41 | + target_sources(omptarget.rtl.${machine} PRIVATE dynamic_ffi/ffi.cpp) |
| 42 | + target_include_directories(omptarget.rtl.${machine} PRIVATE dynamic_ffi) |
| 43 | +endif() |
| 44 | + |
| 45 | +if(OMPT_TARGET_DEFAULT AND LIBOMPTARGET_OMPT_SUPPORT) |
| 46 | + target_link_libraries(omptarget.rtl.${machine} PRIVATE OMPT) |
| 47 | +endif() |
| 48 | + |
| 49 | +if(LIBOMP_HAVE_VERSION_SCRIPT_FLAG) |
| 50 | + target_link_libraries(omptarget.rtl.${machine} PRIVATE |
| 51 | + "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports") |
| 52 | +endif() |
| 53 | + |
| 54 | +# Install plugin under the lib destination folder. |
| 55 | +install(TARGETS omptarget.rtl.${machine} |
| 56 | + LIBRARY DESTINATION "${OPENMP_INSTALL_LIBDIR}") |
| 57 | +set_target_properties(omptarget.rtl.${machine} PROPERTIES |
| 58 | + INSTALL_RPATH "$ORIGIN" BUILD_RPATH "$ORIGIN:${CMAKE_CURRENT_BINARY_DIR}/.." |
| 59 | + POSITION_INDEPENDENT_CODE ON |
| 60 | + CXX_VISIBILITY_PRESET protected) |
| 61 | + |
| 62 | +target_include_directories(omptarget.rtl.${machine} PRIVATE |
| 63 | + ${LIBOMPTARGET_INCLUDE_DIR}) |
| 64 | + |
| 65 | +if(LIBOMPTARGET_DEP_LIBFFI_FOUND) |
| 66 | + list(APPEND LIBOMPTARGET_TESTED_PLUGINS omptarget.rtl.${machine}) |
| 67 | + set(LIBOMPTARGET_TESTED_PLUGINS |
| 68 | + "${LIBOMPTARGET_TESTED_PLUGINS}" PARENT_SCOPE) |
| 69 | +else() |
| 70 | + libomptarget_say("Not generating ${tmachine_name} tests. LibFFI not found.") |
| 71 | +endif() |
| 72 | + |
| 73 | +# Define macro to be used as prefix of the runtime messages for this target. |
| 74 | +target_compile_definitions(omptarget.rtl.${machine} PRIVATE TARGET_NAME=${machine}) |
| 75 | +# TODO: This should be automatized in Debug.h. |
| 76 | +target_compile_definitions(omptarget.rtl.${machine} PRIVATE |
| 77 | + DEBUG_PREFIX="TARGET ${machine} RTL") |
| 78 | + |
| 79 | +# Define the target specific triples and ELF machine values. |
| 80 | +if(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le$" OR |
| 81 | + CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64$") |
| 82 | + target_compile_definitions(omptarget.rtl.${machine} PRIVATE TARGET_ELF_ID=EM_PPC64) |
| 83 | + target_compile_definitions(omptarget.rtl.${machine} PRIVATE |
| 84 | + LIBOMPTARGET_NEXTGEN_GENERIC_PLUGIN_TRIPLE="powerpc64-ibm-linux-gnu") |
| 85 | + list(APPEND LIBOMPTARGET_SYSTEM_TARGETS |
| 86 | + "powerpc64-ibm-linux-gnu" "powerpc64-ibm-linux-gnu-LTO") |
| 87 | + set(LIBOMPTARGET_SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS}" PARENT_SCOPE) |
| 88 | +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64$") |
| 89 | + target_compile_definitions(omptarget.rtl.${machine} PRIVATE TARGET_ELF_ID=EM_X86_64) |
| 90 | + target_compile_definitions(omptarget.rtl.${machine} PRIVATE |
| 91 | + LIBOMPTARGET_NEXTGEN_GENERIC_PLUGIN_TRIPLE="x86_64-pc-linux-gnu") |
| 92 | + list(APPEND LIBOMPTARGET_SYSTEM_TARGETS |
| 93 | + "x86_64-pc-linux-gnu" "x86_64-pc-linux-gnu-LTO") |
| 94 | + set(LIBOMPTARGET_SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS}" PARENT_SCOPE) |
| 95 | +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64$") |
| 96 | + target_compile_definitions(omptarget.rtl.${machine} PRIVATE TARGET_ELF_ID=EM_AARCH64) |
| 97 | + target_compile_definitions(omptarget.rtl.${machine} PRIVATE |
| 98 | + LIBOMPTARGET_NEXTGEN_GENERIC_PLUGIN_TRIPLE="aarch64-unknown-linux-gnu") |
| 99 | + list(APPEND LIBOMPTARGET_SYSTEM_TARGETS |
| 100 | + "aarch64-unknown-linux-gnu" "aarch64-unknown-linux-gnu-LTO") |
| 101 | + set(LIBOMPTARGET_SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS}" PARENT_SCOPE) |
| 102 | +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "s390x$") |
| 103 | + target_compile_definitions(omptarget.rtl.${machine} TARGET_ELF_ID=EM_S390) |
| 104 | + target_compile_definitions(omptarget.rtl.${machine} PRIVATE |
| 105 | + LIBOMPTARGET_NEXTGEN_GENERIC_PLUGIN_TRIPLE="s390x-ibm-linux-gnu") |
| 106 | + list(APPEND LIBOMPTARGET_SYSTEM_TARGETS |
| 107 | + "s390x-ibm-linux-gnu" "s390x-ibm-linux-gnu-LTO") |
| 108 | + set(LIBOMPTARGET_SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS}" PARENT_SCOPE) |
| 109 | +endif() |
0 commit comments