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

codegen-backend doesn't allow arbitrary pathnames #12249

Closed
azizghuloum opened this issue Jun 10, 2023 · 1 comment
Closed

codegen-backend doesn't allow arbitrary pathnames #12249

azizghuloum opened this issue Jun 10, 2023 · 1 comment
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.

Comments

@azizghuloum
Copy link

azizghuloum commented Jun 10, 2023

Problem

The -Zcodegen-backend=<path> flag[1] and the codegen-backend spec in cargo.toml[2] are incompatible,

[1] https://doc.rust-lang.org/beta/unstable-book/compiler-flags/codegen-backend.html
[2] https://doc.rust-lang.org/cargo/reference/unstable.html#codegen-backend

Steps

Currently, I can do:

$ RUSTFLAGS='-Zcodegen-backend=./some/path/to/codegenerator.dylib' cargo test

to run some tests using that code generator (mac os). That works.

I tried adding the following to Cargo.toml:

[profile.test]
codegen-backend = "./some/path/to/codegenerator.dylib"

Now running cargo test gives

$  cargo test
error: failed to parse manifest at `/some/path/Cargo.toml`

Caused by:
  `profile.test.codegen-backend` setting of `./some/path/to/codegenerator.dylib` is not a valid backend name.

Possible Solution(s)

Cargo source code is restricting it here to alphanumeric and _ characters.

if codegen_backend.contains(|c: char| !c.is_ascii_alphanumeric() && c != '_') {

Is that test too restrictive?

Notes

No response

Version

cargo 1.72.0-nightly (f7b95e316 2023-05-30)
release: 1.72.0-nightly
commit-hash: f7b95e31642e09c2b6eabb18ed75007dda6677a0
commit-date: 2023-05-30
host: x86_64-apple-darwin
libgit2: 1.6.4 (sys:0.17.1 vendored)
libcurl: 7.88.1 (sys:0.4.61+curl-8.0.1 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1t  7 Feb 2023
os: Mac OS 13.4.0 [64-bit]
@azizghuloum azizghuloum added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Jun 10, 2023
@azizghuloum azizghuloum changed the title codegen-backend doesn't allow custom backends codegen-backend doesn't allow paths Jun 10, 2023
@azizghuloum azizghuloum changed the title codegen-backend doesn't allow paths codegen-backend doesn't allow arbitrary pathnames Jun 10, 2023
@weihanglo
Copy link
Member

I wasn't there, but the choice was made intentionally not accepting arbitrary pat seems intentional in #9118 (comment). From my understanding, we're still waiting for rust-lang/rust#81746.

Given you can set RUSTFLAGS, as well as there is also an unstable feature profile.<name>.rustflags, I feel like the workarounds here are sufficient at this moment. I am going to close this. Please call out if there is something I am missing. Thank you!

@weihanglo weihanglo closed this as not planned Won't fix, can't repro, duplicate, stale Jun 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

2 participants