-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add a fallback extension none os dylibs #8022
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
Conversation
Adds a fake extension for none os dynamic libraries to avoid a SwiftPM crash during build planning when cross compiling to none OS with a dylib product in the graph. Fixes #7893
@swift-ci test |
Sources/Basics/Triple+Basics.swift
Outdated
fatalError("Cannot create dynamic libraries for os \"\(os)\".") | ||
// Fallback to a nonsense extension for operating systems with | ||
// unknown conventions. | ||
return ".dynamiclibrary" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason this is preferred over .so
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really like the idea of the extension for "macho" being "so". I think that would be kinda surprising to the user.
I was considering this default branch determining the extension based on the object file format instead, thought?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the behavior if building on a non-macho platform like Linux? Would this still work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code path is only used to plan the build of a dynamic library product for an os none triple. Actually doing this build is nonsensical because the dynamic library would require a specific dynamic loader provided by the OS and by definition, os none does not have a dynamic loader.
One alternative option is to use the object format e.g.:
switch os {
case _ where isDarwin():
return ".dylib"
case .linux, .openbsd:
return ".so"
case .win32:
return ".dll"
case .wasi:
return ".wasm"
default:
break
}
guard let objectFormat = self.objectFormat else {
fatalError("Cannot create dynamic libraries unknown object format.")
}
switch objectFormat {
case .coff:
return ".coff"
case .elf:
return ".elf"
case .macho:
return ".macho"
case .wasm:
return ".wasm"
case .xcoff:
return ".xcoff"
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this basically just spoofs the "dynamic library" on a none OS but doesn't actually generate anything? That's kind of weird. But if that's the case then I guess it's just arbitrary what you pick there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah its not a great thing to do, but fixing the underlying issue with build planning is something the swift pm team is working on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I'm okay with this if it fixes the none OS issue and if it doesn't break anything!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think doing this based on object format looks better.
@swift-ci test |
@swift-ci test windows |
Adds a fake extension for none os dynamic libraries to avoid a SwiftPM crash during build planning when cross compiling to none OS with a dylib product in the graph.
Fixes #7893