ocaml-cross / opam-cross-ios

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

Xcode 9 "prohibits" use of system() on IOS #9

Closed markghayden closed 5 months ago

markghayden commented 7 years ago

See output below for build with ios32.

The definition in stdlib.h for system is as follows:

swift_unavailable_on("Use posix_spawn APIs or NSTask instead.", "Process spawning is unavailable") __API_AVAILABLE(macos(10.0)) IOS_PROHIBITED WATCHOS_PROHIBITED __TVOS_PROHIBITED int system(const char *) DARWIN_ALIAS_C(system);

clang -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.0.sdk -miphoneos-version-min=9.0 -O2 -DCAML_NAME_SPACE -Wall -c -o sys.o sys.c

stderr

[...]

./caml/misc.h:142:34: note: expanded from macro 'CAML_SYS_SYSTEM'

define CAML_SYS_SYSTEM(command) system(command)

^

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.0.sdk/usr/include/stdlib.h:195:6: note: 'system' has been explicitly marked unavailable here

int system(const char *) __DARWIN_ALIAS_C(system);

^

1 error generated.

make[2]: *** [sys.o] Error 1

make[1]: *** [coldstart] Error 2

make: *** [world] Error 2

pvaibhav commented 6 years ago

Same issue here. Any solution yet?

whitequark commented 6 years ago

Soon!

pvaibhav commented 6 years ago

Here's my quick-fix change to byterun/caml/misc.h (didn't try asmrun):

#if __APPLE__
  #include "TargetConditionals.h"
  #if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
    // system() is not supported on iOS
    #define CAML_SYS_SYSTEM(command) (-1)
  #else
    // macOS is OK
    #define CAML_SYS_SYSTEM(command) system_os(command)
  #endif
#else // Other operating systems (Android?)
  #define CAML_SYS_SYSTEM(command) system_os(command)
#endif
whitequark commented 6 years ago

asmrun/caml/misc.h is the same as byterun/caml/misc.h, it is copied (IIRC).

stevenproctor commented 6 years ago

I was going to try using pasmomusic/reason-react by @wokalski, and his instructions refer to set this up to get reason-react going, but I am having the same issue.

Due to my environment, I set the SDK and VER to what is on my machine, instead of what you have in the README.md, as I don't have SDK of 9.2 on my system, and I have XCode 9.2.

The settings I used can be seen below:

ARCH=amd64 SUBARCH=x86_64 PLATFORM=iPhoneSimulator SDK=11.2 VER=9.2 opam install conf-ios

which breaks with the error note: 'system' has been explicitly marked unavailable:

### stderr ###
# [...]
# ./caml/misc.h:142:34: note: expanded from macro 'CAML_SYS_SYSTEM'
# #define CAML_SYS_SYSTEM(command) system(command)
#                                  ^
# /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.2.sdk/usr/include/stdlib.h:195:6: note: 'system' has been explicitly marked unavailable here
# int      system(const char *) __DARWIN_ALIAS_C(system);
#          ^
# 1 error generated.
# make[2]: *** [sys.o] Error 1
# make[1]: *** [coldstart] Error 2
# make: *** [world] Error 2
stevenproctor commented 6 years ago

These projects sound really interesting, so I am looking forward to playing with them some. 😄

wokalski commented 6 years ago

Currently my workaround is sourcing and pinning ocaml-ios locally (i.e. using opam source ocaml-ios). And then I tweak the macros referring to system.

pvaibhav commented 6 years ago

I've gone with bytecode meanwhile. The bytecode runtime works everywhere!

dboris commented 5 months ago

Closing as no longer relevant.