Remove useless target features

This commit is contained in:
Ruihan Li 2025-07-29 10:09:22 +08:00 committed by Tate, Hongliang Tian
parent d73f1016a1
commit 3e88b92ddd
2 changed files with 35 additions and 39 deletions

31
osdk/Cargo.lock generated
View File

@ -417,6 +417,12 @@ dependencies = [
"windows-sys",
]
[[package]]
name = "fastrand"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
[[package]]
name = "getrandom"
version = "0.3.3"
@ -626,6 +632,12 @@ dependencies = [
"xmas-elf",
]
[[package]]
name = "linux-raw-sys"
version = "0.4.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab"
[[package]]
name = "linux-raw-sys"
version = "0.9.4"
@ -835,6 +847,19 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3582f63211428f83597b51b2ddb88e2a91a9d52d12831f9d08f5e624e8977422"
[[package]]
name = "rustix"
version = "0.38.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
dependencies = [
"bitflags 2.9.0",
"errno",
"libc",
"linux-raw-sys 0.4.15",
"windows-sys",
]
[[package]]
name = "rustix"
version = "1.0.7"
@ -844,7 +869,7 @@ dependencies = [
"bitflags 2.9.0",
"errno",
"libc",
"linux-raw-sys",
"linux-raw-sys 0.9.4",
"windows-sys",
]
@ -951,7 +976,7 @@ dependencies = [
"cfg-if",
"fastrand",
"once_cell",
"rustix",
"rustix 0.38.44",
"windows-sys",
]
@ -1120,7 +1145,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3fabb953106c3c8eea8306e4393700d7657561cb43122571b172bbfb7c7ba1d"
dependencies = [
"env_home",
"rustix",
"rustix 1.0.7",
"winsafe",
]

View File

@ -40,11 +40,11 @@ pub fn make_install_bzimage(
let target_json = legacy32_rust_target_json();
let gen_target_json_path = target_dir.as_ref().join("x86_64-i386_pm-none.json");
std::fs::write(&gen_target_json_path, target_json).unwrap();
let arch = SetupInstallArch::Other(gen_target_json_path.canonicalize().unwrap());
let arch = gen_target_json_path.canonicalize().unwrap();
install_setup_with_arch(
setup_install_dir,
setup_target_dir,
&arch,
arch.to_str().unwrap(),
aster_elf,
encoding,
);
@ -53,7 +53,7 @@ pub fn make_install_bzimage(
install_setup_with_arch(
setup_install_dir,
setup_target_dir,
&SetupInstallArch::X86_64,
"x86_64-unknown-none",
aster_elf,
encoding,
);
@ -152,15 +152,10 @@ pub fn make_elf_for_qemu(install_dir: impl AsRef<Path>, elf: &AsterBin, strip: b
)
}
enum SetupInstallArch {
X86_64,
Other(PathBuf),
}
fn install_setup_with_arch(
install_dir: impl AsRef<Path>,
target_dir: impl AsRef<Path>,
arch: &SetupInstallArch,
arch: &str,
aster_elf: &AsterBin,
encoding: PayloadEncoding,
) {
@ -170,36 +165,15 @@ fn install_setup_with_arch(
let target_dir = std::fs::canonicalize(target_dir).unwrap();
let mut cmd = new_command_checked_exists("cargo");
let mut rustflags = vec![
let rustflags = [
"-Cdebuginfo=2",
"-Ccode-model=kernel",
"-Crelocation-model=pie",
"-Zplt=yes",
"-Zrelax-elf-relocations=yes",
"-Crelro-level=full",
"-Ctarget-feature=+crt-static",
];
let target_feature_args = match arch {
SetupInstallArch::X86_64 => {
concat!(
"-Ctarget-feature=",
"+crt-static",
",-adx",
",-aes",
",-avx",
",-avx2",
",-fxsr",
",-sse",
",-sse2",
",-sse3",
",-sse4.1",
",-sse4.2",
",-ssse3",
",-xsave",
)
}
SetupInstallArch::Other(_) => "-Ctarget-feature=+crt-static",
};
rustflags.push(target_feature_args);
cmd.env("RUSTFLAGS", rustflags.join(" "));
cmd.env("PAYLOAD_FILE", encode_kernel_to_file(aster_elf, encoding));
cmd.arg("install").arg("linux-bzimage-setup");
@ -212,10 +186,7 @@ fn install_setup_with_arch(
} else {
cmd.arg("--version").arg(env!("CARGO_PKG_VERSION"));
}
cmd.arg("--target").arg(match arch {
SetupInstallArch::X86_64 => "x86_64-unknown-none",
SetupInstallArch::Other(path) => path.to_str().unwrap(),
});
cmd.arg("--target").arg(arch);
cmd.arg("-Zbuild-std=core,alloc,compiler_builtins");
cmd.arg("-Zbuild-std-features=compiler-builtins-mem");
// Specify the build target directory to avoid cargo running