aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Driver/ToolChain.cpp
AgeCommit message (Collapse)AuthorFilesLines
2024-08-29[Driver] Add -mbranch-protection to ARM and AArch64 multilib flags (#106391)Lucas Duarte Prates1-0/+12
This adds the `-mbranch-protection` command line option to the set of flags used by the multilib selection for ARM and AArch64 targets.
2024-08-20[Driver] Make ffp-model=fast honor non-finite-values, introduce ↵Andy Kaylor1-1/+1
ffp-model=aggressive (#100453) This change modifies -ffp-model=fast to select options that more closely match -funsafe-math-optimizations, and introduces a new model, -ffp-model=aggressive which matches the existing behavior (except for a minor change in the fp-contract behavior). The primary motivation for this change is to make -ffp-model=fast more user friendly, particularly in light of LLVM's aggressive optimizations when -fno-honor-nans and -fno-honor-infinites are used. This was previously proposed here: https://discourse.llvm.org/t/making-ffp-model-fast-more-user-friendly/78402
2024-08-16[RISCV] Allow YAML file to control multilib selection (#98856)R1-0/+19
This changes the bare-metal driver logic such that it _always_ tries multilib.yaml if it exists, and it falls back to the hardwired/default RISC-V multilib selection only if a multilib.yaml doesn't exist. In contrast, the current behavior is that RISC-V can never use multilib.yaml, but other targets will try it if it exists. The flags `-march=` and `-mabi=` are exposed for multilib.yaml to match on. There is no attempt to help YAML file creators to duplicate the existing hard-wired multilib reuse logic -- they will have to implement it using `Mappings`. This should be backwards-compatible with existing sysroots, as multilib.yaml was previously never used for RISC-V, and the behavior doesn't change after this PR if the file doesn't exist.
2024-08-09[Clang] Add env var for nvptx-arch/amdgpu-arch timeout (#102521)Joel E. Denny1-2/+12
When working on very busy systems, check-offload frequently fails many tests with this diagnostic: ``` clang: error: cannot determine amdgcn architecture: /tmp/llvm/build/bin/amdgpu-arch: Child timed out: ; consider passing it via '-march' ``` This patch accepts the environment variable `CLANG_TOOLCHAIN_PROGRAM_TIMEOUT` to set the timeout. It also increases the timeout from 10 to 60 seconds.
2024-08-07[ARM] Enable cfi-icall for thumb triples (#102126)Oliver Stannard1-1/+2
Support for this was added back in 2016 (https://reviews.llvm.org/D27499), but never enabled in the driver. Since then, it's been possible to enable this with an arm triple and the -mthumb option, but not with a thumb triple. This also caused -fsanitise=cfi to enable cfi-icall for arm triple but not thumb triples, which caused spurious sanitiser failures if mixing the two ISAs in one program.
2024-07-22[PAC][Driver] Support `pauthtest` ABI for AArch64 Linux triples (#97237)Daniil Kovalev1-2/+3
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-11[Clang][Driver] Skip empty strings in getAArch64MultilibFlags (#97827)Simon Tatham1-8/+12
In a multilib setting, if you compile with a command line such as `clang --target=aarch64-none-elf -march=armv8.9-a+rcpc3`, `getAArch64MultilibFlags` returns an ill-formed string containing two consecutive `+` signs, of the form `...+rcpc++rcpc3+...`, causing later stages of multilib selection to get confused. The `++` arises from the entry in `AArch64::Extensions` for the SubtargetFeature `rcpc-immo`, which is a dependency of the `rcpc3` SubtargetFeature, but doesn't have an _extension_ name for the purposes of the `-march=foo+bar` option. So its `UserVisibleName` field is the empty string. To fix this, I've excluded extensions from consideration in `getAArch64MultilibFlags` if they have an empty `UserVisibleName`. Since the input to this function is not derived from a completely general set of SubtargetFeatures, but from a set that has only just been converted _from_ a clang driver command line, the only extensions skipped by this check should be cases like this one, where the anonymous extension was only included because it was a dependency of one mentioned explicitly. I've also made the analogous change in `getARMMultilibFlags`. I don't think it's necessary right now, because the architecture extensions for ARM (defined in `ARMTargetParser.def` rather than Tablegen) don't include any anonymous ones. But it seems sensible to add the check anyway, in case future refactoring introduces anonymous array elements in the same way that AArch64 did, and also in case someone writes a function for another platform by using either of these as example code.
2024-07-01[Driver] Support using toolchain libc and libc++ for baremetal (#96736)Petr Hosek1-0/+6
We want to support using a complete Clang/LLVM toolchain that includes LLVM libc and libc++ for baremetal targets. To do so, we need the driver to add the necessary include paths.
2024-06-28Re-land: "[AArch64] Add ability to list extensions enabled for a target" ↵Lucas Duarte Prates1-4/+4
(#95805) (#96795) This introduces the new `--print-enabled-extensions` command line option to AArch64, which prints the list of extensions that are enabled for the target specified by the combination of `--target`/`-march`/`-mcpu` values. The goal of the this option is both to enable the manual inspection of the enabled extensions by users and to enhance the testability of architecture versions and CPU targets implemented in the compiler. As part of this change, a new field for `FEAT_*` architecture feature names was added to the TableGen entries. The output of the existing `--print-supported-extensions` option was updated accordingly to show these in a separate column.
2024-06-26Revert "[AArch64] Add ability to list extensions enabled for a target" (#96768)Lucas Duarte Prates1-4/+4
Reverts llvm/llvm-project#95805 due to test failures caught by the buildbots.
2024-06-26[AArch64] Add ability to list extensions enabled for a target (#95805)Lucas Duarte Prates1-4/+4
This introduces the new `--print-enabled-extensions` command line option to AArch64, which prints the list of extensions that are enabled for the target specified by the combination of `--target`/`-march`/`-mcpu` values. The goal of the this option is both to enable the manual inspection of the enabled extensions by users and to enhance the testability of architecture versions and CPU targets implemented in the compiler. As part of this change, a new field for `FEAT_*` architecture feature names was added to the TableGen entries. The output of the existing `--print-supported-extensions` option was updated accordingly to show these in a separate column.
2024-06-07[Clang] Add timeout for GPU detection utilities (#94751)Joseph Huber1-4/+4
Summary: The utilities `nvptx-arch` and `amdgpu-arch` are used to support `--offload-arch=native` among other utilities in clang. However, these rely on the GPU drivers to query the features. In certain cases these drivers can become locked up, which will lead to indefinate hangs on any compiler jobs running in the meantime. This patch adds a ten second timeout period for these utilities before it kills the job and errors out.
2024-04-29[Driver] Clean up denormal handling with fast-math-related options (#89477)Andy Kaylor1-4/+9
This change cleans up the clang driver handling of umbrella options like -ffast-math, -funsafe-math-optimizations, and -ffp-model, and aligns the behavior of -ffp-model=fast with -ffast-math with regard to the linking of crtfastmath.o. We agreed in a previous review that the fast-math options should not attempt to change the -fdenormal-fp-math option, which is inherently target-specific. The clang user's manual claims that -ffp-model=fast "behaves identically to specifying both -ffast-math and -ffp-contract=fast." Since -ffast-math causes crtfastmath.o to be linked if it is available, that should also happen with -ffp-model=fast. I am going to be proposing further changes to -ffp-model=fast, decoupling it from -ffast-math and introducing a new -ffp-model=aggressive that matches the current behavior, but I wanted to solidfy the current behavior before I do that.
2024-04-25Disable FTZ/DAZ when compiling shared libraries by default. (#80475)Joshua Cranmer1-2/+13
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-14[Driver] Ensure ToolChain::LibraryPaths is not empty for non-DarwinFangrui Song1-1/+7
Follow-up to #81037. ToolChain::LibraryPaths holds the new compiler-rt library directory (e.g. `/tmp/Debug/lib/clang/19/lib/x86_64-unknown-linux-gnu`). However, it might be empty when the directory does not exist (due to the `if (getVFS().exists(P))` change in https://reviews.llvm.org/D158475). If neither the old/new compiler-rt library directories exists, we would suggest the undesired old compiler-rt file name: ``` % /tmp/Debug/bin/clang++ a.cc -fsanitize=memory -o a ld.lld: error: cannot open /tmp/Debug/lib/clang/19/lib/linux/libclang_rt.msan-x86_64.a: No such file or directory clang++: error: linker command failed with exit code 1 (use -v to see invocation) ``` With this change, we will correctly suggest the new compiler-rt file name. Fix #87150 Pull Request: https://github.com/llvm/llvm-project/pull/87866
2024-04-10Revert "[Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin"Arthur Eubanks1-7/+1
This reverts commit ccdebbae4d77d3efc236af92c22941de5d437e01. Causes test failures in the presence of Android runtime libraries in resource-dir. See comments on https://github.com/llvm/llvm-project/pull/87866.
2024-04-08[Driver] Ensure ToolChain::LibraryPaths is not empty for non-DarwinFangrui Song1-1/+7
Follow-up to #81037. ToolChain::LibraryPaths holds the new compiler-rt library directory (e.g. `/tmp/Debug/lib/clang/19/lib/x86_64-unknown-linux-gnu`). However, it might be empty when the directory does not exist (due to the `if (getVFS().exists(P))` change in https://reviews.llvm.org/D158475). If neither the old/new compiler-rt library directories exists, we would suggest the undesired old compiler-rt file name: ``` % /tmp/Debug/bin/clang++ a.cc -fsanitize=memory -o a ld.lld: error: cannot open /tmp/Debug/lib/clang/19/lib/linux/libclang_rt.msan-x86_64.a: No such file or directory clang++: error: linker command failed with exit code 1 (use -v to see invocation) ``` With this change, we will correctly suggest the new compiler-rt file name. Fix #87150 Pull Request: https://github.com/llvm/llvm-project/pull/87866
2024-03-14Revert "[Driver] Default riscv*- triples to -fdebug-default-version=4" (#84119)Fangrui Song1-6/+0
This reverts commit bbc0f99f3bc96f1db16f649fc21dd18e5b0918f6 (https://reviews.llvm.org/D157663). With this change, `-g` for the next major release 19.1 will generate R_RISCV_SET_ULEB128/R_RISCV_SUB_ULEB128 relocations, which require lld>=18 or binutils>=2.41. binutils 2.41 is relatively new, but GCC has been producing R_RISCV_SET_ULEB128/R_RISCV_SUB_ULEB128 for some time now.
2024-02-26[Driver] Improve error when a compiler-rt library is not found (#81037)Fangrui Song1-4/+14
BSD, Linux, and z/OS enable `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR` by default. When a compiler-rt library is not found, we currently report an incorrect filename `libclang_rt.XXX-$arch.a` ``` % /tmp/Debug/bin/clang++ a.cc -fsanitize=address -o a ld.lld: error: cannot open /tmp/Debug/lib/clang/19/lib/linux/libclang_rt.asan-x86_64.a: No such file or directory clang++: error: linker command failed with exit code 1 (use -v to see invocation) ``` With this change, we will correctly report: ``` % /tmp/Debug/bin/clang++ a.cc -fsanitize=address -o a ld.lld: error: cannot open /tmp/Debug/lib/clang/19/lib/x86_64-unknown-linux-gnu/libclang_rt.asan.a: No such file or directory clang++: error: linker command failed with exit code 1 (use -v to see invocation) ``` Link: https://discourse.llvm.org/t/runtime-directory-fallback/76860
2024-02-26[clang][AArch64] multilib: fix deduction of "-march=" option (#81474)Dominik Wójt1-1/+6
The deduced "-march=" option always started with aarch64, which is not a valid value. There was also no way to distinguish between armv8-r and armv8-a. After this commit, the deduced "-march=" option will start with greatest available "armv*-a" value or "armv8-r".
2024-02-22Multilib support for libraries with exceptions (#75031)pwprzybyla1-1/+22
For better multilib matching explicitly match -fno-rtti and -fno-exceptions
2024-02-21[InstallAPI] Set InstallAPI as a standalone tool instead of CC1 action (#82293)Cyndy Ishida1-1/+0
Installapi has important distinctions when compared to the clang driver, so much that, it doesn't make much sense to try to integrate into it. This patch partially reverts the CC1 action & driver support to replace with its own driver as a clang tool. For distribution, we could use `LLVM_TOOL_LLVM_DRIVER_BUILD` mechanism for integrating the functionality into clang such that the toolchain size is less impacted.
2024-02-13 [clang][InstallAPI] Introduce basic driver to write out tbd files (#81571)Cyndy Ishida1-0/+1
This introduces a basic outline of installapi as a clang driver option. It captures relevant information as cc1 args, which are common arguments already passed to the linker to encode into TBD file outputs. This is effectively an upstream for what already exists as `tapi installapi` in Xcode toolchains, but directly in Clang. This patch does not handle any AST traversing on input yet. InstallAPI is broadly an operation that takes a series of header files that represent a single dynamic library and generates a TBD file out of it which represents all the linkable symbols and necessary attributes for statically linking in clients. It is the linkable object in all Apple SDKs and when building dylibs in Xcode. `clang -installapi` also will support verification where it compares all the information recorded for the TBD files against the already built binary, to catch possible mismatches like when a declaration is missing a definition for an exported symbol.
2024-01-19[Driver] Use SmallString::operator std::string (NFC)Kazu Hirata1-4/+4
2023-12-13[clang] Use StringRef::{starts,ends}_with (NFC) (#75149)Kazu Hirata1-2/+2
This patch replaces uses of StringRef::{starts,ends}with with StringRef::{starts,ends}_with for consistency with std::{string,string_view}::{starts,ends}_with in C++20. I'm planning to deprecate and eventually remove StringRef::{starts,ends}with.
2023-09-28[Driver] Support -fsanitize=cfi-icall on loongarch64 (#67310)Ami-zhang1-1/+2
2023-09-18[driver] Search for compatible Android runtime directoriesShoaib Meenai1-9/+46
Android triples include a version number, which makes direct triple comparisons for per-target runtime directory searching not always work. Instead, look for the triple with the highest compatible version number and use that per-target runtime directory instead. This maintains the existing fallback to a triple without any version number, but I'm hoping we can remove that in the future. https://discourse.llvm.org/t/62717 discusses this further. The one remaining triple mismatch after this is that Android armv7 triples usually have an environment of `androideabi`, which Clang normalizes to `android`. If you use the `androideabi` triple when building the runtimes with a per-target runtimes dir, the directory will get created with `androideabi` in its name, but Clang's triple search uses the normalized triple and will look for an `android` directory instead. https://reviews.llvm.org/D140925 will fix that by normalizing triples when creating the per-target runtimes directories as well. Reviewed By: phosek, pirama Differential Revision: https://reviews.llvm.org/D158476
2023-09-18[driver] Perform fallback target searches for stdlibShoaib Meenai1-12/+16
Searching for target-specific standard library header and library paths should perform fallback searches for targets, the same way searching for the runtime libraries does. It's important for the header and library searches to be consistent, otherwise we could end up using mismatched headers and libraries. (See also https://reviews.llvm.org/D146664.) Reviewed By: phosek Differential Revision: https://reviews.llvm.org/D159293
2023-08-29[OpenMP][DeviceRTL][AMDGPU] Support code object version 5Saiyedul Islam1-1/+4
Update DeviceRTL and the AMDGPU plugin to support code object version 5. Default is code object version 4. CodeGen for __builtin_amdgpu_workgroup_size generates code for cov4 as well as cov5 if -mcode-object-version=none is specified. DeviceRTL compilation passes this argument via Xclang option to generate abi-agnostic code. Generated code for the above builtin uses a clang control constant "llvm.amdgcn.abi.version" to branch on the abi version, which is available during linking of user's OpenMP code. Load of this constant gets eliminated during linking. AMDGPU plugin queries the ELF for code object version and then prepares various implicitargs accordingly. Differential Revision: https://reviews.llvm.org/D139730 Reviewed By: jhuber6, yaxunl
2023-08-28[driver] Refactor getRuntimePaths. NFCShoaib Meenai1-10/+15
This used to be getRuntimePath till https://reviews.llvm.org/D115049 added a fallback search path for Android. As far as I can tell, the intent has always been to use the first existing path though instead of actually supporting multiple runtime paths. We can move the existence checks into getRuntimePath and have it return std::optional, which also makes the `--print-runtime-dir` behavior much cleaner. The motivation is a follow-up change to Android runtime path searches, which is much nicer with this in place. Reviewed By: phosek, MaskRay Differential Revision: https://reviews.llvm.org/D158475
2023-08-14[Driver] Default riscv*- triples to -fdebug-default-version=4Fangrui Song1-0/+6
This adds a RISC-V special case to ToolChain::GetDefaultDwarfVersion, affecting Linux/Haiku/RISCVToolChain. DWARF v5 .debug_loclists/.debug_rnglists's DW_LLE_offset_pair/DW_RLE_offset_pair entry kinds utilitize `.uleb128 A-B` directives where A and B reference local labels in code sections. When A and B are separated by a RISC-V linker-relaxable instruction, A-B is incorrectly folded without a relocation, causing incorrect debug information. ``` void ext(void); int foo(int x) {ext(); return 0;} // DW_AT_location [DW_FORM_loclistx] of a DW_TAG_formal_parameter references a DW_LLE_offset_pair that can be incorrect after linker relaxation. int ext(void); void foo() { { int ret = ext(); if (__builtin_expect(ret, 0)) ext(); } } // DW_AT_ranges [DW_FORM_rnglistx] of a DW_TAG_lexical_block references a DW_RLE_offset_pair that can be incorrect after linker relaxation. ``` D157657 will implement R_RISCV_SET_ULEB128/R_RISCV_SUB_ULEB128 relocations, fixing the issue, but the relocation is only supported by bleeding-edge binutils 2.41 and not by lld/ELF yet. The goal is to make the emitted DWARF correct after linking. Many users don't care about the default DWARF version, but a linker error will be unacceptable. Let's just downgrade the default DWARF version, before binutils>=2.41 is more widely available. An alternative compatibility option is to add a toggle to DwarfDebug.cpp, but that doesn't seem like a good idea. Reviewed By: asb, kito-cheng Differential Revision: https://reviews.llvm.org/D157663
2023-07-08Add missing StringExtras.h includesElliot Goodrich1-0/+1
In preparation for removing the `#include "llvm/ADT/StringExtras.h"` from the header to source file of `llvm/Support/Error.h`, first add in all the missing includes that were previously included transitively through this header. This is fixing all files missed in b0abd4893fa1. Differential Revision: https://reviews.llvm.org/D154543
2023-06-16[Driver] Use DenseSet::contains (NFC)Kazu Hirata1-4/+4
2023-06-14[Driver] Enable selecting multiple multilibsMichael Platings1-1/+3
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[Driver] Enable multilib.yaml in the BareMetal ToolChainMichael Platings1-2/+2
The default location for multilib.yaml is lib/clang-runtimes, without any target-specific suffix. This will allow multilibs for different architectures to share a common include directory. To avoid breaking the arm-execute-only.c CHECK-NO-EXECUTE-ONLY-ASM test, add a ForMultilib argument to getARMTargetFeatures. Since the presence of multilib.yaml can change the exact location of a library, relax the baremetal.cpp test. Differential Revision: https://reviews.llvm.org/D142986
2023-06-14[Driver] Add -print-multi-flags-experimental optionMichael Platings1-0/+98
This option causes the flags used for selecting multilibs to be printed. This is an experimental feature that is documented in detail in D143587. Differential Revision: https://reviews.llvm.org/D142933
2023-06-04[AIX] use system assembler for assembly filesChen Zheng1-1/+2
Change to system assembler to compile assembly files even -fintegrated-as is specified. We don't have a good Clang as for now for assembly files on AIX. Reviewed By: qiucf Differential Revision: https://reviews.llvm.org/D148490
2023-05-19Allow -fsanitize=function on all targetsFangrui Song1-2/+1
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-04-05[Driver] Fix rpath for compiler-rtYaxun (Sam) Liu1-6/+16
The compiler-rt library path can be either {resource_dir}/lib/{triple} or {resource_dir}/lib/{OS}/{arch} depending on whether LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default is ON or OFF. Currently, the rpath added by -rtlib-add-rpath only adds the latter. This patch checks both and adds the one that exists. Reviewed by: Fangrui Song Differential Revision: https://reviews.llvm.org/D146686
2023-02-07[NFC][TargetParser] Remove llvm/ADT/Triple.hArchibald Elliott1-1/+1
I also ran `git clang-format` to get the headers in the right order for the new location, which has changed the order of other headers in two files.
2023-02-07[NFC][TargetParser] Remove llvm/Support/TargetParser.hArchibald Elliott1-1/+1
2023-02-01[HLSL] [Dirver] add dxv as a VerifyDebug JobXiang Li1-0/+1
New option --dxv-path is added for dxc mode to set the installation path for dxv. If cannot find dxv, a warning will be report. dxv will be executed with command line dxv file_name -o file_name. It will validate and sign the file and overwrite it. Differential Revision: https://reviews.llvm.org/D141705
2023-01-31[clang][compiler-rt] Support LLVM_ENABLE_PER_TARGET_RUNTIME_DIR on Arm Linux ↵David Spickett1-0/+21
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-17[OpenMP] Make `-Xarch_host` and `-Xarch_device` work for OpenMP offloadingJoseph Huber1-6/+6
Clang currently supports the `-Xarch_host` and `-Xarch_device` variants to handle passing arguments to only one part of the offloading toolchain. This was previously only supported fully for HIP / CUDA This patch simple updates the logic to make it work for any offloading kind. Fixes #59799 Reviewed By: tianshilei1992 Differential Revision: https://reviews.llvm.org/D141935
2023-01-11[CUDA][HIP] Add support for `--offload-arch=native` to CUDA and refactorJoseph Huber1-0/+33
This patch adds basic support for `--offload-arch=native` to CUDA. This is done using the `nvptx-arch` tool that was introduced previously. Some of the logic for handling executing these tools was factored into a common helper as well. This patch does not add support for OpenMP or the "new" driver. That will be done later. Reviewed By: yaxunl Differential Revision: https://reviews.llvm.org/D141051
2022-12-18Remove redundant .c_str() and .get() callsGregory Alfonso1-2/+2
Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D139485
2022-11-30[Driver] Only check -nostdinc++ for -stdlib++-isystemShoaib Meenai1-2/+9
A drive-by change in 53c98d85a8a609552448043d5512e70313b1eb1b made -stdlib++-isystem be suppressed by -nostdinc and -nostdlibinc in addition to -nostdinc++. However, that's contrary to the intent of the flag. It's common to provide your own C++ headers (e.g. when building libc++ by itself or as a compiler-rt dependency) but rely on the system C headers, and having -stdlib++-isystem only look at -nostdinc++ allows us to customize both the C header path (via -nostdinc or -nostdlibinc) and the C++ header path (via -stdlib++-isystem) at the toolchain level but still let users of the toolchain provide their own C++ headers. Add a comment explaining the rationale to make it clearer.
2022-11-22Add generic KCFI operand bundle loweringSami Tolvanen1-4/+1
The KCFI sanitizer emits "kcfi" operand bundles to indirect call instructions, which the LLVM back-end lowers into an architecture-specific type check with a known machine instruction sequence. Currently, KCFI operand bundle lowering is supported only on 64-bit X86 and AArch64 architectures. As a lightweight forward-edge CFI implementation that doesn't require LTO is also useful for non-Linux low-level targets on other machine architectures, add a generic KCFI operand bundle lowering pass that's only used when back-end lowering support is not available and allows -fsanitize=kcfi to be enabled in Clang on all architectures. This relands commit eb2a57ebc7aaad551af30462097a9e06c96db925 with fixes. Reviewed By: nickdesaulniers, MaskRay Differential Revision: https://reviews.llvm.org/D135411
2022-11-18[NFC] Remove unused codes after 4a7be42d922afChuanqi Xu1-1/+0
There are still some unused codes remained after 4a7be42d922af. And this patch tries to remove them.
2022-11-17Revert D135411 "Add generic KCFI operand bundle lowering"Fangrui Song1-1/+4
This reverts commit eb2a57ebc7aaad551af30462097a9e06c96db925. llvm/include/llvm/Transforms/Instrumentation/KCFI.h including llvm/CodeGen is a layering violation. We should use an approach where Instrumementation/ doesn't need to include CodeGen/. Sorry for not spotting this in the review.