ocaml-cross / opam-cross-ios

An OCaml cross-toolchain for iOS and several useful libraries
63 stars 15 forks source link

Support for Apple Silicon #17

Closed nickmain closed 5 months ago

nickmain commented 10 months ago

I am attempting to follow the instructions in the readme and get the following errors for opam install ocaml-ios re-ios:

  * Missing dependency:
    - ocaml-ios → ocaml-ios64 >= 5.0.0
    unmet availability conditions: 'arch = "x86_64"'

I deviated from the instructions when installing conf-ios by using ARCH=arm64 SUBARCH=arm64 PLATFORM=iPhoneSimulator since the iOS simulator on Apple Silicon is now Arm, not Intel. I assume this is the cause of the errors.

Please take this into account when updating this package.

dboris commented 5 months ago

I added support for Apple Silicon. You can give it a try.

nickmain commented 5 months ago

Using

ARCH=arm64 SUBARCH=arm64 PLATFORM=iPhoneSimulator SDK=$(xcrun --sdk iphonesimulator --show-sdk-version) VER=12.0 \
  opam install conf-ios

I get the following installing ocaml-ios. Is there something else that assumes iOS rather than simulator when given arm64?

[ERROR] The compilation of ocaml-ios64.5.0.0 failed at "/bin/sh ./build.sh arm64-apple-darwin".

#=== ERROR while compiling ocaml-ios64.5.0.0 ==================================#
# context     2.1.5 | macos/arm64 | ocaml-base-compiler.5.0.0 | git+ssh://git@github.com/ocaml-cross/opam-cross-ios
# path        ~/.opam/ios-cross/.opam-switch/build/ocaml-ios64.5.0.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build /bin/sh ./build.sh arm64-apple-darwin
# exit-code   2
# env-file    ~/.opam/log/ocaml-ios64-87753-6f85fd.env
# output-file ~/.opam/log/ocaml-ios64-87753-6f85fd.out
### output ###
# [...]
# gcc -c -O2 -fno-strict-aliasing -fwrapv -pthread -g -Wall -fno-common -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk -miphoneos-version-min=12.0  -I./runtime -D_FILE_OFFSET_BITS=64  \
#     -o yacc/symtab.o yacc/symtab.c
# gcc -c -O2 -fno-strict-aliasing -fwrapv -pthread -g -Wall -fno-common -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk -miphoneos-version-min=12.0  -I./runtime -D_FILE_OFFSET_BITS=64  \
#     -o yacc/verbose.o yacc/verbose.c
# gcc -c -O2 -fno-strict-aliasing -fwrapv -pthread -g -Wall -fno-common -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk -miphoneos-version-min=12.0  -I./runtime -D_FILE_OFFSET_BITS=64  \
#     -o yacc/warshall.o yacc/warshall.c
# gcc -O2 -fno-strict-aliasing -fwrapv -pthread -g -Wall -fno-common -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk -miphoneos-version-min=12.0  -Wl,-no_compact_unwind -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk -fra[...]
# ld: building for 'iOS', but linking in dylib (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/Security.framework/Security.tbd) built for 'iOS-simulator'
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
# make[2]: *** [yacc/ocamlyacc] Error 1
# make[1]: *** [coreall] Error 2
# make: *** [world] Error 2
dboris commented 5 months ago

I pushed an update. You can try again:

opam update ios
opam install conf-simulator-ios
opam remove conf-ios
ARCH=arm64 SUBARCH=arm64 PLATFORM=iPhoneSimulator SDK=$(xcrun --sdk iphonesimulator --show-sdk-version) VER=12.0 \
  opam install conf-ios
nickmain commented 5 months ago

Thank you - that works now!

dboris commented 5 months ago

Great.