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

Support codegen-backend and rustflags in profiles in config file #11562

Merged
merged 3 commits into from
Jan 14, 2023

Conversation

weihanglo
Copy link
Member

@weihanglo weihanglo commented Jan 11, 2023

What does this PR try to resolve?

Add two -Z flags

  • profile-rustflags
  • codegen-backend

to support configuring them in .cargo/config.toml without touching Cargo.toml.

How should we test and review this PR?

A test is added for -Zprofile-rustflags. There is no test around codegen-backend. I followed that.

Additional information

Was trying to write an instruction for this fix but accidentally finished it…

Fixes #11552
Fixes #9926

@rustbot
Copy link
Collaborator

rustbot commented Jan 11, 2023

r? @epage

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

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 11, 2023
@ehuss
Copy link
Contributor

ehuss commented Jan 13, 2023

Thanks! Can you also update unstable.md? I would probably just mention in the Profile rustflags option section that if you are just setting the profile in a Cargo config that you can use -Z profile-rustflags or use the [unstable] table in the config itself. (And same in the codegen section.)

@ehuss
Copy link
Contributor

ehuss commented Jan 14, 2023

Thanks!

@bors r+

@bors
Copy link
Contributor

bors commented Jan 14, 2023

📌 Commit 5c87110 has been approved by ehuss

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 Jan 14, 2023
@bors
Copy link
Contributor

bors commented Jan 14, 2023

⌛ Testing commit 5c87110 with merge 48e0c53...

@bors
Copy link
Contributor

bors commented Jan 14, 2023

☀️ Test successful - checks-actions
Approved by: ehuss
Pushing 48e0c53 to master...

@bors bors merged commit 48e0c53 into rust-lang:master Jan 14, 2023
@weihanglo weihanglo deleted the issue-11552 branch January 14, 2023 14:44
weihanglo added a commit to weihanglo/rust that referenced this pull request Jan 17, 2023
9 commits in 1cd6d3803dfb0b342272862a8590f5dfc9f72573..a5d47a72595dd6fbe7d4e4f6ec20dc5fe724edd1
2023-01-12 18:40:36 +0000 to 2023-01-16 18:51:50 +0000

- Add network container tests (rust-lang/cargo#11583)
- Show progress of crates.io index update even `net.git-fetch-with-cli` option enabled (rust-lang/cargo#11579)
- `cargo metadata` supports artifact dependencies (rust-lang/cargo#11550)
- fix(docs): add required "inherits" option to example profile (rust-lang/cargo#11504)
- add documentation that SSH markers aren't supported (rust-lang/cargo#11586)
- Fix typo (rust-lang/cargo#11585)
- Enable source_config_env test on Windows (rust-lang/cargo#11582)
- Support `codegen-backend` and `rustflags` in profiles in config file (rust-lang/cargo#11562)
- ci: reflect to clap updates (rust-lang/cargo#11578)
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 18, 2023
Update cargo

9 commits in 1cd6d3803dfb0b342272862a8590f5dfc9f72573..a5d47a72595dd6fbe7d4e4f6ec20dc5fe724edd1 2023-01-12 18:40:36 +0000 to 2023-01-16 18:51:50 +0000

- Add network container tests (rust-lang/cargo#11583)
- Show progress of crates.io index update even `net.git-fetch-with-cli` option enabled (rust-lang/cargo#11579)
- `cargo metadata` supports artifact dependencies (rust-lang/cargo#11550)
- fix(docs): add required "inherits" option to example profile (rust-lang/cargo#11504)
- add documentation that SSH markers aren't supported (rust-lang/cargo#11586)
- Fix typo (rust-lang/cargo#11585)
- Enable source_config_env test on Windows (rust-lang/cargo#11582)
- Support `codegen-backend` and `rustflags` in profiles in config file (rust-lang/cargo#11562)
- ci: reflect to clap updates (rust-lang/cargo#11578)

r? `@ghost`
@ehuss ehuss added this to the 1.68.0 milestone Jan 28, 2023
@pickfire
Copy link
Contributor

pickfire commented Apr 3, 2023

How does one use this? I added as per the instruction but it says failed to find the directory.

[unstable]
codegen-backend = true

[profile.dev]
codegen-backend = "cranelift"

Error

> cargo c
   Compiling proc-macro2 v1.0.55
   Compiling quote v1.0.26
   Compiling unicode-ident v1.0.8
   Compiling autocfg v1.1.0
   Compiling cfg-if v1.0.0
   Compiling log v0.4.17
error: failed to find a `codegen-backends` folder in the sysroot candidates:
       * /home/ivan/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu
       * /home/ivan/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu

Maybe I need to add it from rustup?

@weihanglo
Copy link
Member Author

Hi, @pickfire. This unstable feature just passes the value to rustc -Zcodegen-backend flag, so I believe the value must be a path to your backend.

cmd.arg("-Z").arg(&format!("codegen-backend={}", backend));

There is a pull request rust-lang/rust#81746 making clif a rustupcomponent though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Global cargo-features Can't use unstable feature in ~/.cargo/config without enabling it in Cargo.toml
6 participants