Commit Graph

372 Commits

Author SHA1 Message Date
Ben Boeckel
a971fcfde7 cmNinjaNormalTargetGenerator: use cmStrCat 2022-11-21 17:12:18 -05:00
Ben Boeckel
b7509d6bf8 cmNinjaNormalTargetGenerator: fix grammar in verbose comment 2022-11-21 17:09:33 -05:00
Evan Wilde
38c8807c5a Ninja: Avoid re-linking a Swift executable on every build
Swift doesn't emit swiftmodules for executables, so we shouldn't put it
in dependency graph.  Ninja sees the "missing" dependency and always
tries to rebuild/re-link the target.
2022-11-17 13:05:22 -05:00
Evan Wilde
e88509d0e8
Swift: Omit output-file-map when used as a linker
Swift is used as the linker for non-swift files because it needs to pull
files like swiftrt.o in when swift symbols are present to ensure that
the swift runtime is linked.

The swift driver uses clang as the underlying linker, which pulls in
crtbegin.o and friends when appropriate, so using Swift as a linker for
C/C++ libraries is fine.

The output-file-map was getting passed to all Swift invocations,
regardless of whether or not we generated one. This patch changes it so
that we only include the output-file-map in the Swift compiler
invocation if we have actually generated the file.
2022-10-28 16:44:26 -07:00
Evan Wilde
a9509cec7e Ninja: Fix mixed Swift/CXX library target generation
With how things were before, mixed Swift/C++ libraries would result in a
broken ninja file.  `cpp.cpp.o` was emitted by the compiler, but was
also being included in the `linkBuild.Outputs` list, so it was being
emitted by multiple targets.

The fix checks that the source language is Swift before adding it to the
list of additional outputs. If it is Swift, this isn't a problem. If it
isn't Swift, we don't include it in the list of outputs.

On the other side, the C++ file was also being passed as a source file,
which the Swift compiler can't compile. So we add the C++ object file as
an explicit dependency and the object file is then added to the list of
Swift sources.
2022-09-16 10:41:39 -04:00
Robert Maynard
6eda92d037 remove unused variable 2022-07-13 10:25:10 -04:00
Brad King
6cc417586e Ninja: Avoid duplicating /DEF: linker flag with MSVC tools
In commit 9a0d5a828a (Ninja: add /DEF: flag to linker call, 2012-03-10,
v2.8.8~22^2~7) the logic should have been added to `GetTargetFlags` in
place of the older logic in that method from commit 7cef36c628 (ENH: add
the ability to generate custom commands for a language that is not
supported by an IDE, 2004-10-21, v2.4.0~2655).

Fixes: #23570
2022-05-31 15:40:58 -04:00
Brad King
39dba8a244 cmLocalGenerator: Adopt AppendModuleDefinitionFlag method
Migrate from `cmCommonTargetGenerator::AddModuleDefinitionFlag`.
2022-05-31 15:40:35 -04:00
Robert Maynard
627ef4c1d0 Provide guidance when trying to use non-enabled language
Fixes #23463
2022-05-04 09:33:35 -04:00
Raul Tambre
4707ecbe6f CUDA: Support CMP0105 on Clang
Add link flags during the "device compile" step.

Enabled the relevant tests. The disable reasons regarding separable compilation
were outdated and the actual failure case was device link flags support.
2021-11-08 21:26:00 +02:00
Raul Tambre
15fde4c420 CUDA: Use local shorthands for variables in Clang device link code
Helps reduce wrapping of lines making code more readable.
2021-11-07 21:28:08 +02:00
Raul Tambre
cf7e68087d CUDA: Avoid unnecessary allocation and GetLinkLanguage()
There's no reason to allocate the cmNinjaLinkLineDeviceComputer on the heap.
We can also assume the link language as CUDA in cmLocalGenerator::GetDeviceLinkFlags().
2021-11-07 21:28:08 +02:00
Raul Tambre
5b0693411e CUDA: Ignore USE_WATCOM_QUOTE for device link rules
It's useless as the Watcom compiler isn't supported by NVCC.
2021-11-07 21:28:08 +02:00
Brad King
73b84db62d Ninja: Fix creation of Windows import library directory
Call `EnsureParentDirectoryExists` with our internal representation
of the path, not the representation quoted/encoded for Ninja.

Fixes: #22841
2021-11-03 10:08:48 -04:00
Marc Chevrier
cc56dc7468 Rename cmProp in cmValue 2021-09-21 17:14:04 +02:00
Brad King
6064c70469 Merge topic 'cuda_separable_clang_make'
3975678fcc CUDA/Clang: Simplify --register-link-binaries logic
0b1cea66cd CUDA/Clang: Fix separable compilation in non-root directories with Makefiles

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6400
2021-07-29 08:45:40 -04:00
root
3975678fcc CUDA/Clang: Simplify --register-link-binaries logic
Move the logic for appending cubin afterwards, so the check can simply be
empty().
With the Makefile generator the option is now at the front instead of being
intermixed with the actual bins.
2021-07-29 13:19:37 +03:00
Marc Chevrier
14e57e9637 LINK_WHAT_YOU_USE feature: externalize configuration
Currently, this feature is only supported on ELF platforms. So, the property
LINK_WHAT_YOU_USE will be ignored for other plateforms.
Moreover, flags and commands are now controled by CMake variables.

Fixes: #20174
2021-07-09 14:50:50 +02:00
Đoàn Trần Công Danh
d7159f9591 Ninja: Fix LINK_WHAT_YOU_USE link flag placement
Move `-Wl,--no-as-needed` from the `<FLAGS>` placeholder to
`<LINK_FLAGS>`, as it is in the Makefile generators.

Fixes: #22342
2021-06-25 08:45:47 -04:00
Bobby D Reynolds
ae108418ae Launchers: Support setting linker launchers
Fixes: #18316
2021-05-28 12:28:43 -04:00
Bobby D Reynolds
92c8b83641 cmNinjaNormalTargetGenerator: Fix "Language" rule variable
Fixes: commit 3bc63e99e4 (Refactor: Prepare Ninja generator for multi-config, 2019-11-14, v3.17.0-rc1~290^2~3)
2021-05-28 12:28:43 -04:00
Brad King
48471cfd18 cmNinjaNormalTargetGenerator: Factor out build event byproduct collection
This was left out of commit 68e5f92cad (cmGlobalNinjaGenerator: Factor
out custom command output collection, 2021-05-18).
2021-05-25 10:48:26 -04:00
Brad King
fb3a57575a cmNinjaTargetGenerator: Rename source file path lookup method for clarity
The `GetSourceFilePath` method is meant only for compiled sources, and
automatically handles converting it to a path for the Ninja build
manifest.  Rename the method to clarify both.
2021-05-25 10:48:25 -04:00
Brad King
ef553410e2 Ninja/Swift: Remove redundant calls to ConvertToNinjaPath
`GetSourceFilePath` already handles converting to a Ninja path.
2021-05-25 10:48:25 -04:00
Brad King
4419b944fd Merge topic 'ninja-multi-long-command-line-config'
ad08f93ee4 Ninja Multi-Config: Split long command lines by config

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6067
2021-05-03 10:53:50 -04:00
Kyle Edwards
ad08f93ee4 Ninja Multi-Config: Split long command lines by config
Fixes: #22123
2021-04-30 14:46:21 -04:00
Alexander Stein
c0a3317497 Ninja: Escape SONAME on linker command line
If the shared object name contains spaces, they need to be properly
escaped, or link command will fail.

This was already done for soname symlink creation in commit 13c92b4a30
(Ninja: Fix creation of library symlinks in folders with spaces,
2019-05-20, v3.15.0-rc1~87^2).

Fixes: #20331
2021-03-04 15:44:49 -05:00
Kyle Edwards
98805a11ce Ninja Multi-Config: Run POST_BUILD when BYPRODUCTS don't overlap
Fixes: #21252
2021-01-07 11:26:17 -05:00
Oleksandr Koval
209daa20b2 Code style: add missed explicit 'this->'
CMake uses explicit 'this->' style. Using custom clang-tidy check we can
detect and fix places where 'this->' was missed.
2021-01-05 14:32:36 +02:00
vvs31415
f808f27919 cmLocalGenerator::GetRuleLauncher: return cmProp 2020-11-02 13:07:46 -05:00
Raul Tambre
c63fe01835 CUDA: Clang separable compilation
For NVCC the compiler takes care of device linking when passed the "-dlink"
flag.
Clang doesn't support such magic and requires the buildsystem to do the work
that NVCC does behind the scenes.

The implementation is based on Bazel's device linking documentation:
7cabcdf073/third_party/nccl/build_defs.bzl.tpl (L259)

Closes: #20726
2020-09-24 15:19:54 -04:00
Robert Maynard
a020787a9b ISPC: Support generation for multiple instruction sets 2020-09-04 08:37:07 -04:00
Vitaly Stakhovsky
11425041f0 cmMakefile::GetDefinition: return cmProp 2020-09-02 07:27:32 -04:00
Brad King
06427db62c Merge topic 'ninja-multi-rsp-remove-path'
cdb50af2f6 Ninja: Restore shorter path to response files

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: alcroito <alexandru.croitor@qt.io>
Merge-request: !5094
2020-08-06 10:28:27 -04:00
Kyle Edwards
cdb50af2f6 Ninja: Restore shorter path to response files
In commit 99ed39b011 (Ninja Multi-Config: Make link response files
per-config, 2020-07-15, v3.17.4~3^2), we added the target directory to
the response file under the mistaken assumption that two different
targets with the same name could be in different directories. However,
this causes the path to the response file to be too long to fit on a
command line.  Take the path back out, while leaving in the per-config
split.

Fixes: #21050
2020-08-03 12:14:16 -04:00
Vitaly Stakhovsky
f37c14e930 Source: use cmNonempty() 2020-07-28 08:31:31 -04:00
Kyle Edwards
cfe2dc4721 Ninja: Remove parameter default for cmNinjaTargetDepends 2020-07-24 11:49:59 -04:00
Brad King
286411ed89 Merge topic 'ninja-multi-rsp'
99ed39b011 Ninja Multi-Config: Make link response files per-config

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5020
2020-07-17 08:49:37 -04:00
Kyle Edwards
99ed39b011 Ninja Multi-Config: Make link response files per-config
Fixes: #20961
2020-07-16 11:57:46 -04:00
Vitaly Stakhovsky
eaad8072ee cmNonempty: Convenience inlines to check for non-empty string 2020-07-14 15:18:59 -04:00
Brad King
a432b1075c Merge topic 'getdef-expand'
7ed8c9ebe3 cmMakefile: add GetDefExpandList() that splits value into std::vector

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4819
2020-06-02 08:02:24 -04:00
Brad King
fff14290d2 Merge topic 'cmprop'
b36d1bdd9d Single location for cmProp typedef

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4829
2020-06-02 08:00:55 -04:00
Vitaly Stakhovsky
b36d1bdd9d Single location for cmProp typedef 2020-06-01 08:54:20 -04:00
Vitaly Stakhovsky
7ed8c9ebe3 cmMakefile: add GetDefExpandList() that splits value into std::vector
Combines cmMakefile:GetDefinition() and cmExpandList()
2020-05-30 08:59:20 -04:00
Vitaly Stakhovsky
1e805f53f5 GetDefinition: avoid duplicate calls 2020-05-29 13:12:22 -04:00
Brad King
3fa3b7a402 cmGeneratorTarget: Remove default config from Get* methods
Ensure all call sites pass an explicit configuration.
2020-05-18 12:56:56 -04:00
Vitaly Stakhovsky
36aba01223 cmGeneratorTarget::GetProperty: return cmProp 2020-04-29 10:59:39 -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
Vitaly Stakhovsky
ef408dd232 cmState::GetTargetTypeName: return type is *cmProp 2020-03-19 08:55:03 -04:00
Kyle Edwards
87819db28d Merge branch 'backport-swift-ninja-multiconfig' into swift-ninja-multiconfig 2020-03-09 09:12:54 -04:00