Swift build problem x86_64, arm64, arm7 (Swift 5.1)

When I trying build swift, I got the next error message:

Undefined symbols for architecture x86_64:
  "___isOSVersionAtLeast", referenced from:
      swift::initializeProtocolLookup() in ImageInspectionMachO.cpp.o
      swift::initializeProtocolConformanceLookup() in ImageInspectionMachO.cpp.o
      swift::initializeTypeMetadataRecordLookup() in ImageInspectionMachO.cpp.o
      swift::initializeDynamicReplacementLookup() in ImageInspectionMachO.cpp.o
ld: symbol(s) not found for architecture x86_64
clang-7: error: linker command failed with exit code 1 (use -v to see invocation)
[5/19][ 26%][7.760s] Building CXX object tools/SourceKit/lib/SwiftLang/CMakeFiles/SourceKitSwiftLang.dir/SwiftTypeContextInfo.cpp.o
ninja: build stopped: subcommand failed.
swift/utils/build-script: fatal error: command terminated with a non-zero exit status 1, aborting

The same message I got for arm64 and arm7.
In llvm I see clang version 7.0.0 without lib folder (only include dir).

Please help me :slight_smile:

I've seen this problem. I'm not sure how I fixed it aside from starting over from a clean build. If you have compiler-rt checked out (via swift/utils/update-checkout --clone), then when llvm builds (via build-script) it should populate this build directory: llvm-macosx-x86_64/tools/clang/runtime/compiler-rt-bins/lib/builtins. Those libclang_rt libraries define ___isOSVersionAtLeast. I'm currently building with 11 beta 5, 11M382q.

1 Like

If clang is able to statically infer that the OS is going to be new enough, it will statically eliminate the calls, resulting in the reference being removed. I don't have a macOS build handy, but it is possible that the OS version is being cached and resulting in an incorrect parameter to clang and creating a dynamic check.

1 Like