Commit Graph

619 Commits

Author SHA1 Message Date
Raul Tambre
b365385d66 Clang: Record Clang 6.0+ as fully supporting C++17 2020-06-13 11:29:55 +03:00
Raul Tambre
5d26efe38f Clang: Add final C++20 flag for Clang 11.0+
-std=c++20 superseded -std=c++2a in upstream Clang commit
24ad121582454e625bdad125c90d9ac0dae948c8.
2020-06-13 11:29:51 +03:00
Robert Maynard
95700be52d CUDA: Teach CMake that NVCC 11 supports cuda_std_17 2020-06-10 13:27:51 -04:00
Raul Tambre
0f88b7a592 CUDA: Fix Clang depfile flags when simulating MSVC
__compiler_clang() doesn't call __compiler_gnu() if we're emulating MSVC. Thus
CMAKE_DEPFILE_FLAGS_CUDA remains unset and compiling doesn't work, due to NVCC
dependency injection workaround in CMakeCUDAInformation.cmake, which triggers
for Ninja if they're not set.
Always set the depfile flags to fix this. Most other compiler modules seem to
do the same.
2020-06-08 07:54:51 -04:00
Osama Moharam
ef816610be ARMClang: allow fallback to -march and correct setting of --cpu flags
allows cmake to fall back to CMAKE_SYSTEM_ARCH in case CMAKE_SYSTEM_PROCESSOR is not in armclang -mcpu=list
additionally checks if CMAKE_SYSTEM_PROCESSOR belongs to armlink --cpu=list

Fixes: #19962
2020-06-03 16:58:31 +02:00
Brad King
007109b20f Merge topic 'armclang-armlink'
73fb6ac82b ARMClang: Add support for armlink

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4811
2020-06-03 06:10:14 -04:00
Osama Moharam
73fb6ac82b ARMClang: Add support for armlink
sets CMAKE_LIBRARY_PATH_FLAG to '--userlibpath=' when using armlink.

Fixes: #20761
2020-06-02 11:32:32 -04:00
Brad King
e76c11aa7c Merge branch 'backport-3.17-pch-no-Fortran' into pch-no-Fortran 2020-06-02 08:24:11 -04:00
Brad King
10c88c4337 PCH: Do not enable GNU or Intel PCH settings for Fortran
The PCH settings are shared by C and CXX languages but do not make sense
for Fortran.  In particular, `CMAKE_PCH_EXTENSION` should not be set
because it can overwrite the value set for C/C++ languages, which may
have a different compiler vendor than the Fortran compiler.

Fixes: #20752
2020-06-02 08:23:40 -04:00
Kyle Edwards
97fa63c09b ASM: Fix preprocessor definition flags for GNU 'as' tool
Fixes: #20780
2020-06-01 14:43:37 -04:00
Brad King
eb705b9531 Update links to gitlab.kitware.com repos to add -/
GitLab now uses a `/-/` component between the `group/project` part of
the URL and the `{issues,merge_requests,tree}` part so that it can
support `group/subgroup/project` with arbitrary depth.
2020-05-26 11:38:01 -04:00
Brad King
62816ff88c Merge topic 'fortran-preprocess-property'
3888de23da Ninja: Skip Fortran preprocessing if Fortran_PREPROCESS is OFF
66c4e87282 Ninja: Add helper functions to generate Fortran build
5cca1ec893 Ninja: Add helper functions to generate Fortran preprocess rule
b0a6161190 Fortran: Add Fortran_PREPROCESS property

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4659
2020-05-22 10:35:10 -04:00
Brad King
d8eee80e30 Merge branch 'backport-cuda-default-runtime' into cuda-default-runtime 2020-05-22 06:50:19 -04:00
Peter Hill
b0a6161190 Fortran: Add Fortran_PREPROCESS property
Issue: #18870
2020-05-21 11:44:14 -04:00
Robert Maynard
e55b21e24e CUDA: Compute CMAKE_CUDA_RUNTIME_LIBRARY default from toolchain
Since commit 0d0145138f (CUDA: Add abstraction for cuda runtime
selection, 2019-11-29, v3.17.0-rc1~83^2) we add CUDA runtime library
selection flags by default.

To maintain backwards compatibility the default CUDA runtime
library needs to be computed based on what libraries are found
on the initial compiler invocation. For example a toolchain
could establish initial flags that have all CUDA compilations
using the runtime version, and if we don't detect this we will
try to link to both the static and shared runtime.

Co-Author: Brad King <brad.king@kitware.com>
Fixes: #20708
2020-05-21 11:15:03 -04:00
Raul Tambre
5df21adf46 CUDA: Add support for Clang compiler
When crosscompiling we pass the sysroot.

We need to try various architecture flags. Clang doesn't automatically
select one that works.  First try the ones that are more likely to work
for modern installations:

* <=sm_50 is deprecated since CUDA 10.2, try sm_52 first for
          future compatibility.
* <=sm_20 is removed since CUDA 9.0, try sm_30.

Otherwise fallback to Clang's current default. Currently that's `sm_20`,
the lowest it supports.

Separable compilation isn't supported yet.

Fixes: #16586
2020-05-15 17:46:51 +03:00
Jiri Malak
d3640dbdd5 OpenWatcom: Organize and update C/C++ toolchain command lines 2020-04-28 09:36:05 -04:00
Jiri Malak
7aa9e89b1c OpenWatcom: Move non-Windows settings to Modules/Compiler
Restructure OpenWatcom toolchain support files to simplify adding of new
targets DOS, OS/2 and Linux including cross-compilation.
2020-04-28 09:36:04 -04:00
Brad King
dba914aa31 Merge topic 'ti-compilers-fix-cxx'
65c1320719 Compiler/TI: Fix C++ toolchain command-lines
4110d9dffb Compiler/TI: Fix linker command line for C++

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4627
2020-04-21 08:15:31 -04:00
Marc Chevrier
4248bb452a CUDA: Device linking use now link options
properties LINK_OPTIONS and INTERFACE_LINK_OPTIONS are propagated
to the device link step.

To control which options are selected for normal link and device link steps,
the $<DEVICE_LINK> and $<HOST_LINK> generator expressions can be used.

Fixes: #18265
2020-04-19 15:53:11 +02:00
Marc Chevrier
ec48e023f6 CUDA: Add information for LINKER: pattern translation 2020-04-19 15:04:56 +02:00
Alekseev Alexey
65c1320719 Compiler/TI: Fix C++ toolchain command-lines
Applied commit 5a0fc68312 (TI: Fix C toolchain command-lines, 2020-03-03) for C++:
Fix `armar` arguments.  Fix the linker `--map_file=` argument.
Enable response files.
2020-04-18 12:12:20 +03:00
Alekseev Alexey
4110d9dffb Compiler/TI: Fix linker command line for C++
Just like C, libraries must be in the last part of the linker.
Commit 89317915d9 (Compiler/TI: Pass libraries as last part to linker, 2016-06-02)
2020-04-18 12:12:20 +03:00
Raul Tambre
60e60b9201 GNU: Disable depfiles in try-compile mode only for GCC
Disabling them causes issues for Clang's CUDA frontend.
Since this is a GCC bug, simply check for GCC.
2020-04-07 09:33:25 -04:00
Raul Tambre
5f02add366 CUDA: Refactor PTX compilation flag into compiler modules 2020-04-07 09:33:25 -04:00
Raul Tambre
25439c7d62 Clang: Refactor CXX standard flags into __compiler_clang_cxx_standards()
These standard flags are the same for CXX, OBJCXX and CUDA.
Refactor them into a single macro to reduce duplication and so we can easily reuse them.

Updated bootstrap script to search in the general Clang module instead of the language-specific.
2020-04-07 09:33:09 -04:00
Brad King
85f87c9d40 Merge topic 'xl-cxx14'
46d9006efa XL: Add comment clarifying why we pretend it has full C++11/14 support
4aaa9ea96c XL: C++14 language level flags are only available on Linux

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4551
2020-04-01 10:42:19 -04:00
Brad King
46d9006efa XL: Add comment clarifying why we pretend it has full C++11/14 support
Since commit b0f46c48f6 (CompileFeatures: Now able to presume full
language level support, 2019-03-06, v3.15.0-rc1~265^2~1) we pretend that
the XL compiler has full C++11 and C++14 support so that projects
specifying granular features will at least get the corresponding
compiler mode.  This is a work around for our lack of a full feature
check table for this compiler that works in common cases.  Add a comment
explaining this.

Issue: #20521
2020-03-31 10:35:56 -04:00
Brad King
4aaa9ea96c XL: C++14 language level flags are only available on Linux
Since commit 458ea9d76c (XL: Add C++14 language level flags, 2019-04-15,
v3.15.0-rc1~226^2) we use `-qlanglvl=extended1y` for C++14 with XL 16.1.
However, that flag is only supported on a Linux host.

Issue: #20521
2020-03-31 10:35:56 -04:00
Brad King
f670435715 Merge topic 'pch-warn-invalid'
2ce08e5489 PCH: add an option to disable `-Winvalid-pch`

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4499
2020-03-27 08:03:30 -04:00
Cristian Adam
2ce08e5489 PCH: add an option to disable -Winvalid-pch
Fixes: #20295
2020-03-26 14:24:46 +01:00
Daan De Meyer
d8622fbd0f Modules: Collapse consecutive whitespace in strings 2020-03-23 21:34:17 +01:00
Brad King
eea528fd92 Merge topic 'gnu-as'
9728839b9e ASM: Fix executable link lines with GNU 'as' tool as CMAKE_ASM_COMPILER
5932f0be4f ASM: Fix depfile flags for GNU 'as' tool
0d0aa98c84 ASM: Record vendor-specific output matched to identify assembler
ee3ec27465 CMakeDetermineCompilerId: Set locale to C for vendor output match

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4460
2020-03-16 11:31:25 -04:00
Brad King
ba216592fc Merge topic 'cuda_language'
f75bea1071 CUDA: Abstract language flag to compiler modules

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4464
2020-03-13 10:43:57 -04:00
Brad King
9728839b9e ASM: Fix executable link lines with GNU 'as' tool as CMAKE_ASM_COMPILER
The GNU `as` tool does not know how to drive linking like the C compiler
does.  When using `as` as the compiler, use the linker directly.
2020-03-13 09:55:36 -04:00
Brad King
5932f0be4f ASM: Fix depfile flags for GNU 'as' tool
The GNU `as --help` shows `--MD <file>` as an option to generate depfiles
as needed by Ninja.  There is no `-MT <target>` flag but fortunately the
generated files automatically account for the `-o <obj>` flag.

Issue: #20426
2020-03-13 09:55:36 -04:00
Brad King
2ca34f0685 Merge topic 'apple-clang-flags-c++17'
a67f2d00d8 Apple Clang: add flags for C++17 standard

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4468
2020-03-12 09:33:19 -04:00
Marc Chevrier
a67f2d00d8 Apple Clang: add flags for C++17 standard 2020-03-12 08:09:12 -04:00
Raul Tambre
f75bea1071 CUDA: Abstract language flag to compiler modules
Separate this detail out into compiler-specific modules.
Required for Clang support, as it uses slightly different language flags.
2020-03-11 21:30:09 +02:00
Oliver Blasius
5a0fc68312 TI: Fix C toolchain command-lines
Fix `armar` arguments.  Fix the linker `--map_file=` argument.
Enable response files.
2020-03-09 12:02:20 -04:00
Brad King
210b0b99a9 XL: Fix using Fortran modules from their output directory
The XL Fortran compiler's `-qmoddir=` flag sets the module output
directory but does not add the directory to the search path for using
modules.  This is inconsistent with other compilers like the GNU Fortran
compiler's `-J` flag that does both.  In order to make these consistent,
add the module output directory with a `-I` flag on the XL Fortran
compiler so that it will be searched when using modules too.

This fixes our `FortranModules` test's coverage of submodules on
Ninja + XL.  That test places module files in a subdirectory that with
Ninja is not the current working directory when the compiler runs.

Fixes: #20400
2020-02-28 10:37:11 -05:00
Brad King
1d338dcf46 Merge topic 'cuda-non-device-link' into release-3.17
7da2c8c543 Merge branch 'backport-cuda-non-device-link'
738f3f23aa Ninja: Do not use nvcc response files with non-nvcc tools

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Robert Maynard <robert.maynard@kitware.com>
Merge-request: !4376
2020-02-25 08:54:45 -05:00
Brad King
64ed4f6f99 Merge topic 'cuda-non-device-link'
7da2c8c543 Merge branch 'backport-cuda-non-device-link'
738f3f23aa Ninja: Do not use nvcc response files with non-nvcc tools

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Robert Maynard <robert.maynard@kitware.com>
Merge-request: !4376
2020-02-25 08:54:45 -05:00
Brad King
7da2c8c543 Merge branch 'backport-cuda-non-device-link' 2020-02-24 13:34:13 -05:00
Francisco Facioni
738f3f23aa Ninja: Do not use nvcc response files with non-nvcc tools
Since commit d91b5a72cd (Ninja: Add support for CUDA nvcc response
files, 2019-05-30, v3.15.0-rc1~8^2) we use NVCC's `--options-file`
option to avoid long link command lines via a response file.  However,
for non-device linking the host tools are used and the option does not
make sense.  Update the logic to use `--options-file` only for device
linking.  Linking with the host tools already has its own logic for
response files.

Fixes: #19954
2020-02-24 13:31:33 -05:00
Sergey Larin
5c6d6ec27c PCH: Clang: Update PCH usage flags to include original header
Add an additional include flag to PCH usage command line to fix programs
that rely on `compile_commands.json` file. Pass it to the preprocessor
directly to avoid compiler driver to change it to '-include-pch'.

When preprocessor is requested to preprocess a file, it tries to get
the original filename from '.pch' and uses that file for preprocessing.
CMake generates a '.pch' file from the '.hxx' file by passing an empty
'.cxx' source file to the compiler as a compilation unit and the header
file with the '-include' flag. After that, compiler puts compilation
unit filename in the '.pch' as the original filename.

However, CMake build system uses empty file as the source file and
passes the header file using '-include-pch' flag. As a result, Clang
uses the wrong file for preprocessing and produces the corrupted
preprocessed file.

Fixes: #20355
Signed-off-by: Sergey Larin <cerg2010cerg2010@mail.ru>
2020-02-24 10:53:39 -05:00
Brad King
193352e420 Merge topic 'clang-tidy-driver-mode'
f6f4eb0907 clang-tidy: Add driver mode argument

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4208
2020-01-28 11:01:19 -05:00
Brad King
571205fb6b Merge topic 'QNX_CMAKE_SYSROOT'
32a6ab1f3b QNX: Add support for CMAKE_SYSROOT

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4277
2020-01-28 10:56:41 -05:00
Robert Maynard
0d0145138f CUDA: Add abstraction for cuda runtime selection
Fixes #17559
Replace our hard-coded default of cudart=static with a first-class abstraction to select the runtime library from an enumeration of logical names.
2020-01-27 16:02:26 -05:00
Stephen Kelly
32a6ab1f3b QNX: Add support for CMAKE_SYSROOT
QCC is a wrapper around GCC, but it is not a fully transparent wrapper.
Some compile options need to be passed to GCC using a `-Wc` option.

QCC does not support --sysroot, so setting CMAKE_SYSROOT in a toolchain
file currently does not work.  This means that it is likely that no one
is setting CMAKE_SYSROOT in existing QNC toolchain files.  Override the
GCC option for sysroot in the QCC.cmake file with -Wc,-isysroot.

This exposes a further issue in that the QNX SDK does not follow the
same architectural folder structure as linux uses.  That is, on linux
systems, architecture-specific libraries might be in

    <sysroot>/usr/lib/<arch>

such as

    /usr/lib/x86_64-linux-gnu/libcurl.so

CMake models this by suffixing the <arch> onto lib directories when
searching for libraries.

The QNX SDK is structured differently such that the <arch> should be
used as a prefix:

    <sysroot>/<arch>/usr/lib

such as

    <sysroot>/x86_64/usr/lib/libcurl.so

Add a variable for platform configuration to set whether to prefix or
suffix the <arch> and set that in the QCC.cmake.

Use the directory structure of the QNX SDK to compute the <arch> from
the implicit library directories.  The assumption is that the arch will
be a single directory directly below the CMAKE_SYSROOT, below which the
usr/ prefix occurs.

It would not be appropriate to instruct users to make the <arch> part of
the sysroot when specified in the toolchain file because:

1.  That would be non-DRY - The QCC wrapper already determines the <arch>
    by the -V argument passed to the compiler, specified in the toolchain
    file as the CMAKE_C_COMPILER_TARGET variable.
2.  The includes in the QNX SDK are not below the <arch> directory.

So, the location of the <arch> in the full path is different on QNX
compared to, say an embedded linux platform, but the intent is the same.

Add documentation to recommend the use of CMAKE_SYSROOT in a QNX
toolchain file.

As the CMAKE_SYSROOT is always the same for QNX, it would be possible to
simply set it in QCC.cmake.  However, that would change behavior for
existing users as when CMAKE_SYSROOT is set, files/paths outside of the
CMAKE_SYSROOT do not get found.

The <arch> prefixing is only enabled in cmSearchPath.cxx if
CMAKE_SYSROOT is set.  This ensures that the user gets consistency in
the current state without CMAKE_SYSROOT, and gets better consistency
when using CMAKE_SYSROOT.
2020-01-27 14:04:56 -05:00