Skip to content

Commit 510971a

Browse files
committed
Set empty RUSTFLAGS to ensure that no .cargo/config applies
Without the `RUSTFLAGS` environment variable set, cargo looks at `.cargo/config` files in all parent directories. Such a file can contain a `build.rustflags` key that would then be applied to the bootloader build too. Since some rustflags can break the build (e.g. `-C target-cpu=native`), we should prevent that. Creating a `cargo/.config` file with an empty `build.rustflags` key in the bootloader repository does not suffice for fixing this because cargo unifies arrays with the values defined in parent directories. So the only way to ensure that no rustflags are passed is to set the RUSTFLAGS environment variable to the empty string, exploiting the fact that it takes precedence over any `build.rustflags` key.
1 parent 3462674 commit 510971a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ impl Builder {
233233
cmd.arg("--release");
234234
cmd.env("KERNEL", kernel_bin_path);
235235
cmd.env("KERNEL_MANIFEST", &self.kernel_manifest_path);
236-
cmd.env_remove("RUSTFLAGS");
236+
cmd.env("RUSTFLAGS", "");
237237
cmd.env("XBUILD_SYSROOT_PATH", target_dir.join("bootloader-sysroot")); // for cargo-xbuild
238238
cmd
239239
};

0 commit comments

Comments
 (0)