diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0c2b233 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +CMake +log +install +nohup.out +tests/build +tests/hw.trace diff --git a/README.md b/README.md index 6f95a68..3742903 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,14 @@ zopen build ``` For details on the build, see (https://zosopentools.github.io/meta/#/Guides/Porting) + +# additional languages + +If we wanted to add another language (like COBOL, PL/I or HL/ASM for example), then we would want to +teach CMake of the language. Some starter points from +[stackoverflow](https://stackoverflow.com/questions/7978517/how-do-i-get-cmake-to-work-with-the-go-programming-language#7979578) + +- Create CMakeDeterminePLICompiler.cmake [initial code] +- Create CMakePLICompiler.cmake.in [initial code] +- Create CMakeTestPLICompiler.cmake [initial code] +- Create CMakePLIInformation.cmake [initial code] diff --git a/patches/CMakeCompilerIdDetection.cmake.patch b/patches/CMakeCompilerIdDetection.cmake.patch new file mode 100644 index 0000000..2c147ff --- /dev/null +++ b/patches/CMakeCompilerIdDetection.cmake.patch @@ -0,0 +1,13 @@ +diff --git a/Modules/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake +index f15974ae01..8a18ac9610 100644 +--- a/Modules/CMakeCompilerIdDetection.cmake ++++ b/Modules/CMakeCompilerIdDetection.cmake +@@ -14,7 +14,7 @@ endfunction() + function(compiler_id_detection outvar lang) + + if (NOT "x${lang}" STREQUAL "xFortran" AND NOT "x${lang}" STREQUAL "xCSharp" +- AND NOT "x${lang}" STREQUAL "xISPC") ++ AND NOT "x${lang}" STREQUAL "xISPC" AND NOT "x${lang}" STREQUAL "xPLI") + file(GLOB lang_files + "${CMAKE_ROOT}/Modules/Compiler/*-DetermineCompiler.cmake") + set(nonlang CXX) diff --git a/patches/CMakeDetermineCompilerId.cmake.patch b/patches/CMakeDetermineCompilerId.cmake.patch new file mode 100644 index 0000000..121319b --- /dev/null +++ b/patches/CMakeDetermineCompilerId.cmake.patch @@ -0,0 +1,28 @@ +diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake +index 2b19736d47..5a7acce657 100644 +--- a/Modules/CMakeDetermineCompilerId.cmake ++++ b/Modules/CMakeDetermineCompilerId.cmake +@@ -5,6 +5,11 @@ macro(__determine_compiler_id_test testflags_var userflags_var) + separate_arguments(testflags UNIX_COMMAND "${${testflags_var}}") + CMAKE_DETERMINE_COMPILER_ID_BUILD("${lang}" "${testflags}" "${${userflags_var}}" "${src}") + CMAKE_DETERMINE_COMPILER_ID_MATCH_VENDOR("${lang}" "${COMPILER_${lang}_PRODUCED_OUTPUT}") ++ foreach(vendor ${CMAKE_${lang}_COMPILER_ID_MATCH_VENDORS}) ++ if(${COMPILER_${lang}_PRODUCED_OUTPUT} MATCHES ${CMAKE_${lang}_COMPILER_ID_MATCH_VERSION_REGEX_${vendor}}) ++ set(CMAKE_${lang}_COMPILER_VERSION "${CMAKE_MATCH_1}") ++ endif() ++ endforeach() + + if(NOT CMAKE_${lang}_COMPILER_ID) + foreach(file ${COMPILER_${lang}_PRODUCED_FILES}) +@@ -32,6 +37,11 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) + endif() + string(REPLACE " " ";" CMAKE_${lang}_COMPILER_ID_FLAGS_LIST "${CMAKE_${lang}_COMPILER_ID_FLAGS}") + ++ # Drop qASCII Flag for z/OS for correct encoding of string literals. ++ if(CMAKE_SYSTEM_NAME MATCHES "OS390") ++ string(REGEX REPLACE "-(qASCII|qascii|fzos-le-char-mode=ascii);?" "" CMAKE_${lang}_COMPILER_ID_FLAGS_LIST "${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST}") ++ endif() ++ + # Compute the directory in which to run the test. + set(CMAKE_${lang}_COMPILER_ID_DIR ${CMAKE_PLATFORM_INFO_DIR}/CompilerId${lang}) + diff --git a/patches/CMakeDeterminePLICompiler.cmake.patch b/patches/CMakeDeterminePLICompiler.cmake.patch new file mode 100644 index 0000000..4fc49e7 --- /dev/null +++ b/patches/CMakeDeterminePLICompiler.cmake.patch @@ -0,0 +1,132 @@ +diff --git a/Modules/CMakeDeterminePLICompiler.cmake b/Modules/CMakeDeterminePLICompiler.cmake +new file mode 100644 +index 0000000000..b8ff84164c +--- /dev/null ++++ b/Modules/CMakeDeterminePLICompiler.cmake +@@ -0,0 +1,126 @@ ++# Distributed under the OSI-approved BSD 3-Clause License. See accompanying ++# file Copyright.txt or https://cmake.org/licensing for details. ++ ++ ++# determine the compiler to use for PLI programs ++# NOTE, a generator may set CMAKE_PLI_COMPILER before ++# loading this file to force a compiler. ++# use environment variable PC first if defined by user, next use ++# the cmake variable CMAKE_GENERATOR_PC which can be defined by a generator ++# as a default compiler ++ ++include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake) ++include(Platform/${CMAKE_SYSTEM_NAME}-Determine-PLI OPTIONAL) ++include(Platform/${CMAKE_SYSTEM_NAME}-PLI OPTIONAL) ++if(NOT CMAKE_PLI_COMPILER_NAMES) ++ set(CMAKE_PLI_COMPILER_NAMES pli) ++endif() ++ ++if(NOT CMAKE_PLI_COMPILER) ++ # prefer the environment variable PC ++ if(NOT $ENV{PC} STREQUAL "") ++ get_filename_component(CMAKE_PLI_COMPILER_INIT $ENV{PC} PROGRAM PROGRAM_ARGS CMAKE_PLI_FLAGS_ENV_INIT) ++ if(CMAKE_PLI_FLAGS_ENV_INIT) ++ set(CMAKE_PLI_COMPILER_ARG1 "${CMAKE_PLI_FLAGS_ENV_INIT}" CACHE STRING "Arguments to PLI compiler") ++ endif() ++ if(EXISTS ${CMAKE_PLI_COMPILER_INIT}) ++ else() ++ message(FATAL_ERROR "Could not find compiler set in environment variable PC:\n$ENV{PC}.") ++ endif() ++ endif() ++ ++ # next try prefer the compiler specified by the generator ++ if(CMAKE_GENERATOR_PC) ++ if(NOT CMAKE_PLI_COMPILER_INIT) ++ set(CMAKE_PLI_COMPILER_INIT ${CMAKE_GENERATOR_PC}) ++ endif() ++ endif() ++ ++ # finally list compilers to try ++ if(NOT CMAKE_PLI_COMPILER_INIT) ++ # Known compilers: ++ # pli: generic compiler names ++ set(CMAKE_PLI_COMPILER_LIST ++ pli ++ ) ++ ++ # Vendor-specific compiler names. ++ set(_PLI_COMPILER_NAMES_ZOS pli) ++ endif() ++ ++ _cmake_find_compiler(PLI) ++ ++else() ++ _cmake_find_compiler_path(PLI) ++endif() ++mark_as_advanced(CMAKE_PLI_COMPILER) ++ ++# Each entry in this list is a set of extra flags to try ++# adding to the compile line to see if it helps produce ++# a valid identification executable. ++set(CMAKE_PLI_COMPILER_ID_TEST_FLAGS_FIRST ++ # Get verbose output to help distinguish compilers. ++ "-v" ++ ) ++set(CMAKE_PLI_COMPILER_ID_TEST_FLAGS ++ # Try compiling to an object file only. ++ "-c" ++ ) ++ ++# Build a small source file to identify the compiler. ++if(NOT CMAKE_PLI_COMPILER_ID_RUN) ++ set(CMAKE_PLI_COMPILER_ID_RUN 1) ++ ++ ++ # Table of per-vendor compiler id flags with expected output. ++ list(APPEND CMAKE_PLI_COMPILER_ID_VENDORS IBM) ++ set(CMAKE_PLI_COMPILER_ID_VENDOR_FLAGS_IBM "-v") ++ set(CMAKE_PLI_COMPILER_ID_VENDOR_REGEX_IBM "15655-PL[.]*") ++ list(APPEND CMAKE_PLI_COMPILER_ID_MATCH_VENDORS "${CMAKE_PLI_COMPILER_ID_VENDORS}") ++ set(CMAKE_PLI_COMPILER_ID_MATCH_VENDOR_REGEX_IBM "${CMAKE_PLI_COMPILER_ID_VENDOR_REGEX_IBM}") ++ set(CMAKE_PLI_COMPILER_ID_MATCH_VERSION_REGEX_IBM "[.]*Enterprise PL/I for z/OS[ ]*([0-9\.]+)[.]*") ++# [=[ V([0-9]+)\.([0-9]+)\.([0-9]+)]=]) ++ include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) ++ CMAKE_DETERMINE_COMPILER_ID(PLI PLIFLAGS CMakePLICompilerId.pli) ++ ++ unset(_version_info) ++ ++endif () ++ ++set(_CMAKE_PROCESSING_LANGUAGE "PLI") ++include(CMakeFindBinUtils) ++include(Compiler/${CMAKE_PLI_COMPILER_ID}-FindBinUtils OPTIONAL) ++unset(_CMAKE_PROCESSING_LANGUAGE) ++ ++if(CMAKE_PLI_COMPILER_SYSROOT) ++ string(CONCAT _SET_CMAKE_PLI_COMPILER_SYSROOT ++ "set(CMAKE_PLI_COMPILER_SYSROOT \"${CMAKE_PLI_COMPILER_SYSROOT}\")\n" ++ "set(CMAKE_COMPILER_SYSROOT \"${CMAKE_PLI_COMPILER_SYSROOT}\")") ++else() ++ set(_SET_CMAKE_PLI_COMPILER_SYSROOT "") ++endif() ++ ++if(CMAKE_PLI_COMPILER_ARCHITECTURE_ID) ++ set(_SET_CMAKE_PLI_COMPILER_ARCHITECTURE_ID ++ "set(CMAKE_PLI_COMPILER_ARCHITECTURE_ID ${CMAKE_PLI_COMPILER_ARCHITECTURE_ID})") ++else() ++ set(_SET_CMAKE_PLI_COMPILER_ARCHITECTURE_ID "") ++endif() ++ ++if(CMAKE_PLI_COMPILER_ID) ++ set(_SET_CMAKE_PLI_COMPILER_ID ++ "set(CMAKE_PLI_COMPILER_ID ${CMAKE_PLI_COMPILER_ID})") ++else() ++ set(_SET_CMAKE_PLI_COMPILER_ID "") ++endif() ++ ++if(MSVC_PLI_ARCHITECTURE_ID) ++ set(SET_MSVC_PLI_ARCHITECTURE_ID ++ "set(MSVC_PLI_ARCHITECTURE_ID ${MSVC_PLI_ARCHITECTURE_ID})") ++endif() ++# configure variables set in this file for fast reload later on ++configure_file(${CMAKE_ROOT}/Modules/CMakePLICompiler.cmake.in ++ ${CMAKE_PLATFORM_INFO_DIR}/CMakePLICompiler.cmake ++ @ONLY ++ ) ++set(CMAKE_PLI_COMPILER_ENV_VAR "PC") diff --git a/patches/CMakePLICompiler.cmake.in.patch b/patches/CMakePLICompiler.cmake.in.patch new file mode 100644 index 0000000..b9ba1f1 --- /dev/null +++ b/patches/CMakePLICompiler.cmake.in.patch @@ -0,0 +1,58 @@ +diff --git a/Modules/CMakePLICompiler.cmake.in b/Modules/CMakePLICompiler.cmake.in +new file mode 100644 +index 0000000000..f2cad7ca1e +--- /dev/null ++++ b/Modules/CMakePLICompiler.cmake.in +@@ -0,0 +1,52 @@ ++set(CMAKE_PLI_COMPILER "@CMAKE_PLI_COMPILER@") ++set(CMAKE_PLI_COMPILER_ARG1 "@CMAKE_PLI_COMPILER_ARG1@") ++set(CMAKE_PLI_COMPILER_ID "@CMAKE_PLI_COMPILER_ID@") ++set(CMAKE_PLI_COMPILER_VERSION "@CMAKE_PLI_COMPILER_VERSION@") ++set(CMAKE_PLI_COMPILER_WRAPPER "@CMAKE_PLI_COMPILER_WRAPPER@") ++set(CMAKE_PLI_PLATFORM_ID "@CMAKE_PLI_PLATFORM_ID@") ++set(CMAKE_PLI_SIMULATE_ID "@CMAKE_PLI_SIMULATE_ID@") ++set(CMAKE_PLI_COMPILER_FRONTEND_VARIANT "@CMAKE_PLI_COMPILER_FRONTEND_VARIANT@") ++set(CMAKE_PLI_SIMULATE_VERSION "@CMAKE_PLI_SIMULATE_VERSION@") ++@_SET_CMAKE_PLI_XL_CPP@ ++@_SET_CMAKE_PLI_COMPILER_ARCHITECTURE_ID@ ++@_SET_CMAKE_PLI_COMPILER_SYSROOT@ ++@SET_MSVC_PLI_ARCHITECTURE_ID@ ++set(CMAKE_AR "@CMAKE_AR@") ++set(CMAKE_PLI_COMPILER_AR "@CMAKE_PLI_COMPILER_AR@") ++set(CMAKE_RANLIB "@CMAKE_RANLIB@") ++set(CMAKE_PLI_COMPILER_RANLIB "@CMAKE_PLI_COMPILER_RANLIB@") ++set(CMAKE_PLI_COMPILER_LOADED 1) ++set(CMAKE_PLI_COMPILER_WORKS @CMAKE_PLI_COMPILER_WORKS@) ++set(CMAKE_PLI_ABI_COMPILED @CMAKE_PLI_ABI_COMPILED@) ++ ++set(CMAKE_PLI_COMPILER_ENV_VAR "PC") ++ ++set(CMAKE_PLI_COMPILER_ID_RUN 1) ++set(CMAKE_PLI_SOURCE_FILE_EXTENSIONS pli;pl1;PLI;PL1) ++set(CMAKE_PLI_IGNORE_EXTENSIONS inc;include;INC;INCLUDE;o;O) ++ ++# Save compiler ABI information. ++set(CMAKE_PLI_SIZEOF_DATA_PTR "@CMAKE_PLI_SIZEOF_DATA_PTR@") ++set(CMAKE_PLI_COMPILER_ABI "@CMAKE_PLI_COMPILER_ABI@") ++set(CMAKE_PLI_LIBRARY_ARCHITECTURE "@CMAKE_PLI_LIBRARY_ARCHITECTURE@") ++ ++if(CMAKE_PLI_SIZEOF_DATA_PTR AND NOT CMAKE_SIZEOF_VOID_P) ++ set(CMAKE_SIZEOF_VOID_P "${CMAKE_PLI_SIZEOF_DATA_PTR}") ++endif() ++ ++if(CMAKE_PLI_COMPILER_ABI) ++ set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_PLI_COMPILER_ABI}") ++endif() ++ ++if(CMAKE_PLI_LIBRARY_ARCHITECTURE) ++ set(CMAKE_LIBRARY_ARCHITECTURE "@CMAKE_PLI_LIBRARY_ARCHITECTURE@") ++endif() ++ ++@CMAKE_PLI_COMPILER_CUSTOM_CODE@ ++@CMAKE_PLI_SYSROOT_FLAG_CODE@ ++@CMAKE_PLI_OSX_DEPLOYMENT_TARGET_FLAG_CODE@ ++ ++set(CMAKE_PLI_IMPLICIT_INCLUDE_DIRECTORIES "@CMAKE_PLI_IMPLICIT_INCLUDE_DIRECTORIES@") ++set(CMAKE_PLI_IMPLICIT_LINK_LIBRARIES "@CMAKE_PLI_IMPLICIT_LINK_LIBRARIES@") ++set(CMAKE_PLI_IMPLICIT_LINK_DIRECTORIES "@CMAKE_PLI_IMPLICIT_LINK_DIRECTORIES@") ++set(CMAKE_PLI_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_PLI_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@") diff --git a/patches/CMakePLICompilerABI.pli.patch b/patches/CMakePLICompilerABI.pli.patch new file mode 100644 index 0000000..fec9d3d --- /dev/null +++ b/patches/CMakePLICompilerABI.pli.patch @@ -0,0 +1,13 @@ +diff --git a/Modules/CMakePLICompilerABI.pli b/Modules/CMakePLICompilerABI.pli +new file mode 100644 +index 0000000000..574e18322b +--- /dev/null ++++ b/Modules/CMakePLICompilerABI.pli +@@ -0,0 +1,7 @@ ++*Process Limits( Extname( 100 ) ); ++ CMakePLICompileABI: PROC OPTIONS(MAIN); ++ /* need to add 64-bit support too */ ++ PUT SKIP LIST('INFO:sizeof_dptr[4]'); ++ PUT SKIP LIST('ABI Detection'); ++ END CMakePLICompileABI; ++ diff --git a/patches/CMakePLICompilerId.pli.in.patch b/patches/CMakePLICompilerId.pli.in.patch new file mode 100644 index 0000000..2c0a517 --- /dev/null +++ b/patches/CMakePLICompilerId.pli.in.patch @@ -0,0 +1,11 @@ +diff --git a/Modules/CMakePLICompilerId.pli.in b/Modules/CMakePLICompilerId.pli.in +new file mode 100644 +index 0000000000..8951d0a63c +--- /dev/null ++++ b/Modules/CMakePLICompilerId.pli.in +@@ -0,0 +1,5 @@ ++*Process Limits( Extname( 100 ) ); ++ CMakePLICompilerId: PROC OPTIONS(MAIN); ++ /* need to add 64-bit support too */ ++ PUT SKIP LIST('PL/I Compiler 6.2'); ++ END CMakePLICompilerId; diff --git a/patches/CMakePLIInformation.cmake.patch b/patches/CMakePLIInformation.cmake.patch new file mode 100644 index 0000000..3fe60ad --- /dev/null +++ b/patches/CMakePLIInformation.cmake.patch @@ -0,0 +1,174 @@ +diff --git a/Modules/CMakePLIInformation.cmake b/Modules/CMakePLIInformation.cmake +new file mode 100644 +index 0000000000..de01b148b6 +--- /dev/null ++++ b/Modules/CMakePLIInformation.cmake +@@ -0,0 +1,168 @@ ++# Distributed under the OSI-approved BSD 3-Clause License. See accompanying ++# file Copyright.txt or https://cmake.org/licensing for details. ++ ++ ++include(CMakeLanguageInformation) ++ ++# This file sets the basic flags for the PLI language in CMake. ++# It also loads the available platform file for the system-compiler ++# if it exists. ++ ++set(_INCLUDED_FILE 0) ++ ++set(CMAKE_PLI_OUTPUT_EXTENSION .o) ++set(CMAKE_INCLUDE_FLAG_PLI "-I") ++ ++# Load compiler-specific information. ++if(CMAKE_PLI_COMPILER_ID) ++ include(Compiler/${CMAKE_PLI_COMPILER_ID}-PLI OPTIONAL) ++endif() ++ ++set(CMAKE_BASE_NAME) ++get_filename_component(CMAKE_BASE_NAME "${CMAKE_PLI_COMPILER}" NAME_WE) ++if(CMAKE_PLI_COMPILER_ID) ++ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_PLI_COMPILER_ID}-PLI OPTIONAL RESULT_VARIABLE _INCLUDED_FILE) ++endif() ++if (NOT _INCLUDED_FILE) ++ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL ++ RESULT_VARIABLE _INCLUDED_FILE) ++endif () ++ ++# load any compiler-wrapper specific information ++if (CMAKE_PLI_COMPILER_WRAPPER) ++ __cmake_include_compiler_wrapper(PLI) ++endif () ++ ++# We specify the compiler information in the system file for some ++# platforms, but this language may not have been enabled when the file ++# was first included. Include it again to get the language info. ++# Remove this when all compiler info is removed from system files. ++if (NOT _INCLUDED_FILE) ++ include(Platform/${CMAKE_SYSTEM_NAME} OPTIONAL) ++endif () ++ ++if(CMAKE_PLI_SIZEOF_DATA_PTR) ++ foreach(f ${CMAKE_PLI_ABI_FILES}) ++ include(${f}) ++ endforeach() ++ unset(CMAKE_PLI_ABI_FILES) ++endif() ++ ++# This should be included before the _INIT variables are ++# used to initialize the cache. Since the rule variables ++# have if blocks on them, users can still define them here. ++# But, it should still be after the platform file so changes can ++# be made to those values. ++ ++if(CMAKE_USER_MAKE_RULES_OVERRIDE) ++ # Save the full path of the file so try_compile can use it. ++ include(${CMAKE_USER_MAKE_RULES_OVERRIDE} RESULT_VARIABLE _override) ++ set(CMAKE_USER_MAKE_RULES_OVERRIDE "${_override}") ++endif() ++ ++if(CMAKE_USER_MAKE_RULES_OVERRIDE_PLI) ++ # Save the full path of the file so try_compile can use it. ++ include(${CMAKE_USER_MAKE_RULES_OVERRIDE_PLI} RESULT_VARIABLE _override) ++ set(CMAKE_USER_MAKE_RULES_OVERRIDE_PLI "${_override}") ++endif() ++ ++if(NOT CMAKE_PLI_COMPILE_OPTIONS_PIC) ++ set(CMAKE_PLI_COMPILE_OPTIONS_PIC ${CMAKE_C_COMPILE_OPTIONS_PIC}) ++endif() ++ ++if(NOT CMAKE_PLI_COMPILE_OPTIONS_PIE) ++ set(CMAKE_PLI_COMPILE_OPTIONS_PIE ${CMAKE_C_COMPILE_OPTIONS_PIE}) ++endif() ++if(NOT CMAKE_PLI_LINK_OPTIONS_PIE) ++ set(CMAKE_PLI_LINK_OPTIONS_PIE ${CMAKE_C_LINK_OPTIONS_PIE}) ++endif() ++if(NOT CMAKE_PLI_LINK_OPTIONS_NO_PIE) ++ set(CMAKE_PLI_LINK_OPTIONS_NO_PIE ${CMAKE_C_LINK_OPTIONS_NO_PIE}) ++endif() ++ ++if(NOT CMAKE_PLI_COMPILE_OPTIONS_DLL) ++ set(CMAKE_PLI_COMPILE_OPTIONS_DLL ${CMAKE_C_COMPILE_OPTIONS_DLL}) ++endif() ++ ++set(CMAKE_VERBOSE_MAKEFILE FALSE CACHE BOOL "If this value is on, makefiles will be generated without the .SILENT directive, and all commands will be echoed to the console during the make. This is useful for debugging only. With Visual Studio IDE projects all commands are done without /nologo.") ++ ++set(CMAKE_PLI_FLAGS_INIT "$ENV{FFLAGS} ${CMAKE_PLI_FLAGS_INIT}") ++ ++cmake_initialize_per_config_variable(CMAKE_PLI_FLAGS "Flags used by the PLI compiler") ++ ++if(NOT CMAKE_PLI_COMPILER_LAUNCHER AND DEFINED ENV{CMAKE_PLI_COMPILER_LAUNCHER}) ++ set(CMAKE_PLI_COMPILER_LAUNCHER "$ENV{CMAKE_PLI_COMPILER_LAUNCHER}" ++ CACHE STRING "Compiler launcher for PLI.") ++endif() ++ ++include(CMakeCommonLanguageInclude) ++ ++# now define the following rule variables ++ ++# CMAKE_PLI_CREATE_SHARED_LIBRARY ++# CMAKE_PLI_CREATE_SHARED_MODULE ++# CMAKE_PLI_COMPILE_OBJECT ++# CMAKE_PLI_LINK_EXECUTABLE ++ ++# variables supplied by the generator at use time ++# ++# the target without the suffix ++# ++# ++# ++# ++# ++ ++# PLI compiler information ++# ++# ++# ++# ++ ++# Static library tools ++# ++# ++ ++# create a PLI shared library ++if(NOT CMAKE_PLI_CREATE_SHARED_LIBRARY) ++ set(CMAKE_PLI_CREATE_SHARED_LIBRARY ++ " -o ") ++endif() ++ ++# create a PLI shared module just copy the shared library rule ++if(NOT CMAKE_PLI_CREATE_SHARED_MODULE) ++ set(CMAKE_PLI_CREATE_SHARED_MODULE ${CMAKE_PLI_CREATE_SHARED_LIBRARY}) ++endif() ++ ++# Create a static archive incrementally for large object file counts. ++# If CMAKE_PLI_CREATE_STATIC_LIBRARY is set it will override these. ++if(NOT DEFINED CMAKE_PLI_ARCHIVE_CREATE) ++ set(CMAKE_PLI_ARCHIVE_CREATE " qc ") ++endif() ++if(NOT DEFINED CMAKE_PLI_ARCHIVE_APPEND) ++ set(CMAKE_PLI_ARCHIVE_APPEND " q ") ++endif() ++if(NOT DEFINED CMAKE_PLI_ARCHIVE_FINISH) ++ set(CMAKE_PLI_ARCHIVE_FINISH " ") ++endif() ++ ++# compile a PLI file into an object file ++if(NOT CMAKE_PLI_COMPILE_OBJECT) ++ set(CMAKE_PLI_COMPILE_OBJECT ++ " -o -c ") ++endif() ++ ++# link a PLI program ++if(NOT CMAKE_PLI_LINK_EXECUTABLE) ++ set(CMAKE_PLI_LINK_EXECUTABLE ++ " -o ") ++endif() ++ ++if(CMAKE_PLI_STANDARD_LIBRARIES_INIT) ++ set(CMAKE_PLI_STANDARD_LIBRARIES "${CMAKE_PLI_STANDARD_LIBRARIES_INIT}" ++ CACHE STRING "Libraries linked by default with all PLI applications.") ++ mark_as_advanced(CMAKE_PLI_STANDARD_LIBRARIES) ++endif() ++ ++# set this variable so we can avoid loading this more than once. ++set(CMAKE_PLI_INFORMATION_LOADED 1) diff --git a/patches/CMakeTestPLICompiler.cmake.patch b/patches/CMakeTestPLICompiler.cmake.patch new file mode 100644 index 0000000..6301883 --- /dev/null +++ b/patches/CMakeTestPLICompiler.cmake.patch @@ -0,0 +1,84 @@ +diff --git a/Modules/CMakeTestPLICompiler.cmake b/Modules/CMakeTestPLICompiler.cmake +new file mode 100644 +index 0000000000..797673a53a +--- /dev/null ++++ b/Modules/CMakeTestPLICompiler.cmake +@@ -0,0 +1,78 @@ ++# Distributed under the OSI-approved BSD 3-Clause License. See accompanying ++# file Copyright.txt or https://cmake.org/licensing for details. ++ ++ ++if(CMAKE_PLI_COMPILER_FORCED) ++ # The compiler configuration was forced by the user. ++ # Assume the user has configured all compiler information. ++ set(CMAKE_PLI_COMPILER_WORKS TRUE) ++ return() ++endif() ++ ++include(CMakeTestCompilerCommon) ++ ++# Remove any cached result from an older CMake version. ++# We now store this in CMakePLICompiler.cmake. ++unset(CMAKE_PLI_COMPILER_WORKS CACHE) ++ ++# Try to identify the ABI and configure it into CMakePLICompiler.cmake ++include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) ++CMAKE_DETERMINE_COMPILER_ABI(PLI ${CMAKE_ROOT}/Modules/CMakePLICompilerABI.pli) ++if(CMAKE_PLI_ABI_COMPILED) ++ # The compiler worked so skip dedicated test below. ++ set(CMAKE_PLI_COMPILER_WORKS TRUE) ++ message(STATUS "Check for working PLI compiler: ${CMAKE_PLI_COMPILER} - skipped") ++endif() ++ ++# This file is used by EnableLanguage in cmGlobalGenerator to ++# determine that the selected PLI compiler can actually compile ++# and link the most basic of programs. If not, a fatal error ++# is set and cmake stops processing commands and will not generate ++# any makefiles or projects. ++if(NOT CMAKE_PLI_COMPILER_WORKS) ++ PrintTestCompilerStatus("PLI") ++ file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testPLICompiler.pli " ++ HELLO: PROCEDURE OPTIONS (MAIN); ++ PUT SKIP LIST('HELLO WORLD!'); ++ END HELLO; ++ ") ++ # Clear result from normal variable. ++ unset(CMAKE_PLI_COMPILER_WORKS) ++ # Puts test result in cache variable. ++ try_compile(CMAKE_PLI_COMPILER_WORKS ${CMAKE_BINARY_DIR} ++ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testPLICompiler.pli ++ OUTPUT_VARIABLE OUTPUT) ++ # Move result from cache to normal variable. ++ set(CMAKE_PLI_COMPILER_WORKS ${CMAKE_PLI_COMPILER_WORKS}) ++ unset(CMAKE_PLI_COMPILER_WORKS CACHE) ++ if(NOT CMAKE_PLI_COMPILER_WORKS) ++ PrintTestCompilerResult(CHECK_FAIL "broken") ++ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log ++ "Determining if the PLI compiler works failed with " ++ "the following output:\n${OUTPUT}\n\n") ++ string(REPLACE "\n" "\n " _output "${OUTPUT}") ++ message(FATAL_ERROR "The PLI compiler\n \"${CMAKE_PLI_COMPILER}\"\n" ++ "is not able to compile a simple test program.\nIt fails " ++ "with the following output:\n ${_output}\n\n" ++ "CMake will not be able to correctly generate this project.") ++ endif() ++ PrintTestCompilerResult(CHECK_PASS "works") ++ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log ++ "Determining if the PLI compiler works passed with " ++ "the following output:\n${OUTPUT}\n\n") ++endif() ++ ++# Re-configure to save learned information. ++configure_file( ++ ${CMAKE_ROOT}/Modules/CMakePLICompiler.cmake.in ++ ${CMAKE_PLATFORM_INFO_DIR}/CMakePLICompiler.cmake ++ @ONLY ++ ) ++include(${CMAKE_PLATFORM_INFO_DIR}/CMakePLICompiler.cmake) ++ ++if(CMAKE_PLI_SIZEOF_DATA_PTR) ++ foreach(f ${CMAKE_PLI_ABI_FILES}) ++ include(${f}) ++ endforeach() ++ unset(CMAKE_PLI_ABI_FILES) ++endif() diff --git a/patches/IBM-PLI.cmake.patch b/patches/IBM-PLI.cmake.patch new file mode 100644 index 0000000..7892b9b --- /dev/null +++ b/patches/IBM-PLI.cmake.patch @@ -0,0 +1,16 @@ +diff --git a/Modules/Compiler/IBM-PLI.cmake b/Modules/Compiler/IBM-PLI.cmake +new file mode 100644 +index 0000000000..19ff0a25c7 +--- /dev/null ++++ b/Modules/Compiler/IBM-PLI.cmake +@@ -0,0 +1,10 @@ ++include(Compiler/zOS) ++ ++if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) ++ AND (NOT CMAKE_PLI_COMPILER_VERSION VERSION_LESS 6.1 )) ++ # dependencies are computed by the compiler itself ++ # this needs to likely be changed to 6.x not 6.1 ++ set(CMAKE_PLI_DEPFILE_FORMAT gcc) ++ set(CMAKE_PLI_DEPENDS_USE_COMPILER TRUE) ++ set(CMAKE_DEPFILE_FLAGS_PLI "-MD -MT -MF ") ++endif() diff --git a/patches/zos-v3.24.2.patch b/patches/zos-v3.24.2.patch index 7887290..91cdbdc 100644 --- a/patches/zos-v3.24.2.patch +++ b/patches/zos-v3.24.2.patch @@ -63,22 +63,6 @@ index 82a6d21a41..0a281f3357 100644 __TestCompiler_setTryCompileTargetType() # Avoid failing ABI detection on warnings. -diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake -index 2b19736d47..1f4f42b67e 100644 ---- a/Modules/CMakeDetermineCompilerId.cmake -+++ b/Modules/CMakeDetermineCompilerId.cmake -@@ -32,6 +32,11 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) - endif() - string(REPLACE " " ";" CMAKE_${lang}_COMPILER_ID_FLAGS_LIST "${CMAKE_${lang}_COMPILER_ID_FLAGS}") - -+ # Drop qASCII Flag for z/OS for correct encoding of string literals. -+ if(CMAKE_SYSTEM_NAME MATCHES "OS390") -+ string(REGEX REPLACE "-(qASCII|qascii|fzos-le-char-mode=ascii);?" "" CMAKE_${lang}_COMPILER_ID_FLAGS_LIST "${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST}") -+ endif() -+ - # Compute the directory in which to run the test. - set(CMAKE_${lang}_COMPILER_ID_DIR ${CMAKE_PLATFORM_INFO_DIR}/CompilerId${lang}) - diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake index 2c2c2ac371..1391f2a7f5 100644 --- a/Modules/CMakeDetermineSystem.cmake diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..5bb4c39 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.24.2) +project(hw LANGUAGES C) + +include_directories(include) + +set(hwsrc src/hw.c src/fn.c) + +add_executable(hw ${hwsrc}) diff --git a/tests/basictest b/tests/basictest new file mode 100755 index 0000000..741b120 --- /dev/null +++ b/tests/basictest @@ -0,0 +1,80 @@ +#!/bin/sh +# +# initial: Configure and build 'hw'. Should be 3 steps (compile, compile, link) +# ctouch: Touch fn.c. Should be 2 steps (compile, link) +# htouch: Touch hw.h. Should be 3 steps (compile, compile, link) + +init_out="/tmp/$$.hwtest_initial.out" +ctouch_out="/tmp/$$.hwtest_ctouch.out" +htouch_out="/tmp/$$.hwtest_htouch.out" + +if ! ./cfghw ; then + echo "Unable to configure hello-world build" >&2 + exit 4 +fi + +# +# initial: +# +if ! ./bldhw >"${init_out}" ; then + echo "Unable to build hello-world (initial). See ${init_out}" >&2 + exit 4 +fi + +actual=$(tail -1 "${init_out}") +expected="[3/3] Linking C executable hw" +if [ "${actual}x" != "${expected}x" ]; then + echo "Unexpected output (initial). See ${init_out}" >&2 + exit 4 +fi + +# +# ctouch: +# +if ! touch src/fn.c; then + echo "Internal error - could not find C file" >&2 + exit 4 +fi + +if ! ./bldhw >"${ctouch_out}" ; then + echo "Unable to build hello-world (ctouch). See ${ctouch_out}" >&2 + exit 4 +fi + +actual=$(tail -1 "${ctouch_out}") +expected="[2/2] Linking C executable hw" +if [ "${actual}x" != "${expected}x" ]; then + echo "Unexpected output (ctouch). See ${ctouch_out}" >&2 + exit 4 +fi + +if ! sleep 1; then + echo "Internal error - unable to sleep for 1s" >&2 + exit 4 +fi + +# +# htouch: +# +if ! touch include/hw.h; then + echo "Internal error - could not find H file" >&2 + exit 4 +fi + +if ! ./bldhw >"${htouch_out}" ; then + echo "Unable to build hello-world (htouch). See ${htouch_out}" >&2 + exit 4 +fi + +actual=$(tail -1 "${htouch_out}") +expected="[3/3] Linking C executable hw" +if [ "${actual}x" != "${expected}x" ]; then + echo "Unexpected output (htouch). See ${htouch_out}" >&2 + exit 4 +fi + +if ! rm /tmp/$$*.out; then + echo "Internal error - unable to clean up temporary files" >&2 + exit 4 +fi + diff --git a/tests/bldhw b/tests/bldhw new file mode 100755 index 0000000..d24027c --- /dev/null +++ b/tests/bldhw @@ -0,0 +1,10 @@ +#!/bin/sh +# +# Build 'hw' using the configured ninja build from 'cfghw' +# +export NINJA=ninja +if ! ${NINJA} --version ; then + echo "Unable to find ${NINJA}" >&2 + exit 4 +fi +cd build && ninja diff --git a/tests/cfghw b/tests/cfghw new file mode 100755 index 0000000..b05ce1b --- /dev/null +++ b/tests/cfghw @@ -0,0 +1,26 @@ +#!/bin/sh +export CC=clang +export CMAKE=cmake +export NINJA=ninja + +if ! ${CC} --version ; then + echo "Unable to find ${CC} compiler" >&2 + exit 4 +fi +if ! ${CMAKE} --version ; then + echo "Unable to find ${CMAKE}" >&2 + exit 4 +fi +if ! ${NINJA} --version ; then + echo "Unable to find ${NINJA}" >&2 + exit 4 +fi + +# +# Delete the old 'build' tools and start from scratch +# +rm -rf build +mkdir -p build +cd build + +cmake -D CMAKE_C_COMPILER=${CC} -G Ninja .. diff --git a/tests/include/hw.h b/tests/include/hw.h new file mode 100644 index 0000000..08ed795 --- /dev/null +++ b/tests/include/hw.h @@ -0,0 +1 @@ +int hw(int); diff --git a/tests/src/fn.c b/tests/src/fn.c new file mode 100644 index 0000000..45ad38a --- /dev/null +++ b/tests/src/fn.c @@ -0,0 +1,7 @@ +#include "hw.h" +#include + +int hw() { + return printf("Hello world\n"); +} + diff --git a/tests/src/hw.c b/tests/src/hw.c new file mode 100644 index 0000000..4e6af84 --- /dev/null +++ b/tests/src/hw.c @@ -0,0 +1,5 @@ +#include "hw.h" + +int main(int argc, char* argv[]) { + return hw(argc); +}