Skip to content

Trying to cross compile zeromq-src for aarch64-apple-ios #173

@berendsliedrecht

Description

@berendsliedrecht

hi

I am currently trying to compile zeromq-src (0.1.10+4.3.2) and it seems to error that cmake can not find the iOS sdk.

  • cmake v3.25.1
  • host: arm macOS (x86 in Github Actions also does not work)
  • target: aarch64-apple-ios (or any apple-ios target)
  • toolchain: stable
  • Xcode: 14.0.1

This part of the stack trace caught my eye:

CMake Error at /opt/homebrew/Cellar/cmake/3.25.1/share/cmake/Modules/Platform/iOS-Initialize.cmake:4 (message):
    / is not an iOS SDK

After doing some digging in cmake-rs it seems to be related to this line here https://github.com/rust-lang/cmake-rs/blob/07cbf8fd36168b8a5dc9e107f6e659130dbcdd30/src/lib.rs.

This sets the CMAKE_OSX_SYSROOT to / and afterwards this code executes within cmake:

...

# Transform CMAKE_OSX_SYSROOT to absolute path
set(_CMAKE_OSX_SYSROOT_PATH "")
if(CMAKE_OSX_SYSROOT)      <----------- EXISTS
  if("x${CMAKE_OSX_SYSROOT}" MATCHES "/")        <---------- MATCHES TRUE
    # This is a path to the SDK.  Make sure it exists.
    if(NOT IS_DIRECTORY "${CMAKE_OSX_SYSROOT}")          <-------------- IS_DIRECTORY TRUE
      message(WARNING "Ignoring CMAKE_OSX_SYSROOT value:\n ${CMAKE_OSX_SYSROOT}\n"
        "because the directory does not exist.")
      set(CMAKE_OSX_SYSROOT "")
    endif()
    set(_CMAKE_OSX_SYSROOT_PATH "${CMAKE_OSX_SYSROOT}") <-------- SETS _CMAKE_OSX_SYSROOT_PATH to /
  else()
    _apple_resolve_sdk_path(${CMAKE_OSX_SYSROOT} _sdk_path)
    if(IS_DIRECTORY "${_sdk_path}")
      set(_CMAKE_OSX_SYSROOT_PATH "${_sdk_path}")
      # For non-Xcode generators use the path.
      if(NOT "${CMAKE_GENERATOR}" MATCHES "Xcode")
        set(CMAKE_OSX_SYSROOT "${_CMAKE_OSX_SYSROOT_PATH}")
      endif()
    endif()
  endif()
endif()

After this code, this executes:

include(Platform/Darwin-Initialize)

if(NOT _CMAKE_OSX_SYSROOT_PATH MATCHES "/iPhone(OS|Simulator)")   <--- _CMAKE_OSX_SYSROOT_PATH = / and therefore does not match the regex
  message(FATAL_ERROR "${CMAKE_OSX_SYSROOT} is not an iOS SDK")
endif()

set(IOS 1)

set(_CMAKE_FEATURE_DETECTION_TARGET_TYPE STATIC_LIBRARY)

I do not know almost anything about cmake, but this does seem very weird and I am unsure how I can resolve this.

Reproduce (on MacOS)

git clone https://github.com/hyperledger/indy-vdr # this uses zmq 0.9.0 vendored, which uses zeromq-src
cd indy-vdr
rustup target add aarch64-apple-ios
cargo build --release --package=indy-vdr --target=aarch64-apple-ios

Happy to provide more information about my system where required.

Stacktrace

error: failed to run custom build command for `zmq-sys v0.11.0`

Caused by:
  process didn't exit successfully: `/Users/beri/Developer/tmp/indy-vdr/target/release/build/zmq-sys-e224b96d1c794902/build-script-main` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=build/main.rs
  cargo:rerun-if-env-changed=PROFILE
  CMAKE_TOOLCHAIN_FILE_x86_64-apple-ios = None
  CMAKE_TOOLCHAIN_FILE_x86_64_apple_ios = None
  TARGET_CMAKE_TOOLCHAIN_FILE = None
  CMAKE_TOOLCHAIN_FILE = None
  CMAKE_GENERATOR_x86_64-apple-ios = None
  CMAKE_GENERATOR_x86_64_apple_ios = None
  TARGET_CMAKE_GENERATOR = None
  CMAKE_GENERATOR = None
  running: "xcrun" "--show-sdk-path" "--sdk" "iphonesimulator"
  exit status: 0
  running: "xcrun" "--show-sdk-path" "--sdk" "iphonesimulator"
  exit status: 0
  CMAKE_PREFIX_PATH_x86_64-apple-ios = None
  CMAKE_PREFIX_PATH_x86_64_apple_ios = None
  TARGET_CMAKE_PREFIX_PATH = None
  CMAKE_PREFIX_PATH = None
  CMAKE_x86_64-apple-ios = None
  CMAKE_x86_64_apple_ios = None
  TARGET_CMAKE = None
  CMAKE = None
  running: "cmake" "/Users/beri/.cargo/registry/src/github.com-1ecc6299db9ec823/zeromq-src-0.1.10+4.3.2/vendor" "-DCMAKE_OSX_SYSROOT=/" "-DCMAKE_OSX_DEPLOYMENT_TARGET=" "-DCMAKE_INSTALL_LIBDIR=lib" "-DCMAKE_C_STANDARD=99" "-DZMQ_BUILD_TESTS=OFF" "-DENABLE_DRAFTS=OFF" "-DENABLE_CURVE=ON" "-DCMAKE_BUILD_TYPE=Release" "-DWITH_PERF_TOOL=OFF" "-DBUILD_SHARED=OFF" "-DBUILD_STATIC=ON" "-DWITH_LIBSODIUM=OFF" "-DCMAKE_SYSTEM_NAME=iOS" "-DCMAKE_SYSTEM_PROCESSOR=x86_64" "-DCMAKE_INSTALL_PREFIX=/Users/beri/Developer/tmp/indy-vdr/target/x86_64-apple-ios/release/build/zmq-sys-828525e3e50a962a/out" "-DCMAKE_C_FLAGS= -fPIC --target=x86_64-apple-ios -m64 -mios-simulator-version-min=7.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.0.sdk -fembed-bitcode" "-DCMAKE_C_COMPILER=/usr/bin/clang" "-DCMAKE_CXX_FLAGS= -fPIC --target=x86_64-apple-ios -m64 -mios-simulator-version-min=7.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.0.sdk -fembed-bitcode" "-DCMAKE_CXX_COMPILER=/usr/bin/clang++" "-DCMAKE_ASM_FLAGS= -fPIC --target=x86_64-apple-ios -m64 -mios-simulator-version-min=7.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.0.sdk -fembed-bitcode" "-DCMAKE_ASM_COMPILER=/usr/bin/clang"
  -- Configuring incomplete, errors occurred!
  See also "/Users/beri/Developer/tmp/indy-vdr/target/x86_64-apple-ios/release/build/zmq-sys-828525e3e50a962a/out/build/CMakeFiles/CMakeOutput.log".

  --- stderr
  CMake Error at /opt/homebrew/Cellar/cmake/3.25.1/share/cmake/Modules/Platform/iOS-Initialize.cmake:4 (message):
    / is not an iOS SDK
  Call Stack (most recent call first):
    /opt/homebrew/Cellar/cmake/3.25.1/share/cmake/Modules/CMakeSystemSpecificInitialize.cmake:21 (include)
    CMakeLists.txt:2 (project)


  thread 'main' panicked at '
  command did not execute successfully, got: exit status: 1

  build script failed, must exit now', /Users/beri/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.49/src/lib.rs:1104:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

EDIT

It seems that the release of 0.1.49 caused this issue, likely from this PR: #160

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions