aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Driver/ToolChain.cpp
AgeCommit message (Collapse)AuthorFilesLines
3 days[Clang] Wire up -fsanitize=alloc-token (#156839)Marco Elver1-1/+2
Wire up the `-fsanitize=alloc-token` command-line option, hooking up the `AllocToken` pass -- it provides allocation tokens to compatible runtime allocators, enabling different heap organization strategies, e.g. hardening schemes based on heap partitioning. The instrumentation rewrites standard allocation calls into variants that accept an additional `size_t token_id` argument. For example, calls to `malloc(size)` become `__alloc_token_malloc(size, token_id)`, and a C++ `new MyType` expression will call `__alloc_token__Znwm(size, token_id)`. Currently untyped allocation calls do not yet have `!alloc_token` metadata, and therefore receive the fallback token only. This will be fixed in subsequent changes through best-effort type-inference. One benefit of the instrumentation approach is that it can be applied transparently to large codebases, and scales in deployment as other sanitizers. Similarly to other sanitizers, instrumentation can selectively be controlled using `__attribute__((no_sanitize("alloc-token")))`. Support for sanitizer ignorelists to disable instrumentation for specific functions or source files is implemented. See clang/docs/AllocToken.rst for more usage instructions. Link: https://discourse.llvm.org/t/rfc-a-framework-for-allocator-partitioning-hints/87434 --- This change is part of the following series: 1. https://github.com/llvm/llvm-project/pull/160131 2. https://github.com/llvm/llvm-project/pull/156838 3. https://github.com/llvm/llvm-project/pull/162098 4. https://github.com/llvm/llvm-project/pull/162099 5. https://github.com/llvm/llvm-project/pull/156839 6. https://github.com/llvm/llvm-project/pull/156840 7. https://github.com/llvm/llvm-project/pull/156841 8. https://github.com/llvm/llvm-project/pull/156842
2025-09-09MC: Use Triple form of lookupTarget in more places (#157591)Matt Arsenault1-1/+3
2025-08-26[HLSL][DirectX] Add the Qdx-rootsignature-strip driver option (#154454)Finn Plummer1-0/+1
This pr adds the `Qstrip-rootsignature` as a `DXC` driver option. To do so, this pr introduces the `BinaryModifyJobClass` as an `Action` to modify a produced object file before its final output. Further, it registers `llvm-objcopy` as the tool to modify a produced `DXContainer` on the `HLSL` toolchain. This allows us to specify the `Qstrip-rootsignature` option to `clang-dxc` which will invoke `llvm-objcopy` with a `--remove-section=RTS0` argument to implement its functionality. Resolves: https://github.com/llvm/llvm-project/issues/150275.
2025-08-22Reapply "[Clang] Take libstdc++ into account during GCC detection" #145056 ↵Frederik Harwath1-7/+8
(#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-19Revert "[Clang] Take libstdc++ into account during GCC detection" (#154368)Frederik Harwath1-8/+7
Reverts llvm/llvm-project#145056
2025-08-19[Clang] Take libstdc++ into account during GCC detection (#145056)Frederik Harwath1-7/+8
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-06[Flang] Search flang_rt in clang_rt path (#151954)Michael Kruse1-8/+21
The clang/flang driver has two separate systems for find the location of clang_rt (simplified): * `getCompilerRTPath()`, e.g. `../lib/clang/22/lib/windows`, used when `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=0` * `getRuntimePath()`, e.g. `../lib/clang/22/lib/x86_64-pc-windows-msvc`, used when `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=1` To simplify the search path, Flang-RT normally assumes only `getRuntimePath()`, i.e. ignoring `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR` and always using the `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=1` mechanism. There is an exception for Apple Darwin triples where `getRuntimePath()` returns nothing. The flang-rt/compiler-rt CMake code for library location also ignores `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR` but uses the `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=0` path instead. Since only `getRuntimePath()` is automatically added to the linker command line, this patch explicitly adds `getCompilerRTPath()` to the path when linking flang_rt. Fixes #151031
2025-07-29[Clang][Cygwin] Enable few conditions that are shared with MinGW (#149637)jeremyd20191-1/+1
The Cygwin target is generally very similar to the MinGW target. The default auto-import behavior, the default calling convention, the `.dll.a` import library extension, the `__GXX_TYPEINFO_EQUALITY_INLINE` pre-define by `g++`, and the long double configuration. Co-authored-by: Mateusz Mikuła <oss@mateuszmikula.dev>
2025-07-29[Clang][Driver] Valid `-march` value is not mandatory in AArch64 multilib ↵Victor Campos1-3/+4
(#151103) If a user passed an invalid value to `-march`, an assertion failure happened in the AArch64 multilib logic. But an invalid `-march` value is an expected case that should be handled via error messages. This patch removes the requirement that the `-march` value must be valid.
2025-07-24[clang][Driver] Add a new member for CLANG_DEFAULT_LINKER to ↵parabola941-1/+1
clang::driver::Driver (NFC) (#149784) The default linker can be changed by a CMake variable CLANG_DEFAULT_LINKER, but it is shared in all toolchains. This patch intends to resolve this.
2025-07-23[HIP][Clang][Driver] Move BC preference logic into ROCm detection (#149294)Jakub Chlanda1-1/+2
This patch provides a single point for handling the logic behind choosing common bitcode libraries. The intention is that the users of ROCm installation detector will not have to rewrite options handling code each time the bitcode libraries are queried. This is not too distant from detectors for other architecture that encapsulate the similar decision making process, providing cleaner interface. The only flag left in `getCommonBitcodeLibs` (main point of entry) is `NeedsASanRT`, this is deliberate, as in order to calculate it we need to consult `ToolChain`.
2025-07-22[Clang][Driver][ARM] Forward `-Os` and `-Oz` as multilib flags (#149819)Victor Campos1-0/+25
Pass along `-Os` and `-Oz` as multilib flags under ARM and AArch64 so that they can be used as criteria for multilib selection.
2025-07-21[Clang] Rework creating offloading toolchains (#125556)Joseph Huber1-38/+0
Summary: This patch reworks how we create offloading toolchains. Previously we would handle this separately for all the different kinds. This patch instead changes this to use the target triple and the offloading kind to determine the proper toolchain. In the old case where the user only passes `--offload-arch` we instead infer the triple from the passed arguments. This is a pretty major overhaul but currently passes all the clang tests with only minor changes to error messages.
2025-07-18[Clang][Driver] Expose relocation model as multilib flags (#149132)Simon Tatham1-5/+35
If a multilib collection contains libraries built for different methods of accessing global data (via absolute address, or via a GOT in -fPIC style, or as an offset from a fixed register in Arm -frwpi style), then `multilib.yaml` will need to know which relocation model an application is using in order to select the right library. Even if a multilib collection only supports one relocation model, it's still useful for `multilib.yaml` to be able to tell if the user has selected the right one, so as to give a useful error message if they haven't, instead of silently selecting a library that won't work. In this commit we determine the PIC / ROPI / RWPI status using the existing logic in `ParsePICArgs`, and translate it back into a canonical set of multilib selection flags.
2025-07-04[Clang] Introduce `--offload-targets` for `-fopenmp-targets` (#146594)Joseph Huber1-1/+1
Summary: This patch is mostly an NFC that renames the existing `-fopenmp-targets` into `--offload-targets`. Doing this early to simplify a follow-up patch that will hopefully allow this syntax to be used more generically over the existing `--offload` syntax (which I think is mostly unmaintained now.). Following in the well-trodden path of trying to pull language specific offload options into generic ones, but right now this is still just OpenMP specific.
2025-06-06[Driver] Move CommonArgs to a location visible by the Frontend Drivers (#142800)Cameron McInally1-1/+1
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-02[clang][AIX] Fix -print-runtime-dir fallback on AIX (#141439)Jake Egan1-13/+10
If the runtime path is not found (by getTargetSubDirPath()), since per target runtime directory is enabled on AIX, we should fall back to the target subdirectory rather than the OS subdirectory.
2025-05-24[clang][AIX] Strip unknown environment component for per target runtime ↵Jake Egan1-0/+9
directory (#140850) Previously, when the triple is `powerpc-ibm-aix-unknown`, the driver fails to find subdirectory `lib/powerpc-ibm-aix`. This ensures the correct runtime path is found if the triple has the -unknown environment component attached.
2025-05-22[XRay] Fix argument parsing with offloading (#140748) (#141043)Sebastian Kreutzer1-4/+3
This PR addressed issue #140748 to support XRay instrumentation on the host side when using offloading. It makes the following changes: - Initializes `XRayArgs` using the processed toolchain arguments instead of the raw input. - Removes the current caching mechanism of `XRayArgs` in the `ToolChain` class, as this is error-prone and potential benefits are questionable. For reference, `SanitizierArgs`, which is constructed in a similar manner but is much more complex, does not use any caching. - Adds driver tests to verify that XRay flags are set correctly with offloading and `-Xarch_host`.
2025-05-21[clang] Avoid creating temporary instances of std::string (NFC) (#140988)Kazu Hirata1-2/+1
lookupTarget takes StringRef and internally creates an instance of std::string with the StringRef as part of constructing Triple, so we don't need to create temporary instances of std::string on our own.
2025-05-11[Driver] Use StringRef::substr instead of StringRef::slice (NFC) (#139455)Kazu Hirata1-1/+1
StringRef::substr is shorter here because we can rely on its default second parameter.
2025-05-08[clang][Darwin] Remove legacy framework search path logic in the frontend ↵Ian Anderson1-12/+28
(#138234) Move the Darwin framework search path logic from InitHeaderSearch::AddDefaultIncludePaths to DarwinClang::AddClangSystemIncludeArgs. Add a new -internal-iframework cc1 argument to support the tool chain adding these paths. Now that the tool chain is adding search paths via cc1 flag, they're only added if they exist, so the Preprocessor/cuda-macos-includes.cu test is no longer relevant. Change Driver/driverkit-path.c and Driver/darwin-subframeworks.c to do -### style testing similar to the darwin-header-search and darwin-embedded-search-paths tests. Rename darwin-subframeworks.c to darwin-framework-search-paths.c and have it test all framework search paths, not just SubFrameworks. Add a unit test to validate that the myriad of search path flags result in the expected search path list. Fixes https://github.com/llvm/llvm-project/issues/75638
2025-04-19[clang] Use llvm::unique (NFC) (#136469)Kazu Hirata1-1/+1
2025-04-13[driver] Generalize the code that adds the path of libflang_rt.runtime.a. ↵Daniel Chen1-5/+21
(#134362) The PR is to generalize the re-use of the `compilerRT` code of adding the path of `libflang_rt.runtime.a (so)` from AIX and LoP only to all platforms via a new function `addFlangRTLibPath`. It also added `-static-libflangrt` and `-shared-libflangrt` compiler options to allow users choosing which `flang-rt` to link to. It defaults to shared `flang-rt`, which is consistent with the linker behavior, except on AIX, it defaults to static. Also, PR #134320 exposed an issue in PR #131041 that the the overriding `addFortranRuntimeLibs` is missing the link to `libquadmath`. This PR also fixed that and restored the test case that PR #131041 broke.
2025-04-03[flang-rt] Pass the whole path of libflang_rt.runtime.a to linker on AIX and ↵Daniel Chen1-10/+66
LoP (#131041) This PR is to improve the driver code to build `flang-rt` path by re-using the logic and code of `compiler-rt`. 1. Moved `addFortranRuntimeLibraryPath` and `addFortranRuntimeLibs` to `ToolChain.h` and made them virtual so that they can be overridden if customization is needed. The current implementation of those two procedures is moved to `ToolChain.cpp` as the base implementation to default to. 2. Both AIX and PPCLinux now override `addFortranRuntimeLibs`. The overriding function of `addFortranRuntimeLibs` for both AIX and PPCLinux calls `getCompilerRTArgString` => `getCompilerRT` => `buildCompilerRTBasename` to get the path to `flang-rt`. This code handles `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR` setting. As shown in `PPCLinux.cpp`, `FT_static` is the default. If not found, it will search and build for `FT_shared`. To differentiate `flang-rt` from `clang-rt`, a boolean flag `IsFortran` is passed to the chain of functions in order to reach `buildCompilerRTBasename`.
2025-04-03[Clang][ARM] Ensure both -mno-unaligned-access and -munaligned-access are ↵Simi Pallipurath1-14/+8
passed to multilib selection logic (#134099) Previously, alignment option was passed to multilib selection logic only when -mno-unaligned-access was explicitly specified on the command line. Now this change ensure both -mno-unaligned-access and -munaligned-access are passed to the multilib selection logic, which now also considers the target architecture when determining alignment access policy.
2025-03-28[Driver] Enable LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON on AIX. (#132821)Daniel Chen1-12/+22
In the wake of discussion in PR #131200 and internal discussion after, we will add support for `LLVM_ENABLE_PER_TARGET_RUNTIME=ON` for AIX instead of disable it. I already reverted the change in PR #131200. The default value of the option is still OFF on AIX.
2025-03-13[InstrProf] Remove -forder-file-instrumentation (#130192)Ellis Hoag1-1/+0
2025-03-10[Clang][AArch64] Add support for SHF_AARCH64_PURECODE ELF section flag (2/3) ↵Csanád Hajdú1-1/+3
(#125688) Add support for the new SHF_AARCH64_PURECODE ELF section flag: https://github.com/ARM-software/abi-aa/pull/304 The general implementation follows the existing one for ARM targets. Simlarly to ARM targets, generating object files with the `SHF_AARCH64_PURECODE` flag set is enabled by the `-mexecute-only`/`-mpure-code` driver flag. Related PRs: * LLVM: https://github.com/llvm/llvm-project/pull/125687 * LLD: https://github.com/llvm/llvm-project/pull/125689
2025-03-07[DXC] Add `-metal` flag to DXC driver (#130173)Chris B1-0/+1
This adds a flag to the DXC driver to enable calling the metal shader converter if it is available to convert the final shader output for metal.
2025-02-21[z/OS] Add option to target older versions of LE on z/OS (#123399)Sean Perry1-4/+20
Add an option similar to the -qtarget option in XL to allow the user to say they want to be able to run the generated program on an older version of the LE environment. This option will do two things: - set the `__TARGET_LIBS` macro so the system headers exclude newer interfaces when targeting older environments - set the arch level to match the minimum arch level for that older version of LE. It doesn't happen right now since all of the supported LE versions have a the same minimum ach level. So the option doesn't change this yet. The user can specify three different kinds of arguments: 1. -mzos-target=zosv*V*r*R* - where V & R are the version and release 2. -mzos-target=0x4vrrmmmm - v, r, m, p are the hex values for the version, release, and modlevel 3. -mzos-target=current - uses the latest version of LE the system headers have support for
2025-02-06[Clang] Only allow `clang` arguments to `-Xarch` (#126101)Joseph Huber1-1/+2
Summary: Currently the `-Xarch` argument needs to re-parse the option, which goes through every single registered argument. This causes errors when trying to pass `-O1` through it because it thinks it's a DXC option. This patch changes the behavior to only allow `clang` options. Concievably we could detect the driver mode to make this more robust, but I don't know if there are other users for this. Fixes: https://github.com/llvm/llvm-project/issues/110325
2025-02-05[Clang] Make `-Xarch_` handling generic for all toolchains (#125421)Joseph Huber1-10/+32
Summary: Currently, `-Xarch_` is handled specially between different toolchains, (i.e. Mach-O). This patch unifies the handling so that it can be used generically. The main benefit here is that we now have a more generic version of `-Xopenmp-target=`, which should probably just be deprecated. Additionally, it allows us to specially pass arguments to different architectures for offloading. This patch is done in preparation for making selecting offloading toolchains more generic, this will be helpful while people are moving toward compile jobs that include multiple toolchains (SPIR-V, AMDGCN, NVPTX).
2025-01-30[Clang] Remove ARCMigrate (#119269)Sirraide1-1/+0
In the discussion around #116792, @rjmccall mentioned that ARCMigrate has been obsoleted and that we could go ahead and remove it from Clang, so this patch does just that.
2025-01-13[Multilib] Add -fmultilib-flag command-line option (#110658)Victor Campos1-0/+12
This patch is the second step to extend the current multilib system to support the selection of library variants which do not correspond to existing command-line options. Proposal can be found in https://discourse.llvm.org/t/rfc-multilib-custom-flags/81058 The multilib mechanism supports libraries that target code generation or language options such as --target, -mcpu, -mfpu, -mbranch-protection. However, some library variants are particular to features that do not correspond to any command-line options. Examples include variants for multithreading and semihosting. This work introduces a way to instruct the multilib system to consider these features in library selection. The driver must be informed about the multilib custom flags with a new command-line option. ``` -fmultilib-flag=C ``` Where the grammar for C is: ``` C -> option option -> multithreaded | no-multithreaded | io-none | io-semihosting | io-linux-syscalls | ... ``` There must be one option instance for each flag specified: ``` -fmultilib-flag=multithreaded -fmultilib-flag=io-semihosting ``` Contradictory options are untied by *last one wins*. These options are to be used exclusively by the multilib mechanism in the Clang driver. Hence they are not forwarded to the compiler frontend.
2025-01-06[Driver][SYCL] Add initial SYCL offload compilation support (#117268)Michael Toguchi1-0/+3
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
2024-12-06[Driver][OpenMP] Fix OpenMP target-toolchain-option parser (#115375)Jefferson Le Quellec1-2/+4
## Description This PR fixes a segmentation fault that occurs when passing options requiring arguments via `-Xopenmp-target=<triple>`. The issue was that the function `Driver::getOffloadArchs` did not properly parse the extracted option, but instead assumed it was valid, leading to a crash when incomplete arguments were provided. ## Backtrace ```sh llvm-project/build/bin/clang++ main.cpp -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target=powerpc64le-ibm-linux-gnu -o PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump: 0. Program arguments: llvm-project/build/bin/clang++ main.cpp -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target=powerpc64le-ibm-linux-gnu -o 1. Compilation construction 2. Building compilation actions #0 0x0000562fb21c363b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (llvm-project/build/bin/clang+++0x392f63b) #1 0x0000562fb21c0e3c SignalHandler(int) Signals.cpp:0:0 #2 0x00007fcbf6c81420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420) #3 0x0000562fb1fa5d70 llvm::opt::Option::matches(llvm::opt::OptSpecifier) const (llvm-project/build/bin/clang+++0x3711d70) #4 0x0000562fb2a78e7d clang::driver::Driver::getOffloadArchs(clang::driver::Compilation&, llvm::opt::DerivedArgList const&, clang::driver::Action::OffloadKind, clang::driver::ToolChain const*, bool) const (llvm-project/build/bin/clang+++0x41e4e7d) #5 0x0000562fb2a7a9aa clang::driver::Driver::BuildOffloadingActions(clang::driver::Compilation&, llvm::opt::DerivedArgList&, std::pair<clang::driver::types::ID, llvm::opt::Arg const*> const&, clang::driver::Action*) const (.part.1164) Driver.cpp:0:0 #6 0x0000562fb2a7c093 clang::driver::Driver::BuildActions(clang::driver::Compilation&, llvm::opt::DerivedArgList&, llvm::SmallVector<std::pair<clang::driver::types::ID, llvm::opt::Arg const*>, 16u> const&, llvm::SmallVector<clang::driver::Action*, 3u>&) const (llvm-project/build/bin/clang+++0x41e8093) #7 0x0000562fb2a8395d clang::driver::Driver::BuildCompilation(llvm::ArrayRef<char const*>) (llvm-project/build/bin/clang+++0x41ef95d) #8 0x0000562faf92684c clang_main(int, char**, llvm::ToolContext const&) (llvm-project/build/bin/clang+++0x109284c) #9 0x0000562faf826cc6 main (llvm-project/build/bin/clang+++0xf92cc6) #10 0x00007fcbf6699083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3 #11 0x0000562faf923a5e _start (llvm-project/build/bin/clang+++0x108fa5e) [1] 2628042 segmentation fault (core dumped) main.cpp -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -o ```
2024-11-15[Driver] Remove unused includes (NFC) (#116316)Kazu Hirata1-2/+0
Identified with misc-include-cleaner.
2024-11-15Revert "[Driver][SYCL] Add initial SYCL offload compilation support" (#116381)Aaron Ballman1-3/+0
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[Driver][SYCL] Add initial SYCL offload compilation support (#107493)Michael Toguchi1-0/+3
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-07Add -mno-unaligned-access and -mbig-endian to ARM and AArch64 multilib flags ↵simpal011-0/+28
(#114782) This adds -mno-unaligned-access and -mbig-endian command line options to the set of flags used by the multilib selection for ARM and AArch64 targets.
2024-11-05[clang][Driver][HIP] Add support for mixing AMDGCNSPIRV & concrete ↵Alex Voicu1-0/+6
`offload-arch`s. (#113509) This removes the temporary ban on mixing AMDGCN flavoured SPIR-V and concrete targets (e.g. `gfx900`) in the same HIPAMD compilation. This is done primarily by tweaking the effective / observable triple when the target is `amdgcnspirv`, which seamlessly composes with the existing infra. The test is stolen from #75357.
2024-10-31[InstrPGO] Avoid using global variable to fix potential data race (#114364)Lei Wang1-1/+3
In https://github.com/llvm/llvm-project/pull/109837, it sets a global variable(`PGOInstrumentColdFunctionOnly`) in PassBuilderPipelines.cpp which introduced a data race detected by TSan. To fix this, I decouple the flag setting, the flags are now set separately(`instrument-cold-function-only-path` is required to be used with `--pgo-instrument-cold-function-only`).
2024-10-31Revert "[InstrPGO] Support cold function coverage instrumentation (#109837)"Dmitry Chernenkov1-3/+1
This reverts commit e517cfc531886bf6ed64b4e7109bb3141ac7f430.
2024-10-30Pass the executable name as arg[0] when calling ExecuteAndWait() (#114067)Sean Perry1-2/+4
PR https://github.com/llvm/llvm-project/pull/111976 was enabling the tests updated in the PR to run on all systems. We found a few didn't run on z/OS. I tracked the problem down to: 1. the ExecuteToolChainProgram() function wasn't passing the executable name as the first arg. That was causing exec on z/OS to fail. 2. the temp file needs to be a text file so codepage conversion happens.
2024-10-28[InstrPGO] Support cold function coverage instrumentation (#109837)Lei Wang1-1/+3
This patch adds support for cold function coverage instrumentation based on sampling PGO counts. The major motivation is to detect dead functions for the services that are optimized with sampling PGO. If a function is covered by sampling profile count (e.g., those with an entry count > 0), we choose to skip instrumenting those functions, which significantly reduces the instrumentation overhead. More details about the implementation and flags: - Added a flag `--pgo-instrument-cold-function-only` in `PGOInstrumentation.cpp` as the main switch to control skipping the instrumentation. - Built the extra instrumentation passes(a bundle of passes in `addPGOInstrPasses`) under sampling PGO pipeline. This is controlled by `--instrument-cold-function-only-path` flag. - Added a driver flag `-fprofile-generate-cold-function-coverage`: - 1) Config the flags in one place, i,e. adding `--instrument-cold-function-only-path=<...>` and `--pgo-function-entry-coverage`. Note that the instrumentation file path is passed through `--instrument-sample-cold-function-path`, because we cannot use the `PGOOptions.ProfileFile` as it's already used by `-fprofile-sample-use=<...>`. - 2) makes linker to link `compiler_rt.profile` lib(see [ToolChain.cpp#L1125-L1131](https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/ToolChain.cpp#L1125-L1131) ). - Added a flag(`--pgo-cold-instrument-entry-threshold`) to config entry count to determine cold function. Overall, the full command is like: ``` clang++ -O2 -fprofile-generate-cold-function-coverage=<...> -fprofile-sample-use=<...> code.cc -o code ```
2024-10-10[flang][driver] rename flang-new to flang (#110023)Brad Richardson1-0/+3
This does a global rename from `flang-new` to `flang`. I also removed/changed any TODOs that I found related to making this change. --------- Co-authored-by: H. Vetinari <h.vetinari@gmx.com> Co-authored-by: Andrzej Warzynski <andrzej.warzynski@arm.com>
2024-10-04[AArch64] Pass -mabi option through to multilib (#110874)Oliver Stannard1-0/+5
Pass the -mabi option through to multilib, so that it can be used for library selection.
2024-09-04[Clang] Fix CLANG_TOOLCHAIN_PROGRAM_TIMEOUT logicJoel E. Denny1-1/+1
PR #102521, which landed as 1ea0865dd6fa, implemented `CLANG_TOOLCHAIN_PROGRAM_TIMEOUT`, but the logic is obviously wrong. If the user-specified value is negative, it should become zero to mean infinite. Otherwise, it should be left as is. Thus, use `std::max` not `std::min`. This obvious fixup doesn't seem worth another pull request.
2024-09-01[clang][AIX] Fix -print-runtime-dir on AIX (#104806)Jake Egan1-2/+2
Currently the option prints a path to a nonexistent directory with the full triple, `lib/powerpc64-ibm-aix7.2.0.0`. It should only be `lib/aix`.