Skip to content

Basic 'starter support' for PL/I #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CMake
log
install
nohup.out
tests/build
tests/hw.trace
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
13 changes: 13 additions & 0 deletions patches/CMakeCompilerIdDetection.cmake.patch
Original file line number Diff line number Diff line change
@@ -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)
28 changes: 28 additions & 0 deletions patches/CMakeDetermineCompilerId.cmake.patch
Original file line number Diff line number Diff line change
@@ -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})

132 changes: 132 additions & 0 deletions patches/CMakeDeterminePLICompiler.cmake.patch
Original file line number Diff line number Diff line change
@@ -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")
58 changes: 58 additions & 0 deletions patches/CMakePLICompiler.cmake.in.patch
Original file line number Diff line number Diff line change
@@ -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@")
13 changes: 13 additions & 0 deletions patches/CMakePLICompilerABI.pli.patch
Original file line number Diff line number Diff line change
@@ -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;
+
11 changes: 11 additions & 0 deletions patches/CMakePLICompilerId.pli.in.patch
Original file line number Diff line number Diff line change
@@ -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;
Loading