Commit Graph

96 Commits

Author SHA1 Message Date
Kitware Robot
1772622772 LICENSE: Replace references to Copyright.txt with LICENSE.rst
```
git grep -lz 'Copyright.txt or https://cmake.org/licensing ' |
  while IFS= read -r -d $'\0' f ; do
    sed -i '/Copyright.txt or https:\/\/cmake.org\/licensing / {
              s/Copyright.txt/LICENSE.rst/
            }' "$f" ; done
```
2025-03-03 10:43:35 -05:00
Peter Kokot
dc7aabf4d0 Help: Document CMAKE_OBJDUMP variable 2025-01-24 10:43:18 -05:00
Brad King
1d4d4362d9 Merge topic 'remove-old-compatibility'
77f71ad4e2 Remove compatibility with CMake versions older than 3.5
fb1bd1d330 CMP0065: Remove support for OLD behavior
d9dd38cccf CMP0064: Remove support for OLD behavior
d88047c329 Remove compatibility with CMake versions older than 3.3
ac1a9cb160 CMP0063: Remove support for OLD behavior
36fffb673a CMP0062: Remove support for OLD behavior
789a7d73d4 CMP0061: Remove support for OLD behavior
3dc19e24cb CMP0060: Remove support for OLD behavior
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10210
2025-01-23 09:36:59 -05:00
Brad King
c283aafe62 CMP0057: Remove support for OLD behavior 2025-01-22 10:40:53 -05:00
Felipe Torrezan
cd9dd4cf8e IAR: decouple linker location from toolkit's bin dir
The implementation in commit 564d527c04 (IAR: Improve error message for
missing license, 2024-08-12, v3.31.0-rc1~234^2) failed for corner cases
in which symlinks were used from a location different from the one in
which the toolkit is shipped with (`<target>/bin`).

In this new implementation, the `<target>` architecture is taken solely
from the compiler NAME itself for all the supported languages and
forwarded to its respective BinUtils executable names
(e.g., `icc<target>`, `iasm<target>`, `a<target>`). This decouples the
location from the subdirectory in which they should be found.

Fixes: #26610
2025-01-21 19:21:06 +01:00
Brad King
137a2060bc BinUtils: Prefer llvm-mt over mt when compiling with Clang
The problem motivating commit 73d0d4e4b5 (BinUtils: Avoid llvm-mt
because it is missing 'mt' features we use, 2022-03-08, v3.23.0-rc3~7^2)
has been fixed in `llvm-mt` since LLVM/Clang 14.0.2.

Fixes: #26319
Issue: #23305
2024-09-25 09:12:27 -04:00
Felipe Torrezan
564d527c04
IAR: Improve error message for missing license
When using the IAR Compiler without a license, CMake issues a
fatal error message about a missing linker and librarian.
This message is misleading.

In the previous detection, CMakeFindBinUtils.cmake would rely
on information collected from try_compile() which depends on a
working license.

In the new detection scheme, the IAR BinUtils are automatically
detected regardless of an existing license, based solely on the
compiler's path.

The failure point will be when trying to compile a C or a CXX
source file, where there will be no CMAKE_${lang}_COMPILER_VERSION
available.

This change improves the resulting message for when trying to use
the compiler without a license.
2024-08-14 09:03:13 +02:00
Arkadiusz Skalski
053c2b3646 BinUtils: Avoid llvm-objcopy versions older than Clang 9
Prior to version 9.0, llvm-objcopy is missing the `--only-keep-debug`
option, which makes it incompatible with the GNU objcopy.
2024-02-06 09:06:37 -05:00
Marc Chevrier
96a953b1ed Add options to specify linker tool
Offer the capability, through variable `CMAKE_LINKER_TYPE`, as well as
the target property `LINKER_TYPE` to specify which linker must be used.

The implementation of this capability is specified by variables specific
to the language and linker type: `CMAKE_<LANG>_USING_LINKER_<TYPE>`.
Some definitions are provided as part of `CMake`.

For example, to select the `LLVM` linker rather than the standard one,
the type `LLD` should be specified through the variable `CMAKE_LINKER_TYPE`.
And, on `Apple`, `Linux` and some environments on `Windows`, the variable
`CMAKE_<LANG>_USING_LINKER_LLD` has value `-fuse-ld=lld`. And for `Windows`
environments  based on `MSVC`, where the linker is used directly, the tool
`lld-link.exe` will be used rather than `link.exe`.

Fixes: #19174, #24254, #24990
2023-10-13 11:52:35 +02:00
Brad King
26bf32cdc6 LLVMFlang: Add support for targeting MSVC ABI on Windows
The compiler does not yet support everything needed to integrate well
with the MSVC ABI, in particular for runtime library selection and debug
format selection.  Document them in FIXME comments and leave this
support undocumented by CMake for now.

Fixes: #24840
Inspired-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
2023-10-03 09:15:24 -04:00
ur4t
3c0f701990 MSVC: Run manifest tool with llvm-mt compatible arguments
Default use of `llvm-mt` was disabled by commit 73d0d4e4b5 (BinUtils:
Avoid llvm-mt because it is missing 'mt' features we use, 2022-03-08,
v3.23.0-rc3~7^2).  However, it can still be specified explicitly by the
user.  Due to limitations of LLVM's command line option parser, llvm-mt
does not support arbitrary manifest files following a single switch.

Issue: #23305
2023-08-16 09:52:57 -04:00
Marc Chevrier
8b0f0dc257 Apple Text Stubs (.tbd): various fixes
* ensure tapi lookup is applied only for concerned toolchains
* fix typos in tests

Fixes: #25182
2023-08-11 16:30:02 +02:00
Brad King
e4c53cdc15 BinUtils: Drop now-unnecessary cross-compiling workaround for Apple hosts
Previously we added fallbacks to `llvm-{ar,strip}` on Apple hosts
in case of cross-compiling because the `APPLE` platform variable
was not set w.r.t. the target platform.  The platform variable
has been fixed, so remove the fallbacks.

Issue: #23333
2023-06-07 07:02:20 -04:00
Felipe Torrezan
57f22c6a3d
IAR:Fix version detection for xlinkavr
- The comparison for minimum version for detecting the newer xlinkavr
  was encompassing V7.30.5, which uses the old `xlink` without target suffix.
2023-05-22 12:08:33 +02:00
Felipe Torrezan
7cd982faf4
IAR: Added support for IAR C/C++ Compiler for Microchip AVR 8.10+
- Added C17 support
- Added C++17 support
- Changed: IAR UBROF Linker (XLINK) suffixed with target architecture (xlinkavr)
2023-05-16 20:08:01 +02:00
Brad King
ac2562afb3 BinUtils: Avoid llvm-strip on Apple platforms
Since commit cf82300a63 (BinUtils: Clarify search logic and make it more
consistent, 2021-05-27, v3.21.0-rc1~119^2~2) we prefer `llvm-strip` over
`strip` when using Clang.  However, `llvm-strip` seems to produce
unusable binaries in cases involving chained fixups.  Prefer Apple's
`strip` over `llvm-strip` on `APPLE` platforms.

We still need to consider `llvm-strip` as a fallback as explained for
`llvm-ar` by commit fee36b7a78 (BinUtils: Restore llvm-ar fallback on
Apple platforms, 2022-03-15, v3.23.0-rc4~12^2).

Issue: #24601
2023-03-30 07:14:07 -04:00
Marc Chevrier
ede33f30cf Apple: Handle generation and comsuption of text-based stubs (.tbd files)
Fixes: #24123
2023-03-01 12:23:28 +01:00
Carlo Cabrera
a54e25b547 BinUtils: Avoid the 'ld.lld' ELF linker on Apple platforms
`ld.lld` is an ELF linker, so we should never set `CMAKE_LINKER` to this
when targeting an Apple platform.
2022-09-14 09:34:14 -04:00
Brad King
768d070180 Merge topic 'binutils-llvm-ar-apple'
fee36b7a78 BinUtils: Restore llvm-ar fallback on Apple platforms

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7077
2022-03-16 11:09:45 -04:00
Brad King
fee36b7a78 BinUtils: Restore llvm-ar fallback on Apple platforms
Since commit 29ea94e17c (BinUtils: Avoid llvm-ar on Apple platforms,
2022-03-03, v3.21.6~1^2) we do not consider `llvm-ar` at all on Apple
platforms.  However, there are existing cross-compiling use cases in
which the toolchain has `llvm-ar` but not `ar`.  Prior to the
re-ordering in commit cf82300a63 (BinUtils: Clarify search logic and
make it more consistent, 2021-05-27, v3.21.0-rc1~119^2~2), we preferred
`ar` and then `llvm-ar`.  Restore the original order for Apple.

Fixes: #23320
2022-03-16 10:46:11 -04:00
Brad King
28da3780c7 Merge topic 'binutils-llvm-mt'
73d0d4e4b5 BinUtils: Avoid llvm-mt because it is missing 'mt' features we use

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7054
2022-03-09 12:10:15 -05:00
Brad King
73d0d4e4b5 BinUtils: Avoid llvm-mt because it is missing 'mt' features we use
Since commit cf82300a63 (BinUtils: Clarify search logic and make it more
consistent, 2021-05-27, v3.21.0-rc1~119^2~2) we correctly prefer the
more-specific name `llvm-mt` over `mt` when using Clang.  However, the
`llvm-mt` tool does not yet support all the flags we need in the
implementation of `vs_link_{exe,dll}`.  Prefer plain `mt` for now.

Fixes: #23305
2022-03-08 11:48:30 -05:00
Brad King
4c68c59117 Merge topic 'binutils-llvm-ar-clang-macos'
29ea94e17c BinUtils: Avoid llvm-ar on Apple platforms

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7039
2022-03-04 08:52:06 -05:00
Brad King
29ea94e17c BinUtils: Avoid llvm-ar on Apple platforms
Since commit cf82300a63 (BinUtils: Clarify search logic and make it more
consistent, 2021-05-27, v3.21.0-rc1~119^2~2) we correctly prefer the
more-specific name `llvm-ar` over `ar` when using Clang.  However, on
Apple platforms, `llvm-ar` does not generate a symbol table that the
Apple linker accepts.  Fall back to `ar` on Apple platforms.

Fixes: #23269
2022-03-03 12:54:10 -05:00
Brad King
0712314f8e Merge topic 'IntelLLVM-no-xilink'
48f29b5805 IntelLLVM: Use MSVC linker with MSVC frontend variant

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6719
2021-11-11 10:45:20 -05:00
William R. Dieter
48f29b5805 IntelLLVM: Use MSVC linker with MSVC frontend variant
The Intel compiler (pre-LLVM) expected xilink.exe and had special logic to
set xilink.exe.  The newer LLVM-based compiler does not want xilink.exe.
link.exe works better for host code, and is the default, so change
the matching condition such that the old compiler matches (and gets
xilink.exe) and the new compiler gets the default link.exe it expects.

A better solution will be to use the compiler as the linker.  A future
change will switch to compiler as linker by default, but that fix needs
more validation.

Signed-off-by: William R. Dieter <william.r.dieter@intel.com>
2021-11-10 13:41:06 -05:00
Brad King
54b85286a4 Merge topic 'binutils-llvm-strip'
5dd981539f BinUtils: Avoid llvm-strip versions older than Clang 11

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6655
2021-10-26 09:07:31 -04:00
Brad King
5dd981539f BinUtils: Avoid llvm-strip versions older than Clang 11
Since commit cf82300a63 (BinUtils: Clarify search logic and make it more
consistent, 2021-05-27, v3.21.0-rc1~119^2~2) we correctly prefer the
more-specific name `llvm-strip` over `strip` when using Clang.  However,
`llvm-strip` from Clang versions prior to 11 require extra flags to
strip everything.  Until our `install(TARGETS)` logic learns to add
those flags, avoid using older versions of `llvm-strip` by default.

Fixes: #22785
2021-10-22 09:24:46 -04:00
Felipe Torrezan
7c3684b356
IAR: fix assembler detection for RISC-V 2021-09-21 11:45:22 +02:00
Jean-Marc Hengen
f77ffbc0e3 IAR: Restore support for projects not enabling policy CMP0057
Since commit 5b9bfe738c (IAR: Moved search logic to BinUtils.,
2021-07-19, v3.21.1~14^2), we use the `IN_LIST` operator in the
`CMakeFindBinUtils` module.  Set policy `CMP0057` to ensure it is
available regardless of the project's policy settings.

Fixes: #22640
2021-09-16 08:30:51 -04:00
Thomas Bernard
788b7afff2 FindBinUtils: Fall back to ld for Clang without lld
If `lld` is not available, Clang can still use `ld`.

Fixes: #22500
2021-08-18 14:31:21 -04:00
Cristian Adam
fc1f733cc7 BinUtils: Avoid searching CMAKE_PREFIX_PATH
Our `find_program` calls specify `HINTS` to look in the toolchain's
directory first, and then in `PATH`.  `CMAKE_PREFIX_PATH` may be
specified by the user to help find packages for project dependencies,
but this should not override the binutils.

Fixes: #22512
2021-08-09 09:59:29 -04:00
Jean-Marc Hengen
5b9bfe738c IAR: Moved search logic to BinUtils.
The search logic for the IAR linker, librarian and related tools is
moved from `Modules/Compiler/IAR-FindBinUtils.cmake` to
`Modules/CMakeFindBinUtils.cmake` by introducing an new elseif block
for the IAR toolchain.

The search logic was refactored to omit repeating itself.

Fixes: #22425
2021-07-23 14:34:26 +02:00
Lingkai Dong
509ef50a06 ARMClang: Fix regression in check for working compiler
Given the compiler to use, `CMakeFindBinUtils.cmake` automatically
determines a number of tools including linker (CMAKE_LINKER) and archiver
(CMAKE_AR) and stores them in a generated file `CMakeCCompiler.cmake` as
non-CACHE entries. The compiler-specific ARMClang.cmake then tries to
override CMAKE_LINKER and CMAKE_AR as CACHE entries.

Following the introduction of CMP0126, which is set to NEW in the test
for a working compiler, setting a CACHE entry does not replace a normal
entry of the same name anymore, resulting in a failed test due to wrong
linker and archiver.

To fix this, set CMAKE_LINKER and CMAKE_AR for ARMClang directly in
`CMakeFindBinUtils.cmake` as is done for other compilers.  Check
for them in `ARMClang.cmake` to safeguard cases when a project explicitly
includes `ARMClang.cmake` prior to compiler determination (which some
projects do to work around other problems in older CMake versions).
2021-07-14 09:45:09 -04:00
Brad King
9411766c35 BinUtils: Avoid llvm-objdump versions older than Clang 9
Since commit cf82300a63 (BinUtils: Clarify search logic and make it more
consistent, 2021-05-27) we correctly prefer the more-specific name
`llvm-objdump` over `objdump` when using Clang.  However, this breaks
`file(GET_RUNTIME_DEPENDENCIES)` with `llvm-objdump` from Clang 8 and
below.  Avoid those older versions of `llvm-objdump`.
2021-05-29 08:09:46 -04:00
Brad King
047585edc6 BinUtils: Find linker and librarian for Intel compilers on Windows
Update our Intel linker and archiver rules to use the `<CMAKE_LINKER>`
and `<CMAKE_AR>` placeholders instead of hard-coding the tool names.
2021-05-27 10:46:33 -04:00
Brad King
995f5b4e7b BinUtils: Find linker and librarian for OpenWatcom
Update our OpenWatcom linker and archiver rules to use the
`<CMAKE_LINKER>` and `<CMAKE_AR>` placeholders instead of
hard-coding the tool names.
2021-05-27 10:46:33 -04:00
Brad King
cf82300a63 BinUtils: Clarify search logic and make it more consistent
Consistently consider more-specific names before less-specific names.
2021-05-27 10:45:09 -04:00
Brad King
c33fb2e664 BinUtils: Use more-private temporary variable names
Since commit 4d786dfcfa (BinUtils: Avoid clobbering a variable named
without a private prefix, 2021-04-06, v3.20.1~4^2) we use variables
named `_tool` and `_name`, but these may still be common enough to
affect project code.  Use `_CMAKE_TOOL` and `_CMAKE_TOOL_NAME` instead,
and unset them when finished.

Fixes: #22140
2021-05-04 12:44:14 -04:00
Brad King
4d786dfcfa BinUtils: Avoid clobbering a variable named without a private prefix
Refactoring in commit b12aec6c8d (BinUtils: prefer bin utils matching
the compiler version extension, 2020-12-11, v3.20.0-rc1~171^2)
accidentally leaked a `TOOL` variable.  Name temporary variables with a
private prefix.

Fixes: #22035
2021-04-07 08:43:45 -04:00
Haibo Huang
61e6fc26bc Android: Fix search for binutils
Set `CMAKE_SYSTEM_PROGRAM_PATH` in `Platform/Android-Initialize` instead
of `Platform/Android` so it can be used in `CMakeFindBinUtils`.

Also add the names `llvm-strip` and `llvm-ranlib` for the corresponding
tools.
2021-03-30 10:06:02 -04:00
Thomas Bernard
b12aec6c8d BinUtils: prefer bin utils matching the compiler version extension 2021-01-11 11:33:37 -05:00
Brad King
0453342cda Merge topic 'clang-llvm-lib'
f5d3da091b Clang: Look for llvm-lib when using MSVC-like front-end

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Thomas Bernard <thomas@famillebernardgouriou.fr>
Merge-request: !5264
2020-09-25 12:23:02 -04:00
Shoaib Meenai
f5d3da091b Clang: Look for llvm-lib when using MSVC-like front-end
In commit 55196a1440 (MSVC: Use 'lib' instead of 'link /lib' to create
static libraries, 2020-01-10, v3.18.0-rc1~625^2) we changed CMake to use
lib instead of `link /lib` to create static libraries, but it didn't
search for `llvm-lib`. If you have `llvm-lib` but not `lib` (e.g. when
cross-compiling), when `CMakeFindBinutils` is invoked for the `C` and
`CXX` languages, `CMAKE_AR` is not found. When it's subsequently invoked
for the ASM language, `CMAKE_ASM_SIMULATE_ID` and
`CMAKE_ASM_COMPILER_FRONTEND_VARIANT` are not set (because
`CMakeDetermineASMCompiler` doesn't call `CMAKE_DETERMINE_COMPILER_ID`,
which sets those variables), so we go down the non-MSVC conditional and
set `CMAKE_AR` to a GNU-style `ar`, which of course does not understand
lib flags. Explicitly search for `llvm-lib` to avoid this situation.
2020-09-24 15:37:24 -04:00
Thomas Bernard
013270ef09 Clang: Detect lld-link when using gnu front end with msvc target
Fixes: #21137
2020-09-14 22:00:17 +02:00
Brad King
f10682b796 Merge topic 'ispc_lang_support'
5ece12b7e4 gitlab-ci: add ISPC to the Fedora CI image
8976817d6d ISPC: Update help documentation to include ISPC
2368f46ba4 ISPC: Support building with the MSVC toolchain
e783bf8aa6 ISPC: Support ISPC header generation byproducts and parallel builds
34cc6acc81 Add ISPC compiler support to CMake
419d70d490 Refactor some swift only logic to be re-used by other languages

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5065
2020-09-01 09:15:39 -04:00
Robert Maynard
2368f46ba4 ISPC: Support building with the MSVC toolchain 2020-08-28 11:21:31 -04:00
Robert Maynard
6896e50967 CMakeFindBinUtils: Always consider plain binutils when not cross-compiling
Since commit c5dd2ca538 (DetermineCompiler: Relax
_CMAKE_TOOLCHAIN_PREFIX detection, 2020-03-25, v3.18.0-rc1~430^2),
`_CMAKE_TOOLCHAIN_PREFIX` may be set even when not cross-compiling.
In this case we may still need to use binutils without any prefix.

Fixes: #21103
2020-08-18 13:19:24 -04:00
Francisco Facioni
55196a1440 MSVC: Use 'lib' instead of 'link /lib' to create static libraries
`link.exe /lib` is an undocumented flag and it just calls `lib.exe`.
Also `link.exe` doesn't parse the `/lib` option correctly when in a
response file.
2020-03-03 08:31:13 -05:00
Brad King
b2857514b0 FindBinUtils: Revert "Use the compiler to get the path to compiler tools"
Revert commit b2fd479df5 (FindBinUtils: Use the compiler to get the path
to compiler tools, 2019-09-22, v3.16.0-rc1~51^2).  The compiler's answer
may incorrectly come from the `PATH`.  Another approach will be needed.

Fixes: #19934
2019-11-07 10:31:02 -05:00