207 Commits

Author SHA1 Message Date
Frederik Harwath
d6fae7f921
Reapply "[Clang] Take libstdc++ into account during GCC detection" #145056 (#154487)
The Generic_GCC::GCCInstallationDetector class picks the GCC installation directory with the largest version number. Since the location of the libstdc++ include directories is tied to the GCC version, this can break C++ compilation if the libstdc++ headers for this particular GCC version are not available. Linux distributions tend to package the libstdc++ headers separately from GCC. This frequently leads to situations in which a newer version of GCC gets installed as a dependency of another package without installing the corresponding libstdc++ package. Clang then fails to compile C++ code because it cannot find the libstdc++ headers. Since libstdc++ headers are in fact installed on the system, the GCC installation continues to work, the user may not be aware of the details of the GCC detection, and the compiler does not recognize the situation and emit a warning, this behavior can be hard to understand - as witnessed by many related bug reports over the years.

The goal of this work is to change the GCC detection to prefer GCC installations that contain libstdc++ include directories over those which do not. This should happen regardless of the input language since picking different GCC installations for a build that mixes C and C++ might lead to incompatibilities.
Any change to the GCC installation detection will probably have a negative impact on some users. For instance, for a C user who relies on using the GCC installation with the largest version number, it might become necessary to use the --gcc-install-dir option to ensure that this GCC version is selected.
This seems like an acceptable trade-off given that the situation for users who do not have any special demands on the particular GCC installation directory would be improved significantly.
 
This patch does not yet change the automatic GCC installation directory choice. Instead, it does introduce a warning that informs the user about the future change if the chosen GCC installation directory differs from the one that would be chosen if the libstdc++ headers are taken into account.

See also this related Discourse discussion: https://discourse.llvm.org/t/rfc-take-libstdc-into-account-during-gcc-detection/86992.

This patch reapplies #145056. The test in the original PR did not specify a target in the clang RUN line and used a wrong way of piping to FileCheck.
2025-08-22 07:39:11 +02:00
Frederik Harwath
f1e56ac032
Revert "[Clang] Take libstdc++ into account during GCC detection" (#154368)
Reverts llvm/llvm-project#145056
2025-08-19 16:35:58 +00:00
Frederik Harwath
50a3368f22
[Clang] Take libstdc++ into account during GCC detection (#145056)
The Generic_GCC::GCCInstallationDetector class picks the GCC
installation directory with the largest version number. Since the
location of the libstdc++ include directories is tied to the GCC
version, this can break C++ compilation if the libstdc++ headers for
this particular GCC version are not available. Linux distributions tend
to package the libstdc++ headers separately from GCC. This frequently
leads to situations in which a newer version of GCC gets installed as a
dependency of another package without installing the corresponding
libstdc++ package. Clang then fails to compile C++ code because it
cannot find the libstdc++ headers. Since libstdc++ headers are in fact
installed on the system, the GCC installation continues to work, the
user may not be aware of the details of the GCC detection, and the
compiler does not recognize the situation and emit a warning, this
behavior can be hard to understand - as witnessed by many related bug
reports over the years.

The goal of this work is to change the GCC detection to prefer GCC
installations that contain libstdc++ include directories over those
which do not. This should happen regardless of the input language since
picking different GCC installations for a build that mixes C and C++
might lead to incompatibilities.
Any change to the GCC installation detection will probably have a
negative impact on some users. For instance, for a C user who relies on
using the GCC installation with the largest version number, it might
become necessary to use the --gcc-install-dir option to ensure that this
GCC version is selected.
This seems like an acceptable trade-off given that the situation for
users who do not have any special demands on the particular GCC
installation directory would be improved significantly.
 
This patch does not yet change the automatic GCC installation directory
choice. Instead, it does introduce a warning that informs the user about
the future change if the chosen GCC installation directory differs from
the one that would be chosen if the libstdc++ headers are taken into
account.

See also this related Discourse discussion:
https://discourse.llvm.org/t/rfc-take-libstdc-into-account-during-gcc-detection/86992.
2025-08-19 16:55:45 +02:00
Siu Chi Chan
7e8f1f5f72
[HIP] Remove dots in HIP runtime path (#143792)
Remove the dots in the HIP path before passing to the rpath flag
2025-06-19 14:23:23 +00:00
Cameron McInally
a42bb8b57a
[Driver] Move CommonArgs to a location visible by the Frontend Drivers (#142800)
This patch moves the CommonArgs utilities into a location visible by the
Frontend Drivers, so that the Frontend Drivers may share option parsing
code with the Compiler Driver. This is useful when the Frontend Drivers
would like to verify that their incoming options are well-formed and
also not reinvent the option parsing wheel.

We already see code in the Clang/Flang Drivers that is parsing and
verifying its incoming options. E.g. OPT_ffp_contract. This option is
parsed in the Compiler Driver, Clang Driver, and Flang Driver, all with
slightly different parsing code. It would be nice if the Frontend
Drivers were not required to duplicate this Compiler Driver code. That
way there is no/low maintenance burden on keeping all these parsing
functions in sync.

Along those lines, the Frontend Drivers will now have a useful mechanism
to verify their incoming options are well-formed. Currently, the
Frontend Drivers trust that the Compiler Driver is not passing back junk
in some cases. The Language Drivers may even accept junk with no error
at all. E.g.:

  `clang -cc1 -mprefer-vector-width=junk test.c'

With this patch, we'll now be able to tighten up incomming options to
the Frontend drivers in a lightweight way.

---------

Co-authored-by: Cameron McInally <cmcinally@nvidia.com>
Co-authored-by: Shafik Yaghmour <shafik.yaghmour@intel.com>
2025-06-06 17:59:24 -04:00
Kazu Hirata
6c37341943
[Driver] Remove unused includes (NFC) (#141448)
These are identified by misc-include-cleaner.  I've filtered out those
that break builds.  Also, I'm staying away from llvm-config.h,
config.h, and Compiler.h, which likely cause platform- or
compiler-specific build failures.
2025-05-26 09:13:36 -07:00
Fangrui Song
0b84d72c52
[Driver] Replace /usr/lib/../$OSLibDir with /usr/$OSLibDir (#128428)
The latter is simpler and generalizes the OpenEmbedded special case
introduced in https://reviews.llvm.org/D48862
(they have /usr/lib64 but not /usr/lib)
2025-02-23 10:53:49 -08:00
AdityaK
2a51a0d39a
Remove reference to android-mips (#124021) 2025-01-22 23:30:04 -08:00
Sharjeel Khan
fdfe7e7fab
[Driver] Error when using msan on Android (#122540)
Msan is not supported on Android as mentioned in google/sanitizers#1381.
We proactively give the warning saying it is unsupported to fix
android/ndk#1958.
2025-01-12 17:36:00 +08:00
Michael Toguchi
d00f65c6ac
[Driver][SYCL] Add initial SYCL offload compilation support (#117268)
Introduces the SYCL based toolchain and initial toolchain construction
when using the '-fsycl' option. This option will enable SYCL based
offloading, creating a SPIR-V based IR file packaged into the compiled
host object.

This includes early support for creating the host/device object using
the new offloading model. The device object is created using the
spir64-unknown-unknown target triple.

New/Updated Options:
 -fsycl  Enables SYCL offloading for host and device
 -fsycl-device-only
         Enables device only compilation for SYCL
 -fsycl-host-only
         Enables host only compilation for SYCL

RFC Reference:
https://discourse.llvm.org/t/rfc-sycl-driver-enhancements/74092

This is a reland of: https://github.com/llvm/llvm-project/pull/107493
2025-01-06 11:52:46 -05:00
Florian Hahn
c135f6ffe2
[TySan] Add initial Type Sanitizer support to Clang) (#76260)
This patch introduces the Clang components of type sanitizer: a
sanitizer for type-based aliasing violations.

It is based on Hal Finkel's https://reviews.llvm.org/D32198.

The Clang changes are mostly formulaic, the one specific change being
that when the TBAA sanitizer is enabled, TBAA is always generated, even
at -O0.

It goes together with the corresponding LLVM changes
(https://github.com/llvm/llvm-project/pull/76259) and compiler-rt
changes (https://github.com/llvm/llvm-project/pull/76261)

PR: https://github.com/llvm/llvm-project/pull/76260
2024-12-17 15:13:42 +00:00
AdityaK
004e75ef17
Pack relocations for Android API >= 28 (#117624)
Patch copied from:
https://github.com/android/ndk/issues/909#issuecomment-649872696
Fixes: https://github.com/android/ndk/issues/909
2024-12-04 13:53:47 -08:00
Aaron Ballman
62c3c1cad7
Revert "[Driver][SYCL] Add initial SYCL offload compilation support" (#116381)
Reverts llvm/llvm-project#107493

Failing bots include:
https://lab.llvm.org/buildbot/#/builders/190/builds/9546
https://lab.llvm.org/buildbot/#/builders/46/builds/7938
2024-11-15 08:04:59 -05:00
Michael Toguchi
0b0d61101f
[Driver][SYCL] Add initial SYCL offload compilation support (#107493)
Introduces the SYCL based toolchain and initial toolchain construction
when using the '-fsycl' option. This option will enable SYCL based
offloading, creating a SPIR-V based IR file packaged into the compiled
host object.

This includes early support for creating the host/device object using
the new offloading model. The device object is created using the
spir64-unknown-unknown target triple.

New/Updated Options:
 -fsycl  Enables SYCL offloading for host and device
 -fsycl-device-only
         Enables device only compilation for SYCL
 -fsycl-host-only
         Enables host only compilation for SYCL

RFC Reference:
https://discourse.llvm.org/t/rfc-sycl-driver-enhancements/74092
2024-11-15 07:14:21 -05:00
Michał Górny
387b37af1a
[LLVM] [Clang] Support for Gentoo *t64 triples (64-bit time_t ABIs) (#111302)
Gentoo is planning to introduce a `*t64` suffix for triples that will be
used by 32-bit platforms that use 64-bit `time_t`. Add support for
parsing and accepting these triples, and while at it make clang
automatically enable the necessary glibc feature macros when this suffix
is used.

An open question is whether we can backport this to LLVM 19.x. After
all, adding new triplets to Triple sounds like an ABI change — though I
suppose we can minimize the risk of breaking something if we move new
enum values to the very end.
2024-10-14 11:18:04 +00:00
Alex Rønne Petersen
72a218056d
[llvm][Triple] Add Environment members and parsing for glibc/musl parity. (#107664)
This adds support for:

* `muslabin32` (MIPS N32)
* `muslabi64` (MIPS N64)
* `muslf32` (LoongArch ILP32F/LP64F)
* `muslsf` (LoongArch ILP32S/LP64S)

As we start adding glibc/musl cross-compilation support for these
targets in Zig, it would make our life easier if LLVM recognized these
triples. I'm hoping this'll be uncontroversial since the same has
already been done for `musleabi`, `musleabihf`, and `muslx32`.

I intentionally left out a musl equivalent of `gnuf64` (LoongArch
ILP32D/LP64D); my understanding is that Loongson ultimately settled on
simply `gnu` for this much more common case, so there doesn't *seem* to
be a particularly compelling reason to add a `muslf64` that's basically
deprecated on arrival.

Note: I don't have commit access.
2024-09-20 08:53:03 +08:00
Chris Apple
f77e8f765e
[clang][rtsan] Reland realtime sanitizer codegen and driver (#102622)
This reverts commit a1e9b7e646b76bf844e8a9a101ebd27de11992ff
This relands commit d010ec6af8162a8ae4e42d2cac5282f83db0ce07

No modifications from the original patch. It was determined that the
ubsan build failure was happening even after the revert, some examples:

https://lab.llvm.org/buildbot/#/builders/159/builds/4477 
https://lab.llvm.org/buildbot/#/builders/159/builds/4478 
https://lab.llvm.org/buildbot/#/builders/159/builds/4479
2024-08-23 08:16:52 -07:00
Chris Apple
a1e9b7e646
Revert "[clang][rtsan] Introduce realtime sanitizer codegen and drive… (#105744)
…r (#102622)"

This reverts commit d010ec6af8162a8ae4e42d2cac5282f83db0ce07.

Build failure: https://lab.llvm.org/buildbot/#/builders/159/builds/4466
2024-08-22 15:19:41 -07:00
Chris Apple
d010ec6af8
[clang][rtsan] Introduce realtime sanitizer codegen and driver (#102622)
Introduce the `-fsanitize=realtime` flag in clang driver

Plug in the RealtimeSanitizer PassManager pass in Codegen, and attribute
a function based on if it has the `[[clang::nonblocking]]` function
effect.
2024-08-22 14:08:24 -07:00
Daniil Kovalev
146fd7cd45
[PAC][Driver] Support pauthtest ABI for AArch64 Linux triples (#97237)
When `pauthtest` is either passed as environment part of AArch64 Linux
triple
or passed via `-mabi=`, enable the following ptrauth flags:

- `intrinsics`;
- `calls`;
- `returns`;
- `auth-traps`;
- `vtable-pointer-address-discrimination`;
- `vtable-pointer-type-discrimination`;
- `init-fini`.

Some related stuff is still subject to change, and the ABI itself might
be changed, so end users are not expected to use this and the ABI name
has 'test' suffix.

If `-mabi=pauthtest` option is used, it's normalized to effective
triple.

When the environment part of the effective triple is `pauthtest`, try
to use `aarch64-linux-pauthtest` as multilib directory.

The following is not supported:
- combination of `pauthtest` ABI with any branch protection scheme
except BTI;
- explicit set of environment part of the triple to a value different
  from `pauthtest` in combination with `-mabi=pauthtest`;
- usage on non-Linux OS.

---------

Co-authored-by: Anatoly Trosinenko <atrosinenko@accesssoftek.com>
2024-07-22 21:18:39 +03:00
Pengcheng Wang
4468c3dd53
[NFC][RISCV] Simplify the dynamic linker construction logic
The format of dynamic linker is `ld-linux-{arch}-{abi}.so.1`, so
we can just get the arch name from arch type.

Reviewers: asb, kito-cheng, MaskRay

Reviewed By: MaskRay

Pull Request: https://github.com/llvm/llvm-project/pull/97383
2024-07-02 14:41:17 +08:00
Alexander Shaposhnikov
c638ba1997
[Clang][Sanitizers] Enable NSAN on X86_64 only (#95885)
This is a follow-up to https://github.com/llvm/llvm-project/pull/93783.
The current set of patches covers only x86_64,
therefore we should not enable this flag on arm64 yet.
2024-06-18 16:17:32 -07:00
NMiehlbradt
1b66306c9c
[KMSAN] Enable on PowerPC64 (#73611)
Enable -fsanitize=kernel-memory support in Clang.

Add tests.

---------

Co-authored-by: Nicholas Miehlbradt <nicholas@linux.ibm.com>
2024-06-12 13:32:39 +08:00
Alexander Shaposhnikov
48f8130a49
[Clang][Sanitizers] Add numerical sanitizer (#93783)
Add plumbing for the numerical sanitizer on Clang's side.
2024-06-10 22:14:26 -07:00
Joshua Cranmer
63ecd2a725
Disable FTZ/DAZ when compiling shared libraries by default. (#80475)
This fixes https://github.com/llvm/llvm-project/issues/57589, and aligns
Clang with the behavior of current versions of gcc. There is a new
option, -mdaz-ftz, to control the linking of the file that sets FTZ/DAZ
on startup, and this flag is on by default if -ffast-math is present and
-shared isn't.

This also partially reverts fa7cd549d60 in that it disables the attempt
to set the IR denormal-fp-math attribute based on whether or not
-ffast-math is applied as it is insufficiently reliable.
2024-04-25 13:57:32 -04:00
Kalesh Singh
2620ccc3cd
ANDROID: x86_64: Set default max-page-size to 16kB (#87413)
Android now supports both 4kB and 16kB page sizes. The vast majority of
android apps are developed on x86_64 machines. In order to provide
emulators that support larger page sizes, Android emulates the page-size
in x86_64 to support testing apps for large page size support.

For this reason, update Android x86_64 ELFs default max-page-size to
16384 to support both 4kB and 16kB page-size devices.

Increase max-page-size raises concerns of increased disk space and extra
VMA slab memory.

In Android, RO partitions use sparse images, so that the holes on ELFs
don't allocate blocks on disk; and PackageManager ensures to punch holes
in ELF-paddings on the /data partition when apps are installed.

Extra VMA slab memory is addressed by the bionic loader, which extends
segment VMAs to cover the gaps between consecutive segment mappings, to
avoid the extra VMAs needed for the gap PROT_NONE mappings (---p). This
optimization is done in the crt_pad_segment note [1] is present in the
ELF.

[1]
189e480390:bionic/libc/arch-common/bionic/crt_pad_segment.S

---------

Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Co-authored-by: Kalesh Singh <kaleshsingh@google.com>
2024-04-12 10:43:59 -07:00
Fangrui Song
2b5cd8be3a [Driver] Remove InstallDir and getInstalledDir. NFC
Follow-up to #80527.
2024-03-03 18:10:46 -08:00
Kalesh Singh
856ce495e5
ANDROID: AArch64: Change default max-page-size from 4k to 16k (#70251)
File size increase were found negligible from sparseness and zero
block compression in f2fs and ext4 (supported filesystems for
Android's userdata partition).

Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Co-authored-by: Kalesh Singh <kaleshsingh@google.com>
2024-02-29 10:06:25 -08:00
Martin Storsjö
65a56a29b6
[clang] [Driver] Treat MuslEABIHF as a hardfloat environment wrt multiarch directories (#77536)
If using multiarch directories with musl, the multiarch directory still
uses *-linux-gnu triples - which may or may not be intentional, while it
is somewhat consistent at least.

However, for musl armhf targets, make sure that this also picks
arm-linux-gnueabihf, rather than arm-linux-gnueabi.
2024-01-10 11:27:46 +02: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
Haowei Wu
531233d4b0 Revert "add support for riscv64"
This reverts commit cd0a8245b0feb951569eb3d396a1ff629daeb55c, 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
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
Michael Platings
edc1130c0a [Driver] Enable selecting multiple multilibs
This will enable layering multilibs on top of each other.
For example a multilib containing only a no-exceptions libc++ could be
layered on top of a multilib containing C libs. This avoids the need
to duplicate the C library for every libc++ variant.

This change doesn't expose the functionality externally, it only opens
the functionality up to be potentially used by ToolChain classes.

Differential Revision: https://reviews.llvm.org/D143059
2023-06-14 06:46:41 +01:00
Florian Mayer
a2684acfb6 [HWASan] use hwasan linker for Android 14+
This will allow to compile binaries that use hwasan to run on a
non-HWASan system image.

Reviewed By: pcc

Differential Revision: https://reviews.llvm.org/D151388
2023-05-26 14:25:46 -07:00
Fangrui Song
4aa1cadf3c [Driver] Disable -fsanitize=function for ppc64be after D148573
ELFObjectWriter.cpp may report
```
error: Cannot represent a difference across sections
```
on some ppc64be configurations, likely related to some interaction
between the obsoleted ELFv1 and MC.
Unfortunately I cannot reproduce this locally with --target=powerpc64-linux-gnu.
2023-05-21 09:14:40 -07:00
Fangrui Song
67cbe1b859 Allow -fsanitize=function on all targets
Functions instrumented with -fsanitize=function have two words before
the function label: a signature and a RTTI proxy.
Instrumented call sites check the signature first to skip checks
for uninstrumented callees.

The code is generic and works for all targets supporting C++ RTTI.
Change clangDriver to allow all targets. Add tests for Armv8.5
Branch Target Identification and `-fpatchable-function-entry=`.

Reviewed By: peter.smith

Differential Revision: https://reviews.llvm.org/D148573
2023-05-19 07:59:37 -07:00
Ilya Leoshkevich
a3e56a8792 [KMSAN] Enable on SystemZ
Enable -fsanitize=kernel-memory support in Clang.

The x86_64 ABI requires that shadow_origin_ptr_t must be returned via a
register pair, and the s390x ABI requires that it must be returned via
memory pointed to by a hidden parameter. Normally Clang takes care of
the ABI, but the sanitizers run long after it, so unfortunately they
have to duplicate the ABI logic.

Therefore add a special case for SystemZ and manually emit the
s390x-ABI-compliant calling sequences. Since it's only 2 architectures,
do not create a VarArgHelper-like abstraction layer.

The kernel functions are compiled with the "packed-stack" and
"use-soft-float" attributes. For the "packed-stack" functions, it's not
correct for copyRegSaveArea() to copy 160 bytes of shadow and origins,
since the save area is dynamically sized. Things are greatly simplified
by the fact that the vararg "use-soft-float" functions use precisely
56 bytes in order to save the argument registers to where va_arg() can
find them.

Make copyRegSaveArea() copy only 56 bytes in the "use-soft-float" case.
The "packed-stack" && !"use-soft-float" case has no practical uses at
the moment, so leave it for the future.

Add tests.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D148596
2023-04-27 13:44:54 +02:00
Louis Dionne
5084ba395e [clang] Remove workaround for old LLVM_ENABLE_PROJECTS=libcxx build
We don't support the LLVM_ENABLE_PROJECTS=libcxx build anymore (and have
not for over a year), so it should be fine to remove this workaround now.

Differential Revision: https://reviews.llvm.org/D148945
2023-04-24 16:44:05 -04:00
WANG Xuerui
61fee67cd7 [Clang][Driver] Handle LoongArch multiarch tuples
This follows v1.00 of the [[ https://loongson.github.io/LoongArch-Documentation/LoongArch-toolchain-conventions-EN.html | LoongArch Toolchain Conventions ]],
but notably with [[ https://github.com/loongson/LoongArch-Documentation/pull/80 | this patch ]]
applied (a proper version bump to v2.00 was not done, so it is
indistinguishable from the "original" but now incompatible v1.00
otherwise).

Only `loongarch64` is implemented in `Linux::getMultiarchTriple`
because support for LA32 and ILP32* ABIs are incomplete right now.

The Debian sysroot layout is based on Han Gao's recent porting effort,
specifically the ghcr.io/rabenda/beige:loong64-v23-preview-20230330
container image.

Reviewed By: SixWeining

Differential Revision: https://reviews.llvm.org/D142688
2023-04-24 15:18:59 +08:00
AdityaK
156d966ec4 Remove mips target triple for Android
Reviewers: enh, phosek, srhines, MaskRay

thanks to @enh for pointing these out.

Differential Revision: https://reviews.llvm.org/D146565
2023-03-23 13:52:38 -07: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
Yaxun (Sam) Liu
43c90f905a [HIP] Make --offload-add-rpath alias of -frtlib-add-rpath
HIP runtime is the language runtime of HIP. When users need
to specify rpath, they usually need to specify rpath for
both compiler-rt and HIP runtime. It seems redundant
to have separate options. Therefore make --offload-add-rpath
an alias to -frtlib-add-rpath.

Reviewed by: Fangrui Song, Artem Belevich

Differential Revision: https://reviews.llvm.org/D145393
2023-03-11 13:33:17 -05:00
serge-sans-paille
0ffaffcaac
Reapply 6fa2abf90886f18472c87bc9bffbcdf4f73c465e
Lazyly initialize uncommon toolchain detector

Cuda and rocm toolchain detectors are currently run unconditionally,
while their result may not be used at all. Make their initialization
lazy so that the discovery code is not run in common cases.

Reapplied since 77910ac374656319ff114ef251fda358d4aa166a landed and
fixes the test ordering issue.

Differential Revision: https://reviews.llvm.org/D142606
2023-02-06 16:44:11 +01:00
Jonas Hahnfeld
b5ee4f755f Revert "Lazyly initialize uncommon toolchain detector"
clang/test/Driver/rocm-detect.hip is failing for a number of
configurations, for example:

clang-x86_64-debian-fast
https://lab.llvm.org/buildbot/#/builders/109/builds/57270

clang-debian-cpp20
https://lab.llvm.org/buildbot/#/builders/249/builds/310

clang-with-lto-ubuntu
https://lab.llvm.org/buildbot/#/builders/124/builds/6693

This reverts commit 6fa2abf90886f18472c87bc9bffbcdf4f73c465e.
2023-02-06 15:39:33 +01:00
serge-sans-paille
6fa2abf908
Lazyly initialize uncommon toolchain detector
Cuda and rocm toolchain detectors are currently run unconditionally,
while their result may not be used at all. Make their initialization
lazy so that the discovery code is not run in common cases.

Differential Revision: https://reviews.llvm.org/D142606
2023-02-06 12:03:00 +01: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
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
b89b42b31c [tsan] Add tsan support for loongarch64
This patch enabled tsan for loongarch64 with 47-bit VMA layout. All
tests are passing.

Also adds assembly routines to enable setjmp/longjmp for loongarch64
on linux.

Reviewed By: dvyukov, SixWeining, #sanitizers

Differential Revision: https://reviews.llvm.org/D138489
2022-12-08 10:08:49 +08:00