]> git.feebdaed.xyz Git - 0xmirror/radare2.git/commitdiff
Fix and tune the xcframework sdk ##build
authorOle André Vadla Ravnås <oleavr@frida.re>
Thu, 11 Dec 2025 15:10:57 +0000 (16:10 +0100)
committerGitHub <noreply@github.com>
Thu, 11 Dec 2025 15:10:57 +0000 (16:10 +0100)
24 files changed:
binr/rules.mk
doc/iphone.md
libr/debug/p/debug_evm.c
libr/do-ar-sh [deleted file]
mk/darwin.mk
mk/ios-sdk-clang.mk [new file with mode: 0644]
mk/ios-sdk-gcc.mk [deleted file]
mk/ios-sdk.mk [deleted file]
mk/macos-sdk-clang.mk [new file with mode: 0644]
shlr/Makefile
sys/ios-cydia.sh
sys/ios-env.sh
sys/ios-sdk-clang [new file with mode: 0755]
sys/ios-sdk-gcc [deleted file]
sys/ios-sdk-ld
sys/ios-simulator.sh
sys/ios-static.sh
sys/macos-env.sh [new file with mode: 0755]
sys/macos-sdk-clang [new file with mode: 0755]
sys/macos-sdk-ld [new file with mode: 0755]
sys/sdk-common.sh
sys/sdk-ios.sh
sys/sdk-macos.sh
sys/sdk.sh

index 44b82562245e9635d09e6af454630cc7e718f0ae..4134a46ec362a217e994b7ee9e28f6140b84a51f 100644 (file)
@@ -5,7 +5,7 @@ include ../../shlr/sdb.mk
 
 # despite libs are pic, some systems/compilers dont
 # like relocatable executables, so here we do the magic
-USE_PIE=$(shell echo "$(CC)" | grep -E "emcc|tcc|vinix|wasm" >/dev/null && echo 0 || echo 1)
+USE_PIE=$(shell echo "$(CC)" | grep -E "emcc|ios-sdk|macos-sdk|tcc|vinix|wasm" >/dev/null && echo 0 || echo 1)
 
 ifeq ($(USE_PIE),1)
 CFLAGS+=-pie
index 7609673aa82d8f0e430ead2f6a23d7841d9420da..47e447bb830795bcd6e14710c40026debf891cee 100644 (file)
@@ -2,12 +2,12 @@
 
 ```
 export PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:$PATH
-export CC=`pwd`/sys/ios-sdk-gcc
+export CC=`pwd`/sys/ios-sdk-clang
 # set only for arm64, otherwise it is armv7
 export CPU=arm64
 # select ios sdk version
 export IOSVER=7.1
-./configure --prefix=/usr --with-ostype=darwin --with-compiler=ios-sdk --target=arm-unknown-darwin
+./configure --prefix=/usr --with-ostype=darwin --with-compiler=ios-sdk-clang --target=arm-unknown-darwin
 make -j4
 make install DESTDIR=/tmp/r2ios
 ```
index 3436a841bb9e12d4da2b0bfa189f523b8ec146fd..3807b4c260ccb8b2f13c04e5ac536e5abfb62848 100644 (file)
@@ -259,7 +259,7 @@ RDebugPlugin r_debug_plugin_evm = {
        .frames = &r_debug_evm_frames,
 };
 
-#ifndef CORELIB
+#ifndef R2_PLUGIN_INCORE
 RLibStruct radare_plugin = {
        .type = R_LIB_TYPE_DBG,
        .data = &r_debug_plugin_evm,
diff --git a/libr/do-ar-sh b/libr/do-ar-sh
deleted file mode 100644 (file)
index af90f87..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-#!/bin/sh
-
-LIBS="libr/cons/libr_cons.a libr/util/libr_util.a  libr/bin/libr_bin.a  libr/anal/libr_anal.a libr/bp/libr_bp.a libr/muta/libr_muta.a libr/debug/libr_debug.a subprojects/sdb/src/libsdb.a libr/core/libr_core.a libr/main/libr_main.a libr/fs/libr_fs.a libr/syscall/libr_syscall.a shlr/java/libr_java.a shlr/zip/librz.a libr/socket/libr_socket.a libr/anal/libr_anal.a libr/flag/libr_flag.a libr/search/libr_search.a libr/reg/libr_reg.a libr/config/libr_config.a libr/io/libr_io.a libr/bp/libr_bp.a libr/asm/libr_asm.a libr/bp/libr_bp.a libr/egg/libr_egg.a libr/anal/libr_anal.a libr/magic/libr_magic.a libr/lang/libr_lang.a libr/fs/libr_fs.a shlr/grub/libgrubfs.a shlr/gdb/lib/libgdbr.a"
-
-if [ "${USE_CS4}" = 1 ]; then
-       LIBS="$(LIBS) subprojects/capstone-v4/libcapstone.a"
-elif [ "${USE_CSNEXT}" = 1 ]; then
-       LIBS="$(LIBS) subprojects/capstone-next/libcapstone.a"
-else
-       LIBS="$(LIBS) subprojects/capstone-v5/libcapstone.a"
-fi
-
-if [ "${WANT_V35}" = 1 ]; then
-       LIBS="$(LIBS) subprojects/binaryninja/v35arm64.a subprojects/binaryninja/v35armv7.a"
-fi
-
-cd ..
-
-LIB=libr.a
-TMP=.ar.tmp
-
-IOSVER=1
-if [ -n "${IOSVER}" ]; then
-       RANLIB="xcrun --sdk iphoneos ranlib"
-       AR="xcrun --sdk iphoneos ar"
-else
-       RANLIB=ranlib
-       AR=ar
-fi
-
-rm -rf ${TMP}
-mkdir -p ${TMP}
-for a in ${LIBS} ; do
-       ${RANLIB} $a
-       file "$a" | grep -q universal
-       if [ $? = 0 ]; then
-               ARCHS=`lipo -info $a | cut -d : -f 3-`
-       else
-               ARCHS=""
-       fi
-       if [ -n "${ARCHS}" ]; then
-               for b in ${ARCHS} ; do
-                       mkdir -p "$TMP/$a/$b"
-                       ORIG="$PWD/$a.$b"
-                       lipo -thin $b -output $a.$b $a
-                       echo "cd $TMP/$a/$b : ${AR} -x $ORIG"
-                       ( cd $TMP/$a/$b ; ${AR} -x $ORIG )
-                       rm -f $a.$b
-               done
-       else
-               mkdir -p "${TMP}/${a}"
-               ORIG="$PWD/$a"
-               ( cd $TMP/$a ; ${AR} -x $ORIG )
-               echo $a
-       fi
-done
-
-cd ${TMP}
-OBJS=`find * -iname *.o`
-if [ -z "${OBJS}" ]; then
-       echo
-       echo "Cannot find any object"
-       echo
-       exit 1
-else
-       rm -f "${LIB}"
-       ${AR} -qv "${LIB}" ${OBJS}
-       ${RANLIB} "${LIB}"
-fi
index 6815947ff2366e3d96c4a71cdac46b5b89cc92c5..9ed04e09b1940dee0e5794c7b2f2ec7632d52f09 100644 (file)
@@ -4,21 +4,15 @@ ARCH=$(shell uname -m)
 XCODE_VERSION=$(shell xcodebuild -version|grep Xcode|grep -o "[\.0-9]\+")
 XCODE_VERSION_MAJOR=$(word 1, $(subst ., ,$(XCODE_VERSION)))
 
-ifneq (,$(findstring ios-sdk,$(COMPILER)))
-
-IOS_VERSION="9.0"
-IOS_SDK_VERSION="9.0"
-
-else
+ifeq (,$(findstring ios-sdk,$(COMPILER)))
 
 ifeq ($(XCODE_VERSION_MAJOR),)
 XCODE_VERSION_MAJOR=0
 endif
 
 ifeq ($(shell test $(XCODE_VERSION_MAJOR) -gt 10;echo $$?),0)
-MACOS_VERSION="10.5"
-MACOS_SDK_VERSION="10.5"
-PARTIALLD+=-arch ${ARCH} -platform_version macos $(MACOS_VERSION) $(MACOS_SDK_VERSION)
+MACOSVER?=10.10
+PARTIALLD+=-arch ${ARCH} -platform_version macos $(MACOSVER) $(shell xcrun --sdk macosx --show-sdk-version)
 endif
 
 endif
diff --git a/mk/ios-sdk-clang.mk b/mk/ios-sdk-clang.mk
new file mode 100644 (file)
index 0000000..4d825b1
--- /dev/null
@@ -0,0 +1,21 @@
+CROSS=ios-sdk-
+HOST_CC=clang
+CC=${CROSS}clang
+USERCC=${CROSS}clang
+RANLIB=xcrun --sdk iphoneos ranlib
+ONELIB=0
+OSTYPE=darwin
+AR=xcrun --sdk iphoneos ar
+CC_AR=${AR} -r ${LIBAR}
+PARTIALLD=${CROSS}ld -r -all_load
+PICFLAGS=
+CFLAGS+=${PICFLAGS}
+CC_LIB=${CC} -shared -o
+CFLAGS_INCLUDE=-I
+LDFLAGS_LINK=-l
+LDFLAGS_LINKPATH=-L
+CFLAGS_OPT0=-O0
+CFLAGS_OPT1=-O1
+CFLAGS_OPT2=-O2
+CFLAGS_OPT3=-O3
+CFLAGS_DEBUG=-g
diff --git a/mk/ios-sdk-gcc.mk b/mk/ios-sdk-gcc.mk
deleted file mode 100644 (file)
index a8ac0c1..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-CROSS=ios-sdk-
-HOST_CC=gcc
-CC=${CROSS}gcc
-USERCC=${CROSS}gcc
-RANLIB=xcrun --sdk iphoneos ranlib
-ONELIB=0
-OSTYPE=darwin
-AR=xcrun --sdk iphoneos ar
-CC_AR=${AR} -r ${LIBAR}
-PARTIALLD=${CROSS}ld -r -all_load
-PICFLAGS=
-CFLAGS+=${PICFLAGS}
-CC_LIB=${CC} -shared -o
-CFLAGS_INCLUDE=-I
-LDFLAGS_LINK=-l
-LDFLAGS_LINKPATH=-L
-CFLAGS_OPT0=-O0
-CFLAGS_OPT1=-O1
-CFLAGS_OPT2=-O2
-CFLAGS_OPT3=-O3
-CFLAGS_DEBUG=-g
diff --git a/mk/ios-sdk.mk b/mk/ios-sdk.mk
deleted file mode 100644 (file)
index a8ac0c1..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-CROSS=ios-sdk-
-HOST_CC=gcc
-CC=${CROSS}gcc
-USERCC=${CROSS}gcc
-RANLIB=xcrun --sdk iphoneos ranlib
-ONELIB=0
-OSTYPE=darwin
-AR=xcrun --sdk iphoneos ar
-CC_AR=${AR} -r ${LIBAR}
-PARTIALLD=${CROSS}ld -r -all_load
-PICFLAGS=
-CFLAGS+=${PICFLAGS}
-CC_LIB=${CC} -shared -o
-CFLAGS_INCLUDE=-I
-LDFLAGS_LINK=-l
-LDFLAGS_LINKPATH=-L
-CFLAGS_OPT0=-O0
-CFLAGS_OPT1=-O1
-CFLAGS_OPT2=-O2
-CFLAGS_OPT3=-O3
-CFLAGS_DEBUG=-g
diff --git a/mk/macos-sdk-clang.mk b/mk/macos-sdk-clang.mk
new file mode 100644 (file)
index 0000000..c220ef2
--- /dev/null
@@ -0,0 +1,21 @@
+CROSS=macos-sdk-
+HOST_CC=clang
+CC=${CROSS}clang
+USERCC=${CROSS}clang
+RANLIB=xcrun --sdk macosx ranlib
+ONELIB=0
+OSTYPE=darwin
+AR=xcrun --sdk macosx ar
+CC_AR=${AR} -r ${LIBAR}
+PARTIALLD=${CROSS}ld -r -all_load
+PICFLAGS=
+CFLAGS+=${PICFLAGS}
+CC_LIB=${CC} -shared -o
+CFLAGS_INCLUDE=-I
+LDFLAGS_LINK=-l
+LDFLAGS_LINKPATH=-L
+CFLAGS_OPT0=-O0
+CFLAGS_OPT1=-O1
+CFLAGS_OPT2=-O2
+CFLAGS_OPT3=-O3
+CFLAGS_DEBUG=-g
index c19b675f8792b861e8e6d93a25bd40e5c852d70c..dfa84b1feb743ac6bec730b166ba1b17aecb21fe 100644 (file)
@@ -266,6 +266,15 @@ SHLRS+=winkd/libr_winkd.a
 SHLRS+=zip/librz.a
 
 libr_shlr.${EXT_AR}:
+ifeq ($(OSTYPE),darwin)
+       @LIBS=""; \
+       for LIB in $(SHLRS); do \
+               if [ -f "$${LIB}" ]; then \
+                       LIBS="$${LIBS} $${LIB}"; \
+               fi; \
+       done; \
+       xcrun libtool -static -o $@ $${LIBS}
+else
        rm -rf .libr
        mkdir .libr
        for LIB in ${SHLRS} ; do \
@@ -273,5 +282,6 @@ libr_shlr.${EXT_AR}:
        done
        ${AR} rs $@ .libr/*.o
        $(RANLIB) $@
+endif
 
 .PHONY: spp
index 5ca7c87e7c784d09c4420738777a1308f248bc99..c7d8a42bc5de0ae9dae3550734c8dee322ee9542 100755 (executable)
@@ -91,16 +91,16 @@ if [ $onlymakedeb = 1 ]; then
        makeDeb
 else
        RV=0
-       export CC="ios-sdk-gcc"
+       export CC="ios-sdk-clang"
        if [ $fromscratch = 1 ]; then
                make clean
                cp -f dist/plugins-cfg/plugins.ios.cfg plugins.cfg
                if [ "$static" = 1 ]; then
                        ./configure --prefix="${PREFIX}" --with-ostype=darwin \
-                       --with-compiler=ios-sdk --target=arm-unknown-darwin --with-libr
+                       --with-compiler=ios-sdk-clang --target=arm-unknown-darwin --with-libr
                else
                        ./configure --prefix="${PREFIX}" --with-ostype=darwin \
-                       --with-compiler=ios-sdk --target=arm-unknown-darwin
+                       --with-compiler=ios-sdk-clang --target=arm-unknown-darwin
                fi
                RV=$?
        fi
index 3a8555aa8c4ebfe54f5139587582c9a8301a3e78..9781c8b2463c1c1ab3fceaaf332b09aba1eb044f 100755 (executable)
@@ -2,8 +2,5 @@
 
 export PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:${PATH}
 export PATH=$(pwd)/sys:${PATH}
-export CC=$(pwd)/sys/ios-sdk-gcc
-# set only for arm64, otherwise it is armv7
-# select ios sdk version
-export IOSVER=11.0
-export CFLAGS=-O2
+export CC=$(pwd)/sys/ios-sdk-clang
+export CFLAGS=-Oz
diff --git a/sys/ios-sdk-clang b/sys/ios-sdk-clang
new file mode 100755 (executable)
index 0000000..60cc50a
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+[ -z "${SDK}"    ] && SDK=iphoneos
+[ -z "${IOSVER}" ] && IOSVER=14.0
+[ -z "${CPU}"    ] && CPU="arm64"
+
+CLANG=$(xcrun --sdk ${SDK} -f clang)
+SYSROOT=$(xcrun --sdk ${SDK} --show-sdk-path)
+if [ "$SDK" = "iphoneos" ]; then
+       VERSION_FLAG="-mios-version-min=${IOSVER}"
+else
+       VERSION_FLAG="-mios-simulator-version-min=${IOSVER}"
+fi
+CPUS=""
+IFS=+
+for a in $CPU; do
+       CPUS="-arch $a ${CPUS}"
+done
+unset IFS
+BITCODE_FLAG=""
+if [ "${EMBED_BITCODE}" = "1" ]; then
+       BITCODE_FLAG="-fembed-bitcode"
+fi
+APPLE_SDK=`echo ${SDK} | tr a-z A-Z`
+
+CC="${CLANG} -isysroot ${SYSROOT} ${VERSION_FLAG} ${CPUS} ${BITCODE_FLAG} -DAPPLE_SDK_${APPLE_SDK}=1"
+echo $CC $*
+${CC} $*
+r=$?
+[ "$r" != 0 ] && echo ${CC} $* >&2
+exit $r
diff --git a/sys/ios-sdk-gcc b/sys/ios-sdk-gcc
deleted file mode 100755 (executable)
index 34427ae..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh
-
-[ -z "${CPU}" ] && CPU="arm64"
-CWD="$(dirname "$0")"
-CPUS=""
-CPU=`echo $CPU | sed -e 's,+, ,g'`
-for a in `IFS=+ echo ${CPU}` ; do
-       CPUS="-arch $a ${CPUS}"
-done
-[ -z "${SDK}" ] && SDK=iphoneos
-APPLE_SDK=`echo ${SDK} |tr a-z A-Z`
-# Respect EMBED_BITCODE; default off
-BITCODE_FLAG=""
-if [ "${EMBED_BITCODE}" = "1" ]; then
-    BITCODE_FLAG="-fembed-bitcode"
-fi
-CC="xcrun --sdk ${SDK} clang ${CPUS} ${BITCODE_FLAG} -DAPPLE_SDK_${APPLE_SDK}=1 -miphoneos-version-min=10.0"
-echo $CC $*
-${CC} $*
-r=$?
-[ "$r" != 0 ] && echo ${CC} $* >&2
-exit $r
index c588b5709d9122fc2304cfcbd3070ffb27e74631..61c4181f9384131b286f5fce044b52178041a435 100755 (executable)
@@ -1,25 +1,27 @@
 #!/bin/sh
 
-[ -z "${CPU}" ] && CPU="arm64"
-CWD="$(dirname "$0")"
+[ -z "${SDK}"    ] && SDK=iphoneos
+[ -z "${IOSVER}" ] && IOSVER=14.0
+[ -z "${CPU}"    ] && CPU="arm64"
+
+LINKER=$(xcrun --sdk ${SDK} -f ld)
+if [ "$SDK" = "iphoneos" ]; then
+       VERSION_FLAG="-platform_version ios ${IOSVER} $(xcrun --sdk iphoneos --show-sdk-version)"
+else
+       VERSION_FLAG="-platform_version ios-simulator ${IOSVER} $(xcrun --sdk iphonesimulator --show-sdk-version)"
+fi
 CPUS=""
 CPU=`echo $CPU | sed -e 's,+, ,g'`
 for a in `IFS=+ echo ${CPU}` ; do
        CPUS="-arch $a ${CPUS}"
 done
-[ -z "${SDK}" ] && SDK=iphoneos
 APPLE_SDK=`echo ${SDK} | tr a-z A-Z`
-# Respect EMBED_BITCODE; default off
 BITCODE_BUNDLE=""
 if [ "${EMBED_BITCODE}" = "1" ]; then
-    BITCODE_BUNDLE="-bitcode_bundle"
-fi
-LD="xcrun --sdk ${SDK} ld ${CPUS} ${BITCODE_BUNDLE}"
-if [ "$SDK" = "iphoneos" ]; then
-       LD="$LD -ios_version_min 10.0"
-else
-       LD="$LD -ios_simulator_version_min 10.0"
+       BITCODE_BUNDLE="-bitcode_bundle"
 fi
+
+LD="${LINKER} ${VERSION_FLAG} ${CPUS} ${BITCODE_BUNDLE}"
 echo "$LD $*"
 ${LD} $*
 r=$?
index d6368abe34e51d035ad52b11f257bd07c3578f6a..4352a87552782608d495a99c6a00804a44ed6668 100755 (executable)
@@ -35,7 +35,7 @@ export SDK=watchos
 
 ##########################################
 
-export CPU=x86_64
+export CPU=arm64
 export SDK=iphonesimulator
 export PLGCFG=plugins.ios-store.cfg
 
@@ -45,10 +45,7 @@ PREFIX="/usr"
 
 export PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:$PATH
 export PATH=$(pwd)/sys:${PATH}
-export CC="$(pwd)/sys/ios-sdk-gcc"
-# set only for arm64, otherwise it is armv7
-# select ios sdk version
-export IOSVER=10.2
+export CC="$(pwd)/sys/ios-sdk-clang"
 export CFLAGS="${CFLAGS} -O2"
 export USE_SIMULATOR=1
 export RANLIB="xcrun --sdk iphoneos ranlib"
@@ -62,7 +59,7 @@ if true; then
 make mrproper
 cp -f ${PLGCFG} plugins.cfg
 ./configure --prefix=${PREFIX} --with-ostype=darwin --with-libr \
-       --without-fork --disable-debugger --with-compiler=ios-sdk \
+       --without-fork --disable-debugger --with-compiler=ios-sdk-clang \
        --target=arm-unknown-darwin || exit 1
 fi
 
@@ -78,6 +75,5 @@ if [ $? = 0 ]; then
                rm -rf sys/cydia/radare2/root
                mkdir -p sys/cydia/radare2/root
                sudo tar xpzvf /tmp/r2ios-${CPU}.tar.gz -C sys/cydia/radare2/root
-               ( cd sys/cydia/radare2 ; sudo make clean ; sudo make )
        fi
 fi
index 1bccbc90a30f08c3abee112e6cae51aea6d97553..b90e4416ede212a32d6c96434bc66218d6ac240c 100755 (executable)
@@ -37,10 +37,7 @@ PREFIX="/usr"
 
 export PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:$PATH
 export PATH=$(pwd)/sys:${PATH}
-export CC=$(pwd)/sys/ios-sdk-gcc
-# set only for arm64, otherwise it is armv7
-# select ios sdk version
-export IOSVER=9.3
+export CC=$(pwd)/sys/ios-sdk-clang
 #export CFLAGS=-O2
 export CFLAGS="-Os -flto"
 export LDFLAGS="-flto"
@@ -61,7 +58,7 @@ cp -f dist/plugins-cfg/plugins.ios.cfg plugins.cfg
        ${CFGFLAGS} \
        --with-ostype=darwin --with-libr \
        --without-gpl --without-fork \
-       --with-compiler=ios-sdk \
+       --with-compiler=ios-sdk-clang \
        --target=arm-unknown-darwin
 fi
 
diff --git a/sys/macos-env.sh b/sys/macos-env.sh
new file mode 100755 (executable)
index 0000000..95ad179
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+export PATH=$(pwd)/sys:${PATH}
+export CC=$(pwd)/sys/macos-sdk-clang
+export CFLAGS=-Oz
diff --git a/sys/macos-sdk-clang b/sys/macos-sdk-clang
new file mode 100755 (executable)
index 0000000..3a55d41
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+[ -z "${MACOSVER}" ] && MACOSVER=10.10
+[ -z "${CPU}"      ] && CPU="$(uname -m)"
+
+CLANG=$(xcrun --sdk macosx -f clang)
+SYSROOT=$(xcrun --sdk macosx --show-sdk-path)
+CPUS=""
+IFS=+
+for a in $CPU; do
+       CPUS="-arch $a ${CPUS}"
+done
+unset IFS
+APPLE_SDK=`echo macosx | tr a-z A-Z`
+
+CC="${CLANG} -isysroot ${SYSROOT} -mmacosx-version-min=${MACOSVER} ${CPUS}"
+echo $CC $*
+${CC} $*
+r=$?
+[ "$r" != 0 ] && echo ${CC} $* >&2
+exit $r
diff --git a/sys/macos-sdk-ld b/sys/macos-sdk-ld
new file mode 100755 (executable)
index 0000000..4f11988
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+[ -z "${MACOSVER}" ] && MACOSVER=10.10
+[ -z "${CPU}"      ] && CPU="$(uname -m)"
+
+CPUS=""
+CPU=`echo $CPU | sed -e 's,+, ,g'`
+for a in `IFS=+ echo ${CPU}` ; do
+       CPUS="-arch $a ${CPUS}"
+done
+
+LD="$(xcrun --sdk macosx -f ld) ${CPUS} -platform_version macos ${MACOSVER} $(xcrun --sdk macosx --show-sdk-version)"
+echo "$LD $*"
+${LD} $*
+r=$?
+if [ "$r" != 0 ]; then
+       echo ${LD} $* >&2
+fi
+exit $r
index 8f1a0e38b4b9d4b0f8f3bab458af04e56d6e83f2..99ada6d01a121077362f0af1d55e3d9e5edd4f04 100755 (executable)
@@ -11,9 +11,12 @@ ARCHS=""
 MERGE_LIBS=1
 
 sdkClean() {
-       make clean
+       make clean || true
        rm -rf libr/.libr libr/.libr2 libr/libr.a libr/libr.dylib shlr/libr_shlr.a
+       rm -rf shlr/.libr/
        rm -rf shlr/capstone
+       rm -rf subprojects/sdb/src/libsdb.a
+       rm -rf subprojects/capstone-v5/libcapstone.a
 }
 
 sdkBuild() {
@@ -93,10 +96,13 @@ parseArgs() {
                        fi
                        shift
                        ;;
-               *|-h|--help)
+               -h|--help)
                        showHelp
                        exit 0
                        ;;
+               *)
+                       shift
+                       ;;
                esac
        done
 }
index ae2f8eab0de85b057e16300a6b62f1f23bfb77e2..f165c786c01b1cfceacf161cde3a73dae1fbdd73 100755 (executable)
@@ -4,11 +4,9 @@
 
 . sys/sdk-common.sh
 
-: "${R2_IOS_MIN:=12.0}"
-
 # iOS specific variables
 USE_SIMULATOR=0
-SIMULATOR_ARCHS="x86_64"
+SIMULATOR_ARCHS="arm64"
 PACKAGE_RADARE=0
 EMBED_BITCODE=0
 PLUGINS_CFG=plugins.ios-store.cfg
@@ -17,6 +15,8 @@ PLUGINS_CFG=plugins.ios-store.cfg
 . sys/ios-env.sh
 export USE_IOS_STATIC=0
 
+set -eo pipefail
+
 echo "If xcrun --sdk iphoneos cant find the profile use this line:"
 echo " sudo xcode-select -switch /Applications/Xcode.app"
 
@@ -26,16 +26,10 @@ if [ "${EMBED_BITCODE}" = 1 ]; then
 fi
 
 iosConfigure() {
-       : "${IPHONEOS_DEPLOYMENT_TARGET:=${R2_IOS_MIN}}"
-       export IPHONEOS_DEPLOYMENT_TARGET
-
-       export CFLAGS="-miphoneos-version-min=${IPHONEOS_DEPLOYMENT_TARGET} ${CFLAGS}"
-       export LDFLAGS="-miphoneos-version-min=${IPHONEOS_DEPLOYMENT_TARGET} ${LDFLAGS}"
-
        cp -f dist/plugins-cfg/${PLUGINS_CFG} plugins.cfg
        ./configure --with-libr --prefix=${PREFIX} --with-ostype=darwin \
                --disable-debugger --without-gpl \
-               --without-fork --with-compiler=ios-sdk \
+               --without-fork --with-compiler=ios-sdk-clang \
                --target=arm64-unknown-darwin
        return $?
 }
@@ -142,40 +136,36 @@ rm -rf "$INSTALL_DST"
 # Build for simulator
 if [ "${USE_SIMULATOR}" = 1 ]; then
        sdkClean
-       if [ 1 = 0 ]; then
-               iosConfigure
-               if [ $? -eq 0 ]; then
-                       export CPU="$SIMULATOR_ARCHS"
-                       export SDK=iphonesimulator
-                       echo "Building for simulator($SIMULATOR_ARCHS)"
-                       sleep 1
-                       sdkBuild
-               fi
-       else
-               sys/ios-simulator.sh
-       fi
-       # backup lib folder
+       export CPU="$SIMULATOR_ARCHS"
+       export SDK=iphonesimulator
+       iosConfigure
+       echo "Building for simulator($SIMULATOR_ARCHS)"
+       sleep 1
+       sdkBuild
+       # backup include and lib directories
        if [ "${#ARCHS}" -gt 0 ]; then
-               rm -rf "$INSTALL_DST/$PREFIX"/lib_simulator
-               mv "$INSTALL_DST/$PREFIX"/lib "$INSTALL_DST/$PREFIX"/lib_simulator
+               for d in include lib; do
+                       rm -rf "$INSTALL_DST/$PREFIX"/${d}_simulator
+                       mv "$INSTALL_DST/$PREFIX"/${d} "$INSTALL_DST/$PREFIX"/${d}_simulator
+               done
        else
-               cp -r "$INSTALL_DST/$PREFIX"/lib "$INSTALL_DST/$PREFIX"/lib_simulator
+               for d in include lib; do
+                       cp -r "$INSTALL_DST/$PREFIX"/${d} "$INSTALL_DST/$PREFIX"/${d}_simulator
+               done
        fi
 fi
 
 # Build for device
 if [ "${#ARCHS}" -gt 0 ]; then
        sdkClean
+       export CPU="$ARCHS"
+       export SDK=iphoneos
        iosConfigure
-       if [ $? -eq 0 ]; then
-               export CPU="$ARCHS"
-               export SDK=iphoneos
-               echo "Building for $CPU"
-               sleep 1
-               sdkBuild
-               if [ "${PACKAGE_RADARE}" = 1 ]; then
-                       iosPackage
-               fi
+       echo "Building for $CPU"
+       sleep 1
+       sdkBuild
+       if [ "${PACKAGE_RADARE}" = 1 ]; then
+               iosPackage
        fi
 fi
 
index 44d47d1113479f03b94ce601a3f796dcce20396d..d4adc39295705453873247cbab4e8d5a41c99a8f 100755 (executable)
@@ -4,22 +4,19 @@
 
 . sys/sdk-common.sh
 
-: "${R2_MACOS_MIN:=10.10}"
-
 # macOS specific
 PLUGINS_CFG=plugins.ios-store.cfg
 
-macosConfigure() {
-       : "${MACOSX_DEPLOYMENT_TARGET:=${R2_MACOS_MIN}}"
-       export MACOSX_DEPLOYMENT_TARGET
+# Environment variables
+. sys/macos-env.sh
 
-       export CFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET} ${CFLAGS}"
-       export LDFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET} ${LDFLAGS}"
+set -eo pipefail
 
+macosConfigure() {
        cp -f dist/plugins-cfg/${PLUGINS_CFG} plugins.cfg
        ./configure --with-libr --prefix=${PREFIX} --with-ostype=darwin \
                --disable-debugger --without-gpl \
-               --without-fork --with-compiler=clang \
+               --without-fork --with-compiler=macos-sdk-clang \
                --target=x86_64-apple-darwin
        return $?
 }
@@ -66,9 +63,9 @@ rm -rf "$INSTALL_DST"
 
 if [ "${#ARCHS}" -gt 0 ]; then
        sdkClean
+       export CPU="$ARCHS"
        macosConfigure
        if [ $? -eq 0 ]; then
-               export CPU="$ARCHS"
                echo "Building for $CPU"
                sleep 1
                sdkBuild
index af352483e98feccd2fd94cacf62419bbc58e94ae..616d35cf041adbde94e5e71df67ca5286f443da0 100755 (executable)
@@ -16,6 +16,8 @@ fi
 
 OS=`uname`
 
+set -eo pipefail
+
 if [ "$OS" = "Darwin" ]; then
        # On macOS, build xcframework for iOS and macOS
        echo "Building xcframework for iOS and macOS"
@@ -23,7 +25,7 @@ if [ "$OS" = "Darwin" ]; then
        # Build iOS SDK
        echo "Building iOS SDK..."
        INSTALL_DST_IOS="/tmp/r2ios"
-       sys/sdk-ios.sh -archs arm64 -d "$INSTALL_DST_IOS"
+       sys/sdk-ios.sh -archs arm64 -simulator -d "$INSTALL_DST_IOS"
        
        # Build macOS SDK
        echo "Building macOS SDK..."
@@ -38,38 +40,36 @@ if [ "$OS" = "Darwin" ]; then
 
        # Prepare headers with module maps
        XCF_HEADERS_IOS="/tmp/xcframework_headers/ios"
+       XCF_HEADERS_SIM="/tmp/xcframework_headers/sim"
        XCF_HEADERS_MACOS="/tmp/xcframework_headers/macos"
-       rm -rf "$XCF_HEADERS_IOS" "$XCF_HEADERS_MACOS"
-       mkdir -p "$XCF_HEADERS_IOS" "$XCF_HEADERS_MACOS"
+       rm -rf "$XCF_HEADERS_IOS" "$XCF_HEADERS_SIM" "$XCF_HEADERS_MACOS"
+       mkdir -p "${XCF_HEADERS_IOS}/Radare2" "${XCF_HEADERS_SIM}/Radare2" "${XCF_HEADERS_MACOS}/Radare2"
 
-       # Copy headers
+       # Copy headers and add modulemap
        cp -r "$INSTALL_DST_IOS/usr/local/include/libr/"* "$XCF_HEADERS_IOS/"
+       cp -r "$INSTALL_DST_IOS/usr/local/include_simulator/libr/"* "$XCF_HEADERS_SIM/"
        cp -r "$INSTALL_DST_MACOS/usr/local/include/libr/"* "$XCF_HEADERS_MACOS/"
-       for d in "$XCF_HEADERS_IOS" "$XCF_HEADERS_MACOS"; do
+       for d in "$XCF_HEADERS_IOS" "$XCF_HEADERS_SIM" "$XCF_HEADERS_MACOS"; do
                (
                cd "$d" || exit 1
-               rm -rf r2naked.h sflib sdb/gcc_stdatomic.h sdb/msvc_stdatomic.h
+               rm -rf ptrace_wrap.h r2naked.h sflib sdb/gcc_stdatomic.h sdb/msvc_stdatomic.h
                )
-       done
-
-       # Add module.modulemap
-       cat > "$XCF_HEADERS_IOS/module.modulemap" <<'EOF'
+               cat > "$d/Radare2/module.modulemap" <<'EOF'
 module Radare2 [extern_c] {
-  umbrella "."
-  export *
-}
-EOF
-       cat > "$XCF_HEADERS_MACOS/module.modulemap" <<'EOF'
-module Radare2 [extern_c] {
-  umbrella "."
+  umbrella ".."
   export *
 }
 EOF
+       done
 
        # For iOS
        IOS_LIB="$INSTALL_DST_IOS/usr/local/lib/libr.a"
        IOS_HEADERS="$XCF_HEADERS_IOS"
 
+       # For iOS Simulator
+       SIM_LIB="$INSTALL_DST_IOS/usr/local/lib_simulator/libr.a"
+       SIM_HEADERS="$XCF_HEADERS_SIM"
+
        # For macOS
        MACOS_LIB="$INSTALL_DST_MACOS/usr/local/lib/libr.a"
        MACOS_HEADERS="$XCF_HEADERS_MACOS"
@@ -77,6 +77,8 @@ EOF
        xcodebuild -create-xcframework \
                -library "$IOS_LIB" \
                -headers "$IOS_HEADERS" \
+               -library "$SIM_LIB" \
+               -headers "$SIM_HEADERS" \
                -library "$MACOS_LIB" \
                -headers "$MACOS_HEADERS" \
                -output "$XCF_DST"
@@ -89,7 +91,6 @@ EOF
                        cd "$(dirname "$XCF_DST")" || exit 1
                        zip -r "${OUTDIR}/Radare2.xcframework.zip" "$(basename "$XCF_DST")"
                )
-               zip -r Radare2.xcframework.zip "$XCF_DST"
                echo "Zipped to Radare2.xcframework.zip"
        else
                echo "Failed to create xcframework"