Commit Graph

49 Commits

Author SHA1 Message Date
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
klensy
dd34581ec9 edition 2018 2023-08-07 21:04:25 +03:00
danakj
fb77604e79 Add the weak-intrinsics feature
When enabled, the weak-intrinsics feature will cause all intrinsics
functions to be marked with weak linkage (i.e. `#[linkage = "weak"])
so that they can be replaced at link time by a stronger symbol.

This can be set to use C++ intrinsics from the compiler-rt library,
as it will avoid Rust's implementation replacing the compiler-rt
implementation as long as the compiler-rt symbols are linked as
strong symbols. Typically this requires the compiler-rt library to
be explicitly specified in the link command.

Addresses https://github.com/rust-lang/compiler-builtins/issues/525.

Without weak-intrinsics, from nm:
```
00000000 W __aeabi_memclr8  // Is explicitly weak
00000000 T __udivsi3  // Is not.
```

With weak-intrinsics, from nm:
```
00000000 W __aeabi_memclr8  // Is explicitly weak
00000000 W __udivsi3  // Is weak due to weak-intrinsics
```
2023-05-19 17:35:00 -04:00
Lokathor
8568a33255 restrict linkage to platforms using ELF binaries
on windows and apple (which don't use ELF) we can't apply weak linkage
2022-07-28 09:42:18 -06:00
Lokathor
011f92c877 add weak linkage to the ARM AEABI division functions 2022-07-22 17:14:18 -06:00
Amanieu d'Antras
5bdeade2c4 Fix typo in __aeabi_uldivmod
Accidentally introduced in #452
2022-02-09 21:01:07 +00:00
Amanieu d'Antras
f03c7fd6af Wrap all intrinsics in the intrinsics! macro
This ensures that each intrinsic ends up in a separate module, which in
turn (because rustc treats compiler_builtins specially) will result in
each intrinsic ending up in its own object file. This allows the linker
to only pick up object files for intrinsics that are missing and avoids
duplicate symbol definition errors.
2022-02-06 09:20:43 +00:00
Amanieu d'Antras
4abfecabef Import the asm! macro from core::arch
It is going to be removed from the prelude due to the decision in
https://github.com/rust-lang/rust/issues/87228
2021-12-09 23:57:26 +00:00
Yuki Okushi
c041104afd Suppress some warnings 2021-05-31 20:53:15 +09:00
bjorn3
5dd043525a Fix typo 2021-04-10 16:03:19 +02:00
Amanieu d'Antras
2608f8392c Replace llvm_asm! with asm! 2021-04-02 20:43:11 +01:00
Joseph Richey
5c294cedc0 Move from an "asm" flag to a "no-asm" feature flag (#386)
* Use a no-asm feature instead of an asm feature

This works better as core/alloc/std have trouble supporting default
featues in this crate.

Signed-off-by: Joe Richey <joerichey@google.com>

* Have no-asm disable arm assembly intrinsics

Signed-off-by: Joe Richey <joerichey@google.com>
2020-11-09 09:24:25 -06:00
pca006132
f9bf5fee78 Use weak linkage for aeabi memory functions (#385) 2020-10-14 11:10:38 -05:00
Alex Crichton
0e69cc8817 Switch to using llvm_asm! instead of asm! (#351)
* Switch to using `llvm_asm!` instead of `asm!`

* Run rustfmt

* Fix how LTO is specified on nightly
2020-04-29 15:30:10 -05:00
Ralf Jung
29ea38c623 remove unused imports 2019-07-13 11:00:15 +02:00
Ralf Jung
f4bc012b26 avoid ptr::write which might panic in debug mode 2019-07-13 10:55:54 +02:00
Jordan Rhee
cab813bf74 Fix undefined symbol errors on windows/arm
Fix undefined symbol linker errors when building rust for windows/arm
by excluding unneeded symbols. The errors are:

  = note: lib.def : error LNK2001: unresolved external symbol __aeabi_memclr4
  lib.def : error LNK2001: unresolved external symbol __aeabi_memclr8
  lib.def : error LNK2001: unresolved external symbol __aeabi_memmove4
  lib.def : error LNK2001: unresolved external symbol __aeabi_memmove8
2019-02-27 11:39:49 -08:00
Jordan Rhee
6310b74d85 Support windows/arm target 2018-09-06 09:27:24 -07:00
Tim Neumann
f83c8529e7 Fix incorrect names used / generated on ARM 2018-03-27 14:32:01 +02:00
Dan Gohman
3bd28c8b6d Add "volatile" and "memory" clobber to asm! that doesn't fall through.
Use the "volatile" option and the "memory" clobber on inline asm that does
things like return directly, to reduce the chances of compilers rearranging
the code.
2017-11-15 12:49:10 -08:00
Alex Crichton
79b55c48ca Fix unused imports on iOS 2017-07-03 19:11:34 -07:00
Jorge Aparicio
b9d6291682 no aeabi_mem* symbols on iOS, weak symbols on thumb, normal symbols elsewhere 2017-06-30 18:06:25 -05:00
Jorge Aparicio
f096e02f63 optimize 32-bit aligned mem{cpy,clr,set} intrinsics for ARM
this reduces the execution time of all these routines by 40-70%
2017-06-29 22:40:58 -05:00
Alex Crichton
6792390e3e Enable the intrinsics program on thumb 2017-06-25 10:09:50 -07:00
Alex Crichton
f9db3c5b32 Don't test mangled names on thumb
We are both the "real compiler-rt" and the "to be tested one".
2017-06-24 12:54:35 -07:00
Alex Crichton
e7008c8609 Don't check for references to panics with debug assertions 2017-06-24 11:44:50 -07:00
Alex Crichton
3eff54a4ee Don't generate unmangled aeabi with gen-tests
The symbols they delgate to also don't exist...
2017-06-24 11:34:10 -07:00
Alex Crichton
6db18f6536 Handle aeabi aliasing
Objects in compiler-rt may have two symbols, so this makes sure that we don't
bring in those objects by accident by defining the aliases ourselves.
2017-06-23 15:55:11 -07:00
Alex Crichton
0e5562c38d Remove executable bit on arm.rs 2017-06-23 11:21:15 -07:00
Jorge Aparicio
0869e5b93a remove arm tests from the old test suite 2017-04-10 16:35:08 -05:00
Wilfried Chauveau
b3e33508a0 impl (unsigned/signed) int to single/double precision float conversion based on llvm algorithms. 2017-03-06 11:55:57 -05:00
Jorge Aparicio
9916fa670c implement float subtraction
as a + (-b)
2017-02-08 10:10:40 -05:00
Jorge Aparicio
3a4e6ce2f4 use AAPCS calling convention on all aeabi intrinsics
also, on ARM, inline(always) the actual implementation of the intrinsics so we
end with code like this:

```
00000000 <__aeabi_dadd>:
    (implementation here)
```

instead of "trampolines" like this:

```
00000000 <__aeabi_dadd>:
    (shuffle registers)
    (call __adddf3)

00000000 <__adddf3>:
    (implementation here)
```

closes #116
2017-02-07 09:41:26 -05:00
Jorge Aparicio
b8d6652035 add implementations of memcpy et al
behind the "mem" Cargo feature, which used to be named "weak"

fixes #126
2016-12-17 23:06:37 -05:00
Jorge Aparicio
cb9b1f82e3 add an opt-in cargo feature to build intrinsics from compiler-rt source
closes #63
cc #66
2016-09-29 16:06:24 -05:00
homunkulus
bc07830e09 Auto merge of #71 - japaric:aeabi-aliases, r=japaric
add missing aeabi aliases
2016-09-22 22:55:43 +00:00
Jorge Aparicio
2d630eedfd add missing aeabi aliases 2016-09-22 17:02:36 -05:00
Jorge Aparicio
a83c11232e avoid division overflow in idivmod test 2016-09-22 10:32:15 -05:00
Matt Ickstadt
35d68d8ab2 Move integer functions to separate module 2016-08-20 15:55:06 -05:00
Amanieu d'Antras
59fe09c493 Add tests for ARM division builtins 2016-08-19 12:13:02 +01:00
Amanieu d'Antras
161234b8b3 Add signed division functions 2016-08-19 12:13:02 +01:00
Amanieu d'Antras
d668c385ac Fix inline assembly to work on ARMv6-M 2016-08-13 17:29:38 +01:00
Amanieu d'Antras
1a60c3d52f Various changes 2016-08-13 09:56:40 +01:00
Jorge Aparicio
d66ff75198 note about calling convention 2016-08-11 00:36:19 -05:00
Jorge Aparicio
4c93f05195 port __udivmodsi4, aeabi_uidivmod and udivsi3
also rewrite these last two new aeabi intrinsics as naked functions
2016-08-11 00:26:16 -05:00
Jorge Aparicio
2eb2ac115d port udivmoddi4 and __aeabi_uldivmod 2016-08-11 00:26:12 -05:00
Amanieu d'Antras
6f22c85b25 Remove builtins that are not called by LLVM 2016-08-08 08:25:11 +01:00
Amanieu d'Antras
9fbd25b4cd Rewrite the arm mem* builtins without asm and naked functions 2016-08-08 07:25:32 +01:00
Jorge Aparicio
773fd1a707 initial commit 2016-08-07 15:58:21 -05:00