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

Needs documention: How to specify a certain version of Rust compiler? #299

Open
dnrusakov opened this issue Apr 6, 2020 · 6 comments
Open

Comments

@dnrusakov
Copy link

I went through the documentation and have not found:

  1. how to specify a certain version of Rust compiler?
  2. how to enable Rust nightly compiler?
    Thanks!
@damienmg
Copy link
Collaborator

damienmg commented Apr 6, 2020

The toolchains is specified using rust_toolchain.

They are defined on standard rust toolchain with: https://github.com/bazelbuild/rules_rust/blob/master/rust/repositories.bzl

So for using a specific version of the compiler you likely want to add a rules in your WORKSPACE file, e.g.:

rust_repository_set(
        name = "rust_linux_x86_64_nightly",
        exec_triple = "x86_64-unknown-linux-gnu",
        extra_target_triples = ["wasm32-unknown-unknown"],
        version = "nightly",
        rustfmt_version = "nightly",
 )

This needs more documentation.

If you do not use "rust_repositories", then it will probably just works with this other repo before the repository set:

load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

    maybe(
        http_archive,
        name = "rules_cc",
        url = "https://github.com/bazelbuild/rules_cc/archive/624b5d59dfb45672d4239422fa1e3de1822ee110.zip",
        sha256 = "8c7e8bf24a2bf515713445199a677ee2336e1c487fa1da41037c6026de04bbc3",
        strip_prefix = "rules_cc-624b5d59dfb45672d4239422fa1e3de1822ee110",
        type = "zip",
    )

If you specify the other, you might need to select the toolchain at the command line but I could not find a good answer on how to do that. Maybe @katre knows?

@damienmg damienmg changed the title How to specify a certain version of Rust compiler? Needs documention: How to specify a certain version of Rust compiler? Apr 6, 2020
@DmitryRusakovKodiak
Copy link

DmitryRusakovKodiak commented Apr 7, 2020

@damienmg Thanks for the help!
I wonder, why RUST_VERSION is hard-coded inside def rust_repositories()? Shouldn't it be a parameter of the function, like, for example, def rust_repositories(rust_version, rust_fmt_version)?

@damienmg
Copy link
Collaborator

damienmg commented Apr 7, 2020

@DmitryRusakovKodiak yes I also think that should be parameters of the rust_repositories rule.

@katre
Copy link
Member

katre commented Apr 7, 2020

Since rust_repository_set is calling native.register_toolchains, you shouldn't need any extra flags to make Bazel aware of the new toolchains. You may need to tweak the order of things, however, to ensure your new toolchain is higher priority than the standard toolchains.

@kragniz
Copy link
Contributor

kragniz commented Apr 19, 2020

I made a start at this in #307

@nathanielford
Copy link

The rust_repositories(version = "nightly", iso_date = "2020-04-19") documentation does not seem to work with the previously mentioned configuration in the README's 'setup' section, due to the cited release not including the more recent version-specifying change. Might be worth updating to match?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants