3769 Commits

Author SHA1 Message Date
Guillaume Chatelet
4873968649
[libc] Remove automemcpy folder (#118781)
The build is currently broken and we don't have the resources to keep it
up to date :-/
2024-12-06 09:30:13 +01:00
Schrodinger ZHU Yifan
2dba66b853
[libc] document supported os ranges (#118863) 2024-12-05 18:25:07 -05:00
Schrodinger ZHU Yifan
e6cf5d2863
Reapply "[libc][windows] start time API implementation (#117775)" (#118886) 2024-12-05 18:21:03 -05:00
Nick Desaulniers
7329086d4e
[libc][docs] stub out assert, errno, and locale (#118852)
[libc][docs] stub out assert, errno, and locale

These were the remaining c89 library headers (besides string.h and
stdlib.h; I
will split strings.rst in a follow up commit).

The macro support detection in docgen doesn't quite work for some of
these
headers. Add the stubs for these headers for now, and fix up docgen
later.

See the "NIST publication":
Link: https://www.open-std.org/jtc1/sc22/wg14/www/projects.html
2024-12-05 14:20:03 -08:00
Nick Desaulniers
a9aff440d9
[libc][docs] reorganize documentation (#118836)
This commit does a few things:
* creates libc/docs/headers/ and moves all user API related headers under it.
* updates paths and docgen
* updates the top level index to put these headers under a new "Implementation
  Status" tab.
* rename some of the files to be foo.rst for foo.h (except strings, which is
  currently a mix of string.h and stdlib.h)
* update the heading of some files to be in the form foo.h.
2024-12-05 13:54:09 -08:00
Tristan Ross
3a7d1b5c16
[libc] Include CheckCXXCompilerFlag when checking compiler features (#118862)
Includes `CheckCXXCompilerFlag` so when building LLVM libc is built
standalone, it actually works and doesn't complain about
`check_cxx_compiler_flag` not being defined.
2024-12-05 15:12:36 -06:00
Joseph Huber
9fd052a122 Revert "[libc][windows] start time API implementation (#117775)"
This reverts commit 0adff0af20c7d9bae8bd8bdf402506c10369ead1.

Breaks the GPU build
2024-12-05 14:43:06 -06:00
Schrodinger ZHU Yifan
0adff0af20
[libc][windows] start time API implementation (#117775)
Add a `clock_gettime` emulation layer and use it to implement the `time`
entrypoint.

For windows, the monotonic clock is emulated using `QPC`.
The realtime clock is emulated using `GetSystemTimePreciseAsFileTime`.
2024-12-05 14:08:27 -05:00
Schrodinger ZHU Yifan
245f26a3d3
[libc] revert all process_mrelease changes (#118650)
Revert as its test is unstable.
https://github.com/llvm/llvm-project/issues/118057
2024-12-05 11:58:37 -05:00
Nick Desaulniers
fdb90cef75
[libc][docgen] update to POSIX.1-2024 (#118717)
The recently ratified POSIX.1-2024 is newer than POSIX.1-2017.
2024-12-05 08:23:40 -08:00
Nick Desaulniers
659834df0e
docgen refresh (#118709)
- **[libc][docgen] Use Macro for macro table name**
- **fix setjmp json, otherwise can't regen**
- **regen all docs**
2024-12-04 15:43:52 -08:00
Joseph Huber
a2fc276ed2 [libc] Remove complicated header guards on HSA include
Summary:
This is much more standard now, we already require new HSA with what we
use, so no point checking for this.
2024-12-04 16:28:13 -06:00
lntue
a7da702377
[libc][math] Add small code size options for atan2f. (#118532) 2024-12-04 16:37:51 -05:00
Nick Desaulniers
5e769fb234
[libc] add headers.txt for windows (#118675)
Link:
https://github.com/llvm/llvm-project/pull/117220#issuecomment-2518126598

---------

Co-authored-by: Michael Jones <michaelrj@google.com>
2024-12-04 12:38:21 -08:00
Nick Desaulniers
06c831d7fb
[libc] rename newhdrgen to just hdrgen (#118545)
Link: #117208
Fixes: #117254
2024-12-04 08:48:12 -08:00
Joseph Huber
3dc97557d1
[libc] Fix the GPU build when building inside the NATIVE project (#118573)
Summary:
We use the NATIVE directory for cross-compiling tools that need to be
run on the host. This was not forwarding the CMake arguments we used to
check if this was a GPU compile that created its own tools. Forward that
and simplify.

Fixes https://github.com/llvm/llvm-project/issues/118558
2024-12-03 20:34:32 -06:00
Shilei Tian
68bcba6d7a Revert "[AMDGPU] Use COV6 by default (#118515)"
This reverts commit 410cbe3cf28913cca2fc61b3437306b841d08172 because some
buildbots are not ready yet.
2024-12-03 20:17:06 -05:00
Shilei Tian
410cbe3cf2
[AMDGPU] Use COV6 by default (#118515) 2024-12-03 19:38:35 -05:00
Michael Jones
a0c4f854ca
[libc] Change ctype to be encoding independent (#110574)
The previous implementation of the ctype functions assumed ASCII.
This patch changes to a switch/case implementation that looks odd, but
actually is easier for the compiler to understand and optimize.
2024-12-03 12:36:04 -08:00
Nick Desaulniers
e0ae7793fc
[libc] delete hdrgen (#117220)
Thanks to the effort of @RoseZhang03 and @aaryanshukla under the
guidance of
@michaelrj-google and @amykhuang, we now have newhdrgen and no longer
have a
dependency on TableGen and thus LLVM in order to start bootstrapping a
full
build.

This PR removes:
- LIBC_HDRGEN_EXE; the in tree newhdrgen is the only hdrgen that can be
used.
- LIBC_USE_NEW_HEADER_GEN; newhdrgen is the default and only option.
- LIBC_HDRGEN_ONLY; there is no need to have a distinct build step for
old
  hdrgen.
- libc-api-test and libc-api-test-tidy build targets.
- Deletes all .td files.

It does not rename newhdrgen to just hdrgen. Will follow up with a
distinct PR
for that.

Link: #117209
Link: #117254
Fixes: #117208
2024-12-03 12:34:26 -08:00
wldfngrs
cd04653c4e
[libc][math][c23] Add sinf16 C23 math function (#116674)
Co-authored-by: OverMighty <its.overmighty@gmail.com>
2024-12-03 21:08:46 +01:00
Nick Desaulniers
68112f0f5b
libc: fixup include path and bazel stale comments (#118510)
Downstream builders are having issues with this local include. Use a
fuller
path that's more standard throughout the codebase.

Also some of the comments in the bazel overlay are stale. Remove them.

Reported-by: Brooks Moses <bmoses@google.com>
2024-12-03 08:59:58 -08:00
Petr Hosek
b8daa45a56
[libc] Implement timespec_get (#116102)
`timespec_get` is C standard counterpart to POSIX `clock_gettime`. On
Linux we simply use `clock_gettime`. On baremetal we introduce a new
external API `__llvm_libc_timespec_get_utc` that should be implemented
by the vendor.
2024-12-02 14:29:49 -08:00
Joseph Huber
a6ef0debb1 [libc][NFC] Rename RPC opcodes to better reflect their usage
Summary:
RPC_ is a generic prefix here, use LIBC_ to indicate that these are
opcodes used to implement the C library
2024-12-02 15:35:08 -06:00
Shankhin
eaa6cc547e
Fixes #118231: Corrected spelling mistake in has_acitive_owner function (#118266)
Fixes #118231 
- Updated the method name to `has_active_owner` in
`llvm-project/libc/src/__support/threads/linux/rwlock.h`
- Verified usage and updated all references to the method.
- Ran tests:
    - `check-llvm-unit`
    - `check-all`
2024-12-02 16:10:25 +08:00
Schrodinger ZHU Yifan
cf478bf744
[libc] always clean up child process to avoid hanging ninja (#118049) 2024-11-29 00:17:09 -05:00
Schrodinger ZHU Yifan
700d9ac9ef
[libc] disable process_mrelease for riscv (#117956)
`process_mrelease` upsets the RV32 build bot. Disable it for now.
2024-11-27 21:17:38 -05:00
Schrodinger ZHU Yifan
819b155c2a
[libc] skip test and return ENOSYS when processm_release unavailable (#117951) 2024-11-27 20:52:16 -05:00
Omar Hossam
d2b482b0ef
[libc] (reland #117503) Implement process_mrelease (#117851)
This PR implements process_mrelease.
A previous PR was merged #117503, but failed on merge due to an issue in
the tests. Namely the failing tests were comparing against return type
as opposed to errno. This is fixed in this PR.
2024-11-27 20:15:17 -05:00
Joseph Huber
1d810ece2b
[libc] Move libc server handlers to a shared header (#117908)
Summary:
We can simply include this header from the shared directory now and do
not need to have this level of indirection. Simply stash it with the
other libc opcode handlers.

If we were able to move the printf handlers to the shared directory then
this could just be a header as well, which would HEAVILY simplify the
mess associated with building the RPC server first in the projects
build, then copying it to the runtimes build.
2024-11-27 14:57:52 -06:00
Joseph Huber
89d8e70031
[libc] Export a pointer to the RPC client directly (#117913)
Summary:
We currently have an unnecessary level of indirection when initializing
the RPC client. This is a holdover from when the RPC client was not
trivially copyable and simply makes it more complicated. Here we use the
`asm` syntax to give the C++ variable a valid name so that we can just
copy to it directly.

Another advantage to this, is that if users want to piggy-back on the
same RPC interface they need only declare theirs as extern with the same
symbol name, or make it weak to optionally use it if LIBC isn't
avaialb.e
2024-11-27 14:57:38 -06:00
Joseph Huber
38049dc8ee
[libc] Handle differing wavefront sizes correctly in the AMDHSA loader (#117788)
Summary:
The AMDGPU backend can handle wavefront sizes of 32 and 64, with the
native hardware preferring one or the other. The user can override the
hardware with `-mwavefrontsize64` or `-mwavefrontsize32` which
previously wasn't handled. We need to know the wavefront size to know
how much memory to allocate and how to index the RPC buffer. There isn't
a good way to do this with ROCm so we just use the LLVM support for
offloading to check this from the image.
2024-11-27 10:04:00 -06:00
lntue
3372303188
Revert "[libc] Implement process_mrelease." (#117807)
Reverts llvm/llvm-project#117503
2024-11-26 18:07:30 -05:00
Omar Hossam
36a46d85e7
[libc] Implement process_mrelease. (#117503)
This PR addresses #110124.
2024-11-26 17:40:06 -05:00
Schrodinger ZHU Yifan
c71418574f
[libc] suppress more clang-cl warnings (#117718)
- migrate more `-O3` to `${libc_opt_high_flag}`
- workaround a issue with `LLP64` in test. The overflow testing is
guarded by a constexpr but the literal overflow itself will still
trigger warnings.

Notice that for math smoke test, for some reasons, the
`${libc_opt_high_flag}` will be passed into `lld-link` which confuses
the linker so there are still some warnings leftover there. I can
investigate more when I have time.
2024-11-26 15:15:58 -05:00
Schrodinger ZHU Yifan
32432a6a02
[libc] suppress math library warnings on windows (#117638) 2024-11-25 18:06:16 -05:00
Schrodinger ZHU Yifan
1973270fc6
[libc] suppress string warning in case intrinsics are defined as macros (#117640) 2024-11-25 18:05:22 -05:00
Caslyn Tonelli
4c91662a51
[libc] Resolve multi-line comment error (#117636)
gcc interprets a backslash '\\' as the last char before a new line as a
line continuation character, even in a comment context. This can produce
an "error: multi-line comment [-Werror=comment]".

This removes the line continuation so that the comment can compile with
gcc.
2024-11-25 15:01:01 -08:00
Joseph Huber
d7c20a6f0c [libc][NFC] Move RPC opcodes to the 'shared/' directory as well 2024-11-25 12:04:10 -06:00
Joseph Huber
387be04dde [libc][NFC] Add const to RPC header members
Summary:
Make sure that these don't get modified.
2024-11-25 09:11:58 -06:00
Joseph Huber
6de97e9a67 [libc] Allow NVPTX targets to build in debug mode
Summary:
This previously did not work, but recent improvements to the NVPTX
backend allow this to work now.
2024-11-25 09:11:58 -06:00
Joseph Huber
0ccc389512 [libc] Make RPC header work with GCC9 2024-11-25 07:31:35 -06:00
Joseph Huber
b4d49fb52e
[libc] Remove RPC server API and use the header directly (#117075)
Summary:
This patch removes much of the `llvmlibc_rpc_server` interface. This
pretty much deletes all of this code and just replaces it with including
`rpc.h` directly. We still maintain the file to let `libc` handle the
opcodes, since those depend on the `printf` impelmentation.

This will need to be cleaned up more, but I don't want to put too much
into a single patch.
2024-11-25 07:13:28 -06:00
Daniel Thornburgh
d121d71fc7
[libc][NFC] Remove template arguments from Block (#117386) 2024-11-22 15:33:18 -08:00
Michael Jones
182f9aad8b
[libc] Fix unpoisoning for recvfrom (#117366)
Turns out there were also errors in the recvfrom unpoisoning logic. This
patch fixes those.
2024-11-22 13:41:07 -08:00
Joseph Huber
89614ceb40
[libc] Move RPC interface to libc/shared to export it (#117034)
Summary:
Previous patches have made the `rpc.h` header independent of the `libc`
internals. This allows us to include it directly rather than providing
an indirect C API. This patch only does the work to move the header. A
future patch will pull out the `rpc_server` interface and simply replace
it with a single function that handles the opcodes.
2024-11-22 15:32:25 -06:00
Joseph Huber
676a1e6643
[AMDGPU] Remove uses of deprecreated HSA executable functions (#117241)
Summary:
These functions were deprecated in ROCR 1.3 which was released quite
some time ago. The main functionality that was lost was modifying and
inspecting the code object indepedently of the executable, however we do
all of that custom through our ELF API. This should be within the
versions of other functions we use.
2024-11-22 07:16:40 -06:00
Daniel Thornburgh
ab28d387fa [libc] Fix forward freestore test on riscv32 2024-11-21 15:41:07 -08:00
Chuvak
3709c2d15a
[libc] Fix wrong name in Compare.h (#117223)
Fix for some mistakes in source code found using PVS Studio.

Inspired by: https://pvs-studio.com/en/blog/posts/cpp/1188/

Fixed:
- [Bug 5](https://pvs-studio.com/en/blog/posts/cpp/1188/#IDF23EA2CEAB)
2024-11-21 18:29:08 -05:00
Daniel Thornburgh
385961d7b2 Reapply "[libc] Use best-fit binary trie to make malloc logarithmic (#117065)"
This reverts commit 93b83642ee34d0092b94776728dad0117c2b72a1.

 - Correct riscv32 assumption about alignment (bit of a hack).
 - Fix test case where the largest_small and smallest sizes are the
   same.
2024-11-21 15:26:24 -08:00