Skip to content

Commit f8c56a2

Browse files
committed
Move example to a non-default crate
1 parent 010120a commit f8c56a2

File tree

9 files changed

+54
-26
lines changed

9 files changed

+54
-26
lines changed

Cargo.toml

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
[workspace]
2+
resolver = "3"
23
members = [
34
"compiler-builtins",
45
"builtins-test",
6+
"builtins-test-intrinsics",
7+
]
8+
# Exclude builtins-test-intrinsics because features
9+
default-members = [
10+
"compiler-builtins",
11+
"builtins-test",
512
]
6-
resolver = "3"
713

814
[profile.release]
915
panic = 'abort'

builtins-test-intrinsics/Cargo.toml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "builtins-test-intrinsics"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
compiler_builtins = { path = "../compiler-builtins", features = ["compiler-builtins"]}
8+
panic-handler = { path = '../crates/panic-handler' }

builtins-test-intrinsics/build.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
mod builtins_configure {
2+
include!("../compiler-builtins/configure.rs");
3+
}
4+
5+
fn main() {
6+
println!("cargo::rerun-if-changed=../configure.rs");
7+
8+
let target = builtins_configure::Target::from_env();
9+
builtins_configure::configure_f16_f128(&target);
10+
builtins_configure::configure_aliases(&target);
11+
}
File renamed without changes.

builtins-test/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ fn main() {
3030
println!("cargo::rerun-if-changed=../configure.rs");
3131

3232
let target = builtins_configure::Target::from_env();
33+
builtins_configure::configure_aliases(&target);
3334
let mut features = HashSet::new();
3435

3536
// These platforms do not have f128 symbols available in their system libraries, so

ci/run.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ done
121121
rm -f "${rlib_paths[@]}"
122122

123123
build_intrinsics() {
124-
cargo build --target "$target" -v --example intrinsics "$@"
124+
cargo build --target "$target" -v --package builtins-test-intrinsics "$@"
125125
}
126126

127127
# Verify that we haven't drop any intrinsic/symbol
@@ -133,9 +133,9 @@ build_intrinsics --features c --release
133133
# Verify that there are no undefined symbols to `panic` within our
134134
# implementations
135135
CARGO_PROFILE_DEV_LTO=true \
136-
cargo build --target "$target" --example intrinsics
136+
cargo build --target "$target" --package builtins-test-intrinsics
137137
CARGO_PROFILE_RELEASE_LTO=true \
138-
cargo build --target "$target" --example intrinsics --release
138+
cargo build --target "$target" --package builtins-test-intrinsics --release
139139

140140
# Ensure no references to any symbols from core
141141
update_rlib_paths

compiler-builtins/Cargo.toml

-4
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ rustc-dep-of-std = ['compiler-builtins', 'core']
7272
# are not normally public but are required by the `testcrate`
7373
public-test-deps = []
7474

75-
[[example]]
76-
name = "intrinsics"
77-
required-features = ["compiler-builtins"]
78-
7975
# [workspace]
8076
# resolver = "2"
8177
# members = ["testcrate"]

compiler-builtins/build.rs

+3-17
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
use std::{collections::BTreeMap, env, path::PathBuf, sync::atomic::Ordering};
2-
31
mod configure;
42

5-
use configure::{configure_f16_f128, Target};
3+
use configure::{configure_aliases, configure_f16_f128, Target};
4+
use std::{collections::BTreeMap, env, path::PathBuf, sync::atomic::Ordering};
65

76
fn main() {
87
println!("cargo::rerun-if-changed=build.rs");
@@ -13,6 +12,7 @@ fn main() {
1312

1413
configure_check_cfg();
1514
configure_f16_f128(&target);
15+
configure_aliases(&target);
1616

1717
configure_libm(&target);
1818

@@ -71,20 +71,6 @@ fn main() {
7171
}
7272
}
7373

74-
// To compile intrinsics.rs for thumb targets, where there is no libc
75-
println!("cargo::rustc-check-cfg=cfg(thumb)");
76-
if llvm_target[0].starts_with("thumb") {
77-
println!("cargo:rustc-cfg=thumb")
78-
}
79-
80-
// compiler-rt `cfg`s away some intrinsics for thumbv6m and thumbv8m.base because
81-
// these targets do not have full Thumb-2 support but only original Thumb-1.
82-
// We have to cfg our code accordingly.
83-
println!("cargo::rustc-check-cfg=cfg(thumb_1)");
84-
if llvm_target[0] == "thumbv6m" || llvm_target[0] == "thumbv8m.base" {
85-
println!("cargo:rustc-cfg=thumb_1")
86-
}
87-
8874
// Only emit the ARM Linux atomic emulation on pre-ARMv6 architectures. This
8975
// includes the old androideabi. It is deprecated but it is available as a
9076
// rustc target (arm-linux-androideabi).

compiler-builtins/configure.rs

+21-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::env;
66
#[allow(dead_code)]
77
pub struct Target {
88
pub triple: String,
9+
pub triple_split: Vec<String>,
910
pub opt_level: String,
1011
pub cargo_features: Vec<String>,
1112
pub os: String,
@@ -19,6 +20,8 @@ pub struct Target {
1920

2021
impl Target {
2122
pub fn from_env() -> Self {
23+
let triple = env::var("TARGET").unwrap();
24+
let triple_split = triple.split('-').map(ToOwned::to_owned).collect();
2225
let little_endian = match env::var("CARGO_CFG_TARGET_ENDIAN").unwrap().as_str() {
2326
"little" => true,
2427
"big" => false,
@@ -30,7 +33,8 @@ impl Target {
3033
.collect();
3134

3235
Self {
33-
triple: env::var("TARGET").unwrap(),
36+
triple,
37+
triple_split,
3438
os: env::var("CARGO_CFG_TARGET_OS").unwrap(),
3539
opt_level: env::var("OPT_LEVEL").unwrap(),
3640
cargo_features,
@@ -56,6 +60,22 @@ impl Target {
5660
}
5761
}
5862

63+
pub fn configure_aliases(target: &Target) {
64+
// To compile intrinsics.rs for thumb targets, where there is no libc
65+
println!("cargo::rustc-check-cfg=cfg(thumb)");
66+
if target.triple_split[0].starts_with("thumb") {
67+
println!("cargo:rustc-cfg=thumb")
68+
}
69+
70+
// compiler-rt `cfg`s away some intrinsics for thumbv6m and thumbv8m.base because
71+
// these targets do not have full Thumb-2 support but only original Thumb-1.
72+
// We have to cfg our code accordingly.
73+
println!("cargo::rustc-check-cfg=cfg(thumb_1)");
74+
if target.triple_split[0] == "thumbv6m" || target.triple_split[0] == "thumbv8m.base" {
75+
println!("cargo:rustc-cfg=thumb_1")
76+
}
77+
}
78+
5979
/// Configure whether or not `f16` and `f128` support should be enabled.
6080
pub fn configure_f16_f128(target: &Target) {
6181
// Set whether or not `f16` and `f128` are supported at a basic level by LLVM. This only means

0 commit comments

Comments
 (0)