Skip to content

Commit e9938ce

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

File tree

9 files changed

+57
-88
lines changed

9 files changed

+57
-88
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 --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: 1 addition & 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" }

build_system/src/build.rs

Lines changed: 3 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,9 @@ 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(feature);
136+
}
145137

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

build_system/src/config.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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,16 @@ 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("--features".to_string());
139+
self.features.push(arg);
140+
} else {
141+
return Err(
142+
"Expected a value after `--features`, found nothing".to_string()
143+
);
144+
}
145+
}
135146
"--target" => {
136147
if let Some(arg) = args.next() {
137148
self.target = arg;
@@ -442,6 +453,7 @@ impl ConfigInfo {
442453
pub fn show_usage() {
443454
println!(
444455
"\
456+
--features [arg] : Add a new feature [arg]
445457
--target-triple [arg] : Set the target triple to [arg]
446458
--target [arg] : Set the target to [arg]
447459
--out-dir : Location where the files will be generated

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
}

src/intrinsic/simd.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -765,10 +765,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
765765
_ => return_error!(InvalidMonomorphization::UnrecognizedIntrinsic { span, name }),
766766
};
767767
let builtin_name = format!("{}{}", intr_name, elem_ty_str);
768-
let funcs = bx.cx.functions.borrow();
769-
let function = funcs
770-
.get(&builtin_name)
771-
.unwrap_or_else(|| panic!("unable to find builtin function {}", builtin_name));
768+
let function = bx.context.get_builtin_function(builtin_name);
772769

773770
// TODO(antoyo): add platform-specific behavior here for architectures that have these
774771
// intrinsics as instructions (for instance, gpus)
@@ -786,7 +783,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
786783
.map(|arg| bx.extract_element(arg.immediate(), index).to_rvalue())
787784
.collect()
788785
};
789-
vector_elements.push(bx.context.new_call(None, *function, &arguments));
786+
vector_elements.push(bx.context.new_call(None, function, &arguments));
790787
}
791788
let c = bx.context.new_rvalue_from_vector(None, vec_ty, &vector_elements);
792789
Ok(c)

0 commit comments

Comments
 (0)