Commit Graph

2518 Commits

Author SHA1 Message Date
Nick Desaulniers
6a3ace20c8
[libc] remove redundant call_once (#79226)
Missed cleanup from https://reviews.llvm.org/D134716.

Fixes: #79220
2024-01-23 15:38:12 -08:00
lntue
3a9ff32354
[libc] Fix implicit conversion in FEnvImpl for arm32 targets. (#79210) 2024-01-23 16:14:50 -05:00
lntue
d86a6eacf6
[libc] Fix aliasing function name got accidentally deleted in #79128. (#79203) 2024-01-23 14:19:34 -06:00
Roland McGrath
9122d19de4
Revert "[libc] Fix forward arm32 buildbot" (#79201)
Reverts llvm/llvm-project#79151, necessary to revert #79128, which broke
all production builds and landed without review.
2024-01-23 12:15:22 -08:00
Schrodinger ZHU Yifan
0cf20c2971
[libc] fix sysconf (#79159)
Apply previously discussed fix for `sysconf`
2024-01-23 13:31:48 -05:00
Joseph Huber
03d362db74
[libc][Docs] Update the GPU RPC documentation (#79069)
Summary:
This adds some more concrete information on the RPC interface. Hopefully
this is intelligable and provides some useful examples.
2024-01-23 11:40:58 -06:00
Guillaume Chatelet
2856db0d3b
[libc][NFC] Remove FPBits cast operator (#79142)
The semantics for casting can range from "bitcast" (same representation)
to "different representation", to "type promotion". Here we remove the
cast operator and force usage of `get_val` as the only function to get
the floating point value, making the intent clearer and more consistent.
2024-01-23 17:30:19 +01:00
Schrodinger ZHU Yifan
2cff46f8c0
[libc][NFC] use builder pattern for ErrnoSetterMatcher (#79153)
ErrnoSetterMatcher::returns can be misleading as it does not initialize
the errno. This is made worse as later on there is a switch statement on
the errno comparator using __builtin_unreachable(). This patch make
ErrnoSetterMatcher::returns give back a builder that is nomially
different from ErrnoSetterMatcher.
2024-01-23 10:43:24 -05:00
Guillaume Chatelet
dffa8039b1
[libc] Remove specific nan payload in math functions (#79133) 2024-01-23 16:37:36 +01:00
Guillaume Chatelet
10a3e9138e
[libc] Fix forward arm32 buildbot (#79151)
Fix forward #79128
2024-01-23 16:14:04 +01:00
Guillaume Chatelet
6b02d2f863
[reland][libc] Remove unnecessary FPBits functions and properties (#79128)
- reland #79113
- Fix aarch64 RISC-V build
2024-01-23 13:48:03 +01:00
Guillaume Chatelet
b524eed925
Revert "[libc] Remove unnecessary FPBits functions and properties" (#79118)
Reverts llvm/llvm-project#79113
It broke aarch64 build bot machines.
2024-01-23 11:51:18 +01:00
Guillaume Chatelet
3bc86bf3bf
[libc] Remove unnecessary FPBits functions and properties (#79113)
This patch reduces the surface of `FPBits`.
2024-01-23 11:48:28 +01:00
Schrodinger ZHU Yifan
86f05477d0
[libc] add missing header deps to getauxval (#79091)
`getauxval` depends on `libc.include.sys_auxv`
2024-01-23 00:57:07 -05:00
Schrodinger ZHU Yifan
3f740322c5
[libc] remove getauxval from arm32 entrypoint list (#79093)
`getauxval` depends on `open/read/close` which are not built on arm32.
Remove `getauxval` for now.
2024-01-23 00:56:40 -05:00
Schrodinger ZHU Yifan
4beb723710
[libc] implement sys/getauxval (#78493)
This PR implements `sys/getauxval`
that can be used in both overlay builds and full builds.
2024-01-22 21:47:31 -05:00
Petr Hosek
23edf782a2
[libc] Include missing RISC-V stdlib.h and math.h entrypoints (#79034)
This matches the entrypoints for baremetal ARM.
2024-01-22 18:46:48 -08:00
lntue
029bfd6329
[libc] Replace -nostdlib++ flag when building with gcc and add placement new operator to HermeticTestUtils.cpp. (#78906)
`-nostdlib++` is a clang-only flag. Replacing it with `-nostdlib` when
building with gcc.
2024-01-22 19:27:27 -05:00
Nick Desaulniers
1d5c16d780
[libc] default enable -ftrivial-auto-var-init=pattern (#78776)
Usage of uninitialized memory is a top memory safety issue in C++ codebases.
Help mitigate this somewhat by default initialize stack allocations to a
pattern (0xAA repeating).

Clang has received optimizations to sink these into control flow paths that
access such values to minimize the overhead of these added initializations.

If there's a measurable slowdown, we can add
-ftrivial-auto-var-init-max-size=<N> for some value N bytes if we have any
large stack allocations, or add attribute uninitialized to any variable
declarations.

Unsupported until GCC 12.1 / Clang 8.

Increases file size of libc.a from a full build by +8.79Ki (+0.2%).
2024-01-22 14:55:51 -08:00
Petr Hosek
f10ec8c774
[libc][riscv] Check if we have F or D extension before using them (#79036)
We shouldn't be using instructions that require F or D extensions
unconditionally before checking if those instructions are available.
2024-01-22 11:33:13 -08:00
Petr Hosek
c0a74ad90c
[libc] Use QUEUE_TYPEOF in STAILQ_LAST (#79011)
This is to ensure this macro is compatible with both C and C++.
2024-01-22 10:25:06 -08:00
Schrodinger ZHU Yifan
0fe20aa45e
[libc] support PIE relocations (#78993)
For some reasons, we are using `-fpie`
(libc/cmake/modules/LLVMLibCObjectRules.cmake:31) without supporting it.
According to @lntue, some of the hermetic tests are broken without
proper PIE support. This patch implements basic relocations support for
PIE.
2024-01-22 12:45:35 -05:00
Guillaume Chatelet
1edb43f62c
[reland][libc] FPRep builders return FPRep instead of raw StorageType (#78978)
Reland #78588
2024-01-22 15:18:16 +01:00
Guillaume Chatelet
bf7b8dae06
Revert "[libc] FPRep builders return FPRep instead of raw StorageType" (#78974)
Reverts llvm/llvm-project#78588
2024-01-22 15:04:50 +01:00
Guillaume Chatelet
cabe8be6bb
[libc] FPRep builders return FPRep instead of raw StorageType (#78588) 2024-01-22 15:02:21 +01:00
Petr Hosek
04c8558759 [libc] Fix issue introduces by #76449
Use correct CMake variable.
2024-01-22 03:26:18 +00:00
Schrodinger ZHU Yifan
be0fa319f9
[libc] fix unit tests in fullbuild (#78864)
fixes https://github.com/llvm/llvm-project/issues/78743

- For normal objects, the patch removes `RTTI` and exceptions in `fullbuild`
- For FP tests, the patch adds links to `stdc++` and `gcc_s` if `MPFR` is used.
2024-01-21 21:37:17 -05:00
Schrodinger ZHU Yifan
128d53f44c
[libc] add missing header dependencies for sched objects (#78741)
This patch fixes full build problems in
https://github.com/llvm/llvm-project/issues/78721 (the header problem).
The `libc.a` target can be built now.

As a separate issue, `check-libc` is failing because undefined symbols
from `libunwind`, which I do not actually know the reason yet. I will be
looking into it.
2024-01-21 11:13:12 -05:00
lntue
975deb3664
[libc] Add missing header ioctl.h on aarch64. (#78865) 2024-01-20 18:16:45 -05:00
lntue
1cc7cd46a9
[libc] Fix size_t used without including stddef.h in CPP/limit.h. (#78861) 2024-01-20 16:14:17 -05:00
lntue
ce8fcad5f4
[libc] Fix float.h header to include the system float.h first and add more definitions. (#78857) 2024-01-20 14:44:51 -05:00
Petr Hosek
b86d02375e
[libc] Redo the install targets (#78795)
Prior to this change, we wouldn't build headers that aren't referenced
by other parts of the libc which would result in a build error during
installation. To address this, we make the header target a dependency of
the libc archive. Additionally, we also redo the install targets, moving
the install targets closer to build targets and simplifying the
hierarchy and generally matching what we do for other runtimes.
2024-01-19 15:45:22 -08:00
Nick Desaulniers
2c0d20668a
[libc] remove extra -Werror (#78761)
-Werror is now a global default as of
commit c52b467875 ("Reapply "[libc] build with -Werror (#73966)"
(#74506)")
2024-01-19 12:28:06 -08:00
lntue
c80d68a676
[libc] Add float.h header. (#78737) 2024-01-19 12:04:34 -05:00
Joseph Huber
cebe4de66f [libc] Fix test failing on GPU using deprecated 'add_unittest'
Summary:
We use `add_libc_test' now because it works for both hermetic and unit
tests. If the test needs to be unit test only you use `UNIT_TEST_ONLY`
as an argument.
2024-01-19 10:38:41 -06:00
Guillaume Chatelet
508c4efe1e
[libc][NFC] Use Sign in NormalFloat (#78579) 2024-01-19 09:56:01 +01:00
Guillaume Chatelet
14f0c06f48
[libc] Fix is_subnormal for Intel Extended Precision (#78592)
Also turn a set of `get_biased_exponent() == 0` into `is_subnormal()`
which is clearer.
2024-01-19 09:36:03 +01:00
Guillaume Chatelet
28d64c1237
[libc][NFC] Simplify FPBits expressions (#78590) 2024-01-19 09:34:28 +01:00
Guillaume Chatelet
508c6aa8f3
[libc][NFC] Fix "type qualifiers ignored on cast result type" GCC warning (#78509)
GCC complains about "type qualifiers ignored on cast result type".
Upon investigation the correct fix was to remove all `volatile` and use the `-frounding-math` option.
2024-01-19 09:27:03 +01:00
Petr Hosek
dbc0955314
[libc] Provide sys/queue.h (#78081)
This header first appeared in 4.4BSD and is provided by a number of C
libraries including Newlib. Several of our embedded projects use this
header and so to make LLVM libc a drop-in replacement, we need to
provide it as well.

For the initial commit, we only implement singly linked variants (SLIST
and STAILQ). The doubly linked variants (LIST, TAILQ and CIRCLEQ) can be
implemented in the future as needed.
2024-01-18 21:45:58 -08:00
Joseph Huber
a9ca820529
[libc] Use clang's scoped atomics if available from the compiler (#74769)
Summary:
A recent patch in https://github.com/llvm/llvm-project/pull/72280
provided `clang` the ability to easily use scoped atomics. These are a
special modifier on atomics that some backends support. They are
intended for providing more fine-grained control over the affected
memory of an atomic action. The default is a "system" scope, e.g.
coherence with the GPU and CPU memory on a heterogeneous system. If we
use "device" scope, that implies that the memory is only ordered with
respect to the current GPU.

These builtins are direct replacements for the GCC atomic builitins in
cases where the backend doesn't do anything with the information, so
these should be a drop-in. This introduces some noise, but hopefully it
isn't too contentious.
2024-01-18 14:43:09 -06:00
Nick Desaulniers
3044d75485
[libc][arm] add more math.h entrypoints (#77839)
In particular, we have internal customers that would like to use nanf
and
scalbnf.

The differences between various entrypoint files can be checked via:

    $ comm -3 <(grep libc\.src path/to/entrypoints.txt | sort) \
       <(grep libc\.src path/to/other/entrypoints.txt | sort)
2024-01-18 08:18:13 -08:00
Nick Desaulniers
de03c46b8b
[libc] reverts for 32b arm (#78307)
These were fixed properly by f1f1875c18.

- Revert "[libc] temporarily set -Wno-shorten-64-to-32 (#77396)"
- Revert "[libc] make off_t 32b for 32b arm (#77350)"
2024-01-18 08:17:19 -08:00
Guillaume Chatelet
e6a6a90fe7
[libc][NFC] Use the Sign type for DyadicFloat (#78577) 2024-01-18 15:03:35 +01:00
Guillaume Chatelet
11ec512f44
[libc][NFC] Introduce a Sign type for FPBits (#78500)
Another patch is needed to cover `DyadicFloat` and `NormalFloat`
constructors.
2024-01-18 13:40:49 +01:00
Guillaume Chatelet
bc4f3e31a9
[libc][NFC] Selectively disable GCC warnings (#78462) 2024-01-18 10:36:21 +01:00
michaelrj-google
47d5967023
[libc][obvious] disable fabsf128 on aarch64 (#78511)
It's not working on the buildbot, so I've disabled it until we fix it.
2024-01-17 14:22:50 -08:00
Guillaume Chatelet
5ddd7bc38c
[reland][libc][NFC] Refactor FPBits and remove LongDoubleBits specialization (#78465)
- [reland] #78192 
- [reland] #78447 
- Turn `as` static function into a `to_storage_type` member function.
2024-01-17 17:38:48 +01:00
Guillaume Chatelet
d8627cb138
Revert "[reland][libc][NFC] Refactor FPBits and remove LongDoubleBits specialization" (#78457)
Reverts llvm/llvm-project#78447
This broke the gcc buildbot.
2024-01-17 16:50:52 +01:00
Guillaume Chatelet
cab041fe63
[reland][libc][NFC] Refactor FPBits and remove LongDoubleBits specialization (#78447)
- [reland] #78192
- Make the implementation work when `__uint128_t` is not available on
the plaftorm.
2024-01-17 16:15:09 +01:00