summaryrefslogtreecommitdiff
path: root/clang/lib/Driver/Types.cpp
AgeCommit message (Collapse)Author
2025-03-12[Clang][OpenCL] Fix Missing `-fdeclare-opencl-builtins` When Using ↵Shilei Tian
`--save-temps` (#131017) When compiling an OpenCL program directly with `clang` using `--save-temps`, an error may occur if the program contains OpenCL builtins: ``` test.cl:3:21: error: use of undeclared identifier 'get_global_id' 3 | unsigned int id = get_global_id(0); | ^ ``` This happens because the driver does not add `-fdeclare-opencl-builtins` when the input type is `TY_PP_CL`. This PR fixes the issue.
2024-11-15[Driver] Remove unused includes (NFC) (#116316)Kazu Hirata
Identified with misc-include-cleaner.
2024-10-28Remove support for RenderScript (#112916)Aaron Ballman
See https://discourse.llvm.org/t/rfc-deprecate-and-eventually-remove-renderscript-support/81284 for the RFC
2024-08-16Reland "[flang][cuda][driver] Make sure flang does not switch to cc1 (#104613)"Valentin Clement (バレンタイン クレメン)
Flang is switch to cc1 when we use `-x cuda`. Make sure we can use fc1 with cuda fortran input. The current pipeline will fail at MLIR level for the moment.
2024-08-16Revert "Reland "[flang][cuda][driver] Make sure flang does not switch to cc1 ↵Valentin Clement
(#104613)"" This reverts commit af81b4f9f98f6ac89f876637f065d6525e374468.
2024-08-16Reland "[flang][cuda][driver] Make sure flang does not switch to cc1 (#104613)"Valentin Clement (バレンタイン クレメン)
Flang is switch to cc1 when we use `-x cuda`. Make sure we can use fc1 with cuda fortran input. The current pipeline will fail at MLIR level for the moment.
2024-08-16Revert "[flang][cuda][driver] Make sure flang does not switch to cc1" (#104632)Valentin Clement (バレンタイン クレメン)
Reverts llvm/llvm-project#104613
2024-08-16[flang][cuda][driver] Make sure flang does not switch to cc1 (#104613)Valentin Clement (バレンタイン クレメン)
Flang is switch to cc1 when we use `-x cuda`. Make sure we can use fc1 with cuda fortran input. The current pipeline will fail at MLIR level for the moment. #104483
2024-08-08[clang][driver][clang-cl] Fix unused argument warning for `/std:c++20` for ↵Sharadh Rajaraman
precompiled module inputs to `clang-cl` (#99300) Relates to #98761: `-fmodule-file` requires `/std:c++20` or greater, but passing that option results in an unused argument warning. This resolves that.
2024-01-23[Clang][Driver] Fix `--save-temps` for OpenCL AoT compilation (#78333)Shilei Tian
We can directly call `clang -c -x cl -target amdgcn -mcpu=gfx90a test.cl -o test.o` to compile an OpenCL kernel file. However, when `--save-temps` is enabled, it doesn't work because the preprocessed file (`.i` file) is taken as C source file when it is fed to the front end, thus causing compilation error because those OpenCL keywords can't be recognized. This patch fixes the issue.
2023-08-15[Driver][DXC] Handle -Fo and -Fc flagsJustin Bogner
This splits the backend and assemble actions for HLSL inputs and handles the options in GetNamedOutputPath instead of aliasing `-o`. This also moves how we default to emitting asm to stdout, since doing this in the HLSL toolchain rather than the driver pollutes how the clang driver works as well. When both options are specified we disable collapsing the assemble action and attempt to generate both outputs. Note that while this handles the driver aspects, we can't actually run in that mode for now since -cc1as doesn't understand DXIL as an input yet. Differential Revision: https://reviews.llvm.org/D157582
2023-03-12[Flang] Allow compile *.f03, *.f08 fileShao-Ce SUN
Fix issue [#61260](https://github.com/llvm/llvm-project/issues/61260) Reviewed By: awarzynski Differential Revision: https://reviews.llvm.org/D145845
2023-03-12Revert "[Flang] Allow compile *.f03, *.f08 file"Shao-Ce SUN
The test will fail in the MSVC environment. This reverts commit 171794de533b400edb47f0e6df4375a7ae052fc8.
2023-03-11[Flang] Allow compile *.f03, *.f08 fileShao-Ce SUN
Fix issue [#61260](https://github.com/llvm/llvm-project/issues/61260) Reviewed By: awarzynski Differential Revision: https://reviews.llvm.org/D145845
2023-01-11[HIP] Use .hipi as preprocessor output extensionYaxun (Sam) Liu
so that clang can recognize it and handle it automatically without -x hip-cpp-output. Reviewed by: Artem Belevich Differential Revision: https://reviews.llvm.org/D141437
2022-09-20[HLSL] Pass flags to cc1 based on languageChris Bieneman
Having the flags only pass through if you're using the dxc-driver means that the clang driver doesn't work for HLSL, which is undesirable. This change switches to instead passing flags based on the language mode similar to how OpenCL does it. This allows the clang driver to be used for HLSL source files as well. Reviewed By: python3kgae Differential Revision: https://reviews.llvm.org/D133958
2022-09-08[clang] Use std::size instead of llvm::array_lengthofJoe Loser
LLVM contains a helpful function for getting the size of a C-style array: `llvm::array_lengthof`. This is useful prior to C++17, but not as helpful for C++17 or later: `std::size` already has support for C-style arrays. Change call sites to use `std::size` instead. Leave the few call sites that use a locally defined `array_lengthof` that are meant to test previous bugs with NTTPs in clang analyzer and SemaTemplate. Differential Revision: https://reviews.llvm.org/D133520
2022-05-05[flang][driver] Add support for consuming LLVM IR/BC filesAndrzej Warzynski
This change makes sure that Flang's driver recognises LLVM IR and BC as supported file formats. To this end, `isFortran` is extended and renamed as `isSupportedByFlang` (the latter better reflects the new functionality). New tests are added to verify that the target triple is correctly overridden by the frontend driver's default value or the value specified with `-triple`. Strictly speaking, this is not a functionality that's new in this patch (it was added in D124664). This patch simply enables us to write such tests and hence I'm including them here. Differential Revision: https://reviews.llvm.org/D124667
2022-04-22[C++20][Modules][Driver][HU 1/N] Initial handling for ↵Iain Sandoe
-xc++-{system,user}-header. This adds file types and handling for three input types, representing a C++20 header unit source: 1. When provided with a complete pathname for the header. 2. For a header to be looked up (by the frontend) in the user search paths 3. For a header to be looked up in the system search paths. We also add a pre-processed file type (although that is a single type, regardless of the original input type). These types may be specified with -xc++-{user,system,header-unit}-header xxxx. These types allow us to disambiguate header unit jobs from PCH ones, and thus we handle these differently from other header jobs in two ways: 1. The job construction is altered to build a C++20 header unit (rather than a PCH file, as would be the case for other headers). 2. When the type is "user" or "system" we defer checking for the file until the front end is run, since we need to look up the header in the relevant paths which are not known at this point. Differential Revision: https://reviews.llvm.org/D121588
2022-04-15[HLSL][clang][Driver] Support target profile command line option.Xiang Li
The target profile option(/T) decide the shader model when compile hlsl. The format is shaderKind_major_minor like ps_6_1. The shader model is saved as llvm::Triple is clang/llvm like dxil-unknown-shadermodel6.1-hull. The main job to support the option is translating ps_6_1 into shadermodel6.1-pixel. That is done inside tryParseProfile at HLSL.cpp. To integrate the option into clang Driver, a new DriverMode DxcMode is created. When DxcMode is enabled, OSType for TargetTriple will be forced into Triple::ShaderModel. And new ToolChain HLSLToolChain will be created when OSType is Triple::ShaderModel. In HLSLToolChain, ComputeEffectiveClangTriple is overridden to call tryParseProfile when targetProfile option is set. To make test work, Fo option is added and .hlsl is added for active -xhlsl. Reviewed By: beanz Differential Revision: https://reviews.llvm.org/D122865 Patch by: Xiang Li <python3kgae@outlook.com>
2022-01-26[clang] Add an extract-api driver optionZixu Wang
This is the initial commit for the clang-extract-api RFC <https://lists.llvm.org/pipermail/cfe-dev/2021-September/068768.html> Add a new driver option `-extract-api` and associate it with a dummy (for now) frontend action to set up the initial structure for incremental works. Differential Revision: https://reviews.llvm.org/D117809
2022-01-26Revert "Rename llvm::array_lengthof into llvm::size to match std::size from ↵Benjamin Kramer
C++17" This reverts commit ef8206320769ad31422a803a0d6de6077fd231d2. - It conflicts with the existing llvm::size in STLExtras, which will now never be called. - Calling it without llvm:: breaks C++17 compat
2022-01-26Rename llvm::array_lengthof into llvm::size to match std::size from C++17serge-sans-paille
As a conquence move llvm::array_lengthof from STLExtras.h to STLForwardCompat.h (which is included by STLExtras.h so no build breakage expected).
2021-09-30[clang] Remove duplication in types::getCompilationPhases()Nico Weber
Call Driver::getFinalPhase() instead of duplicating it. https://reviews.llvm.org/D65993 added the duplication, then 02e35832c301e maded it more obviously a copy of getFinalPhase(). The only difference is that getCompilationPhases() used to use LastPhase / IfsMerge where getFinalPhase() used Link. Adapt getFinalPhase() to return IfsMerge when needed. No intentional behavior change. Differential Revision: https://reviews.llvm.org/D110770
2021-07-25[Preprocessor] Implement -fminimize-whitespace.Michael Kruse
This patch adds the -fminimize-whitespace with the following effects: * If combined with -E, remove as much non-line-breaking whitespace as possible. * If combined with -E -P, removes as much whitespace as possible, including line-breaks. The motivation is to reduce the amount of insignificant changes in the preprocessed output with source files where only whitespace has been changed (add/remove comments, clang-format, etc.) which is in particular useful with ccache. A patch for ccache for using this flag has been proposed to ccache as well: https://github.com/ccache/ccache/pull/815, which will use -fnormalize-whitespace when clang-13 has been detected, and additionally uses -P in "unify_mode". ccache already had a unify_mode in an older version which was removed because of problems that using the preprocessor itself does not have (such that the custom tokenizer did not recognize C++11 raw strings). This patch slightly reorganizes which part is responsible for adding newlines that are required for semantics. It is now either startNewLineIfNeeded() or MoveToLine() but never both; this avoids the ShouldUpdateCurrentLine workaround and avoids redundant lines being inserted in some cases. It also fixes a mandatory newline not inserted after a _Pragma("...") that is expanded into a #pragma. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D104601
2021-03-24[OpenCL] Added distinct file extension for C++ for OpenCL.Anastasia Stulova
Files compiled with C++ for OpenCL mode can now have a distinct file extension - clcpp, then clang driver picks the compilation mode automatically (-x clcpp) without the use of -cl-std=clc++. Differential Revision: https://reviews.llvm.org/D96771
2021-02-22[OpenCL] Add builtin declarations by default.Anastasia Stulova
This change enables the builtin function declarations in clang driver by default using the Tablegen solution along with the implicit include of 'opencl-c-base.h' header. A new flag '-cl-no-stdinc' disabling all default declarations and header includes is added. If any other mechanisms were used to include the declarations (e.g. with -Xclang -finclude-default-header) and the new default approach is not sufficient the, `-cl-no-stdinc` flag has to be used with clang to activate the old behavior. Tags: #clang Differential Revision: https://reviews.llvm.org/D96515
2021-02-22[flang][driver] Add -Xflang and make -test-io a frontend-only flangAndrzej Warzynski
This patch adds support for `-Xflang` in `flang-new`. The semantics are identical to `-Xclang`. With the addition of `-Xflang`, we can modify `-test-io` to be a compiler-frontend only flag. This makes more sense, this flag is: * very frontend specific * to be used for development and testing only * not to be exposed to the end user Originally we added it to the compiler driver, `flang-new`, in order to facilitate testing. With `-Xflang` this is no longer needed. Tests are updated accordingly. Differential Revision: https://reviews.llvm.org/D96864
2020-10-24[Flang][Driver] Add infrastructure for basic frontend actions and file I/OCaroline Concatto
This patch introduces the dependencies required to read and manage input files provided by the command line option. It also adds the infrastructure to create and write to output files. The output is sent to either stdout or a file (specified with the `-o` flag). Separately, in order to be able to test the code for file I/O, it adds infrastructure to create frontend actions. As a basic testable example, it adds the `InputOutputTest` FrontendAction. The sole purpose of this action is to read a file from the command line and print it either to stdout or the output file. This action is run by using the `-test-io` flag also introduced in this patch (available for `flang-new` and `flang-new -fc1`). With this patch: ``` flang-new -test-io input-file.f90 ``` will read input-file.f90 and print it in the output file. The `InputOutputTest` frontend action has been introduced primarily to facilitate testing. It is hidden from users (i.e. it's only displayed with `--help-hidden`). Currently Clang doesn’t have an equivalent action. `-test-io` is used to trigger the InputOutputTest action in the Flang frontend driver. This patch makes sure that “flang-new” forwards it to “flang-new -fc1" by creating a preprocessor job. However, in Flang.cpp, `-test-io` is passed to “flang-new -fc1” without `-E`. This way we make sure that the preprocessor is _not_ run in the frontend driver. This is the desired behaviour: `-test-io` should only read the input file and print it to the output stream. co-authored-by: Andrzej Warzynski <andrzej.warzynski@arm.com> Differential Revision: https://reviews.llvm.org/D87989
2020-07-22accept 'clang++ -c a.pch -o a.o' to create PCH's object fileLuboš Luňák
This way should be the same like with a.pcm for modules. An alternative way is 'clang++ -c empty.cpp -include-pch a.pch -o a.o -Xclang -building-pch-with-obj', which is what clang-cl's /Yc does internally. Differential Revision: https://reviews.llvm.org/D83716
2020-06-08Recognize *.hxx as a C++ header extension, like *.hpp.Sam McCall
Reviewers: kadircet Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D81366
2020-06-07[Driver] Simplify code. NFCI.Benjamin Kramer
2020-06-07Try to make msvc crash lessBenjamin Kramer
llvm-project\clang\lib\Driver\Types.cpp(44): fatal error C1001: An internal error has occurred in the compiler. (compiler file 'msc1.cpp', line 1518)
2020-06-07Put compilation phases from Types.def into a bit setBenjamin Kramer
This avoids a global constructor and is a bit more efficient for "contained" queries. No functionality change intended.
2020-04-09[CUDA] Accept -x cu to indicate language is CUDA, transfer CUDA language ↵ADRA
flag to header-file arguments Summary: * accept -x cu to indicate language is CUDA * transfer CUDA language flag to header-file arguments Differential Revision: https://reviews.llvm.org/D77451
2019-11-20[clang][IFS] Driver Pipeline: generate stubs after standard pipeline (3)Puyan Lotfi
Third Landing Attempt (dropping any linker invocation from clang driver): Up until now, clang interface stubs has replaced the standard PP -> C -> BE -> ASM -> LNK pipeline. With this change, it will happen in conjunction with it. So what when you build your code you will get an a.out or lib.so as well as an interface stub file. Example: clang -shared -o libfoo.so -emit-interface-stubs ... will generate both a libfoo.so and a libfoo.ifso. The .so file will contain the code from the standard compilation pipeline and the .ifso file will contain the ELF stub library. Note: For driver-test.c I've added -S in order to prevent any bot failures on bots that don't have the proper linker for their native triple. You could always specify a triple like x86_64-unknown-linux-gnu and on bots like x86_64-scei-ps4 the clang driver would invoke regular ld instead of getting the error 'Executable "orbis-ld" doesn't exist!' but on bots like ppc64be and s390x you'd get an error "/usr/bin/ld: unrecognised emulation mode: elf_x86_64" Differential Revision: https://reviews.llvm.org/D70274
2019-11-19Revert "[clang][IFS] Driver Pipeline: generate stubs after standard pipeline ↵Puyan Lotfi
(2)" This reverts commit ea8e02822341e2421b94167d828d3f224e767424.
2019-11-19[clang][IFS] Driver Pipeline: generate stubs after standard pipeline (2)Puyan Lotfi
Second Landing Attempt: Up until now, clang interface stubs has replaced the standard PP -> C -> BE -> ASM -> LNK pipeline. With this change, it will happen in conjunction with it. So what when you build your code you will get an a.out or lib.so as well as an interface stub file. Example: clang -shared -o libfoo.so -emit-interface-stubs ... will generate both a libfoo.so and a libfoo.ifso. The .so file will contain the code from the standard compilation pipeline and the .ifso file will contain the ELF stub library. Differential Revision: https://reviews.llvm.org/D70274
2019-11-19Revert "[clang][IFS] Driver pipeline: generate interface stubs after ↵Puyan Lotfi
standard pipeline." This reverts commit 58ea00b51fe9b011301484957556872fced7dd08. Test for .o + .ifs sidecar files is brittle and failing on bots. Reverting to unblock.
2019-11-19[clang][IFS] Driver pipeline: generate interface stubs after standard pipeline.Puyan Lotfi
Up until now, clang interface stubs has replaced the standard PP -> C -> BE -> ASM -> LNK pipeline. With this change, it will happen in conjunction with it. So what when you build your code you will get an a.out or lib.so as well as an interface stub file. Example: clang -shared -o libfoo.so -emit-interface-stubs ... will generate both a libfoo.so and a libfoo.ifso. The .so file will contain the code from the standard compilation pipeline and the .ifso file will contain the ELF stub library. Differential Revision: https://reviews.llvm.org/D70274
2019-10-30[clang][driver] Add basic --driver-mode=flang support for fortranPeter Waller
This patch adds a new Flang mode. When in Flang mode, the driver will invoke flang for fortran inputs instead of falling back to the GCC toolchain as it would otherwise do. The behaviour of other driver modes are left unmodified to preserve backwards compatibility. It is intended that a soon to be implemented binary in the flang project will import libclangDriver and run the clang driver in the new flang mode. Please note that since the binary invoked by the driver is under development, there will no doubt be further tweaks necessary in future commits. * Initial support is added for basic driver phases * -E, -fsyntax-only, -emit-llvm -S, -emit-llvm, -S, (none specified) * -### tests are added for all of the above * This is more than is supported by f18 so far, which will emit errors for those options which are unimplemented. * A test is added that ensures that clang gives a reasonable error message if flang is not available in the path (without -###). * Test that the driver accepts multiple inputs in --driver-mode=flang. * Test that a combination of C and Fortran inputs run both clang and flang in --driver-mode=flang. * clang/test/Driver/fortran.f95 is fixed to use the correct fortran comment character. Differential revision: https://reviews.llvm.org/D63607
2019-10-12[clang][IFS] Fixing spelling errors in interface-stubs OPT flag (NFC).Puyan Lotfi
This is just a long standing spelling error that was found recently. llvm-svn: 374638
2019-10-08[clang][ifs] Clang Interface Stubs ToolChain plumbing.Puyan Lotfi
Second Landing Attempt: This patch enables end to end support for generating ELF interface stubs directly from clang. Now the following: clang -emit-interface-stubs -o libfoo.so a.cpp b.cpp c.cpp will product an ELF binary with visible symbols populated. Visibility attributes and -fvisibility can be used to control what gets populated. * Adding ToolChain support for clang Driver IFS Merge Phase * Implementing a default InterfaceStubs Merge clang Tool, used by ToolChain * Adds support for the clang Driver to involve llvm-ifs on ifs files. * Adds -emit-merged-ifs flag, to tell llvm-ifs to emit a merged ifs text file instead of the final object format (normally ELF) Differential Revision: https://reviews.llvm.org/D63978 llvm-svn: 374061
2019-10-03Revert 373538 and follow-ups 373549 and 373552.Nico Weber
They break tests on (at least) macOS. llvm-svn: 373556
2019-10-02[clang][ifs] Clang Interface Stubs ToolChain plumbing.Puyan Lotfi
This patch enables end to end support for generating ELF interface stubs directly from clang. Now the following: clang -emit-interface-stubs -o libfoo.so a.cpp b.cpp c.cpp will product an ELF binary with visible symbols populated. Visibility attributes and -fvisibility can be used to control what gets populated. * Adding ToolChain support for clang Driver IFS Merge Phase * Implementing a default InterfaceStubs Merge clang Tool, used by ToolChain * Adds support for the clang Driver to involve llvm-ifs on ifs files. * Adds -emit-merged-ifs flag, to tell llvm-ifs to emit a merged ifs text file instead of the final object format (normally ELF) Differential Revision: https://reviews.llvm.org/D63978 llvm-svn: 373538
2019-09-24[static analyzer] Remove --analyze-autoJan Korous
Differential Revision: https://reviews.llvm.org/D67934 llvm-svn: 372680
2019-08-13[NFC][clang] Adding argument based Phase list filtering to getComplicationPhasesPuyan Lotfi
This patch removes usage of FinalPhase from anywhere outside of the scope where it is used to do argument handling. It also adds argument based trimming of the Phase list pulled out of the Types.def table. Differential Revision: https://reviews.llvm.org/D65993 llvm-svn: 368734
2019-07-31[NFC][clang] Refactor getCompilationPhases()+Types.def step 3.Puyan Lotfi
Second landing attempt: Changed TY_ObjCXXHeader to TY_PP_ObjCXXHeader to fix -xobjective-c++-header. This time I verified against preprocessor output. Dropping the 'u' entry and the entire Flags table from Types.def. Now it'll be a bit easier to tablegenify this. Differential Revision: https://reviews.llvm.org/D65308 llvm-svn: 367478
2019-07-30Revert "[NFC][clang] Refactor getCompilationPhases()+Types.def step 3."Sam McCall
This reverts commit d2254dbf21a3243233b75294ef901086199df1b9. This (unintentionally?) changed behavior, disallowing e.g. -x objective-c++-header llvm-svn: 367353
2019-07-30[NFC][clang] Refactor getCompilationPhases()+Types.def step 3.Puyan Lotfi
Dropping the 'u' entry and the entire Flags table from Types.def. Now it'll be a bit easier to tablegenify this. Differential Revision: https://reviews.llvm.org/D65308 llvm-svn: 367345