Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Cross-compiling on MacOS x86_64 for MacOS arm64 fails  #944

@maxirmx

Description

@maxirmx

I am developing a script to cross compile a complex Ruby project on GHA MacOS x86_64 runner for MacOS arm64

When it comes to ffi gem (1.15.5) configuration is determined correctly

## ----------- ##
## Core tests. ##
## ----------- ##

configure:2704: checking build system type
configure:2718: result: x86_64-apple-darwin21.3.0
configure:2738: checking host system type
configure:2751: result: aarch64-apple-darwin
configure:2771: checking target system type
configure:2784: result: aarch64-apple-darwin
...

However it is only partially applied:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c
/Users/maxirmx/Projects/tebako/output/source_filesystem/bin/ruby -I /Users/maxirmx/Projects/tebako/deps/host/lib/ruby/2.7.0 -r ./siteconf20220311-60390-r2a1r7.rb extconf.rb --disable-system-libffi
checking for whether -Wl,--exclude-libs,ALL is accepted as LDFLAGS... no
checking for whether -pthread is accepted as LDFLAGS... yes
creating extconf.h
creating Makefile

current directory: /Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c
make "DESTDIR=" clean

current directory: /Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c
make "DESTDIR="
Configuring libffi
/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/configure: line 18692: readelf: command not found
clang: error: unsupported option '-print-multi-os-directory'
clang: error: no input files
Making all in include
Making all in testsuite
Making all in man
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi -I. -I/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/include -Iinclude
-I/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/src -Wall -fexceptions -c /Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/src/aarch64/ffi.c  -fno-common -DPIC -o
src/aarch64/.libs/ffi.o
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi -I. -I/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/include -Iinclude
-I/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/src -I. -I/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/include -Iinclude
-I/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/src -c /Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/src/aarch64/sysv.S  -fno-common -DPIC -o
src/aarch64/.libs/sysv.o
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi -I. -I/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/include -Iinclude
-I/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/src -Wall -fexceptions -c /Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/src/types.c  -fno-common -DPIC -o
src/.libs/types.o
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi -I. -I/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/include -Iinclude
-I/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/src -Wall -fexceptions -c /Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/src/java_raw_api.c  -fno-common -DPIC -o
src/.libs/java_raw_api.o
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi -I. -I/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/include -Iinclude
-I/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/src -Wall -fexceptions -c /Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/src/prep_cif.c  -fno-common -DPIC -o
src/.libs/prep_cif.o
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi -I. -I/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/include -Iinclude
-I/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/src -Wall -fexceptions -c /Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/src/raw_api.c  -fno-common -DPIC -o
src/.libs/raw_api.o
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi -I. -I/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/include -Iinclude
-I/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/src -Wall -fexceptions -c /Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/src/closures.c  -fno-common -DPIC -o
src/.libs/closures.o
/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/src/java_raw_api.c:328:46: warning: 'ffi_java_raw_size' is deprecated [-Wdeprecated-declarations]
  ffi_java_raw *raw = (ffi_java_raw*)alloca (ffi_java_raw_size (cif));
                                             ^
include/ffi.h:299:56: note: 'ffi_java_raw_size' has been explicitly marked deprecated here
size_t ffi_java_raw_size (ffi_cif *cif) __attribute__((deprecated));
                                                       ^
/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/src/java_raw_api.c:331:3: warning: 'ffi_java_ptrarray_to_raw' is deprecated [-Wdeprecated-declarations]
  ffi_java_ptrarray_to_raw (cif, avalue, raw);
  ^
include/ffi.h:295:93: note: 'ffi_java_ptrarray_to_raw' has been explicitly marked deprecated here
void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw) __attribute__((deprecated));
                                                                                            ^
2 warnings generated.
libtool: link: ar cru .libs/libffi_convenience.a 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/aarch64/.libs/ffi.o src/aarch64/.libs/sysv.o 
libtool: link: gcc -dynamiclib  -o .libs/libffi.8.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/aarch64/.libs/ffi.o src/aarch64/.libs/sysv.o      -install_name  /usr/local/lib/libffi.8.dylib -compatibility_version 10
-current_version 10.0 -Wl,-single_module
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: .libs/libffi_convenience.a(ffi.o) has no symbols
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: .libs/libffi_convenience.a(sysv.o) has no symbols
libtool: link: ranlib .libs/libffi_convenience.a
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: .libs/libffi_convenience.a(ffi.o) has no symbols
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: .libs/libffi_convenience.a(sysv.o) has no symbols
libtool: link: ( cd ".libs" && rm -f "libffi_convenience.la" && ln -s "../libffi_convenience.la" "libffi_convenience.la" )
Undefined symbols for architecture x86_64:
  "_ffi_call", referenced from:
      _ffi_raw_call in raw_api.o
      _ffi_java_raw_call in java_raw_api.o
  "_ffi_closure_trampoline_table_page", referenced from:
      _ffi_trampoline_table_alloc in closures.o
  "_ffi_prep_cif_machdep", referenced from:
      _ffi_prep_cif_core in prep_cif.o
  "_ffi_prep_cif_machdep_var", referenced from:
      _ffi_prep_cif_core in prep_cif.o
  "_ffi_prep_closure_loc", referenced from:
      _ffi_prep_closure in prep_cif.o
      _ffi_prep_raw_closure_loc in raw_api.o
      _ffi_prep_java_raw_closure_loc in java_raw_api.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[7]: *** [libffi.la] Error 1
make[6]: *** [all-recursive] Error 1
make[5]: *** [all] Error 2
make[4]: *** ["/Users/maxirmx/Projects/tebako/output/source_filesystem/lib/ruby/gems/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi-arm64-darwin"/.libs/libffi_convenience.a] Error 2

You can see that -arch arm64 flag is applied against some source files and is not honored against others.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions