Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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-L74There 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.
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 whereexe
is currently being used.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, 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.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 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?
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.
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.