| Age | Commit message (Collapse) | Author | Files | Lines |
|
Requested as a binary size optimization. Updates the parser, converter
utils, config, tests, and docs.
|
|
Summary:
We should likely use `-DLLVM_DEFAULT_TARGET_TRIPLE` as the general
source of truth, make the handling work with that since we use it for
the output directories. Fix the creation of startup files in this mode
and make sure it can detect the GPU properly.
Fixes: https://github.com/llvm/llvm-project/issues/179375
|
|
The str to float code path offers options which can reduce code bloat.
Expose them as build config options. Disable Eisel Lemire for avoiding
code bloat caused by DETAILED_POWERS_OF_TEN look up table.
|
|
In order to apply the stack protector correctly to the compile options,
we need to make sure to use the same config name everywhere.
`LIBC_CONF_ENABLE_STACK_PROTECTOR` seems to be outdated and all other
places specify `LIBC_CONF_ENABLE_STRONG_STACK_PROTECTOR` and it should
therefore be updated here as well.
|
|
Add support for %lc in printf by calling internal wcrtomb function and
relevant end-to-end sprintf test.
Additionally, made the following changes:
- Modified printf parser for recognizing length modifier
- Added two internal error codes.
- Added a flag to disable wchar support on windows platform.
- To keep printf interface header only, converted wcrtomb and
CharacterConverter to header only implementation and removed the cpp
source.
Resolves GPU libc issues in #169983 and original issue: #166598
---------
Co-authored-by: shubhe25p <shubhp@mbm3a24.local>
Co-authored-by: Joseph Huber <huberjn@outlook.com>
|
|
This reverts commit 1327c50ef199b481f5326cf6ca3710fc111b70b1.
The printf headers are intended to be header-only, this introduces
external symbol dependencies.
|
|
Add support for %lc in printf by calling internal wcrtomb function and
relevant end-to-end sprintf test. Additionally, modified printf parser
for recognizing length modifier and added two internal error codes. Also
added a flag to disable wchar support on windows platform. Resolves
#166598
Co-authored-by: shubh@DOE <shubhp@mbm3a24.local>
|
|
Some of the baremetal users of libc use elf.h to generate coredumps and
we would like to support this use case without needing Linux elf.h.
|
|
This is a follow up to #174823 which adds build system integration.
|
|
(#172042)
[#172040](https://github.com/llvm/llvm-project/issues/172040)
This patch implements the scripts for generating the lookup tables and
associated utils for wctype classification functions. Not all Unicode
properties are covered as not all need a lookup table, the rest will be
hardcoded. The size of the generated tables is 47,8KB.
|
|
(#172902)
This is to allow math function implementations to use system libc's
fenv.h instead of internal fenv implementations.
|
|
This patch implements the generic mutex and raw_mutex interfaces on
macOS. A new Futex class is provided that relies on os_sync_wait and
os_sync_wake to emulate futex‑like wait and wake semantics. The
OS‑specific part is moved into futex_utils, which now contains the
Darwin implementation.
|
|
fenv_t. (#165015)
|
|
function selection (#165613) (#170738)
[Previous commit had an incorrect default case when
FIND_FIRST_CHARACTER_WIDE_READ_IMPL was not specified in config.json.
This PR is identical to that one with one line fixed.]
As we implement more high-performance string-related functions, we have
found a need for better control over their selection than the big-hammer
LIBC_CONF_STRING_LENGTH_WIDE_READ. For example, I have a memchr
implementation coming, and unless I implement it in every variant, a
simple binary value doesn't work.
This PR makes gives finer-grained control over high-performance
functions than the generic LIBC_CONF_UNSAFE_WIDE_READ option. For any
function they like, the user can now select one of four implementations
at build time:
1. element, which reads byte-by-byte (or wchar by wchar)
2. wide, which reads by unsigned long
3. generic, which uses standard clang vector implemenations, if
available
4. arch, which uses an architecture-specific implemenation
(Reading the code carefully, you may note that a user can actually
specify any namespace they want, so we aren't technically limited to
those 4.)
We may also want to switch from command-line #defines as it is currently
done, to something more like
llvm-project/llvm/include/llvm/Config/llvm-config.h.cmake, and
complexity out of the command-line. But that's a future problem.
|
|
function selection" (#170717)
Reverts llvm/llvm-project#165613
Breaks build bot
|
|
selection (#165613)
[This is more of a straw-proposal than a ready-for-merging PR. I got
started thinking about what this might look like, and ended up just
implementing something as a proof-of-concept. Totally open to other
methods an ideas.]
As we implement more high-performance string-related functions, we have
found a need for better control over their selection than the big-hammer
LIBC_CONF_STRING_LENGTH_WIDE_READ. For example, I have a memchr
implementation coming, and unless I implement it in every variant, a
simple binary value doesn't work.
This PR makes gives finer-grained control over high-performance
functions than the generic LIBC_CONF_UNSAFE_WIDE_READ option. For any
function they like, the user can now select one of four implementations
at build time:
1. element, which reads byte-by-byte (or wchar by wchar)
2. wide, which reads by unsigned long
3. generic, which uses standard clang vector implemenations, if
available
4. arch, which uses an architecture-specific implemenation
(Reading the code carefully, you may note that a user can actually
specify any namespace they want, so we aren't technically limited to
those 4.)
We may also want to switch from command-line #defines as it is currently
done, to something more like
llvm-project/llvm/include/llvm/Config/llvm-config.h.cmake, and
#including the resulting file, which would move quite a bit of
complexity out of the command-line. But that's a future problem.
|
|
This PR adds support to include syscall.h from MacOS sdk by explicitly including the path to the sdk via `xcrun`.
|
|
Summary:
These were originally intended to represent the functions that are
present on the GPU as to be provided by the LLVM libc implementation.
The original plan was that LLVM libc would report which functions were
supported and then the offload interface would mark those as supported.
The problem is that these wrapper headers are very difficult to make
work given the various libc extensions everyone does so they were
extremely fragile.
OpenMP already declares all functions used inside of a target region as
implicitly host / device, while these headers weren't even used for CUDA
/ HIP yet anyway. The only things we need to define right now are the
stdio FILE types. If we want to make this work for CUDA we'd need to
define these manually, but we're a ways off and that's way easier
because they do proper overloading.
|
|
Reverts llvm/llvm-project#166355
|
|
_Exit(3) is a fairly simple syscall wrapper whereas exit(3) calls
atexit-registered functions + whole lot of stuff that require support
for sync primitives.
Splitting the tests allows testing the former easily (especially for new
port projects)
---------
Signed-off-by: Shreeyash Pandey <shreeyash335@gmail.com>
|
|
When the backend for the host target isn't enabled, Clang would report
the default target as `unknown`. This currently breaks the libc CMake
build, but shouldn't in the case where we're cross-compiling since we're
given an explicit target and the default one isn't being used.
|
|
Add in SVE/SVE2/MOPS features for aarch64 cpus. These features may be
interesting for future memory/math routines.
SVE/SVE2 are now being accepted in more implementations:
```
❯ echo | clang-21 -dM -E - -march=native | grep -i ARM_FEAT
#define __ARM_FEATURE_ATOMICS 1
#define __ARM_FEATURE_BF16 1
#define __ARM_FEATURE_BF16_SCALAR_ARITHMETIC 1
#define __ARM_FEATURE_BF16_VECTOR_ARITHMETIC 1
#define __ARM_FEATURE_BTI 1
#define __ARM_FEATURE_CLZ 1
#define __ARM_FEATURE_COMPLEX 1
#define __ARM_FEATURE_CRC32 1
#define __ARM_FEATURE_DIRECTED_ROUNDING 1
#define __ARM_FEATURE_DIV 1
#define __ARM_FEATURE_DOTPROD 1
#define __ARM_FEATURE_FMA 1
#define __ARM_FEATURE_FP16_SCALAR_ARITHMETIC 1
#define __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 1
#define __ARM_FEATURE_FRINT 1
#define __ARM_FEATURE_IDIV 1
#define __ARM_FEATURE_JCVT 1
#define __ARM_FEATURE_LDREX 0xF
#define __ARM_FEATURE_MATMUL_INT8 1
#define __ARM_FEATURE_NUMERIC_MAXMIN 1
#define __ARM_FEATURE_PAUTH 1
#define __ARM_FEATURE_QRDMX 1
#define __ARM_FEATURE_RCPC 1
#define __ARM_FEATURE_SVE 1
#define __ARM_FEATURE_SVE2 1
#define __ARM_FEATURE_SVE_BF16 1
#define __ARM_FEATURE_SVE_MATMUL_INT8 1
#define __ARM_FEATURE_SVE_VECTOR_OPERATORS 2
#define __ARM_FEATURE_UNALIGNED 1
```
MOPS is another set of extension for string operations, but may not be
generally available for now:
```
❯ echo | clang-21 -dM -E - -march=armv9.2a+mops | grep -i MOPS
#define __ARM_FEATURE_MOPS 1
```
|
|
This options sets a compile option when building sources inside the
string directory, and this option affects string_utils.h. But
string_utils.h is #included from more places than just the string
directory (such as from __support/CPP/string.h), leading to both
narrow-reads in those cases, but more seriously, ODR violations when the
two different string_length implementations are included int he same
program.
Having this option at the top level avoids this problem.
|
|
Reverts llvm/llvm-project#160413
|
|
Relates to https://github.com/llvm/llvm-project/issues/119281
Note:
1) As this PR enables `-Werror` for `libc` tests, it's very likely some
downstream CI's may fail / start failing, so it's very likely this PR
may need to be reverted and re-applied.
P.S.
I do not have merge permissions, so I will need one of the reviews to
merge it for me. Thank you!
|
|
This partially reverts #124200. Rather than using a CMake option to
control whether to enable `-fno-math-errno`, use LIBC_MATH_NO_ERRNO
configuration option. While there might be other cases when we want to
set `-fno-math-errno`, having LIBC_MATH_NO_ERRNO imply it should be
always safe and represents a reasonable starting point.
|
|
Relates to #119281
|
|
RE apply https://github.com/llvm/llvm-project/pull/133643/commits#top
|
|
Summary:
The AMDGPU hack can be removed, and we no longer need to skip 90% of the
`HandleLLVMOptions` if we work around NVPTX earlier. Simplifies the
interface by removing duplicated logic and keeps the GPU targets from
being weirdly divergent on some flags.
|
|
Summary:
This adds a few basic tests for the SIMD helpers and adds a CMake
variable we can use to detect support.
|
|
Also this will allow all arguments to have overlay-only and
full-build-only options.
|
|
Summary:
People might want to modify this to run on older machines. Expose this
so it can be set with
`-DRUNTIMES_amdgcn-amd-amdhsa_LIBC_GPU_CODE_OBJECT_VERSION`.
|
|
in cmake. (#156485)
|
|
This is required in hermetic testing downstream. It is not complete, and
will not work on hardware, however it runs on QEMU, and can report a
pass/fail on our tests.
|
|
Reverts llvm/llvm-project#133643
|
|
* Relates to: https://github.com/llvm/llvm-project/issues/119281
|
|
This test was caught by our hermetic testing downstream. The baremetal
implementation does not support monotonic, so we disable it.
|
|
Add a cmake warning when an entrypoint or object library depends on a
public entrypoint.
|
|
Part of https://github.com/llvm/llvm-project/issues/145349. Required to
allow `atexit` to work. As part of `HermeticTestUtils.cpp`, there is a
reference to `atexit()`, which eventually instantiates an instance of a
Mutex.
Instead of copying the implementation from
`libc/src/__support/threads/gpu/mutex.h`, we allow platforms to select
an implementation based on configurations, allowing the GPU and
single-threaded baremetal platforms to share an implementation. This can
be configured or overridden.
Later, when the threading API is more complete, we can add an option to
support multithreading (or set it as the default), but having
single-threading (in tandem) is in line with other libraries for
embedded devices.
|
|
stdio test suite. (#149740)
|
|
This PR simplifies how we enable the different fma configs for riscv:
1. Removes __LIBC_RISCV_USE_FMA define
2. Checks if __riscv_flen is defined to set LIBC_TARGET_CPU_HAS_FMA
As a bonus, we enable *FMA_OPT tests for rv32, so any rv32 hardware that
doesn't implement the f/d extensions is also covered by the tests.
|
|
https://github.com/llvm/llvm-project/pull/147931
|
|
Part of #145349. These hooks are required downstream in order to run
hermetic tests. See https://github.com/arm/arm-toolchain/pull/420 for
more context on how this PR will be used.
|
|
For some reason cmake usually turns this path into an absolute path, but
sometimes
it doesn't do it and stays as a relative path, which means the command
will fail.
Specify it as an absolute path always so this doesn't happen any more.
|
|
A typo, set() instead of list() would cause the build to not define
LIBC_CONF_ERRNO_MODE, which would cause the wrong configuration to be
used.
|
|
Following discussion from
https://discourse.llvm.org/t/missing-declarations-in-header-files/86678,
we decided to add a flag to output all headers. Requires #144049.
- Allows outputting all headers
- Minor whitespace change for alignment
---------
Co-authored-by: Michael Jones <michaelrj@google.com>
|
|
LIBC_ERRNO_MODE_SYSTEM to be header-only. (#143187)
This is the first step in preparation for:
https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450
|
|
Summary:
This patch cleans up the leftoever files that were either implemented or
are still unimplemented stubs.
|
|
|
|
Fixes [#141505](https://github.com/llvm/llvm-project/issues/141505)
The main intention behind this PR is to update the
LibCTargetArchitecture for arm64 to use the implementation of aarch64
architecture and not arm32.
This is a historical issue , and is a blocker to issue #138407.
The intended fix is to set the `LibCTargetArchitecture` to aarch64 when
it matches arm64 , this in turn would help us run darwin/aarch64
specific code on our MacOs pipeline in the git actions.
Methods used to search and find "darwin/arm" directories was
1. "find . -type d -path "*/libc/*/darwin/arm" in a linux terminal to
check for arm specifically
2. "find . -type d -path "*/libc/*/darwin/*" to ensure there are no
directories that are named "*arm*" where star is a wildcard for any
character.
|