Compile very simple code but with large array static initialization:
let array: [Foo] = [
.init(....),
// thousands .init here
]
compile took a very long time (why such long compile time for this?) and ends with:
swiftc containfilter.swift
:0: remark: did not find a prebuilt standard library for target 'x86_64-apple-macos' compatible with this Swift compiler; building it may take a few minutes, but it should only happen once for this combination of compiler and target
swiftc --version
Apple Swift version 5.6 (swiftlang-5.6.0.323.62 clang-1316.0.20.8)
the swiftc
actually produce an executable output, but running it prints:
zsh: segmentation fault
when this same very large array code is compile as part of Xcode(Version 13.3 (13E113)) SwiftUI project, compile also takes a very long time and sometimes fail with:
but most of time compile fine.
command line swiftc compile this is fine:
print("Hello")
what's wrong? how to fix?
My code: https://gist.github.com/mattyoung/883142efa0705429dd3964aff20441fb
Edit: compiler should not produce executable that seg fault. I file a bug: [SR-16086] Command line swiftc compile executable segmentation fault · Issue #58345 · apple/swift · GitHub