510 Commits

Author SHA1 Message Date
David Tenty
63195d3d7a
[NFC][CMake] quote ${CMAKE_SYSTEM_NAME} consistently (#154537)
A CMake change included in CMake 4.0 makes `AIX` into a variable
(similar to `APPLE`, etc.)
ff03db6657

However, `${CMAKE_SYSTEM_NAME}` unfortunately also expands exactly to
`AIX` and `if` auto-expands variable names in CMake. That means you get
a double expansion if you write:

`if (${CMAKE_SYSTEM_NAME}  MATCHES "AIX")`
which becomes:
`if (AIX  MATCHES "AIX")`
which is as if you wrote:
`if (ON MATCHES "AIX")`

You can prevent this by quoting the expansion of "${CMAKE_SYSTEM_NAME}",
due to policy
[CMP0054](https://cmake.org/cmake/help/latest/policy/CMP0054.html#policy:CMP0054)
which is on by default in 4.0+. Most of the LLVM CMake already does
this, but this PR fixes the remaining cases where we do not.
2025-08-20 12:45:41 -04:00
Orlando Cazalet-Hyams
1778669739
[KeyInstr] Remove LLVM_EXPERIMENTAL_KEY_INSTRUCTIONS CMake flag (#152735)
The CMake flag has been on by default for a month without any issues.

This makes the feature support in LLVM unconditional (but does not
enable the feature by default).
2025-08-08 17:03:28 +01:00
Mateusz Mikuła
2723a6d992
[LLVM][Cygwin] Enable dynamic linking of libLLVM (#146440)
These changes allow to link everything to shared LLVM library with
MSYS2 "Cygwin" toolchain.
2025-07-01 22:30:12 -07:00
Douglas
71e20c6c86
Fix references to required libraries when building LLVM with ASAN and MultiThreaded[Debug] on Windows (#139657)
After https://github.com/llvm/llvm-project/pull/81677, statically
linking ASAN under Windows is no longer supported. Therefore, when using
Clang built past
53a81d4d26
to build LLVM / Clang with
`-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded[Debug]
-DLLVM_USE_SANITIZER=Address`, a different set of dependent libraries
must be linked. This is mentioned in the description of
https://github.com/llvm/llvm-project/pull/81677 and also in
https://devblogs.microsoft.com/cppblog/msvc-address-sanitizer-one-dll-for-all-runtime-configurations/.
2025-06-20 08:13:48 -07:00
Slava Zakharin
3f794759f4
[build] Fixed LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING handling. (#144391)
Change in #107278 modified the CMake CACHE variable with values
that are not supported for it as documented. This patch renames the
derived vars so that they do not conflict with the CACHE variable.
2025-06-16 11:24:22 -07:00
NAKAMURA Takumi
1bc0b08e19 CMake: Fix LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING to be 1 or 0.
It has been introduced in #107278 but it was passing
"DISABLED" of LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING to cmakedefine01.

cmakadefine01 treats non-false-like strings as 1.
"DISABLED" is replaced with 1.
2025-06-14 19:16:21 +09:00
Tomohiro Kashiwada
bd319d9071
[Cygwin] CYGWIN is not WIN32 in current CMake (#143130)
On old CMake, Cygwin were also WIN32 but currently not. LLVM_ON_UNIX=1
and LLVM_HAVE_LINK_VERSION_SCRIPT=0 should be defined for Cygwin target.
2025-06-13 17:42:39 -07:00
Stephen Tozer
cc365331af
[DLCov] Origin-Tracking: Add config options (#143590)
This patch is part of a series that adds origin-tracking to the debugify
source location coverage checks, allowing us to report symbolized stack
traces of the point where missing source locations appear.

This patch adds the configuration options needed to enable this feature,
in the form of a new CMake option that enables a flag in
`llvm-config.h`; this is not an entirely new CMake flag, but a new
option, `COVERAGE_AND_ORIGIN`, for the existing flag
`LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING`. This patch contains
documentation, but no actual implementation for the flag itself.
2025-06-13 12:54:30 +01:00
Devon Loehr
63de20c0de
Reland "Add macro to suppress -Wunnecessary-virtual-specifier" (#141091)
This fixes #139614 on non-clang compilers by moving `__has_warning`
completely inside the `#if defined(__clang__)` block. This prevents a
parse failure from compilers which don't recognize `__has_warning`.

Original description:
Followup to #138741.

This adds the requested macro to silence
`-Wunnecessary-virtual-specifier` when declaring virtual anchor
functions in `final` classes, per [LLVM
policy](https://llvm.org/docs/CodingStandards.html#provide-a-virtual-method-anchor-for-classes-in-headers).

It also cleans up any remaining instances of the warning, allowing us to
stop disabling it when we build LLVM.
2025-05-28 12:15:22 +02:00
Philip Reames
e4e7a7e64e Revert "Add macro to suppress -Wunnecessary-virtual-specifier (#139614)"
This reverts commit 0954c9d487e7cb30673df9f0ac125f71320d2936.

It breaks the build when built with gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04).
2025-05-21 11:31:26 -07:00
Devon Loehr
0954c9d487
Add macro to suppress -Wunnecessary-virtual-specifier (#139614)
Followup to #138741.

This adds the requested macro to silence
`-Wunnecessary-virtual-specifier` when declaring virtual anchor
functions in `final` classes, per [LLVM
policy](https://llvm.org/docs/CodingStandards.html#provide-a-virtual-method-anchor-for-classes-in-headers).

It also cleans up any remaining instances of the warning, allowing us to
stop disabling it when we build LLVM.
2025-05-21 10:54:36 -07:00
Martin Storsjö
61c1f6d7e8
[cmake] Warn if LLVM_PROFDATA_FILE was specified but wasn't found (#139882)
Ideally we should perhaps even error out here; if the user requested
building with profiling info, but that profile wasn't found, it seems
like the build configuration is subtly broken, and I would expect the
user to want to know about it. But that may be a too disruptive change,
as users may very well rely on being able to build things in such a
setup anyway thanks to Hyrum's Law.

To make things clearer, at least print a warning in this case.
2025-05-14 22:04:58 +03:00
Devon Loehr
8810595068
Add unnecessary-virtual-specifier to -Wextra (#138741)
Effectively a reland of #133265, though due to discussion there we add
the warning to -Wextra instead of turning it on by default. We still
need to disable it for LLVM due to our unusual policy of using virtual
`anchor` functions even in final classes. We now check if the warning
exists before disabling it in LLVM builds, so hopefully this will fix
the issues libcxx ran into last time.

From the previous PR:

I've been working on cleaning up this warning in two codebases: LLVM and
chromium (plus its dependencies). The chromium + dependency cleanup has
been straightforward. Git archaeology shows that there are two reasons
for the warnings: classes to which `final` was added after they were
initially committed, and classes with virtual destructors that nobody
remarks on. Presumably the latter case is because people are just very
used to destructors being virtual.

The LLVM cleanup was more surprising: I discovered that we have an [old
policy](https://llvm.org/docs/CodingStandards.html#provide-a-virtual-method-anchor-for-classes-in-headers)
about including out-of-line virtual functions in every class with a
vtable, even `final` ones. This means our codebase has many virtual
"anchor" functions which do nothing except control where the vtable is
emitted, and which trigger the warning. I looked into alternatives to
satisfy the policy, such as using destructors instead of introducing a
new function, but it wasn't clear if they had larger implications.

Overall, it seems like the warning is genuinely useful in most codebases
(evidenced by chromium and its dependencies), and LLVM is an unusual
case. Therefore we should enable the warning by default, and turn it off
only for LLVM builds.
2025-05-07 20:10:25 +02:00
Stephen Tozer
3e523502a1
[DLCov] Move DebugLoc coverage macro to llvm-config.h (#137787)
This patch follows the reversion of #107279, which caused errors by
including `llvm/Config/config.h` in a public header. In order to reapply
that patch, this PR moves the definition of the config option to the
`llvm-config.h` header instead, so that it can be used publicly. This
patch also adds `LLVM_` as a prefix to the define, since it is now in a
public header.
2025-04-30 10:23:30 +01:00
Nikolas Klauser
04676c6160
Revert "Enable unnecessary-virtual-specifier by default" (#134105)
Reverts llvm/llvm-project#133265

This causes the whole libc++ CI to fail, since we're not building
against a compiler built from current trunk. Specifically, the CMake
changes causes some feature detection to fail, resulting in CMake
being unable to configure libc++.
2025-04-02 17:59:08 +02:00
Devon Loehr
4007de00a0
Enable unnecessary-virtual-specifier by default (#133265)
This turns on the unnecessary-virtual-specifier warning in general, but
disables it when building LLVM. It also tweaks the warning description
to be slightly more accurate.

Background: I've been working on cleaning up this warning in two
codebases: LLVM and chromium (plus its dependencies). The chromium
cleanup has been straightforward. Git archaeology shows that there are
two reasons for the warnings: classes to which `final` was added after
they were initially committed, and classes with virtual destructors that
nobody remarks on. Presumably the latter case is because people are just
very used to destructors being virtual.

The LLVM cleanup was more surprising: I discovered that we have an [old
policy](https://llvm.org/docs/CodingStandards.html#provide-a-virtual-method-anchor-for-classes-in-headers)
about including out-of-line virtual functions in every class with a
vtable, even `final` ones. This means our codebase has many virtual
"anchor" functions which do nothing except control where the vtable is
emitted, and which trigger the warning. I looked into alternatives to
satisfy the policy, such as using destructors instead of introducing a
new function, but it wasn't clear if they had larger implications.

Overall, it seems like the warning is genuinely useful in most codebases
(evidenced by chromium and its dependencies), and LLVM is an unusual
case. Therefore we should enable the warning by default, and turn it off
only for LLVM builds.
2025-03-31 16:28:53 +02:00
Orlando Cazalet-Hyams
f4feab927b
[NFC][KeyInstr] Add (LLVM_)EXPERIMENTAL_KEY_INSTRUCTIONS (cmake/)definition (#131344)
Key Instructions will start development behind a compile time flag to avoid
passing on the increased memory usage to all debug builds. We're working on
improving DILocation memory characteristics simultaneously; once that work lands
we can remove `EXPERIMENTAL_KEY_INSTRUCTIONS`.

This patch doesn't add any code, it's just so we can get the SIE buildbot
building with the new option right away.
2025-03-17 11:32:59 +00:00
Joseph Huber
6ac63129b7
[LLVM] Only enable -fno-lifetime-dse in LTO mode (#131381)
Summary:
Always passing this option is problematic since it is not supported by
`clang.` this leads to conflicts when using extra CMake tools like
`compile-commands` or `include-what-you-use`. This mainly works around a
bug that showed up during the LTO build. Theoretically this can show up
without LTO, but it's likely to work.

This can be removed once
https://github.com/llvm/llvm-project/issues/24952 is resolved.
2025-03-14 15:21:39 -05:00
Mészáros Gergely
e1b5826c2b
[LLVM][CMake][MSVC] Wrap linker options for ICX with LLVM_BUILD_INSTUMENTED (#124573)
RFC:
https://discourse.llvm.org/t/rfc-cmake-linker-flags-need-wl-equivalent-for-intel-c-icx-on-windows/82446

The Intel C++ Compiler (ICX) passes linker flags through the driver
unlike MSVC and clang-cl, and therefore needs them to be prefixed with
`/Qoption,link` (the equivalent of `-Wl,` for gcc on *nix).

Previous PRs did not catch this because I did not try building with
`LLVM_BUILD_INSTRUMENTED=ON`.
`CMAKE_CXX_LINKER_WRAPPER_FLAG` is empty for plain clang-cl (icx on
windows behaves as clang-cl), so this is NFC for clang-cl.
2025-01-28 13:49:37 +01:00
mcbarton
3cfda4f118
Don't use -z,defs linker flag when building shared libraries with emscripten (#123396) 2025-01-27 16:00:31 -08:00
Paul Kirth
6578790076
Reapply "[Fuchsia][cmake] Allow using FatLTO when building runtimes" (#119252) (#121820)
The previous failures were addressed with CMake changes in #121819
2025-01-27 13:44:18 -08:00
Paul Kirth
1cbd67efe4
Revert "[Fuchsia][cmake] Allow using FatLTO when building runtimes" (#119252)
Reverts llvm/llvm-project#112277

This broke something on Fuchsia's Mac builders, 
so there's still something in the CMake that needs to be updated before
we reland.

Failed build: 

https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/clang-mac-xarm64/b8729005878443108801/overview
2024-12-09 11:25:01 -08:00
Paul Kirth
57545dbbdb
[Fuchsia][cmake] Allow using FatLTO when building runtimes (#112277)
We'd like to build runtimes using FatLTO (see
https://llvm.org/docs/FatLTO.html for details). This gives us more
control over how libc++ can be consumed by users of our toolchain, like
the Fuchsia SDK.
2024-12-09 09:26:17 -08:00
Greg Roth
1f0e0da3af
[CMake] update Apple undefined symbol link flag from suppress (#116113)
the -undefined suppress option for Apple's linker is deprecated and was
producing multiple warnings. This updates it to dynamic_lookup, which
has much the same effect, but avoids these deprecation warnings.
2024-11-13 16:44:54 -08:00
Mészáros Gergely
7ab6d39a4d
[LLVM][CMake][MSVC] Wrap linker flags for ICX on Windows (#112680)
The Intel C++ Compiler (ICX) passes linker flags through the driver
unlike MSVC and clang-cl, and therefore needs them to be prefixed with
`/Qoption,link` (the equivalent of `-Wl,` for gcc on *nix).

Use `LINKER:` prefix wherever supported by cmake, when that's not
possible fall-back to `${CMAKE_CXX_LINKER_WRAPPER_FLAG}`. CMake replaces
these with `/Qoption,link` for ICX and with the empty string for MSVC
and clang-cl.

For `target_link_libraries` neither `LINKER:` (not supported prior to
CMake 3.32) nor `${CMAKE_CXX_LINKER_WRAPPER_FLAG}` (does not begin with
`-` would be taken as a library name) works, use `-Qoption,link`
directly within a conditional generator expression that we're linking
with ICX.

For MSVC and clang-cl no functional change is intended.

Tested by compiling with ICX and setting
`CMAKE_(EXE|SHARED|STATIC|MODULE)_LINKER_FLAGS_INIT` to
`-Werror=unknown-argument`.

RFC:
https://discourse.llvm.org/t/rfc-cmake-linker-flags-need-wl-equivalent-for-intel-c-icx-on-windows/82446
2024-10-23 13:03:25 +02:00
Stephen Tozer
84088d3a28
[DLCov 1/5] Add CMake option for enhanced debug line coverage tracking (#107278)
This is part of a series of patches that tries to improve DILocation bug
detection in Debugify. This first patch adds the necessary CMake flag to
LLVM and a variable defined by that flag to LLVM's config header, allowing
the next patch to track information without affecting normal builds.

This series of patches adds a "DebugLoc coverage tracking" feature, that
inserts conditionally-compiled tracking information into DebugLocs (and
by extension, to Instructions), which is used by Debugify to provide
more accurate and detailed coverage reports. When enabled, this features
tracks whether and why we have intentionally dropped a DebugLoc,
allowing Debugify to ignore false positives. An optional additional
feature allows also storing a stack trace of the point where a DebugLoc
was unintentionally dropped/not generated, which is used to make fixing
detected errors significantly easier. The goal of these features is to
provide useful tools for developers to fix existing DebugLoc errors and
allow reliable detection of regressions by either manual inspection or
an automated script.
2024-10-08 18:15:46 +01:00
Mészáros Gergely
97a784ecac
[llvm][cmake][Trivial] use /Zc:preprocessor with MSVC only explicitly (#111520)
Only MSVC recognizes this flag, so be explicit. As an example the Intel
C++ Compiler (IntelLLVM in CMake) also has an MSVC compatible CLI, but
does not suppport this flag.
2024-10-08 15:58:25 +02:00
Mike Hommey
631bcbe9de
[llvm][cmake] Properly place clang runtime directory on linker command line when WinMsvc.cmake is involved (#110084)
WinMsvc.cmake, used for cross-compiling LLVM, targetting Windows, puts
-libpath flags on the linker command line for the MSVC directories.
Those may contain clang runtime libraries that come from MSVC, and may
be incompatible with the clang compiler in use when it doesn't come from
MSVC (which is obviously the case on cross-compiles). By prioritizing
the clang runtime directory on the linker command line, we avoid those
libraries being picked up by the linker.
2024-09-27 06:15:55 +00:00
Thomas Fransham
59f8796aaa
Initial changes for llvm shared library build using explicit visibility annotations
These are my initial build and code changes to supporting building llvm
as shared library/DLL on windows(without force exporting all symbols)
and making symbol visibility hidden by default on Linux which adding
explicit symbol visibility macros to the whole llvm codebase.

Updated cmake code to allow building llvm-shlib on windows by appending
/WHOLEARCHIVE:lib to the linker options.
Remove the hardcoded CMake error from using LLVM_BUILD_LLVM_DYLIB on
windows.
Updated CMake to define new macros to control conditional export macros
in llvm/Support/Compiler.h
Use /Zc:dllexportInlines- when compiling with clang-cl on windows with a
opt out CMake option to disable using it.
Replace some use of LLVM_EXTERNAL_VISIBILITY with new export macros.

Some of the cmake and code changes are based on @tstellar's earlier PR
https://github.com/llvm/llvm-project/pull/67502.

I have Windows building using clang-cl, while for MSVC its at-least able
to build libllvm, but some tests can't build because llvm iterator
template metaprogramming that doesn't work well with dllexport. Linux
should build without issue. My full branch is here
https://github.com/fsfod/llvm-project/tree/llvm-export-api-20.0 and
including all the auto generated export macros from clang tooling based
system.
2024-09-06 10:51:44 -07:00
h-vetinari
89946bda5e
[cmake] switch to CMake's native check_{compiler,linker}_flag (#96171)
Broken out from #93429

Somewhat closing the loop opened by 7017e6c9cfd2de.

Co-authored-by: Ryan Prichard <rprichard@google.com>
2024-07-31 10:31:13 -04:00
Vlad Serebrennikov
32b91ec395 [cmake] Fix -fno-lifetime-dse not being passed to GCC
A follow-up to #92953. This should fix unexpected performance gains when Clang is built with GCC, and fix downstream LTO crashes reported in 4feae05c6a (r142466703)
2024-05-30 12:00:24 +03:00
Vlad Serebrennikov
f02e074552 Make sure -Wnon-virtual-dtor is passed only when compiling with Clang
Another follow-up for #92953. Addresses buildbot failure https://lab.llvm.org/buildbot/#/builders/193/builds/52421
2024-05-23 17:46:46 +03:00
Vlad Serebrennikov
ed803c879a Properly initialize CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG CMake variable
A follow-up for #92953. Addresses the following buildbot failures:
https://lab.llvm.org/buildbot/#/builders/36/builds/45836
https://lab.llvm.org/buildbot/#/builders/57/builds/35200
2024-05-23 17:16:32 +03:00
Vlad Serebrennikov
4feae05c6a
Remove some try_compile CMake checks for compiler flags (#92953)
This patch remove 36 checks for compiler flags that are done via
invoking the compiler across LLVM, Clang, and LLDB. It's was made
possible by raising the bar for supported compilers that has been
happening over the years since the checks were added.

This is going to improve CMake configuration times. This topic was
highlighted in
https://discourse.llvm.org/t/cmake-compiler-flag-checks-are-really-slow-ideas-to-speed-them-up/78882.
2024-05-23 17:05:41 +04:00
Vlad Serebrennikov
566431ce08 [NFC] Improve the comment about std::min_element being constepxr in libstdc++ 2024-05-21 10:17:24 +03:00
Paul Kirth
3cd9dccbb4
[cmake] Disable using FatLTO on Apple platforms (#85708)
FatLTO currently only supports ELF, so ensure we don't use it
on non-ELF platforms.
2024-03-19 13:03:02 -07:00
Paul Kirth
43fc921795
[CMAKE] Enable FatLTO as a build option for LLVM (#80480)
Since LLVM supports `-ffat-lto-objects` we should enable this as an
option in the LLVM build. FatLTO should improve the time it takes to
build tests for LTO enabled builds of the compiler by not linking w/ the
bitcode portion of the object files, which should speed up build times
for LTO builds without disabling optimizations.
2024-03-15 16:35:06 -07:00
David Stuttard
9228859c2a
[CMake] Add tablegen job pool support (#84762)
Add the ability to set the number of tablegen jobs that can run in
parallel
similar to the LLVM_PARALLEL_[COMPILE|LINK]_JOBS options that already
exist.
2024-03-12 10:07:02 +00:00
Joseph Huber
07b1aebced
[LLVM][NFC] Ignore including the GNUInstallDirs on the GPU (#83910)
Summary:
I've begun treating GPU runtimes builds as cross-compiling with the LLVM
infrastructure. However, we include a lot of random stuff that the GPU
build isn't prepared to handle. This currently emits a warning, and
while it's not striclty necessary, is annoying. This patch suppresses it
by not including the standard GNU install directory resources when used
from the GPU.
2024-03-04 17:38:42 -06:00
Joseph Huber
b8a7d8131e [LLVM] Fix incorrect GPU triple detection for runtimes builds
Summary:
This block of code is used to prevent a GPU-based cross compiling build
from taking incompatible arguments. However this incorrectly used the
LLVM default triple instead of the runtimes target. Fix that so the bots
can continue to default the triple to NVPTX.
2024-02-23 07:32:03 -06:00
huaatian
5ccf54640a
[llvm][cmake] Performing expensive checks requires enabling assert. (#80821)
LLVM will intercept errors using assert() when
LLVM_ENABLE_EXPENSIVE_CHECKS is ON. So an explicit check is added.

---------

Co-authored-by: Hua Tian <akiratian@tencent.com>
2024-02-23 10:25:02 +08:00
Joseph Huber
47b7c91abe
[libc] Rework the GPU build to be a regular target (#81921)
Summary:
This is a massive patch because it reworks the entire build and
everything that depends on it. This is not split up because various bots
would fail otherwise. I will attempt to describe the necessary changes
here.

This patch completely reworks how the GPU build is built and targeted.
Previously, we used a standard runtimes build and handled both NVPTX and
AMDGPU in a single build via multi-targeting. This added a lot of
divergence in the build system and prevented us from doing various
things like building for the CPU / GPU at the same time, or exporting
the startup libraries or running tests without a full rebuild.

The new appraoch is to handle the GPU builds as strict cross-compiling
runtimes. The first step required
https://github.com/llvm/llvm-project/pull/81557 to allow the `LIBC`
target to build for the GPU without touching the other targets. This
means that the GPU uses all the same handling as the other builds in
`libc`.

The new expected way to build the GPU libc is with
`LLVM_LIBC_RUNTIME_TARGETS=amdgcn-amd-amdhsa;nvptx64-nvidia-cuda`.

The second step was reworking how we generated the embedded GPU library
by moving it into the library install step. Where we previously had one
`libcgpu.a` we now have `libcgpu-amdgpu.a` and `libcgpu-nvptx.a`. This
patch includes the necessary clang / OpenMP changes to make that not
break the bots when this lands.

We unfortunately still require that the NVPTX target has an `internal`
target for tests. This is because the NVPTX target needs to do LTO for
the provided version (The offloading toolchain can handle it) but cannot
use it for the native toolchain which is used for making tests.

This approach is vastly superior in every way, allowing us to treat the
GPU as a standard cross-compiling target. We can now install the GPU
utilities to do things like use the offload tests and other fun things.

Some certain utilities need to be built with 
`--target=${LLVM_HOST_TRIPLE}` as well. I think this is a fine
workaround as we
will always assume that the GPU `libc` is a cross-build with a
functioning host.

Depends on https://github.com/llvm/llvm-project/pull/81557
2024-02-22 15:29:29 -06:00
Jeremy Morse
92eaf036bf
[NFC][RemoveDIs] Remove conditional compilation for RemoveDIs (#81149)
A colleague observes that switching the default value of
LLVM_EXPERIMENTAL_DEBUGINFO_ITERATORS to "On" hasn't flipped the value
in their CMakeCache.txt. This probably means that everyone with an
existing build tree is going to not have support built in, meaning
everyone in LLVM would need to clean+rebuild their worktree when we flip
the switch on... which doesn't sound good.

So instead, just delete the flag and everything it does, making everyone
build and run ~400 lit tests in RemoveDIs mode. None of the buildbots
have had trouble with this, so it Should Be Fine (TM).

(Sending for review as this is changing various comments, and touches
several different areas -- I don't want to get too punchy).
2024-02-08 16:13:22 +00:00
Corentin Jabot
4d467215f1 [Clang] Revert inintentional changes to cmake committed in 33e5db6e0 2024-01-12 10:59:46 +01:00
Corentin Jabot
33e5db6e04 [clang] Improve colors in status tracking web pages.
Use a consistent, more pastel color for unknown status
in papers and issues tracking pages
2024-01-11 10:21:51 +01:00
Duo Wang
4a4804bf70
[CMake][Windows] Turn off lld string tail merging when ASAN is turned on (#74207)
lld string tail merging interacts badly with ASAN on Windows, as is
reported in https://github.com/llvm/llvm-project/issues/62078.
A similar error was found when building LLVM with
`-DLLVM_USE_SANITIZER=Address`:
```console
[2/2] Building GenVT.inc...
FAILED: include/llvm/CodeGen/GenVT.inc C:/Dev/llvm-project/Build_asan/include/llvm/CodeGen/GenVT.inc
cmd.exe /C "cd /D C:\Dev\llvm-project\Build_asan && C:\Dev\llvm-project\Build_asan\bin\llvm-min-tblgen.exe -gen-vt -I C:/Dev/llvm-project/llvm/include/llvm/CodeGen -IC:/Dev/llvm-project/Build_asan/include -IC:/Dev/llvm-project/llvm/include C:/Dev/llvm-project/llvm/include/llvm/CodeGen/ValueTypes.td --write-if-changed -o include/llvm/CodeGen/GenVT.inc -d include/llvm/CodeGen/GenVT.inc.d"       
=================================================================
==31944==ERROR: AddressSanitizer: global-buffer-overflow on address 0x7ff6cff80d20 at pc 0x7ff6cfcc7378 bp 0x00e8bcb8e990 sp 0x00e8bcb8e9d8
READ of size 1 at 0x7ff6cff80d20 thread T0
    #0 0x7ff6cfcc7377 in strlen (C:\Dev\llvm-project\Build_asan\bin\llvm-min-tblgen.exe+0x1400a7377)
    #1 0x7ff6cfde50c2 in operator delete(void *, unsigned __int64) (C:\Dev\llvm-project\Build_asan\bin\llvm-min-tblgen.exe+0x1401c50c2)
    #2 0x7ff6cfdd75ef in operator delete(void *, unsigned __int64) (C:\Dev\llvm-project\Build_asan\bin\llvm-min-tblgen.exe+0x1401b75ef)
    #3 0x7ff6cfde59f9 in operator delete(void *, unsigned __int64) (C:\Dev\llvm-project\Build_asan\bin\llvm-min-tblgen.exe+0x1401c59f9)
    #4 0x7ff6cff03f6c in operator delete(void *, unsigned __int64) (C:\Dev\llvm-project\Build_asan\bin\llvm-min-tblgen.exe+0x1402e3f6c)
    #5 0x7ff6cfefbcbc in operator delete(void *, unsigned __int64) (C:\Dev\llvm-project\Build_asan\bin\llvm-min-tblgen.exe+0x1402dbcbc)
    #6 0x7ffb7f247343  (C:\WINDOWS\System32\KERNEL32.DLL+0x180017343)
    #7 0x7ffb800826b0  (C:\WINDOWS\SYSTEM32\ntdll.dll+0x1800526b0)

0x7ff6cff80d20 is located 31 bytes after global variable '"#error \"ArgKind is not defined\"\n"...' defined in 'C:\Dev\llvm-project\llvm\utils\TableGen\IntrinsicEmitter.cpp' (0x7ff6cff80ce0) of size 33
  '"#error \"ArgKind is not defined\"\n"...' is ascii string '#error "ArgKind is not defined"
'
0x7ff6cff80d20 is located 0 bytes inside of global variable '""' defined in 'C:\Dev\llvm-project\llvm\utils\TableGen\IntrinsicEmitter.cpp' (0x7ff6cff80d20) of size 1
  '""' is ascii string ''
SUMMARY: AddressSanitizer: global-buffer-overflow (C:\Dev\llvm-project\Build_asan\bin\llvm-min-tblgen.exe+0x1400a7377) in strlen
Shadow bytes around the buggy address:
  0x7ff6cff80a80: 01 f9 f9 f9 f9 f9 f9 f9 00 00 00 00 01 f9 f9 f9
  0x7ff6cff80b00: f9 f9 f9 f9 00 00 00 00 00 00 00 00 01 f9 f9 f9
  0x7ff6cff80b80: f9 f9 f9 f9 00 00 00 00 01 f9 f9 f9 f9 f9 f9 f9
  0x7ff6cff80c00: 00 00 00 00 01 f9 f9 f9 f9 f9 f9 f9 00 00 00 00
  0x7ff6cff80c80: 00 00 00 00 01 f9 f9 f9 f9 f9 f9 f9 00 00 00 00
=>0x7ff6cff80d00: 01 f9 f9 f9[f9]f9 f9 f9 00 00 00 00 00 00 00 00
  0x7ff6cff80d80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7ff6cff80e00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7ff6cff80e80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7ff6cff80f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x7ff6cff80f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==31944==ABORTING
```
This is reproducible with the 17.0.3 release:
```console
$ clang-cl --version
clang version 17.0.3
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin
$ cmake -S llvm -B Build -G Ninja -DLLVM_USE_SANITIZER=Address -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_BUILD_TYPE=Release
$ cd Build
$ ninja all
```
2023-12-07 11:44:24 +00:00
Paul Kirth
d22944d1cc
[cmake] Fix relative paths in prefix map (#74132)
When building debug version of LLVM with
`LLVM_USE_RELATIVE_PATHS_IN_FILES=On` would cause source paths to be
incorrect, and be prefixed by the build directory. This lead to source
locations like the following: `../build/llvm/...`. Such paths do not
exist, and existing debuggers can't adjust their search location because
of the incorrect prefix. Ultimately, this happened because the relative
path creation goes in the wrong direction, from source-dir to build-dir
instead of from build-dir to source-dir.

This patch swaps the directionality of the relative paths so that they
get a proper prefix from the build directory. Given a build dir at
`/build` and a project directory at `/llvm-project`, we get source
locations like: `../llvm-project/llvm/lib/Transforms/...`, which a
debugger can resolve once pointed to the correct project directory.
2023-12-01 14:51:21 -08:00
Konstantin Varlamov
4a9c71b8c2
[libc++][hardening] Fix references to old names for hardening modes (#71743)
This should fix some builds broken by
https://github.com/llvm/llvm-project/pull/70575
2023-11-08 13:16:01 -10:00
Will Hawkins
4aae5387a8
[llvm][CMake] Respect LIBCXX_HARDENING_MODE on command-line (#68541)
When the user specifies `LIBCXX_HARDENING_MODE` on the command line in a
bootstrapping build, it should override the setting implied by
`LLVM_ENABLE_ASSERTIONS`.
2023-10-20 23:13:33 -07:00
jusito
7b9fa2146e
[cmake] Option to create Ninja job pools depending on available resources (#65274)
This PR adds options to let CMake calculate the ninja job pools
depending on free memory and available cores.
You can provide memory requirements for each compile and link job which
is checked against CMake AVAILABLE_PHYSICAL_MEMORY and
NUMBER_OF_LOGICAL_CORES. [This information are available since CMake
3.0](https://cmake.org/cmake/help/v3.0/command/cmake_host_system_information.html).

This is very helpful in CI environments with multiple jobs per
environment or a VM with multiple users.
Its different to LLVM_PARALLEL_LINK_JOBS / LLVM_PARALLEL_COMPILE_JOBS
(or ninja -j 1) because it tries to use the resources more efficient
without being terminated. Only downside currently is that compile and
link jobs can run at the same time so there is an offset for link job
memory suggested which is added to the documentation.

The definitions aren't added as cache because if I understand it
correctly this would break it because values could be outdated.
2023-10-20 22:37:51 +05:30