Commit Graph

93 Commits

Author SHA1 Message Date
Siva Chandra Reddy c08af2c11a [libc][NFC] Cleanup dependencies in src/signal and test/src/signal.
Reviewers: abrachet

Differential Revision: https://reviews.llvm.org/D78585
2020-04-21 22:25:01 -07:00
Siva Chandra Reddy 7f12512db2 [libc][Take 2] Propagate entrypoint deps to downstream targets.
This reverts commit a8086ba4ac.
Setting couple of target properties to an empty string was missed in the
previous commit.
2020-04-21 10:29:09 -07:00
Siva Chandra Reddy a8086ba4ac [libc] Revert "Propagate entrypoint deps to downstream targets."
This reverts commit 20cb440ea2 as the
target llvmlibc seems to be failing on the bots.
2020-04-21 10:10:18 -07:00
Siva Chandra Reddy 20cb440ea2 [libc] Propagate entrypoint deps to downstream targets.
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
2020-04-21 09:58:55 -07:00
Siva Chandra Reddy 8c2e66226f [libc] [NFC] Split the CMake rules into multiple files.
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
2020-04-21 09:24:17 -07:00
Alex Brachet 5793c84925 [libc] Add write(2) implementation for Linux and FDReader test utility
Summary: Adds `write` for Linux and FDReader utility which should be useful for some stdio tests as well.

Reviewers: sivachandra, PaulkaToast

Reviewed By: sivachandra

Subscribers: mgorny, tschuett, libc-commits

Differential Revision: https://reviews.llvm.org/D78184
2020-04-17 13:21:05 -04:00
Alex Brachet d9e96b6a02 [libc] Add spec/*.td as dependencies to add_gen_header
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
2020-04-17 13:10:46 -04:00
Siva Chandra Reddy a127d61835 [libc] Disable AOR ulp tests for sinf, cosf and sincosf.
They seemed to fallback to the system libc and start depending on its
accuracy.
2020-04-17 09:01:44 -07:00
Alex Brachet 91c10f50f3 Use proper dependency name for libc.include.stdio 2020-04-17 05:10:22 -04:00
Paula Toth 741d3c2016 [libc] Add cmake target for linting libc.
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
2020-04-16 17:41:03 -07:00
Siva Chandra Reddy 5fedf7f420 [libc] Move implementations of cosf, sinf, sincosf to src/math directory.
NFC intended in the implementaton. Only mechanical changes to fit the LLVM
libc implementation standard have been done.

Math testing infrastructure has been added. This infrastructure compares the
results produced by the libc with the high precision results from MPFR.
Tests making use of this infrastructure have been added for cosf, sinf and
sincosf.

Reviewers: abrachet, phosek

Differential Revision: https://reviews.llvm.org/D76825
2020-04-16 08:46:10 -07:00
Alex Brachet 99aea57928 [libc] Add very basic stdio FILE and fwrite
Summary:
This patch adds a very basic `FILE` type and basic `fwrite`.

It also removes `snprintf` from `StdIO`'s function spec because `VarArgType` was causing the generation to fail.

Reviewers: sivachandra, PaulkaToast

Reviewed By: sivachandra

Subscribers: mgorny, MaskRay, tschuett, libc-commits

Differential Revision: https://reviews.llvm.org/D77626
2020-04-14 04:02:27 -04:00
Alex Brachet 54d13b5b2d [libc] Remove <functional> dependency in syscall_test.cpp
Summary: Create self contained functional header which has a type similar to `std::function`

Reviewers: sivachandra, PaulkaToast

Reviewed By: sivachandra

Subscribers: mgorny, tschuett, libc-commits

Differential Revision: https://reviews.llvm.org/D77948
2020-04-14 03:27:10 -04:00
Siva Chandra Reddy e4767a6f14 [libc] Add fully-qualified target names.
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
2020-04-10 18:01:52 -07:00
Paula Toth be54ea52f1 [libc] Change minimum cmake requirement.
Summary: As per this thread: http://lists.llvm.org/pipermail/llvm-dev/2020-April/140744.html, changed the minimum requirement to reflect the decision made to upgrade to cmake 3.13.4.

Reviewers: sivachandra

Reviewed By: sivachandra

Subscribers: mgorny, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D77781
2020-04-09 20:42:55 -07:00
Siva Chandra Reddy 939fa1b560 [libc] Collect objects only from visible deps of an object library.
A typo in an earlier change allowed this check to be missed.

Reviewers: abrachet

Differential Revision: https://reviews.llvm.org/D77256
2020-04-09 10:40:37 -07:00
Paula Toth 66d00feb18 [libc][NFC] Make all top of file comments consistent.
Summary:
Made all header files consistent based of this documentation: https://llvm.org/docs/CodingStandards.html#file-headers.
And did the same for all source files top of file comments.

Reviewers: sivachandra, abrachet

Reviewed By: sivachandra, abrachet

Subscribers: MaskRay, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D77533
2020-04-08 10:18:37 -07:00
Kazuaki Ishizaki 0570de73c4 [libc] NFC: Fix trivial typo in comments, documents, and messages
Differential Revision: https://reviews.llvm.org/D77462
2020-04-06 16:19:34 +09:00
Paula Toth 90eb7be6a1 [libc] Fix memcpy to adhere to qualified calls.
Summary: Switched to using the new memcpy implementation.

Reviewers: sivachandra, abrachet, gchatelet

Reviewed By: abrachet, gchatelet

Subscribers: mgorny, MaskRay, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D77277
2020-04-03 15:27:57 -07:00
Paula Toth 1fcfd30fae [libc] Add strlen implementation.
Summary: This should fix the call to a non internal libc function.

Reviewers: sivachandra, abrachet

Reviewed By: sivachandra

Subscribers: xbolva00, mgorny, MaskRay, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D77279
2020-04-03 15:11:35 -07:00
Alex Brachet 123a5328f9 [libc] Add sigfillset and sigdelset
Summary: Add's `sigfillset` and `sigdelset` which will be used in D76676.

Reviewers: sivachandra, PaulkaToast

Reviewed By: sivachandra

Subscribers: mgorny, MaskRay, tschuett, libc-commits

Differential Revision: https://reviews.llvm.org/D76936
2020-04-01 15:07:49 -04:00
Alex Brachet 6a4f8423ae [libc] Only use __has_builtin on clang
The preprocessor reads the whole line even if the first condition of an and is false so this broke when compiling on older gcc versions which don't recognize `__has_builtin`
2020-03-28 12:28:43 -04:00
Siva Chandra Reddy 51b899c846 [libc] Extend add_object rule to handle helper object libraries.
The rule is now called add_object_library.

Reviewers: abrachet

Differential Revision: https://reviews.llvm.org/D76826
2020-03-28 00:07:46 -07:00
Alex Brachet 255e634bf7 [libc][NFC] Ensure internal implementation is in __llvm_libc namespace
Summary: In preparation for D76818.

Reviewers: PaulkaToast, sivachandra, gchatelet

Reviewed By: PaulkaToast, sivachandra

Subscribers: MaskRay, tschuett, libc-commits

Differential Revision: https://reviews.llvm.org/D76967
2020-03-28 02:59:42 -04:00
Siva Chandra Reddy 911f2e7dc4 [libc] Add a GNU extensions spec containing sincosf from math.h.
Reviewers: abrachet

Differential Revision: https://reviews.llvm.org/D76783
2020-03-25 15:13:22 -07:00
Siva Chandra Reddy f6ccb4fef2 [libc] Add a simple x86_64 linux loader.
This adds a very simple loader. This will be extended to a full loader
in future patches. A utility rule to add unittests has been added to
serve us while we are building out the full loader.

Reviewers: abrachet, phosek

Differential Revision: https://reviews.llvm.org/D76412
2020-03-25 10:12:35 -07:00
Siva Chandra Reddy 2c080a3f23 [libc] Generate math.h instead of the static file it is currently.
Just enough to help a follow up patch adding cosf and sinf has been
added.

Reviewers: abrachet

Differential Revision: https://reviews.llvm.org/D76723
2020-03-24 21:17:55 -07:00
Paula Toth dab219eedd [libc] Enable llvmlibc clang-tidy checks
Summary:
Add  clang-tidy for llvm-libc source directory.

Example of check in action:
```
/workspace/llvm-project/libc/src/string/strcpy.cpp:10:1: error: system include stdio.h not allowed [llvmlibc-restrict-system-libc-headers,-warnings-as-errors]
#include <stdio.h>
^~~~~~~~~~~~~~~~~~
```

Reviewers: sivachandra, abrachet

Reviewed By: sivachandra, abrachet

Subscribers: aheejin, MaskRay, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D76559
2020-03-23 20:34:39 -07:00
Alex Brachet a1762f9ceb [libc] Don't configure test and fuzzer when -DLLVM_INCLUDE_TESTS=OFF
Summary:  Fixes problem reported in D74397#1935863

Reviewers: nathanchance, gchatelet, sivachandra, MaskRay

Reviewed By: sivachandra, MaskRay

Subscribers: mgorny, MaskRay, tschuett

Differential Revision: https://reviews.llvm.org/D76577
2020-03-23 01:50:16 -04:00
Alex Brachet 0e1e9b9a81 [libc][NFC] Fix typo in milliseconds 2020-03-22 15:11:22 -04:00
Alex Brachet ca04d0c8fd [libc] Add signal
Summary:
This patch adds a Linux implementation for `signal`
It also fixes `ASSERT|EXPECT_THAT` macros

Reviewers: sivachandra, PaulkaToast, MaskRay

Reviewed By: sivachandra

Subscribers: mgorny, tschuett, libc-commits

Differential Revision: https://reviews.llvm.org/D76536
2020-03-22 14:15:47 -04:00
Siva Chandra Reddy 25294708f5 [libc] NFC - Move the round redirector from its own nested directory.
We have moved away from directories for entrypoints but this function
was not moved out.

Submitting as obvious.
2020-03-20 12:15:27 -07:00
Siva Chandra Reddy 4e8830830e [libc] Add a missing deps to the linux syscalls target.
Submitted as obvious.
2020-03-18 12:48:53 -07:00
Guillaume Chatelet 04a309dd0b [libc] Adding memcpy implementation for x86_64
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
2020-03-18 17:43:21 +01:00
Alex Brachet 4d35055635 [libc] Add sigaction
Summary: This patch adds `sigaction` and the `sa_restorer` signal trampoline function `__restore_rt`

Reviewers: sivachandra, MaskRay, PaulkaToast

Reviewed By: sivachandra

Subscribers: gchatelet, mgorny, tschuett, libc-commits

Differential Revision: https://reviews.llvm.org/D75802
2020-03-18 01:08:59 -04:00
Paula Toth a9e05d5711 [libc] Add AOR testing dependencies for buildbot workers.
Summary: These dependencies are needed for testing on the buildbots until we migrate AORs into libc.

Reviewers: sivachandra

Reviewed By: sivachandra

Subscribers: MaskRay, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D76330
2020-03-17 17:43:55 -07:00
Paula Toth 17566573b2 [libc] Resolve race condition in sub-process test runner.
Summary:
There seems to be a race condition between the pipe closing and the child process death. Likely these two events are not atomic on some versions of linux.

With the removal of `WNOHANG` we eliminate the race condition, however if the child closes the pipe intentionally then it could result in the test runner hanging. I find this situation less likely, where as I experience failures locally with this race condition rather consistently.

Reviewers: sivachandra, abrachet

Reviewed By: sivachandra, abrachet

Subscribers: MaskRay, jfb, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D76267
2020-03-17 13:00:00 -07:00
Siva Chandra Reddy 768ead0a6c [libc] Add a new rule `add_object`.
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
2020-03-17 12:33:36 -07:00
Siva Chandra Reddy 78d622a48c [libc] Add a README.md file to the AOR directory.
Also, add config.mk file which will help test the implementations in the
"math" directory for x86_64 with a simple "make check".
2020-03-16 12:29:24 -07:00
Kristof Beyls 0928368f62 [libc] Provide Arm Optimized Routines for the LLVM libc project.
This adds the Arm Optimized Routines (see
https://github.com/ARM-software/optimized-routines) source code under the
the LLVM license. The version of the code provided in this patch is v20.02
of the Arm Optimized Routines project.

This entire contribution is being committed as is even though it does
not currently fit the LLVM libc model and does not follow the LLVM
coding style. In the near future, implementations from this patch will be
moved over to their right place in the LLVM-libc tree. This will be done
over many small patches, all of which will go through the normal LLVM code
review process. See this libc-dev post for the plan:
http://lists.llvm.org/pipermail/libc-dev/2020-March/000044.html

Differential revision of the original upload: https://reviews.llvm.org/D75355
2020-03-16 12:19:31 -07:00
Alex Brachet af0b0e00fb [libc] [UnitTest] Add timeout to death tests
Summary:
This patch adds a timeout of 500ms to death tests. As we add multithreaded code and locks, deadlocks become more likely so timeout will be useful.

Additionally:
 - Better error handling in `invokeSubprocess`
 - Makes `ProcessStatus`'s methods const

Reviewers: sivachandra, MaskRay, gchatelet, PaulkaToast

Reviewed By: sivachandra, PaulkaToast

Subscribers: tschuett, libc-commits

Differential Revision: https://reviews.llvm.org/D75651
2020-03-11 23:57:20 -04:00
Alex Brachet b47c9f535c [libc] Add initial assert definition
Summary: This patch adds a temporary `__assert_fail` and `assert` definition to make it available to internal llvm libc code. `__assert_fail` writes to fd 2 directly instead of `stderr`, using SYS_write. I have not put it in its own linux directory because this is temporary and it should be using stdio's api in the future. It does not currently print out the line number (although we could do that by stringifying `__LINE__` if reviewers wish).

Reviewers: sivachandra, gchatelet, PaulkaToast

Reviewed By: sivachandra

Subscribers: mgorny, MaskRay, tschuett, libc-commits

Differential Revision: https://reviews.llvm.org/D75420
2020-03-11 23:45:58 -04:00
Paula Toth 270b528c7c [libc] Add docker container for llvm-libc buildbot worker.
Summary: Created a docker container to provide transparency and easy changes to the llvm-libc buildbot intfra.

Reviewers: sivachandra

Reviewed By: sivachandra

Subscribers: MaskRay, tschuett, libc-commits

Tags: #libc-project

Differential Revision: https://reviews.llvm.org/D75596
2020-03-11 17:35:41 -07:00
Siva Chandra Reddy 550be40515 [libc] Add simple implementations of mtx_lock and mtx_unlock.
These functions only support locking and unlocking of plain mutexes.
They will be extended in future changes to handled recursive and timed
mutexes.

Reviewers: phosek

Differential Revision: https://reviews.llvm.org/D74653
2020-03-09 21:56:02 -07:00
Siva Chandra Reddy fd8c133613 [libc] Take 2: Add linux implementations of thrd_create and thrd_join functions.
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
2020-03-09 21:28:11 -07:00
Alex Brachet 129c8b8081 add extern "C" to __errno_location's definition if in __cplusplus file 2020-03-09 03:10:59 -04:00
Alex Brachet 1348ca4046 [libc] [NFC] Use matchers in tests
Summary:
Use `EXPECT_THAT` where possible in tests NFC intended.

Added a `void *` template instantiation of `StreamWrapper::operator<<`

Reviewers: sivachandra, PaulkaToast

Reviewed By: sivachandra

Subscribers: MaskRay, tschuett, libc-commits

Differential Revision: https://reviews.llvm.org/D75717
2020-03-07 22:56:03 -05:00
Siva Chandra Reddy 3c88489a06 [libc]Revert "Add linux implementations of thrd_create and thrd_join functions."
This reverts commit abc040e953 as the bots
are failing because of this.
2020-03-05 20:46:13 -08:00
Alex Brachet 1962bc1dfb [libc] [UnitTest] Add Matchers
Summary: This patch adds gtest-like matchers and `EXPECT|ASSERT_THAT` macros. It also adds matchers `Succeeds` and `Fails` and has examples using these in test/src/signal/sigaddset_test.cpp.

Reviewers: sivachandra, gchatelet, PaulkaToast

Reviewed By: sivachandra, PaulkaToast

Subscribers: mgorny, MaskRay, tschuett, libc-commits

Differential Revision: https://reviews.llvm.org/D75487
2020-03-05 18:36:11 -05:00
Siva Chandra Reddy abc040e953 [libc] Add linux implementations of thrd_create and thrd_join functions.
Reviewers: abrachet, phosek

Differential Revision: https://reviews.llvm.org/D75380
2020-03-05 13:53:17 -08:00