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

Compiler crash specializing generics #78167

Closed
TeamPuzel opened this issue Dec 13, 2024 · 4 comments
Closed

Compiler crash specializing generics #78167

TeamPuzel opened this issue Dec 13, 2024 · 4 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software generics Feature: generic declarations and types SIL SILOptimizer Area → compiler: SIL optimization passes

Comments

@TeamPuzel
Copy link

Description

The copy method seems to be at fault. It works fine if converted to use a concrete Image and flattening in the convenience initializer instead of directly taking an arbitrary Drawable. This is the first time I had such an issue with the Drawable protocol.

Reproduction

The source code is available here, and the link should point to a commit where I reintroduced the bug for this bug report

https://gitea.com/TeamPuzel/BlockGameSwift/commit/e521f5337f458a20a1e4a7178542a391e7219b3a

This is the class in question

public final class Texture {
    private let id: GLuint
    public var unit: GLuint

    public init(_ unit: GLuint = 0) {
        var id: GLuint = 0
        glad_glGenTextures(1, &id)

        self.id = id
        self.unit = unit
    }

    public func copy(_ drawable: some Drawable) {
        self.bind()
        
        let image = drawable.flatten()

        image.data.withUnsafeBytes { ptr in
            glad_glTexImage2D(
                GLenum(GL_TEXTURE_2D),
                0,
                GL_RGBA,
                GLsizei(image.width),
                GLsizei(image.height),
                0,
                GLenum(GL_RGBA),
                GLenum(GL_UNSIGNED_BYTE),
                ptr.baseAddress
            )
        }

        glad_glTexParameteri(GLenum(GL_TEXTURE_2D), GLenum(GL_TEXTURE_MIN_FILTER), GL_NEAREST)
        glad_glTexParameteri(GLenum(GL_TEXTURE_2D), GLenum(GL_TEXTURE_MAG_FILTER), GL_NEAREST)
        glad_glTexParameteri(GLenum(GL_TEXTURE_2D), GLenum(GL_TEXTURE_WRAP_S), GL_CLAMP_TO_EDGE)
        glad_glTexParameteri(GLenum(GL_TEXTURE_2D), GLenum(GL_TEXTURE_WRAP_T), GL_CLAMP_TO_EDGE)
    }

    public convenience init(_ unit: GLuint = 0, drawable: some Drawable) {
        self.init()
        self.copy(drawable.flatten())
    }

    deinit {
        withUnsafePointer(to: self.id) { id in
            glad_glDeleteTextures(1, id)
        }
    }

    func bind() {
        glad_glActiveTexture(UInt32(GL_TEXTURE0) + self.unit)
        glad_glBindTexture(GLenum(GL_TEXTURE_2D), self.id)
    }
}

This is the flatten signature in case it is relevant, as it is somewhat unusual

public extension Drawable {
    /// Shorthand for flattening a nested structure of lazy drawables into a trivial image, for
    /// cases where using memory and losing information is preferable to repeatedly recomputing all layers.
    ///
    /// This method is a convenience and overloads the generic version of this function in cases where
    /// an explicit type is not provided, since an `Image` is the most primitive of drawables.
    /// It is the equivalent of calling `flatten(into: Image.self)`.
    @_disfavoredOverload func flatten() -> Image { .init(self) }
    /// Shorthand for flattening a nested structure of lazy drawables into a primitive drawable, for
    /// cases where using memory and losing information is preferable to repeatedly recomputing all layers.
    ///
    /// This overload allows specifying the type in the middle of a method chain.
    func flatten<T>(into type: T.Type) -> T where T: PrimitiveDrawable { .init(self) }
    /// Shorthand for flattening a nested structure of lazy drawables into a primitive drawable, for
    /// cases where using memory and losing information is preferable to repeatedly recomputing all layers.
    ///
    /// This overload is used when inferring the return type.
    func flatten<T>() -> T where T: PrimitiveDrawable { .init(self) }
}

Stack dump

FAILED: Engine.swiftmodule CMakeFiles/Engine.dir/src/Engine/Context.swift.o CMakeFiles/Engine.dir/src/Engine/Game.swift.o CMakeFiles/Engine.dir/src/Engine/OpenGL.swift.o 
/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swiftc -j 12 -num-threads 12 -c  -parse-as-library -static -emit-module -emit-module-path Engine.swiftmodule -module-name Engine -module-link-name Engine -parse-as-library -wmo    -enable-experimental-feature BuiltinModule    -enable-experimental-feature Extern    -enable-experimental-feature Embedded    -Xcc -fmodule-map-file=/Users/teampuzel/Minecraft/lib/SDL3/module.modulemap    -Xcc -fmodule-map-file=/Users/teampuzel/Minecraft/lib/glad/include/module.modulemap -Onone -g -swift-version 6 -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk -incremental -color-diagnostics -F /Library/Frameworks/SDL3.xcframework/macos-arm64_x86_64 -output-file-map CMakeFiles/Engine.dir/Debug/output-file-map.json -I /Users/teampuzel/Minecraft/build/debug -I /Users/teampuzel/Minecraft/lib/glad/include -F /Library/Frameworks/SDL3.xcframework/macos-arm64_x86_64 /Users/teampuzel/Minecraft/src/Engine/Context.swift /Users/teampuzel/Minecraft/src/Engine/Game.swift /Users/teampuzel/Minecraft/src/Engine/OpenGL.swift
remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
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)
Assertion failed: (Specialization->isExternalDeclaration() && "Specialization should be a public external declaration"), function lookupPrespecializedSymbol, file Generics.cpp, line 3604.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swift-frontend -frontend -emit-module -experimental-skip-non-inlinable-function-bodies-without-types /Users/teampuzel/Minecraft/src/Engine/Context.swift /Users/teampuzel/Minecraft/src/Engine/Game.swift /Users/teampuzel/Minecraft/src/Engine/OpenGL.swift -target arm64-apple-macosx15.0 -Xllvm -aarch64-use-tbi -disable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk -I /Users/teampuzel/Minecraft/build/debug -I /Users/teampuzel/Minecraft/lib/glad/include -F /Library/Frameworks/SDL3.xcframework/macos-arm64_x86_64 -F /Library/Frameworks/SDL3.xcframework/macos-arm64_x86_64 -color-diagnostics -g -debug-info-format=dwarf -dwarf-version=5 -module-link-name Engine -static -swift-version 6 -Onone -enable-experimental-feature BuiltinModule -enable-experimental-feature Extern -enable-experimental-feature Embedded -empty-abi-descriptor -resource-dir /Library/Developer/Toolchains/swift-latest.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -file-compilation-dir /Users/teampuzel/Minecraft/build/debug -Xcc -fmodule-map-file=/Users/teampuzel/Minecraft/lib/SDL3/module.modulemap -Xcc -fmodule-map-file=/Users/teampuzel/Minecraft/lib/glad/include/module.modulemap -module-name Engine -in-process-plugin-server-path /Library/Developer/Toolchains/swift-latest.xctoolchain/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Library/Developer/Toolchains/swift-latest.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Library/Developer/Toolchains/swift-latest.xctoolchain/usr/local/lib/swift/host/plugins -target-sdk-version 15.2 -target-sdk-name macosx15.2 -external-plugin-path /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -emit-module-doc-path Engine.swiftdoc -emit-module-source-info-path Engine.swiftsourceinfo -parse-as-library -o Engine.swiftmodule -emit-abi-descriptor-path Engine.abi.json
1.	Apple Swift version 6.2-dev (LLVM 4930d5a55e7728b, Swift ec5bee8bc94399a)
2.	Compiling with the current language version
3.	While evaluating request ExecuteSILPipelineRequest(Run pipelines { Non-Diagnostic Mandatory Optimizations, Serialization, Rest of Onone } on SIL for Engine)
4.	While running pass #4837 SILModuleTransform "UsePrespecialized".
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x0000000108c5ce60 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000108c5b544 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000108c5d4bc SignalHandler(int) + 304
3  libsystem_platform.dylib 0x000000018f7f6e04 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000018f7bff70 pthread_kill + 288
5  libsystem_c.dylib        0x000000018f6cc908 abort + 128
6  libsystem_c.dylib        0x000000018f6cbc1c err + 0
7  swift-frontend           0x0000000108f7cca0 swift::lookupPrespecializedSymbol(swift::SILModule&, llvm::StringRef) (.cold.2) + 0
8  swift-frontend           0x0000000103d7e174 swift::lookupPrespecializedSymbol(swift::SILModule&, llvm::StringRef) + 832
9  swift-frontend           0x0000000103a21f30 (anonymous namespace)::UsePrespecialized::run() + 1676
10 swift-frontend           0x0000000103bad7e8 swift::SILPassManager::runModulePass(unsigned int) + 856
11 swift-frontend           0x0000000103bafbe8 swift::SILPassManager::execute() + 624
12 swift-frontend           0x0000000103baa4bc swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 72
13 swift-frontend           0x0000000103baa43c swift::ExecuteSILPipelineRequest::evaluate(swift::Evaluator&, swift::SILPipelineExecutionDescriptor) const + 68
14 swift-frontend           0x0000000103bfadb8 swift::SimpleRequest<swift::ExecuteSILPipelineRequest, std::__1::tuple<> (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1>::evaluateRequest(swift::ExecuteSILPipelineRequest const&, swift::Evaluator&) + 28
15 swift-frontend           0x0000000103bc7358 swift::ExecuteSILPipelineRequest::OutputType swift::Evaluator::getResultUncached<swift::ExecuteSILPipelineRequest, swift::ExecuteSILPipelineRequest::OutputType swift::evaluateOrFatal<swift::ExecuteSILPipelineRequest>(swift::Evaluator&, swift::ExecuteSILPipelineRequest)::'lambda'()>(swift::ExecuteSILPipelineRequest const&, swift::ExecuteSILPipelineRequest::OutputType swift::evaluateOrFatal<swift::ExecuteSILPipelineRequest>(swift::Evaluator&, swift::ExecuteSILPipelineRequest)::'lambda'()) + 204
16 swift-frontend           0x0000000103baa698 swift::executePassPipelinePlan(swift::SILModule*, swift::SILPassPipelinePlan const&, bool, swift::irgen::IRGenModule*) + 64
17 swift-frontend           0x0000000103bdd2c4 swift::runSILPassesForOnone(swift::SILModule&) + 80
18 swift-frontend           0x000000010338b700 swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 260
19 swift-frontend           0x000000010313aa78 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 820
20 swift-frontend           0x000000010313a334 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1228
21 swift-frontend           0x0000000103146774 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 160
22 swift-frontend           0x000000010313bfd0 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 716
23 swift-frontend           0x000000010313b69c swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2328
24 swift-frontend           0x0000000102f0ed0c swift::mainEntry(int, char const**) + 3100
25 dyld                     0x000000018f440274 start + 2840
Assertion failed: (Specialization->isExternalDeclaration() && "Specialization should be a public external declaration"), function lookupPrespecializedSymbol, file Generics.cpp, line 3604.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swift-frontend -frontend -c /Users/teampuzel/Minecraft/src/Engine/Context.swift /Users/teampuzel/Minecraft/src/Engine/Game.swift /Users/teampuzel/Minecraft/src/Engine/OpenGL.swift -supplementary-output-file-map /var/folders/tf/zch6121s4wd8hv092csrhrth0000gn/T/TemporaryDirectory.lFj2QH/supplementaryOutputs-1 -target arm64-apple-macosx15.0 -Xllvm -aarch64-use-tbi -disable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk -I /Users/teampuzel/Minecraft/build/debug -I /Users/teampuzel/Minecraft/lib/glad/include -F /Library/Frameworks/SDL3.xcframework/macos-arm64_x86_64 -F /Library/Frameworks/SDL3.xcframework/macos-arm64_x86_64 -color-diagnostics -g -debug-info-format=dwarf -dwarf-version=5 -module-link-name Engine -static -swift-version 6 -Onone -enable-experimental-feature BuiltinModule -enable-experimental-feature Extern -enable-experimental-feature Embedded -empty-abi-descriptor -resource-dir /Library/Developer/Toolchains/swift-latest.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -file-compilation-dir /Users/teampuzel/Minecraft/build/debug -Xcc -fmodule-map-file=/Users/teampuzel/Minecraft/lib/SDL3/module.modulemap -Xcc -fmodule-map-file=/Users/teampuzel/Minecraft/lib/glad/include/module.modulemap -module-name Engine -in-process-plugin-server-path /Library/Developer/Toolchains/swift-latest.xctoolchain/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Library/Developer/Toolchains/swift-latest.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Library/Developer/Toolchains/swift-latest.xctoolchain/usr/local/lib/swift/host/plugins -target-sdk-version 15.2 -target-sdk-name macosx15.2 -external-plugin-path /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -parse-as-library -num-threads 12 -o CMakeFiles/Engine.dir/src/Engine/Context.swift.o -o CMakeFiles/Engine.dir/src/Engine/Game.swift.o -o CMakeFiles/Engine.dir/src/Engine/OpenGL.swift.o
1.	Apple Swift version 6.2-dev (LLVM 4930d5a55e7728b, Swift ec5bee8bc94399a)
2.	Compiling with the current language version
3.	While evaluating request ExecuteSILPipelineRequest(Run pipelines { Non-Diagnostic Mandatory Optimizations, Serialization, Rest of Onone } on SIL for Engine)
4.	While running pass #4837 SILModuleTransform "UsePrespecialized".
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x000000010aa9ce60 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x000000010aa9b544 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x000000010aa9d4bc SignalHandler(int) + 304
3  libsystem_platform.dylib 0x000000018f7f6e04 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000018f7bff70 pthread_kill + 288
5  libsystem_c.dylib        0x000000018f6cc908 abort + 128
6  libsystem_c.dylib        0x000000018f6cbc1c err + 0
7  swift-frontend           0x000000010adbcca0 swift::lookupPrespecializedSymbol(swift::SILModule&, llvm::StringRef) (.cold.2) + 0
8  swift-frontend           0x0000000105bbe174 swift::lookupPrespecializedSymbol(swift::SILModule&, llvm::StringRef) + 832
9  swift-frontend           0x0000000105861f30 (anonymous namespace)::UsePrespecialized::run() + 1676
10 swift-frontend           0x00000001059ed7e8 swift::SILPassManager::runModulePass(unsigned int) + 856
11 swift-frontend           0x00000001059efbe8 swift::SILPassManager::execute() + 624
12 swift-frontend           0x00000001059ea4bc swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 72
13 swift-frontend           0x00000001059ea43c swift::ExecuteSILPipelineRequest::evaluate(swift::Evaluator&, swift::SILPipelineExecutionDescriptor) const + 68
14 swift-frontend           0x0000000105a3adb8 swift::SimpleRequest<swift::ExecuteSILPipelineRequest, std::__1::tuple<> (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1>::evaluateRequest(swift::ExecuteSILPipelineRequest const&, swift::Evaluator&) + 28
15 swift-frontend           0x0000000105a07358 swift::ExecuteSILPipelineRequest::OutputType swift::Evaluator::getResultUncached<swift::ExecuteSILPipelineRequest, swift::ExecuteSILPipelineRequest::OutputType swift::evaluateOrFatal<swift::ExecuteSILPipelineRequest>(swift::Evaluator&, swift::ExecuteSILPipelineRequest)::'lambda'()>(swift::ExecuteSILPipelineRequest const&, swift::ExecuteSILPipelineRequest::OutputType swift::evaluateOrFatal<swift::ExecuteSILPipelineRequest>(swift::Evaluator&, swift::ExecuteSILPipelineRequest)::'lambda'()) + 204
16 swift-frontend           0x00000001059ea698 swift::executePassPipelinePlan(swift::SILModule*, swift::SILPassPipelinePlan const&, bool, swift::irgen::IRGenModule*) + 64
17 swift-frontend           0x0000000105a1d2c4 swift::runSILPassesForOnone(swift::SILModule&) + 80
18 swift-frontend           0x00000001051cb700 swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 260
19 swift-frontend           0x0000000104f7aa78 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 820
20 swift-frontend           0x0000000104f7a334 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1228
21 swift-frontend           0x0000000104f86774 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 160
22 swift-frontend           0x0000000104f7bfd0 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 716
23 swift-frontend           0x0000000104f7b69c swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2328
24 swift-frontend           0x0000000104d4ed0c swift::mainEntry(int, char const**) + 3100
25 dyld                     0x000000018f440274 start + 2840
ninja: build stopped: subcommand failed.

Expected behavior

The compiler should not crash.

Environment

Apple Swift version 6.2-dev (LLVM 4930d5a55e7728b, Swift ec5bee8bc94399a)
Target: arm64-apple-macosx15.0

I tested with an older toolchain I have installed, swift-DEVELOPMENT-SNAPSHOT-2024-10-30-a which still crashes

Additional information

Relevant forum issue https://forums.swift.org/t/swift-has-no-ide-support-not-even-xcode-works/76508/36

Previous related bug #78150

@TeamPuzel TeamPuzel added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software triage needed This issue needs more specific labels labels Dec 13, 2024
@MaxDesiatov MaxDesiatov added SILOptimizer Area → compiler: SIL optimization passes generics Feature: generic declarations and types SIL and removed triage needed This issue needs more specific labels labels Dec 13, 2024
@eeckstein
Copy link
Contributor

@TeamPuzel Can you please provide instructions on how to reproduce? I did not see the problem when I build with swift build -c release (except that I see a linker error because of the missing SDL framework)

@kubamracek
Copy link
Contributor

I was able to reproduce this using the CMake build (had to hack it up a bit to also avoid the missing SDL dependency), and then I found out it just boils down to compiling the first module (Core) and then the second one (Engine) that uses the first one:

$ swiftc \
	-parse-as-library \
	-emit-module \
	-o Core.swiftmodule \
	-module-name Core \
	-module-link-name Core \
	-wmo    \
	-enable-experimental-feature BuiltinModule    \
	-enable-experimental-feature Extern    \
	-enable-experimental-feature Embedded    \
	-Xcc -fmodule-map-file=lib/SDL3/module.modulemap    \
	-Xcc -fmodule-map-file=lib/glad/include/module.modulemap \
	-swift-version 6 \
	-sdk $(xcrun --sdk macosx --show-sdk-path) \
	-I lib/glad/include \
	src/Core/*.swift


$ swiftc \
	-c  \
	-parse-as-library \
	-wmo    \
	-enable-experimental-feature BuiltinModule    \
	-enable-experimental-feature Extern    \
	-enable-experimental-feature Embedded    \
	-Xcc -fmodule-map-file=lib/SDL3/module.modulemap    \
	-Xcc -fmodule-map-file=lib/glad/include/module.modulemap \
	-swift-version 6 \
	-sdk $(xcrun --sdk macosx --show-sdk-path) \
	-I . \
	-I lib/glad/include \
	src/Engine/*.swift \
	-o /dev/null

Assertion failed: (Specialization->isExternalDeclaration() && "Specialization should be a public external declaration"), function lookupPrespecializedSymbol, file Generics.cpp, line 3604.
...
7  swift-frontend           0x00000001061b0ca0 swift::lookupPrespecializedSymbol(swift::SILModule&, llvm::StringRef) (.cold.2) + 0
8  swift-frontend           0x0000000100fb2174 swift::lookupPrespecializedSymbol(swift::SILModule&, llvm::StringRef) + 832
9  swift-frontend           0x0000000100c55f30 (anonymous namespace)::UsePrespecialized::run() + 1676
10 swift-frontend           0x0000000100de17e8 swift::SILPassManager::runModulePass(unsigned int) + 856

eeckstein added a commit to eeckstein/swift that referenced this issue Dec 17, 2024
There are not pre-specialized parts of the stdlib in embedded mode.

Fixes a compiler crash.
Unfortunately I con't have a test case for this.

swiftlang#78167
@TeamPuzel
Copy link
Author

@TeamPuzel Can you please provide instructions on how to reproduce? I did not see the problem when I build with swift build -c release (except that I see a linker error because of the missing SDL framework)

This isn't intended to be built using swift build, the Package.swift is there only for source kit because of other bugs preventing it from working with my compile_commands.json.

Also note that you do need the specific commit I linked to.

@eeckstein
Copy link
Contributor

fixed with #78234

eeckstein added a commit to eeckstein/swift that referenced this issue Dec 18, 2024
There are not pre-specialized parts of the stdlib in embedded mode.

Fixes a compiler crash.
Unfortunately I con't have a test case for this.

swiftlang#78167
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software generics Feature: generic declarations and types SIL SILOptimizer Area → compiler: SIL optimization passes
Projects
None yet
Development

No branches or pull requests

4 participants