malloc, calloc, realloc, and free are all functions that other libc
functions depend on, but are pulled from external sources, instead of
having an internal implementation. This patch adds a way to include
functions like that as entrypoints in the list of external entrypoints,
and includes the malloc functions using this new path.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D112104
This suite is helpful is adding long running tests which take a long
time to finish that they can be run on the public builders. They
will probably be run on special builders in future.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D104816
Included more math functions to Windows's entrypoints
and made a cmake option (-DLLVM_LIBC_MPFR_INSTALL_PATH)
where the user can specify the install path where the MPFR
library was built so it can be linked. The try_compile was
moved to LLVMLibCCheckMPFR.cmake, so the variable that is
set after this process can retain its value in other files
of the same parent file. A direct reason for this is for
LIBC_TESTS_CAN_USE_MPFR to be true when the user specifies
MPFR's path and retain its value even after leaving the file.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D106894
This patch adds LLVM_LIBC_INCLUDE_SCUDO as a flag. When enabled it
should link in the standalone version of SCUDO as the allocator for LLVM
libc.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D106502
This addition reads command line input to run specific single tests
within a larger call to run all the tests for a particular function.
When the user adds a second argument to the command line, the code skips
all the tests that don't match the user's specified binary. If the user
doesn't specify a test correctly and/or no tests are run, a failure
message prints.
Reviewed By: sivachandra, aeubanks
Differential Revision: https://reviews.llvm.org/D105843
The current compile options function hardcodes the -fpie and
-ffreestanding flags, which don't exist on Windows. This patch sets the
compilation flags conditionally based on the OS specifics.
Reviewed By: sivachandra, aeubanks
Differential Revision: https://reviews.llvm.org/D105643
This is a roll forward of D101895 with two additional fixes:
Original Patch description:
> This is a follow up on D101524 which:
>
> - simplifies cpu features detection and usage,
> - flattens target dependent optimizations so it's obvious which implementations are generated,
> - provides an implementation targeting the host (march/mtune=native) for the mem* functions,
> - makes sure all implementations are unittested (provided the host can run them).
Additional fixes:
- Fix uninitialized ALL_CPU_FEATURES
- Use non pseudo microarch as it is only supported from Clang 12 on
Differential Revision: https://reviews.llvm.org/D102233
This reverts commit 541f107871 as the bots
are failing with unknown architecture "x86-64-v*". Will let the original
author decide on the right course of action to correct the problem and
reland.
This is a follow up on D101524 which:
- simplifies cpu features detection and usage,
- flattens target dependent optimizations so it's obvious which implementations are generated,
- provides an implementation targeting the host (march/mtune=native) for the mem* functions,
- makes sure all implementations are unittested (provided the host can run them),
- makes sure all implementations are benchmarkable (provided the host can run them).
Differential Revision: https://reviews.llvm.org/D101895
This patch provides a way to specify the default target cpu optimizations to use when compiling llvm-libc.
This ensures we don't rely on current compiler's default and allows compiling and cross compiling for a particular target.
Differential Revision: https://reviews.llvm.org/D101991
Current implementation defines LIBC_TARGET_MACHINE with the use of CMAKE_SYSTEM_PROCESSOR.
Unfortunately CMAKE_SYSTEM_PROCESSOR is OS dependent and can produce different results.
An evidence of this is the various matchers used to detect whether the architecture is x86.
This patch normalizes LIBC_TARGET_MACHINE and renames it LIBC_TARGET_ARCHITECTURE.
I've added many architectures but we may want to limit ourselves to x86 and ARM.
Differential Revision: https://reviews.llvm.org/D101524
This option will build LLVM libc as a full libc by itself. In this mode,
it is not expected that it will be mixed with other libcs. The
non-full-build mode will be the default LLVM libc build mode. In a future
where LLVM libc is complete enough, the full libc build will be made the
default mode.
This is useful when cross-compiling libc to another target in which
case we first need to compile libc-hdrgen for host. We rely on the
existing LLVM CMake infrastructure for that.
Differential Revision: https://reviews.llvm.org/D95205
We won't be able to run the compiled program since it will be compiled
for different system. We instead allow passing the CPU features via
CMake option in that case.
Differential Revision: https://reviews.llvm.org/D95203
Summary:
The new macro also inserts the C alias for the C++ implementations
without needing an objcopy based post processing step. The CMake
rules have been updated to reflect this. More CMake cleanup can be
taken up in future rounds and appropriate TODOs have been added for them.
Reviewers: mcgrathr, sivachandra
Subscribers:
Couple of helper functions enableExcept and disableExcept have been
added. In a later round, they will be used to implemented the GNU
extension functions feenableexcept and fedisableexcept.
Differential Revision: https://reviews.llvm.org/D92821
The function listings in api.td are removed. The same lists are now deduced using the information
in entrypoints.txt.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D89267
The feature check should probably be enhanced for non-x86 architectures,
but this change shields them from x86 specific pieces until then.
This patch has been split out from https://reviews.llvm.org/D81533.
Summary:
If a test depends on a skipped entrypoint, then the test is also
skipped. This setup will be useful as we gradually add support for
more operating systems and target architectures.
Reviewers: asteinhauser
Differential Revision: https://reviews.llvm.org/D81489
Summary:
This patch aims to add integration tests to check the following:
1) Header files are generated as expected.
2) Libc functions have the correct public name.
3) Libc functions have the correct return type and parameter types.
4) Symbols are exposed in the public lib.a files.
Reviewers: sivachandra, abrachet
Reviewed By: sivachandra
Subscribers: aheejin, ecnelises, dxf, mgorny, jfb, tschuett, libc-commits
Tags: #libc-project
Differential Revision: https://reviews.llvm.org/D79192
Summary: When building llvm-libc with linting enabled, clang-tidy would use the resource dir of the monorepo rather then the host compiler's resource dir. This presented issues when including headers from the host compiler e.g. for sanitizers. Therefore this patch explicitly tells clang-tidy to use the host compiler's resource dir.
Reviewers: sivachandra
Reviewed By: sivachandra
Subscribers: mgorny, tschuett, ecnelises, libc-commits
Tags: #libc-project
Differential Revision: https://reviews.llvm.org/D80265
Summary:
I found that because `--system-headers` flag was not included when running clang-tidy, errors produced from compiler provided headers were being suppressed. After passing this flag I realized that by including headers like stdint.h we were indirectly including headers from the system libc. To prevent this we pass `-ffreestanding`.
We don't want to pass `--system-headers` for all checks just the `llvmlibc-restrict-system-libc-headers` therefore we do a separate invocation of clang-tidy for this check.
Reviewers: abrachet, sivachandra
Reviewed By: sivachandra
Subscribers: mgorny, aheejin, tschuett, ecnelises, libc-commits
Tags: #libc-project
Differential Revision: https://reviews.llvm.org/D80178
Deps are recrusively evaluated at the place they are needed. With this
change, one does not have to list recursive deps of entrypoints when
listing test targets. One will still have to explicitly list all
entrypoint objects when setting up an "add_entrypoint_library" target.
Reviewers: abrachet
Differential Revision: https://reviews.llvm.org/D78537
Summary:
The single file was getting too long to be convenient to navigate. This
patch splits it up two into 4 files one each for header rules,
object rules, library rules, and test rules.
Reviewers: abrachet, alexshap
Subscribers: mgorny, tschuett, libc-commits
Tags: #libc-project
Differential Revision: https://reviews.llvm.org/D78536
Summary: It also re formats long lines in `add_gen_header`
Reviewers: sivachandra
Reviewed By: sivachandra
Subscribers: mgorny, tschuett, libc-commits
Differential Revision: https://reviews.llvm.org/D78349
Summary:
This patch implements running linting on llvm-libc using build rule targets.
1) adds a new target per entrypoint for linting with the naming convention `<qualified_target_name>.__lint__` e.g `libc.src.string.strlen.__lint__`.
2) makes the build target for each entrypoint depend on the linting targets so that they run along with compilation of each entrypoint.
3) adds a lint all target named `lint-libc`. `check-libc` now depends on this new target.
4) linting creates a lot of additional targets from clang and clang-tidy that need to be built so an opt out flag can be passed to cmake: `LLVM_LIBC_ENABLE_LINTING`.
Reviewers: sivachandra, abrachet
Reviewed By: sivachandra
Subscribers: abrachet, mgorny, tschuett, libc-commits
Tags: #libc-project
Differential Revision: https://reviews.llvm.org/D77861
Only targets setup by the special LLVM libc rules now have fully
qualified names. The naming style is similar to fully qualified names in
Python.
Reviewers: abrachet, PaulkaToast, phosek
Differential Revision: https://reviews.llvm.org/D77340
Summary:
The patch is not ready yet and is here to discuss a few options:
- How do we customize the implementation? (i.e. how to define `kRepMovsBSize`),
- How do we specify custom compilation flags? (We'd need `-fno-builtin-memcpy` to be passed in),
- How do we build? We may want to test in debug but build the libc with `-march=native` for instance,
- Clang has a brand new builtin `__builtin_memcpy_inline` which makes the implementation easy and efficient, but:
- If we compile with `gcc` or `msvc` we can't use it, resorting on less efficient code generation,
- With gcc we can use `__builtin_memcpy` but then we'd need a postprocess step to check that the final assembly do not contain call to `memcpy` (unlikely but allowed),
- For msvc we'd need to resort on the compiler optimization passes.
Reviewers: sivachandra, abrachet
Subscribers: mgorny, MaskRay, tschuett, libc-commits, courbet
Tags: #libc-project
Differential Revision: https://reviews.llvm.org/D74397
This rule can help add targets to generate special object files like the
crt1.o on linux. Also, it can be used to add specially compiled object
stubs which are to be linked into the entrypoint objects.
Reviewers: abrachet
Differential Revision: https://reviews.llvm.org/D76271
The following are the differences from the first version:
1. The kernel does not copy the stack for the new thread (it cannot).
The previous version missed this fact. In this new version, the new
thread's start args are copied on to the new stack in a known location
so that the new thread can sniff them out.
2. A start args sniffer for x86_64 has been added.
2. Default stack size has been increased to 64KB.
Reviewers: abrachet, phosek
Differential Revision: https://reviews.llvm.org/D75818
This argument can be used to specify the entrypoint name if it is different
from the target name.
Reviewers: gchatelet, abrachet
Differential Revision: https://reviews.llvm.org/D74948
Summary: This patch adds `EXPECT_EXITS` and `EXPECT_DEATH` macros for testing exit codes and deadly signals. They are less convoluted than their analogs in GTEST and don't have matchers but just take an int for either the exit code or the signal respectively. Nor do they have any regex match against the stdout/stderr of the child process.
Reviewers: sivachandra, gchatelet
Reviewed By: sivachandra
Subscribers: mgorny, MaskRay, tschuett, libc-commits
Differential Revision: https://reviews.llvm.org/D74665
Summary:
Added fuzzing test for strcpy and some documentation related to fuzzing.
This will be the first step in integrating this with oss-fuzz.
Reviewers: sivachandra, abrachet
Reviewed By: sivachandra, abrachet
Subscribers: gchatelet, abrachet, mgorny, MaskRay, tschuett, libc-commits
Tags: #libc-project
Differential Revision: https://reviews.llvm.org/D74091
Some of the existing utils in utils/UnitTest/Test.h have been moved to
this new library.
Reviewers: abrachet, gchatelet
Tags: #libc-project
Differential Revision: https://reviews.llvm.org/D73530
Summary: LibcUnitTest is missing a dependency on LLVMSupport. This prevents building with shared libraries.
Reviewers: sivachandra
Subscribers: mgorny, MaskRay, libc-commits
Tags: #libc-project
Differential Revision: https://reviews.llvm.org/D73337