diff --git a/examples/aya-tool/xtask/src/build_ebpf.rs b/examples/aya-tool/xtask/src/build_ebpf.rs index f541371c..e7507cc4 100644 --- a/examples/aya-tool/xtask/src/build_ebpf.rs +++ b/examples/aya-tool/xtask/src/build_ebpf.rs @@ -43,7 +43,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> { let dir = PathBuf::from("myapp-ebpf"); let target = format!("--target={}", opts.target); let args = vec![ - "+nightly", "build", "--verbose", target.as_str(), @@ -52,8 +51,14 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> { "--profile", opts.profile.as_str(), ]; + + // Command::new creates a child process which inherits all env variables. This means env + // vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed + // so the rust-toolchain.toml file in the -ebpf folder is honored. + let status = Command::new("cargo") .current_dir(&dir) + .env_remove("RUSTUP_TOOLCHAIN") .args(&args) .status() .expect("failed to build bpf program"); diff --git a/examples/cgroup-skb-egress/xtask/src/build_ebpf.rs b/examples/cgroup-skb-egress/xtask/src/build_ebpf.rs index 983055a8..81de1ee9 100644 --- a/examples/cgroup-skb-egress/xtask/src/build_ebpf.rs +++ b/examples/cgroup-skb-egress/xtask/src/build_ebpf.rs @@ -44,7 +44,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> { let dir = PathBuf::from("cgroup-skb-egress-ebpf"); let target = format!("--target={}", opts.target); let mut args = vec![ - "+nightly", "build", "--verbose", target.as_str(), @@ -54,8 +53,14 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> { if opts.release { args.push("--release") } + + // Command::new creates a child process which inherits all env variables. This means env + // vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed + // so the rust-toolchain.toml file in the -ebpf folder is honored. + let status = Command::new("cargo") .current_dir(&dir) + .env_remove("RUSTUP_TOOLCHAIN") .args(&args) .status() .expect("failed to build bpf program"); diff --git a/examples/kprobetcp/xtask/src/build_ebpf.rs b/examples/kprobetcp/xtask/src/build_ebpf.rs index 26fa19dd..9b514a20 100644 --- a/examples/kprobetcp/xtask/src/build_ebpf.rs +++ b/examples/kprobetcp/xtask/src/build_ebpf.rs @@ -43,7 +43,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> { let dir = PathBuf::from("kprobetcp-ebpf"); let target = format!("--target={}", opts.target); let mut args = vec![ - "+nightly", "build", "--verbose", target.as_str(), @@ -53,8 +52,14 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> { if opts.release { args.push("--release") } + + // Command::new creates a child process which inherits all env variables. This means env + // vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed + // so the rust-toolchain.toml file in the -ebpf folder is honored. + let status = Command::new("cargo") .current_dir(&dir) + .env_remove("RUSTUP_TOOLCHAIN") .args(&args) .status() .expect("failed to build bpf program"); diff --git a/examples/lsm-nice/xtask/src/build_ebpf.rs b/examples/lsm-nice/xtask/src/build_ebpf.rs index e2e63247..200096a8 100644 --- a/examples/lsm-nice/xtask/src/build_ebpf.rs +++ b/examples/lsm-nice/xtask/src/build_ebpf.rs @@ -43,7 +43,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> { let dir = PathBuf::from("lsm-nice-ebpf"); let target = format!("--target={}", opts.target); let args = vec![ - "+nightly", "build", "--verbose", target.as_str(), @@ -52,8 +51,14 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> { "--profile", opts.profile.as_str(), ]; + + // Command::new creates a child process which inherits all env variables. This means env + // vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed + // so the rust-toolchain.toml file in the -ebpf folder is honored. + let status = Command::new("cargo") .current_dir(&dir) + .env_remove("RUSTUP_TOOLCHAIN") .args(&args) .status() .expect("failed to build bpf program"); diff --git a/examples/tc-egress/xtask/src/build_ebpf.rs b/examples/tc-egress/xtask/src/build_ebpf.rs index 557d0e8e..90c2b9b0 100644 --- a/examples/tc-egress/xtask/src/build_ebpf.rs +++ b/examples/tc-egress/xtask/src/build_ebpf.rs @@ -44,7 +44,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> { let dir = PathBuf::from("tc-egress-ebpf"); let target = format!("--target={}", opts.target); let mut args = vec![ - "+nightly", "build", "--verbose", target.as_str(), @@ -54,8 +53,14 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> { if opts.release { args.push("--release") } + + // Command::new creates a child process which inherits all env variables. This means env + // vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed + // so the rust-toolchain.toml file in the -ebpf folder is honored. + let status = Command::new("cargo") .current_dir(&dir) + .env_remove("RUSTUP_TOOLCHAIN") .args(&args) .status() .expect("failed to build bpf program"); diff --git a/examples/xdp-drop/xtask/src/build_ebpf.rs b/examples/xdp-drop/xtask/src/build_ebpf.rs index 09decf2f..ee527d5b 100644 --- a/examples/xdp-drop/xtask/src/build_ebpf.rs +++ b/examples/xdp-drop/xtask/src/build_ebpf.rs @@ -44,7 +44,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> { let dir = PathBuf::from("xdp-drop-ebpf"); let target = format!("--target={}", opts.target); let mut args = vec![ - "+nightly", "build", "--verbose", target.as_str(), @@ -54,8 +53,14 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> { if opts.release { args.push("--release") } + + // Command::new creates a child process which inherits all env variables. This means env + // vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed + // so the rust-toolchain.toml file in the -ebpf folder is honored. + let status = Command::new("cargo") .current_dir(&dir) + .env_remove("RUSTUP_TOOLCHAIN") .args(&args) .status() .expect("failed to build bpf program"); diff --git a/examples/xdp-hello/xtask/src/build_ebpf.rs b/examples/xdp-hello/xtask/src/build_ebpf.rs index e6f157e1..3f14eec2 100644 --- a/examples/xdp-hello/xtask/src/build_ebpf.rs +++ b/examples/xdp-hello/xtask/src/build_ebpf.rs @@ -44,7 +44,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> { let dir = PathBuf::from("xdp-hello-ebpf"); let target = format!("--target={}", opts.target); let mut args = vec![ - "+nightly", "build", "--verbose", target.as_str(), @@ -54,8 +53,14 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> { if opts.release { args.push("--release") } + + // Command::new creates a child process which inherits all env variables. This means env + // vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed + // so the rust-toolchain.toml file in the -ebpf folder is honored. + let status = Command::new("cargo") .current_dir(&dir) + .env_remove("RUSTUP_TOOLCHAIN") .args(&args) .status() .expect("failed to build bpf program"); diff --git a/examples/xdp-log/xtask/src/build_ebpf.rs b/examples/xdp-log/xtask/src/build_ebpf.rs index 9e1f2882..c476aded 100644 --- a/examples/xdp-log/xtask/src/build_ebpf.rs +++ b/examples/xdp-log/xtask/src/build_ebpf.rs @@ -44,7 +44,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> { let dir = PathBuf::from("xdp-log-ebpf"); let target = format!("--target={}", opts.target); let mut args = vec![ - "+nightly", "build", "--verbose", target.as_str(), @@ -54,8 +53,14 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> { if opts.release { args.push("--release") } + + // Command::new creates a child process which inherits all env variables. This means env + // vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed + // so the rust-toolchain.toml file in the -ebpf folder is honored. + let status = Command::new("cargo") .current_dir(&dir) + .env_remove("RUSTUP_TOOLCHAIN") .args(&args) .status() .expect("failed to build bpf program");