676 Commits

Author SHA1 Message Date
Tristan Ross
7477b61b24
[libc] Add unistd overlay (#119312)
Reverts the revert #119295 of #118882 by expanding #118882 with
additional fixes which made CI unhappy.
2024-12-17 10:40:22 -08:00
Nick Desaulniers
8c3a8c2619 [bazel][libc] fix typo in comment
Link: #119433
2024-12-10 14:40:12 -08:00
Nick Desaulniers
1d0ca626d8
[bazel] fix libc build (#119433)
Due to moving strings out of string.

Link: #118899
2024-12-10 12:29:49 -08:00
Dmitri Gribenko
6f190cabe0 [bazel] Port e6cf5d2863b77895ae7183952514bedd9e8dde16 2024-12-06 10:30:09 +01:00
Schrodinger ZHU Yifan
e6cf5d2863
Reapply "[libc][windows] start time API implementation (#117775)" (#118886) 2024-12-05 18:21:03 -05: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
Augie Fackler
f6f16b5f54 [bazel] update for a0c4f854cad2b97e44a1b58dc1fd982e1c4d60f3 2024-12-03 20:55:11 -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
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
Mikhail Goncharov
5bdee35544 [bazel] format utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl 2024-11-21 11:41:34 +01:00
lntue
14667119bc
[libc] Allow each function can have extra attributes by defining LLVM_LIBC_FUNCTION_ATTR_func macro. (#116160) 2024-11-20 17:50:00 -05:00
Daniel Thornburgh
95b680e4c3
[libc] Rename libc/src/__support/endian.h to endian_internal.h (#115950)
This prevents a conflict with the Linux system endian.h when built in
overlay mode for CPP files in __support.

This issue appeared in PR #106259.
2024-11-13 10:28:07 -08:00
Haojian Wu
70d6789c7a [bazel] Port for 7302c8dbe71b7c03b73a35a21fa4b415fa1f4505 2024-11-12 21:06:19 +01:00
Michael Jones
36cbc09e63
[libc][bazel] config macros is a support library (#115776)
Previously __support_macros_config was a cc_library, but making it a
libc_support_library makes things cleaner.
2024-11-11 14:16:53 -08:00
Pranav Kant
cb98366ea4
[bazel][libc] Add exp10m1f (#115565) 2024-11-08 15:32:25 -08:00
Michael Jones
aae5a38e4e
[libc][bazel] Mark socket functions weak (#115088)
Downstream ther'es a user that needs the syscall wrappers to be weak. I
intend to set up a proper mechanism for just listing which functions
should be weak eventually, but for now this is necessary.
2024-11-06 10:29:07 -08:00
Alexey Samsonov
2f48765b45
[libc][bazel] Remove -mllvm --tail-merge-threshold=0 from Bazel. (#115061)
Follow-up on the `-mllvm --tail-merge-threshold=0` removal promised in
aeccc16497a84d61200f7ccfa3864096349260d3 (see
b2a9ea4420127d10b18ae648b16757665f8bbd7c commit message on why we don't
need this in Bazel, and will only keep in AArch64-specific compile flags
in CMake build).
2024-11-06 10:51:08 +01:00
Dmitri Gribenko
21f8e8c918 [bazel][libc] Port 9cfe3028ca7977fb582fa3b15b875e8772fc8fc0 (part 2) 2024-11-05 12:35:02 +01:00
Pranav Kant
2d2371df0f
[bazel][libc] Fix bazel build (#114917) 2024-11-04 19:10:57 -08:00
Benjamin Kramer
1b1e325583 [bazel][libc] Port 33bdb53d864e3e244d8fd5649062f17b7d4c958d 2024-11-03 18:11:55 +01:00
Alexey Samsonov
33d636f0f6
[libc][bazel] Fix linter warning - remove unused load. (#114493)
This load is no longer necessary since PLATFORM_CPU_ARM64 was removed in
fa17977c315062646d4d1e01262d68dd69313e61
2024-10-31 17:34:39 -07:00
Alexey Samsonov
14f3cdc8e2
[libc][bazel] Add BUILD rules for float16 math functions. (#114187)
Adds libc_math_function rules for various f16* and *f16 functions.
Closes #114140
2024-10-30 19:05:24 -07:00
Dmitry Chernenkov
872981bd23 [Bazel] Fix layering for libc 2024-10-29 14:34:51 +00:00
Dmitry Chernenkov
340cd4e631 [Bazel] fix for abc49cc19463970d5523d7d3332e4c1f83bc2ef7 2024-10-29 14:13:20 +00:00
Guillaume Chatelet
b1ede8fcb4
[reland][libc][bazel] Enable software prefetching for memcpy (#113886)
This will affect only Bazel configuration for now.
This is a reland of #108939 which has been reverted because of codegen
issues fixed by https://github.com/llvm/llvm-project/pull/113161.
2024-10-28 14:43:10 +01:00
Michael Jones
6c4267fb17
[libcxx][libc] Hand in Hand PoC with from_chars (#91651)
Implements std::from_chars for float and double.

The implementation uses LLVM-libc to do the real parsing. Since this is
the first time libc++
uses LLVM-libc there is a bit of additional infrastructure code. The
patch is based on the
[RFC] Project Hand In Hand (LLVM-libc/libc++ code sharing)

https://discourse.llvm.org/t/rfc-project-hand-in-hand-llvm-libc-libc-code-sharing/77701
2024-10-21 15:04:06 -07:00
Krasimir Georgiev
25b58c877c
bazelbuild: fix for commit 2ce10 (#113142)
bazelbuild: fix for
2ce10f0491.

No functional changes intended.
2024-10-21 13:08:49 +02:00
Benjamin Kramer
c7d1163554 [bazel] Port 7be4ab0a86f9a52f1b49dad5665617441ec24a2e 2024-10-18 12:28:15 +02:00
Guillaume Chatelet
dda107b8cb
Revert "[libc][bazel] Enable software prefetching for memcpy" (#111370)
Reverts llvm/llvm-project#108939

When `AVX` is available but `-mprefer-vector-width=128` some of the
`mov` instructions turn into the x86 `rep;movsb` instruction leading to
poor performance on "old" architectures (sandybridge, haswell). The
possible solutions are : get rid of the `-mprefer-vector-width` option
or use smaller static copy sizes in
`inline_memcpy_x86_sse2_ge64_sw_prefetching`. Right now a copy size of 3
cache lines (192B) relying exclusively on xmm registers gets turned into
`rep;movsb`.
2024-10-07 15:00:31 +02:00
Danial Klimkin
53b3c9e408
[bazel] Fix libc/hdr past c63112a9118277a20ae440f3f69189c0937e8f4d (#111135) 2024-10-04 13:21:25 +02:00
Alexey Samsonov
ec06471c83
Stop disabling link_llvmlibc feature in libc_test Bazel rule
This detail is not relevant for the upstream Bazel version. llvm-libc unit tests today directly invoke the function under test using the namespace, which reduces the potential problems of linking with some other (system-provided) version of llvm-libc further.
2024-10-03 22:40:30 -07:00
Keith Smiley
e7edd53e2d
[bazel] Port c63112a9118277a20ae440f3f69189c0937e8f4d (#110706) 2024-10-01 10:34:43 -07:00
Michael Jones
aeb18ebbe0
[libc] Add MSAN unpoison annotations to recv funcs (#109844)
Anywhere a struct is returned from the kernel, we need to explicitly
unpoison it for MSAN. This patch does that for the recv, recvfrom,
recvmsg, and socketpair functions.
2024-09-24 14:54:02 -07:00
lntue
fa17977c31
[libc][bazel] Remove specializations from libc_math_function. (#109802)
There are no more specializations `libc/src/math/x86_64` or
`libc/src/math/aarch64` anymore. All implementations are going through
the generic implementation.
2024-09-24 11:26:06 -04:00
Dmitry Chernenkov
3ec5e74c0d [Bazel] Fix layering for 127349fcba81646389e4b8202b35405a5fdbef47 2024-09-24 13:00:12 +00:00
Dmitry Chernenkov
30dbbdd2ea [Bazel] Fix for 127349fcba81646389e4b8202b35405a5fdbef47 2024-09-24 09:18:22 +00:00
OverMighty
127349fcba
[libc][math] Add floating-point cast independent of compiler runtime (#105152)
Fixes build and tests with compiler-rt on x86.
2024-09-23 19:35:39 +02:00
Guillaume Chatelet
42b696d7b9
[libc][bazel] Enable software prefetching for memcpy (#108939)
This will affect only Bazel configuration for now.
2024-09-20 15:16:38 +02:00
Michael Jones
f6b4c34d4f
[libc] Add functions to send/recv messages (#106467)
This patch adds the necessary functions to send and receive messages
over a socket. Those functions are: recv, recvfrom, recvmsg, send,
sendto, sendmsg, and socketpair for testing.
2024-09-19 14:43:00 -07:00
Michael Jones
f009f72df5
[libc] Add printf strerror conversion (%m) (#105891)
This patch adds the %m conversion to printf, which prints the
strerror(errno). Explanation of why is below, this patch also updates
the docs, tests, and build system to accomodate this.

The standard for syslog in posix specifies it uses the same format as
printf, but adds %m which prints the error message string for the
current value of errno. For ease of implementation, it's standard
practice for libc implementers to just add %m to printf instead of
creating a separate parser for syslog.
2024-09-19 10:48:08 -07:00
Benjamin Kramer
4de7026ce3 [bazel] Split linux time targets to avoid dependency cycles
clock_gettime is much heavier than the others as it depends on vdso.
2024-09-17 10:28:03 +02:00
Guillaume Chatelet
c970e96eae
[libc][bazel] Enable software prefetching for memset (#108860)
This will affect only Bazel configuration for now.
2024-09-17 09:52:23 +02:00
Benjamin Kramer
d044732a25 [bazel] Port a205a854e06d36c1d0def3e3bc3743defdb6abc1 2024-09-15 23:14:38 +02:00
Pranav Kant
a592e4b4b0
[bazel] add vdso dependency to time_linux lib (#108647)
This is a quick fix to unbreak Bazel build. The right solution would
probably add vdso.cpp in the support library which includes circular
dependency and needs more restructuring.
2024-09-13 14:35:59 -07:00
Mikhail Goncharov
59731eebf8 [bazel] port ded080152acceca5d68014d63f5027a6d8266cbb 2024-09-12 12:01:03 +02:00
Michael Jones
4618b67b48
[libc][bazel] Enable epoll_pwait2 on bazel (#108254)
The wrapper for epoll_pwait2 has been difficult to enable since it
requires a very new version of the linux kernel (5.11). On cmake we
still need to create a mechanism to check if we can build it, but our
current bazel users are all on a new enough kernel version we can just
enable it.
2024-09-11 14:36:10 -07:00
lntue
1896ee3889
[libc] Fix undefined behavior for nan functions. (#106468)
Currently the nan* functions use nullptr dereferencing to crash with
SIGSEGV if the input is nullptr. Both `nan(nullptr)` and `nullptr`
dereferencing are undefined behaviors according to the C standard.
Employing `nullptr` dereference in the `nan` function implementation is
ok if users only linked against the pre-built library, but it might be
completely removed by the compilers' optimizations if it is built from
source together with the users' code.

See for instance:  https://godbolt.org/z/fd8KcM9bx

This PR uses volatile load to prevent the undefined behavior if libc is
built without sanitizers, and leave the current undefined behavior if
libc is built with sanitizers, so that the undefined behavior can be
caught for users' codes.
2024-09-11 14:13:31 -04:00
Mikhail Goncharov
33f1235b80 [libc][bazel] fix accidental rename
for 277371943fa48f2550df02870951f5e5a77efef5
2024-09-10 16:22:21 +02:00
Jordan Rupprecht
02ab43596f
[bazel][libc][NFC] Add missing dep for standalone compile (#107957)
One more after 277371943fa48f2550df02870951f5e5a77efef5
2024-09-09 22:39:29 -05:00