Fix iOS target detection on Darwin

This commit is contained in:
moluopro
2026-05-01 13:06:14 +08:00
parent 4e5c4bf567
commit e2174b31c1
4 changed files with 19 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
TOPDIR = .
include ./Makefile.system
LNCMD = ln -fs
OSNAME_DISPLAY ?= $(OSNAME)
ifeq ($(FIXED_LIBNAME), 1)
LNCMD = true
endif
@@ -58,7 +59,7 @@ all :: tests
@echo
@echo " OpenBLAS build complete. ($(LIB_COMPONENTS))"
@echo
@echo " OS ... $(OSNAME) "
@echo " OS ... $(OSNAME_DISPLAY) "
@echo " Architecture ... $(ARCH) "
ifndef BINARY64
@echo " BINARY ... 32bit "

12
c_check
View File

@@ -23,7 +23,7 @@ config="$2"
compiler_name="$3"
shift 3
flags="$*"
is_ios=false
darwin_os=""
# First, we need to know the target OS and compiler name
{
@@ -70,7 +70,7 @@ case "$data" in *OS_FREEBSD*) os=FreeBSD ;; esac
case "$data" in *OS_NETBSD*) os=NetBSD ;; esac
case "$data" in *OS_OPENBSD*) os=OpenBSD ;; esac
case "$data" in *OS_DRAGONFLY*) os=DragonFly ;; esac
case "$data" in *OS_DARWIN*) os=Darwin ;; esac
case "$data" in *OS_DARWIN*) os=Darwin; darwin_os=macOS ;; esac
case "$data" in *OS_SUNOS*) os=SunOS ;; esac
case "$data" in *OS_AIX*) os=AIX ;; esac
case "$data" in *OS_OSF*) os=osf ;; esac
@@ -79,7 +79,7 @@ case "$data" in *OS_CYGWIN_NT*) os=CYGWIN_NT ;; esac
case "$data" in *OS_INTERIX*) os=Interix ;; esac
case "$data" in *OS_ANDROID*) os=Android ;; esac
case "$data" in *OS_HAIKU*) os=Haiku ;; esac
case "$data" in *OS_IOS*) is_ios=true ;; esac
case "$data" in *OS_IOS*) darwin_os=iOS ;; esac
case "$data" in
*ARCH_X86_64*) architecture=x86_64 ;;
@@ -404,7 +404,7 @@ fi
data=`$compiler_name $flags -S ctest1.c && grep globl ctest1.s | head -n 1 && rm -f ctest1.s`
need_fu=''
if echo "$data" | grep 'globl[[:space:]][_\.]'; then
if echo "$data" | grep -q 'globl[[:space:]][_\.]'; then
need_fu="${data##*globl[[:space:]]}"
need_fu="${need_fu%%[!_\.]*}"
fi
@@ -421,7 +421,7 @@ fi
[ "$os" = "Android" ] && [ "$hostos" = "Linux" ] && [ -n "$TERMUX_APP_PID" ] \
&& cross=0
[ "$is_ios" = true ] && cross=1
[ "$darwin_os" = iOS ] && cross=1
[ "$USE_OPENMP" != 1 ] && openmp=''
@@ -489,11 +489,11 @@ done
:> "$makefile" || exit 1
:> "$config" || exit 1
# print $data, "\n";
{
printf "OSNAME=%s\n" "$os"
[ -n "$darwin_os" ] && printf "OSNAME_DISPLAY=%s\n" "$darwin_os"
printf "ARCH=%s\n" "$architecture"
printf "C_COMPILER=%s\n" "$compiler"
[ $binformat != 'bin32' ] && printf "BINARY32=\n"

View File

@@ -56,6 +56,7 @@ if ($@){
}
$compiler = "";
$darwin_os = "";
$compiler = LSB if ($data =~ /COMPILER_LSB/);
$compiler = CLANG if ($data =~ /COMPILER_CLANG/);
$compiler = PGI if ($data =~ /COMPILER_PGI/);
@@ -73,7 +74,13 @@ $os = FreeBSD if ($data =~ /OS_FREEBSD/);
$os = NetBSD if ($data =~ /OS_NETBSD/);
$os = OpenBSD if ($data =~ /OS_OPENBSD/);
$os = DragonFly if ($data =~ /OS_DRAGONFLY/);
$os = Darwin if ($data =~ /OS_DARWIN/);
if ($data =~ /OS_DARWIN/) {
$os = Darwin;
$darwin_os = "macOS";
}
if ($data =~ /OS_IOS/) {
$darwin_os = "iOS";
}
$os = SunOS if ($data =~ /OS_SUNOS/);
$os = AIX if ($data =~ /OS_AIX/);
$os = osf if ($data =~ /OS_OSF/);
@@ -391,6 +398,7 @@ if ($architecture ne $hostarch) {
$cross = 1 if ($os ne $hostos);
$cross = 0 if (($os eq "Android") && ($hostos eq "Linux") && ($ENV{TERMUX_APP_PID} != ""));
$cross = 1 if $darwin_os eq "iOS";
$openmp = "" if $ENV{USE_OPENMP} != 1;
@@ -454,6 +462,7 @@ open(CONFFILE, "> $config" ) || die "Can't create $config";
# print $data, "\n";
print MAKEFILE "OSNAME=$os\n";
print MAKEFILE "OSNAME_DISPLAY=$darwin_os\n" if $darwin_os ne "";
print MAKEFILE "ARCH=$architecture\n";
print MAKEFILE "C_COMPILER=$compiler\n";
print MAKEFILE "BINARY32=\n" if $binformat ne bin32;

View File

@@ -182,6 +182,6 @@ ARCH_WASM
OS_WINDOWS
#endif
#if defined(TARGET_OS_IPHONE)
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
OS_IOS
#endif