Kyle-Ye
(Kyle)
January 23, 2024, 6:36am
1
Bug reproduce step:
Add a C target define uint32 as a struct
typedef uint32_t CAttribute __attribute((swift_newtype(struct)));
import the C module and use the type in our Swift code. If we add Equatable
to our Swift type and have import Foundation
statement in the same module, we'll get a compiler crash here.
import CDemoKit
import Foundation
public struct Demo {
var attribute: CAttribute
}
extension Demo: Equatable {}
Comment on Line 2 or Line 7 will not crash the compiler.
Cannot look up associated type for imported conformance:
(struct_type decl=CDemoKit.(file).CAttribute)
(associated_type_decl "_ObjectiveCType" access=public overridden=)
See full crash log and reproduce DemoKit package on this GitHub issue
Kyle-Ye
(Kyle)
January 23, 2024, 7:06am
2
Besides this stable reproducible issue mentioned here, I've also encountered a lot of other ObjectiveC related compiler crash on Linux.
On other platforms, such as Linux, no Objective-C runtime is present, because it isn’t necessary.
Reading Platform Support on swift.org again, I noticed it said unnecessary to include ObjC on Linux instead of impossible. Wondering if we can just provide a full ObjC supported Swift on Linux so that we'll never meet so many annoying diff behaviors and compilers crash on non-Darwin platform.
mickeyl
(Dr. Mickey Lauer)
January 23, 2024, 2:32pm
3
And who is going provide that? Apple won't, they're keeping a tight lock on Objective-C and even more so on swift-corelibs-foundation (up to rejecting perfectly fine fixes from the community). Instead we will eventually get the rewritten (but rudimentary) new Swift Foundation...
Kyle-Ye
(Kyle)
January 23, 2024, 3:48pm
4
I do not know. Maybe Apple can provide it. Or at least we should not see any confusion ObjC related compiler crash on Linux.
Kyle-Ye
(Kyle)
March 30, 2024, 3:05am
5
Tried Remove an old restriction on `_ObjectiveCBridgeable` conformances. by DougGregor · Pull Request #71426 · apple/swift · GitHub via the latest toolchain installed by swiftly
, it will produce the following error message.
swiftly install 6.0-snapshot-2024-03-21
➜ DemoKit swift build
error: 'demokit': Invalid manifest (compiled with: ["/home/kyle/.local/bin/swiftc", "-vfsoverlay", "/tmp/TemporaryDirectory.WRxElB/vfs.yaml", "-L", "/home/kyle/.local/bin", "-lPackageDescription", "-Xlinker", "-rpath", "-Xlinker", "/home/kyle/.local/bin", "-swift-version", "5", "-I", "/home/kyle/.local/bin", "-package-description-version", "5.9.0", "/home/kyle/DemoKit/Package.swift", "-Xfrontend", "-disable-implicit-concurrency-module-import", "-Xfrontend", "-disable-implicit-string-processing-module-import", "-o", "/tmp/TemporaryDirectory.ROiOkX/demokit-manifest"])
/home/kyle/DemoKit/Package.swift:4:8: error: no such module 'PackageDescription'
2 │ // The swift-tools-version declares the minimum version of Swift required to build this package.
3 │
4 │ import PackageDescription
│ ╰─ error: no such module 'PackageDescription'
5 │
6 │ let package = Package(
Is there something wrong with swiftly
or swift 6.0 snapshot
?
Kyle-Ye
(Kyle)
April 1, 2024, 6:24am
6
Finally build a local Swift toolchain to get the backtrace here.
export LLVM_SYMBOLIZER_PATH=/home/kyle/swift-project/build/buildbot_linux/llvm-linux-aarch64/bin/llvm-symbolizer
kyle@builder:~/DemoKit$ SWIFT_EXEC=/home/kyle/swift-nightly-install/usr/bin/swiftc swift build
Building for debugging...
error: emit-module command failed due to signal 6 (use -v to see invocation)
error: compile command failed due to signal 6 (use -v to see invocation)
Cannot look up associated type for imported conformance:
(struct_type decl=CDemoKit.(file).CAttribute)
(associated_type_decl "_ObjectiveCType" access=public overridden=)
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0. Program arguments: /home/kyle/swift-nightly-install/usr/bin/swift-frontend -frontend -emit-module -experimental-skip-non-inlinable-function-bodies-without-types /home/kyle/DemoKit/Sources/DemoKit/DemoKit.swift -target aarch64-unknown-linux-gnu -Xllvm -aarch64-use-tbi -disable-objc-interop -I /home/kyle/DemoKit/.build/aarch64-unknown-linux-gnu/debug -color-diagnostics -enable-testing -g -module-cache-path /home/kyle/DemoKit/.build/aarch64-unknown-linux-gnu/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -new-driver-path /home/kyle/swift-nightly-install/usr/bin/swift-driver -empty-abi-descriptor -resource-dir /home/kyle/swift-nightly-install/usr/lib/swift -enable-anonymous-context-mangled-names -Xcc -fmodule-map-file=/home/kyle/DemoKit/.build/aarch64-unknown-linux-gnu/debug/CDemoKit.build/module.modulemap -Xcc -I -Xcc /home/kyle/DemoKit/Sources/CDemoKit/include -Xcc -fPIC -Xcc -g -Xcc -fno-omit-frame-pointer -module-name DemoKit -package-name demokit -plugin-path /home/kyle/swift-nightly-install/usr/lib/swift/host/plugins -plugin-path /home/kyle/swift-nightly-install/usr/local/lib/swift/host/plugins -emit-module-doc-path /home/kyle/DemoKit/.build/aarch64-unknown-linux-gnu/debug/DemoKit.swiftdoc -emit-module-source-info-path /home/kyle/DemoKit/.build/aarch64-unknown-linux-gnu/debug/DemoKit.swiftsourceinfo -emit-dependencies-path /home/kyle/DemoKit/.build/aarch64-unknown-linux-gnu/debug/DemoKit.build/DemoKit.emit-module.d -parse-as-library -o /home/kyle/DemoKit/.build/aarch64-unknown-linux-gnu/debug/DemoKit.swiftmodule
1. Swift version 5.10-dev (LLVM 5dc9d563e5a6cd2, Swift 17ca88c94a34b34)
2. Compiling with the current language version
3. While evaluating request ASTLoweringRequest(Lowering AST to SIL for module DemoKit)
4. While generating SIL witness table protocol conformance to '_ObjectiveCBridgeable' (in module 'Swift') for type 'CAttribute'
5. While completing import of protocol conformance to '_ObjectiveCBridgeable' (in module 'Swift') for type 'CAttribute'
#0 0x0000aaaaed669580 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/kyle/swift-nightly-install/usr/bin/swift-frontend+0x5a99580)
#1 0x0000aaaaed6677a8 llvm::sys::RunSignalHandlers() (/home/kyle/swift-nightly-install/usr/bin/swift-frontend+0x5a977a8)
#2 0x0000aaaaed66999c SignalHandler(int) Signals.cpp:0:0
#3 0x0000ffff8afbc860 (linux-vdso.so.1+0x860)
#4 0x0000ffff896cf200 (/lib/aarch64-linux-gnu/libc.so.6+0x7f200)
#5 0x0000ffff8968a67c gsignal (/lib/aarch64-linux-gnu/libc.so.6+0x3a67c)
#6 0x0000ffff89677130 abort (/lib/aarch64-linux-gnu/libc.so.6+0x27130)
#7 0x0000aaaae99938a4 non-virtual thunk to swift::ClangImporter::Implementation::finishNormalConformance(swift::NormalProtocolConformance*, unsigned long) crtstuff.c:0:0
#8 0x0000aaaae9db5778 swift::NormalProtocolConformance::getTypeWitnessAndDecl(swift::AssociatedTypeDecl*, swift::SubstOptions) const (/home/kyle/swift-nightly-install/usr/bin/swift-frontend+0x21e5778)
#9 0x0000aaaae9db55bc swift::ProtocolConformance::getTypeWitnessAndDecl(swift::AssociatedTypeDecl*, swift::SubstOptions) const (/home/kyle/swift-nightly-install/usr/bin/swift-frontend+0x21e55bc)
#10 0x0000aaaae9db5c4c swift::ProtocolConformance::getTypeWitness(swift::AssociatedTypeDecl*, swift::SubstOptions) const (/home/kyle/swift-nightly-install/usr/bin/swift-frontend+0x21e5c4c)
#11 0x0000aaaae8e1799c swift::SILWitnessVisitor<(anonymous namespace)::SILGenConformance>::visitProtocolDecl(swift::ProtocolDecl*) SILGenType.cpp:0:0
#12 0x0000aaaae8e155a0 swift::Lowering::SILGenModule::getWitnessTable(swift::NormalProtocolConformance*) crtstuff.c:0:0
#13 0x0000aaaae8d7f9a0 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const (/home/kyle/swift-nightly-install/usr/bin/swift-frontend+0x11af9a0)
#14 0x0000aaaae8e0ad48 std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule>> swift::SimpleRequest<swift::ASTLoweringRequest, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule>> (swift::ASTLoweringDescriptor), (swift::RequestFlags)9>::callDerived<0ul>(swift::Evaluator&, std::integer_sequence<unsigned long, 0ul>) const crtstuff.c:0:0
#15 0x0000aaaae8d81c68 llvm::Expected<swift::ASTLoweringRequest::OutputType> swift::Evaluator::getResultUncached<swift::ASTLoweringRequest>(swift::ASTLoweringRequest const&) crtstuff.c:0:0
#16 0x0000aaaae8d7fa70 swift::performASTLowering(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions const&, swift::IRGenOptions const*) (/home/kyle/swift-nightly-install/usr/bin/swift-frontend+0x11afa70)
#17 0x0000aaaae881f4c8 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) (/home/kyle/swift-nightly-install/usr/bin/swift-frontend+0xc4f4c8)
#18 0x0000aaaae8822190 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) FrontendTool.cpp:0:0
#19 0x0000aaaae8820d00 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/home/kyle/swift-nightly-install/usr/bin/swift-frontend+0xc50d00)
#20 0x0000aaaae86f7ccc swift::mainEntry(int, char const**) (/home/kyle/swift-nightly-install/usr/bin/swift-frontend+0xb27ccc)
#21 0x0000ffff896773fc (/lib/aarch64-linux-gnu/libc.so.6+0x273fc)
#22 0x0000ffff896774cc __libc_start_main (/lib/aarch64-linux-gnu/libc.so.6+0x274cc)
#23 0x0000aaaae86f6c30 _start (/home/kyle/swift-nightly-install/usr/bin/swift-frontend+0xb26c30)
Is there any guide help me debug the compiler on Linux platform? The guide on GettingStarted.md
looks a little unclear for me.