aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Driver/Driver.cpp
AgeCommit message (Collapse)AuthorFilesLines
32 hours[WebAssembly] Support for new target `wasm32-linux-muslwali` (#162581)Arjun Ramesh1-0/+2
Add toolchain support for the [WALI](https://doc.rust-lang.org/rustc/platform-support/wasm32-wali-linux.html) target as per its corresponding [RFC](https://discourse.llvm.org/t/rfc-new-wasm-linux-target-support/88203)
13 days[clang][modules] Ensure -nostdlib causes no manifest to be reported (#161110)Naveen Seth Hanig1-0/+3
When -nostdlib is specified, Clang should not report any library‑provided module manifest, even if a manifest for the default standard library is present.
2025-08-26[HLSL][DirectX] Add the Qdx-rootsignature-strip driver option (#154454)Finn Plummer1-4/+17
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-23[clang] Remove redundant control flow statements (NFC) (#155138)Kazu Hirata1-1/+0
2025-08-18Reland [clang][modules-driver] Add scanner to detect C++20 module presence ↵Naveen Seth Hanig1-0/+67
(#153497) This patch is part of a series to support driver managed module builds for C++ named modules and Clang modules. This introduces a scanner that detects C++ named module usage early in the driver with only negligible overhead. For now, it is enabled only with the `-fmodules-driver` flag and serves solely diagnostic purposes. In the future, the scanner will be enabled for any (modules-driver compatible) compilation with two or more inputs, and will help the driver determine whether to implicitly enable the modules driver. Since the scanner adds very little overhead, we are also exploring enabling it for compilations with only a single input. This approach could allow us to detect `import std` usage in a single-file compilation, which would then activate the modules driver. For performance measurements on this, see https://github.com/naveen-seth/llvm-dev-cxx-modules-check-benchmark. RFC for driver managed module builds: https://discourse.llvm.org/t/rfc-modules-support-simple-c-20-modules-use-from-the-clang-driver-without-a-build-system This patch relands the reland (2d31fc8) for commit ded1426. The earlier reland failed due to a missing link dependency on `clangLex`. This reland fixes the issue by adding the link dependency after discussing it in the following RFC: https://discourse.llvm.org/t/rfc-driver-link-the-driver-against-clangdependencyscanning-clangast-clangfrontend-clangserialization-and-clanglex
2025-08-06[Clang] Fix warning on synthetic offload arch argument in host only mode ↵Joseph Huber1-0/+1
(#151969) Summary: These arguments are synthetically generated and should always be considered used. This was emitting a warning on the new driver.
2025-07-30[HIP] Handle `-fhip-emit-reloctable` in the new driver (#151237)Joseph Huber1-2/+17
Summary: Support for this was missing, here it pretty much overrides the normal bundling behavior and also requires a few errors to be emitted.
2025-07-28[HIP] Always respect `--gpu-bundle-output` in the new driver (#150989)Joseph Huber1-5/+6
Summary: This is a bit of an awkward transition point for the new and old drivers. Previously AMDGPU uses this to generate offloading bundles, but the new driver much prefers to output the file itself. This patch changes the behavior to always respect `--gpu-bundle-output` instead of having it be the default behavior. This means that we effectively get to override the default new driver behavior with this flag now. This should hoepfully fix some errors in the downstream comgr tests.
2025-07-28[Clang] Search for 'offload-arch' only next to the clang driver (#150965)Joseph Huber1-1/+1
Summary: Previously, querying for the offload architecture tool would invoke the user's PATH, which is bad when potentially using the driver from a direct path. This patch change this to *only* consider the `offload-arch` that's supposed to live next to the driver executable. Now we will no longer pick up a potentially conflicting version of this tool and it should always be found (Since it's a clang tool that's installazed alongside the driver)
2025-07-24[clang][Driver] Add a new member for CLANG_DEFAULT_LINKER to ↵parabola941-2/+2
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[Clang] Make SPIR-V handling only for HIPSPRVJoseph Huber1-2/+2
2025-07-23[Clang] Fix new driver HIP SPIR-V compilation in device only mode (#150309)Joseph Huber1-2/+5
Summary: This should emit LLVM-IR. Add to the extremely ugly if statement so that this happens correctly.
2025-07-23[Clang] Fix new driver device only compilation for `amdgcnspirv` target ↵Joseph Huber1-3/+10
(#150110) Summary: This is broken with the current target because it was not bundling the output as HIP likes and this would fail if targeting both at the same time.
2025-07-23[Clang] Fix build on 32-bit platforms after #125556Harald van Dijk1-1/+1
2025-07-22[Clang] Add generated offloading Xarch args to synthesized args (#150142)Joseph Huber1-0/+1
Summary: The synthesized args contains a list of unique pointers, so this should clean this generated argument up once created.
2025-07-22[Clang] Fix sanitizer failure on DenseMap sentinel value enumJoseph Huber1-1/+2
Summary: This triggers UBSan because the sentinel value `-1` is outside the range of accepted enum values. Just replace this with a small set.
2025-07-21[Clang][NFC] Fix linting warnings after #125556Joseph Huber1-34/+6
2025-07-21[Clang] Rework creating offloading toolchains (#125556)Joseph Huber1-400/+314
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-21Revert "Reland [clang][modules-driver] Add scanner to detect C++20 module ↵Naveen Seth Hanig1-70/+0
presence" (#149900) Reverts llvm/llvm-project#147630. This causes a linker error caused by linking the driver against the lexer.
2025-07-21Reland [clang][modules-driver] Add scanner to detect C++20 module presence ↵Naveen Seth Hanig1-0/+70
(#147630) This patch is part of a series to natively support C++20 module usage from the Clang driver (without requiring an external build system). This introduces a new scanner that detects C++20 module usage in source files without using the preprocessor or lexer. For now, it is enabled only with the `-fmodules-driver` flag and serves solely diagnostic purposes. In the future, the scanner will be enabled for any (modules-driver compatible) compilation with two or more inputs, and will help the driver determine whether to implicitly enable the modules driver. Since the scanner adds very little overhead, we are also exploring enabling it for compilations with only a single input. This approach could allow us to detect `import std` usage in a single-file compilation, which would then activate the modules driver. For performance measurements on this, see https://github.com/naveen-seth/llvm-dev-cxx-modules-check-benchmark. RFC: https://discourse.llvm.org/t/rfc-modules-support-simple-c-20-modules-use-from-the-clang-driver-without-a-build-system This patch relands commit ded1426. The CI failure is resolved by removing the compatibility warning for using the `-fmodules-driver` flag with pre-C++20 standards, which also better aligns its behavior with other features/flags supported only in newer standards.
2025-07-21[C++20] [Modules] Enable reduced BMI by defaultChuanqi Xu1-3/+5
As documented in 20.x, we'd like to keep reduced BMI off by default for 1~2 versions. And now we're in 22.x. I rarely receive bug reports for reduced BMI. I am not sure about the reason. Maybe not a lot of people are using it. Or it is really stable enough. And also, we've been enabling the reduced BMI internally for roughly half a year. So I think it's the time to move on. See the document changes for other information.
2025-07-15Remove Native Client support (#133661)Brad Smith1-4/+0
Remove the Native Client support now that it has finally reached end of life.
2025-07-07Revert "[clang][modules-driver] Add scanner to detect C++20 module presence" ↵Corentin Jabot1-210/+0
(#147286) Reverts llvm/llvm-project#145220 This breaks CI when building the documentation ``` Included from /home/runner/work/llvm-project/llvm-project/clang/docs/../include/clang/Basic/Diagnostic.td:74: /home/runner/work/llvm-project/llvm-project/clang/docs/../include/clang/Basic/DiagnosticGroups.td:628:5: error: Diagnostic group contains both remark and non-remark diagnostics def ModulesDriver : DiagGroup<"modules-driver">; ^ ``` https://github.com/llvm/llvm-project/actions/runs/16116118496/job/45470268367
2025-07-07[clang][modules-driver] Add scanner to detect C++20 module presence (#145220)Naveen Seth Hanig1-0/+210
This PR is part of a series to natively support C++20 module usage from the Clang driver (without requiring an external build system). This introduces a new scanner that detects C++20 module usage in source files without using the preprocessor or lexer. For now, it is enabled only with the `-fmodules-driver` flag and serves solely diagnostic purposes. In the future, the scanner will be enabled for any (modules-driver compatible) compilation with two or more inputs, and will help the driver determine whether to implicitly enable the modules driver. Since the scanner adds very little overhead, we are also exploring enabling it for compilations with only a single input. This approach could allow us to detect `import std` usage in a single-file compilation, which would then activate the modules driver. For performance measurements on this, see https://github.com/naveen-seth/llvm-dev-cxx-modules-check-benchmark. RFC: https://discourse.llvm.org/t/rfc-modules-support-simple-c-20-modules-use-from-the-clang-driver-without-a-build-system
2025-07-04[Clang] Introduce `--offload-targets` for `-fopenmp-targets` (#146594)Joseph Huber1-4/+4
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-07-02[Clang] Properly use `CommaJoined` for `--offload-arch` (#146687)Joseph Huber1-13/+10
Summary: This didn't use the built-in 'CommaJoined' feature for arguments and parsed out the strings manually. This patch simplifies this by just using the present functionality.
2025-07-01Driver: Avoid llvm::sys::path::append if resource directory absolute.Peter Collingbourne1-1/+6
After #145996 CLANG_RESOURCE_DIR can be an absolute path so we need to handle it correctly in the driver. llvm::sys::path::append does not append absolute paths in the way that I expected (or consistent with other similar APIs such as C++17 std::filesystem::path::append or Python os.path.join); instead, it effectively discards the leading / and appends the resulting relative path (e.g. append(P, "/bar") with P = "/foo" sets P to "/foo/bar"). Many tests start failing if I try to align llvm::sys::path::append with the other APIs because of callers that expect the existing behavior, so for now let's add a special case here for absolute resource paths, and document the behavior in Path.h. Reviewers: MaskRay Reviewed By: MaskRay Pull Request: https://github.com/llvm/llvm-project/pull/146449
2025-06-30[RISCV] Integrate RISCV target in baremetal toolchain object and deprecate ↵Garvit Gupta1-8/+2
RISCVToolchain object (#121831) This patch: - Adds CXXStdlib, runtimelib defaults for riscv target to BareMetal toolchain object. - Set the unwindlib to None for riscv target to match the behavior of RISCVToolChain. - Removes call to RISCVToolChain object from llvm. This PR is last patch in the series of patches of merging RISCVToolchain object into BareMetal toolchain object. RFC: https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524
2025-06-26[Clang] Determine offloading architectures at Toolchain creation (#145799)Joseph Huber1-64/+68
Summary: Previously we had this weird disconnect where we would get some offloading architectures beforehand and some later. This patch changes it to where we just generate this information at Toolchain creation. There's a few edge cases that will need to be cleaned up. Namely, we don't handle the strange SPIR-V handling that mixes two separate toolchains and we needed a pre-check to reject errors when inferring the toolchain from `--offload-arch` in OpenMP. Possible we could also use this information for some host defines if needed.
2025-06-25[Clang][NFC] Clean up OpenMP offload toolchain generation (#145549)Joseph Huber1-66/+57
Summary: Small cleanup prior to some larger changes in this area. I want to move the offload arch detection to be done solely here. This might change the order the targets show up in but shouldn't affect anything else. Will look into that.
2025-06-20[clang] Add managarm support (#144791)no921-0/+4
This is a repost of the quickly reverted #139271. The failing buildbot tests have been fixed and pass on my machine now.
2025-06-19[Clang] Add standalone AMDGPU SPIR-V toolchain (#144576)Joseph Huber1-5/+11
Summary: The AMDGPU toolchain uses a different set of tools than the standard SPIR-V toolchain. The linker wrapper prefers to invoke a linker via a clang toolchain. To make that work we introduce `--target=spirv64-amd-amdhsa` so that it creates the linking phases that HIP prefers. Additionally, this can be used to make LLVM-IR / SPIR-V from C/C++ that can be linked with the HIP output.
2025-06-17Revert "[clang] Add managarm support" (#144514)Aaron Ballman1-4/+0
Reverts llvm/llvm-project#139271 There are multiple failing build bots: https://lab.llvm.org/buildbot/#/builders/10/builds/7482 https://lab.llvm.org/buildbot/#/builders/11/builds/17473
2025-06-17Reland: "[Frontend][PCH]-Add support for ignoring PCH options (-ignore-pch). ↵Ying Yi1-0/+8
(#142409)" (#143614) Visual Studio has an argument to ignore all PCH related switches. clang-cl has also support option /Y-. Having the same option in clang would be helpful. This commit is to add support for ignoring PCH options (-ignore-pch). The commit includes: 1. Implement -ignore-pch as a Driver option. 2. Add a Driver test and a PCH test. 3. Add a section of -ignore-pch to user manual. 4. Add a release note for the new option '-ignore-pch'. The change since the original landing: 1. preprocessing-only mode doesn't imply that -include-pch is disabled. Co-authored-by: Matheus Izvekov <mizvekov@gmail.com>
2025-06-17[clang] Add managarm support (#139271)no921-0/+4
This PR is part of a series to upstream managarm support, as laid out in the [RFC](https://discourse.llvm.org/t/rfc-new-proposed-managarm-support-for-llvm-and-clang-87845/85884/1). This PR is a follow-up to #87845 and #138854.
2025-06-12Reland [HIP] use offload wrapper for non-device-only non-rdc (#143964)Yaxun (Sam) Liu1-18/+44
Fixed a typo: - auto Section = (Prefix + "llvm_offload_entries").str(); + auto Section = (Prefix + "_offload_entries").str(); which broke buildbot e.g. https://lab.llvm.org/buildbot/#/builders/208/builds/1948
2025-06-12Revert "Reland [HIP] use offload wrapper for non-device-only non-rdc ↵Yaxun (Sam) Liu1-44/+18
(#132869) (#143964)" This reverts commit 22f9b4aa1dad597d908be77be1e10ba4c77330ce.
2025-06-12Reland [HIP] use offload wrapper for non-device-only non-rdc (#132869) (#143964)Yaxun (Sam) Liu1-18/+44
Fixed two issues: 1. assertion with -flto. the linker wrapper action is missing for wrapping the device binary. Added it for -flto. 2. when there are two HIP files, the kernels in the second file were not found. This is because the -r option of linker wrapper assumes offload entries section of HIP to be hip_offloading_entries but it is actually llvm_offload_entries, causing the offload entries sections not made unique for different object files. Fixed and tested working for both -fgpu-rdc and -fno-gpu-rdc case with and without -r
2025-06-11[HLSL][Driver] Make vk1.3 the default. (#143384)Steven Perron1-14/+13
The HLSL driver currently defaults the triple to an unversioned os and subarch when targeting SPIR-V. This means the SPIR-V backend decides the default value. That is not a great option because a change the backend could cause a change in Clang. Now that we want to choose the default we need to consider the best option. DXC currently defaults to Vulkan1.0. We are planning on not supporting Vulkan1.0 in the Clang HLSL compiler because it is newer versions of Vulkan are commonly supported on nearly all hardware, so users do not use it. Since we have to change from DXC anyway, we are using VK1.3. It has been out long enough to be commonly available, and the initial implementation of SPIR-V features for HLSL are assuming Vulkan 1.3. --------- Co-authored-by: Nathan Gauër <github@keenuts.net>
2025-06-10Revert "[Frontend][PCH]-Add support for ignoring PCH options (-ignore-pch). ↵Ying Yi1-9/+0
(#142409)" This reverts commit 4fb81f11cea0fce9f1f5409fcd55ae3aba70d368.
2025-06-10[Frontend][PCH]-Add support for ignoring PCH options (-ignore-pch). (#142409)MaggieYingYi1-0/+9
Visual Studio has an argument to ignore all PCH related switches. clang-cl has also support option /Y-. Having the same option in clang would be helpful. This commit is to add support for ignoring PCH options (-ignore-pch). The commit includes: 1. Implement -ignore-pch as a Driver option. 2. Add a Driver test and a PCH test. 3. Add a section of -ignore-pch to user manual. 4. Add a release note for the new option '-ignore-pch'. Code reviewed by: Matheus Izvekov <mizvekov@gmail.com>
2025-06-09Revert "[HIP] use offload wrapper for non-device-only non-rdc (#132869)" ↵Joseph Huber1-41/+18
(#143432) This breaks a lot of new driver HIP compilation. We should probably revert this for now until we can make a fixed version. ```c++ static __global__ void print() { printf("%s\n", "foo"); } void b(); int main() { hipLaunchKernelGGL(print, dim3(1), dim3(1), 0, 0); auto y = hipDeviceSynchronize(); b(); } ``` ```c++ static __global__ void print() { printf("%s\n", "bar"); } void b() { hipLaunchKernelGGL(print, dim3(1), dim3(1), 0, 0); auto y = hipDeviceSynchronize(); } ``` ```console $ clang++ a.hip b.hip --offload-arch=gfx1030 --offload-new-driver $ ./a.out foo foo ``` ```console $ clang++ a.hip b.hip --offload-arch=gfx1030 --offload-new-driver -flto <crash> ``` This reverts commit d54c28b9c1396fa92d9347ac1135da7907121cb8.
2025-06-03Reapply "[AMDGPU] Use the AMDGPUToolChain when targeting C/C++ directly" ↵Joseph Huber1-2/+19
(#125744) Summary: This reverts commit 740e6aeccdb2f8eeee549ba80b15ff3d5dd3392e. After discussions it was determined that the behavior for IR inputs needs to be maintained at least for now. In the future we should put a deprecation notice on this behavior. This patch keeps the old behavior for OpenCL and IR inputs, while others will be standalone. This is good enough for standard compile flows.
2025-06-02[NFC][clang] Move argument handling: Driver::BuildActions -> handleArguments ↵Naveen Seth Hanig1-33/+33
(#142455) This simply moves code for diagnosing misuse of arguments `/Fo`, `/Fa`, and `/o` from `Driver::BuildActions` into `Driver::handleArguments`, following the intention of 740f69b. This change better aligns with the roles of `BuildActions` and `handleArguments`.
2025-06-02[flang][driver] Introduce FCC_OVERRIDE_OPTIONS. (#140556)Abid Qadeer1-4/+5
This PR add functionality to change `flang` command line using environment variable `FCC_OVERRIDE_OPTIONS`. It is quite similar to what `CCC_OVERRIDE_OPTIONS` does for clang. The `FCC_OVERRIDE_OPTIONS` seemed like the most obvious name to me but I am open to other ideas. The `applyOverrideOptions` now takes an extra argument that is the name of the environment variable. Previously `CCC_OVERRIDE_OPTIONS` was hardcoded.
2025-05-28Check for unsupported target options even with -Qunused-arguments (#141698)Matthias Braun1-6/+6
Fix clang accidentally skipping checks for `err_drv_unsupported_opt_for_target` when `-Qunused-arguments` was active.
2025-05-16[clang] Use llvm::replace (NFC) (#140264)Kazu Hirata1-1/+1
2025-05-12[Clang][Driver] Fix condition in combineBackendCompile when using ↵Juan Manuel Martinez Caamaño1-9/+10
-no-integrated-cpp (#136853) When using -no-integrated-cpp, before, the driver won't collapse actions when the input was not llvm-ir or it would collapse them too aggressively with -save-temps The original code was checking the action type (which is IR too for preprocessed->bc actions) instead of the action inputs.
2025-05-09[Clang] [Driver] add a Cygwin ToolChain (#135691)jeremyd20191-0/+4
Add a new Cygwin toolchain that just goes through the motions to initialize the Generic_GCC base properly. This allows removing some old, almost certainly wrong hard-coded paths from Lex/InitHeaderSearch.cpp. MSYS2 (GCC triple (arch)-pc-msys) is a fork of Cygwin (GCC triple (arch)-pc-cygwin), and this driver can be used for either. Add a simple test for this driver.
2025-04-29[HLSL] Allow non `.hlsl` files as source files (#137378)Steven Perron1-0/+2
Changes the driver to assume input file with an unknown extension are HLSL source files instead of object files. Fixes https://github.com/llvm/llvm-project/issues/137370