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

Release 0.57.0 #3165

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module(
name = "rules_rust",
version = "0.56.0",
version = "0.57.0",
)

###############################################################################
Expand Down
4 changes: 2 additions & 2 deletions crate_universe/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ There are some examples of using crate_universe with bzlmod in the [example fold
To use rules_rust in a project using bzlmod, add the following to your MODULE.bazel file:

```python
bazel_dep(name = "rules_rust", version = "0.49.3")
bazel_dep(name = "rules_rust", version = "0.57.0")
```

You find the latest version on the [release page](https://github.com/bazelbuild/rules_rust/releases).
Expand Down Expand Up @@ -196,7 +196,7 @@ module(
bazel_dep(name = "bazel_skylib", version = "1.7.1")

# https://github.com/bazelbuild/rules_rust/releases
bazel_dep(name = "rules_rust", version = "0.49.3")
bazel_dep(name = "rules_rust", version = "0.57.0")

###############################################################################
# T O O L C H A I N S
Expand Down
2 changes: 1 addition & 1 deletion docs/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module(
version = "0.0.0",
)

bazel_dep(name = "rules_rust", version = "0.55.6")
bazel_dep(name = "rules_rust", version = "0.0.0")
local_path_override(
module_name = "rules_rust",
path = "..",
Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Note that rules_rust bzlmod support is still a work in progress. Most features s
To use `rules_rust` in a project using bzlmod, add the following to your `MODULE.bazel` file:

```python
bazel_dep(name = "rules_rust", version = "0.48.0")
bazel_dep(name = "rules_rust", version = "0.57.0")
```

Don't forget to substitute in your desired release's version number.
Expand Down
2 changes: 1 addition & 1 deletion examples/all_deps_vendor/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module(
bazel_dep(name = "bazel_skylib", version = "1.7.1")

# https://github.com/bazelbuild/rules_rust/releases
bazel_dep(name = "rules_rust", version = "0.46.0")
bazel_dep(name = "rules_rust", version = "0.0.0")
local_path_override(
module_name = "rules_rust",
path = "../..",
Expand Down
2 changes: 1 addition & 1 deletion examples/all_deps_vendor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module(
bazel_dep(name = "bazel_skylib", version = "1.7.1")

# https://github.com/bazelbuild/rules_rust/releases
bazel_dep(name = "rules_rust", version = "0.46.0")
bazel_dep(name = "rules_rust", version = "0.57.0")

###############################################################################
# T O O L C H A I N S
Expand Down
2 changes: 1 addition & 1 deletion examples/compile_opt/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module(
# B A Z E L C E N T R A L R E G I S T R Y # https://registry.bazel.build/
###############################################################################
# https://github.com/bazelbuild/rules_rust/releases
bazel_dep(name = "rules_rust", version = "0.56.0")
bazel_dep(name = "rules_rust", version = "0.0.0")
local_path_override(
module_name = "rules_rust",
path = "../..",
Expand Down
2 changes: 1 addition & 1 deletion examples/crate_universe_local_path/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bazel_dep(name = "rules_rust", version = "0.54.1")
bazel_dep(name = "rules_rust", version = "0.0.0")
local_path_override(
module_name = "rules_rust",
path = "../..",
Expand Down
2 changes: 1 addition & 1 deletion examples/cross_compile/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module(
###############################################################################
# Get latest rules_rust release from:
# https://github.com/bazelbuild/rules_rust/releases
bazel_dep(name = "rules_rust", version = "0.52.0")
bazel_dep(name = "rules_rust", version = "0.0.0")
local_path_override(
module_name = "rules_rust",
path = "../..",
Expand Down
20 changes: 10 additions & 10 deletions examples/cross_compile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The example code is setup to cross compile from the following hosts to the the f
* {darwin, aarch64 (Apple Silicon)} -> {linux, x86_64}
* {darwin, aarch64 (Apple Silicon)} -> {linux, aarch64}

Cross compilation from Linux to Apple may work, but has not been tested.
Cross compilation from Linux to Apple may work, but has not been tested.

You cross-compile by calling the target.

Expand All @@ -23,7 +23,7 @@ or


You can also build all targets at once:


`bazel build //...`

Expand All @@ -43,7 +43,7 @@ You add the required rules for cross compilation to your MODULE.bazel as shown b
```Starlark
# Get latest release from:
# https://github.com/bazelbuild/rules_rust/releases
bazel_dep(name = "rules_rust", version = "0.52.0")
bazel_dep(name = "rules_rust", version = "0.57.0")

# https://github.com/bazelbuild/platforms/releases
bazel_dep(name = "platforms", version = "0.0.10")
Expand All @@ -57,8 +57,8 @@ http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "ht

## LLVM Configuration

Next, you have to configure the LLVM toolchain because rules_rust still needs a cpp toolchain for cross compilation and you have to add the specific platform triplets to the Rust toolchain.
Suppose you want to compile a Rust binary that supports linux on both, X86 and ARM.
Next, you have to configure the LLVM toolchain because rules_rust still needs a cpp toolchain for cross compilation and you have to add the specific platform triplets to the Rust toolchain.
Suppose you want to compile a Rust binary that supports linux on both, X86 and ARM.
In that case, you have to configure three LLVM targets:

1) LLVM for the host
Expand Down Expand Up @@ -88,14 +88,14 @@ http_archive(
```

Here, we declare to new http downloads that retrieve the sysroot for linux_x64 (Intel/AMD) and linux_aarch64 (ARM/Apple Silicon). The buildfile is a simple filegroup and located in the /build/sysroot directory. You have to copy it in your project directory to make the sysroots work. Note, these are only
sysroots, that means you have to configure LLVM next to use these files.
sysroots, that means you have to configure LLVM next to use these files.

If you need a custom sysroot, for example to cross compile system dependencies such as openssl,
If you need a custom sysroot, for example to cross compile system dependencies such as openssl,
libpq (postgres client library) or similar, read through the excellent tutorial by Steven Casagrande:

https://steven.casagrande.io/posts/2024/sysroot-generation-toolchains-llvm/

As mentioned earlier, three LLVM targets need to be configured and to do just that,
As mentioned earlier, three LLVM targets need to be configured and to do just that,
please add the following to your MODULE.bazel

```Starlark
Expand Down Expand Up @@ -128,7 +128,7 @@ register_toolchains(

For simplicity, all toolchains are pinned to LLVM version 16 because it is one of the few releases that supports many targets and runs on older linux distributions i.e. Ubuntu 18.04. If you target modern CPU's i.e. ARMv9 that require a more recent LLVM version, see the complete [list off all LLVM releases and supported platforms.](https://github.com/bazel-contrib/toolchains_llvm/blob/master/toolchain/internal/llvm_distributions.bzl) Also, it is possible to pin different targets to different LLVM versions; [see the documentation for details](https://github.com/bazel-contrib/toolchains_llvm/tree/master?tab=readme-ov-file#per-host-architecture-llvm-version).

If you face difficulties with building LLVM on older linux distros or your CI,
If you face difficulties with building LLVM on older linux distros or your CI,
please take a look at the [LLVM Troubleshooting guide](README_LLVM_Troubleshooting) for known issues.


Expand All @@ -138,7 +138,7 @@ The Rust toolchain only need to know the additional platform triplets to downloa
or or modify your MODULE.bazel with the following entry:

```Starlark
RUST_EDITION = "2021"
RUST_EDITION = "2021"
RUST_VERSION = "1.81.0"

rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
Expand Down
2 changes: 1 addition & 1 deletion examples/ffi/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module(
# B A Z E L C E N T R A L R E G I S T R Y # https://registry.bazel.build/
###############################################################################
# https://github.com/bazelbuild/rules_rust/releases
bazel_dep(name = "rules_rust", version = "0.46.0")
bazel_dep(name = "rules_rust", version = "0.0.0")
local_path_override(
module_name = "rules_rust",
path = "../..",
Expand Down
21 changes: 9 additions & 12 deletions examples/ffi/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Rust FFI

In case of an existing C++, Rust can call into the C++ function via FFI.
With Bazel, this is straightforward. However, your C++ API needs an extern "C"
With Bazel, this is straightforward. However, your C++ API needs an extern "C"
declaration to generate the C compatibility required for FFI.

## Setup

The setup is twofold, the Rust rules are declared in the MODULE file,
but the rules_cc are not yet available in the Bazelmod format and thus are declared in
The setup is twofold, the Rust rules are declared in the MODULE file,
but the rules_cc are not yet available in the Bazelmod format and thus are declared in
the WORKSPACE.bzlmod file.

In your MODULE.bazel file, ensure to have the following entry:
Expand All @@ -21,7 +21,7 @@ module(
# B A Z E L C E N T R A L R E G I S T R Y # https://registry.bazel.build/
###############################################################################
# https://github.com/bazelbuild/rules_rust/releases
bazel_dep(name = "rules_rust", version = "0.46.0")
bazel_dep(name = "rules_rust", version = "0.57.0")

###############################################################################
# T O O L C H A I N S
Expand Down Expand Up @@ -73,8 +73,8 @@ cc_library(
)
```

In some cases, you have to deal with non standard naming. In that case you define a
custom gen_rule to take of that and then define a cc_import.
In some cases, you have to deal with non standard naming. In that case you define a
custom gen_rule to take of that and then define a cc_import.

```starlark
load("@rules_cc//cc:defs.bzl", "cc_import", "cc_library")
Expand All @@ -94,10 +94,10 @@ cc_import(
)
```

## Rust Callsite
## Rust Callsite

On the Rust side, interestingly, you just declare the cc_import as a dependency of
your Rust target.
your Rust target.

```starlark
load("@rules_rust//rust:defs.bzl", "rust_shared_library")
Expand All @@ -111,7 +111,7 @@ rust_shared_library(
)
```

Then in your Rust source file, your create a FFI binding and wrap the call to it into unsafe. You can do that because the Rust standard library provides all the c raw types for FFI so you just import them and unsafe informs the Rust borrow checker to hold off certain checks. The public Rust function f() can then be used in regular Rust code.
Then in your Rust source file, your create a FFI binding and wrap the call to it into unsafe. You can do that because the Rust standard library provides all the c raw types for FFI so you just import them and unsafe informs the Rust borrow checker to hold off certain checks. The public Rust function f() can then be used in regular Rust code.

```rust
use std::os::raw::c_int;
Expand All @@ -132,6 +132,3 @@ pub fn f() {
And with that, you build your FFI target as usual:

`bazel build //...`



2 changes: 1 addition & 1 deletion examples/proto/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module(
# B A Z E L C E N T R A L R E G I S T R Y # https://registry.bazel.build/
###############################################################################
# https://github.com/bazelbuild/rules_rust/releases
bazel_dep(name = "rules_rust", version = "0.54.1")
bazel_dep(name = "rules_rust", version = "0.0.0")
local_path_override(
module_name = "rules_rust",
path = "../..",
Expand Down
4 changes: 2 additions & 2 deletions examples/proto_with_toolchain/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ module(
# B A Z E L C E N T R A L R E G I S T R Y # https://registry.bazel.build/
###############################################################################
# https://github.com/bazelbuild/rules_rust/releases
bazel_dep(name = "rules_rust", version = "0.54.1")
bazel_dep(name = "rules_rust", version = "0.0.0")
local_path_override(
module_name = "rules_rust",
path = "../..",
)

bazel_dep(name = "rules_rust_prost", version = "0.54.1")
bazel_dep(name = "rules_rust_prost", version = "0.0.0")
local_path_override(
module_name = "rules_rust_prost",
path = "../../extensions/prost",
Expand Down
2 changes: 1 addition & 1 deletion examples/sys/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module(
# B A Z E L C E N T R A L R E G I S T R Y # https://registry.bazel.build/
###############################################################################
# https://github.com/bazelbuild/rules_rust/releases
bazel_dep(name = "rules_rust", version = "0.46.0")
bazel_dep(name = "rules_rust", version = "0.0.0")
local_path_override(
module_name = "rules_rust",
path = "../..",
Expand Down
4 changes: 2 additions & 2 deletions extensions/bindgen/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

module(
name = "rules_rust_bindgen",
version = "0.56.0",
version = "0.57.0",
)

bazel_dep(
name = "rules_rust",
version = "0.56.0",
version = "0.57.0",
)
bazel_dep(
name = "bazel_features",
Expand Down
4 changes: 2 additions & 2 deletions extensions/mdbook/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

module(
name = "rules_rust_mdbook",
version = "0.56.0",
version = "0.57.0",
)

bazel_dep(
name = "rules_rust",
version = "0.56.0",
version = "0.57.0",
)
bazel_dep(
name = "rules_cc",
Expand Down
4 changes: 2 additions & 2 deletions extensions/prost/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

module(
name = "rules_rust_prost",
version = "0.56.0",
version = "0.57.0",
)

bazel_dep(
name = "rules_rust",
version = "0.56.0",
version = "0.57.0",
)
bazel_dep(
name = "platforms",
Expand Down
4 changes: 2 additions & 2 deletions extensions/protobuf/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

module(
name = "rules_rust_protobuf",
version = "0.56.0",
version = "0.57.0",
)

bazel_dep(
name = "rules_rust",
version = "0.56.0",
version = "0.57.0",
)
bazel_dep(
name = "bazel_features",
Expand Down
4 changes: 2 additions & 2 deletions extensions/wasm_bindgen/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

module(
name = "rules_rust_wasm_bindgen",
version = "0.56.0",
version = "0.57.0",
)

bazel_dep(
name = "rules_rust",
version = "0.56.0",
version = "0.57.0",
)
bazel_dep(
name = "bazel_features",
Expand Down
2 changes: 1 addition & 1 deletion test/no_std/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module(
version = "0.0.0",
)

bazel_dep(name = "rules_rust", version = "0.55.6")
bazel_dep(name = "rules_rust", version = "0.0.0")
local_path_override(
module_name = "rules_rust",
path = "../..",
Expand Down
2 changes: 1 addition & 1 deletion version.bzl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""The version of rules_rust."""

VERSION = "0.56.0"
VERSION = "0.57.0"
Loading