Commit Graph

3083 Commits

Author SHA1 Message Date
LLVM GN Syncbot 41c79d0b6d [gn build] Port 2d52c6bfae 2022-09-05 14:41:45 +00:00
LLVM GN Syncbot 8f33a3abb3 [gn build] Port d5e26775d0 2022-09-05 10:39:22 +00:00
LLVM GN Syncbot 1553179e34 [gn build] Port a46154cb1c 2022-09-04 21:07:13 +00:00
LLVM GN Syncbot e3018e4a4f [gn build] Port bc8fd9c633 2022-09-03 02:43:17 +00:00
LLVM GN Syncbot 211817d3be [gn build] Port 3a49cffe3a 2022-09-03 02:22:45 +00:00
LLVM GN Syncbot 055721ff75 [gn build] Port 30adaa730c 2022-09-02 19:47:21 +00:00
LLVM GN Syncbot c0433f91d3 [gn build] Port f6b66cbc7d 2022-09-01 18:01:38 +00:00
LLVM GN Syncbot f252b8477e [gn build] Port d931ac9e27 2022-09-01 10:19:04 +00:00
LLVM GN Syncbot 3622e9bea0 [gn build] Port 74c8d9d5fc 2022-08-31 18:52:31 +00:00
Nico Weber 068fe0724d [gn build] port d45c04da7c (TestingADTTests) 2022-08-31 14:15:23 -04:00
LLVM GN Syncbot 1830302b3f [gn build] Port c9033eeb2e 2022-08-31 17:02:52 +00:00
LLVM GN Syncbot 9eec2ac1d1 [gn build] Port ea9ac3519c 2022-08-30 22:53:54 +00:00
Alexey Baturo f8b71a307e [RISC-V][HWASAN] Add tag mismatch routines for HWASAN required for RISC-V
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D131341
2022-08-28 19:42:08 +03:00
LLVM GN Syncbot a5857bd21f [gn build] Port 82e893c47c 2022-08-26 19:20:51 +00:00
Nico Weber cb0644b1cc [gn build] port 47166968db (no more clang-offload-wrapper) 2022-08-26 15:11:45 -04:00
LLVM GN Syncbot df46c78078 [gn build] Port 56c54cf66b 2022-08-26 11:23:06 +00:00
LLVM GN Syncbot 66f180edd7 [gn build] Port 3e39b27101 2022-08-26 11:23:05 +00:00
Nico Weber 217eb9f75a [gn build] port bb26ebb4d1 2022-08-26 07:22:35 -04:00
LLVM GN Syncbot 0355a54a2d [gn build] Port 48506fbbbf 2022-08-25 22:25:21 +00:00
Nico Weber 58d630fbfa Revert "[gn build] port bc39d7bdd4 (libclang.map -> libclang.exports)"
This reverts commit 94c00c10e8.
bc39d7bdd4 was reverted in 0f28d48566.
2022-08-25 07:08:44 -04:00
LLVM GN Syncbot e7796c9673 [gn build] Port 5ce4c9aa04 2022-08-25 01:34:14 +00:00
Nico Weber d83a3394b6 [gn build] port 5ce4c9aa04 2022-08-24 21:33:56 -04:00
Sami Tolvanen cff5bef948 KCFI sanitizer
The KCFI sanitizer, enabled with `-fsanitize=kcfi`, implements a
forward-edge control flow integrity scheme for indirect calls. It
uses a !kcfi_type metadata node to attach a type identifier for each
function and injects verification code before indirect calls.

Unlike the current CFI schemes implemented in LLVM, KCFI does not
require LTO, does not alter function references to point to a jump
table, and never breaks function address equality. KCFI is intended
to be used in low-level code, such as operating system kernels,
where the existing schemes can cause undue complications because
of the aforementioned properties. However, unlike the existing
schemes, KCFI is limited to validating only function pointers and is
not compatible with executable-only memory.

KCFI does not provide runtime support, but always traps when a
type mismatch is encountered. Users of the scheme are expected
to handle the trap. With `-fsanitize=kcfi`, Clang emits a `kcfi`
operand bundle to indirect calls, and LLVM lowers this to a
known architecture-specific sequence of instructions for each
callsite to make runtime patching easier for users who require this
functionality.

A KCFI type identifier is a 32-bit constant produced by taking the
lower half of xxHash64 from a C++ mangled typename. If a program
contains indirect calls to assembly functions, they must be
manually annotated with the expected type identifiers to prevent
errors. To make this easier, Clang generates a weak SHN_ABS
`__kcfi_typeid_<function>` symbol for each address-taken function
declaration, which can be used to annotate functions in assembly
as long as at least one C translation unit linked into the program
takes the function address. For example on AArch64, we might have
the following code:

```
.c:
  int f(void);
  int (*p)(void) = f;
  p();

.s:
  .4byte __kcfi_typeid_f
  .global f
  f:
    ...
```

Note that X86 uses a different preamble format for compatibility
with Linux kernel tooling. See the comments in
`X86AsmPrinter::emitKCFITypeId` for details.

As users of KCFI may need to locate trap locations for binary
validation and error handling, LLVM can additionally emit the
locations of traps to a `.kcfi_traps` section.

Similarly to other sanitizers, KCFI checking can be disabled for a
function with a `no_sanitize("kcfi")` function attribute.

Relands 67504c9549 with a fix for
32-bit builds.

Reviewed By: nickdesaulniers, kees, joaomoreira, MaskRay

Differential Revision: https://reviews.llvm.org/D119296
2022-08-24 22:41:38 +00:00
LLVM GN Syncbot fafc6f9985 [gn build] Port 91389000ab 2022-08-24 21:45:56 +00:00
Sami Tolvanen a79060e275 Revert "KCFI sanitizer"
This reverts commit 67504c9549 as using
PointerEmbeddedInt to store 32 bits breaks 32-bit arm builds.
2022-08-24 19:30:13 +00:00
Sami Tolvanen 67504c9549 KCFI sanitizer
The KCFI sanitizer, enabled with `-fsanitize=kcfi`, implements a
forward-edge control flow integrity scheme for indirect calls. It
uses a !kcfi_type metadata node to attach a type identifier for each
function and injects verification code before indirect calls.

Unlike the current CFI schemes implemented in LLVM, KCFI does not
require LTO, does not alter function references to point to a jump
table, and never breaks function address equality. KCFI is intended
to be used in low-level code, such as operating system kernels,
where the existing schemes can cause undue complications because
of the aforementioned properties. However, unlike the existing
schemes, KCFI is limited to validating only function pointers and is
not compatible with executable-only memory.

KCFI does not provide runtime support, but always traps when a
type mismatch is encountered. Users of the scheme are expected
to handle the trap. With `-fsanitize=kcfi`, Clang emits a `kcfi`
operand bundle to indirect calls, and LLVM lowers this to a
known architecture-specific sequence of instructions for each
callsite to make runtime patching easier for users who require this
functionality.

A KCFI type identifier is a 32-bit constant produced by taking the
lower half of xxHash64 from a C++ mangled typename. If a program
contains indirect calls to assembly functions, they must be
manually annotated with the expected type identifiers to prevent
errors. To make this easier, Clang generates a weak SHN_ABS
`__kcfi_typeid_<function>` symbol for each address-taken function
declaration, which can be used to annotate functions in assembly
as long as at least one C translation unit linked into the program
takes the function address. For example on AArch64, we might have
the following code:

```
.c:
  int f(void);
  int (*p)(void) = f;
  p();

.s:
  .4byte __kcfi_typeid_f
  .global f
  f:
    ...
```

Note that X86 uses a different preamble format for compatibility
with Linux kernel tooling. See the comments in
`X86AsmPrinter::emitKCFITypeId` for details.

As users of KCFI may need to locate trap locations for binary
validation and error handling, LLVM can additionally emit the
locations of traps to a `.kcfi_traps` section.

Similarly to other sanitizers, KCFI checking can be disabled for a
function with a `no_sanitize("kcfi")` function attribute.

Reviewed By: nickdesaulniers, kees, joaomoreira, MaskRay

Differential Revision: https://reviews.llvm.org/D119296
2022-08-24 18:52:42 +00:00
LLVM GN Syncbot ab8fcd5ab0 [gn build] Port 134d017b88 2022-08-23 11:31:54 +00:00
LLVM GN Syncbot 684e71eef2 [gn build] Port 15b65bcd65 2022-08-23 05:49:48 +00:00
Nico Weber 4a2c8dcc17 [gn build] port e78208f082 2022-08-22 21:46:36 -04:00
Kazu Hirata 36357c967c Remove llvm::is_trivially_copyable (NFC)
This patch removes llvm::is_trivially_copyable as it seems to be dead.
Once I remove it, HAVE_STD_IS_TRIVIALLY_COPYABLE has no users, so this
patch removes the macro also.

The comment on llvm::is_trivially_copyable mentions GCC 4.9, but note
that we now require GCC 7.1 or higher.

Differential Revision: https://reviews.llvm.org/D132328
2022-08-21 10:39:19 -07:00
Nico Weber 804d4594cb [gn build] Fix oversight in 3adda398ce 2022-08-20 13:39:45 -04:00
John Ericson 3adda398ce [clang][lldb][cmake] Use new `*_INSTALL_LIBDIR_BASENAME` CPP macro
Use this instead of `*_LIBDIR_SUFFIX`, from which it is computed.

This gets us ready for D130586, in which `*_LIBDIR_SUFFIX` is
deprecated.

Differential Revision: https://reviews.llvm.org/D132300
2022-08-20 12:52:21 -04:00
LLVM GN Syncbot 9e51cbac9e [gn build] Port 57c9780d60 2022-08-19 21:56:27 +00:00
Nico Weber 6a62fc1827 [gn build] Port c74c17f37a 2022-08-19 07:45:44 -04:00
Nico Weber ca5902cc82 Revert "[gn build] port f7a33090a910"
This reverts commit d3a1dbc490.
f7a33090a9 was reverted in e941b031d3.
2022-08-19 07:40:45 -04:00
John Ericson e941b031d3 Revert "[cmake] Use `CMAKE_INSTALL_LIBDIR` too"
This reverts commit f7a33090a9.

Unfortunately this causes a number of failures that didn't show up in my
local build.
2022-08-18 22:46:32 -04:00
LLVM GN Syncbot aaccb2370f [gn build] Port ad8eb85545 2022-08-18 22:43:34 +00:00
LLVM GN Syncbot 6fed13f502 [gn build] Port 0ac597f3ca 2022-08-18 21:18:53 +00:00
Nico Weber d3a1dbc490 [gn build] port f7a33090a9 2022-08-18 15:48:22 -04:00
John Ericson f7a33090a9 [cmake] Use `CMAKE_INSTALL_LIBDIR` too
We held off on this before as `LLVM_LIBDIR_SUFFIX` conflicted with it.
Now we return this.

`LLVM_LIBDIR_SUFFIX` is kept as a deprecated way to set
`CMAKE_INSTALL_LIBDIR`. The other `*_LIBDIR_SUFFIX` are just removed
entirely.

I imagine this is too potentially-breaking to make LLVM 15. That's fine.
I have a more minimal version of this in the disto (NixOS) patches for
LLVM 15 (like previous versions). This more expansive version I will
test harder after the release is cut.

Reviewed By: sebastian-ne, ldionne, #libc, #libc_abi

Differential Revision: https://reviews.llvm.org/D130586
2022-08-18 15:33:35 -04:00
Nico Weber b098407280 [gn build] build libclang_rt.ubsan_osx_dynamic.dylib on mac
For now, this only builds the dylib, so using `-fsanitize=undefined`
with `-static-libsan` or `fsanitize-minimal-runtime` still won't
work -- but the common case does work.

Differential Revision: https://reviews.llvm.org/D131969
2022-08-17 15:35:41 -04:00
LLVM GN Syncbot f09f4b73fc [gn build] Port 5f300397c6 2022-08-16 01:39:36 +00:00
LLVM GN Syncbot a74b028f58 [gn build] Port 2f1fa6242a 2022-08-15 22:49:18 +00:00
Nico Weber 73f0ca806e [gn build] Try to unbreak mac after f56e486fdc 2022-08-15 18:22:08 -04:00
Arthur Eubanks 6d17254df4 [gn build] Add ubsan libraries
clang -fsanitize=undefined works with this.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D131916
2022-08-15 13:55:36 -07:00
LLVM GN Syncbot e83408c6ee [gn build] Port 1cf81274f4 2022-08-14 17:56:25 +00:00
LLVM GN Syncbot 6b6e9d2268 [gn build] Port 7ae66e5e95 2022-08-14 08:35:03 +00:00
Nico Weber 6bb243bbdb [gn build] port 7260cdd2e1 more 2022-08-13 08:41:58 -04:00
Arthur Eubanks bd1f80f54e [llvm-reduce] Add delta pass to run IR passes
The exact IR passes run is customizable via `-ir-passes`.

Reviewed By: regehr

Differential Revision: https://reviews.llvm.org/D123749
2022-08-12 10:38:19 -07:00
Nico Weber 8b3c274efb [gn build] port 3e119c0efd (split-file move to utils/) 2022-08-12 08:20:08 -04:00
Nico Weber 3d53ecfc19 [gn build] port 74384c7fce 2022-08-12 08:10:16 -04:00
Nico Weber d299c033e6 [gn build] Make it possible to do PGO-optimized builds
This is fairly manual for now.

Differential Revision: https://reviews.llvm.org/D131710
2022-08-11 18:39:46 -04:00
LLVM GN Syncbot 88a521a048 [gn build] Port 9ae5896d96 2022-08-11 08:37:36 +00:00
LLVM GN Syncbot e04f8c81d5 [gn build] Port 7bece0f03b 2022-08-11 06:28:14 +00:00
LLVM GN Syncbot a5656496f0 [gn build] Port 7260cdd2e1 2022-08-11 06:28:12 +00:00
Nico Weber e4161e88f3 [gn build] port 59bb9e37c6 2022-08-08 14:16:30 -04:00
Nico Weber cf7c8bd74e [gn build] (manually) port ace6e172bd 2022-08-07 22:02:51 -04:00
Nico Weber f489297501 [gn build] fix 547c551925 2022-08-06 08:36:01 -04:00
Nico Weber 547c551925 [gn build] Try to fix build on linux after std=c++17 switch
glibc annotates `process_vm_readv` with `__THROW`.
lldb/include/lldb/Host/linux/Uio.h and
lldb/source/Host/linux/LibcGlue.cpp don't.

Having a mismatch causes an error with c++17:

    ../../lldb/source/Host/linux/LibcGlue.cpp:18:9:
        error: 'process_vm_readv' is missing exception specification 'throw()'
    ssize_t process_vm_readv(::pid_t pid, const struct iovec *local_iov,
            ^
    ../../lldb/include/lldb/Host/linux/Uio.h:18:9:
        note: previous declaration is here
    ssize_t process_vm_readv(::pid_t pid, const struct iovec *local_iov,
            ^

The diagnostic is a bit misleading, since the previous declaration
in the sysroot (in usr/include/x76_64-linux-gnu/bits/uio-ext.h) is
what has the `__THROW`.

In the cmake build, cmake sets `HAVE_PROCESS_VM_READV` correctly based
on header probing.

In the GN build, just set it to 1 unconditionally on linux. If that
turns out to not be good enough everywhere, we'll have to add a GN arg
for this.

(I'm also setting it to 1 on Android. I'm not sure if that's correct --
but we don't build lldb for Android anyways.)
2022-08-06 08:34:24 -04:00
Nico Weber c59c8a515f [gn build] port b1356504e6 better (c++17) 2022-08-06 07:54:43 -04:00
Nico Weber 51a91d6c5d [gn build] port b1356504e6 (c++17) 2022-08-06 07:51:06 -04:00
Nico Weber 35cc173846 [gn build] port 976f37050d more
Follow-up to commit 51d84737b5.
2022-08-04 15:33:35 -04:00
LLVM GN Syncbot ffb8d4a958 [gn build] Port 4038c859e5 2022-08-04 18:26:38 +00:00
LLVM GN Syncbot 2d47e0fd27 [gn build] Port 2138c90645 2022-08-04 14:49:27 +00:00
LLVM GN Syncbot 2b0d5e9e79 [gn build] Port a203acb9dd 2022-08-04 09:46:03 +00:00
LLVM GN Syncbot ca8de2d242 [gn build] Port 0cb9746a7d 2022-08-03 23:20:59 +00:00
LLVM GN Syncbot 670122b92b [gn build] Port 36c746ca2d 2022-08-03 23:08:51 +00:00
Nico Weber 96faef0f6e [gn build] Set LLVM_TOOLS_INSTALL_DIR to bin for llvm-config
Matches the CMake build, and might help with a flaky test on Windows.
See https://bugs.chromium.org/p/chromium/issues/detail?id=1348730#c2
for details.
2022-08-03 09:51:14 -04:00
LLVM GN Syncbot 7e8bf0a320 [gn build] Port 68264b6494 2022-08-03 05:46:25 +00:00
LLVM GN Syncbot 75f6a10d52 [gn build] Port 6bdb642234 2022-08-03 05:36:28 +00:00
LLVM GN Syncbot 3ddc280c03 [gn build] Port f9b4ea0ce9 2022-08-02 23:57:33 +00:00
LLVM GN Syncbot 577840bc7a [gn build] Port 95a92995d4 2022-08-02 21:01:56 +00:00
Nico Weber 5c6181fd9f [gn build] Port 88181375a3 more 2022-07-30 19:30:53 -04:00
Nico Weber 72d7989031 [gn build] Port 88181375a3 2022-07-30 18:58:10 -04:00
Nico Weber 2063b5ed24 [gn build] (manually) port 507125af3d more 2022-07-29 14:06:10 -04:00
Nico Weber 72d0db596c [gn build] (manually) port 507125af3d 2022-07-29 14:03:32 -04:00
LLVM GN Syncbot 59ea2c64d5 [gn build] Port d52e775b05 2022-07-28 14:44:36 +00:00
LLVM GN Syncbot cf0196db88 [gn build] Port c113594378 2022-07-28 14:37:35 +00:00
LLVM GN Syncbot e293802499 [gn build] Port bb7f62bbbd 2022-07-28 13:30:20 +00:00
Nico Weber dd428a571c [gn build] (manually) port 18b4a8bcf3 more 2022-07-28 07:14:43 -04:00
Martin Storsjö 18b4a8bcf3 [clang-tidy] Rename the make-confusable-table executable
Rename it to clang-tidy-confusable-chars-gen, to make its role
clearer in a wider context.

In cross builds, the caller might want to provide this tool
externally (to avoid needing to rebuild it in the cross build).
In such a case, having the tool properly namespaced makes its role
clearer.

This matches how the clang-pseudo-gen tool was renamed in
a43fef05d4 / D126725.

Differential Revision: https://reviews.llvm.org/D129798
2022-07-28 12:00:20 +03:00
LLVM GN Syncbot 3f6c6e94d6 [gn build] Port e01b4fe956 2022-07-28 08:23:10 +00:00
LLVM GN Syncbot 7fac9c9141 [gn build] Port 8a61749f76 2022-07-28 07:43:55 +00:00
LLVM GN Syncbot a35596675b [gn build] Port 6047deb7c2 2022-07-27 21:44:47 +00:00
LLVM GN Syncbot 0fdf8db727 [gn build] Port 0f3f357e26 2022-07-27 19:04:03 +00:00
Nico Weber 1870a8af15 [gn build] (semi-manually) port 6bdb15fe84 2022-07-27 07:31:32 -04:00
Tom Stellard 809855b56f Bump the trunk major version to 16 2022-07-26 21:34:45 -07:00
LLVM GN Syncbot c17420fdee [gn build] Port 4638d7a28f 2022-07-26 18:27:34 +00:00
Nico Weber 215a792cd5 [gn build] Port 8348c40956 2022-07-26 13:32:14 -04:00
LLVM GN Syncbot 38dce2959e [gn build] Port f4fb72e6d4 2022-07-26 15:44:44 +00:00
Nico Weber a97bb48db8 [gn build] (manually) port a5640968f2 2022-07-26 11:28:05 -04:00
Nico Weber 1ce9887213 [gn build] Port 7a5cb15ea6 2022-07-26 07:34:14 -04:00
Nico Weber a9b21ec484 [gn build] tweak how symbol_exports map files look on linux, for 94c00c10e
After bc39d7bdd4 (ported to GN in 94c00c10e), libclang uses symbol_exports,
and clang/test/LibClang/symbols.test wants the versioned name to be `LLVM_[0-9]$`
instead of `FOO`.
2022-07-26 01:52:00 -04:00
Nico Weber 94c00c10e8 [gn build] port bc39d7bdd4 (libclang.map -> libclang.exports) 2022-07-26 01:39:15 -04:00
LLVM GN Syncbot 80cb0cab4e [gn build] Port b7aa9c4ac8 2022-07-24 20:22:32 +00:00
LLVM GN Syncbot 81f0f5a0e5 [gn build] Port 46ae26e7eb 2022-07-24 17:43:27 +00:00
LLVM GN Syncbot 9daf945367 [gn build] Port 8184b252cd 2022-07-22 07:02:59 +00:00
LLVM GN Syncbot 674cab116d [gn build] Port 1d057a6d43 2022-07-21 21:26:59 +00:00
LLVM GN Syncbot 31049b3d2b [gn build] Port 1dad6247d2 2022-07-21 20:54:39 +00:00
LLVM GN Syncbot f6b5f24c19 [gn build] Port 4fcf8434dd 2022-07-21 00:53:15 +00:00