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

Get current target config from --print=cfg #111472

Merged
merged 1 commit into from
May 16, 2023

Conversation

djkoloski
Copy link
Contributor

Compiletest was switched to querying all targets using --print=all-target-specs-json and --print=target-spec-json in #108905. This unintentionally prevented codegen flags like -Cpanic from being reflected in the current target configuration. This change gets the current compiletest target config using --print=cfg like it was previously while still using the faster prints for getting information on all other targets.

Fixes #110850.

@jyn514 might be interested in reviewing since they commented on the issue.
cc @tmandry since this issue is affecting Fuchsia.

@rustbot
Copy link
Collaborator

rustbot commented May 11, 2023

r? @compiler-errors

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels May 11, 2023
@rust-log-analyzer

This comment has been minimized.

@bjorn3
Copy link
Member

bjorn3 commented May 11, 2023

This is useful for cg_clif too. It currently has to explicitly filter out needs-unwind tests, but with this PR these should transparently be skipped as the rustc-clif wrapper passes -Cpanic=abort to rustc.

@djkoloski djkoloski force-pushed the compiletest_cfg_current_target branch from 989e821 to 6aea01b Compare May 11, 2023 18:55
@rust-log-analyzer

This comment has been minimized.

Compiletest was switched to querying all targets using
`--print=all-target-specs-json` and `--print=target-spec-json`
in rust-lang#108905. This unintentionally prevented codegen flags like `-Cpanic`
from being reflected in the current target configuration. This change
gets the current compiletest target config using `--print=cfg` like it
was previously while still using the faster prints for getting
information on all other targets.

Fixes rust-lang#110850.
@djkoloski djkoloski force-pushed the compiletest_cfg_current_target branch from 6aea01b to 9dffb52 Compare May 11, 2023 19:10
@jyn514
Copy link
Member

jyn514 commented May 11, 2023

Doesn't this defeat the point of --print=all-target-specs-json? Shouldn't we fix that flag instead of invoking rustc more often?

@bjorn3
Copy link
Member

bjorn3 commented May 11, 2023

-print=all-target-specs-json is for getting configurations for all possible targets to check if every test has at least one target on which it runs. --print cfg here prints the active configuration to determine if the test should be run right now. This for example takes into account passing -Cpanic=abort on an otherwise panic=unwind target. This doesn't affect the target spec, but should still cause needs-unwind tests to not run.

@djkoloski
Copy link
Contributor Author

Architecturally, I think it makes sense to have separate operations to get all default configurations for supported targets, and to get the very specific configuration for a specific target given some additional flags. For example, if we passed some target RUSTCFLAGS while getting all configurations, should we apply those flags to every target? What if we wanted to only apply to some targets? My opinion is that it seems more straightforward to keep the operations separate.

@compiler-errors
Copy link
Member

Makes sense.

@bors r+

@bors
Copy link
Contributor

bors commented May 14, 2023

📌 Commit 9dffb52 has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 14, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request May 15, 2023
…target, r=compiler-errors

Get current target config from` --print=cfg`

Compiletest was switched to querying all targets using `--print=all-target-specs-json` and `--print=target-spec-json` in rust-lang#108905. This unintentionally prevented codegen flags like `-Cpanic` from being reflected in the current target configuration. This change gets the current compiletest target config using `--print=cfg` like it was previously while still using the faster prints for getting information on all other targets.

Fixes rust-lang#110850.

`@jyn514` might be interested in reviewing since they commented on the issue.
cc `@tmandry` since this issue is affecting Fuchsia.
@bors
Copy link
Contributor

bors commented May 16, 2023

⌛ Testing commit 9dffb52 with merge 72b2716...

@bors
Copy link
Contributor

bors commented May 16, 2023

☀️ Test successful - checks-actions
Approved by: compiler-errors
Pushing 72b2716 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 16, 2023
@bors bors merged commit 72b2716 into rust-lang:master May 16, 2023
11 checks passed
@rustbot rustbot added this to the 1.71.0 milestone May 16, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (72b2716): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.4% [-2.4%, -2.4%] 1
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 641.794s -> 641.487s (-0.05%)

@tmandry tmandry added the O-fuchsia Operating system: Fuchsia label May 24, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 27, 2023
…inking, r=davidtwco

Make compiletest aware of targets without dynamic linking

Some parts of the compiletest internals and some tests require dynamic linking to work, which is not supported by all targets. Before this PR, this was handled by if branches matching on the target name.

This PR loads whether a target supports dynamic linking or not from the target spec, and adds a `// needs-dynamic-linking` attribute for tests that require it. Note that I was not able to replace all the old conditions based on the target name, as some targets have `dynamic_linking: true` in their spec but pretend they don't have it in compiletest.

Also, to get this to work I had to *partially* revert rust-lang#111472 (cc `@djkoloski` `@tmandry` `@bjorn3).` On one hand, only the target spec contains whether a target supports dynamic linking, but on the other hand a subset of the fields can be overridden through `-C` flags (as far as I'm aware only `-C panic=$strategy`). The solution I came up with is to take the target spec as the base, and then override the panic strategy based on `--print=cfg`. Hopefully that should not break y'all again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc merged-by-bors This PR was explicitly merged by bors. O-fuchsia Operating system: Fuchsia S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compiletest no longer respects -Cpanic=abort in TARGET_RUSTCFLAGS after #108905
9 participants