Commit Graph

562 Commits

Author SHA1 Message Date
Saiyedul Islam
2084a07087 Revert "[compiler-rt] Allow running tests without installing first"
This reverts commit c91254db1d.

It was throwing error:
 g++: error: unrecognized command line option ‘-resource-dir=
2024-04-08 03:35:23 -04:00
Alexander Richardson
c91254db1d [compiler-rt] Allow running tests without installing first
Currently, the testsuite uses the default runtimes path to find the
runtimes libraries which may or may not match the just-built runtimes.
This change uses the `-resource-dir` flag for clang whenever
`COMPILER_RT_TEST_STANDALONE_BUILD_LIBS` is set to ensure that we are
actually testing the currently built libraries rather than the ones
bundled with `${COMPILER_RT_TEST_COMPILER}`.

The existing logic works fine when clang and compiler-rt share the same
build directory ``-DLLVM_ENABLE_PROJECTS=clang;compiler-rt`, but when
building compiler-rt separately we need to tell the compiler used for
the tests where it can find the just-built libraries.

This reduces the fixes check-all failures to one in my configuration:
```
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -G Ninja
-DCMAKE_C_COMPILER=$HOME/output/upstream-llvm/bin/clang
-DCMAKE_CXX_COMPILER=$HOME/output/upstream-llvm/bin/clang++
-DCOMPILER_RT_INCLUDE_TESTS=ON
-DLLVM_EXTERNAL_LIT=$HOME/build/upstream-llvm-project-build/bin/llvm-lit
-DLLVM_CMAKE_DIR=$HOME/output/upstream-llvm
-DCOMPILER_RT_DEBUG=OFF
-S $HOME/src/upstream-llvm-project/compiler-rt
-B $HOME/src/upstream-llvm-project/compiler-rt/cmake-build-all-sanitizers
```

Reviewed By: vitalybuka, delcypher, MaskRay

Pull Request: https://github.com/llvm/llvm-project/pull/83088
2024-04-07 09:50:06 -07:00
Alexander Richardson
6f9297fc4d [compiler-rt] Fix build race with COMPILER_RT_TEST_STANDALONE_BUILD_LIBS
Since this standalone build configuration uses the runtime libraries that
are being built just now, we need to ensure that e.g. the TSan unit tests
depend on the tsan runtime library. Also fix TSAN_DEPS being overridden
to not include the tsan runtime (commit .....).
This change fixes a build race seen in the CI checks for
TsanRtlTest-x86_64-Test in https://github.com/llvm/llvm-project/pull/83088.

Reviewed By: vitalybuka

Pull Request: https://github.com/llvm/llvm-project/pull/83650
2024-03-21 15:22:06 -07:00
Alexander Richardson
ba2dc2953c [compiler-rt] Don't check COMPILER_RT_STANDALONE_BUILD for test deps
With https://github.com/llvm/llvm-project/pull/83088, we now need the
runtimes to be built before running test if
COMPILER_RT_TEST_STANDALONE_BUILD_LIBS is true, since otherwise we
get failures running `ninja check-all` such as the following:
```
/usr/bin/ld: cannot find .../compiler-rt/cmake-build-all-sanitizers/lib/linux/libclang_rt.fuzzer-x86_64.a: No such file or directory
/usr/bin/ld: cannot find .../compiler-rt/cmake-build-all-sanitizers/lib/linux/libclang_rt.xray-x86_64.a: No such file or directory
/usr/bin/ld: cannot find .../compiler-rt/cmake-build-all-sanitizers/lib/linux/libclang_rt.xray-basic-x86_64.a: No such file or directory
/usr/bin/ld: cannot find .../compiler-rt/cmake-build-all-sanitizers/lib/linux/libclang_rt.xray-fdr-x86_64.a: No such file or directory
```

This is a follow-up to 058e9b03 which started removing these checks
and it should make it easier to stop forcing COMPILER_RT_STANDALONE_BUILD
for runtimes builds in the future.

Reviewed By: vitalybuka

Pull Request: https://github.com/llvm/llvm-project/pull/83651
2024-03-18 16:48:37 -07:00
Alex Richardson
80a9574d36 [compiler-rt] Unbreak GCC builds after bfa6444a33
GCC complains if we pass -Werror=format-security without -Wformat.
Reported at https://github.com/llvm/llvm-project/pull/83779#issuecomment-1985246797
2024-03-08 00:45:33 -08:00
rohit-rao
9faca1e401 [compiler-rt/darwin] Disable building sanitizers on platforms without fork(). (#83485)
The watchOS and tvOS sanitizers do not compile with publicly-available
SDKs, failing on calls such as fork() and posix_spawn(). Updating the
darwin_test_archs test program to include a call to fork() allows cmake
to exclude those platforms when compiling runtimes. This allows public
builds to enable watchOS/tvOS and compile builtins but not sanitizers.
2024-03-05 15:55:36 -05:00
Alex Richardson
07317bbc66 [compiler-rt] Build libfuzzer sources with the chosen C++ compiler
I was getting build failures due to missing <cstddef> when building the
libfuzzer tests. It turns out that the custom command was using
COMPILER_RT_TEST_COMPILER when building the source file rather than
the COMPILER_RT_TEST_CXX_COMPILER.

Pull Request: https://github.com/llvm/llvm-project/pull/83090
2024-03-01 19:11:39 -08:00
Mariusz Borsa
d9c3066a58 [Sanitizers][ABI] Build ASAN shim for arm64_32 arch (#81066)
Turns out this arch is needed by the ABI impls

rdar://121963634

Co-authored-by: Mariusz Borsa <m_borsa@apple.com>
2024-02-12 10:46:17 -08:00
Vitaly Buka
837503023a [sanitizer] Fix builds after #77991 2024-01-15 12:58:23 -08:00
Dimitry Andric
aad5c2f887 [cmake] Honor CMAKE_VERBOSE_MAKEFILE when building external projects (#75749)
When the top-level CMake invocation has `CMAKE_VERBOSE_MAKEFILE=ON`,
indicating the user wants to have verbose builds (i.e. all executed
commands explicitly echoed), some of the subprojects and runtimes (such
as compiler-rt, libcxx, etc) do not build in verbose mode. For example,
with Ninja:

```
[ 99% 6252/6308] cd /build/runtimes/builtins-bins && /usr/local/bin/cmake --build .
[  0% 6/308] Building C object CMakeFiles/clang_rt.builtins-i386.dir/absvti2.c.o
[  0% 7/308] Building C object CMakeFiles/clang_rt.builtins-i386.dir/absvdi2.c.o
[  0% 8/308] Building C object CMakeFiles/clang_rt.builtins-i386.dir/absvsi2.c.o
...
```

This is because `llvm_ExternalProject_Add()` and `add_custom_libcxx()`
use CMake's `ExternalProject_Add()` function to configure such
subproject builds, and do not pass through the `CMAKE_VERBOSE_MAKEFILE`
setting.

Similar to what is done in `clang/CMakeLists.txt`, add
`-DCMAKE_VERBOSE_MAKEFILE=ON` to the `ExternalProject_Add()` invocations
in `llvm_ExternalProject_Add()` and `add_custom_libcxx()`, whenever the
top-level CMake invocation had `CMAKE_VERBOSE_MAKEFILE` turned on.
2023-12-17 22:43:34 +01:00
Shoaib Meenai
1ad920f05e [compiler-rt] Pass CMAKE_TOOLCHAIN_FILE through to custom libc++ build
This can be used to configure runtimes builds (instead of setting flags
individually), and we need to pass it down to the custom libc++ build
for it to work correctly.
2023-11-06 11:27:47 -08:00
Ryan Prichard
3747cde5e8 [Fuzzer] Enable custom libc++ for Android (#70407)
The Android LLVM build system builds the arm64 fuzzer lib without
HWASan, but then applications that enable HWASan can generated an object
file with a HWASan-ified version of some libc++ symbols (e.g.
`std::__1::piecewise_construct`). The linker can choose the HWASan-ified
definition, but then it cannot resolve the relocation from
libclang_rt.fuzzer-aarch64-android.a to this symbol because the high
bits of the address are unexpectedly set. This produces an error:

```
relocation R_AARCH64_ADR_PREL_PG_HI21 out of range
```

Fix this problem by linking a custom isolated libc++ into Android's
fuzzer library.

We need to pass through ANDROID_NATIVE_API_LEVEL so that the libc++ for
32-bit Android (API < 24) uses LLVM_FORCE_SMALLFILE_FOR_ANDROID.
2023-11-02 14:07:39 -07:00
AdityaK
46cb8d9a32 [TSAN] add support for riscv64 (#68735)
Implements for sv39 and sv48 VMA layout.

Userspace only has access to the bottom half of vma range. The top half
is used by kernel. There is no dedicated vsyscall or heap segment.
PIE program is allocated to start at TASK_SIZE/3*2. Maximum ASLR is
ARCH_MMAP_RND_BITS_MAX+PAGE_SHIFT=24+12=36 Loader, vdso and other
libraries are allocated below stack from the top.

Also change RestoreAddr to use 4 bits to accommodate MappingRiscv64_48

Reviewed by: MaskRay, dvyukov, asb, StephenFan, luismarques, jrtc27,
hiraditya, vitalybuka

Differential Revision: https://reviews.llvm.org/D145214

D145214 was reverted because one file was missing in the latest commit.
Luckily the file was there in the previous commit, probably the author
missed uploading that file with latest commit.

Co-authored-by: Alex Fan <alex.fan.q@gmail.com>
2023-10-12 16:03:07 -07:00
Sander de Smalen
f445be9790 Reland "[compiler-rt][aarch64] Add SME ABI support routines." (#68875)
Resolved issue with green dragon build by fixing relocations for
MachO/Darwin which doesn't compile without @page/@pageoff directives.

Also silenced a warning about constructor(90) priority being < 101,
which is reserved for the implementation. In this case, we're compiling
the implementation so we should be able to use 90.

This reverts commit 072713add4.
2023-10-12 13:56:58 +00:00
Henrik G. Olsson
072713add4 Revert "[compiler-rt][aarch64] Add SME ABI support routines." (#68875)
This reverts commit 2b05fa8f0b. It caused build errors in compiler-rt.
2023-10-12 13:11:25 +02:00
Sander de Smalen
2b05fa8f0b [compiler-rt][aarch64] Add SME ABI support routines.
When compiling for SME and using the attributes to use PSTATE.ZA,
Clang will emit calls to SME ABI support routines to save and
restore ZA state.

Reviewed By: paulwalker-arm

Differential Revision: https://reviews.llvm.org/D154045
2023-10-12 07:47:16 +00:00
Haowei Wu
531233d4b0 Revert "add support for riscv64"
This reverts commit cd0a8245b0, which
breaks the build of compiler-rt for riscv64.
2023-10-06 14:56:16 -07:00
Alex Fan
cd0a8245b0 add support for riscv64
Implements for sv39 and sv48 VMA layout.

Userspace only has access to the bottom half of vma range. The top half is used by kernel.
There is no dedicated vsyscall or heap segment.
PIE program is allocated to start at TASK_SIZE/3*2. Maximum ASLR is ARCH_MMAP_RND_BITS_MAX+PAGE_SHIFT=24+12=36
Loader, vdso and other libraries are allocated below stack from the top.

Also change RestoreAddr to use 4 bits to accommodate MappingRiscv64_48

Reviewed by: MaskRay, dvyukov, asb, StephenFan, luismarques, jrtc27, hiraditya, vitalybuka

Differential Revision: https://reviews.llvm.org/D145214
2023-10-06 13:48:48 -07:00
Ami-zhang
adb555ea36 [CFI] Allow LoongArch (#67314)
Enable icall tests on loongarch64 and `check-cfi` all pass.
2023-09-28 15:40:42 +08:00
Kai Luo
f9546d8e1d [Orc][rtlib] Build orc runtime support for ppc64 only under Linux
We haven't supported JIT on AIX yet.

Fix AIX buildbot failure in https://lab.llvm.org/buildbot/#/builders/214/builds/8770.

Reviewed By: Jake-Egan

Differential Revision: https://reviews.llvm.org/D156921
2023-08-03 07:06:49 +08:00
Kai Luo
5cb2a78ac2 [Orc][PowerPC] Enable ELFNixPlatform support for ppc64le
Since jitlink for ppc64le is ready for general use, test cases in compiler-rt for ELFNixPlatform support can be enabled.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D156399
2023-08-02 02:20:59 +00:00
Youling Tang
9c2f792dce [fuzzer] Enable loongarch64
Enable fuzzer on loongarch64.

Reviewed By: SixWeining, xen0n, MaskRay

Differential Revision: https://reviews.llvm.org/D140601
2023-07-18 09:40:25 +08:00
Weining Lu
ef33d6cbfc [XRay] Add initial support for loongarch64
Only support patching FunctionEntry/FunctionExit/FunctionTailExit for now.

Reviewed By: MaskRay, xen0n
Co-Authored-By: zhanglimin <zhanglimin@loongson.cn>

Differential Revision: https://reviews.llvm.org/D140727
2023-07-14 09:27:13 +08:00
zhanglimin
cea3a89841 [profile] Enable loongarch64
Mark loongarch64 as supported for profile. All tests passed.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D154405
2023-07-06 11:06:54 +08:00
zhanglimin
280d163887 [dfsan] Support Linux loongarch64
Make minor changes to enable DFSAN and its tests on
loongarch64. And port Linux loongarch64 memory mappings
from msan.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D140690
2023-07-03 16:05:02 +08:00
zhanglimin
310a6f12b5 [MSan] Enable MSAN for loongarch64
This patch adds basic memory sanitizer support for loongarch64
with 47-bit VMA, which memory layout is based on x86_64.

The LLVM part of the LoongArch memory sanitizer implementation will
be done separately, which will fix failing tests in check-msan.
These failing tests fail with the following same error: "error in
backend: unsupported architecture".

Reviewed By: #sanitizers, vitalybuka, MaskRay

Differential Revision: https://reviews.llvm.org/D140528
2023-06-29 11:33:04 +08:00
Oleksii Lozovskyi
be1b2ac948 [compiler-rt][CMake] Multiarch build of XRay libraries
Instead of dumping all sources into RTXray object library with a weird
special case for x86, handle multiarch builds better. Build a separate
object library for each arch with its arch-specific sources, then link
in all those libraries.

This fixes the build on platforms that produce fat binaries, such as new
macOS which expects both x86_64 and aarch64 objects in the same library
since Apple Silicon is a thing.

This only enables building XRay support for Apple Silicon. It does not
actually work yet on macOS, neither on Intel nor on Apple Silicon CPUs.
Thus the tests are still disabled.

Reviewed By: MaskRay, phosek

Differential Revision: https://reviews.llvm.org/D153221
2023-06-22 18:41:07 -07:00
Roland McGrath
42564f97e8 [fuzzer][fuchsia] Support RISC-V
Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D153082
2023-06-16 11:39:32 -07:00
Mark de Wever
42478d1473 [compiler-rt] Removes CMake work-arounds.
CMake older than 3.20.0 is no longer supported.
This removes work-arounds for no longer supported versions.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D152102
2023-06-07 17:42:28 +02:00
Blue Gaston
6df9b06aa8 [Sanitizers][Darwin][ASanABI] Fix architecture config for ASan Abi
Moved setting supported architecture to parent cmake configuration files
so they can be read by both lib and test CMakeList.txt.

Fixed issue with check-asan-abi that did not filter for current host architecture
which caused x86_64 bots to run Arm64 tests.

Added x86_64 as a supported arch to the test cmake file.

rdar://110017569

Differential Revision: https://reviews.llvm.org/D151846
2023-06-01 14:11:47 -07:00
Eli Kobrin
80ed3c30fc [CMake][fuzzer] Add riscv64 to fuzzer supported arch list
I tried to build libFuzzer for RISC-V and succeeded. All the libFuzzer
targets were successfully built. I tested this on the small hello world code
with a few branches to check the instrumentation; all of them were covered by
libFuzzer on RISC-V arch. So I suppose it makes sense to enable libFuzzer
build for RISC-V.

Reviewed By: phosek, thetruestblue, MaskRay

Differential Revision: https://reviews.llvm.org/D147788
2023-05-11 18:33:44 -07:00
Hans Wennborg
55224bc55c Typo fix 2023-05-02 10:31:37 +02:00
Martin Storsjö
86339ef088 [compiler-rt] [test] Add an .exe suffix for unit test executables on MinGW
Previously, an .exe suffix was only added for MSVC configurations.

In practice, an .exe suffix is added implicitly by MinGW toolchains
if the output is a suffixless file name. However this can cause lots
of subtle build system confusion, when it's not generating the file it
expected.

Differential Revision: https://reviews.llvm.org/D149029
2023-04-25 21:09:05 +03:00
Butta
8f833f88ab [CMake] Don't set absolute paths as install runpaths on ELF platforms in llvm_setup_rpath()
If any LLVM subprojects are built separately, the LLVM build directory
LLVM_LIBRARY_DIR is added to both the build and install runpaths in
llvm_setup_rpath(), which is incorrect when installed. Separate the
build and install runpaths on ELF platforms and finally remove the
incorrect call to this function for compiler-rt, as previously attempted
in 21c008d5a5. That prior attempt was reverted in 959dbd1761, where it
was said to break the build on macOS and Windows, so I made sure to keep
those platforms the same.

Two examples of incorrect runpaths that are currently added, one from
the latest LLVM 16 toolchain for linux x86_64:

  > readelf -d clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/clang/16/lib/x86_64-unknown-linux-gnu/libclang_rt.*so | ag "File:|runpath"
  File: clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/clang/16/lib/x86_64-unknown-linux-gnu/libclang_rt.asan.so
  0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib:/tmp/llvm_release/final/Phase3/Release/llvmCore-16.0.0-final.obj/./lib]
  File: clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/clang/16/lib/x86_64-unknown-linux-gnu/libclang_rt.dyndd.so
  0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib:/tmp/llvm_release/final/Phase3/Release/llvmCore-16.0.0-final.obj/./lib]
  File: clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/clang/16/lib/x86_64-unknown-linux-gnu/libclang_rt.hwasan_aliases.so
  0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib:/tmp/llvm_release/final/Phase3/Release/llvmCore-16.0.0-final.obj/./lib]
  File: clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/clang/16/lib/x86_64-unknown-linux-gnu/libclang_rt.hwasan.so
  0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib:/tmp/llvm_release/final/Phase3/Release/llvmCore-16.0.0-final.obj/./lib]
  File: clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/clang/16/lib/x86_64-unknown-linux-gnu/libclang_rt.memprof.so
  0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib:/tmp/llvm_release/final/Phase3/Release/llvmCore-16.0.0-final.obj/./lib]
  File: clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/clang/16/lib/x86_64-unknown-linux-gnu/libclang_rt.scudo_standalone.so
  0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib:/tmp/llvm_release/final/Phase3/Release/llvmCore-16.0.0-final.obj/./lib]
  File: clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/clang/16/lib/x86_64-unknown-linux-gnu/libclang_rt.tsan.so
  0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib:/tmp/llvm_release/final/Phase3/Release/llvmCore-16.0.0-final.obj/./lib]
  File: clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/clang/16/lib/x86_64-unknown-linux-gnu/libclang_rt.ubsan_minimal.so
  0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib:/tmp/llvm_release/final/Phase3/Release/llvmCore-16.0.0-final.obj/./lib]
  File: clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/clang/16/lib/x86_64-unknown-linux-gnu/libclang_rt.ubsan_standalone.so
  0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib:/tmp/llvm_release/final/Phase3/Release/llvmCore-16.0.0-final.obj/./lib]

Another is in the Swift toolchain, which builds lldb separately:

  > readelf -d swift-5.9-DEVELOPMENT-SNAPSHOT-2023-03-24-a-ubuntu20.04/usr/{bin/lldb*,lib/liblldb.so}|ag "File:|runpath"
  File: swift-5.9-DEVELOPMENT-SNAPSHOT-2023-03-24-a-ubuntu20.04/usr/bin/lldb
  0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib:/home/build-user/build/buildbot_linux/llvm-linux-x86_64/./lib]
  File: swift-5.9-DEVELOPMENT-SNAPSHOT-2023-03-24-a-ubuntu20.04/usr/bin/lldb-argdumper
  0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib:/home/build-user/build/buildbot_linux/llvm-linux-x86_64/./lib]
  File: swift-5.9-DEVELOPMENT-SNAPSHOT-2023-03-24-a-ubuntu20.04/usr/bin/lldb-server
  0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib:/home/build-user/build/buildbot_linux/llvm-linux-x86_64/./lib]
  File: swift-5.9-DEVELOPMENT-SNAPSHOT-2023-03-24-a-ubuntu20.04/usr/lib/liblldb.so
  0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib:/home/build-user/build/buildbot_linux/llvm-linux-x86_64/./lib:/home/build-user/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux:$ORIGIN/../lib/swift/linux]

This patch should fix this problem of absolute paths from the build host
leaking out into the toolchain's runpaths.

Differential revision: https://reviews.llvm.org/D146918
2023-04-19 15:56:02 -07:00
Vitaly Buka
3fb4d45866 Revert "[cmake] Explicitly disable download step"
This does not help. The build is broken because compiler-rt-clear
deletes cmake generated files in STAMP_DIR/

This reverts commit da89ed99a1.
2023-04-19 15:14:35 -07:00
Vitaly Buka
da89ed99a1 [cmake] Explicitly disable download step
Fixes the following on cmake version 3.24.2:
'tools/clang/runtime/compiler-rt-stamps/compiler-rt-source_dirinfo.txt',
needed by 'tools/clang/runtime/compiler-rt-stamps/compiler-rt-download',
missing and no known rule to make it

Maybe related to https://cmake.org/cmake/help/latest/release/3.24.html#modules
2023-04-19 12:57:12 -07:00
David Spickett
0ecd4f6c55 [compiler-rt] Check for missing CMAKE_C_COMPILER_TARGET when using COMPILER_RT_DEFAULT_TARGET_ONLY
COMPILER_RT_DEFAULT_TARGET_ONLY is the goto workaround for building
only one of a multilib setup while still being able to autodetect the native target.
For example only building 64 bit libraries on Intel instead of 32 and 64 bit.
Which may fail without 32 bit compatibility libs installed.

As reported in https://discourse.llvm.org/t/configuring-compiler-rt-to-use-default-target-only-does-not-work/62727
this build config hasn't worked in a while.

It relies on a variable usually set during cross compliation,
though my testing shows you can set it in other scenarios too.
https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_TARGET.html

So the options you need to provide are:
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON -DCMAKE_C_COMPILER_TARGET="aarch64-unknown-linux-gnu"

And we should error if CMAKE_C_COMPILER_TARGET isn't set.

Reviewed By: glaubitz

Differential Revision: https://reviews.llvm.org/D147598
2023-04-06 12:55:48 +00:00
Nikita Popov
6afe972195 Revert "Reland "[compiler-rt] Drop -Werror in compiler flag checks""
This reverts commit cc90ca6f0f.

This still breaks the GCC build in the same way as the previous
version.
2023-04-03 12:06:01 +02:00
Sergei Barannikov
cc90ca6f0f Reland "[compiler-rt] Drop -Werror in compiler flag checks"
-Werror is redundant because CMake not only checks the
exit status, but also parses the output of try_compile.
-Wformat-security is a special case, because specifying it
without -Wformat causes gcc to emit a warning in a format
not recognized by CMake, which makes the check pass.
2023-04-03 12:00:16 +03:00
Colin Cross
1d30afdc2d [PATCH] Enable targeting riscv64-linux-android
Reviewers: ccross, asb, phosek, enh, srhines, hiraditya

Putting: https://android.googlesource.com/toolchain/llvm_android/+/refs/heads/master/patches/Enable-targeting-riscv64-linux-android.patch for review.

Differential Revision: https://reviews.llvm.org/D146560
2023-03-23 13:33:52 -07:00
Jun Sha (Joshua)
2538e55042 [Sanitizer] [Scudo] Add riscv64 support for scudo
Enable Scudo on RISCV64 on both clang side and compiler-rt side.

Reviewers: cryptoad, eugenis, vitalybuka, luismarques, hiraditya

Reviewed By: vitalybuka, luismarques
Differential Revision: https://reviews.llvm.org/D137397
2023-03-18 23:37:46 -07:00
usama hameed
e277d6adf8 [Sanitizers] Disable armv7* sanitizers slice for ios
rdar://104059106

Differential Revision: https://reviews.llvm.org/D145000
2023-03-02 21:08:33 +05:00
Tobias Hieta
8470430107 [NFC][compiler-rt] Shorten comment 2023-02-10 14:42:48 +01:00
Tobias Hieta
8ccde9368f [CMake][compiler-rt] Support clang-cl in CompilerRTMockLLVMCMakeConfig
clang-cl doesn't support -dumpmachine directly, so we need to
preface it with /clang: in order to get this probing function
to work.

This is needed in order to run cmake directly on the runtimes
directory.

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D143557
2023-02-10 14:32:46 +01:00
David Spickett
cd173cbd7c [clang][compiler-rt] Support LLVM_ENABLE_PER_TARGET_RUNTIME_DIR on Arm Linux and BSD
The orginal single folder layout produced libraries in the form:
lib/linux/<libname>-<archname>.a

That archname for Arm depended on whether you had hard or soft float.
This is sometimes shown as "arm" (soft) vs. "armhf" (hard).

If this is set in a triple we do it in the final portion, the ABI.
"gnueabi" for soft float, "gnueabihf" for hard float.

Meaning that the expected triple is:
arm-unknown-linux-gnueabihf
Not this:
armhf-unknown-linux-gnueabihf

For the per target layout I have decided to rely on the ABI portion
of the triple instead of the arch name used for the old layout
(doing that would produce the invalid triple above).

This means that building with triple:
armv8l-unknown-linux-gnueabihf
Will result in libraries in:
lib/arm-unknown-linux-gnueabihf/

And clang will now know to look for "arm" instead of "armv8l".
Meaning that we can share libraries between an armv8 and armv7 build
as we did with the previous layout. In addition to handling spelling
differences e.g. "armv8l" with an "l" on some Linux distros.

compiler-rt will autodetect that the "armhf" and/or "arm" architecture
can be built. We then replace the given triple's architecture with that.
Then if the triple's float ABI doesn't match, we change that. That new
triple is then used as the folder name.

If you select to build only the given triple, with COMPILER_RT_DEFAULT_TARGET_ONLY,
compiler-rt will not autodetect the architecture and for that I assume you
know what you're doing. In that case the library path will use the unomdified triple.

From what I can tell, this is how most large builds e.g Android and
Arm's Embedded Toolchain for llvm do things. I assume that big endian "armeb"
builds would end up doing this too.

Bare metal builds will not be using per target runtime dirs so they
remain as they were.

Depends on D139536

Reviewed By: MaskRay, phosek

Differential Revision: https://reviews.llvm.org/D140011
2023-01-31 09:49:56 +00:00
usama hameed
4729f6e03a [CompilerRT] Remove sanitizer support for i386 iossim
Summary:
This patch removes building sanitizers for i386 iossim. This is to reduce the toolchain size.
Reviewers:

Subscribers:
2023-01-17 14:37:06 -08:00
Youling Tang
3a58e11961 [lsan] Add lsan support for loongarch64
This patch enabled lsan for loongarch64 with 47-bit VMA layout.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D139686
2023-01-14 09:23:51 +08:00
Fangrui Song
7f7a56b9a1 [CMake] Remove unused ALL_SCUDO_SUPPORTED_ARCH after D138157 2022-12-30 18:23:55 -08:00
Alexey Baturo
2eac70c108 [RISC-V][HWASAN] Enable HWASAN for RISC-V architecture
Reviewed by: vitalybuka, kito-cheng

These changes will allow to use HWASAN with RISCV64 architecture.

The majority of existing tests are passing with a few exceptions(see below).
The tests were running on QEMU, since currently there're no hardware with support
for J-extension.

For this feature to work the system must support PR_{SET,GET}_TAGGED_ADDR_CTRL
syscall. For now this is only available for a patched Linux kernel and QEMU with
enabled experimental J-extension.

Results of running HWASAN lit tests for RISC-V:
```
  Unsupported      :  6
  Passed           : 79
  Expectedly Failed:  2
```

Tests are marked as expected to fail or unsupported either because of:
- android platform not being supported
- no support for legacy hwasan v1 mode
- test config explicitly uses aarch64 option
```
UNSUPPORTED: HWAddressSanitizer-riscv64 :: TestCases/abort-message-android.cpp
UNSUPPORTED: HWAddressSanitizer-riscv64 :: TestCases/cfi.cpp
UNSUPPORTED: HWAddressSanitizer-riscv64 :: TestCases/lto.c
UNSUPPORTED: HWAddressSanitizer-riscv64 :: TestCases/print-memory-usage-android.c
UNSUPPORTED: HWAddressSanitizer-riscv64 :: TestCases/register-dump-read.c
UNSUPPORTED: HWAddressSanitizer-riscv64 :: TestCases/try-catch.cpp
XFAIL: HWAddressSanitizer-riscv64 :: TestCases/stack-oob.c
XFAIL: HWAddressSanitizer-riscv64 :: TestCases/exported-tagged-global.c
```

Differential Revision: https://reviews.llvm.org/D131345
2022-12-14 17:29:05 +03:00
Youling Tang
97f370a0a3 [safestack] Enable loongarch64
Enable safestack on loongarch64.

Some test cases will fail on loongarch, it will be fixed in glibc,
Links: https://sourceware.org/pipermail/libc-alpha/2022-November/143641.html

Reviewed By: #sanitizers, SixWeining, vitalybuka

Differential Revision: https://reviews.llvm.org/D139494
2022-12-10 11:48:52 +08:00