From: George Koehler Subject: security/libgcrypt fix for powerpc, powerpc64 To: ports@openbsd.org Cc: Antoine Jacoutot Date: Thu, 15 Aug 2024 20:26:02 -0400 This diff unbreaks security/libgcrypt for powerpc and powerpc64 and should not affect other archs. Builds failed with "./sha256-ppc.c:294:8:warning: call to undeclared function 'vec_mergeo'" followed by errors. Fix by building the VSX files with cc -mpower8-vector (Power ISA 2.07), so in clang-16 defines vec_mergeo. This matches how libgcrypt checks for ISA 2.07 before calling VSX functions. (It isn't calling them on OpenBSD. It will if we add the ISA stuff to elf_aux_info.) After I unbroke the build, "make test" had mpi (integer) failures on powerpc64 until I added patch-mpi_config_links. Now "make test" passes on powerpc64 and has 2 secmem failures on powerpc, t-secmem: line 189: gcry_control ((GCRYCTL_INIT_SECMEM, pool_size, 0)) failed: General error t-sexp: line 1321: gcry_control ((GCRYCTL_INIT_SECMEM, 16384, 0)) failed: General error Should I bump REVISION? powerpc and powerpc64 never packaged 1.11.0. ok? --gkoehler Index: Makefile =================================================================== RCS file: /cvs/ports/security/libgcrypt/Makefile,v diff -u -p -r1.95 Makefile --- Makefile 10 Jul 2024 12:58:39 -0000 1.95 +++ Makefile 15 Aug 2024 18:19:17 -0000 @@ -6,6 +6,7 @@ USE_NOEXECONLY= Yes COMMENT= crypto library based on code used in GnuPG DISTNAME= libgcrypt-1.11.0 +REVISION= 0 CATEGORIES= security Index: patches/patch-cipher_Makefile_in =================================================================== RCS file: patches/patch-cipher_Makefile_in diff -N patches/patch-cipher_Makefile_in --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-cipher_Makefile_in 15 Aug 2024 18:19:17 -0000 @@ -0,0 +1,15 @@ +- powerpc and powerpc64: add -mpower8-vector to fix + ./sha256-ppc.c:294:8: warning: call to undeclared function 'vec_mergeo' + +Index: cipher/Makefile.in +--- cipher/Makefile.in.orig ++++ cipher/Makefile.in +@@ -655,7 +655,7 @@ EXTRA_libcipher_la_SOURCES = \ + @ENABLE_INSTRUMENTATION_MUNGING_TRUE@ -e 's/-fcoverage[=,\-][=,a-z,A-Z,0-9,\,,\-]*//g' + + @ENABLE_PPC_VCRYPTO_EXTRA_CFLAGS_FALSE@ppc_vcrypto_cflags = +-@ENABLE_PPC_VCRYPTO_EXTRA_CFLAGS_TRUE@ppc_vcrypto_cflags = -O2 -maltivec -mvsx -mcrypto ++@ENABLE_PPC_VCRYPTO_EXTRA_CFLAGS_TRUE@ppc_vcrypto_cflags = -O2 -maltivec -mvsx -mcrypto -mpower8-vector + @ENABLE_AARCH64_NEON_INTRINSICS_EXTRA_CFLAGS_FALSE@aarch64_neon_cflags = + @ENABLE_AARCH64_NEON_INTRINSICS_EXTRA_CFLAGS_TRUE@aarch64_neon_cflags = -O2 -march=armv8-a+crypto + @ENABLE_X86_AVX512_INTRINSICS_EXTRA_CFLAGS_FALSE@avx512f_cflags = Index: patches/patch-configure =================================================================== RCS file: /cvs/ports/security/libgcrypt/patches/patch-configure,v diff -u -p -r1.13 patch-configure --- patches/patch-configure 10 Jul 2024 12:58:39 -0000 1.13 +++ patches/patch-configure 15 Aug 2024 18:19:17 -0000 @@ -1,18 +1,29 @@ -https://dev.gnupg.org/T6442 +- powerpc and powerpc64: add -mpower8-vector to fix + ./sha256-ppc.c:294:8: warning: call to undeclared function 'vec_mergeo' +- getrandom: https://dev.gnupg.org/T6442 Index: configure --- configure.orig +++ configure -@@ -20021,6 +20021,12 @@ if test "$gcry_cv_gcc_inline_asm_ppc_altivec" = "yes" - printf "%s\n" "#define HAVE_GCC_INLINE_ASM_PPC_ALTIVEC 1" >>confdefs.h - +@@ -19906,7 +19906,7 @@ printf "%s\n" "#define HAVE_COMPATIBLE_CC_PPC_ALTIVEC fi + + _gcc_cflags_save=$CFLAGS +-CFLAGS="$CFLAGS -O2 -maltivec -mvsx -mcrypto" ++CFLAGS="$CFLAGS -O2 -maltivec -mvsx -mcrypto -mpower8-vector" + + if test "$gcry_cv_cc_ppc_altivec" = "no" && + test "$mpi_cpu_arch" = "ppc" && +@@ -20019,6 +20019,12 @@ printf "%s\n" "$gcry_cv_gcc_inline_asm_ppc_altivec" >& + if test "$gcry_cv_gcc_inline_asm_ppc_altivec" = "yes" ; then + + printf "%s\n" "#define HAVE_GCC_INLINE_ASM_PPC_ALTIVEC 1" >>confdefs.h ++ ++fi +ac_fn_c_check_func "$LINENO" "getrandom" "ac_cv_func_getrandom" +if test "x$ac_cv_func_getrandom" = xyes +then : + printf "%s\n" "#define HAVE_GETRANDOM 1" >>confdefs.h -+ -+fi + fi - # Index: patches/patch-mpi_config_links =================================================================== RCS file: patches/patch-mpi_config_links diff -N patches/patch-mpi_config_links --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-mpi_config_links 15 Aug 2024 18:19:17 -0000 @@ -0,0 +1,36 @@ +- For OpenBSD/powerpc64, don't pick powerpc32 asm. + +Index: mpi/config.links +--- mpi/config.links.orig ++++ mpi/config.links +@@ -272,15 +272,6 @@ case "${host}" in + mpi_cpu_arch="ppc" + ;; + +- powerpc*-*-netbsd* | powerpc*-*-openbsd*) +- echo '/* configured {Open,Net}BSD on powerpc */' >>./mpi/asm-syntax.h +- echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h +- cat $srcdir/mpi/powerpc32/syntax.h >>./mpi/asm-syntax.h +- mpi_sflags="-Wa,-mppc" +- path="powerpc32" +- mpi_cpu_arch="ppc" +- ;; +- + ppc620-*-* | \ + powerpc64*-*-*) + mpi_sflags="-Wa,-mppc" +@@ -294,6 +285,14 @@ case "${host}" in + path="powerpc32" + mpi_cpu_arch="ppc" + ;; ++ powerpc*-*-netbsd* | powerpc*-*-openbsd*) ++ echo '/* configured {Open,Net}BSD on powerpc */' >>./mpi/asm-syntax.h ++ echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h ++ cat $srcdir/mpi/powerpc32/syntax.h >>./mpi/asm-syntax.h ++ mpi_sflags="-Wa,-mppc" ++ path="powerpc32" ++ mpi_cpu_arch="ppc" ++ ;; + + rs6000-*-aix[456789]* | \ + rs6000-*-aix3.2.[456789])