aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Driver
AgeCommit message (Collapse)AuthorFilesLines
2025-06-06[Driver] Move CommonArgs to a location visible by the Frontend Drivers (#142800)Cameron McInally2-2/+2
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-05-22Reapply "[clang] Remove intrusive reference count from `DiagnosticOptions` ↵Jan Svoboda4-48/+47
(#139584)" This reverts commit e2a885537f11f8d9ced1c80c2c90069ab5adeb1d. Build failures were fixed right away and reverting the original commit without the fixes breaks the build again.
2025-05-22Revert "[clang] Remove intrusive reference count from `DiagnosticOptions` ↵Kazu Hirata4-47/+48
(#139584)" This reverts commit 9e306ad4600c4d3392c194a8be88919ee758425c. Multiple builtbot failures have been reported: https://github.com/llvm/llvm-project/pull/139584
2025-05-22[clang] Remove intrusive reference count from `DiagnosticOptions` (#139584)Jan Svoboda4-48/+47
The `DiagnosticOptions` class is currently intrusively reference-counted, which makes reasoning about its lifetime very difficult in some cases. For example, `CompilerInvocation` owns the `DiagnosticOptions` instance (wrapped in `llvm::IntrusiveRefCntPtr`) and only exposes an accessor returning `DiagnosticOptions &`. One would think this gives `CompilerInvocation` exclusive ownership of the object, but that's not the case: ```c++ void shareOwnership(CompilerInvocation &CI) { llvm::IntrusiveRefCntPtr<DiagnosticOptions> CoOwner = &CI.getDiagnosticOptions(); // ... } ``` This is a perfectly valid pattern that is being actually used in the codebase. I would like to ensure the ownership of `DiagnosticOptions` by `CompilerInvocation` is guaranteed to be exclusive. This can be leveraged for a copy-on-write optimization later on. This PR changes usages of `DiagnosticOptions` across `clang`, `clang-tools-extra` and `lldb` to not be intrusively reference-counted.
2025-05-16[clang] Use llvm::replace (NFC) (#140264)Kazu Hirata1-9/+9
2025-04-29[clang] Merge gtest binaries into AllClangUnitTests (#134196)Reid Kleckner1-1/+1
This reduces the size of the clang/unittests build directory by 64% and my overall build dir size by 5%. Static linking is the real driving factor here, but even if the default build configuration used shared libraries, I don't see why we should be building so many unit test binaries. To make the project more approachable for new contributors, I'm attempting to make the build a bit less resource-intensive. Build directory size is a common complaint, and this is low-hanging fruit. I've noticed that incremental builds leave behind the old, stale gtest binaries, and lit will keep running them. This mostly doesn't matter unless they use shared libraries, which will eventually stop working after successive builds. You can clean up the old test binaries with this command in the build directory: $ find tools/clang/unittests/ -iname '*Tests' -type f | xargs rm ... or you can simply clean the build directory in a more holistic way. --------- Co-authored-by: Petr Hosek <phosek@google.com>
2025-04-28[clang] Hide the `TargetOptions` pointer from `CompilerInvocation` (#106271)Jan Svoboda1-2/+1
This PR hides the reference-counted pointer that holds `TargetOptions` from the public API of `CompilerInvocation`. This gives `CompilerInvocation` an exclusive control over the lifetime of this member, which will eventually be leveraged to implement a copy-on-write behavior. There are two clients that currently share ownership of that pointer: * `TargetInfo` - This was refactored to hold a non-owning reference to `TargetOptions`. The options object is typically owned by the `CompilerInvocation` or by the new `CompilerInstance::AuxTargetOpts` for the auxiliary target. This needed a bit of care in `ASTUnit::Parse()` to keep the `CompilerInvocation` alive. * `clangd::PreambleData` - This was refactored to exclusively own the `TargetOptions` that get moved out of the `CompilerInvocation`.
2025-04-02Reapply "[cmake] Refactor clang unittest cmake" (#134195)Reid Kleckner1-12/+7
This reapplies 5ffd9bdb50b57 (#133545) with fixes. The BUILD_SHARED_LIBS=ON build was fixed by adding missing LLVM dependencies to the InterpTests binary in unittests/AST/ByteCode/CMakeLists.txt .
2025-04-01Revert "[cmake] Refactor clang unittest cmake" (#134022)dpalermo1-7/+12
Reverts llvm/llvm-project#133545 This change is breaking several buildbots as well as developer's builds. Reverting to allow people to make progress.
2025-04-01[cmake] Refactor clang unittest cmake (#133545)Reid Kleckner1-12/+7
Pass all the dependencies into add_clang_unittest. This is consistent with how it is done for LLDB. I borrowed the same named argument list structure from add_lldb_unittest. This is a necessary step towards consolidating unit tests into fewer binaries, but seems like a good refactoring in its own right.
2025-02-04[clang] UEFI targets must use CodeView. (#124660)Prabhuk1-0/+17
2024-11-21Reapply "[NFC] Explicitly pass a VFS when creating DiagnosticsEngine (#115852)"Kadir Cetinkaya2-2/+3
This reverts commit a1153cd6fedd4c906a9840987934ca4712e34cb2 with fixes to lldb breakages. Fixes https://github.com/llvm/llvm-project/issues/117145.
2024-11-21Revert "[NFC] Explicitly pass a VFS when creating DiagnosticsEngine (#115852)"Sylvestre Ledru2-3/+2
Reverted for causing: https://github.com/llvm/llvm-project/issues/117145 This reverts commit bdd10d9d249bd1c2a45e3de56a5accd97e953458.
2024-11-21[NFC] Explicitly pass a VFS when creating DiagnosticsEngine (#115852)kadir çetinkaya2-2/+3
Starting with 41e3919ded78d8870f7c95e9181c7f7e29aa3cc4 DiagnosticsEngine creation might perform IO. It was implicitly defaulting to getRealFileSystem. This patch makes it explicit by pushing the decision making to callers. It uses ambient VFS if one is available, and keeps using `getRealFileSystem` if there aren't any VFS.
2024-10-07[clang][Driver] Rename "FatalError" key to "Error" in multilib.yaml (#110804)Simon Tatham1-1/+1
This is a late-breaking change to #105684, suggested after the original patch was already landed.
2024-09-20Reland "[Driver] Add toolchain for X86_64 UEFI target" (#109364)Prabhuk1-0/+21
Reverts llvm/llvm-project#109340 Addressing the failed MAC Clang Driver test as part of this reland.
2024-09-20Revert "[SystemZ][z/OS] Propagate IsText parameter to open text files as ↵Abhina Sreeskantharajan2-3/+3
text (#107906)" This reverts commit edf3b277a5f2ebe144827ed47463c22743cac5f9.
2024-09-19Revert "[Driver] Add toolchain for X86_64 UEFI target" (#109340)Prabhuk1-21/+0
Reverts llvm/llvm-project#76838 Appears to be causing failures in MAC builders. First reverting the patch and will investigate after.
2024-09-19[Clang] - Add libclangSerialization to clang driver unittests (#109329)Pranav Bhandarkar1-0/+1
This PR is a fix for issue [#109328](https://github.com/llvm/llvm-project/issues/109328). libclangSerializaton.so is needed for building clang driver unittests after https://github.com/llvm/llvm-project/pull/76838 was merged. Needed for builds with `BUILD_SHARED_LIBS=ON`
2024-09-19[Driver] Add toolchain for X86_64 UEFI target (#76838)Prabhuk1-0/+21
Introduce changes necessary for UEFI X86_64 target Clang driver. Addressed the review comments originally suggested in Phabricator. Differential Revision: https://reviews.llvm.org/D159541
2024-09-19[SystemZ][z/OS] Propagate IsText parameter to open text files as text (#107906)Abhina Sree2-3/+3
This patch adds an IsText parameter to the following functions openFileForRead, getBufferForFile, getBufferForFileImpl and determines whether a file is text by querying the file tag on z/OS. The default is set to OF_Text instead of OF_None, this change in value does not affect any other platforms other than z/OS.
2024-09-18Fix OOM in FormatDiagnostic (2nd attempt) (#108866)Vakhurin Sergei1-5/+0
Resolves: #70930 (and probably latest comments from clangd/clangd#251) by fixing racing for the shared DiagStorage value which caused messing with args inside the storage and then formatting the following message with getArgSInt(1) == 2: def err_module_odr_violation_function : Error< "%q0 has different definitions in different modules; " "%select{definition in module '%2'|defined here}1 " "first difference is " which causes HandleSelectModifier to go beyond the ArgumentLen so the recursive call to FormatDiagnostic was made with DiagStr > DiagEnd that leads to infinite while (DiagStr != DiagEnd). The Main Idea: Reuse the existing DiagStorageAllocator logic to make all DiagnosticBuilders having independent states. Also, encapsulating the rest of state (e.g. ID and Loc) into DiagnosticBuilder. The last attempt failed - https://github.com/llvm/llvm-project/pull/108187#issuecomment-2353122096 so was reverted - #108838
2024-09-16Revert "Fix OOM in FormatDiagnostic" (#108838)Aaron Ballman1-0/+5
Reverting due to build failures found in #108187
2024-09-16Fix OOM in FormatDiagnostic (#108187)Vakhurin Sergei1-5/+0
Resolves: #70930 (and probably latest comments from https://github.com/clangd/clangd/issues/251) by fixing racing for the shared `DiagStorage` value which caused messing with args inside the storage and then formatting the following message with `getArgSInt(1)` == 2: ``` def err_module_odr_violation_function : Error< "%q0 has different definitions in different modules; " "%select{definition in module '%2'|defined here}1 " "first difference is " ``` which causes `HandleSelectModifier` to go beyond the `ArgumentLen` so the recursive call to `FormatDiagnostic` was made with `DiagStr` > `DiagEnd` that leads to infinite `while (DiagStr != DiagEnd)`. **The Main Idea:** Reuse the existing `DiagStorageAllocator` logic to make all `DiagnosticBuilder`s having independent states. Also, encapsulating the rest of state (e.g. ID and Loc) into `DiagnosticBuilder`. **TODO (if it will be requested by reviewer):** - [x] add a test (I have no idea how to turn a whole bunch of my proprietary code which leads `clangd` to OOM into a small public example.. probably I must try using [this](https://github.com/llvm/llvm-project/issues/70930#issuecomment-2209872975) instead) - [x] [`Diag.CurDiagID != diag::fatal_too_many_errors`](https://github.com/llvm/llvm-project/pull/108187#pullrequestreview-2296395489) - [ ] ? get rid of `DiagStorageAllocator` at all and make `DiagnosticBuilder` having they own `DiagnosticStorage` coz it seems pretty small so should fit the stack for short-living `DiagnosticBuilder` instances
2024-09-06[NFC] Add explicit #include llvm-config.h where its macros are used, clang ↵Daniil Fukalov1-0/+1
part. (#107301) (this is clang related part) Without these explicit includes, removing other headers, who implicitly include llvm-config.h, may have non-trivial side effects. For example, `clagd` may report even `llvm-config.h` as "no used" in case it defines a macro, that is explicitly used with #ifdef. It is actually amplified with different build configs which use different set of macros.
2024-09-03[clang][Driver] Add missing include after ↵Christian Sigg1-0/+1
26bf0b4ae7df7f5350f71afd40a57cdf8f98c588. https://github.com/llvm/llvm-project/commit/26bf0b4ae7df7f5350f71afd40a57cdf8f98c588
2024-09-02[clang][Driver] Add a custom error option in multilib.yaml. (#105684)Simon Tatham3-36/+75
Sometimes a collection of multilibs has a gap in it, where a set of driver command-line options can't work with any of the available libraries. For example, the Arm MVE extension requires special startup code (you need to initialize FPSCR.LTPSIZE), and also benefits greatly from -mfloat-abi=hard. So a multilib provider might build a library for systems without MVE, and another for MVE with -mfloat-abi=hard, anticipating that that's what most MVE users would want. But then if a user compiles for MVE _without_ -mfloat-abi=hard, thhey can't use either of those libraries – one has an ABI mismatch, and the other will fail to set up LTPSIZE. In that situation, it's useful to include a multilib.yaml entry for the unworkable intermediate situation, and have it map to a fatal error message rather than a set of actual libraries. Then the user gets a build failure with a sensible explanation, instead of selecting an unworkable library and silently generating bad output. The new regression test demonstrates this case. This patch introduces extra syntax into multilib.yaml, so that a record in the `Variants` list can omit the `Dir` key, and in its place, provide a `FatalError` key. Then, if that variant is selected, the error message is emitted as a clang diagnostic, and multilib selection fails. In order to emit the error message in `MultilibSet::select`, I had to pass a `Driver &` to that function, which involved plumbing one through to every call site, and in the unit tests, constructing one specially.
2024-05-23Fix an accidental escape sequence in a unit testAaron Ballman1-1/+1
This amends b49ce9c304b00dae49148b6a2f5f27965000206c
2024-05-23Fix more diagnostic wording for style; NFC (#93190)Aaron Ballman1-9/+10
This tries to fix all of the places where a diagnostic message starts with a capital letter (other than acroynyms or proper nouns) or ends with punctuation (other than a question mark). This is in support of a planned change to tablegen to start diagnosing incorrect diagnostic message styles.
2024-05-08[DXIL] Set DXIL Version in DXIL target triple based on shader model version ↵S. Bharadwaj Yadavalli1-10/+12
(#91407) This change set restores commit 080978dd2067d0c9ea7e229aa7696c2480d89ef1 that was reverted to address ASAN failures and includes a fix for the ASAN failures. Following is the description of the change: An earlier commit provided a way to decouple DXIL version from Shader Model version by representing the DXIL version as `SubArch` in the DXIL Target Triple and adding corresponding valid DXIL Arch types. This change constructs DXIL target triple with DXIL version that is deduced from Shader Model version specified in the following scenarios: 1. When compilation target profile is specified: For e.g., DXIL target triple `dxilv1.8-unknown-shader6.8-library` is constructed when `-T lib_6_8` is specified. 2. When DXIL target triple without DXIL version is specified: For e.g., DXIL target triple `dxilv1.8-pc-shadermodel6.8-library` is constructed when `-mtriple=dxil-pc-shadermodel6.8-library` is specified. Updated relevant HLSL tests that check for target triple.
2024-05-06Revert "[DirectX][DXIL] Set DXIL Version in DXIL target triple based on ↵S. Bharadwaj Yadavalli1-12/+10
shader model version" (#91290) Reverts llvm/llvm-project#90809 Need to investigate ASAN failures.
2024-05-06[DirectX][DXIL] Set DXIL Version in DXIL target triple based on shader model ↵S. Bharadwaj Yadavalli1-10/+12
version (#90809) An earlier commit provided a way to decouple DXIL version from Shader Model version by representing the DXIL version as `SubArch` in the DXIL Target Triple and adding corresponding valid DXIL Arch types. This change constructs DXIL target triple with DXIL version that is deduced from Shader Model version specified in the following scenarios: 1. When compilation target profile is specified: For e.g., DXIL target triple `dxilv1.8-unknown-shader6.8-library` is constructed when `-T lib_6_8` is specified. 2. When DXIL target triple without DXIL version is specified: For e.g., DXIL target triple `dxilv1.8-pc-shadermodel6.8-library` is constructed when `-mtriple=dxil-pc-shadermodel6.8-library` is specified. Updated relevant HLSL tests that check for target triple. Validated that Clang (`check-clang`) and LLVM (`check-llvm`) regression tests pass.
2023-12-13[clang] Use StringRef::{starts,ends}_with (NFC) (#75149)Kazu Hirata3-4/+4
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-10-26[clang] [Gnu] Improve GCCVersion parsing to match versions such as ↵Martin Storsjö1-0/+1
"10-win32" (#69079) In earlier GCC versions, the Debian/Ubuntu provided mingw toolchains were packaged in /usr/lib/gcc/<triple> with version strings such as "5.3-win32", which were matched and found since 6afcd64eb65fca233a7b173f88cffb2c2c9c114c. However in recent versions, they have stopped including the minor version number and only have version strings such as "10-win32" and "10-posix". Generalize the parsing code to tolerate the patch suffix to be present on a version number with only a major number. Refactor the string parsing code to highlight the overall structure of the parsing. This implementation should yield the same result as before, except for when there's only one segment and it has trailing, non-number contents. This allows Clang to find the GCC libraries and headers in Debian/Ubuntu provided MinGW cross compilers.
2023-10-20Reland [clang] [unittest] Add a test for Generic_GCC::GCCVersion::Parse (#69078)Martin Storsjö2-0/+60
This adds actual test cases for all the cases that are listed in a code comment in the implementation of this function; having such test coverage eases doing further modifications to the function. This relands b4b35a5d2b4ee26bf79b8a92715dd200f3f9cc49. This time, the new test is excluded if building with dylibs or shared libraries enabled, as the clang::toolchains::Generic_GCC class is marked LLVM_LIBRARY_VISIBILITY, giving it hidden visibility in such builds, making it unreferencable outside of the dylib/shared library.
2023-10-18Revert "[clang] [unittest] Add a test for Generic_GCC::GCCVersion::Parse ↵Martin Storsjö2-53/+0
(#69078)" This reverts commit b4b35a5d2b4ee26bf79b8a92715dd200f3f9cc49. That commit broke builds with -DBUILD_SHARED_LIBS=ON. The reason is that clang::driver::toolchains::Generic_GCC::GCCVersion::Parse isn't visible outside of the shared library, because the Generic_GCC class is marked with LLVM_LIBRARY_VISIBILITY.
2023-10-18[clang] [unittest] Add a test for Generic_GCC::GCCVersion::Parse (#69078)Martin Storsjö2-0/+53
This adds actual test cases for all the cases that are listed in a code comment in the implementation of this function; having such test coverage eases doing further modifications to the function.
2023-09-27[Driver] Fix VFSGnuLibcxxPathNoSysroot test with DEFAULT_SYSROOTSam McCall1-1/+2
2023-09-22[Driver] Fix detection of libc++ with empty sysroot. (#66947)Sam McCall1-0/+48
b1e3cd1d79443603dc003441e07cdd8d30bb7f26 dropped the leading slash here, presumably unintentionally. (I don't understand Driver well enough to know how/where this is supposed to be tested, but it broke clangd on any project that uses the system-installed -stdlib=libc++ on a standard debian install)
2023-08-16[Driver][unittest] Unbreak ToolChainTest.cpp compilation with -WerrorRainer Orth1-2/+1
D157275 broke some buildbots that run with -Werror: https://lab.llvm.org/buildbot#builders/36/builds/36604 https://lab.llvm.org/buildbot#builders/57/builds/29201 Avoid this by using an overlong line rather than appeasing `clang-format`.
2023-08-16[Driver] Select newest GCC installation on SolarisRainer Orth1-0/+149
As described in Issue #53709 <https://github.com/llvm/llvm-project/issues/53709>, since 28d58d8fe2094af6902dee7b4d68ec30a3e9d737 <https://reviews.llvm.org/rG28d58d8fe2094af6902dee7b4d68ec30a3e9d737> `clang` doesn't find the latest of several parallel GCC installations on Solaris, but only the first in directory order, which is pretty random. This patch sorts GCC installations in reverse version order so the latest is picked. Tested on `sparcv9-sun-solaris2.11`, `amd64-pc-solaris2.11`, and `x86_64-pc-linux-gnu`. Differential Revision: https://reviews.llvm.org/D157275
2023-07-12[clang][clangd] Don't crash/assert on -gsplit-dwarf=single without outputDmitry Polukhin1-0/+10
The crash happens in clang::driver::tools::SplitDebugName when Output is InputInfo::Nothing. It doesn't happen with standalone clang driver because output is created in Driver::BuildJobsForActionNoCache. Example backtrace: ``` * thread #1, name = 'clangd', stop reason = hit program assert * frame #0: 0x00007ffff5c4eacf libc.so.6`raise + 271 frame #1: 0x00007ffff5c21ea5 libc.so.6`abort + 295 frame #2: 0x00007ffff5c21d79 libc.so.6`__assert_fail_base.cold.0 + 15 frame #3: 0x00007ffff5c47426 libc.so.6`__assert_fail + 70 frame #4: 0x000055555dc0923c clangd`clang::driver::InputInfo::getFilename(this=0x00007fffffff9398) const at InputInfo.h:84:5 frame #5: 0x000055555dcd0d8d clangd`clang::driver::tools::SplitDebugName(JA=0x000055555f6c6a50, Args=0x000055555f6d0b80, Input=0x00007fffffff9678, Output=0x00007fffffff9398) at CommonArgs.cpp:1275:40 frame #6: 0x000055555dc955a5 clangd`clang::driver::tools::Clang::ConstructJob(this=0x000055555f6c69d0, C=0x000055555f6c64a0, JA=0x000055555f6c6a50, Output=0x00007fffffff9398, Inputs=0x00007fffffff9668, Args=0x000055555f6d0b80, LinkingOutput=0x0000000000000000) const at Clang.cpp:5690:33 frame #7: 0x000055555dbf6b54 clangd`clang::driver::Driver::BuildJobsForActionNoCache(this=0x00007fffffffb5e0, C=0x000055555f6c64a0, A=0x000055555f6c6a50, TC=0x000055555f6c4be0, BoundArch=(Data = 0x0000000000000000, Length = 0), AtTopLevel=true, MultipleArchs=false, LinkingOutput=0x0000000000000000, CachedResults=size=1, TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:5618:10 frame #8: 0x000055555dbf4ef0 clangd`clang::driver::Driver::BuildJobsForAction(this=0x00007fffffffb5e0, C=0x000055555f6c64a0, A=0x000055555f6c6a50, TC=0x000055555f6c4be0, BoundArch=(Data = 0x0000000000000000, Length = 0), AtTopLevel=true, MultipleArchs=false, LinkingOutput=0x0000000000000000, CachedResults=size=1, TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:5306:26 frame #9: 0x000055555dbeb590 clangd`clang::driver::Driver::BuildJobs(this=0x00007fffffffb5e0, C=0x000055555f6c64a0) const at Driver.cpp:4844:5 frame #10: 0x000055555dbe6b0f clangd`clang::driver::Driver::BuildCompilation(this=0x00007fffffffb5e0, ArgList=ArrayRef<const char *> @ 0x00007fffffffb268) at Driver.cpp:1496:3 frame #11: 0x000055555b0cc0d9 clangd`clang::createInvocation(ArgList=ArrayRef<const char *> @ 0x00007fffffffbb38, Opts=CreateInvocationOptions @ 0x00007fffffffbb90) at CreateInvocationFromCommandLine.cpp:53:52 frame #12: 0x000055555b378e7b clangd`clang::clangd::buildCompilerInvocation(Inputs=0x00007fffffffca58, D=0x00007fffffffc158, CC1Args=size=0) at Compiler.cpp:116:44 frame #13: 0x000055555895a6c8 clangd`clang::clangd::(anonymous namespace)::Checker::buildInvocation(this=0x00007fffffffc760, TFS=0x00007fffffffe570, Contents= Has Value=false ) at Check.cpp:212:9 frame #14: 0x0000555558959cec clangd`clang::clangd::check(File=(Data = "build/test.cpp", Length = 64), TFS=0x00007fffffffe570, Opts=0x00007fffffffe600) at Check.cpp:486:34 frame #15: 0x000055555892164a clangd`main(argc=4, argv=0x00007fffffffecd8) at ClangdMain.cpp:993:12 frame #16: 0x00007ffff5c3ad85 libc.so.6`__libc_start_main + 229 frame #17: 0x00005555585bbe9e clangd`_start + 46 ``` Test Plan: ninja ClangDriverTests && tools/clang/unittests/Driver/ClangDriverTests Differential Revision: https://reviews.llvm.org/D154602
2023-06-14[Driver] Enable selecting multiple multilibsMichael Platings2-41/+44
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] Multilib YAML parsingMichael Platings1-0/+348
The format includes a ClangMinimumVersion entry to avoid a potential source of subtle errors if an older version of Clang were to be used with a multilib.yaml that requires a newer Clang to work correctly. This feature is comparable to CMake's cmake_minimum_required. Reviewed By: peter.smith Differential Revision: https://reviews.llvm.org/D142932
2023-06-08[NFC][Driver] Change MultilibBuilder flags argument orderMichael Platings1-13/+15
Follow up to D151437 Reviewed By: phosek Differential Revision: https://reviews.llvm.org/D152353
2023-06-07[NFC][Driver] Change Multilib flag representationMichael Platings1-23/+23
This new representation means that a valid command line option may potentially be used directly as a multilib flag without any translation. To indicate that a flag is required not to be present, its first character is replaced with '!', which is intended for consistency with the logical not operator in many programming languages. Reviewed By: simon_tatham Differential Revision: https://reviews.llvm.org/D151438
2023-06-07[NFC][Driver] Change MultilibBuilder interfaceMichael Platings1-12/+15
Decouple the interface of the MultilibBuilder flag method from how flags are stored internally. Likewise change the addMultilibFlag function. Currently a multilib flag like "-fexceptions" means a multilib is *incompatible* with the -fexceptions command line option, which is counter-intuitive. This change is a step towards changing this scheme. Differential Revision: https://reviews.llvm.org/D151437
2023-05-18[NFC][Driver] Fix -Wdangling-else warningMichael Platings1-1/+2
GCC emits this warning because the EXPECT_STREQ macro contains an if-else statement: warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wdangling-else]
2023-03-24[Driver] Change multilib selection algorithmMichael Platings1-8/+29
The new algorithm is: 1. Find all multilibs with flags that are a subset of the requested flags. 2. If more than one multilib matches, choose the last. In addition a new selection mechanism is permitted via an overload of MultilibSet::select() for which multiple multilibs are returned. This allows layering multilibs on top of each other. Since multilibs are now ordered within a list, they no longer need a Priority field. The new algorithm is different to the old algorithm, but in practise the old algorithm was always used in such a way that the effect is the same. The old algorithm was to find the set intersection of the requested flags (with the first character of each removed) with each multilib's flags (ditto), and for that intersection check whether the first character matched. However, ignoring the first characters, the requested flags were always a superset of all the multilibs flags. Therefore the new algorithm can be used as a drop-in replacement. The exception is Fuchsia, which needs adjusting slightly to set both fexceptions and fno-exceptions flags. Differential Revision: https://reviews.llvm.org/D142905
2023-02-22[NFC] Class for building MultilibSetMichael Platings3-240/+243
The functionality in MultilibSet for creating it is tied to its current implementation. Putting that code in a separate class is an enabler for changing the MultilibSet implementation. Differential Revision: https://reviews.llvm.org/D142893