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

Instructions should use shell syntax #501

Open
workingjubilee opened this issue Apr 20, 2024 · 1 comment · May be fixed by #533
Open

Instructions should use shell syntax #501

workingjubilee opened this issue Apr 20, 2024 · 1 comment · May be fixed by #533
Labels
good first issue Good for newcomers

Comments

@workingjubilee
Copy link
Member

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.

@workingjubilee workingjubilee changed the title Instructions should use shell syntax for variables Instructions should use shell syntax Apr 20, 2024
@workingjubilee
Copy link
Member Author

This shell:

../gcc/configure \
    --enable-host-shared \
    --enable-languages=jit \
    --enable-checking=release \ # it enables extra checks which allow to find bugs
    --disable-bootstrap \
    --disable-multilib \
    --prefix=$(pwd)/../gcc-install

does not actually execute correctly if pasted into my terminal:

$ ../gcc/configure \
    --enable-host-shared \
    --enable-languages=jit \
    --enable-checking=release \ # it enables extra checks which allow to find bugs
    --disable-bootstrap \
    --disable-multilib \
    --prefix=$(pwd)/../gcc-install
configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type:  #
configure: WARNING: you should use --build, --host, --target
configure: WARNING: you should use --build, --host, --target
configure: WARNING: you should use --build, --host, --target
configure: WARNING: you should use --build, --host, --target
configure: WARNING: you should use --build, --host, --target
configure: WARNING: you should use --build, --host, --target
configure: WARNING: you should use --build, --host, --target
configure: WARNING: you should use --build, --host, --target
configure: WARNING: you should use --build, --host, --target
checking build system type... Invalid configuration `#': machine `#-unknown' not recognized
configure: error: /bin/sh ../gcc/config.sub  # failed
bash: --disable-bootstrap: command not found

@antoyo antoyo added the good first issue Good for newcomers label May 3, 2024
@darcagn darcagn linked a pull request Jun 19, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants