Commit Graph

1088 Commits

Author SHA1 Message Date
Trevor Gross
54d96150b5 Update cfg to fix warnings 2024-05-11 09:56:55 +02:00
Trevor Gross
286944e479 Emit directives for cargo-check-cfg 2024-05-11 09:56:55 +02:00
Trevor Gross
ccfe0e3808 Deny warnings in CI
There are currently a lot of warnings printed in CI, mostly dead code.
Update CI to deny warnings.
2024-05-11 09:56:55 +02:00
Nicholas Bishop
e4e03883ed Enable chkstk/alloca intrinsics on i686-unknown-uefi 2024-05-08 21:47:12 -04:00
Amanieu d'Antras
2faef31e96 Release version 0.1.111 2024-05-04 19:57:27 +01:00
Patryk Wychowaniec
461682bd91 fix: Add #[avr_skip] for __addsf3 & __adddf3
It looks like I've forgotten about them [back in 2023](https://github.com/rust-lang/compiler-builtins/pull/527).
2024-05-04 19:50:22 +02:00
Amanieu d'Antras
060391b020 Release version 0.1.110 2024-05-04 15:31:14 +01:00
Martin Nordholts
8c0c504d4f Update reference to rustc-std-workspace-core 2024-05-04 14:56:01 +02:00
Amjad Alsharafi
ce8a0c346d Cleanup manged-names macro
Don't generate the whole function if we are not going to use `no_mangle`, there is no point
2024-05-03 13:27:03 +02:00
Amjad Alsharafi
e232a79146 Remove unneeded weak for optimized-c function
`weak` is only used with `no_mangle`
2024-05-03 13:27:03 +02:00
Amjad Alsharafi
2e096145c3 Apply weak attributes to all intrinsics
Removed the `weak-intrinsics` feature, so that all functions
will have the `weak` linkage attribute.

Also this fixed the bug in
https://github.com/rust-lang/rust/issues/124042.

Before this commit, generated code will be
```rust
pub extern "C" fn <name>(...) -> ... {
        // code...
}
pub mod <name> {
    #[linkage = "weak"]
    #[no_mangle]
    pub extern "C" fn <name>(...) -> ... {
        super::<name>(...)
    }
}
```

The issue is that there is 2 `weak` linkage, the first one is not required.
Along refactoring `weak` attributes, this was fixed.
2024-05-03 13:27:03 +02:00
beetrees
229babb1d0 Add builtins for f16/f128 float conversions 2024-05-02 13:49:24 +02:00
Amjad Alsharafi
656106f050 Updated libm to fix clippy warning 2024-04-30 23:28:43 +02:00
Amjad Alsharafi
f761f03822 Fix clippy warnings in math
The solution is not pretty, but not sure why we still get clippy
warning from one of the files in `libm` even though we use
`allow(clippy::all)`
2024-04-30 23:28:43 +02:00
Amjad Alsharafi
2ce9bc0cc1 Fix math libraries not being linked on some platforms
This is a continuation/fix of 018616e. In that commit, we made it add
the math functions to all platforms (except apple-targets and windows),
and use `weak` linking, so that it can be used if the system doesn't
have those functions.

Didn't notice `mod math` was behind another set of `cfg`, so removed it
as well here.
2024-04-30 23:28:43 +02:00
beetrees
a2587f7b02
Update status of 128-bit integers in README.md 2024-04-28 17:41:35 +01:00
Trevor Gross
1b679e5cee Apply some more fixes suggested by Shellcheck 2024-04-19 11:49:23 -04:00
Trevor Gross
a55604fd8c Add a way to run tests on non-linux machines
Allow using the `rust-lang/rust:nightly` docker image to run tests in
cases where the host rust and cargo cannot be used, such as non-linux
hosts.
2024-04-19 11:49:23 -04:00
Trevor Gross
d5bc2de9ec Add CI testing for AArch64 Darwin
The Apple ARM silicon has been around for a while now and hopefully will
become Rust Tier 1 at some point. Add it to CI since it is distinct
enough from aarch64-linux and x86_86-darwin that there may be
differences.
2024-04-16 14:04:47 -04:00
Trevor Gross
47f2241db9 Change aarch64_linux module and lse tests to have the same gating
Trying to run testcrate on non-linux aarch64 currently hits a
compilation error. Make this test linux-only, to be consistent with the
`aarch64_linux` module that it depends on.

Additionally, enable the `aarch64_linux` module for `target_arch =
"arm64ec"` to be the same as these tests.
2024-04-16 14:04:47 -04:00
Amanieu d'Antras
bd48df66bd Release 0.1.109 2024-04-10 13:16:43 +01:00
Amjad Alsharafi
6cf5c13e87 Do not include math intrinsics for windows and apple targets 2024-04-10 13:40:59 +02:00
Amjad Alsharafi
5416c204a9 Always have math functions but with weak linking attribute if we can
This is a replacement for https://github.com/rust-lang/libm/pull/290

This fixes crashes during compilations for targets that don't have math
symbols by default.

So, we will provide them libm symbols, but mark it as `weak` (if its
supported), so that the linker will choose the system builtin functions,
since those are sometimes more optimized.
If the linker couldn't find those, it will go with `libm`
implementation.
2024-04-10 13:40:59 +02:00
Ralf Jung
bf0ce314e9 add lib.miri.rs file for miri-test-libstd 2024-04-10 12:59:14 +02:00
Jeremy Drake
f23a83c53c Add __chkstk on i686-pc-windows-gnu.
libLLVMSupport.a(DynamicLibrary.cpp.obj) references ___chkstk, which is
an alias of __alloca in libgcc.  This crate provided __alloca, but
libgcc's implementation was also pulled in by the linker due to the
reference to ___chkstk, causing a multiple definition linker error.
Providing that symbol here prevents that.

Fixes #585
2024-04-07 13:08:27 -07:00
Kleis Auke Wolthuizen
f04f8a6a9d Sync x86 chkstk intrinsics with LLVM
Incorporates the following commits:
885d7b759b
1f9eff100c
7a5cba8bea
2024-03-29 19:51:56 +01:00
Daniel Paoliello
30182128c9 Add support for arm64ec 2024-03-28 09:20:13 -07:00
trevyn
dc1321a5ca Remove duplicate symbol workaround 2024-03-28 14:19:13 +00:00
WANG Rui
75624cc8ae Add compiler-rt fallbacks on loongarch64-musl 2024-03-28 14:12:16 +00:00
Ralf Jung
ce85d06f3b add c_unwind feature 2024-03-28 11:33:03 +01:00
Amanieu d'Antras
68b5a7a0ad Clean up and rework CI script 2024-03-28 10:17:42 +00:00
Amanieu d'Antras
079d7d857c Release 0.1.108 2024-02-04 06:40:51 +00:00
Nikita Popov
168bc9ecd7 Also don't build floatdixf and floatundixf 2024-02-02 10:04:55 +01:00
Nikita Popov
2f8b08f9e3 Remove 80-bit builtins entirely
It turns out that these also don't build on x86 + MSVC. Rather
than fixing up the condition, I'm just deleting them entirely.
As far as I know, Rust does not support 80-bit floats and has
no plan to support them, so we shouldn't need them.
2024-01-31 17:37:26 +01:00
Amanieu d'Antras
1cd23fa8b0
Bump to 0.1.107 (#571) 2024-01-31 08:36:00 +00:00
trevyn
f4dbd52ed5
Merge branch 'master' into wasm 2024-01-28 07:20:27 -08:00
Tyler Mandry
45a113effb Handle move of cpu_model.c
This happened in https://github.com/llvm/llvm-project/pull/75635/files
and shows up when building against a recent commit of LLVM.
2024-01-28 11:20:12 +00:00
Amanieu d'Antras
bb30119076
Merge pull request #569 from Kobzol/ci-check-success
CI: add a success conclusion job
2024-01-26 02:37:28 +00:00
BD103
845f4e75d1
fix: replace travis link with github actions link 2024-01-24 13:57:31 -05:00
Jakub Beránek
8ca492c7d7 CI: add a success conclusion job 2024-01-24 19:38:55 +01:00
Nikita Popov
105f0d834d Only add 80-bit long double source on x86
These no longer build on other architectures with LLVM 18. In
previous versions they used an incorrect float layout.
2024-01-22 13:04:44 +01:00
trevyn
d9065480c7
Merge branch 'master' into wasm 2024-01-18 09:36:53 +04:00
Amanieu d'Antras
0dc7f73408 Bump to 0.1.106 2024-01-18 01:27:08 +00:00
Amanieu d'Antras
56f10da22e
Merge pull request #563 from alistair23/alistair/riscv-builtins
build: Allow building C compiler-rt fallbacks for RISC-V
2024-01-18 01:25:47 +00:00
trevyn
0808cdeb67 build: Allow building C compiler-rt fallbacks for wasm 2024-01-09 02:11:00 +04:00
Taiki Endo
c464d5a38d Update actions/checkout action to v4 2024-01-09 00:07:27 +09:00
Alistair Francis
e898296fd9 build: Allow building C compiler-rt fallbacks for RISC-V
Now that https://github.com/rust-lang/rust/pull/117654 has been merged
the rust-lang/rust distribution containers contain RISC-V C compilers.

This means that we can now enable the "c" feature fallback.

Resolves: https://github.com/rust-lang/compiler-builtins/issues/350
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2023-12-20 09:47:37 +10:00
Amanieu d'Antras
72dbe301ff Bump to 0.1.105 2023-12-14 20:23:55 +00:00
Brian Cain
c4a7058a11 Add hexagon support
Signed-off-by: Brian Cain <bcain@quicinc.com>
2023-12-11 12:35:21 -08:00
Amanieu d'Antras
d46758a18f Bump to 0.1.104 2023-11-28 08:02:43 +00:00
Patryk Wychowaniec
c2c4c8e146
fix: Add (even more) #[avr_skip] for floats
Tale as old as the world - there's an ABI mismatch:
https://github.com/rust-lang/compiler-builtins/pull/527

Fortunately, newest GCCs (from v11, it seems) actually provide most of
those intrinsics (even for f64!), so that's pretty cool.

(the only intrinsics not provided by GCC are `__powisf2` & `__powidf2`,
but our codegen for AVR doesn't emit those anyway.)

Fixes https://github.com/rust-lang/rust/issues/118079.
2023-11-26 16:17:00 +01:00
Amanieu d'Antras
52959b5800 Bump to 0.1.103
There was a mistake in publishing the 0.1.102 release.
2023-11-04 00:29:46 +00:00
Amanieu d'Antras
44d0e30db9 Bump to 0.1.102 2023-11-04 00:28:36 +00:00
Amanieu d'Antras
2a9210b900
Merge pull request #554 from mchodzikiewicz/fix-math-for-riscv32 2023-10-31 22:43:37 +01:00
Michał Chodzikiewicz
8ec53915fe Enable math module for all "none" os targets
This was initially a bugfix that fixed gating math module for riscv32,
but conclusiion is it makes no sense to gate on target architecture.
2023-10-31 20:32:53 +01:00
Amanieu d'Antras
ed04e1e2b0
Merge pull request #552 from elbe0046/fix-aeabi-multi-def 2023-10-31 20:15:42 +01:00
Nicholas Bishop
e8509dd054 Enable src/math for all UEFI targets
This fixes various math operations on aarch64-unknown-uefi and
i686-unknown-uefi.
2023-10-27 20:21:08 +00:00
Grant Elbert
de2da94c49 intrinsics macro: fix non-weak aeabi generation
Signed-off-by: Grant Elbert <grant.elbert@smartthings.com>
2023-10-23 15:54:05 -05:00
Sebastian Imlay
25fa91e1b2 Add tvOS to build script 2023-10-06 17:35:20 -04:00
James Farrell
6595f36317 Generate outlined_atomics.rs in a deterministic order.
Also add a missing newline.
2023-08-28 22:14:18 +00:00
Amanieu d'Antras
5642f6ba4c Bump to 0.1.101 2023-08-12 10:28:45 +02:00
Sean Cross
10df3f61ad build: compile memory intrinsics on xous
Like SGX, Xous does not have any libc to link against. As a result,
memory intrinsics need to be available as part of `compiler_builtins`

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-12 07:50:26 +03:00
Amanieu d'Antras
14f4e11a86 Bump to 0.1.100 2023-08-07 23:37:59 +01:00
Amanieu d'Antras
6d180d8377
Merge pull request #546 from ankane/lgamma-r-mingw 2023-08-07 23:37:06 +01:00
klensy
a15a3a5df0 impl_binary_long allow to pass attribute 2023-08-07 21:23:23 +03:00
klensy
10f6ee84e3 allow internal_features, added in https://github.com/rust-lang/rust/pull/108955 2023-08-07 21:04:25 +03:00
klensy
dd34581ec9 edition 2018 2023-08-07 21:04:25 +03:00
Andrew Kane
2a197cb5c9 Add lgamma_r and lgammaf_r to MinGW 2023-07-31 15:08:37 -07:00
Amanieu d'Antras
0db7a3a020 Bump to 0.1.99 2023-07-30 23:56:13 +01:00
Andrew Kane
d4477f8218 Add lgamma_r and lgammaf_r to MSVC 2023-07-30 10:45:26 -07:00
Nicholas Bishop
da05233935 Add __chkstk for aarch64-unknown-uefi
This is based on compiler-rt/lib/builtins/aarch64/chkstk.S:
f8e19b3799
2023-07-22 15:05:30 -04:00
Amanieu d'Antras
05ca9048ad Bump to 0.1.98 2023-07-21 17:46:23 +01:00
Amanieu d'Antras
2b29ddcca7 Upgrade to libm 0.2.7 2023-07-21 17:45:47 +01:00
Amanieu d'Antras
2a14bca476 Bump to 0.1.97 2023-07-21 14:29:00 +01:00
Nicholas Bishop
7eca0c2ba3 Enable chkstk/alloca intrinsics on x86_64-unknown-uefi 2023-07-18 22:58:59 -04:00
Amanieu d'Antras
5cc74482b4 Bump to 0.1.96 2023-07-17 13:51:40 +01:00
Amanieu d'Antras
4cb7858aac
Merge pull request #538 from ankane/lgamma-r-msvc 2023-07-17 13:51:00 +01:00
Taiki Endo
716d2064f0 Fix build error on aarch64_be linux 2023-07-08 14:18:27 +09:00
Andrew Kane
e2f0b9cd3a Add lgamma_r and lgammaf_r to MSVC 2023-07-07 10:49:54 -04:00
Aaron Kutch
025076f763 Use the target_feature "zbb" instead of "b" for RISC-V 2023-07-06 17:20:32 -05:00
Amanieu d'Antras
28f2437614 Disable MIPS in CI
See https://github.com/rust-lang/compiler-team/issues/648
2023-07-06 20:20:19 +02:00
Amanieu d'Antras
8a3c3942a5 Bump to 0.1.95 2023-07-03 10:45:20 +02:00
jyn
c4e9f479ad Only compile outlined-atomics intrinsics on linux 2023-07-02 21:55:02 -05:00
Amanieu d'Antras
9234bedeea Bump to 0.1.94 2023-06-28 23:44:06 +01:00
Amanieu d'Antras
050754d4e3
Merge pull request #534 from kiffie/mips-core-float 2023-06-28 23:43:34 +01:00
Amanieu d'Antras
bb0d107feb
Merge pull request #532 from jyn514/lse.rs 2023-06-28 23:41:39 +01:00
Amanieu d'Antras
d5543c4cfb
Merge pull request #531 from knickish/float_div_subnormal_rounding 2023-06-28 23:41:07 +01:00
Stephan
c6fa74aacb enable simple f32/f64 support needed by core library 2023-06-28 21:35:33 +02:00
Joshua Nelson
1a41e48d11 fix tests to work with --feature c 2023-06-27 02:31:42 +00:00
kirk
379445f9a5 port updated version of llvm float div 2023-06-27 01:17:31 +00:00
Joshua Nelson
e7c4a45348 require naked functions to be unsafe again
they dereference raw pointers, so the caller needs to make sure the
pointer is valid.

note that this requires changing `maybe_use_optimized_c_shim` to support
unsafe functions.
2023-06-26 16:27:16 +00:00
Joshua Nelson
6242fd629e address review comments and fix CI
- implement CAS 16
- remove useless commented out symbol name
- support `feature("no-asm")`
- fix warnings when `feature("c")` is enabled
- rustfmt
2023-06-26 15:09:37 +00:00
Joshua Nelson
21c821c6c9 Port outline-atomics to rust
This has a very long history, summarized in
https://github.com/rust-lang/rust/issues/109064. This port is a very
minimal subset of `aarch64/lse.S` from LLVM's compiler-rt. In
particular, it is missing the following:

1. Any form of runtime dispatch between LL/SC and LSE.

Determining which version of the intrinsics to use
requires one of the following:

  i) `getauxval` from glibc. It's unclear whether `compiler_builtins` is
allowed to depend on libc at all, and musl doesn't even support
getauxval. Don't enshrine the requirement "de-facto" by making it
required for outline-atomics.

  ii) kernel support. Linux and FreeBSD have limited support, but it
requires an extremely recent kernel version and doesn't work at all under QEMU (https://github.com/rust-lang/rust/issues/109064#issuecomment-1494939904).

Instead, we hard-code LL/SC intrinsics. Users who want LSE support
should use the LLVM compiler-rt (if you're building from source in
rust-lang/rust, make sure you have `src/llvm-project` checked out
locally. the goal is to soon add a new `optimized-compiler-builtins`
option so this is easier to discover).

2. The global `___aarch64_have_lse_atomics` CTOR, required to do runtime
   dispatch. Thom Chiviolani has this to say about global CTORs:

> static ctors are problems because we are pretty eager about dead code elim
> in general if you have a module that isnt directly reference we will probably not have its static ctors
> also, while llvm has a super robust way to have a static ctor (theres s special "appending global" to use for c++), we dont use that and just have people make a #[used] static in a special section
> 1. the robust way kinda requires rust knowing that the argument is a static ctor (maybe a #[rustc_static_ctor] attribute). it also would be... finnicky, since on windows we actually care beyond being a static ctor, that we run as part in a specific group of ctors, which means a very specific section (one for TLS and the other for, uh, i dont remember)
> 2. we still actually have to codegen the cgu that isn't referenced. but maybe we could remember that it has that attribute and use that

So while this is possible in theory, it's decidedly non-trivial, and
needs invasive changes to rust itself. In any case, it doesn't matter
until we decide the story around libc.

3. The 16-byte (i128) version of compare_and_swap. This wouldn't be
   *too* hard to add, but it would be hard to test. The way I tested the
existing code was not just with unit tests but also by loading it as a
path dependency and running `x test core` - the latter caught several
bugs the unit tests didn't catch (because I originally wrote the tests
wrong). So I am slightly nervous about adding a 16-byte version that is
much more poorly tested than the other intrinsics.
2023-06-26 05:56:08 +00:00
Amanieu d'Antras
4a84991713
Merge pull request #529 from knickish/compile_warning_cleanup 2023-06-18 00:47:22 +02:00
kirk
fad0b3a431 change links in README to match reference code version used in CI 2023-06-17 14:35:00 +00:00
kirk
d3951c082e allow stable features lint, fix link formatting warning, add ignore block to intrinsics macro documentation 2023-06-17 14:11:31 +00:00
Amanieu d'Antras
2eeedaf25a Bump to 0.1.93 2023-06-12 15:37:22 +01:00
Patryk Wychowaniec
73f57893aa
fix: Add #[avr_skip] for floats
Same story as always, i.e. ABI mismatch:

- https://github.com/rust-lang/compiler-builtins/pull/462
- https://github.com/rust-lang/compiler-builtins/pull/466
- https://github.com/rust-lang/compiler-builtins/pull/513

I've made sure the changes work by rendering a Mandelbrot fractal:

```rust
#[arduino_hal::entry]
fn main() -> ! {
    let dp = arduino_hal::Peripherals::take().unwrap();
    let pins = arduino_hal::pins!(dp);
    let mut serial = arduino_hal::default_serial!(dp, pins, 57600);

    mandelbrot(&mut serial, 60, 40, -2.05, -1.12, 0.47, 1.12, 100);

    loop {
        //
    }
}

fn mandelbrot<T>(
    output: &mut T,
    viewport_width: i64,
    viewport_height: i64,
    x1: f32,
    y1: f32,
    x2: f32,
    y2: f32,
    max_iterations: i64,
) where
    T: uWrite,
{
    for viewport_y in 0..viewport_height {
        let y0 = y1 + (y2 - y1) * ((viewport_y as f32) / (viewport_height as f32));

        for viewport_x in 0..viewport_width {
            let x0 = x1 + (x2 - x1) * ((viewport_x as f32) / (viewport_width as f32));

            let mut x = 0.0;
            let mut y = 0.0;
            let mut iterations = max_iterations;

            while x * x + y * y <= 4.0 && iterations > 0 {
                let xtemp = x * x - y * y + x0;
                y = 2.0 * x * y + y0;
                x = xtemp;
                iterations -= 1;
            }

            let ch = "#%=-:,. "
                .chars()
                .nth((8.0 * ((iterations as f32) / (max_iterations as f32))) as _)
                .unwrap();

            _ = ufmt::uwrite!(output, "{}", ch);
        }

        _ = ufmt::uwriteln!(output, "");
    }
}
```

... where without avr_skips, the code printed an image full of only `#`.

Note that because libgcc doesn't provide implementations for f64, using
those (e.g. swapping f32 to f64 in the code above) will cause linking to
fail:

```
undefined reference to `__divdf3'
undefined reference to `__muldf3'
undefined reference to `__gedf2'
undefined reference to `__fixunsdfsi'
undefined reference to `__gtdf2'
```

Ideally compiler-builtins could jump right in and provide those, but f64
also require a special calling convention which hasn't been yet exposed
through LLVM.

Note that because using 64-bit floats on an 8-bit target is a pretty
niche thing to do, and because f64 floats don't work correctly anyway at
the moment (due to this ABI mismatch), we're not actually breaking
anything by skipping those functions, since any code that currently uses
f64 on AVR works by accident.

Closes https://github.com/rust-lang/rust/issues/108489.
2023-06-12 14:14:36 +02:00
Amanieu d'Antras
92d88fd7a4 Bump to 0.1.92 2023-05-20 10:50:12 +02:00
Amanieu d'Antras
2eb4f692bc Upgrade libm to 0.2.7 2023-05-20 10:49:41 +02:00