public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
* Cross compiling for iOS
@ 2024-02-01  7:04 saleem gagguturu
  2024-02-03  2:11 ` Russell Keith-Magee
  0 siblings, 1 reply; 5+ messages in thread
From: saleem gagguturu @ 2024-02-01  7:04 UTC (permalink / raw)
  To: libffi-discuss

[-- Attachment #1: Type: text/plain, Size: 1432 bytes --]

Hi,

I'm trying to cross-compile libffi for iOS from Debian. I managed to cross-compile it successfully for MacOS (arm64 and x86) using OSX Cross but I'm getting some errors for iOS.

My configure command is:

./configure --host=arm-apple-darwin11 --prefix=$IOS_TOOLCHAIN_ROOT --libdir=$IOS_TOOLCHAIN_ROOT/lib --disable-docs

This is the error I'm getting:


libtool: link: ( cd ".libs" && rm -f "libffi_convenience.la" && ln -s "../libffi_convenience.la" "libffi_convenience.la" )
Undefined symbols for architecture arm64:
  "_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_closure_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_raw_closure in raw_api.o
      _ffi_prep_java_raw_closure_loc in java_raw_api.o
      _ffi_prep_java_raw_closure in java_raw_api.o
ld: symbol(s) not found for architecture arm64

I've raised an issue with full logs here https://github.com/libffi/libffi/issues/821

Anyone know any workaround for this? I need libffi as it's a dependency to Glib.

Thanks


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Cross compiling for iOS
  2024-02-01  7:04 Cross compiling for iOS saleem gagguturu
@ 2024-02-03  2:11 ` Russell Keith-Magee
  2024-05-27 15:14   ` saleem gagguturu
  0 siblings, 1 reply; 5+ messages in thread
From: Russell Keith-Magee @ 2024-02-03  2:11 UTC (permalink / raw)
  To: saleem gagguturu, libffi-discuss

[-- Attachment #1: Type: text/plain, Size: 2909 bytes --]

I can’t speak to any of the eccentricities introduced by using OSX Cross, but the build process for iOS isn’t quite the same as it is for the platforms - it requires some pre- and post- processing. You don't just invoke ./configure from the command line as you would for a “normal” autoconf project.

There’s a `generate_darwin_source_and_headers.py` script in the root of the libffi code checkout; when you execute that, it generates `build_` folders for each architecture, and runs configure for you. 

You can see these tools in action in the repo I maintain for libFFI support on iOS/tvOS/watchOS; here’s the invocation of the helper script:
https://github.com/beeware/cpython-apple-source-deps/blob/main/Makefile#L474

And the build itself:
https://github.com/beeware/cpython-apple-source-deps/blob/main/Makefile#L339 

Each pass will give you a binary for a *single* ABI and architecture; Depending on your intended usage, you may need to combine them into  “fat” binaries for each ABI; depending on how you’re using the library, you may also need to combine the multiple ABI fat binaries into a single XCframework.

Or - the releases page for the repo I just linked has pre-built (single ABI and architecture) binaries.

https://github.com/beeware/cpython-apple-source-deps/releases/tag/libFFI-3.4.4-1

Hope that helps,
Russ Magee %-)

On 1 February 2024 at 3:04:54 pm, saleem gagguturu via Libffi-discuss (libffi-discuss@sourceware.org) wrote:

Hi,  

I'm trying to cross-compile libffi for iOS from Debian. I managed to cross-compile it successfully for MacOS (arm64 and x86) using OSX Cross but I'm getting some errors for iOS.  

My configure command is:  

./configure --host=arm-apple-darwin11 --prefix=$IOS_TOOLCHAIN_ROOT --libdir=$IOS_TOOLCHAIN_ROOT/lib --disable-docs  

This is the error I'm getting:  


libtool: link: ( cd ".libs" && rm -f "libffi_convenience.la" && ln -s "../libffi_convenience.la" "libffi_convenience.la" )  
Undefined symbols for architecture arm64:  
"_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_closure_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_raw_closure in raw_api.o  
_ffi_prep_java_raw_closure_loc in java_raw_api.o  
_ffi_prep_java_raw_closure in java_raw_api.o  
ld: symbol(s) not found for architecture arm64  

I've raised an issue with full logs here https://github.com/libffi/libffi/issues/821  

Anyone know any workaround for this? I need libffi as it's a dependency to Glib.  

Thanks  


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Cross compiling for iOS
  2024-02-03  2:11 ` Russell Keith-Magee
@ 2024-05-27 15:14   ` saleem gagguturu
  2024-05-28  3:47     ` Russell Keith-Magee
  2024-05-28  6:18     ` Jeffrey Walton
  0 siblings, 2 replies; 5+ messages in thread
From: saleem gagguturu @ 2024-05-27 15:14 UTC (permalink / raw)
  To: Russell Keith-Magee, libffi-discuss

[-- Attachment #1: Type: text/plain, Size: 3740 bytes --]

Hi Russell,
I just upgraded to the latest version of libffi 3.4.6.
I'm no longer able to compile the library as a shared library for ios.
In the configure logs, I'm getting this:

checking whether the xcrun -sdk iphoneos clang -target arm64-apple-ios linker (xcrun -sdk iphoneos ld -target arm64-apple-ios) supports shared libraries... no

The same log line shows "supports shared libraries... yes" in version 3.4.4.

Are you able to kindly check if you can build the 3.4.6 libraries and if so, upload them to your repo when you get the chance?

Thank very much in advance.
________________________________
From: Russell Keith-Magee <russell@keith-magee.com>
Sent: Saturday, 3 February 2024 1:11 PM
To: saleem gagguturu <saleemgagguturu@live.com>; libffi-discuss@sourceware.org <libffi-discuss@sourceware.org>
Subject: Re: Cross compiling for iOS

I can’t speak to any of the eccentricities introduced by using OSX Cross, but the build process for iOS isn’t quite the same as it is for the platforms - it requires some pre- and post- processing. You don't just invoke ./configure from the command line as you would for a “normal” autoconf project.

There’s a `generate_darwin_source_and_headers.py` script in the root of the libffi code checkout; when you execute that, it generates `build_` folders for each architecture, and runs configure for you.

You can see these tools in action in the repo I maintain for libFFI support on iOS/tvOS/watchOS; here’s the invocation of the helper script:
https://github.com/beeware/cpython-apple-source-deps/blob/main/Makefile#L474

And the build itself:
https://github.com/beeware/cpython-apple-source-deps/blob/main/Makefile#L339

Each pass will give you a binary for a *single* ABI and architecture; Depending on your intended usage, you may need to combine them into  “fat” binaries for each ABI; depending on how you’re using the library, you may also need to combine the multiple ABI fat binaries into a single XCframework.

Or - the releases page for the repo I just linked has pre-built (single ABI and architecture) binaries.

https://github.com/beeware/cpython-apple-source-deps/releases/tag/libFFI-3.4.4-1

Hope that helps,
Russ Magee %-)


On 1 February 2024 at 3:04:54 pm, saleem gagguturu via Libffi-discuss (libffi-discuss@sourceware.org<mailto:libffi-discuss@sourceware.org>) wrote:

Hi,

I'm trying to cross-compile libffi for iOS from Debian. I managed to cross-compile it successfully for MacOS (arm64 and x86) using OSX Cross but I'm getting some errors for iOS.

My configure command is:

./configure --host=arm-apple-darwin11 --prefix=$IOS_TOOLCHAIN_ROOT --libdir=$IOS_TOOLCHAIN_ROOT/lib --disable-docs

This is the error I'm getting:


libtool: link: ( cd ".libs" && rm -f "libffi_convenience.la" && ln -s "../libffi_convenience.la" "libffi_convenience.la" )
Undefined symbols for architecture arm64:
"_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_closure_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_raw_closure in raw_api.o
_ffi_prep_java_raw_closure_loc in java_raw_api.o
_ffi_prep_java_raw_closure in java_raw_api.o
ld: symbol(s) not found for architecture arm64

I've raised an issue with full logs here https://github.com/libffi/libffi/issues/821

Anyone know any workaround for this? I need libffi as it's a dependency to Glib.

Thanks


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Cross compiling for iOS
  2024-05-27 15:14   ` saleem gagguturu
@ 2024-05-28  3:47     ` Russell Keith-Magee
  2024-05-28  6:18     ` Jeffrey Walton
  1 sibling, 0 replies; 5+ messages in thread
From: Russell Keith-Magee @ 2024-05-28  3:47 UTC (permalink / raw)
  To: saleem gagguturu, libffi-discuss

[-- Attachment #1: Type: text/plain, Size: 4521 bytes --]

I’ve just done a quick test, and I didn’t have any difficulties building an iOS package for libFFI 3.4.6 with the tooling contained the cpython-apple-source-deps repository. Update the version number on line 49; comment out the patch application on line 479, and run `make libFFI-iOS` and build artefacts are generated.

Testing and releasing an updated package will require more work, and I don’t have time in my schedule to commit to that right now.

However, I would note that I’ve *never* published a *shared* iOS library - it’s only ever been a static build, because of the unusual requirements that iOS places on shared library distribution.

Yours,
Russ Magee %-)

On 27 May 2024 at 11:14:34 PM, saleem gagguturu (saleemgagguturu@live.com) wrote:

Hi Russell,
I just upgraded to the latest version of libffi 3.4.6.
I'm no longer able to compile the library as a shared library for ios.
In the configure logs, I'm getting this:

checking whether the xcrun -sdk iphoneos clang -target arm64-apple-ios linker (xcrun -sdk iphoneos ld -target arm64-apple-ios) supports shared libraries... no

The same log line shows "supports shared libraries... yes" in version 3.4.4.

Are you able to kindly check if you can build the 3.4.6 libraries and if so, upload them to your repo when you get the chance?

Thank very much in advance.
From: Russell Keith-Magee <russell@keith-magee.com>
Sent: Saturday, 3 February 2024 1:11 PM
To: saleem gagguturu <saleemgagguturu@live.com>; libffi-discuss@sourceware.org <libffi-discuss@sourceware.org>
Subject: Re: Cross compiling for iOS
 
I can’t speak to any of the eccentricities introduced by using OSX Cross, but the build process for iOS isn’t quite the same as it is for the platforms - it requires some pre- and post- processing. You don't just invoke ./configure from the command line as you would for a “normal” autoconf project.

There’s a `generate_darwin_source_and_headers.py` script in the root of the libffi code checkout; when you execute that, it generates `build_` folders for each architecture, and runs configure for you. 

You can see these tools in action in the repo I maintain for libFFI support on iOS/tvOS/watchOS; here’s the invocation of the helper script:
https://github.com/beeware/cpython-apple-source-deps/blob/main/Makefile#L474

And the build itself:
https://github.com/beeware/cpython-apple-source-deps/blob/main/Makefile#L339 

Each pass will give you a binary for a *single* ABI and architecture; Depending on your intended usage, you may need to combine them into  “fat” binaries for each ABI; depending on how you’re using the library, you may also need to combine the multiple ABI fat binaries into a single XCframework.

Or - the releases page for the repo I just linked has pre-built (single ABI and architecture) binaries.

https://github.com/beeware/cpython-apple-source-deps/releases/tag/libFFI-3.4.4-1

Hope that helps,
Russ Magee %-)

On 1 February 2024 at 3:04:54 pm, saleem gagguturu via Libffi-discuss (libffi-discuss@sourceware.org) wrote:

Hi,  

I'm trying to cross-compile libffi for iOS from Debian. I managed to cross-compile it successfully for MacOS (arm64 and x86) using OSX Cross but I'm getting some errors for iOS.  

My configure command is:  

./configure --host=arm-apple-darwin11 --prefix=$IOS_TOOLCHAIN_ROOT --libdir=$IOS_TOOLCHAIN_ROOT/lib --disable-docs  

This is the error I'm getting:  


libtool: link: ( cd ".libs" && rm -f "libffi_convenience.la" && ln -s "../libffi_convenience.la" "libffi_convenience.la" )  
Undefined symbols for architecture arm64:  
"_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_closure_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_raw_closure in raw_api.o  
_ffi_prep_java_raw_closure_loc in java_raw_api.o  
_ffi_prep_java_raw_closure in java_raw_api.o  
ld: symbol(s) not found for architecture arm64  

I've raised an issue with full logs here https://github.com/libffi/libffi/issues/821  

Anyone know any workaround for this? I need libffi as it's a dependency to Glib.  

Thanks  


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Cross compiling for iOS
  2024-05-27 15:14   ` saleem gagguturu
  2024-05-28  3:47     ` Russell Keith-Magee
@ 2024-05-28  6:18     ` Jeffrey Walton
  1 sibling, 0 replies; 5+ messages in thread
From: Jeffrey Walton @ 2024-05-28  6:18 UTC (permalink / raw)
  To: saleem gagguturu; +Cc: Russell Keith-Magee, libffi-discuss

On Mon, May 27, 2024 at 11:14 AM saleem gagguturu via Libffi-discuss
<libffi-discuss@sourceware.org> wrote:
>
> I just upgraded to the latest version of libffi 3.4.6.
> I'm no longer able to compile the library as a shared library for ios.
> In the configure logs, I'm getting this:
>
> checking whether the xcrun -sdk iphoneos clang -target arm64-apple-ios linker (xcrun -sdk iphoneos ld -target arm64-apple-ios) supports shared libraries... no
>
> The same log line shows "supports shared libraries... yes" in version 3.4.4.

Open configure or configure.ac. See what variable is set when
'supports shared libraries' runs. Then set that variable to yes when
you run configure. Something like:

    ./configure ac_cv_shared_library=yes

That should skip the configure check, set the variable the way you
want it, and produce the artifacts you want.

> Are you able to kindly check if you can build the 3.4.6 libraries and if so, upload them to your repo when you get the chance?
>

Jeff

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-05-28  6:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-01  7:04 Cross compiling for iOS saleem gagguturu
2024-02-03  2:11 ` Russell Keith-Magee
2024-05-27 15:14   ` saleem gagguturu
2024-05-28  3:47     ` Russell Keith-Magee
2024-05-28  6:18     ` Jeffrey Walton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).