-
Notifications
You must be signed in to change notification settings - Fork 686
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
Use environment variable for force rustup toolchain version #322
Conversation
Makefile.common
Outdated
@@ -33,7 +35,7 @@ endif | |||
|
|||
# Check that rustc is the right nightly - warn not error if wrong, sometimes useful to test others | |||
RUSTC_VERSION_STRING := rustc 1.16.0-nightly (83c2d9523 2017-01-24) | |||
ifneq ($(shell rustc --version),$(RUSTC_VERSION_STRING)) | |||
ifneq ($(shell RUSTUP_TOOLCHAIN=$(RUSTUP_TOOLCHAIN) rustc --version),$(RUSTC_VERSION_STRING)) | |||
$(warning Unexpected rustc version. Expected $(RUSTC_VERSION_STRING) got $(shell rustc --version)) | |||
$(warning You may experience unexpected compilation warnings or errors) | |||
$(warning To fix, run `rustup override set nightly-2017-01-25`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we change this line to just suggest installing rustup
instead of suggesting running override?
Also, if I've done an override and this env variable is set - who wins? Importantly, if the env variable wins, we need to have an escape hatch to let people try building with different versions briefly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added an escape hatch (will squash the commit):
$ make RUSTUP_VERSION=some-other-version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest some best practice in place of the To fix
language?
something like - "To fix Install rustup. Remove any overrides you may have set if rustup was previously installed"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, but I just pointed to https://rustup.rs
for installation. RUSTUP_TOOLCHAIN
takes precedence over rustup override
.
Leaving this note here for the annals of history. In make http://stackoverflow.com/questions/2838715/makefile-variable-initialization-and-export |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to work great for me.
You should update getting_started |
Really all of these:
|
`rustup` looks at the `RUSTUP_TOOLCHAIN` variable first to figure out which toolchain to use (e.g. `nightly-2017-01-25`). Using this environment variable avoids requiring developers building the kernel to configure toolchain themselves.
Done, but it turns out not to be as sweet as we thought, you still need to manually install that version (which override does automatically). It's still nice that you don't have to get the override in the exact right directory and the failure mode is a bit less baffling, so probably still useful. |
Can't make run rustup for you? |
OK, how's that? |
Makefile.common
Outdated
ifneq ($(shell rustc --version),$(RUSTC_VERSION_STRING)) | ||
$(warning Unexpected rustc version. Expected $(RUSTC_VERSION_STRING) got $(shell rustc --version)) | ||
ifeq ($(shell rustup -V &> /dev/null && echo success),success) | ||
DUMMY := $(shell rustup install $(RUSTUP_TOOLCHAIN)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs to fail / bail out here somehow if the install fails. Make doesn't care if the sub $(shell
exits with an error code:
$ cat Makefile
FOO := /bin/false
all:
echo hi
[-bash] Wed 22 Mar 16:21 [/tmp/m]
$ make
echo hi
hi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any thoughts on how to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this:
RUSTC_VERSION_STRING := rustc 1.16.0-nightly (83c2d9523 2017-01-24)
ifneq ($(shell rustup -V &> /dev/null && rustup install $(RUSTUP_TOOLCHAIN) 1>&2 && echo success),success)
ifneq ($(shell RUST_TOOLCHAIN=$(RUSTUP_TOOLCHAIN) rustc --version), $(RUSTC_VERSION_STRING))
$(warning You do not have the correct version of `rustc` configured, and `rustup` is not installed.)
$(warning Expected `rustc` version "$(RUSTC_VERSION_STRING)" but got "$(shell rustc --version)")
$(warning You may experience unexpected compilation warnings or errors)
$(warning To fix, install `rustup` from https://rustup.rs/, then run: `rustup install $(RUSTUP_TOOLCHAIN)`)
endif
endif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like the new language
It's a bit hacky, but the solution that jumps to mind is to just nest the checks:
ifeq ($(shell rustup -V &> /dev/null && echo success),success)
DUMMY := $(shell rustup install $(RUSTUP_TOOLCHAIN))
ifneq ($(shell RUST_TOOLCHAIN=$(RUSTUP_TOOLCHAIN) rustc --version), $(RUSTC_VERSION_STRING))
$(error rustup failed. SAD)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oic... how about this:
the logic is:
- check to see if the expected version of
rustc
is installed (we don't care how, on the path? cool. from rustup? cool). - if not, just blindly try installing with
rustup
. - check again
- if after all that, it's not installed, spit out the warning.
It involves the same check twice, but meh...
RUSTC_VERSION_STRING := rustc 1.16.0-nightly (83c2d9523 2017-01-24)
ifneq ($(shell RUST_TOOLCHAIN=$(RUSTUP_TOOLCHAIN) rustc --version), $(RUSTC_VERSION_STRING))
DUMMY := $(shell rustup install $(RUSTUP_TOOLCHAIN))
ifneq ($(shell RUST_TOOLCHAIN=$(RUSTUP_TOOLCHAIN) rustc --version), $(RUSTC_VERSION_STRING))
$(warning You do not have the correct version of `rustc` configured, and `rustup` is not installed.)
$(warning Expected `rustc` version "$(RUSTC_VERSION_STRING)" but got "$(shell rustc --version)")
$(warning You may experience unexpected compilation warnings or errors)
$(warning To fix, install `rustup` from https://rustup.rs/, then run: `rustup install $(RUSTUP_TOOLCHAIN)`)
endif
endif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that looks perfect
What if we make our getting_started specify that rustup is the dependency, and not rust. The we can update just with the makefile. |
OK, took another pass. Whoever merges, if it's ready, please squash the commits? |
Nice @alevy, thanks -- sorry to turn a two-line change into so much work 🤕 |
rustup
looks at theRUSTUP_TOOLCHAIN
variable first to figure outwhich toolchain to use (e.g.
nightly-2017-01-25
). Using thisenvironment variable avoids requiring developers building the kernel to
configure toolchain themselves.
Solves #321