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

Unpin compiler-builtins #545

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 3 additions & 3 deletions .github/workflows/m68k.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ jobs:
- name: Build sample project with target defined as JSON spec
run: |
./y.sh prepare --only-libcore --cross
./y.sh build --sysroot --target-triple m68k-unknown-linux-gnu --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json
./y.sh build --sysroot --features compiler_builtins/no-f16-f128 --target-triple m68k-unknown-linux-gnu --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json
./y.sh cargo build --manifest-path=./tests/hello-world/Cargo.toml --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json
./y.sh clean all

- name: Build
run: |
./y.sh prepare --only-libcore --cross
./y.sh build --sysroot --target-triple m68k-unknown-linux-gnu
./y.sh build --sysroot --features compiler_builtins/no-f16-f128 --target-triple m68k-unknown-linux-gnu
CG_GCC_TEST_TARGET=m68k-unknown-linux-gnu cargo test
./y.sh clean all

Expand All @@ -107,4 +107,4 @@ jobs:

- name: Run tests
run: |
./y.sh test --release --clean --build-sysroot ${{ matrix.commands }}
./y.sh test --release --clean --build-sysroot --sysroot-features compiler_builtins/no-f16-f128 ${{ matrix.commands }}
10 changes: 6 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 23 additions & 14 deletions build_system/build_sysroot/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions build_system/build_sysroot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ resolver = "2"

[dependencies]
core = { path = "./sysroot_src/library/core" }
# TODO: after the sync, revert to using version 0.1.
# compiler_builtins = "0.1"
compiler_builtins = "=0.1.109"
compiler_builtins = "0.1"
alloc = { path = "./sysroot_src/library/alloc" }
std = { path = "./sysroot_src/library/std", features = ["panic_unwind", "backtrace"] }
test = { path = "./sysroot_src/library/test" }
Expand All @@ -19,6 +17,22 @@ rustc-std-workspace-core = { path = "./sysroot_src/library/rustc-std-workspace-c
rustc-std-workspace-alloc = { path = "./sysroot_src/library/rustc-std-workspace-alloc" }
rustc-std-workspace-std = { path = "./sysroot_src/library/rustc-std-workspace-std" }

# For compiler-builtins we always use a high number of codegen units.
# The goal here is to place every single intrinsic into its own object
# file to avoid symbol clashes with the system libgcc if possible. Note
# that this number doesn't actually produce this many object files, we
# just don't create more than this number of object files.
#
# It's a bit of a bummer that we have to pass this here, unfortunately.
# Ideally this would be specified through an env var to Cargo so Cargo
# knows how many CGUs are for this specific crate, but for now
# per-crate configuration isn't specifiable in the environment.
[profile.dev.package.compiler_builtins]
codegen-units = 10000

[profile.release.package.compiler_builtins]
codegen-units = 10000

[profile.release]
debug = "limited"
#lto = "fat" # TODO(antoyo): re-enable when the failing LTO tests regarding proc-macros are fixed.
15 changes: 4 additions & 11 deletions build_system/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@ impl BuildArg {

while let Some(arg) = args.next() {
match arg.as_str() {
"--features" => {
if let Some(arg) = args.next() {
build_arg.flags.push("--features".to_string());
build_arg.flags.push(arg.as_str().into());
} else {
return Err(
"Expected a value after `--features`, found nothing".to_string()
);
}
}
"--sysroot" => {
build_arg.build_sysroot = true;
}
Expand All @@ -55,7 +45,6 @@ impl BuildArg {
r#"
`build` command help:

--features [arg] : Add a new feature [arg]
--sysroot : Build with sysroot"#
);
ConfigInfo::show_usage();
Expand Down Expand Up @@ -142,6 +131,10 @@ pub fn build_sysroot(env: &HashMap<String, String>, config: &ConfigInfo) -> Resu
}

let mut args: Vec<&dyn AsRef<OsStr>> = vec![&"cargo", &"build", &"--target", &config.target];
for feature in &config.features {
args.push(&"--features");
args.push(feature);
}

if config.no_default_features {
rustflags.push_str(" -Csymbol-mangling-version=v0");
Expand Down
11 changes: 10 additions & 1 deletion build_system/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl ConfigFile {
}
}

#[derive(Default, Debug)]
#[derive(Default, Debug, Clone)]
pub struct ConfigInfo {
pub target: String,
pub target_triple: String,
Expand All @@ -122,6 +122,7 @@ pub struct ConfigInfo {
pub no_download: bool,
pub no_default_features: bool,
pub backend: Option<String>,
pub features: Vec<String>,
}

impl ConfigInfo {
Expand All @@ -132,6 +133,13 @@ impl ConfigInfo {
args: &mut impl Iterator<Item = String>,
) -> Result<bool, String> {
match arg {
"--features" => {
if let Some(arg) = args.next() {
self.features.push(arg);
} else {
return Err("Expected a value after `--features`, found nothing".to_string());
}
}
"--target" => {
if let Some(arg) = args.next() {
self.target = arg;
Expand Down Expand Up @@ -442,6 +450,7 @@ impl ConfigInfo {
pub fn show_usage() {
println!(
"\
--features [arg] : Add a new feature [arg]
--target-triple [arg] : Set the target triple to [arg]
--target [arg] : Set the target to [arg]
--out-dir : Location where the files will be generated
Expand Down
13 changes: 12 additions & 1 deletion build_system/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ struct TestArg {
current_part: Option<usize>,
sysroot_panic_abort: bool,
config_info: ConfigInfo,
sysroot_features: Vec<String>,
}

impl TestArg {
Expand Down Expand Up @@ -127,6 +128,14 @@ impl TestArg {
"--sysroot-panic-abort" => {
test_arg.sysroot_panic_abort = true;
}
"--sysroot-features" => match args.next() {
Some(feature) if !feature.is_empty() => {
test_arg.sysroot_features.push(feature);
}
_ => {
return Err(format!("Expected an argument after `{}`, found nothing", arg))
}
},
"--help" => {
show_usage();
return Ok(None);
Expand Down Expand Up @@ -250,7 +259,9 @@ fn mini_tests(env: &Env, args: &TestArg) -> Result<(), String> {
fn build_sysroot(env: &Env, args: &TestArg) -> Result<(), String> {
// FIXME: create a function "display_if_not_quiet" or something along the line.
println!("[BUILD] sysroot");
build::build_sysroot(env, &args.config_info)?;
let mut config = args.config_info.clone();
config.features.extend(args.sysroot_features.iter().cloned());
build::build_sysroot(env, &config)?;
Ok(())
}

Expand Down
34 changes: 0 additions & 34 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,48 +228,14 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
"__builtin_umul_overflow",
"__builtin_usubll_overflow",
"__builtin_usub_overflow",
"sqrtf",
"sqrt",
"__builtin_powif",
"__builtin_powi",
"sinf",
"sin",
"cosf",
"cos",
"powf",
"pow",
"expf",
"exp",
"exp2f",
"exp2",
"logf",
"log",
"log10f",
"log10",
"log2f",
"log2",
"fmaf",
"fma",
"fabsf",
"fabs",
"fminf",
"fmin",
"fmaxf",
"fmax",
"copysignf",
"copysign",
"floorf",
"floor",
"ceilf",
"ceil",
"truncf",
"trunc",
"rintf",
"rint",
"nearbyintf",
"nearbyint",
"roundf",
"round",
];

for builtin in builtins.iter() {
Expand Down
21 changes: 7 additions & 14 deletions src/intrinsic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,13 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
// https://github.com/rust-lang/rust-clippy/issues/12497
// and leave `else if use_integer_compare` to be placed "as is".
#[allow(clippy::suspicious_else_formatting)]
let llval = match name {
let value = match name {
_ if simple.is_some() => {
// FIXME(antoyo): remove this cast when the API supports function.
let func = unsafe {
std::mem::transmute::<Function<'gcc>, RValue<'gcc>>(simple.expect("simple"))
};
self.call(
self.type_void(),
None,
None,
let func = simple.expect("simple function");
self.cx.context.new_call(
self.location,
func,
&args.iter().map(|arg| arg.immediate()).collect::<Vec<_>>(),
None,
None,
)
}
sym::likely => self.expect(args[0].immediate(), true),
Expand Down Expand Up @@ -383,7 +376,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {

_ if name_str.starts_with("simd_") => {
match generic_simd_intrinsic(self, name, callee_ty, args, ret_ty, llret_ty, span) {
Ok(llval) => llval,
Ok(value) => value,
Err(()) => return Ok(()),
}
}
Expand All @@ -396,9 +389,9 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
if let PassMode::Cast { cast: ref ty, .. } = fn_abi.ret.mode {
let ptr_llty = self.type_ptr_to(ty.gcc_type(self));
let ptr = self.pointercast(result.val.llval, ptr_llty);
self.store(llval, ptr, result.val.align);
self.store(value, ptr, result.val.align);
} else {
OperandRef::from_immediate_or_packed_pair(self, llval, result.layout)
OperandRef::from_immediate_or_packed_pair(self, value, result.layout)
.val
.store(self, result);
}
Expand Down
Loading
Loading