Commit Graph

1267 Commits

Author SHA1 Message Date
Cassie Jones
68b939f931 [driver] Make --version show if assertions, etc. are enabled (#87585)
It's useful to have some significant build options visible in the
version when investigating problems with a specific compiler artifact.
This makes it easy to see if assertions, expensive checks, sanitizers,
etc. are enabled when checking a compiler version.

Example config line output:
Build configuration: +unoptimized, +assertions, +asan, +ubsan
2024-04-05 10:01:09 -07:00
Daniel Grumberg
e05c1b46d0 Reenable external categories (#87357)
Reenables b31414bf4f.

Also adds a new warning for missing `--symbol-graph-dir` arg when
`--emit-extension-symbol-graphs` is provided. This also reverts the
commit that removed.
2024-04-03 10:18:05 +01:00
Daniel Grumberg
209a1e8dfd Revert "[clang][ExtractAPI] Add ability to create multiple symbol graphs (#86676)"
This failed the test suite due to missing DiagGroup for a new warning.

This reverts commit b31414bf4f.
2024-04-02 15:34:52 +01:00
Daniel Grumberg
b31414bf4f [clang][ExtractAPI] Add ability to create multiple symbol graphs (#86676)
This extends ExtractAPI to take into account symbols defined in categories to types defined in an external module.
This introduces 2 new command line flags, `--symbol-graph-dir=DIR` and `--emit-extension-symbol-graphs`, when used together this generates additional symbol graph files at `DIR/ExtendedModule@ProductName.symbols.json` for each external module that is extended in this way.

Additionally this makes some cleanups to tests to make them more resilient and cleans up the `APISet` data structure.
2024-04-02 15:03:46 +01:00
Chuanqi Xu
21f85e2300 [NFC] [C++20] [Modules] Pulling out getCXX20NamedModuleOutputPath into a seperate function
Required in the review process of
https://github.com/llvm/llvm-project/pull/85050.
2024-04-02 09:58:59 +08:00
Mark de Wever
2152094a45 [clang] Improves -print-library-module-manifest-path. (#85943)
This adds a libc++ to modules.json as is currently used by libc++. When
libc++.so is not found the function will search for libc++.a as
fallback.
2024-03-21 15:11:45 +01:00
Joseph Huber
357f00dddb [HIP] Correctly omit bundling with the new driver (#85842)
Summary:
The HIP phases do not emit the offload bundler output when we do not
invoke the final linker phase in device only mode. Check this propery.
2024-03-20 07:15:49 -05:00
Joseph Huber
280c7a9526 [Clang] Fix preprocessing device only in HIP mode
Summary:
A recent change made the HIP compilation bundle by default. However we
don't want to do this for `-E`, which silently broke some handling.
2024-03-18 12:12:17 -05:00
Chuanqi Xu
0e1e1fc8f0 Reland Print library module manifest path again (#84881)
Following of https://github.com/llvm/llvm-project/pull/82160

The reason why the above PR fails is that the `--sysroot` has lower
priority than the libc++ built from the same source. On the one hand, it
matches the codes behavior. We will add the built libc++ project paths
in the ToolChain class. But we will only add the path related to sysroot
in Linux class, which is derived from the ToolChain classes. So the
paths of just built libc++ is in the front of the paths relative to
sysroot. On the other hand, the behavior should be good from the higher
level. Since the just built libc++ has the same version number with the
just built clang, so it makes sense that these 2 compilers just matches.

So for patch it self, I hacked it by using resource dir in the test
since the resource dir has the higher priority, which is not strongly
correct since we won't do that in practice.

@kaz7 would you like to test on your environment to avoid this get
reverted again?

On the libc++ side, it shows that it lacks a `modules.json` file for the
just built libc++ directory. If we don't have that, it will be
problematic to use std modules from the just built clang and libc++
pair. Then it is not good. And I feel it may be problematic for future
compiler/standard library developers. So I feel this is somewhat a
libc++ issue that need to be fixed.

Also if we don't like the hacked test in the current patch, we must wait
for libc++ to fix this to proceed. But I feel this is somewhat odd since
the test of clang shouldn't dependent on libc++.

CC: @mordante

---------

Co-authored-by: Mark de Wever <koraq@xs4all.nl>
2024-03-17 21:14:53 +08:00
Dave Lee
8d7ee4691d [clang] Move CCC_OVERRIDE_OPTIONS implementation to Driver (#85425)
Move CCC_OVERRIDE_OPTIONS support to clangDriver so that it may be used outside of the 
clang driver binary.

The override functionality will be used in LLDB, to apply adjustments to ClangImporter 
flags. This will be useful as an escape hatch when there are issues that can be fixed 
by adding or removing clang flags.

The only thing changed is the name, from `ApplyQAOverride` to `applyOverrideOptions`.
2024-03-15 16:09:56 -07:00
Joseph Huber
d1d80cc319 [HIP] Make the new driver bundle outputs for device-only (#84534)
Summary:
The current behavior of HIP is that when --offload-device-only is set it
still bundles the outputs into a fat binary. Even though this is
different from how all the other targets handle this, it seems to be
dependned on by some tooling so just make it backwards compatible for
the `-fno-gpu-rdc` case.
2024-03-11 14:09:59 -05:00
Joseph Huber
4d1d1271b8 [HIP] Make the HIP default architecture use the enum value (#84400)
Summary:
This default enum is used in other places, we should keep it consistent.
2024-03-08 06:54:52 -06:00
Joseph Huber
3a56b5a27d [CUDA] Include PTX in non-RDC mode using the new driver (#84367)
Summary:
The old driver embed PTX in rdc-mode and so does the `nvcc` compiler.
The new drivers currently does not do this, so we should keep it
consistent in this case. This simply requires adding the assembler
output as an input to the offloading action that gets fed to fatbin.
2024-03-07 16:53:41 -06:00
Joseph Huber
433b71188d [CUDA] Correctly set CUDA default architecture (#84017)
Summary:
We already had a special CUDA default that better tracked the state as
of modern CUDA installations. Recently this was bumped up to `sm_52`,
but there was a location that wasn't respecting this. Fix that.
2024-03-05 22:03:00 -06:00
Kazushi (Jam) Marukawa
c240aca7a8 Revert "Reland "[clang][modules] Print library module manifest path." (#82160)"
This reverts commit 0c89427b99.
2024-03-05 01:34:48 +09:00
Fangrui Song
2b5cd8be3a [Driver] Remove InstallDir and getInstalledDir. NFC
Follow-up to #80527.
2024-03-03 18:10:46 -08:00
Mark de Wever
0c89427b99 Reland "[clang][modules] Print library module manifest path." (#82160)
This implements a way for the compiler to find the modules.json
associated with the C++23 Standard library modules.

This is based on a discussion in SG15. At the moment no Standard library
installs this manifest. #75741 adds this feature in libc++.

This reverts commit 82f424f766.

Disables the tests on non-X86 platforms as suggested.
2024-03-03 17:58:08 +01:00
Cyndy Ishida
0a518db99e [InstallAPI] Set InstallAPI as a standalone tool instead of CC1 action (#82293)
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-21 09:39:31 -08:00
Mikael Holmen
4a32a414ee [clang] Fix two gcc warnings about unused variables [NFC]
Without the fix gcc warns like
 ../../clang/lib/Sema/SemaDecl.cpp:2963:24: warning: unused variable 'SupA' [-Wunused-variable]
  2963 |   else if (const auto *SupA = dyn_cast<SuppressAttr>(Attr))
       |                        ^~~~
and
 ../../clang/lib/Driver/Driver.cpp:4192:17: warning: unused variable 'IAA' [-Wunused-variable]
  4192 |       if (auto *IAA = dyn_cast<InstallAPIJobAction>(Current)) {
       |                 ^~~

Remove the unused variables and change the "dyn_cast"s into "isa"s.
2024-02-15 10:31:59 +01:00
Cyndy Ishida
09e98950bf [clang][InstallAPI] Introduce basic driver to write out tbd files (#81571)
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-02-13 18:52:11 -08:00
ZijunZhaoCCK
fbded6663f [Driver] Check the environment version except wasm case. (#80783)
Add isWasm() check for here:
https://github.com/llvm/llvm-project/pull/78655#issuecomment-1928075569
2024-02-06 15:40:27 -08:00
ZijunZhaoCCK
34c4a0fa2b [Driver] Report invalid target triple versions for all environment types. (#78655)
Followup for https://github.com/llvm/llvm-project/pull/75373

1. Make this feature not just available for android, but everyone.
2. Correct some target triples.
3. Add opencl to the environment type list.
2024-02-04 16:42:15 -08:00
Sean Fertile
f1b1611148 [LTO] Fix fat-lto output for -c -emit-llvm. (#79404)
Fix and add a test case for combining '-ffat-lto-objects -c -emit-llvm'
options and fix a spelling mistake in same test.
2024-01-25 10:50:59 -05:00
Kazu Hirata
5404a3792e [Driver] Use StringRef::consume_front (NFC) 2024-01-24 00:27:33 -08:00
Aaron Ballman
82f424f766 Revert "[clang][modules] Print library module manifest path. (#76451)"
This reverts commit a301fb1101.

The changes caused failures like:
https://lab.llvm.org/buildbot/#/builders/91/builds/22189
2024-01-23 07:06:07 -05:00
Sean Fertile
62eb65b36f [FatLTO] output of -ffat-lto-objects -S should be assembly. (#79041)
Fat lto with -c compiles to an object file with the IR embedded in a
section of the object, the combination of fat-lto with -S should then
produce an assembly file equivalent of that. The IR output can still be
genreated by using both -S and -emit-llvm.
2024-01-22 21:41:19 -05:00
Mark de Wever
a301fb1101 [clang][modules] Print library module manifest path. (#76451)
This implements a way for the compiler to find the modules.json
associated with the C++23 Standard library modules.

This is based on a discussion in SG15. At the moment no Standard library
installs this manifest. #75741 adds this feature in libc++.
2024-01-22 19:42:32 +01:00
Natalie Chouinard
ce519b59b7 [HLSL][SPIR-V] Add support -fspv-target-env opt (#78611)
Add the -fspv-target-env option to the clang-dxc compatibility driver to
specify the SPIR-V target environment, which is propagated to the target
Triple.
2024-01-22 09:54:54 -05:00
Kazu Hirata
10886a8f0a [Driver] Use SmallString::operator std::string (NFC) 2024-01-19 22:24:09 -08:00
Jonas Devlieghere
a4fe6a1838 [clang] Upstream XROS support in Clang (#78392)
Upstream XROS support in the clang frontend and driver.
2024-01-17 21:09:15 -08:00
ZijunZhaoCCK
f6dbd4cc5f Make clang report invalid target versions. (#75373)
Clang always silently ignores garbage target versions and this makes
debug harder. So clang will report when target versions are invalid.
2024-01-08 20:46:05 -08:00
Wang Pengcheng
705065f365 [RISCV][NFC] Use RISCVISAInfo instead of string comparison (#76387)
The arch string may not start with rv32/rv64 if we have supported
profiles in `-march`.
2023-12-28 13:00:43 +08:00
Kazu Hirata
f3dcc2351c [clang] Use StringRef::{starts,ends}_with (NFC) (#75149)
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-12-13 08:54:13 -08:00
Kazu Hirata
cc4ecfd68b [ADT] Rename SmallString::{starts,ends}with to {starts,ends}_with (#74916)
This patch renames {starts,ends}with to {starts,ends}_with for
consistency with std::{string,string_view}::{starts,ends}_with in
C++20.  Since there are only a handful of occurrences, this patch
skips the deprecation phase and simply renames them.
2023-12-09 14:28:45 -08:00
Philip Reames
a93cacf9b0 [clang driver] Remove a bit of redundant flang specific code [nfc]
getOptionVisibilityMask already returns options::FlangOption in FlangMode,
so this assignment is entirely pointless.
2023-12-06 14:20:36 -08:00
Natalie Chouinard
6c320b434d [SPIRV] Add -spirv option to DXC driver (#65989)
Add an option to target SPIR-V to the clang-dxc driver, which sets the
target triple's architecture to logical SPIR-V. This does not yet
address the need for a Vulkan target environment in the triple, tracked
in Issue #70051.

Depends on #70330
2023-11-01 13:41:30 -04:00
Kazu Hirata
f40ed134b4 [Driver] Use StringSet::contains (NFC) 2023-10-25 20:14:35 -07:00
Yaxun (Sam) Liu
e880e8aedb Let clang-cl support CUDA/HIP (#68921)
clang-cl is a driver mode that accepts options of MSVC cl.exe as a
drop-in replacement for cl.exe. Currently clang-cl accepts mixed clang
style options and cl style options. To let clang-cl accept a clang-style
option, just need to add visibility CLOption to that option.

Currently nvcc can pass cl style options to cl.exe, which allows nvcc to
compile C++ and CUDA programs with mixed nvcc and cl style options. On
the other hand, clang cannot use mixed clang and cl style options to
compile CUDA/HIP programs.

This patch add visibility CLOption to options needed to compile CUDA/HIP
programs. This allows clang-cl to compile CUDA/HIP programs with mixed
clang and cl style options.
2023-10-19 11:56:56 -04:00
Alex Voicu
9a408588d1 [HIP][Clang][Driver] Add Driver support for hipstdpar
This patch adds the Driver changes needed for enabling HIP parallel algorithm offload on AMDGPU targets. What this change does can be summed up as follows:

- add two flags, one for enabling `hipstdpar` compilation, the second enabling the optional allocation interposition mode;
- the flags correspond to new LangOpt members;
- if we are compiling or linking with --hipstdpar, we enable HIP; in the compilation case C and C++ inputs are treated as HIP inputs;
- the ROCm / AMDGPU driver is augmented to look for and include an implementation detail forwarding header; we error out if the user requested `hipstdpar` but the header or its dependencies cannot be found.

Tests for the behaviour described above are also added.

Reviewed by: MaskRay, yaxunl

Differential Revision: https://reviews.llvm.org/D155775
2023-10-03 13:14:46 +01:00
David Spickett
99594ba30a [clang][ARM] Enable --print-supported-extensions for ARM (#66083)
```
$ ./bin/clang --target=arm-linux-gnueabihf --print-supported-extensions
<...>
All available -march extensions for ARM

        crc
        crypto
        sha2
        aes
        dotprod
<...>
```

This follows the format set by RISC-V and AArch64. As for AArch64, ARM
doesn't have versioned extensions like RISC-V does. So there is only 1
column, which contains the name.

Any extension without a "feature" is hidden as these cannot be used with
-march.
2023-09-13 10:10:57 +01:00
Maciej Gabka
9272aa9d08 [Driver] Do not generate error about unsupported target specific options when there is no compiler jobs
The upstream commit: https://reviews.llvm.org/D151590
added a new flag to mark target specific compiler options.

The side effect of it was that in cases when -### or -v is used without any
input file, clang started emitting an error.
It happened like that becasue there is no compilation actions created
which could consume/verify these target specific options.

This patch changes that error to a warning about unused option in situations
when there is no actions and still generates error when there are actions.

Fix for https://github.com/llvm/llvm-project/issues/64958

Differential Revision: https://reviews.llvm.org/D159361
2023-09-11 14:58:36 +00:00
David Spickett
90db4193f8 [clang][AArch64] Add --print-supported-extensions support (#65466)
This follows the RISC-V work done in
4b40ced4e5.

This uses AArch64's target parser instead. We just list the names,
without the "+" on them, which matches RISC-V's format.

```
$ ./bin/clang -target aarch64-linux-gnu --print-supported-extensions
clang version 18.0.0 (https://github.com/llvm/llvm-project.git 154da8aec20719c82235a6957aa6e461f5a5e030)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: <...>
All available -march extensions for AArch64

        aes
        b16b16
        bf16
        brbe
        crc
        crypto
        cssc
        <...>
```

Since our extensions don't have versions in the same way there's just
one column with the name in.

Any extension without a feature name (including the special "none") is
not listed as those cannot be passed to -march, they're just for the
backend. For example the MTE extension can be added with "+memtag" but
MTE2 and MTE3 do not have feature names so they cannot be added to
-march.

This does not attempt to tackle the fact that clang allows invalid
combinations of AArch64 extensions, it simply lists the possible
options. It's still up to the user to ask for something sensible.

Equally, this has no context of what CPU is being selected. Neither does
the RISC-V option, the user has to be aware of that.

I've added a target parser test, and a high level clang test that checks
RISC-V and AArch64 work and that Intel, that doesn't support this, shows
the correct error.
2023-09-11 08:25:02 +01:00
Fangrui Song
e9d454d1c1 [Driver] Report warnings for unclaimed TargetSpecific options for assembler input
This patch amends D151590 to not error for unlaimed TargetSpecific
options for `-x assembler` input files. This input type causes Driver to
construct tools::ClangAs (-fintegrated-as) or other assemblers (e.g.
tools::gnutools::Assembler) Their ConstructJobs methods, unlike
Clang::ConstructJobs, claim very few options. If an option is unclaimed,
it either leads to a -Wunused-command-line-argument warning or an error
(if `TargetSpecific` is set):
```
% clang '-###' --target=aarch64 -mbranch-protection=bti -c a.s
clang: error: unsupported option '-mbranch-protection=' for target 'aarch64'
```

It seems that downgrading the diagnostic to warning is most useful as
many users use CFLAGS even for `.s` files:
```
clang --target=aarch64 -mbranch-protection=bti -S a.c
clang --target=aarch64 -mbranch-protection=bti -c a.s
```

I decide not to suppress the warning so that
-Wunused-command-line-argument lovers still get a warning, and help
projects use proper ASFLAGS/CFLAGS/etc.

Note: `-mbranch-protection=bti a.S` currently has no warning as `-x assembler-with-cpp`
instructs clangDriver to select tools::Clang and claim most options.

Revert D159010 to demonstrate that we emit a warning for -mfpmath= for
`-x assembler` input.

Modify my AIX cleanup cd18efb61d to
add an err_drv_unsupported_opt_for_target.

Reviewed By: thesamesam

Differential Revision: https://reviews.llvm.org/D159173
2023-08-31 23:26:46 -07:00
4vtomat
4b40ced4e5 [RISCV] Add --print-supported-extensions support
This revision supports --print-supported-extensions,
it prints out all of the extensions and corresponding version supported.

Reviewed By: craig.topper, kito-cheng

Differential Revision: https://reviews.llvm.org/D146054
2023-08-31 00:24:06 -07:00
Brad Smith
5165593a97 Delete CloudABI support
After this D108637 and with FreeBSD -current and now 14 dropping support for
CloudABI I think it is time to consider deleting the CloudABI support.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D158920
2023-08-29 22:57:30 -04:00
Shoaib Meenai
b6a1473f97 [driver] Refactor getRuntimePaths. NFC
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-28 17:34:50 -07:00
Brad Smith
2a105105a6 Delete Ananas support
After looking at this further I think the Ananas support should be removed.

They stopped using Clang. There have never been any releases either; as in
source only, and the backend is not maintained.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D158946
2023-08-27 18:43:23 -04:00
Fangrui Song
aa9d7d1cd0 [Driver] Remove Myriad.cpp
I am trying to clean up GCCInstallationDetector::init and noticed that
Myriad.cpp is the only toolchain using `ExtraTripleAliases`. This is a
little overhead, but I figured that Myriad.cpp is unused.
Its sanitizer runtime part was removed in 2021 by D104279. It seems time
to retire it.

Reviewed By: waltl

Differential Revision: https://reviews.llvm.org/D158706
2023-08-24 18:44:45 -07:00
Brad Smith
e75f240a04 [Driver] Cleanup last vestiges of Minix / Contiki support
Cleanup what is left after D158461.

Reviewed by: MaskRay

Differential Revision:
2023-08-24 20:04:40 -04:00
Fangrui Song
3515409012 [Driver] Remove unlikely-working Minix.cpp and Contiki.cpp
Minix is a ToolChain that was added back in 2010 but has been
unmaintained with no test. The constructed command line contains
/usr/gnu/include/c++/4.4.3 and CompilerRT-Generic which are unlikely
working for a long time.

Contiki is a barebone ToolChain that just enables safestack.
This doesn't justify a new ToolChain.

Remove these ToolChains so that their target triples will use Generic_ELF instead.

If these developers feel like having an updated llvm-project is useful,
fixing other build issues and adding a new ToolChain is much better than
having the unmaintained ToolChains.

Reviewed By: brad

Differential Revision: https://reviews.llvm.org/D158461
2023-08-23 23:58:38 -07:00