Skip to content

Commit 32a41fa

Browse files
committed
examples: Honor rust-toolchain.toml file in xtask
Signed-off-by: Michal Rostecki <[email protected]>
1 parent 9d69141 commit 32a41fa

File tree

8 files changed

+48
-8
lines changed

8 files changed

+48
-8
lines changed

examples/aya-tool/xtask/src/build_ebpf.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
4343
let dir = PathBuf::from("myapp-ebpf");
4444
let target = format!("--target={}", opts.target);
4545
let args = vec![
46-
"+nightly",
4746
"build",
4847
"--verbose",
4948
target.as_str(),
@@ -52,8 +51,14 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
5251
"--profile",
5352
opts.profile.as_str(),
5453
];
54+
55+
// Command::new creates a child process which inherits all env variables. This means env
56+
// vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed
57+
// so the rust-toolchain.toml file in the -ebpf folder is honored.
58+
5559
let status = Command::new("cargo")
5660
.current_dir(&dir)
61+
.env_remove("RUSTUP_TOOLCHAIN")
5762
.args(&args)
5863
.status()
5964
.expect("failed to build bpf program");

examples/cgroup-skb-egress/xtask/src/build_ebpf.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
4444
let dir = PathBuf::from("cgroup-skb-egress-ebpf");
4545
let target = format!("--target={}", opts.target);
4646
let mut args = vec![
47-
"+nightly",
4847
"build",
4948
"--verbose",
5049
target.as_str(),
@@ -54,8 +53,14 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
5453
if opts.release {
5554
args.push("--release")
5655
}
56+
57+
// Command::new creates a child process which inherits all env variables. This means env
58+
// vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed
59+
// so the rust-toolchain.toml file in the -ebpf folder is honored.
60+
5761
let status = Command::new("cargo")
5862
.current_dir(&dir)
63+
.env_remove("RUSTUP_TOOLCHAIN")
5964
.args(&args)
6065
.status()
6166
.expect("failed to build bpf program");

examples/kprobetcp/xtask/src/build_ebpf.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
4343
let dir = PathBuf::from("kprobetcp-ebpf");
4444
let target = format!("--target={}", opts.target);
4545
let mut args = vec![
46-
"+nightly",
4746
"build",
4847
"--verbose",
4948
target.as_str(),
@@ -53,8 +52,14 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
5352
if opts.release {
5453
args.push("--release")
5554
}
55+
56+
// Command::new creates a child process which inherits all env variables. This means env
57+
// vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed
58+
// so the rust-toolchain.toml file in the -ebpf folder is honored.
59+
5660
let status = Command::new("cargo")
5761
.current_dir(&dir)
62+
.env_remove("RUSTUP_TOOLCHAIN")
5863
.args(&args)
5964
.status()
6065
.expect("failed to build bpf program");

examples/lsm-nice/xtask/src/build_ebpf.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
4343
let dir = PathBuf::from("lsm-nice-ebpf");
4444
let target = format!("--target={}", opts.target);
4545
let args = vec![
46-
"+nightly",
4746
"build",
4847
"--verbose",
4948
target.as_str(),
@@ -52,8 +51,14 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
5251
"--profile",
5352
opts.profile.as_str(),
5453
];
54+
55+
// Command::new creates a child process which inherits all env variables. This means env
56+
// vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed
57+
// so the rust-toolchain.toml file in the -ebpf folder is honored.
58+
5559
let status = Command::new("cargo")
5660
.current_dir(&dir)
61+
.env_remove("RUSTUP_TOOLCHAIN")
5762
.args(&args)
5863
.status()
5964
.expect("failed to build bpf program");

examples/tc-egress/xtask/src/build_ebpf.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
4444
let dir = PathBuf::from("tc-egress-ebpf");
4545
let target = format!("--target={}", opts.target);
4646
let mut args = vec![
47-
"+nightly",
4847
"build",
4948
"--verbose",
5049
target.as_str(),
@@ -54,8 +53,14 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
5453
if opts.release {
5554
args.push("--release")
5655
}
56+
57+
// Command::new creates a child process which inherits all env variables. This means env
58+
// vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed
59+
// so the rust-toolchain.toml file in the -ebpf folder is honored.
60+
5761
let status = Command::new("cargo")
5862
.current_dir(&dir)
63+
.env_remove("RUSTUP_TOOLCHAIN")
5964
.args(&args)
6065
.status()
6166
.expect("failed to build bpf program");

examples/xdp-drop/xtask/src/build_ebpf.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
4444
let dir = PathBuf::from("xdp-drop-ebpf");
4545
let target = format!("--target={}", opts.target);
4646
let mut args = vec![
47-
"+nightly",
4847
"build",
4948
"--verbose",
5049
target.as_str(),
@@ -54,8 +53,14 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
5453
if opts.release {
5554
args.push("--release")
5655
}
56+
57+
// Command::new creates a child process which inherits all env variables. This means env
58+
// vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed
59+
// so the rust-toolchain.toml file in the -ebpf folder is honored.
60+
5761
let status = Command::new("cargo")
5862
.current_dir(&dir)
63+
.env_remove("RUSTUP_TOOLCHAIN")
5964
.args(&args)
6065
.status()
6166
.expect("failed to build bpf program");

examples/xdp-hello/xtask/src/build_ebpf.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
4444
let dir = PathBuf::from("xdp-hello-ebpf");
4545
let target = format!("--target={}", opts.target);
4646
let mut args = vec![
47-
"+nightly",
4847
"build",
4948
"--verbose",
5049
target.as_str(),
@@ -54,8 +53,14 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
5453
if opts.release {
5554
args.push("--release")
5655
}
56+
57+
// Command::new creates a child process which inherits all env variables. This means env
58+
// vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed
59+
// so the rust-toolchain.toml file in the -ebpf folder is honored.
60+
5761
let status = Command::new("cargo")
5862
.current_dir(&dir)
63+
.env_remove("RUSTUP_TOOLCHAIN")
5964
.args(&args)
6065
.status()
6166
.expect("failed to build bpf program");

examples/xdp-log/xtask/src/build_ebpf.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
4444
let dir = PathBuf::from("xdp-log-ebpf");
4545
let target = format!("--target={}", opts.target);
4646
let mut args = vec![
47-
"+nightly",
4847
"build",
4948
"--verbose",
5049
target.as_str(),
@@ -54,8 +53,14 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
5453
if opts.release {
5554
args.push("--release")
5655
}
56+
57+
// Command::new creates a child process which inherits all env variables. This means env
58+
// vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed
59+
// so the rust-toolchain.toml file in the -ebpf folder is honored.
60+
5761
let status = Command::new("cargo")
5862
.current_dir(&dir)
63+
.env_remove("RUSTUP_TOOLCHAIN")
5964
.args(&args)
6065
.status()
6166
.expect("failed to build bpf program");

0 commit comments

Comments
 (0)