rust-lang / rust-lang/rustc_codegen_gcc

Instructions should use shell syntax

Open
#501 4 comments 0 reactions 1 assignee View on GitHub

@mizoz is already working on this.

Since Apr 28, 2026.

good first issue
Dominant language
Rust
Stars
1.2k
Forks
105
Avg merge
8h 20m
Merged PRs (30d)
14

Description

This is regarding this excerpt from the README, primarily:

$ LIBRARY_PATH="[gcc-path value]" LD_LIBRARY_PATH="[gcc-path value]" rustc +$(cat $CG_GCCJIT_DIR/rust-toolchain | grep 'channel' | cut -d '=' -f 2 | sed 's/"//g' | sed 's/ //g') -Cpanic=abort -Zcodegen-backend=$CG_GCCJIT_DIR/target/release/librustc_codegen_gcc.so --sysroot $CG_GCCJIT_DIR/build_sysroot/sysroot my_crate.rs

This has a problem. Namely: if we ignore the $, this is legal shell syntax, but the command will probably fail? Variables get set to legal strings that are useless values, i.e. [gcc-path value] does not mean anything in terms of paths. The linker will ignore these, but I imagine you meant to suggest actual commands or paths... in other words, substitutions. Like variables?

I am aware of the [option] convention in man pages, but that is for optional values, and these commands will simply fail if these are not set. It is also a hoary convention lost to the mists of time and not actually documented anywhere, so anyone unfamiliar with this particular notation will have no idea.

If you want to force them to define the variable (and thus, likely force them to break if they try to simply copy and paste the code), you can do this for these vars:

LIBRARY_PATH="${YOUR_GCC_PATH_VALUE:?define this to your path}"

This command will fail (setting $? to 1, it doesn't really "exit") with an error like:

bash: YOUR_GCC_PATH_VALUE: define this to your path

This is, despite being somewhat obscure syntax, portable shell. All POSIX shells are required to understand this, and non-POSIX shells I am aware of will at least parse-error on it, even if they don't replicate this behavior.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.