Skip to content

codegen-backend doesn't allow arbitrary pathnames #12249

Closed as not planned
Closed as not planned
@azizghuloum

Description

@azizghuloum

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions