[PATCH libgcrypt] Add support for IBM z/OS

Sachin T sachin.t at ibm.com
Thu Nov 27 10:37:01 CET 2025


Hello Maintainers,

Please review the required changes for libgcrypt on z/OS platform.

Patch details as explained below.

  1.
configure.ac: Add z/OS detection to set a printable OS name, hint pthread availability, obtain EXTRA_LIBS_FOR_BUILD via pkg-config/zoslib for external library linking, and disable mmap detection so configure and generated Makefiles behave correctly on z/OS.
  2.
cipher/Makefile.am, doc/Makefile.am: Append $(EXTRA_LIBS_FOR_BUILD) to gost-s-box and yat2m link lines so build-host helper programs link correctly with z/OS-specific libraries during the build.
  3.  m4/libtool.m4: Add openedition* case setting lt_cv_deplibs_check_method=pass_all to accommodate z/OS/libtool dependency-check behavior.
  4.
mpi/longlong.h: Exclude the s390x GCC inline-assembly path on z/OS (MVS) because the inline asm is written for GAS-style syntax used on Linux on Z (LoZ) and is not compatible with z/OS.
Rationale: although both targets use the same s390x architecture, z/OS uses HLASM (IBM High Level Assembler) with different syntax/semantics while LoZ uses GAS-style inline asm, so the GAS-formatted asm must be avoided on z/OS.
  5.
src/secmem.c: Make secure-memory locking a no-op on z/OS  because the platform lacks the same secure memory primitives.

---

Signed-off-by: Sachin T <sachin.t at ibm.com>
---
 cipher/Makefile.am |  2 +-
 configure.ac       | 30 +++++++++++++++++++++++++++++-
 doc/Makefile.am    |  2 +-
 m4/libtool.m4      |  4 ++++
 mpi/longlong.h     |  2 +-
 src/secmem.c       |  4 ++++
 6 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/cipher/Makefile.am b/cipher/Makefile.am
index bbcd518a..fc8966f8 100644
--- a/cipher/Makefile.am
+++ b/cipher/Makefile.am
@@ -175,7 +175,7 @@ gost-sb.h: gost-s-box$(EXEEXT_FOR_BUILD)

 gost-s-box$(EXEEXT_FOR_BUILD): gost-s-box.c
      $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) \
-         $(CPPFLAGS_FOR_BUILD) -o $@ $(srcdir)/gost-s-box.c
+         $(CPPFLAGS_FOR_BUILD) -o $@ $(srcdir)/gost-s-box.c $(EXTRA_LIBS_FOR_BUILD)


 if ENABLE_O_FLAG_MUNGING
diff --git a/configure.ac b/configure.ac
index f5e78077..c7070169 100644
--- a/configure.ac
+++ b/configure.ac
@@ -290,6 +290,10 @@ case "${host}" in
                   [defined if we use posix_spawn in test program])
         AC_CHECK_HEADERS(spawn.h)
         ;;
+    *-openedition*)
+           # The z/OS C runtime includes pthread support, and linking is handled automatically at build time.
+        have_pthread=yes
+        ;;
     *)
       ;;
 esac
@@ -299,7 +303,6 @@ if test "$have_w32_system" = yes; then
 fi
 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)

-
 # A printable OS Name is sometimes useful.
 case "${host}" in
     *-*-mingw32*)
@@ -318,11 +321,29 @@ case "${host}" in
         PRINTABLE_OS_NAME="GNU/Linux"
         ;;

+    *-openedition*)
+        PRINTABLE_OS_NAME="IBM z/OS"
+        ;;
+
     *)
         PRINTABLE_OS_NAME=`uname -s || echo "Unknown"`
         ;;
 esac

+# Set some variables for build platform helpers.
+
+case "$build_os" in
+    *openedition*)
+        PKG_CHECK_MODULES([ZOSLIB], [zoslib],
+                          [EXTRA_LIBS_FOR_BUILD="$ZOSLIB_LIBS"],
+                          [AC_MSG_ERROR([zoslib not found. Please ensure zoslib.pc is in PKG_CONFIG_PATH.])])
+         ;;
+    *)
+        EXTRA_LIBS_FOR_BUILD=""
+     ;;
+esac
+AC_SUBST(EXTRA_LIBS_FOR_BUILD)
+
 NAME_OF_DEV_RANDOM="/dev/random"
 NAME_OF_DEV_URANDOM="/dev/urandom"

@@ -3029,6 +3050,13 @@ AC_CHECK_FUNCS(stpcpy strcasecmp)
 # We have replacements for these in src/g10lib.h
 AC_CHECK_FUNCS(strtoul memmove stricmp atexit raise)
 # Other checks
+case "$host_os" in
+    *openedition*)
+        # mmap is not fully supported on z/os.
+        ac_cv_func_mmap=no
+        ;;
+esac
+
 AC_CHECK_FUNCS(strerror rand mmap getpagesize sysconf waitpid wait4)
 AC_CHECK_FUNCS(gettimeofday getrusage gethrtime clock_gettime syslog)
 AC_CHECK_FUNCS(syscall fcntl ftruncate flockfile getauxval elf_aux_info)
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 2501e5da..f5432700 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -40,7 +40,7 @@ myman_pages   = hmac256.1
 man_MANS = $(myman_pages)

 yat2m$(EXEEXT_FOR_BUILD): yat2m.c
-     $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) \
+     $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(EXTRA_LIBS_FOR_BUILD) \
          $(CPPFLAGS_FOR_BUILD) -o $@ $(srcdir)/yat2m.c

 .fig.png:
diff --git a/m4/libtool.m4 b/m4/libtool.m4
index 102e884d..d4b52744 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -3348,6 +3348,10 @@ openbsd*)
   fi
   ;;

+openedition*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
 osf3* | osf4* | osf5*)
   lt_cv_deplibs_check_method=pass_all
   ;;
diff --git a/mpi/longlong.h b/mpi/longlong.h
index 9e60592a..46de33a8 100644
--- a/mpi/longlong.h
+++ b/mpi/longlong.h
@@ -1505,7 +1505,7 @@ extern USItype __udiv_qrnnd (USItype *, USItype, USItype, USItype);
 /***************************************
  *********** s390x/zSeries  ************
  ***************************************/
-#if defined (__s390x__) && W_TYPE_SIZE == 64 && __GNUC__ >= 4
+#if defined (__s390x__) && !defined (__MVS__) && W_TYPE_SIZE == 64 && __GNUC__ >= 4
 # define add_ssaaaa(sh, sl, ah, al, bh, bl) \
   __asm__ ("algr %1,%5\n"                                               \
         "alcgr %0,%3\n"                                              \
diff --git a/src/secmem.c b/src/secmem.c
index 19cf1ad4..7c5cac76 100644
--- a/src/secmem.c
+++ b/src/secmem.c
@@ -365,6 +365,10 @@ lock_pool_pages (void *p, size_t n)
      * this whole Windows !@#$% and their user base are inherently insecure. */
   (void)p;
   (void)n;
+#elif defined (__MVS__)
+  /* On z/OS secure memory locking is not implemented */
+  (void)p;
+  (void)n;
 #else
   (void)p;
   (void)n;
--
2.51.0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnupg-devel/attachments/20251127/ef34aaa1/attachment-0001.html>


More information about the Gnupg-devel mailing list