Building libSwiftDemangle.a for arm64

Hey all, having a hell of a time trying to build the static libSwiftDemangle.a framework to build for both arm64 and x86_64. I can build it just fine for x86_64, but ARM64 has been a major PitA

What I've done:

update-checkout  --clone-with-ssh  --tag swift-5.1.4-RELEASE

And tried to compile with various permutations leading up to this monstrosity:

build-script  --maccatalyst=1 --stdlib-deployment-targets="iphoneos-arm64"  --build-stdlib-deployment-targets="iphoneos-arm64" -r   --skip-test-ios=1   --skip-test-ios-32bit-simulator=1 --llvm-targets-to-build="AArch64;X86" --skip-build-watchos=1   --skip-build-tvos=1   --skip-build-linux=1   --skip-build-benchmarks=1   --skip-test-playgroundsupport=1   --skip-build-cygwin=1   --skip-build-freebsd=1   --build-swift-static-sdk-overlay=1  --build-swift-static-stdlib=1   -i --skip-build-ios-simulator=1   --cross-compile-hosts="iphoneos-arm64"  --llvm-targets-to-build="X86;AArch64"

Which then will eventually give me these errors:

-- Configuring done
CMake Error at /Users/lolgrep/code/dsdump/llvm-project/llvm/cmake/modules/AddLLVM.cmake:738 (add_executable):
  Error evaluating generator expression:

    $<TARGET_OBJECTS:swiftRuntime-macosx-x86_64>

  Objects of target "swiftRuntime-macosx-x86_64" referenced but no such
  target exists.
Call Stack (most recent call first):
  /Users/lolgrep/code/dsdump/llvm-project/llvm/cmake/modules/AddLLVM.cmake:1112 (add_llvm_executable)
  cmake/modules/AddSwiftUnittests.cmake:11 (add_unittest)
  unittests/runtime/CMakeLists.txt:64 (add_swift_unittest)


CMake Error at /Users/lolgrep/code/dsdump/llvm-project/llvm/cmake/modules/AddLLVM.cmake:738 (add_executable):
  Error evaluating generator expression:

    $<TARGET_OBJECTS:swiftRuntime-macosx-x86_64>

  Objects of target "swiftRuntime-macosx-x86_64" referenced but no such
  target exists.
Call Stack (most recent call first):
  /Users/lolgrep/code/dsdump/llvm-project/llvm/cmake/modules/AddLLVM.cmake:1112 (add_llvm_executable)
  cmake/modules/AddSwiftUnittests.cmake:11 (add_unittest)
  unittests/runtime/LongTests/CMakeLists.txt:32 (add_swift_unittest)


CMake Error at /Users/lolgrep/code/dsdump/llvm-project/llvm/cmake/modules/AddLLVM.cmake:738 (add_executable):
  No SOURCES given to target: SwiftRuntimeTests
Call Stack (most recent call first):
  /Users/lolgrep/code/dsdump/llvm-project/llvm/cmake/modules/AddLLVM.cmake:1112 (add_llvm_executable)
  cmake/modules/AddSwiftUnittests.cmake:11 (add_unittest)
  unittests/runtime/CMakeLists.txt:64 (add_swift_unittest)


CMake Error at /Users/lolgrep/code/dsdump/llvm-project/llvm/cmake/modules/AddLLVM.cmake:738 (add_executable):
  No SOURCES given to target: SwiftRuntimeLongTests
Call Stack (most recent call first):
  /Users/lolgrep/code/dsdump/llvm-project/llvm/cmake/modules/AddLLVM.cmake:1112 (add_llvm_executable)
  cmake/modules/AddSwiftUnittests.cmake:11 (add_unittest)
  unittests/runtime/LongTests/CMakeLists.txt:32 (add_swift_unittest)


-- Build files have been written to: /Users/lolgrep/code/dsdump/build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64
ERROR: command terminated with a non-zero exit status 1, aborting
  1. I've tried so many different permutations wanting to compile swift for an iphoneos-arm64 target (specifically the libSwiftDemangle.a static lib), but I am at the point where I need help. What's the best or fastest way to do this? Do I need to modify the CMakeLists.txt? Do I need to add some missing arguments so LLVM can play nice?

  2. The libSwiftDemangle.a source code can be found in swift-source/lib directory. I am wondering what subcomponent of Swift will build all these components in this directory. For example, in the build-script documentation I see all these compile options for stdlib, which I can assume correlates to swift-source/stdlib files, but what compile name correlates to the lib directory?

did you fix that? I have the same error

@uuttff8 heh, yeah. Fixed it by buying an M1 Mac and creating a tool to change around a platform Exchange Mach-O platform types with min version ยท GitHub

Super straightforward