aboutsummaryrefslogtreecommitdiff
path: root/libc
AgeCommit message (Collapse)AuthorFilesLines
2024-02-23[libc] Fix standard cross build targeting the GPU (#82724)Joseph Huber2-2/+6
Summary: The GPU target has recently been changed to support standard `libc` build rules. This means we should be able to build for it both in `LLVM_ENABLE_PROJECTS` mode, or targeting the runtimes directory directly as in the LLVM `libc` documentation. Previously this failed because the version check on the compiler was too strict and the `--target=` options were not being set on the link jobs unless in CMake cross compiliation mode. This patch fixes those so the following config should work now to build the GPU target directly if using NVPTX. ``` cmake ../runtimes -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang \ -DLLVM_ENABLE_RUNTIMES=libc -DLLVM_RUNTIMES_TARGET=nvptx64-nvidia-cuda \ -DLLVM_DEFAULT_TARGET_TRIPLE=nvptx64-nvidia-cuda \ -DLIBC_HDRGEN_EXE=/path/to/hdrgen/libc-hdrgen \ -DLLVM_LIBC_FULL_BUILD=ON -GNinja ```
2024-02-23[libc][NFC] Remove redundant external clock symbol for AMDGPU (#82794)Joseph Huber1-6/+0
Summary: The AMDGPU target needs an external clock symbol so the driver can set the frequency with the correct value. This was left over from the previous implementation and I forgot to remove it when actually implementing the timing utilities.
2024-02-22[libc] Search the compiler's path for GPU utility tools (#82712)Joseph Huber1-2/+3
Summary: We need some extra tools for the GPU build. Normally we search for these from the build itself, but in the case of a `LLVM_PROJECTS_BUILD` or some other kind of external build, this directory will not be populated. However, the GPU build already requires that the compiler is an up-to-date clang, which should always have these present next to the binary. Simply add this as a fallback search path. Generally we want it to be the second, because it would pick up someone install and then become stale.
2024-02-22[libc] Silence warnings when building GPU tests (#82701)Joseph Huber2-2/+4
Summary: This patch silences two warnings that may occur during the building of GPU tests. These are not informative or helpful and just make the test output longer.
2024-02-22[libc] Match the names of BSD sys/queue.h member names (#82696)Petr Hosek1-26/+26
While these names are technically internal implemenetation detail, there's an existing code which relies on these details and using different names makes LLVM libc implementation incompatible. Since our goal is for LLVM libc to be a drop in replacement, use the same name as BSD sys/queue.h version.
2024-02-22[libc] Rework the GPU build to be a regular target (#81921)Joseph Huber43-642/+502
Summary: This is a massive patch because it reworks the entire build and everything that depends on it. This is not split up because various bots would fail otherwise. I will attempt to describe the necessary changes here. This patch completely reworks how the GPU build is built and targeted. Previously, we used a standard runtimes build and handled both NVPTX and AMDGPU in a single build via multi-targeting. This added a lot of divergence in the build system and prevented us from doing various things like building for the CPU / GPU at the same time, or exporting the startup libraries or running tests without a full rebuild. The new appraoch is to handle the GPU builds as strict cross-compiling runtimes. The first step required https://github.com/llvm/llvm-project/pull/81557 to allow the `LIBC` target to build for the GPU without touching the other targets. This means that the GPU uses all the same handling as the other builds in `libc`. The new expected way to build the GPU libc is with `LLVM_LIBC_RUNTIME_TARGETS=amdgcn-amd-amdhsa;nvptx64-nvidia-cuda`. The second step was reworking how we generated the embedded GPU library by moving it into the library install step. Where we previously had one `libcgpu.a` we now have `libcgpu-amdgpu.a` and `libcgpu-nvptx.a`. This patch includes the necessary clang / OpenMP changes to make that not break the bots when this lands. We unfortunately still require that the NVPTX target has an `internal` target for tests. This is because the NVPTX target needs to do LTO for the provided version (The offloading toolchain can handle it) but cannot use it for the native toolchain which is used for making tests. This approach is vastly superior in every way, allowing us to treat the GPU as a standard cross-compiling target. We can now install the GPU utilities to do things like use the offload tests and other fun things. Some certain utilities need to be built with `--target=${LLVM_HOST_TRIPLE}` as well. I think this is a fine workaround as we will always assume that the GPU `libc` is a cross-build with a functioning host. Depends on https://github.com/llvm/llvm-project/pull/81557
2024-02-22[libc] add FXBits class (#82065)Michael Jones6-1/+446
The FXBits class is what will be used to modify fixed point numbers on a bit level. This patch adds a basic implementation as well as basic tests.
2024-02-22[build] Check RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES for libc also (#82561)Petr Hosek1-2/+15
When checking whether we need to build libc-hdrgen, we need to check LLVM_ENABLE_RUNTIMES and RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES, just the former is not sufficient since libc may be enabled only for certain targets.
2024-02-21[libc] Fix startup utilities failing to install in full build mode (#82522)Joseph Huber3-10/+14
Summary: Currently, doing `ninja install` will fail in fullbuild mode due to the startup utilities not being built by default. This was hidden previously by the fact that if tests were run, it would build the startup utilities and thus they would be present. This patch solves this issue by making the `libc-startup` target a dependncy on the final library. Furthermore we simply factor out the library install directory into the base CMake directory next to the include directory handling. This change makes the `crt` files get installed in `lib/x86_64-unknown-linu-gnu` instead of just `lib`. This fixes an error I had where doing a runtimes failed to install its libraries because the install step always errored.
2024-02-20[libc] add more stdbit.h entrypoints to additional targets (#82440)Nick Desaulniers6-0/+232
stdbit.h isn't complete yet, but looking to turn these on on more targets for earlier feedback.
2024-02-20Add explicit conversion to fix arm64 builds. (#82429)Moshe1-4/+4
Fixes issue preventing builds on ARM-based Macs. https://github.com/llvm/llvm-project/issues/82205. Co-authored-by: Moshe Berman <mosheberman@users.noreply.github.com>
2024-02-20[libc][__support][bit] add count_zeros (#82076)Nick Desaulniers2-0/+42
Will be useful for implementing C23 stdbit.h's stdc_count_zeros and stdc_count_ones.
2024-02-20[libc] Cleanup of hermetic test flag handling (#82384)Joseph Huber3-46/+25
Summary: This cleans up the handling of hermetic test flags. Primarily done to simplify the GPU rework patch.
2024-02-20[libc] use LIBC_HAS_BUILTIN instead __has_builtin (#82377)Schrodinger ZHU Yifan1-1/+1
fix the issue that `__has_builtin` is undefined on some non-clang targets.
2024-02-20[libc][c23] add definitions for stdckdint.h (#82059)Schrodinger ZHU Yifan13-1/+120
See docs at - https://gustedt.gitlabpages.inria.fr/c23-library/#stdckdint - https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3047.pdf (Ch7.10) Compiler header: - https://github.com/llvm/llvm-project/blob/450462cbaceddf57812ce15b5135b17f65a77654/clang/lib/Headers/stdckdint.h - New version of GCC (https://github.com/gcc-mirror/gcc/blob/cd503b0616462445381a8232fb753239d319af76/gcc/ginclude/stdckdint.h) also provides this.
2024-02-20[libc][cpp] add `atomic_signal_fence` (#82138)Schrodinger ZHU Yifan1-3/+16
Add `atomic_signal_fence`. This will be useful in https://gustedt.gitlabpages.inria.fr/c23-library/#memset_explicit.
2024-02-16[libc][stdfix] Add round functions for fixed point types. (#81994)lntue44-1/+809
2024-02-16[libc][NFC] Add missing constexpr (#82007)Guillaume Chatelet1-2/+2
This is a fix forward for the Fuchsia build bot https://lab.llvm.org/buildbot/#/builders/98/builds/33515
2024-02-16[libc][docs] start documenting c23 support (#81933)Nick Desaulniers2-0/+115
I've been diffing the c17 vs c23 latest publicly available drafts and think I have most of the library related differences. I haven't yet annotated what we actually support or not. Link: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2310.pdf (C17) Link: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf (C23)
2024-02-16[reland][libc][NFC] Use user defined literals to build 128 and 256 bit ↵Guillaume Chatelet15-2516/+2555
constants (#81998) - #81835 - Fix for platforms where uint64_t is not available
2024-02-16[libc][stdfix] Re-enable fixed point abs entry points. (#81995)lntue1-7/+6
#80757 has been merged.
2024-02-16[libc][NFC] Simplify BigInt (#81992)Guillaume Chatelet2-146/+74
- Add a single `cmp` function to derive all comparison operators - Use the `friend` version of the member functions for symmetry - Add a `is_neg` function to factor sign extraction - Implement binary op through macro expansion
2024-02-15[libc] Move compile options to new cmake file (#81917)Michael Jones5-181/+229
The cmake test generator needed to be updated to support the same flags as the source. To simplify the code, I moved it to a new file.
2024-02-15[libc] Tempporarily disable fixed point entry points until #80757 is merged. ↵lntue1-6/+7
(#81945)
2024-02-15[libc][stdfix] Add abs functions for signed fixed point types. (#81823)lntue29-2/+473
2024-02-15[libc][NFC] Annotate LIBC_INLINE and constexpr to BigInt and DyadicFloat ↵lntue4-27/+31
methods. (#81912)
2024-02-15[libc][stdfix] Add support for fixed point types in the testing ↵lntue5-84/+161
infrastructure. (#81819)
2024-02-15[libc] Make add_with_carry and sub_with_borrow constexpr. (#81898)lntue1-46/+84
2024-02-15Revert "[reland][libc][NFC] Use user defined literals to build 128 and 256 ↵Guillaume Chatelet14-2526/+2502
bit constants" (#81882) Reverts llvm/llvm-project#81835 This is breaking arm32 which does not support 64 bit types.
2024-02-15[libc] add support for function level attributes (#79891)Schrodinger ZHU Yifan4-21/+231
See discussion at https://discourse.llvm.org/t/rfc-support-function-attributes-in-user-interface/76624 Demo macro: ```c++ #if !defined(__LIBC_CONST_ATTR) && defined(__cplusplus) && defined(__GNUC__) #if __has_attribute(const) #define __LIBC_CONST_ATTR [[gnu::const]] #endif #endif #if !defined(__LIBC_CONST_ATTR) && defined(__GNUC__) #if __has_attribute(const) #define __LIBC_CONST_ATTR __attribute__((const)) #endif #endif #if !defined(__LIBC_CONST_ATTR) #define __LIBC_CONST_ATTR #endif ```
2024-02-15[libc][NFC] Cleanup unnecessary template parameters in BigInt (#81871)Guillaume Chatelet1-100/+71
2024-02-15[libc][NFC] Fix missing replacement in BigInt (#81864)Guillaume Chatelet1-1/+1
2024-02-15[libc][NFC] Fix missing `constexpr` qualifier in `cpp::array` (#81862)Guillaume Chatelet1-1/+1
2024-02-15[reland][libc][NFC] Use user defined literals to build 128 and 256 bit ↵Guillaume Chatelet14-2502/+2526
constants (#81835) This is a reland of #81746
2024-02-15[libc][stdfix] Use __FRACT_FBIT__ for fixed point support detection instead ↵lntue1-4/+2
of compiler version. (#81820) Now that `__FRACT_FBIT__` and related macros are added in https://github.com/llvm/llvm-project/pull/81207, it is safer to use them for fixed point support detection, so that codes that do not use fixed point types will not fail to build when `-ffixed-point` is missing.
2024-02-14[libc][fix] Fix new test that crashes the NVPTX backendJoseph Huber1-10/+13
2024-02-14[libc][math] Add C23 ldexpf128 math function and fix DyadicFloat conversions ↵lntue20-63/+222
for subnormal ranges and 80-bit floating points. (#81780)
2024-02-14[libc] Fix fixed point detection and add compile option. (#81788)lntue3-1/+8
2024-02-14[libc] Add is_fixed_point type trait. (#81263)lntue4-1/+50
2024-02-14[libc][stdfix] Add FXRep helper class for fixed point types. (#81272)lntue3-0/+185
2024-02-14[libc][stdbit] implement stdc_first_trailing_one (C23) (#81768)Nick Desaulniers24-12/+362
2024-02-14[libc][stdbit] implement stdc_first_trailing_zero (C23) (#81526)Nick Desaulniers24-8/+366
2024-02-14Revert "[libc][NFC] Use user defined literals to build 128 and 256 bit ↵Guillaume Chatelet14-2505/+2482
constants." (#81771) Reverts llvm/llvm-project#81746
2024-02-14[libc][NFC] Use user defined literals to build 128 and 256 bit constants. ↵Guillaume Chatelet14-2482/+2505
(#81746)
2024-02-14[libc][stdbit] implement stdc_first_leading_one (C23) (#81502)Nick Desaulniers24-26/+385
2024-02-14[libc][__support][bit] simplify FLZ (#81678)Nick Desaulniers1-20/+1
`countl_zero(~x)` *is* `countl_one(x)`
2024-02-14[libc][__support][bit] remove compiler has builtin checks (#81679)Nick Desaulniers1-18/+0
We only support building llvmlibc with modern compilers. https://libc.llvm.org/compiler_support.html#minimum-supported-versions All versions of the these compilers support these builtins; GCC does not support the short variants.
2024-02-14[libc] Add user defined literals to initialize `BigInt` and `__uint128_t` ↵Guillaume Chatelet6-213/+505
constants (#81267) Adds user defined literal to construct unsigned integer constants. This is useful when constructing constants for non native C++ types like `__uint128_t` or our custom `BigInt` type.
2024-02-13[libc][stdfix] Generate stdfix.h header with fixed point precision macros ↵lntue11-3/+539
according to ISO/IEC TR 18037:2008 standard, and add fixed point type support detection. (#81255) Fixed point extension standard: https://standards.iso.org/ittf/PubliclyAvailableStandards/c051126_ISO_IEC_TR_18037_2008.zip
2024-02-13[libc] Allow BigInt class to use base word types other than uint64_t. (#81634)lntue5-390/+493
This will allow DyadicFloat class to replace NormalFloat class.