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

rustc: add a --print targets command #31358

Merged
merged 1 commit into from
Feb 13, 2016
Merged

Conversation

japaric
Copy link
Member

@japaric japaric commented Feb 2, 2016

that prints a list of all the triples supported by the --target flag

r? @alexcrichton

"x86_64-unknown-linux-musl",
"x86_64-unknown-netbsd",
"x86_64-unknown-openbsd",
];
Copy link
Member

Choose a reason for hiding this comment

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

Would it be possible to not duplicate this list with the one below? Could the macro somehow use something like stringify! to build a vector, or could an iterator macro be used?

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems tricky to handle mixture of hyphens and an underscore...

Copy link
Contributor

Choose a reason for hiding this comment

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

I think "x86_64-w64-mingw32" is an alias for "x86_64-pc-windows-gnu" and should be included in the list as a valid target.

Copy link
Member Author

Choose a reason for hiding this comment

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

Would it be possible to not duplicate this list with the one below? Could the macro somehow use something like stringify! to build a vector, or could an iterator macro be used?

As @nodakai said, the mixture of hyphens and underscores makes it tricky.

I think "x86_64-w64-mingw32" is an alias for "x86_64-pc-windows-gnu" and should be included in the list as a valid target.

That's what the logic of this function seems to indicate. But, rustc --target=x86_64-w64-mingw32 ... returns error: Error loading target specification: Could not find specification for target "x86_64-w64-mingw32".

Copy link
Contributor

Choose a reason for hiding this comment

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

I think "x86_64-w64-mingw32" is an alias for "x86_64-pc-windows-gnu" and should be included in the list as a valid target.

The former is deprecated and I don't think we should be promoting it.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with @brson that we shouldn't be handling aliases, and this also probably isn't the right place to discuss it regardless (e.g. an issue would be more appropriate).

@japaric sure it's trick but that doesn't mean it's not possible! I'd be personally much happier with something like:

load! {
    (x86_64_pc_windows_gnu, "x86_64-pc-windows-gnu"),
    // ...
}

It's basically just much easier if there doesn't need to exist a comment of "modify this other location as well" as they will invariably get out of sync.

Copy link
Member Author

Choose a reason for hiding this comment

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

sure it's trick but that doesn't mean it's not possible!

Well, I was thinking about a macro that didn't need to specify the triple twice in different formats (hyphenated and underscored).

I'd be personally much happier with something like:

Yeah, that looks less prone to errors. I'll look into it.

@alexcrichton
Copy link
Member

This can in theory have some form of interaction with custom target specifications where we probe for foo.json in RUST_TARGET_PATH (both of which are... semi-stable). That being said I'm not sure I want a command like this to be probing around the filesystem for that kind of information.

I'm pretty ok with the option here, though. We may want to rename --print targets to something like --print supported-targets. Eventually we may have a "print all targets I have a standard library for" which may want to be called targets.

@alexcrichton
Copy link
Member

cc @rust-lang/tools

@japaric
Copy link
Member Author

japaric commented Feb 2, 2016

... probe for foo.json in RUST_TARGET_PATH ...

Wait RUST_TARGET_PATH is a thing? TIL

That being said I'm not sure I want a command like this to be probing around the filesystem for that kind of information.

Yeah I don't think it should. The other --print commands don't do that kind of probing. Also it seems the command would have to look at all the *.json files and check that they are valid target specification files.

We may want to rename --print targets to something like --print supported-targets.

Happy to rename --print targets to --print supported-targets if the tools subteam decides so.

@alexcrichton
Copy link
Member

Wait RUST_TARGET_PATH is a thing? TIL

That's ok, if you unlearn it right now I'd be fine with that.

@nagisa
Copy link
Member

nagisa commented Feb 3, 2016

This should probably also print the target passed in to rust through --target=PATH.

@japaric
Copy link
Member Author

japaric commented Feb 3, 2016

Pushed two commits. The first one generates the TARGETS constant from the existing macro as @alexcrichton suggested. The second commit makes the rmake test simpler.

This should probably also print the target passed in to rust through --target=PATH.

This seems doable and makes sense, but I wasn't expecting it to come up in practice. @alexcrichton thoughts?

return Some(t);
}
)*
else if target == "x86_64-w64-mingw32" {
Copy link
Member Author

Choose a reason for hiding this comment

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

While copy pasting this code, I noticed these last two else-if branches are effectively unreachable (because of the let target = target.replace("-", "_"); a few lines above).

Not sure if I should fix them or just remove them. Probably the latter because @brson said these targets are deprecated.

Copy link
Member

Choose a reason for hiding this comment

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

Ah for now I'd just leave out these targets entirely, we've generally tried to remove them as much as possible

@nrc
Copy link
Member

nrc commented Feb 3, 2016

Can we have target instead of targets? I think it is confusing to have --target but require the plural here (or just use something completely different like supported-targets.

@bors
Copy link
Contributor

bors commented Feb 4, 2016

☔ The latest upstream changes (presumably #31078) made this pull request unmergeable. Please resolve the merge conflicts.

@vi
Copy link
Contributor

vi commented Feb 6, 2016

Can there be --target=help also doing the print?

@japaric
Copy link
Member Author

japaric commented Feb 6, 2016

Can there be --target=help also doing the print?

That's what I proposed on IRC because of the llc -march=mips -mcpu=help parallel. But @alexcrichton suggested --print targets; I think because we already use --print to query for other information. Also it's currently possible to create a target named "test", so --target=help could mean two different things.

@vi
Copy link
Contributor

vi commented Feb 6, 2016

Alternatively, error message for unknown/malformed target like --target=qwerty may suggest using --print.

@alexcrichton
Copy link
Member

Yeah right now --print is the way we currently have for printing various bits of information from the compiler. I do like the idea, though, of re-wording the error message for --target foo to suggest --print targets!

@alexcrichton
Copy link
Member

Ok, the tools team had a chance to talk about this today during triage, and we all agreed that this is good to add, but none of us felt too too strongly about the name. Some possibilities were:

  • --print target - matches the tense of --target
  • --print targets - matches what's printed, a lot of targets
  • --print target-list - also kinda matches what's printed?

I think that I may lean a bit in favor of target-list as we may have other things like target-support or target-with-std or something like that in the future. @japaric what do you think?

@japaric
Copy link
Member Author

japaric commented Feb 11, 2016

I like the sound of --print target-list, but I'm curious as to what --print target-support would do?

@alexcrichton
Copy link
Member

Ah I was just thinking in terms of there being a difference between targets we can generate code for and targets we can generate things like rlibs/binaries for. The latter case would require a standard library and/or libcore, but as I write this down it sounds weird. Anyway target-list sounds good to me as well!

@japaric
Copy link
Member Author

japaric commented Feb 12, 2016

removed the deprecated mingw aliases, renamed print targets to print target-list, rebased and squashed. r? @alexcrichton

@alexcrichton alexcrichton added the relnotes Marks issues that should be documented in the release notes of the next release. label Feb 12, 2016
@alexcrichton
Copy link
Member

Tagging as relnotes as we're basically dropping the old w64-mingw32 triples. I had no idea we were actually supporting them!

@bors: r+ 0bb4209

@bors
Copy link
Contributor

bors commented Feb 13, 2016

⌛ Testing commit 0bb4209 with merge 97842f5...

bors added a commit that referenced this pull request Feb 13, 2016
that prints a list of all the triples supported by the `--target` flag

r? @alexcrichton
@bors bors merged commit 0bb4209 into rust-lang:master Feb 13, 2016
@japaric japaric deleted the print-targets branch March 8, 2016 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes Marks issues that should be documented in the release notes of the next release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants