sfence / luajit_app

Test MacOS app using LuaJIT.
0 stars 0 forks source link

iOS simulator compilation #1

Open alexdoloz opened 1 month ago

alexdoloz commented 1 month ago

Hello! Sorry for creating issue mostly unrelated to your repo but this it the only way I found to write to you. Did you ever manage to compile LuaJIT for iOS Simulator on Apple Silicon?

sfence commented 3 days ago

This looks to work for me.

arch=iPhoneSimulator
osver=18.1

target_sysroot="/Applications/Xcode.app/Contents/Developer/Platforms/${arch}.platform/Developer/SDKs/${arch}${osver}.sdk"
host_sysroot="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"

HOST_CC="clang -isysroot $host_sysroot"

export CPPFLAGS="-arch arm64"
export CC="$(xcrun --sdk iphonesimulator --find clang) -isysroot $target_sysroot"
export CXX="$(xcrun --sdk iphonesimulator --find clang++) -isysroot $target_sysroot"
export LDFLAGS="-arch arm64"

# luajit
  cd LuaJIT-*
  echo "Building LuaJIT..."
  target_jit_flags="-arch arm64 -isysroot $target_sysroot -DLUAJIT_DISABLE_JIT"
  host_jit_flags="-arch arm64 -isysroot $host_sysroot -DLUAJIT_DISABLE_JIT"
  make -j$(sysctl -n hw.logicalcpu) "PREFIX=$dir/install" \
        "CC=$CC" \
        "HOST_CC=$HOST_CC" \
        "CFLAGS=$target_jit_flags" "HOST_CFLAGS=$host_jit_flags" \
        "TARGET_CFLAGS=$target_jit_flags" TARGET_SYS=iOS\
        2>&1 | tee log_build.txt
  make install \
        "CFLAGS=$jit_flags" "HOST_CFLAGS=$jit_flags" \
        "TARGET_CFLAGS=$jit_flags" TARGET_SYS=iOS\
        "PREFIX=$dir/install" 2>&1 | tee log_install.txt
  check_ios_file "$dir/install/lib/libluajit-5.1.a"
  cd $dir