Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support building for aarch64-apple-ios-sim #160

Closed
tomleavy opened this issue Jun 15, 2023 · 2 comments
Closed

Support building for aarch64-apple-ios-sim #160

tomleavy opened this issue Jun 15, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@tomleavy
Copy link

Problem:

Targeting the iOS device (aarch64-apple-ios) works properly but building for the simulator doesn't. I can generally build aws-lc for iOS simulator, so I suspect that this is a problem between the cmake cargo crate and aws-lc cmake.

Building aws-lc for iOS simulator works with the following cmake command

cmake -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_NAME="iOS" -DCMAKE_OSX_ARCHITECTURES="arm64" -DCMAKE_OSX_SYSROOT="iphonesimulator" -DBUILD_LIBSSL=OFF ..

Relevant details

AWS-LC for Rust versions or commit: latest main

System information: for linux, below info can be collected by running uname -srvmp

  • CPU architecture: aarch64
  • Host OS: MacOS 13.4 (arm) + XCode 14.3.1
  • Compiler: Rust 1.70
  • Target OS: iOS Simulator (aarch64-apple-ios-sim)

Build log:

❯ cargo build --release -p aws-lc-sys --target aarch64-apple-ios-sim
   Compiling libc v0.2.146
   Compiling memchr v2.5.0
   Compiling regex-syntax v0.7.2
   Compiling syn v2.0.18
   Compiling nom v7.1.3
   Compiling which v4.4.0
   Compiling clang-sys v1.6.1
   Compiling regex v1.8.4
   Compiling cexpr v0.6.0
   Compiling prettyplease v0.2.6
   Compiling bindgen v0.65.1
   Compiling aws-lc-sys v0.7.0 (/Users/tomleavy/git/aws-lc-rs/aws-lc-sys)
error: failed to run custom build command for `aws-lc-sys v0.7.0 (/Users/tomleavy/git/aws-lc-rs/aws-lc-sys)`

Caused by:
  process didn't exit successfully: `/Users/tomleavy/git/aws-lc-rs/target/release/build/aws-lc-sys-e1e4be26c4b092ee/build-script-main` (exit status: 101)
  --- stdout
  cargo:rustc-cfg=use_bindgen_generated
  CMAKE_TOOLCHAIN_FILE_aarch64-apple-ios-sim = None
  CMAKE_TOOLCHAIN_FILE_aarch64_apple_ios_sim = None
  TARGET_CMAKE_TOOLCHAIN_FILE = None
  CMAKE_TOOLCHAIN_FILE = None
  CMAKE_GENERATOR_aarch64-apple-ios-sim = None
  CMAKE_GENERATOR_aarch64_apple_ios_sim = 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_aarch64-apple-ios-sim = None
  CMAKE_PREFIX_PATH_aarch64_apple_ios_sim = None
  TARGET_CMAKE_PREFIX_PATH = None
  CMAKE_PREFIX_PATH = None
  CMAKE_aarch64-apple-ios-sim = None
  CMAKE_aarch64_apple_ios_sim = None
  TARGET_CMAKE = None
  CMAKE = Some("cmake")
  running: cd "/Users/tomleavy/git/aws-lc-rs/target/aarch64-apple-ios-sim/release/build/aws-lc-sys-80b5c96041eaa31f/out/build" && CMAKE_PREFIX_PATH="" "cmake" "/Users/tomleavy/git/aws-lc-rs/aws-lc-sys" "-DCMAKE_BUILD_TYPE=release" "-DBORINGSSL_PREFIX=aws_lc_0_7_0" "-DBORINGSSL_PREFIX_HEADERS=/Users/tomleavy/git/aws-lc-rs/aws-lc-sys/generated-include" "-DBUILD_TESTING=OFF" "-DBUILD_LIBSSL=OFF" "-DDISABLE_PERL=ON" "-DDISABLE_GO=ON" "-DCMAKE_SYSTEM_NAME=iOS" "-DCMAKE_SYSTEM_PROCESSOR=arm64" "-DCMAKE_INSTALL_PREFIX=/Users/tomleavy/git/aws-lc-rs/target/aarch64-apple-ios-sim/release/build/aws-lc-sys-80b5c96041eaa31f/out" "-DCMAKE_C_FLAGS= -fPIC --target=arm64-apple-ios7.0-simulator -arch arm64 -mios-simulator-version-min=7.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.4.sdk -fembed-bitcode" "-DCMAKE_C_COMPILER=/usr/bin/clang" "-DCMAKE_CXX_FLAGS= -fPIC --target=arm64-apple-ios7.0-simulator -arch arm64 -mios-simulator-version-min=7.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.4.sdk -fembed-bitcode" "-DCMAKE_CXX_COMPILER=/usr/bin/clang++" "-DCMAKE_ASM_FLAGS= -fPIC --target=arm64-apple-ios7.0-simulator -arch arm64 -mios-simulator-version-min=7.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.4.sdk -fembed-bitcode" "-DCMAKE_ASM_COMPILER=/usr/bin/clang" "--no-warn-unused-cli"
  Not searching for unused variables given on the command line.
  -- The C compiler identification is AppleClang 14.0.3.14030022
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working C compiler: /usr/bin/clang - skipped
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Go not found. Disabling some code generation and using pre-generated code in generated-src/
  -- Perl not found. Disabling some code generation and using pre-generated code in generated-src/
  -- stdalign_check.c probe is negative, NOT enabling AWS_LC_STDALIGN_AVAILABLE:
  --     Change Dir: /Users/tomleavy/git/aws-lc-rs/target/aarch64-apple-ios-sim/release/build/aws-lc-sys-80b5c96041eaa31f/out/build/aws-lc/CMakeFiles/CMakeTmp

  Run Build Command(s):/opt/homebrew/Cellar/cmake/3.26.4/bin/cmake -E env VERBOSE=1 /usr/bin/make -f Makefile cmTC_114e5/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make  -f CMakeFiles/cmTC_114e5.dir/build.make CMakeFiles/cmTC_114e5.dir/build
  Building C object CMakeFiles/cmTC_114e5.dir/stdalign_check.c.o
  /usr/bin/clang   -fPIC --target=arm64-apple-ios7.0-simulator -arch arm64 -mios-simulator-version-min=7.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.4.sdk -fembed-bitcode -std=c99 -fvisibility=hidden -Wall -Wextra -Wno-unused-parameter -Werror -Wunused -Wcomment -Wchar-subscripts -Wuninitialized -Wshadow -Wwrite-strings -Wformat-security -Wunused-result  -Wvla -Wtype-limits -Werror -Wformat=2 -Wsign-compare -Wmissing-field-initializers -Wwrite-strings -ggdb -Wall -fvisibility=hidden -fno-common -Wnewline-eof -fcolor-diagnostics -Wstring-concatenation -Wimplicit-fallthrough -Wmissing-prototypes -Wold-style-definition -Wstrict-prototypes  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.4.sdk   -Werror -MD -MT CMakeFiles/cmTC_114e5.dir/stdalign_check.c.o -MF CMakeFiles/cmTC_114e5.dir/stdalign_check.c.o.d -o CMakeFiles/cmTC_114e5.dir/stdalign_check.c.o -c /Users/tomleavy/git/aws-lc-rs/aws-lc-sys/aws-lc/tests/compiler_features_tests/stdalign_check.c
  Linking C executable cmTC_114e5.app/cmTC_114e5
  /opt/homebrew/Cellar/cmake/3.26.4/bin/cmake -E cmake_link_script CMakeFiles/cmTC_114e5.dir/link.txt --verbose=1
  /usr/bin/clang  -fPIC --target=arm64-apple-ios7.0-simulator -arch arm64 -mios-simulator-version-min=7.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.4.sdk -fembed-bitcode -std=c99 -fvisibility=hidden -Wall -Wextra -Wno-unused-parameter -Werror -Wunused -Wcomment -Wchar-subscripts -Wuninitialized -Wshadow -Wwrite-strings -Wformat-security -Wunused-result  -Wvla -Wtype-limits -Werror -Wformat=2 -Wsign-compare -Wmissing-field-initializers -Wwrite-strings -ggdb -Wall -fvisibility=hidden -fno-common -Wnewline-eof -fcolor-diagnostics -Wstring-concatenation -Wimplicit-fallthrough -Wmissing-prototypes -Wold-style-definition -Wstrict-prototypes  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.4.sdk CMakeFiles/cmTC_114e5.dir/stdalign_check.c.o -o cmTC_114e5.app/cmTC_114e5
  ld: building for iOS Simulator, but linking in .tbd file (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.4.sdk/usr/lib/libSystem.tbd) built for iOS, file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.4.sdk/usr/lib/libSystem.tbd' for architecture arm64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  make[1]: *** [cmTC_114e5.app/cmTC_114e5] Error 1
  make: *** [cmTC_114e5/fast] Error 2


  -- builtin_swap_check.c probe is negative, NOT enabling AWS_LC_BUILTIN_SWAP_SUPPORTED:
  --     Change Dir: /Users/tomleavy/git/aws-lc-rs/target/aarch64-apple-ios-sim/release/build/aws-lc-sys-80b5c96041eaa31f/out/build/aws-lc/CMakeFiles/CMakeTmp

  Run Build Command(s):/opt/homebrew/Cellar/cmake/3.26.4/bin/cmake -E env VERBOSE=1 /usr/bin/make -f Makefile cmTC_44e7d/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make  -f CMakeFiles/cmTC_44e7d.dir/build.make CMakeFiles/cmTC_44e7d.dir/build
  Building C object CMakeFiles/cmTC_44e7d.dir/builtin_swap_check.c.o
  /usr/bin/clang   -fPIC --target=arm64-apple-ios7.0-simulator -arch arm64 -mios-simulator-version-min=7.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.4.sdk -fembed-bitcode -std=c99 -fvisibility=hidden -Wall -Wextra -Wno-unused-parameter -Werror -Wunused -Wcomment -Wchar-subscripts -Wuninitialized -Wshadow -Wwrite-strings -Wformat-security -Wunused-result  -Wvla -Wtype-limits -Werror -Wformat=2 -Wsign-compare -Wmissing-field-initializers -Wwrite-strings -ggdb -Wall -fvisibility=hidden -fno-common -Wnewline-eof -fcolor-diagnostics -Wstring-concatenation -Wimplicit-fallthrough -Wmissing-prototypes -Wold-style-definition -Wstrict-prototypes  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.4.sdk   -Werror -MD -MT CMakeFiles/cmTC_44e7d.dir/builtin_swap_check.c.o -MF CMakeFiles/cmTC_44e7d.dir/builtin_swap_check.c.o.d -o CMakeFiles/cmTC_44e7d.dir/builtin_swap_check.c.o -c /Users/tomleavy/git/aws-lc-rs/aws-lc-sys/aws-lc/tests/compiler_features_tests/builtin_swap_check.c
  Linking C executable cmTC_44e7d.app/cmTC_44e7d
  /opt/homebrew/Cellar/cmake/3.26.4/bin/cmake -E cmake_link_script CMakeFiles/cmTC_44e7d.dir/link.txt --verbose=1
  /usr/bin/clang  -fPIC --target=arm64-apple-ios7.0-simulator -arch arm64 -mios-simulator-version-min=7.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.4.sdk -fembed-bitcode -std=c99 -fvisibility=hidden -Wall -Wextra -Wno-unused-parameter -Werror -Wunused -Wcomment -Wchar-subscripts -Wuninitialized -Wshadow -Wwrite-strings -Wformat-security -Wunused-result  -Wvla -Wtype-limits -Werror -Wformat=2 -Wsign-compare -Wmissing-field-initializers -Wwrite-strings -ggdb -Wall -fvisibility=hidden -fno-common -Wnewline-eof -fcolor-diagnostics -Wstring-concatenation -Wimplicit-fallthrough -Wmissing-prototypes -Wold-style-definition -Wstrict-prototypes  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.4.sdk CMakeFiles/cmTC_44e7d.dir/builtin_swap_check.c.o -o cmTC_44e7d.app/cmTC_44e7d
  ld: building for iOS Simulator, but linking in .tbd file (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.4.sdk/usr/lib/libSystem.tbd) built for iOS, file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.4.sdk/usr/lib/libSystem.tbd' for architecture arm64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  make[1]: *** [cmTC_44e7d.app/cmTC_44e7d] Error 1
  make: *** [cmTC_44e7d/fast] Error 2


  -- The ASM compiler identification is Clang with GNU-like command-line
  -- Found assembler: /usr/bin/clang
  -- Disabling debug symbols for Clang internal assembler
  -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
  -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
  -- Looking for pthread_create in pthreads
  -- Looking for pthread_create in pthreads - not found
  -- Looking for pthread_create in pthread
  -- Looking for pthread_create in pthread - not found
  -- Check if compiler accepts -pthread
  -- Check if compiler accepts -pthread - no
  -- Configuring incomplete, errors occurred!

  --- stderr
  Copying platform assembly files from /Users/tomleavy/git/aws-lc-rs/aws-lc-sys/aws-lc/generated-src/ios-aarch64/crypto/ to /Users/tomleavy/git/aws-lc-rs/target/aarch64-apple-ios-sim/release/build/aws-lc-sys-80b5c96041eaa31f/out/build/aws-lc/crypto
  CMake Error at /opt/homebrew/Cellar/cmake/3.26.4/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
    Could NOT find Threads (missing: Threads_FOUND)
  Call Stack (most recent call first):
    /opt/homebrew/Cellar/cmake/3.26.4/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
    /opt/homebrew/Cellar/cmake/3.26.4/share/cmake/Modules/FindThreads.cmake:226 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
    aws-lc/crypto/CMakeLists.txt:623 (find_package)


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

  build script failed, must exit now', /Users/tomleavy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cmake-0.1.50/src/lib.rs:1098:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@justinwsmith
Copy link
Contributor

justinwsmith commented Jun 15, 2023

Hi Tom! I was able to reproduce this error on my M1 Mac and managed to hack the build script to make it work.

aws-lc-rs on  iOS-hack [?] via 🦀 v1.70.0 
❯ cargo build -p aws-lc-rs --target aarch64-apple-ios-sim
   Compiling libc v0.2.146
...
   Compiling aws-lc-sys v0.7.0 (/Users/justin/repos/aws-lc-rs/aws-lc-sys)
    Finished dev [unoptimized + debuginfo] target(s) in 15.87s

Although aws-lc-rs doesn't currently support iOS officially, I hope we can add it soon.

@justsmth justsmth added the enhancement New feature or request label Jun 15, 2023
@justsmth
Copy link
Contributor

As of this PR, we run our tests on aarch64-apple-ios-sim as part of our CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants