Skip to content

Fix Apple platform detection and iOS cross-build#5791

Merged
martin-frbg merged 3 commits intoOpenMathLib:developfrom
moluopro:develop
May 2, 2026
Merged

Fix Apple platform detection and iOS cross-build#5791
martin-frbg merged 3 commits intoOpenMathLib:developfrom
moluopro:develop

Conversation

@moluopro
Copy link
Copy Markdown
Contributor

@moluopro moluopro commented May 1, 2026

This PR fixes Apple platform detection and iOS cross-build instructions.

The main issue is that Apple clang defines TARGET_OS_IPHONE on macOS as well,
but with value 0. The previous detection only checked whether the macro was
defined, so macOS builds could be identified as iOS. This PR checks the macro
value, adds a separate display name for Darwin targets, and updates the iOS CI
and documentation build commands so that iPhoneOS compiler flags are actually
passed to make.

Changes

ctest.c

  • Change iOS detection from defined(TARGET_OS_IPHONE) to
    defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE.
  • This avoids treating normal macOS builds as iOS, because Apple headers define
    TARGET_OS_IPHONE as 0 for macOS targets.

c_check

  • Replace the boolean is_ios state with darwin_os, which records the Darwin
    target kind as macOS or iOS.
  • Keep the internal build OS as Darwin, while writing OSNAME_DISPLAY for
    user-facing output.
  • Set CROSS=1 when the detected Darwin target kind is iOS.
  • Use grep -q when checking the generated assembly symbol prefix, avoiding
    accidental diagnostic output from the detection command.

c_check.pl

  • Mirror the shell c_check behavior in the Perl fallback script.
  • Track darwin_os separately from OSNAME.
  • Emit OSNAME_DISPLAY only for Darwin targets.
  • Set cross-compilation mode for iOS targets.

Makefile

  • Add OSNAME_DISPLAY ?= $(OSNAME).
  • Print OSNAME_DISPLAY in the final build summary instead of the internal
    OSNAME.
  • This keeps existing build logic based on Darwin, while showing users
    macOS or iOS in the summary.

.github/workflows/apple_m.yml

  • Update the iOS cross-build step to query the iPhoneOS clang and SDK path with
    xcrun.
  • Pass CC and CFLAGS directly to make, instead of setting shell variables
    that make would not necessarily receive.
  • Print the resolved CC and SDKROOT values in CI logs for easier debugging.
  • Restore DYNAMIC_ARCH=1 in the iOS CI build command.

docs/install.md

  • Update the iOS build instructions to match the CI command.
  • Use xcrun --sdk iphoneos --find clang instead of a hard-coded Xcode path.
  • Pass CC and CFLAGS directly to make.
  • Fix the follow-up note to refer to the actual
    -miphoneos-version-min flag instead of MIN_IOS_VERSION.

@moluopro
Copy link
Copy Markdown
Contributor Author

moluopro commented May 1, 2026

I previously fixed the iOS shell script, but didn’t update Perl, CI, or the documentation. I’ve polished those up this time.

@martin-frbg
Copy link
Copy Markdown
Collaborator

Thank you very much

@martin-frbg martin-frbg added this to the 0.3.34 milestone May 2, 2026
@martin-frbg martin-frbg merged commit 8e57c86 into OpenMathLib:develop May 2, 2026
101 of 103 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants