| Age | Commit message (Collapse) | Author | Files | Lines |
|
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 change expands the stdio support on baremetal to support opaque
FILE*. This builds on top of the existing baremetal embedding API; we
treat the standard FILE* streams as pointers that point to the cookie
symbols which are a part of the embedding API. This also allows users to
define their own FILE* streams, but we don't (yet) support the API that
return FILE* such as fopen or fopencookie.
|
|
This patch adds support for clock_gettime for Darwin. Darwin syscall
'gettimeofday' is used to query the time from the system.
Many headers in llvm-libc-types, namely clockid_t, struct_timespec,
struct_timeval, suseconds_t, time_t_32, time_t_64, are modified to
include
header guards as Darwin has its own implementation of primitive types.
|
|
Add internal::exit for MacOS/Darwin
|
|
(#166846)
The previous implementation in #166252 (rolled back in #166658) caused
buildbot failures due to a bug in an added test. The modified
`UseAfterClose` did not pass a `struct flock` value to `fcntl`:
https://github.com/llvm/llvm-project/blob/2d5170594147b42a37698760d6e0194eec4f1390/libc/test/src/fcntl/fcntl_test.cpp#L175
Which ASAN caught and errored in the `fcntl` implementation when the
unspecified argument was accessed:
https://github.com/llvm/llvm-project/blob/c12cb2892c808af459eaa270b8738a2b375ecc9b/libc/src/__support/OSUtil/linux/fcntl.cpp#L59
|
|
Reverts llvm/llvm-project#166252
Causing buildbot failures on `libc-x86_64-debian-dbg-asan`.
|
|
This patch also configures fcntl lock tests to run with F_OFD_* command
variants, as all existing lock tests do not exercise process-associated-
or OFD-specific functionality.
|
|
|
|
|
|
Fix auxv rv32 build problem
|
|
|
|
Closes https://github.com/llvm/llvm-project/issues/153666
This patch introduces a new centralized AUXV (auxiliary vector) handling
mechanism for LLVM libc on Linux, replacing the previous scattered
implementation across multiple files.
## Key Changes:
### New Files:
- **libc/src/__support/OSUtil/linux/auxv.h**: New header library
providing
a clean interface for AUXV access with:
- `auxv::Entry` struct for AUXV entries (type and value)
- `auxv::Vector` class with iterator support for traversing AUXV
- `auxv::get()` function for retrieving specific AUXV values
- Thread-safe initialization with fallback mechanisms (prctl and
/proc/self/auxv)
### Modified Files:
1. **libc/src/__support/OSUtil/linux/CMakeLists.txt**:
- Added `auxv` header library declaration with proper dependencies:
- libc.hdr.fcntl_macros
- libc.src.__support.OSUtil.osutil
- libc.src.__support.common
- libc.src.__support.CPP.optional
- libc.src.__support.threads.callonce
2. **libc/config/linux/app.h**:
- Removed `AuxEntry` struct (moved to auxv.h as `auxv::Entry`)
- Removed `auxv_ptr` from `AppProperties` struct
- Simplified application properties structure
3. **libc/src/sys/auxv/linux/getauxval.cpp**:
- Completely refactored to use new auxv.h interface
- Removed ~200 lines of complex initialization code
- Simplified to just call `auxv::get()` function
- Removed dependencies to external symbols (mman, prctl, fcntl, read,
close, open)
4. **libc/src/sys/auxv/linux/CMakeLists.txt**:
- Updated dependencies to use new auxv header library
- Removed dependencies to external symbols (prctl, mman, fcntl, unistd,
etc.)
5. **libc/startup/linux/do_start.cpp**:
- Updated to use new `auxv::Vector` interface
- Changed from pointer-based to iterator-based AUXV traversal
- Updated field names (`aux_entry->id` → `aux_entry.type`,
`aux_entry->value` → `aux_entry.val`)
- Added call to `auxv::Vector::initialize_unsafe()` for early AUXV setup
6. **libc/startup/linux/CMakeLists.txt**:
- Added dependency on `libc.src.__support.OSUtil.linux.auxv`
|
|
Reverts llvm/llvm-project#152748
|
|
This is a follow up to the RFC here:
https://discourse.llvm.org/t/rfc-implementation-of-stdio-on-baremetal/86944
This provides the stdout/stderr/stdin symbols (which now don't have to
provided by the user). This allows the user to have access to all
functions, currently I've only tested `fprintf` but in theory everything
that works in the generic folder should work in the baremetal
configuration.
All streams are _non-buffered_, which does NOT require flushing. It is
based on the CookieFile that already existed
|
|
|
|
Implemented an internal getrandom to avoid calls to the public one in
table.h
---------
Co-authored-by: Sriya Pratipati <sriyap@google.com>
|
|
The previous internal fcntl implementation modified errno directly, this
patch fixes that. This patch also moves open and close into OSUtil since
they are used in multiple places. There are more places that need
similar cleanup but only got comments in this patch to keep it
relatively reviewable.
Related to: https://github.com/llvm/llvm-project/issues/143937
|
|
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
|
|
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.
|
|
Adds `crt1.o` for the UEFI platform in the LLVM C library. This makes
things start to become useful.
|
|
The entrypoints for aarch64 are mostly up to date, but the headers are
not. This patch fixes that, and also makes explicit the dependency from
OSUtils/linux on sys/syscalls.h
|
|
Initial UEFI OS target support after the headers. This just defines
enough that stuff might try and compile. Test with:
```
$ cmake -S llvm -B build -G Ninja -DLLVM_RUNTIME_TARGETS=x86_64-unknown-uefi-llvm -DRUNTIMES_x86_64-unknown-uefi-llvm_LLVM_ENABLE_RUNTIMES=libc -DRUNTIMES_x86_64-unknown-uefi-llvm_LLVM_LIBC_FULL_BUILD=true -DCMAKE_C_COMPILER_WORKS=true -DCMAKE_CXX_COMPILER_WORKS=true -DLLVM_ENABLE_PROJECTS="clang;lld" -DCMAKE_BUILD_TYPE=Debug -DLLVM_ENABLE_LIBCXX=true -DLLVM_HOST_TRIPLE=aarch64-unknown-linux-gnu -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-uefi-llvm -DCMAKE_INSTALL_LIBDIR=build/target/lib
$ ninja -C build
```
|
|
Relates to
https://github.com/llvm/llvm-project/issues/119281#issuecomment-2699470459
|
|
This reverts commit 1e6e845d49a336e9da7ca6c576ec45c0b419b5f6 because it
changed the 1st parameter of adjust() to be unsigned, but libc itself
calls adjust() with a negative argument in align_backward() in
op_generic.h.
|
|
Relates to: #119281
|
|
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>
|
|
Summary:
RPC_ is a generic prefix here, use LIBC_ to indicate that these are
opcodes used to implement the C library
|
|
Summary:
These are provided by a resource header now, cut these from the
dependencies and only provide the ones we use for RPC.
|
|
Configured via:
$ cmake ../runtimes -G Ninja -DLLVM_ENABLE_LLD=ON \
-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RUNTIMES="libc" \
-DLIBC_TARGET_TRIPLE=i386-linux-gnu -DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++
Link: #93709
|
|
Link: #93709
|
|
Summary:
I'm going to attempt to move the `rpc.h` header to a separate folder
that we can install and include outside of `libc`. Before doing this I'm
going to try to trim up the file so there's not as many things I need to
copy to make it work. This dependency on `cpp::functional` is a low
hanging fruit. I only did it so that I could overload the argument of
the work function so that passing the id was optional in the lambda,
that's not a *huge* deal and it makes it more explicit I suppose.
|
|
|
|
|
|
target (#104676)
This PR first adds osutils for Windows, and changes some libc code to
make libc and its tests build on the Windows target. It then temporarily
disables some libc tests that are currently problematic on Windows.
Specifically, the changes besides the addition of osutils include:
- Macro `LIBC_TYPES_HAS_FLOAT16` is disabled on Windows. `clang-cl`
generates calls to functions in `compiler-rt` to handle float16
arithmetic and these functions are currently not linked in on Windows.
- Macro `LIBC_TYPES_HAS_INT128` is disabled on Windows.
- The invocation to `::aligned_malloc` is changed to an invocation to
`::_aligned_malloc`.
- The following unit tests are temporarily disabled because they
currently fail on Windows:
- `test.src.__support.big_int_test`
- `test.src.__support.arg_list_test`
- `test.src.fenv.getenv_and_setenv_test`
- Tests involving `__m128i`, `__m256i`, and `__m512i` in
`test.src.string.memory_utils.op_tests.cpp`
- `test_range_errors` in `libc/test/src/math/smoke/AddTest.h` and
`libc/test/src/math/smoke/SubTest.h`
|
|
|
|
|
|
This patch removes the recursion in fcntl introduced by PR #99675 as it is not required and may be dangerous in some cases: some toolchains define F_GETLK == F_GETLK64 causing infinite recursion.
|
|
In some systems like rv32, only fcntl64 is available and it employs a different structure for file locking and the correspoding F_GETLK64, F_SETLK64, and F_SETLKW64 commands.
So if we use fcntl64, the F_GETLK, F_SETLK, and F_SETLKW commands need to be changed to their 64 versions. This patch adds new cases to the swich(cmd) in our implementation of fcntl to do that.
The default case was moved to outside the switch, so we don't need to change anything, the F_GETLK, F_SETLK, and F_SETLKW commands will just go through the old implementation.
|
|
|
|
Reverts llvm/llvm-project#98989
|
|
migrated from https://github.com/llvm/llvm-project/pull/95965 due to
corrupted git history
|
|
These need to use C ABI.
|
|
This refines and extends the external ABI for I/O, later changes will
update the baremetal implementations of I/O functions to use these.
|
|
This is a part of #97655.
|
|
declaration" (#98593)
Reverts llvm/llvm-project#98075
bots are broken
|
|
This is a part of #97655.
|
|
reland of https://github.com/llvm/llvm-project/pull/98215
Additionally adds proxy headers for FILE and the fopencookie types
The arm32 build has been failing due to redefinitions of the off_t type.
This patch fixes this by moving off_t to a proper proxy header. To do
this, it also moves stdio macros to a proxy header to hopefully avoid
including this proxy header alongside this public stdio.h.
|
|
Reverts llvm/llvm-project#98215
Breaks linux bots
|
|
This ensures that these symbols inherit the namespace visibility.
|
|
The arm32 build has been failing due to redefinitions of the off_t type.
This patch fixes this by moving off_t to a proper proxy header. To do
this, it also moves stdio macros to a proxy header to hopefully avoid
including this proxy header alongside this public stdio.h.
|