Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#61153 closed defect (fixed)

libffi @3.3_1: error: expected ‘)’ before ‘*’ token

Reported by: TzunamiOSX Owned by: kencu (Ken)
Priority: Normal Milestone:
Component: ports Version: 2.6.3
Keywords: powerpc Cc: ballapete (Peter "Pete" Dyballa)
Port: libffi

Description (last modified by ryandesign (Ryan Carsten Schmidt))

Want to update ffmpeg and get an error on libffi

ffi_darwin.lo -MD -MP -MF src/powerpc/.deps/ffi_darwin.Tpo -c ../src/powerpc/ffi_darwin.c  -fno-common -DPIC -o src/powerpc/.libs/ffi_darwin.o
:info:build ../src/powerpc/ffi_darwin.c:1114: error: expected ‘)’ before ‘*’ token
:info:build ../src/powerpc/ffi_darwin.c:1172: error: expected ‘)’ before ‘*’ token
:info:build ../src/powerpc/ffi_darwin.c:1434: error: expected ‘)’ before ‘*’ token
:info:build make[3]: *** [src/powerpc/ffi_darwin.lo] Error 1
:info:build make[3]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libffi/libffi/work/libffi-3.3/powerpc-apple-darwin9.8.0'
:info:build make[2]: *** [all-recursive] Error 1
:info:build make[2]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libffi/libffi/work/libffi-3.3/powerpc-apple-darwin9.8.0'
:info:build make[1]: *** [all] Error 2
:info:build make[1]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libffi/libffi/work/libffi-3.3/powerpc-apple-darwin9.8.0'
:info:build make: *** [all] Error 2
:info:build make: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libffi/libffi/work/libffi-3.3'
:info:build Command failed:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libffi/libffi/work/libffi-3.3" && /usr/bin/make -w all 
:info:build Exit code: 2
:error:build Failed to build libffi: command execution failed
:debug:build Error code: CHILDSTATUS 19223 2
:debug:build Backtrace: command execution failed
:debug:build     while executing
:debug:build "system {*}$notty {*}$nice $fullcmdstring"
:debug:build     invoked from within
:debug:build "command_exec build"
:debug:build     (procedure "portbuild::build_main" line 8)
:debug:build     invoked from within
:debug:build "$procedure $targetname"
:error:build See /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libffi/libffi/main.log for details.

Attachments (2)

main libffi.log (31.7 KB) - added by TzunamiOSX 4 years ago.
mainlog
FFI_GO_CLOSURES.patch (481 bytes) - added by ballapete (Peter "Pete" Dyballa) 4 years ago.
Patch file to add POWER and POWER64

Download all attachments as: .zip

Change History (32)

Changed 4 years ago by TzunamiOSX

Attachment: main libffi.log added

mainlog

comment:1 Changed 4 years ago by TzunamiOSX

Description: modified (diff)

comment:2 Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: (nobody) removed
Description: modified (diff)
Port: libffi added; libffi-3.3_1 removed
Summary: libffi-3.3_1.darwin_9.ppc error on "upgrade outdated"libffi @3.3_1: error: expected ‘)’ before ‘*’ token

comment:3 Changed 4 years ago by kencu (Ken)

that error usually means you need a newer compiler to build it...try gcc7.

hopefully we can tweak it to build with gcc-4.2 as bootstrapping is more complicated otherwise.

comment:4 in reply to:  3 Changed 4 years ago by TzunamiOSX

Replying to kencu:

that error usually means you need a newer compiler to build it...try gcc7.

hopefully we can tweak it to build with gcc-4.2 as bootstrapping is more complicated otherwise.

ok, i will try

see you in 3 days :P

Thx :)

Last edited 4 years ago by TzunamiOSX (previous) (diff)

comment:5 in reply to:  3 Changed 4 years ago by TzunamiOSX

Replying to kencu:

that error usually means you need a newer compiler to build it...try gcc7.

hopefully we can tweak it to build with gcc-4.2 as bootstrapping is more complicated otherwise.

Cant install gcc7 because gcc7 wants libffi to install

Last edited 4 years ago by TzunamiOSX (previous) (diff)

comment:6 Changed 4 years ago by kencu (Ken)

yep, that's the bootstrapping issue I was talking about.

turns out gcc7 doesn't fix it either, but at least it has better error messages to get us closer to the real issue:

libtool: compile:  /opt/local/bin/gcc-mp-7 -DHAVE_CONFIG_H -I. -I.. -I. -I../include -Iinclude -I../src -I/opt/local/include -pipe -Os -arch ppc -Wall -fexceptions -MT src/powerpc/ffi_darwin.lo -MD -MP -MF src/powerpc/.deps/ffi_darwin.Tpo -c ../src/powerpc/ffi_darwin.c  -fno-common -DPIC -o src/powerpc/.libs/ffi_darwin.o
../src/powerpc/ffi_darwin.c:1114:22: error: unknown type name 'ffi_go_closure'; did you mean 'ffi_raw_closure'?
 ffi_prep_go_closure (ffi_go_closure* closure,
                      ^~~~~~~~~~~~~~
                      ffi_raw_closure
../src/powerpc/ffi_darwin.c:1172:31: error: unknown type name 'ffi_go_closure'; did you mean 'ffi_raw_closure'?
 ffi_go_closure_helper_DARWIN (ffi_go_closure*, void *,
                               ^~~~~~~~~~~~~~
                               ffi_raw_closure
../src/powerpc/ffi_darwin.c:1434:31: error: unknown type name 'ffi_go_closure'; did you mean 'ffi_raw_closure'?
 ffi_go_closure_helper_DARWIN (ffi_go_closure *closure, void *rvalue,
                               ^~~~~~~~~~~~~~
                               ffi_raw_closure

comment:7 Changed 4 years ago by kencu (Ken)

I thought perhaps deactivating the previous libffi might fix this, but no go.

So we need to figure out why ffi_go_closure is undefined, or otherwise fix that section of the file.

If this is relating somehow to the go port, then that doesn't build on PowerPC anyway...

comment:8 Changed 4 years ago by mf2k (Frank Schima)

Keywords: leopard, powerpcleopard powerpc

comment:9 Changed 4 years ago by kencu (Ken)

This commit <https://github.com/libffi/libffi/commit/fa1040c111b3e423bc9c7e78d9af89470c0fa2fb#diff-8812a240988e12730090db5e550af6d2> is what we have to turn off somehow.

I can see us holding back libffi on PowerPC for a while to sort this out.

comment:10 in reply to:  7 ; Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to kencu:

So we need to figure out why ffi_go_closure is undefined, or otherwise fix that section of the file.

ffi_go_closure should be defined in include/ffi.h.in, provided FFI_GO_CLOSURES is defined and truthy. FFI_GO_CLOSURES should be defined to 1 in src/powerpc/ffitarget.h, provided that POWERPC or POWERPC_FREEBSD are defined. I don't know where POWERPC or POWERPC_FREEBSD would get defined.

comment:11 Changed 4 years ago by kencu (Ken)

Sadly not so easy -- I set it to "0" in the header, but there were yet more errors. Have to really fix it, unfortunately :>

That commit I referenced indicates there was a lot of work done there, and I doubt anyone has ever tried to build it with darwin 32bit PPC before now...

comment:12 Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

Cc: ballapete added

comment:13 Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

The same error happens on PPC Tiger, Mac OS X 10.4.11.

comment:14 Changed 4 years ago by TzunamiOSX

I have installed gcc7 around 7 days ago without problems, but now there is the problem with libffi.

Im not sure this was needed for ffmpeg or gcc7 before.

comment:15 in reply to:  11 ; Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to kencu:

Sadly not so easy -- I set it to "0" in the header, but there were yet more errors. Have to really fix it, unfortunately :>

You set what to "0"? I was suggesting that maybe POWERPC or POWERPC_FREEBSD needed to be defined.

comment:16 in reply to:  14 Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to TzunamiOSX:

Im not sure this was needed for ffmpeg or gcc7 before.

Right, this problem is new in libffi 3.3.

comment:17 Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

The error is in libffi-3.3/powerpc-apple-darwin8.11.0/include/ffi.h. This C header file has a perfect type declaration:

  436	#if FFI_GO_CLOSURES
  437	
  438	typedef struct {
  439	  void      *tramp;
  440	  ffi_cif   *cif;
  441	  void     (*fun)(ffi_cif*,void*,void**,void*);
  442	} ffi_go_closure;
  443	
  444	FFI_API ffi_status ffi_prep_go_closure (ffi_go_closure*, ffi_cif *,
  445					void (*fun)(ffi_cif*,void*,void**,void*));
  446	
  447	FFI_API void ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue,
  448			  void **avalue, void *closure);
  449	
  450	#endif /* FFI_GO_CLOSURES */
  451	
  452	/* ---- Public interface definition -------------------------------------- */

It's just necessary to define FFI_GO_CLOSURES, I think…

comment:18 in reply to:  10 ; Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

Replying to ryandesign:

Replying to kencu:

So we need to figure out why ffi_go_closure is undefined, or otherwise fix that section of the file.

GCC always defines __POWERPC__ and similiar values, starting with two underscores and finishing with two underscores. So we should try to add || defined (__POWERPC__) || defined (__POWERPC64__) to the line # 145:

#if defined (POWERPC) || defined (POWERPC_FREEBSD)
Last edited 4 years ago by ballapete (Peter "Pete" Dyballa) (previous) (diff)

comment:19 in reply to:  18 Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

Replying to ballapete:

Replying to ryandesign:

Replying to kencu:

Last line of the configure script is:

cp ${srcdir}/src/$TARGETDIR/ffitarget.h include/ffitarget.h

The value of ${srcdir}/src/$TARGETDIR/ffitarget.h is ${worksrcpath}/src/powerpc. Here exists:

  -rw-r--r--  1 macports admin  6294 18. Nov 2019  ffitarget.h

So this file needs to be patched.

Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

Attachment: FFI_GO_CLOSURES.patch added

Patch file to add POWER and POWER64

comment:20 Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

New error:

libtool: link: ranlib .libs/libffi_convenience.a
libtool: link: ( cd ".libs" && rm -f "libffi_convenience.la" && ln -s "../libffi_convenience.la" "libffi_convenience.la" )
/bin/sh ./libtool  --tag=CC   --mode=link /opt/local/bin/gcc-apple-4.2  -pipe -Os -arch ppc -Wall -fexceptions -no-undefined -version-info `grep -v '^#' ../libtool-version`   '-L/opt/local/lib' '-Wl,-headerpad_max_install_names' '-arch' 'ppc'  -L/opt/local/lib -Wl,-headerpad_max_install_names -arch ppc -o libffi.la -rpath /opt/local/lib src/prep_cif.lo src/types.lo src/raw_api.lo src/java_raw_api.lo src/closures.lo  src/powerpc/ffi_darwin.lo src/powerpc/darwin.lo src/powerpc/darwin_closure.lo 
libtool: link: /opt/local/bin/gcc-apple-4.2 -dynamiclib  -o .libs/libffi.7.dylib  src/.libs/prep_cif.o src/.libs/types.o src/.libs/raw_api.o src/.libs/java_raw_api.o src/.libs/closures.o src/powerpc/.libs/ffi_darwin.o src/powerpc/.libs/darwin.o src/powerpc/.libs/darwin_closure.o   -L/opt/local/lib  -Os -arch ppc -Wl,-headerpad_max_install_names -arch ppc -Wl,-headerpad_max_install_names -arch ppc   -install_name  /opt/local/lib/libffi.7.dylib -compatibility_version 9 -current_version 9.0 -Wl,-single_module
Undefined symbols:
  "_ffi_go_closure_ASM", referenced from:
      _ffi_go_closure_ASM$non_lazy_ptr in ffi_darwin.o
     (maybe you meant: _ffi_go_closure_ASM$non_lazy_ptr)
  "_ffi_call_go_AIX", referenced from:
      _ffi_call_go in ffi_darwin.o
  "_ffi_prep_cif_machdep_var", referenced from:
      _ffi_prep_cif_core in prep_cif.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[3]: *** [libffi.la] Error 1
make[3]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_nue.de.rsync.macports.org_macports_release_tarballs_ports_devel_libffi/libffi/work/libffi-3.3/powerpc-apple-darwin8.11.0'

comment:21 in reply to:  15 Changed 4 years ago by kencu (Ken)

Replying to ryandesign:

Replying to kencu:

Sadly not so easy -- I set it to "0" in the header, but there were yet more errors. Have to really fix it, unfortunately :>

You set what to "0"? I was suggesting that maybe POWERPC or POWERPC_FREEBSD needed to be defined.

# define FFI_GO_CLOSURES 1

to

# define FFI_GO_CLOSURES 0

comment:22 Changed 4 years ago by kencu (Ken)

For now, I have pegged libffi at 3.2.1 in my Tiger & Leopard PowerPC overlay repos.

comment:23 Changed 4 years ago by kencu (Ken)

You can try this <https://github.com/macports/macports-ports/pull/8379> which builds for me on 10.5.8 PowerPC and passes most of the tests.

For now I'm still pegging libffi at 3.2.1, but at least this PR gives us a starting point, perhaps, and does build through.

comment:24 Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

(Before testing Guile) Tiger is upgrading its software, Clang and llvm with old libffi, and port has decided to first upgrade some other ports (imlib2, python27, re2c, rsync, xterm)…

comment:26 Changed 4 years ago by kencu (Ken)

Keywords: leopard removed

comment:27 Changed 4 years ago by kencu (Ken)

Owner: set to kencu
Resolution: fixed
Status: newclosed

In 5287b4e585c1277c33540e78cc8c8ef626dd776e/macports-ports (master):

libffi: fix darwin powerpc build

disable go bindings as they are not supported
on darwin powerpc at present

enable tests

closes: #61153

comment:28 Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

libffi @3.3_1 built on PPC Tiger with these test results:

# of unexpected failures	616
# of unresolved testcases	616
# of unsupported tests		30

comment:29 Changed 4 years ago by kencu (Ken)

Yes -- you have to use gcc7 to test it, due to some unsupported warning flags that gcc-4.2 barfs on.

I just haven't bothered to fix the flags for gcc-4.2, as I tested it with gcc7. But if you feel like fixing the warning flags for gcc-4.2, I'll happily PR it.

comment:30 Changed 4 years ago by kencu (Ken)

Here's the PPC test suite for 10.5 Leopard libffi version 3.2.1:

		=== libffi Summary ===

# of expected passes		1851
# of unexpected failures	12

and here it is for version 3.3

		=== libffi Summary ===

# of expected passes		1414
# of unexpected failures	17
# of unsupported tests		30
Note: See TracTickets for help on using tickets.