Commit Graph

15471 Commits

Author SHA1 Message Date
Stella Laurenzo 38151a08c2 Reapply "[cmake] Prefix gtest and gtest_main with "llvm_"."
This reverts commit 7cdda6b8ce.

Differential Revision: https://reviews.llvm.org/D121020
2022-03-04 13:45:43 -08:00
Ellis Hoag 9c35303981 [InstrProf][NFC] Fix warning by removing typecast
This fixes a warning about comparing mismatched types. Since `mmap()` already returns a `void *` use that as the pointer type for comparison.

Reviewed By: kyulee, zequanwu

Differential Revision: https://reviews.llvm.org/D120945
2022-03-04 10:48:25 -08:00
Colin Cross bcc65fb491 Pass through more LIBCXX_* variables to libfuzzer's custom lib++
Pass LIBCXX_HAS_PTHREAD_LIB, LIBCXX_HAS_RT_LIB  and LIBCXXABI_HAS_PTHREAD_LIB
through to the custom lib++ builds so that libfuzzer  doesn't end up with a .deplibs section that
links against those libraries when the variables are set to false.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D120946
2022-03-04 09:31:37 -08:00
Stella Laurenzo 7cdda6b8ce Revert "[cmake] Prefix gtest and gtest_main with "llvm_"."
lldb buildbot failure. will investigate and roll forward.

This reverts commit 9f37775472.
2022-03-02 11:13:46 -08:00
Stella Laurenzo 9f37775472 [cmake] Prefix gtest and gtest_main with "llvm_".
The upstream project ships CMake rules for building vanilla gtest/gmock which conflict with the names chosen by LLVM. Since LLVM's build rules here are quite specific to LLVM, prefixing them to avoid collision is the right thing (i.e. there does not appear to be a path to letting someone *replace* LLVM's googletest with one they bring, so co-existence should be the goal).

This allows LLVM to be included with testing enabled within projects that themselves have a dependency on an official gtest release.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D120789
2022-03-02 10:53:32 -08:00
Hans Wennborg 3e6cfc631b [NFC][hwasan] Check __GLIBCXX__ before checking _GLIBCXX_RELEASE in test
_GLIBCXX_RELEASE wasn't defined before GCC 7.1.

This is another follow-up to https://reviews.llvm.org/D119161
2022-03-01 09:39:26 +01:00
Fangrui Song 19b06fa599 [asan][test] Remove Linux/asan_prelink_test.cpp
glibc 2.37 will remove prelink support. See
https://sourceware.org/pipermail/libc-alpha/2022-January/135565.html for its
broken current state.

Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D120520
2022-02-28 20:26:34 -08:00
David Spickett ee95fe5caa [compiler-rt] Disable coverage trace pc guard tests on Thumb
These are failing on our silent bot:
https://lab.llvm.org/staging/#/builders/162/builds/358

$ <run cmd>
main
foo
bar
baz
SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard-dso.cpp.tmp.2122517.sancov: 2 PCs written
SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard-dso.cpp.tmp_2.so.2122517.sancov: 1 PCs written
SanitizerCoverage: ./sanitizer_coverage_trace_pc_guard-dso.cpp.tmp_1.so.2122517.sancov: 1 PCs written
$ <sancov cmd>
ERROR: Coverage points in binary and .sancov file do not match.

Also reproduces if you build for Thumb on v8 hardware.

Doesn't fail when built with Arm only code so I guess the Thumb mode bit
in the PCs might be the issue.
2022-02-28 11:56:07 +00:00
Kai Luo eb3730cf89 [AIX][cmake][NFC] Customize name of output atomic library
Let `archive-aix-libatomic` accept additional argument to customize name of output atomic library.

Reviewed By: jsji

Differential Revision: https://reviews.llvm.org/D120534
2022-02-28 02:31:56 +00:00
Nikita Popov 8dcb5e6bf5 Revert "[Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON"
See post-commit discussion on https://reviews.llvm.org/D120305.
This change breaks the clang-ppc64le-rhel buildbot, though
there is suspicion that it's an issue with the bot. The change
also had a larger than expected impact on compile-time and
code-size.

This reverts commit 3c4ed02698
and some followup changes.
2022-02-26 15:32:49 +01:00
Fangrui Song 274ec425dc [test] Precisely disable flaky sanitizer tests on clang-ppc64le-redhat
See https://reviews.llvm.org/D120305#3347094
2022-02-26 07:25:44 +00:00
Fangrui Song 71c4b8dfe1 [crt][test] Add -no-pie to avoid wacky linking with crt1.o if (musl || CLANG_DEFAULT_PIE_ON_LINUX)
This works with glibc crt1.o (its crt1.o is essentially Scrt1.o plus (if static
PIE is supported for the arch) _dl_relocate_static_pie) but looks wacky.

musl crt1.o is not built with an explicit -fno-pic/-fpie/-fpic. If it was built
with a non-default-pie GCC/Clang, the linker might complain about absolute
relocations referencing _init/_fini for the -pie link:

```
ld: error: relocation R_X86_64_32 cannot be used against symbol '_fini'; recompile with -fPIC
>>> defined in obj/crt/crt1.o
>>> referenced by crt1.c
>>>               obj/crt/crt1.o:(_start_c)
```
2022-02-26 04:41:49 +00:00
Fangrui Song a8ddd4cc45 Revert "[lsan][test] Temporarily disable ppc64 and ppc64le to appease clang-ppc64le-rhel"
This reverts commit cb76c4d71c.

The failures were in test/sanitizer_common, not in test/lsan.
2022-02-25 18:50:39 +00:00
Fangrui Song d3d73cabc1 [compiler-rt][test] Temporarily disable ppc64 and ppc64le test/sanitizer_common and test/crt
to appease clang-ppc64le-rhel: https://github.com/llvm/llvm-project/issues/54084
2022-02-25 18:49:10 +00:00
Fangrui Song cb76c4d71c [lsan][test] Temporarily disable ppc64 and ppc64le to appease clang-ppc64le-rhel
Seems that ppc64 lsan doesn't work with default PIE (see D120305):
https://lab.llvm.org/buildbot/#/builders/57/builds/15506
2022-02-25 18:25:45 +00:00
Xiaodong Liu a5ee4335c7 [sanitizer] Disable pc guard coverage test on PPC64/s390x
Reviewed By: benshi001, uweigand

Differential Revision: https://reviews.llvm.org/D120541
2022-02-25 21:09:22 +08:00
Vitaly Buka f978497d67 [sanitizer] Don't collect unused info 2022-02-24 20:20:34 -08:00
Xiaodong Liu f1806f967d [sanitizer] Enable trace pc guard coverage test on PPC64/s390x/MIPS
Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D120472
2022-02-25 09:42:22 +08:00
Fangrui Song 611122892e [asan][test] asan_prelink_test.cpp: use -fno-pie -no-pie
prelink (will be removed by glibc 2.37) does not support PIE.
2022-02-24 16:09:18 -08:00
Xiaodong Liu 56b5f00186 [sancov][sanitizer-common] Correct sanitizer coverage point
Sanitizer coverage point should be the previous instruction PC of the
caller and the offset to the previous instruction might be different
on each CPU architecture.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D119233
2022-02-24 17:16:45 +08:00
Vitaly Buka 924032c592 [NFC][hwasan] Check _GLIBCXX_RELEASE in test
Differential Revision: https://reviews.llvm.org/D119161
2022-02-23 14:31:47 -08:00
Vitaly Buka c990d56d42 [HWASan] Use hwasan_memalign for aligned new.
Aligned new does not require size to be a multiple of alignment, so
memalign is the correct choice instead of aligned_alloc.

Fixes false reports for unaligned sizes.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D119161
2022-02-23 14:22:03 -08:00
Vitaly Buka 5e1ae3aba2 [NFC][hwasan] Clang-format the file 2022-02-23 14:18:45 -08:00
Fangrui Song 632ea6929d [sanitizer][sancov] Use pc-1 for s390x
The stack trace addresses may be odd (normally addresses should be even), but
seems a good compromise when the instruction length (2,4,6) cannot be detected
easily.

Reviewed By: uweigand

Differential Revision: https://reviews.llvm.org/D120432
2022-02-23 13:35:22 -08:00
Martin Liska 78f7a6fbe5 [PATCH] ASAN: Align declaration with definition of a fn
Fixes:
https://bugs.llvm.org/show_bug.cgi?id=51641

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D115447
2022-02-23 11:28:10 -08:00
Xu Mingjie f19f672328 [TSan][NFC] fixup for comment of Shadow
There should be 1-bit unused field between tid field and is_atomic field of Shadow.

Reviewed By: dvyukov, vitalybuka

Differential Revision: https://reviews.llvm.org/D119417
2022-02-23 11:24:24 -08:00
Vitaly Buka 475c43339b Revert "[TSan][NFC] fixup for comment of Shadow"
Wrong author.

This reverts commit 6bff092e3e.
2022-02-23 11:24:24 -08:00
Vitaly Buka 6bff092e3e [TSan][NFC] fixup for comment of Shadow
There should be 1-bit unused field between tid field and is_atomic field of Shadow.

Reviewed By: dvyukov, vitalybuka

Differential Revision: https://reviews.llvm.org/D119417
2022-02-23 11:16:25 -08:00
Tobias Hieta 8182dba0c2 [compiler-rt][builtins] Fix CMake builtin target flag
clang-cl doesn't support -target <target>, instead it only supports
--target=<target> so building a RUNTIME configuration for clang-cl
ended up in never building builtins. Which in turn lead to clang-cl
not being able to find the runtime libraries because we depend
on the compiler_rt.builtins.lib being in the runtime dir for the
Driver to add it as a candidate.

I don't think this should have any downsides since most the code
these days are using --target=<target> instead of the old syntax.

Reviewed By: mstorsjo

Differential Revision: https://reviews.llvm.org/D120308
2022-02-23 10:23:17 +01:00
Alex Lorenz f5153d9e72 [compiler-rt][builtins] build the macOS compiler-rt built-ins with Mac Catalyst support
This patch extends compiler-rt's cmake config to build macOS builtins with both macOS and Mac Catalyst support.
This is done by telling the compiler to emit macho files with two build version load commands.

Differential Revision: https://reviews.llvm.org/D118875
2022-02-22 19:32:19 -08:00
Fangrui Song fc0bd3c2ce [libFuzzer] Refactor GetNextInstructionPc/GetPreviousInstructionPc
Port the change to compiler-rt/lib/fuzzer/FuzzerTracePC.cpp .
Update RISCV to use PC-2: this is coarse (C extension may be disabled) but
sufficient for pure symbolization purpose.

The commit is separate from D120362 so that bisecting/reverting is easier.
2022-02-22 16:25:57 -08:00
Fangrui Song 3de5322b5f [sanitizer] Refactor GetNextInstructionPc/GetPreviousInstructionPc
x86 uses offset 1 while most RISC architectures use offset 4.
Check x86 first to prevent changes for new RISC architectures.

Reviewed By: #sanitizers, vitalybuka

Differential Revision: https://reviews.llvm.org/D120362
2022-02-22 16:20:40 -08:00
Rainer Orth cb8e9bea95 [sanitizer_common] Use GetStaticTlsBoundary on Solaris 11.4
This is a restricted alternative to D91605
<https://reviews.llvm.org/D91605> which only works on Solaris 11.4 SRU 10+,
but would break the build on Solaris 11.3 and Illumos which lack
`dlpi_tls_modid`.

Apart from that, the patch is trivial.  One caveat is that the
`sanitizer_common` and `asan` tests need to be linked explicitly with `ld
-z relax=transtls` on Solaris/amd64 since the archives with calls to
`__tls_get_addr` are linked in directly.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.

Differential Revision: https://reviews.llvm.org/D120048
2022-02-22 20:18:22 +01:00
Gulfem Savrun Yeniceri 4961bb477d [gwp_asan] Add missing <algorithm> include
After https://reviews.llvm.org/D119667, <algorithm> is no longer
transitively included from various headers. This patch adds the
<algorithm> include into gwp_asan.

Differential Revision: https://reviews.llvm.org/D120172
2022-02-19 01:14:14 +00:00
Gulfem Savrun Yeniceri 3d728ef0ba [scudo] Add missing <algorithm> include
After https://reviews.llvm.org/D119667, <algorithm> is no longer
transitively included from various headers. This patch adds the
<algorithm> include into scudo.

Differential Revision: https://reviews.llvm.org/D120171
2022-02-19 01:14:14 +00:00
Snehasish Kumar 0a4184909a Reland "[memprof] Extend the index prof format to include memory profiles."
This patch adds support for optional memory profile information to be
included with and indexed profile. The indexed profile header adds a new
field which points to the offset of the memory profile section (if
present) in the indexed profile. For users who do not utilize this
feature the only overhead is a 64-bit offset in the header.

The memory profile section contains (1) profile metadata describing the
information recorded for each entry (2) an on-disk hashtable containing
the profile records indexed via llvm::md5(function_name). We chose to
introduce a separate hash table instead of the existing one since the
indexing for the instrumented fdo hash table is based on a CFG hash
which itself is perturbed by memprof instrumentation.

This commit also includes the changes reviewed separately in D120093.

Differential Revision: https://reviews.llvm.org/D120103
2022-02-17 22:09:52 -08:00
Vitaly Buka c046cff1cf [msan] strsignal interceptor
Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D120082
2022-02-17 18:13:35 -08:00
Snehasish Kumar 19bdf44d85 Revert "Reland "[memprof] Extend the index prof format to include memory profiles.""
This reverts commit 807ba7aace.
2022-02-17 15:51:04 -08:00
Mitch Phillips 62914bad46 [ASan] Fix TLS teardown.
TLS teardown is currently broken, as we unpoison the shadow a little bit
and to the right of the TLS section, rather than the full TLS section
itself. This currently breaks at -O0, and breaks with some upcoming
globals code that I have.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D120080
2022-02-17 13:34:36 -08:00
Snehasish Kumar 807ba7aace Reland "[memprof] Extend the index prof format to include memory profiles."
This reverts commit 85355a560a.

This patch adds support for optional memory profile information to be
included with and indexed profile. The indexed profile header adds a new
field which points to the offset of the memory profile section (if
present) in the indexed profile. For users who do not utilize this
feature the only overhead is a 64-bit offset in the header.

The memory profile section contains (1) profile metadata describing the
information recorded for each entry (2) an on-disk hashtable containing
the profile records indexed via llvm::md5(function_name). We chose to
introduce a separate hash table instead of the existing one since the
indexing for the instrumented fdo hash table is based on a CFG hash
which itself is perturbed by memprof instrumentation.

Differential Revision: https://reviews.llvm.org/D118653
2022-02-17 13:14:17 -08:00
Alexander Potapenko be77afe43d tsan: Add a missing disable_sanitizer_instrumentation attribute
Turns out the test was working by accident: we need to ensure
TSan instrumentation is not called from the fork() hook, otherwise the
tool will deadlock. Previously it worked because alloc_free_blocks() got
inlined into __tsan_test_only_on_fork(), but it cannot always be the
case.

Adding __attribute__((disable_sanitizer_instrumentation)) will prevent
TSan from instrumenting alloc_free_blocks().

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D120050
2022-02-17 15:34:41 +01:00
Eli Friedman 0389f2edf7 Revert "[compiler-rt] Implement ARM atomic operations for architectures without SMP support"
This reverts commit 910a642c0a.

There are serious correctness issues with the current approach: __sync_*
routines which are not actually atomic should not be enabled by default.

I'll continue discussion on the review.
2022-02-17 02:17:27 -08:00
Eli Friedman d20e01bb06 Revert "[NFC][compiler-rt] Format file lib/builtins/arm/sync-ops.h"
This reverts commit f165c23bf3.

Part of revert sequence for 910a642c0a.
2022-02-17 02:16:25 -08:00
Pavel Kosov f165c23bf3 [NFC][compiler-rt] Format file lib/builtins/arm/sync-ops.h 2022-02-17 10:21:22 +03:00
Pavel Kosov 910a642c0a [compiler-rt] Implement ARM atomic operations for architectures without SMP support
ARMv5 and older architectures don’t  support SMP and do not have atomic instructions. Still they’re in use in IoT world, where one has to stick to libgcc.

Reviewed By: mstorsjo

Differential Revision: https://reviews.llvm.org/D116088
2022-02-17 10:11:25 +03:00
Florian Mayer 014c0333b9 [NFC] Fix order in global_symbols.txt.
I added posix_madvise out of order before.
2022-02-16 13:34:02 -08:00
Florian Mayer d9d12bea82 Fix build_symbolizer.sh.
We now use posix_madvise, so we need to allow this symbol.

Differential Revision: https://reviews.llvm.org/D119970
2022-02-16 13:06:27 -08:00
Christopher Di Bella c5a20b5182 [llvm-libgcc] initial commit
Note: the term "libgcc" refers to the all of `libgcc.a`, `libgcc_eh.a`,
and `libgcc_s.so`.

Enabling libunwind as a replacement for libgcc on Linux has proven to be
challenging since libgcc_s.so is a required dependency in the [Linux
standard base][5]. Some software is transitively dependent on libgcc
because glibc makes hardcoded calls to functions in libgcc_s. For example,
the function `__GI___backtrace` eventually makes its way to a [hardcoded
dlopen to libgcc_s' _Unwind_Backtrace][1]. Since libgcc_{eh.a,s.so} and
libunwind have the same ABI, but different implementations, the two
libraries end up [cross-talking, which ultimately results in a
segfault][2].

To solve this problem, libunwind needs to build a “libgcc”. That is, link
the necessary functions from compiler-rt and libunwind into an archive
and shared object that advertise themselves as `libgcc.a`, `libgcc_eh.a`,
and `libgcc_s.so`, so that glibc’s baked calls are diverted to the
correct objects in memory. Fortunately for us, compiler-rt and libunwind
use the same ABI as the libgcc family, so the problem is solvable at the
llvm-project configuration level: no program source needs to be edited.
Thus, the end result is for a user to configure their LLVM build with a
flag that indicates they want to archive compiler-rt/unwind as libgcc.
We achieve this by compiling libunwind with all the symbols necessary
for compiler-rt to emulate the libgcc family, and then generate symlinks
named for our "libgcc" that point to their corresponding libunwind
counterparts.

We alternatively considered patching glibc so that the source doesn't
directly refer to libgcc, but rather _defaults_ to libgcc, so that a
system preferring compiler-rt/libunwind can point to these libraries
at the config stage instead. Even if we modified the Linux standard
base, this alternative won't work because binaries that are built using
libgcc will still end up having crosstalk between the differing
implementations.

This problem has been solved in this manner for [FreeBSD][3], and this
CL has been tested against [Chrome OS][4].

[1]: https://github.com/bminor/glibc/blob/master/sysdeps/arm/backtrace.c#L68
[2]: https://bugs.chromium.org/p/chromium/issues/detail?id=1162190#c16
[3]: https://github.com/freebsd/freebsd-src/tree/main/lib/libgcc_s
[4]: https://chromium-review.googlesource.com/c/chromiumos/overlays/chromiumos-overlay/+/2945947
[5]: https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/libgcc-s.html

Differential Revision: https://reviews.llvm.org/D108416
2022-02-16 17:06:45 +00:00
Tim Northover 4b120c8d63 Compiler-rt: build fp_mode.c for macho_embedded variants too.
It provides some functions needed by add/sub.
2022-02-16 13:37:24 +00:00
Snehasish Kumar 50713461d4 Reland "[memprof] Introduce a wrapper around MemInfoBlock."
This reverts commit e6999040f5.

Update test to fix signed int comparison warning, fix whitespace in
compiler-rt MIBEntryDef.inc file.

Differential Revision: https://reviews.llvm.org/D117256
2022-02-14 19:04:36 -08:00