Skip to content

Commit

Permalink
Add a feature to compile intrinsics that are missing on the system fo…
Browse files Browse the repository at this point in the history
…r testing
  • Loading branch information
tgross35 committed Apr 19, 2024
1 parent 8941385 commit 3741cb0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ cc = { optional = true, version = "1.0" }
panic-handler = { path = 'crates/panic-handler' }

[features]
default = ["compiler-builtins"]
default = ["compiler-builtins", "complete-system-rt"]

# Enable compilation of C code in compiler-rt, filling in some more optimized
# implementations and also filling in unimplemented intrinsics
Expand Down Expand Up @@ -77,6 +77,12 @@ public-test-deps = []
# it during linking.
weak-intrinsics = []

# On some systems, there are no symbols available in their vendored compiler-rt
# that we would want to use for testing, e.g. MacOS does not provide `f128`
# intrinsics. Enabling this feature builds missing symbols from C so we have
# something to test against.
complete-system-rt = ["cc"]

[[example]]
name = "intrinsics"
required-features = ["compiler-builtins"]
Expand Down
9 changes: 9 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ mod c {

if (target_arch == "aarch64" || target_arch == "arm64ec") && consider_float_intrinsics {
sources.extend(&[
("__comparetf2", "comparetf2.c"),
("__extenddftf2", "extenddftf2.c"),
("__extendsftf2", "extendsftf2.c"),
("__fixtfdi", "fixtfdi.c"),
Expand Down Expand Up @@ -499,11 +500,15 @@ mod c {
sources.extend(&[
("__extenddftf2", "extenddftf2.c"),
("__netf2", "comparetf2.c"),
("__addtf3", "addtf3.c"),
("__multf3", "multf3.c"),
("__subtf3", "subtf3.c"),
("__fixtfsi", "fixtfsi.c"),
("__floatsitf", "floatsitf.c"),
("__fixunstfsi", "fixunstfsi.c"),
("__floatunsitf", "floatunsitf.c"),
("__fe_getround", "fp_mode.c"),
("__divtf3", "divtf3.c"),
("__trunctfdf2", "trunctfdf2.c"),
("__trunctfsf2", "trunctfsf2.c"),
]);
Expand All @@ -513,11 +518,15 @@ mod c {
sources.extend(&[
("__extenddftf2", "extenddftf2.c"),
("__netf2", "comparetf2.c"),
("__addtf3", "addtf3.c"),
("__multf3", "multf3.c"),
("__subtf3", "subtf3.c"),
("__fixtfsi", "fixtfsi.c"),
("__floatsitf", "floatsitf.c"),
("__fixunstfsi", "fixunstfsi.c"),
("__floatunsitf", "floatunsitf.c"),
("__fe_getround", "fp_mode.c"),
("__divtf3", "divtf3.c"),
("__trunctfdf2", "trunctfdf2.c"),
("__trunctfsf2", "trunctfsf2.c"),
]);
Expand Down
3 changes: 2 additions & 1 deletion testcrate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ utest-cortex-m-qemu = { default-features = false, git = "https://github.com/japa
utest-macros = { git = "https://github.com/japaric/utest" }

[features]
default = ["mangled-names"]
default = ["mangled-names", "complete-system-rt"]
c = ["compiler_builtins/c"]
no-asm = ["compiler_builtins/no-asm"]
mem = ["compiler_builtins/mem"]
mangled-names = ["compiler_builtins/mangled-names"]
complete-system-rt = ["compiler_builtins/complete-system-rt"]

0 comments on commit 3741cb0

Please sign in to comment.