Skip to content

Commit 11f2b5a

Browse files
committed
Unpin compiler-builtins
1 parent 98ed962 commit 11f2b5a

File tree

10 files changed

+84
-90
lines changed

10 files changed

+84
-90
lines changed

.github/workflows/m68k.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ jobs:
8585
- name: Build sample project with target defined as JSON spec
8686
run: |
8787
./y.sh prepare --only-libcore --cross
88-
./y.sh build --sysroot --target-triple m68k-unknown-linux-gnu --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json
88+
./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
8989
./y.sh cargo build --manifest-path=./tests/hello-world/Cargo.toml --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json
9090
./y.sh clean all
9191
9292
- name: Build
9393
run: |
9494
./y.sh prepare --only-libcore --cross
95-
./y.sh build --sysroot --target-triple m68k-unknown-linux-gnu
95+
./y.sh build --sysroot --features compiler_builtins/no-f16-f128 --target-triple m68k-unknown-linux-gnu
9696
CG_GCC_TEST_TARGET=m68k-unknown-linux-gnu cargo test
9797
./y.sh clean all
9898
@@ -107,4 +107,4 @@ jobs:
107107

108108
- name: Run tests
109109
run: |
110-
./y.sh test --release --clean --build-sysroot ${{ matrix.commands }}
110+
./y.sh test --release --clean --build-sysroot --sysroot-features compiler_builtins/no-f16-f128 ${{ matrix.commands }}

Cargo.lock

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build_system/build_sysroot/Cargo.lock

Lines changed: 23 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build_system/build_sysroot/Cargo.toml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ resolver = "2"
66

77
[dependencies]
88
core = { path = "./sysroot_src/library/core" }
9-
# TODO: after the sync, revert to using version 0.1.
10-
# compiler_builtins = "0.1"
11-
compiler_builtins = "=0.1.109"
9+
compiler_builtins = "0.1"
1210
alloc = { path = "./sysroot_src/library/alloc" }
1311
std = { path = "./sysroot_src/library/std", features = ["panic_unwind", "backtrace"] }
1412
test = { path = "./sysroot_src/library/test" }
@@ -22,3 +20,19 @@ rustc-std-workspace-std = { path = "./sysroot_src/library/rustc-std-workspace-st
2220
[profile.release]
2321
debug = "limited"
2422
#lto = "fat" # TODO(antoyo): re-enable when the failing LTO tests regarding proc-macros are fixed.
23+
24+
# For compiler-builtins we always use a high number of codegen units.
25+
# The goal here is to place every single intrinsic into its own object
26+
# file to avoid symbol clashes with the system libgcc if possible. Note
27+
# that this number doesn't actually produce this many object files, we
28+
# just don't create more than this number of object files.
29+
#
30+
# It's a bit of a bummer that we have to pass this here, unfortunately.
31+
# Ideally this would be specified through an env var to Cargo so Cargo
32+
# knows how many CGUs are for this specific crate, but for now
33+
# per-crate configuration isn't specifiable in the environment.
34+
[profile.dev.package.compiler_builtins]
35+
codegen-units = 10000
36+
37+
[profile.release.package.compiler_builtins]
38+
codegen-units = 10000

build_system/src/build.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,6 @@ impl BuildArg {
2323

2424
while let Some(arg) = args.next() {
2525
match arg.as_str() {
26-
"--features" => {
27-
if let Some(arg) = args.next() {
28-
build_arg.flags.push("--features".to_string());
29-
build_arg.flags.push(arg.as_str().into());
30-
} else {
31-
return Err(
32-
"Expected a value after `--features`, found nothing".to_string()
33-
);
34-
}
35-
}
3626
"--sysroot" => {
3727
build_arg.build_sysroot = true;
3828
}
@@ -55,7 +45,6 @@ impl BuildArg {
5545
r#"
5646
`build` command help:
5747
58-
--features [arg] : Add a new feature [arg]
5948
--sysroot : Build with sysroot"#
6049
);
6150
ConfigInfo::show_usage();
@@ -142,6 +131,10 @@ pub fn build_sysroot(env: &HashMap<String, String>, config: &ConfigInfo) -> Resu
142131
}
143132

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

146139
if config.no_default_features {
147140
rustflags.push_str(" -Csymbol-mangling-version=v0");

build_system/src/config.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl ConfigFile {
9797
}
9898
}
9999

100-
#[derive(Default, Debug)]
100+
#[derive(Default, Debug, Clone)]
101101
pub struct ConfigInfo {
102102
pub target: String,
103103
pub target_triple: String,
@@ -122,6 +122,7 @@ pub struct ConfigInfo {
122122
pub no_download: bool,
123123
pub no_default_features: bool,
124124
pub backend: Option<String>,
125+
pub features: Vec<String>,
125126
}
126127

127128
impl ConfigInfo {
@@ -132,6 +133,13 @@ impl ConfigInfo {
132133
args: &mut impl Iterator<Item = String>,
133134
) -> Result<bool, String> {
134135
match arg {
136+
"--features" => {
137+
if let Some(arg) = args.next() {
138+
self.features.push(arg);
139+
} else {
140+
return Err("Expected a value after `--features`, found nothing".to_string());
141+
}
142+
}
135143
"--target" => {
136144
if let Some(arg) = args.next() {
137145
self.target = arg;
@@ -442,6 +450,7 @@ impl ConfigInfo {
442450
pub fn show_usage() {
443451
println!(
444452
"\
453+
--features [arg] : Add a new feature [arg]
445454
--target-triple [arg] : Set the target triple to [arg]
446455
--target [arg] : Set the target to [arg]
447456
--out-dir : Location where the files will be generated

build_system/src/test.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ struct TestArg {
9292
current_part: Option<usize>,
9393
sysroot_panic_abort: bool,
9494
config_info: ConfigInfo,
95+
sysroot_features: Vec<String>,
9596
}
9697

9798
impl TestArg {
@@ -127,6 +128,14 @@ impl TestArg {
127128
"--sysroot-panic-abort" => {
128129
test_arg.sysroot_panic_abort = true;
129130
}
131+
"--sysroot-features" => match args.next() {
132+
Some(feature) if !feature.is_empty() => {
133+
test_arg.sysroot_features.push(feature);
134+
}
135+
_ => {
136+
return Err(format!("Expected an argument after `{}`, found nothing", arg))
137+
}
138+
},
130139
"--help" => {
131140
show_usage();
132141
return Ok(None);
@@ -250,7 +259,9 @@ fn mini_tests(env: &Env, args: &TestArg) -> Result<(), String> {
250259
fn build_sysroot(env: &Env, args: &TestArg) -> Result<(), String> {
251260
// FIXME: create a function "display_if_not_quiet" or something along the line.
252261
println!("[BUILD] sysroot");
253-
build::build_sysroot(env, &args.config_info)?;
262+
let mut config = args.config_info.clone();
263+
config.features.extend(args.sysroot_features.iter().cloned());
264+
build::build_sysroot(env, &config)?;
254265
Ok(())
255266
}
256267

src/context.rs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -228,48 +228,14 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
228228
"__builtin_umul_overflow",
229229
"__builtin_usubll_overflow",
230230
"__builtin_usub_overflow",
231-
"sqrtf",
232-
"sqrt",
233231
"__builtin_powif",
234232
"__builtin_powi",
235-
"sinf",
236-
"sin",
237-
"cosf",
238-
"cos",
239-
"powf",
240-
"pow",
241-
"expf",
242-
"exp",
243-
"exp2f",
244-
"exp2",
245-
"logf",
246-
"log",
247-
"log10f",
248-
"log10",
249-
"log2f",
250-
"log2",
251-
"fmaf",
252-
"fma",
253233
"fabsf",
254234
"fabs",
255-
"fminf",
256-
"fmin",
257-
"fmaxf",
258-
"fmax",
259235
"copysignf",
260236
"copysign",
261-
"floorf",
262-
"floor",
263-
"ceilf",
264-
"ceil",
265-
"truncf",
266-
"trunc",
267-
"rintf",
268-
"rint",
269237
"nearbyintf",
270238
"nearbyint",
271-
"roundf",
272-
"round",
273239
];
274240

275241
for builtin in builtins.iter() {

src/intrinsic/mod.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,13 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
127127
// https://github.com/rust-lang/rust-clippy/issues/12497
128128
// and leave `else if use_integer_compare` to be placed "as is".
129129
#[allow(clippy::suspicious_else_formatting)]
130-
let llval = match name {
130+
let value = match name {
131131
_ if simple.is_some() => {
132-
// FIXME(antoyo): remove this cast when the API supports function.
133-
let func = unsafe {
134-
std::mem::transmute::<Function<'gcc>, RValue<'gcc>>(simple.expect("simple"))
135-
};
136-
self.call(
137-
self.type_void(),
138-
None,
139-
None,
132+
let func = simple.expect("simple function");
133+
self.cx.context.new_call(
134+
self.location,
140135
func,
141136
&args.iter().map(|arg| arg.immediate()).collect::<Vec<_>>(),
142-
None,
143-
None,
144137
)
145138
}
146139
sym::likely => self.expect(args[0].immediate(), true),
@@ -383,7 +376,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
383376

384377
_ if name_str.starts_with("simd_") => {
385378
match generic_simd_intrinsic(self, name, callee_ty, args, ret_ty, llret_ty, span) {
386-
Ok(llval) => llval,
379+
Ok(value) => value,
387380
Err(()) => return Ok(()),
388381
}
389382
}
@@ -396,9 +389,9 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
396389
if let PassMode::Cast { cast: ref ty, .. } = fn_abi.ret.mode {
397390
let ptr_llty = self.type_ptr_to(ty.gcc_type(self));
398391
let ptr = self.pointercast(result.val.llval, ptr_llty);
399-
self.store(llval, ptr, result.val.align);
392+
self.store(value, ptr, result.val.align);
400393
} else {
401-
OperandRef::from_immediate_or_packed_pair(self, llval, result.layout)
394+
OperandRef::from_immediate_or_packed_pair(self, value, result.layout)
402395
.val
403396
.store(self, result);
404397
}

0 commit comments

Comments
 (0)