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

Return .efi extension for EFI executable #104158

Merged
merged 1 commit into from
Nov 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/bootstrap/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ pub use t;
/// Given an executable called `name`, return the filename for the
/// executable for a particular target.
pub fn exe(name: &str, target: TargetSelection) -> String {
if target.contains("windows") { format!("{}.exe", name) } else { name.to_string() }
if target.contains("windows") {
format!("{}.exe", name)
} else if target.contains("uefi") {
format!("{}.efi", name)
} else {
name.to_string()
}
Copy link
Member

@bjorn3 bjorn3 Nov 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An option would be to use the output of rustc --print file-names --crate-name {name} --crate-type bin, but that might be a cyclic dependency if this function is used to find the path to the rustc executable. See for example https://github.com/bjorn3/rustc_codegen_cranelift/blob/0b37af8c6168f11221ba74115eb3c5725fd13c3c/build_system/rustc_info.rs#L46-L74

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I see, this function is used with a lot of binaries instead of crates, so I don't think rustc --print file-names --crate-name {name} --crate-type bin can be used at all places where exe is currently being used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, if the binary name contains a -, it won't work. Cargo uses ____ as crate name once and then replaces the ____ in the output with the binary name every time. That should work I think.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels a bit awkward regarding cyclic dependencies, doesn't it? Even if you fetch a stage from an external source, this stage will not reflect the last build, so this function will be out-of-sync with the source it builds. Not necessarily a big issue, but maybe requires a bit more investigation. Not sure it is worth blocking this change on it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally you should ask the rustc binary that actually does the compilation for the artifact of which you want the filename. I do agree that it isn't worth blocking this change on.

}

/// Returns `true` if the file name given looks like a dynamic library.
Expand Down