From e6290f04ddc0ed740127985bde4498ff9d36b6bd Mon Sep 17 00:00:00 2001 From: Fred Wright Date: Wed, 28 Feb 2024 22:40:53 -0800 Subject: [PATCH] libffi: Fix build on 10.4, 10.5 This makes three changes to the patches for 10.4 and 10.5: 1) In the G3 patch, it removes the ppc7400 reference that was never actually used, rather than updating it. It still fixes the case that is actually used. 2) It removes the patch for i386 assembler that has been (approximately) incorporated upstream since v3.4.5. The collision with this patch was the reason for the patch failure. 3) For the gcc 4.2 test-build fix, it replaces the conditionally applied patchfile with an unconditional patch controlled by an environment variable, thereby keeping the source code consistent across OS versions. This new environment variable is now defined by the Portfile when the compiler is gcc 4.2. The patches for #1 and #3 are now in a single unified patchfile. Closes: https://trac.macports.org/ticket/69380 TESTED: Tested on 10.4-10.5 ppc, 10.5-10.6 ppc (x86_64 Rosetta), 10.4-10.6 i386, 10.4-12.x x86_64, and 11.x-14.x arm64. Now builds and passes at least some tests on all tested platforms, except 10.4 ppc +universal. Test behavior on 10.6+ is essentially unchanged. Tests on 10.4 and 10.5 have a few additional failures since v3.4.4 (the last version that built successfully) due to new tests having been added. --- devel/libffi/Portfile | 13 +++-- .../patch-libffi-intel-leopard-sysv.diff | 39 --------------- .../files/patch-libffi-tests-gcc42.diff | 27 ---------- devel/libffi/files/patch-pre-snowleopard.diff | 50 +++++++++++++++++++ devel/libffi/files/powerpc-g3.patch | 24 --------- 5 files changed, 56 insertions(+), 97 deletions(-) delete mode 100644 devel/libffi/files/patch-libffi-intel-leopard-sysv.diff delete mode 100644 devel/libffi/files/patch-libffi-tests-gcc42.diff create mode 100644 devel/libffi/files/patch-pre-snowleopard.diff delete mode 100644 devel/libffi/files/powerpc-g3.patch diff --git a/devel/libffi/Portfile b/devel/libffi/Portfile index 539196fa806c1..f995e2ad417be 100644 --- a/devel/libffi/Portfile +++ b/devel/libffi/Portfile @@ -25,13 +25,7 @@ long_description The libffi library provides a portable, high level \ homepage https://www.sourceware.org/libffi/ -patchfiles powerpc-g3.patch - -if {${os.platform} eq "darwin" && ${os.major} < 10 && ![string match *clang* ${configure.compiler}]} { - # https://trac.macports.org/ticket/61170 - patchfiles-append patch-libffi-intel-leopard-sysv.diff \ - patch-libffi-tests-gcc42.diff -} +patchfiles patch-pre-snowleopard.diff # Don't use macports gcc or clang toolchains to build this due to dependency cycles compiler.blacklist-append macports-* @@ -67,4 +61,9 @@ depends_test-append port:expect port:dejagnu test.run yes test.target check +# Some warnings need to be disabled when building tests with gcc-4.2 +if {[string match *gcc-4.2 ${configure.compiler}]} { + test.env-append LIBFFI_TEST_OLDGCC=1 +} + github.livecheck.regex {(\d+(?:\.\d+)+)} diff --git a/devel/libffi/files/patch-libffi-intel-leopard-sysv.diff b/devel/libffi/files/patch-libffi-intel-leopard-sysv.diff deleted file mode 100644 index b1acb19c593d2..0000000000000 --- a/devel/libffi/files/patch-libffi-intel-leopard-sysv.diff +++ /dev/null @@ -1,39 +0,0 @@ -This i386 code in libffi has been written now to assume a current darwin assembler -and .cfi directives. Bootstrapping with gcc-4.2 and the default "gas" assembler -no longer works. This patch re-enables the build of libffi by reverting the asm change -and disabling the unsupported features. - -If important to someone, it might be possible to rebuild libffi with these features -re-enabled once a newer toolchain has been installed (clang/ld64/cctools). - -https://trac.macports.org/ticket/61170 - ---- ./src/x86/sysv.S.orig -+++ ./src/x86/sysv.S -@@ -792,7 +792,7 @@ - - #ifdef X86_DARWIN - # define COMDAT(X) \ -- .section __TEXT,__text,coalesced,pure_instructions; \ -+ .section __TEXT,__textcoal_nt,coalesced,pure_instructions; \ - .weak_definition X; \ - FFI_HIDDEN(X) - #elif defined __ELF__ && !(defined(__sun__) && defined(__svr4__)) -@@ -820,7 +820,7 @@ - #endif /* __PIC__ */ - - /* Sadly, OSX cctools-as doesn't understand .cfi directives at all. */ -- -+#if 0 - #ifdef __APPLE__ - .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support - EHFrame0: -@@ -1120,7 +1120,7 @@ - .long 0 - .long 0 - #endif /* __APPLE__ */ -- -+#endif /* if 0 */ - #endif /* ifndef _MSC_VER */ - #endif /* ifdef __i386__ */ - diff --git a/devel/libffi/files/patch-libffi-tests-gcc42.diff b/devel/libffi/files/patch-libffi-tests-gcc42.diff deleted file mode 100644 index fbffd2b00015a..0000000000000 --- a/devel/libffi/files/patch-libffi-tests-gcc42.diff +++ /dev/null @@ -1,27 +0,0 @@ -Needed to run the test suite with the default toolchain on older darwin systems. -Removes flags unsupported by gcc-4.2 - -https://trac.macports.org/ticket/61170 - ---- ./testsuite/lib/libffi.exp.orig -+++ ./testsuite/lib/libffi.exp -@@ -488,7 +488,7 @@ - } - } - "gnu" { -- set common "-W -Wall -Wno-psabi" -+ set common "-W -Wall" - if [info exists env(LIBFFI_TEST_OPTIMIZATION)] { - set optimizations [ list $env(LIBFFI_TEST_OPTIMIZATION) ] - } else { ---- ./testsuite/libffi.bhaible/bhaible.exp.orig -+++ ./testsuite/libffi.bhaible/bhaible.exp -@@ -24,7 +24,7 @@ - # was done in a pretty lazy fashion, and requires the use of compiler - # flags to disable warnings for now. - if { [string match $compiler_vendor "gnu"] } { -- set warning_options "-Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-uninitialized"; -+ set warning_options "-Wno-unused-variable -Wno-unused-parameter -Wno-uninitialized"; - } - if { [string match $compiler_vendor "microsoft"] } { - # -wd4996 suggest use of vsprintf_s instead of vsprintf diff --git a/devel/libffi/files/patch-pre-snowleopard.diff b/devel/libffi/files/patch-pre-snowleopard.diff new file mode 100644 index 0000000000000..ba78eb9a4d95f --- /dev/null +++ b/devel/libffi/files/patch-pre-snowleopard.diff @@ -0,0 +1,50 @@ +--- src/powerpc/darwin.S.orig 2023-03-15 07:19:45.000000000 -0700 ++++ src/powerpc/darwin.S 2024-02-26 18:37:38.000000000 -0800 +@@ -31,8 +31,6 @@ + #define MODE_CHOICE(x, y) x + #endif + +-#define machine_choice MODE_CHOICE(ppc7400,ppc64) +- + ; Define some pseudo-opcodes for size-independent load & store of GPRs ... + #define lgu MODE_CHOICE(lwzu, ldu) + #define lg MODE_CHOICE(lwz,ld) +--- src/powerpc/darwin_closure.S.orig 2023-03-15 07:19:45.000000000 -0700 ++++ src/powerpc/darwin_closure.S 2024-02-26 18:37:38.000000000 -0800 +@@ -34,7 +34,7 @@ + #define MODE_CHOICE(x, y) x + #endif + +-#define machine_choice MODE_CHOICE(ppc7400,ppc64) ++#define machine_choice MODE_CHOICE(ppc,ppc64) + + ; Define some pseudo-opcodes for size-independent load & store of GPRs ... + #define lgu MODE_CHOICE(lwzu, ldu) +--- testsuite/lib/libffi.exp.orig 2023-03-15 07:19:45.000000000 -0700 ++++ testsuite/lib/libffi.exp 2024-02-26 18:37:38.000000000 -0800 +@@ -516,7 +516,10 @@ proc run-many-tests { testcases extra_fl + } + } + "gnu" { +- set common "-W -Wall -Wno-psabi" ++ set common "-W -Wall" ++ if ![info exists env(LIBFFI_TEST_OLDGCC)] { ++ set common "$common -Wno-psabi" ++ } + if [info exists env(LIBFFI_TEST_OPTIMIZATION)] { + set optimizations [ list $env(LIBFFI_TEST_OPTIMIZATION) ] + } else { +--- testsuite/libffi.bhaible/bhaible.exp.orig 2023-03-15 07:19:45.000000000 -0700 ++++ testsuite/libffi.bhaible/bhaible.exp 2024-02-26 18:37:38.000000000 -0800 +@@ -24,7 +24,10 @@ global compiler_vendor + # was done in a pretty lazy fashion, and requires the use of compiler + # flags to disable warnings for now. + if { [string match $compiler_vendor "gnu"] } { +- set warning_options "-Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-uninitialized"; ++ set warning_options "-Wno-unused-variable -Wno-unused-parameter -Wno-uninitialized"; ++ if ![info exists env(LIBFFI_TEST_OLDGCC)] { ++ set common "$warning_options -Wno-unused-but-set-variable" ++ } + } + if { [string match $compiler_vendor "microsoft"] } { + # -wd4996 suggest use of vsprintf_s instead of vsprintf diff --git a/devel/libffi/files/powerpc-g3.patch b/devel/libffi/files/powerpc-g3.patch deleted file mode 100644 index f92b852e7f62c..0000000000000 --- a/devel/libffi/files/powerpc-g3.patch +++ /dev/null @@ -1,24 +0,0 @@ -Build for PowerPC G3 not G4 since Tiger still supports G3s. -https://sourceware.org/legacy-ml/libffi-discuss/2015/msg00084.html ---- src/powerpc/darwin.S.orig 2019-10-31 09:49:54.000000000 -0500 -+++ src/powerpc/darwin.S 2021-05-10 13:04:38.000000000 -0500 -@@ -31,7 +31,7 @@ - #define MODE_CHOICE(x, y) x - #endif - --#define machine_choice MODE_CHOICE(ppc7400,ppc64) -+#define machine_choice MODE_CHOICE(ppc,ppc64) - - ; Define some pseudo-opcodes for size-independent load & store of GPRs ... - #define lgu MODE_CHOICE(lwzu, ldu) ---- src/powerpc/darwin_closure.S.orig 2019-10-31 09:49:54.000000000 -0500 -+++ src/powerpc/darwin_closure.S 2021-05-10 13:04:34.000000000 -0500 -@@ -34,7 +34,7 @@ - #define MODE_CHOICE(x, y) x - #endif - --#define machine_choice MODE_CHOICE(ppc7400,ppc64) -+#define machine_choice MODE_CHOICE(ppc,ppc64) - - ; Define some pseudo-opcodes for size-independent load & store of GPRs ... - #define lgu MODE_CHOICE(lwzu, ldu)