1549 Commits

Author SHA1 Message Date
Jeff Bailey
1b89aeb517 [libc] Add instructions for linux headers
Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D146049
2023-03-15 03:02:16 +00:00
Joseph Huber
dab75a4378 [libc] Remove leftover debug prints 2023-03-14 15:14:12 -05:00
Joseph Huber
ab107b3fac [libc] Fix CMake deduplication -Xclang arguments
Summary:
We use `-Xclang` to pass the GPU binary to be embedded. In the case of
multi-source objects this will be passed more than once, but CMake
implicitly deduplicates arguments. Use the special generator to prevent
this from happening.
2023-03-14 15:04:37 -05:00
Joseph Huber
597cef4486 [libc] Fix GPU fatbinary dependencies for multi-source object libraries
Summary:
Multi-source object libraries require some additional handling, this
logic wasn't correctly settending the dependency on each filename
individually and was instead using the last one. This meant that only
the last file was built for multi-object libraries.
2023-03-14 15:04:37 -05:00
Michael Jones
7aec387dbe [libc][NFC] add an atof test for a fuzz failure
The differential fuzzer found that glibc and our libc disagree on the
result for "0x30000002222225p-1077", with ours being rounded up and
theirs rounded down. Ours is more correct for the nearest rounding mode,
so only a test is added.

Reviewed By: lntue, sivachandra

Differential Revision: https://reviews.llvm.org/D145821
2023-03-14 11:42:57 -07:00
Joseph Huber
c2a17bff24 [libc] Set the stub filename to the target name instead of the source
The GPU target requires some weird special case handling to create fat
binaries. CMake offers no way to set the name of an object library. The
only way to do this is to create a file with the desired name and use
that. Currently we name it after the source filename. However, this
breaks if there is more than a single source. This patch changes the
logic to instead look up the object target name and use that. E.g.
`src.__support.OSUtil.osutil` will be `osutil.cpp`.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D145912
2023-03-14 10:31:04 -05:00
Joseph Huber
022f2fa3ad [libc] Remove dummy archive and file from integration test
This doesn't seem to be used anymore after recent changes that removed
the `--sysroot` method for the integration tests.

Reviewed By: sivachandra, lntue

Differential Revision: https://reviews.llvm.org/D146040
2023-03-14 09:30:05 -05:00
Joseph Huber
a031f72187 [libc] Correctly pass the compile options to the internal GPU compilation
Summary:
We use an internal option to create the GPU binary used for testing.
This wasn't getting the proper flags passed to it due to a missing
variable name.
2023-03-14 08:19:13 -05:00
Guillaume Chatelet
a49118a3f4 [reland][libc][NFC] Move memcmp implementations in subfolders 2023-03-14 13:03:47 +00:00
Guillaume Chatelet
00c5233139 Revert "[libc][NFC] Move memcmp implementations in subfolders"
this broke arm32 build bots
This reverts commit 7f20e2a8d2ba73a8b05742903f4ae42afec82bff.
2023-03-14 13:00:40 +00:00
Guillaume Chatelet
7f20e2a8d2 [libc][NFC] Move memcmp implementations in subfolders 2023-03-14 12:47:24 +00:00
Siva Chandra
537e6e7095 [libc] Enable more functions on riscv64.
The list of headers has also been updated. Some duplicated entrypoints
have been removed.
2023-03-14 06:33:08 +00:00
Jeff Bailey
ea471e2aa8 [libc] Update cross-compilation instructions
* Add various options so that it uses the build lld and compiler-rt
 * Add instructions on how to use the newly built libc
 * Remove trailing comments in code-block for cut and pastability

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D145878
2023-03-14 05:31:20 +00:00
Siva Chandra Reddy
547e345666 [libc] Make libc_errno point to internal errno for non-public builds.
The macro llvmlibc_errno has also been removed. This change completes
the switch to using a hermetic errno for unit tests.

Fixes #61037

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D146005
2023-03-14 04:21:56 +00:00
Siva Chandra Reddy
55612b8ec4 [libc] Switch sys/stat implementations over to libc_errno.
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D146004
2023-03-14 04:02:45 +00:00
Siva Chandra Reddy
7e6462d90c [libc][NFC] Switch nanosleep_test and getcwd_test to libc_errno. 2023-03-14 01:25:47 +00:00
Siva Chandra Reddy
bb03705726 [libc] Switch termios implementations to libc_errno. 2023-03-14 01:00:58 +00:00
Siva Chandra Reddy
67de5381a3 [libc][NFC] Switch unistd.h tests to libc_errno. 2023-03-14 00:52:33 +00:00
Siva Chandra Reddy
af783db7fd [libc][NFC] Switch sys/*.h tests over to libc_errno. 2023-03-13 23:44:52 +00:00
Siva Chandra Reddy
40c443e28b [libc][NFC] Switch mman.h tests to libc_errno and update Bazel build. 2023-03-13 22:46:51 +00:00
Siva Chandra Reddy
0b70f95c16 [libc][NFC] Switch startup tests to libc_errno. 2023-03-13 22:22:01 +00:00
Siva Chandra Reddy
30d894239a [libc][NFC] Switch string and errno tests to libc_errno. 2023-03-13 22:22:00 +00:00
Siva Chandra Reddy
adff2b291c [libc][NFC] Switch all uses of errno in math and math tests to libc_errno. 2023-03-13 22:22:00 +00:00
Tue Ly
60d2dbf522 [libc] Fix policy CMP0116 warnings for cmake 3.20 or above.
Warnings due to changes in behavior of cmake 3.20 or above.  See
https://cmake.org/cmake/latest/policy/CMP0116.html

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D145983
2023-03-13 17:28:14 -04:00
Siva Chandra Reddy
71825a889a [libc][NFC] Add string.h header to various platform headers.txt. 2023-03-13 15:34:58 +00:00
Siva Chandra Reddy
2869d31a7a [libc] Enable integration tests when built with gcc. 2023-03-13 07:47:00 +00:00
Siva Chandra Reddy
5b1ad43c2b [libc] Declare __dso_handle in the integration test instead of startup.
Fixes #61355. The __dso_handle decl was introduced incorrectly into the startup
objects during the integration test cleanup which moved the integration tests
away from using an artificial sysroot to using -nostdlib. Having it in the
startup creates the duplicate symbol error when one does not use -nostdlib.
Since this is an integration test only problem, it is meaningful to keep it in
the integration test anyway.

Differential Revision: https://reviews.llvm.org/D145898
2023-03-13 07:47:00 +00:00
Siva Chandra
c1bb7108a2 [libc] Special case sniffing of thread start args for riscv. 2023-03-13 07:29:35 +00:00
Siva Chandra Reddy
5d69233453 [libc][NFC] Reduce the number of threads created in cnd_test to 1000 form 10000.
The high number of 10000 threads was choking bot builders running on boards with
very small memory.
2023-03-12 07:08:58 +00:00
Stephen Neuendorffer
1ab46e5cf8 [libc] update LibcTableGenUtil for LLVM_LINK_LLVM_DYLIB
This library is linked into libc-hdrgen, which is compiled with
DISABLE_LLVM_LINK_LLVM_DYLIB.  This option avoids linking with
libLLVM.so when LLVM_LINK_LLVM_DYLIB is specified.  Unfortunately,
this can cause wierd linkage errors where symbols are defined
multiple times, with one definition coming from static linkage
and another definition coming from libLLVM.so.  This is usually
apparent as a link error with options defined multiple times.

This patch adds DISABLE_LLVM_LINK_LLVM_DYLIB to this library, to
get consistent linkage of libc-hdrgen.

Differential Revision: https://reviews.llvm.org/D145839
2023-03-11 09:15:06 -08:00
Joseph Huber
8a712bf7c4 [libc] Fix common compile options not getting passed to GPU object
Summary:
This variable was named incorrectly. We weren't getting needed flags
passed to object library builds.
2023-03-10 16:54:20 -06:00
Michael Jones
08df6c78b5 [libc][docs] update list of completed stdio funcs
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D145633
2023-03-09 10:44:50 -08:00
Siva Chandra
cf90633cf2 [libc] Extend the linux thread implementation for riscv64.
Also, added riscv64 startup code for static linking which is used
by the integration tests. Functions from the C standard threads
library have been enabled.

Reviewed By: mikhail.ramalho

Differential Revision: https://reviews.llvm.org/D145670
2023-03-09 16:58:48 +00:00
Joseph Huber
fdd710e69c [libc] Add missing header for LIBC_INLINE macro
Summray:
Forgot to do this in the last patch
2023-03-09 06:45:50 -06:00
Joseph Huber
a9cb298b39 [libc] Add intrinsic for thread fence to the atomic support
This function mimics the std::atomic_thread_fence function from
<atomic>. This has no uses in source currently, but this will be used by
the proposed RPC client for the GPU mode support. There is varying
support for direct memory ordering for the GPU atomics on shared memory
resources. So the implementation will use relaxed atomics and explicit
memory fences.

Some additional work may need to be done to map this to `NVPTX` system
level fences.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D145608
2023-03-09 06:36:54 -06:00
Siva Chandra Reddy
b32acff7b7 [libc][Obvious] Fix bad include and type in threads/tss_get.h. 2023-03-09 08:38:32 +00:00
Siva Chandra Reddy
d2e0a98391 [libc][NFC] Compile tests also with -fpie.
The libc runtime code is already compiled with -fpie.
2023-03-09 07:45:39 +00:00
Siva Chandra Reddy
6ab95b0d53 [libc][Obvious] Add missing dep to include.sys_mman. 2023-03-09 07:26:12 +00:00
Siva Chandra
6822156a58 [libc] Widen the riscv64 full build config. 2023-03-08 23:05:00 +00:00
Mikhail R. Gadelha
e9be85da8b [libc] Add fenv_t and signal macros in riscv
This patch now enables full build.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D145594
2023-03-08 17:31:58 -03:00
Siva Chandra
dea96e7dca [libc] Remove log10 from the list of riscv64 entrypoints.
Its test is currently failing of real riscv64 hardware.
2023-03-08 20:05:13 +00:00
Mikhail R. Gadelha
f1f052f9b0 [libc] Add support for sqrt in riscv
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D145593
2023-03-08 16:20:37 -03:00
Mikhail R. Gadelha
ac763b9fdf [libc] Add support for fma in riscv
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D145592
2023-03-08 16:15:24 -03:00
Mikhail R. Gadelha
4d94a0080e [libc] Support more functions in riscv
Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D145444
2023-03-08 14:58:51 -03:00
Siva Chandra
6f8dfeee06 [libc] Add riscv64 fenv implementation and enable the fenv.h functions.
Reviewed By: mikhail.ramalho

Differential Revision: https://reviews.llvm.org/D145560
2023-03-08 10:49:24 -03:00
Mikhail R. Gadelha
0ffea21893 [libc] Small improvements to libc cmake
This patch includes:
1. Better error message when cmake finds incompatible triple
2. Added missing header dependencies libc/include/CMakeLists.txt as per
   app.td
3. Removed unused $LLVM_LIBC_INCLUDE_DIRS cmake variable

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D145496
2023-03-08 09:02:02 -03:00
Siva Chandra
9ca2fb8217 [libc] Add riscv64 syscall implementation.
All syscall wrapper functions which have unit tests have been enabled.

Reviewed By: kito-cheng

Differential Revision: https://reviews.llvm.org/D145452
2023-03-07 21:47:58 -03:00
Michael Jones
60178f04fc [libc][docs] add link to join the discord
Previously we only linked to the channel within the discord.

Differential Revision: https://reviews.llvm.org/D145283
2023-03-07 16:33:27 -08:00
Siva Chandra Reddy
4155503b71 [libc] Add a note about using assertions in the libc runtime code.
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D145466
2023-03-07 10:16:50 -08:00
Siva Chandra Reddy
439eebab81 [libc] Add fenv functions to arm32 baremetal config.
Also, an "arm" subfolder for baremetal config has been added.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D145476
2023-03-07 18:11:20 +00:00