summaryrefslogtreecommitdiff
path: root/compiler-rt
AgeCommit message (Collapse)Author
2025-11-22[UBSan] Fix test-darwin-interface.c on X86 Darwin with Internal Shell (#169105)Aiden Grossman
This test was failing with the internal shell due to the use of subshells. This was not caught in my initial round of testing due to me only using a M4 Mac for running my tests.
2025-11-21[ORC] Fix obj-imageinfo.S on X86 Darwin with Internal Shell (#169104)Aiden Grossman
d464c99f595b69d3a34b361b6a935e803c60d308 fixes this test on AArch64 Darwin, but I did not realize that there was another X86 version of the test. This patch also updates the X86 version of the test in a similar manner.
2025-11-21[profdata] Skip probes with missing counter and function pointers (#163254)Ellis Hoag
2025-11-21[scudo] Small cleanup of memory tagging code part 2. (#168807)Christopher Ferris
Make the systemSupportsMemoryTagging() function return even on system that don't support memory tagging. This avoids the need to always check if memory tagging is supported before calling the function. Modify iterateOverChunks() to call useMemoryTagging<>(Options) to determine if mte is supported. This already uses the cached check of systemSupportsMemoryTagging() rather than directly calling that function. Updated the code that calls systemSupportsMemoryTagging().
2025-11-21[TSan] [Darwin] Fix off by one in TSAN init due to MemoryRangeIsAvailable ↵Andrew Haberlandt
(#169008)
2025-11-21Revert "[ubsan_minimal] Allow UBSan handler from Minimal runtime to accept ↵Vitaly Buka
arguments (#152192)" (#168812) This partially reverts #152192, keeping updated tests and some code reordering in clang/lib/CodeGen/CGExpr.cpp. compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp is exact revert (with followup #152419) We don't have a good use case for that, so revert it before we are stuck maintaining this API. 21.x does not have this patch. This reverts commit a1209d868632b8aea10450cd2323848ab0b6776a.
2025-11-20Revert "[UBSan] [compiler-rt] add preservecc variants of handlers" (#168973)Florian Mayer
Reverts llvm/llvm-project#168643
2025-11-20[UBSan] [compiler-rt] add preservecc variants of handlers (#168643)Florian Mayer
2025-11-20[compiler-rt] [test] Generalize an UNSUPPORTED marking (#168858)Martin Storsjö
Don't specifically target windows-msvc - the same goes for any windows target; mingw doesn't have dlfcn.h either.
2025-11-20[ASAN] Disable broken __SANITIZER_DISABLE_CONTAINER_OVERFLOW__ tests on ↵Andrew Haberlandt
iOS/Android (#168821) The tests added by #163468 appear to be broken due to lack of libcxx support (?). Marking unsupported everywhere for now since it passes on some platforms and fails on others, and I don't know the full list. Android fail: https://lab.llvm.org/buildbot/#/builders/186/builds/14106
2025-11-20Revert "[compiler-rt] Default to Lit's Internal Shell (#168232)"Aiden Grossman
This reverts commit b725bdba1faf256c725f5fd12c581acb381bf0d3. This is still causing Darwin failures. There are six tests that are still failing: AddressSanitizer-x86_64-darwin.TestCases/Posix.deep_call_stack.cpp AddressSanitizer-x86_64-darwin.TestCases.scariness_score_test.cpp AddressSanitizer-x86_64h-darwin.TestCases/Posix.deep_call_stack.cpp ORC-x86_64-darwin.TestCases/Darwin/x86-64.objc-imageinfo.S UBSan-Minimal-x86_64-darwin.TestCases.test-darwin-interface.c UBSan-Minimal-x86_64h-darwin.TestCases.test-darwin-interface.c There are a couple failure modes: 1. deep_call_stack.cpp and scariness_score_test.cpp are failing due to ulimit issues that we have observed previously. 2. objc-imageinfo.S is failing in the x86 variant because I only updated the AArch64 variant. 3. test-darwin-interface.c is using subshells, so obviously fails with the internal shell. Also looks like this one did not run on my system due to it requiring x86_64 Darwin.
2025-11-20[sanitizer_common] posix_spawn test should forward DYLD_LIBRARY_PATH (#168795)Andrew Haberlandt
This test explicitly sets the environment for a spawned process. Without DYLD_LIBRARY_PATH, the spawned process may use a ASAN runtime other than the one that was used by the parent process That other runtime library may not work at all, or may not be in the default search path. Either case can cause the spawned process to die before it makes it to main, thus failing the test. The compiler-rt lit config sets the library path variable [here](https://github.com/llvm/llvm-project/blob/main/compiler-rt/test/lit.common.cfg.py#L84) (i.e. to ensure that just-built runtimes are used for tests, in the case of a standalone compiler-rt build), and that is currently used by the parent process but not the spawned ones. My change only forwards the variable for Darwin (DYLD_LIBRARY_PATH), but we **_ought_** to also forward the variable for other platforms. However, it's not clear that there's any good way to plumb this into the test, since some platforms actually have multiple library path variables which would need to be forwarded (see: SunOS [here](https://github.com/llvm/llvm-project/blob/main/compiler-rt/test/lit.common.cfg.py#L102)). I considered adding a substitution variable for the library path variable, but that doesn't really work if there's multiple such variables.
2025-11-20Reapply "[compiler-rt] Default to Lit's Internal Shell (#168232)" (#168760)Aiden Grossman
This reverts commit eb20b5392599996ce94e4c0392095cacaa33687c. This relands the compiler-rt internal shell after XRay and Darwin tests that were failing under the internal shell have been fixed.
2025-11-19Better fix for the stack_container_dynamic_lib test (#168798)Paddy McDonald
Add the missing %libdl to the link command
2025-11-19Disable test under GCC (#168792)Paddy McDonald
New test stack_container_dynamic_lib.cpp has errors under gcc. Require clang while better fix is investigated
2025-11-19[ASan] Document define to disable container overflow checks at compile time. ↵Paddy McDonald
(#163468) Document a define to allow library developers to support disabling AddressSanitizer's container overflow detection in template code at compile time. The primary motivation is to reduce false positives in environments where libraries and frameworks that cannot be recompiled with sanitizers enabled are called from application code. This supports disabling checks when the runtime environment cannot be reliably controlled to use ASAN_OPTIONS. Key changes: - Use the define `__SANITIZER_DISABLE_CONTAINER_OVERFLOW__` to disable instrumentation at compile time - Implemented redefining the container overflow APIs in common_interface_defs.h to use define to provide null implementation when define is present - Update documentation in AddressSanitizer.rst to suggest and illustrate use of the define - Add details of the define in PrintContainerOverflowHint() - Add test disable_container_overflow_checks to verify new hints on the error and fill the testing gap that ASAN_OPTIONS=detect_container_overflow=0 works - Add tests demonstrating the issue around closed source libraries and instrumented apps that both modify containers This requires no compiler changes and should be supportable cross compiler toolchains. An RFC has been opened to discuss: https://discourse.llvm.org/t/rfc-add-fsanitize-address-disable-container-overflow-flag-to-addresssanitizer/88349
2025-11-19[gn] "port" 5efce7392f3f (arm 32-bit asm compiler-rt)Nico Weber
2025-11-19[Fuzzer] make big-file-copy.test work with the internal shell (#168658)Aiden Grossman
This patch uses several shell features not supported by the internal shell, such as $? to get the exit code of a command, and exit. This patch adjusts the test to work with the internal shell by using bash to run the actual command with a zero exit code to ensure the file is deleted, and python to propagate the exit code up to lit.
2025-11-19[ASan] Make duplicate_os_log_reports.cpp work with the internal shellAiden Grossman
This test used a for loop to implement retries and also did some trickery with PIDs. For this test, just invoke bash for actually running the test given we need the PID, and move the for loop into a separate shell script file that we can then invoke from within the test. Normally it would make sense to rewrite such a script in Python, but given this test does not have portability concerns only running on Darwin, it is fine to use a shell script here given there is no other convenient alternative. Reviewers: ndrewh, DanBlackwell, fmayer Reviewed By: ndrewh Pull Request: https://github.com/llvm/llvm-project/pull/168656
2025-11-19[ASan] Make dyld_insert_libraries_reexec work with internal shellAiden Grossman
This test was doing some feature checks within the test itself. This patch rewrites the feature checks to be done in a fashion more idiomatic to lit, as the internal shell does not support the features needed for the previous feature checks. Reviewers: ndrewh, DanBlackwell, fmayer Reviewed By: ndrewh Pull Request: https://github.com/llvm/llvm-project/pull/168655
2025-11-19[compiler-rt] [libFuzzer] Fix merge-posix test (again) (#168639)Andrew Haberlandt
2025-11-19[ASan] Fix interface_symbols_darwin.cpp on internal shellAiden Grossman
This test turned out to not actually be that interested. There was just a subshell usage that needed replacing with readfile, and then the test just works. Reviewers: fmayer, DanBlackwell, ndrewh Reviewed By: ndrewh Pull Request: https://github.com/llvm/llvm-project/pull/168654
2025-11-19[asan] Implement address sanitizer on AIX: platform support (#139587)Jake Egan
Adds some general changes for supporting asan on AIX. Issue: #138916
2025-11-19[Runtimes] Default build must use its own output dirs (#168266)Michael Kruse
Post-commit fix of #164794 reported at https://github.com/llvm/llvm-project/pull/164794#issuecomment-3536253493 `LLVM_LIBRARY_OUTPUT_INTDIR` and `LLVM_RUNTIME_OUTPUT_INTDIR` is used by `AddLLVM.cmake` as output directories. Unless we are in a bootstrapping-build, It must not point to directories found by `find_package(LLVM)` which may be read-only directories. MLIR for instance sets thesese variables to its own build output directory, so should the runtimes.
2025-11-18[ASan] Make most tests run under internal shell on DarwinAiden Grossman
This patch fixes most of the ASan tests that were failing on Darwin when running under the internal shell. There are still a couple left that are more interesting cases that I'll do in a follow up patch. The tests that still need to be done: ``` TestCases/Darwin/duplicate_os_log_reports.cpp TestCases/Darwin/dyld_insert_libraries_reexec.cpp TestCases/Darwin/interface_symbols_darwin.cpp ``` Reviewers: thetruestblue, fhahn, vitalybuka, DanBlackwell, ndrewh Reviewed By: DanBlackwell Pull Request: https://github.com/llvm/llvm-project/pull/168545
2025-11-18[TSan] Make tests work with internal shellAiden Grossman
This patch makes all tsan tests work with the internal shell on Darwin. Tests were using various features not supported by the internal shell, mainly subshells and not using env to set environment variables. This patch also fixes one of the dynamiclib substitutions to not use a subshell. Reviewers: ndrewh, DanBlackwell, fmayer, vitalybuka Reviewed By: DanBlackwell Pull Request: https://github.com/llvm/llvm-project/pull/168544
2025-11-18[RTSan] Fix tests under Internal Shell (#168470)Aiden Grossman
This patch fixes the only RTSan test that was broken by enabling lit's internal shell on Darwin. This patch rewrites the test to prefix env variables with `env` and to avoid the use of subshells.
2025-11-18[compiler-rt][ARM] Optimized mulsf3 and divsf3 (#168394)Simon Tatham
(Reland of #161546, fixing three build and test issues) This commit adds optimized assembly versions of single-precision float multiplication and division. Both functions are implemented in a style that can be assembled as either of Arm and Thumb2; for multiplication, a separate implementation is provided for Thumb1. Also, extensive new tests are added for multiplication and division. These implementations can be removed from the build by defining the cmake variable COMPILER_RT_ARM_OPTIMIZED_FP=OFF. Outlying parts of the functionality which are not on the fast path, such as NaN handling and underflow, are handled in helper functions written in C. These can be shared between the Arm/Thumb2 and Thumb1 implementations, and also reused by other optimized assembly functions we hope to add in future.
2025-11-17[ORC] Make tests work with Internal Shell (#168471)Aiden Grossman
This patch makes objc-imageinfo.S work with the internal shell. The test uses a subshell to temporarily change the directory. The internal shell does not support subshells, so this construct was replaced with a pushd/popd sequence.
2025-11-18Revert "Reapply "[compiler-rt] Default to Lit's Internal Shell" (#168232)"Aiden Grossman
This reverts commit bde90624185ea2cead0a8d7231536e2625d78798. This caused failures on Darwin that were not caught by upstream buildbots. Reverting for now to give myself some time to fix.
2025-11-17[scudo] Skip test if mlock fails. (#168448)Christopher Ferris
Some linux versions might not support the mlock call, so skip that part of the test if the mlock fails.
2025-11-17[scudo] Fix wrong return type. (#168157)Christopher Ferris
2025-11-17[compiler-rt] [libFuzzer] Fix merge-posix.test file size test (#168137)Andrew Haberlandt
This test uses `ulimit -f 1` to test what libFuzzer does when trying to create a file > **_1KB_**. However, the none of the input files used by this test are actually >= 1KB, so there's no reason to expect this test to pass. This test appears to be passing on accident since the "control file" happens to be > 1KB, but this is not always the case depending upon the length of the path where the test is run from. This modifies the test to ensure that one of the input file is actually >1KB.
2025-11-17[compiler-rt][Profile] Mark Darwin test work with internal shellAiden Grossman
This test was using subshells and then passing the results to diff. Write out the results to files before passing to diff as the internal shell does not support subshells.
2025-11-17[XRay] Rewrite tests to not use subshellsAiden Grossman
So that they will actually function with the internal shell.
2025-11-17[XRay] Prefix setting XRAY_OPTIONS with envAiden Grossman
So setting the environment variable works with the new internal shell. This does not fix all the XRay tests because some of them are using subshells and need to be rewritten to not use subshells.
2025-11-16Reapply "[compiler-rt] Default to Lit's Internal Shell" (#168232)Aiden Grossman
This reverts commit 8cc49fb99a4798f67b6b70fabfd584095d022e92. This was causing failures on two specific buildbots that have since been fixed.
2025-11-16[compiler-rt] Update test to export variables instead of using envAiden Grossman
To work around a bug in lit's internal test runner around ulimit. Commands that use env to set environment variables for that command do not have limits applied to them. This needs to be fixed, but for now we can work around without degrading the readability of the test too much.
2025-11-15[X86] Remove vector length (256 vs 512) distinction of AVX10 (#167736)Mikołaj Piróg
As in title. AVX10.x doesn't distinguish between available vector lengths. -mattr=avx10.x-512 and defining of macros with _512 is kept for compatibility. Bit-positions of avx10.1/2 features in compiler-rt and X86TargetParser are synced to match those in the gcc.
2025-11-14[compiler-rt] [Darwin] Strip MTE tags from ASAN and TSAN (#166453)Andrew Haberlandt
ASAN and TSAN need to strip tags in order to compute the correct shadow addresses. rdar://163518624
2025-11-13[dfsan] Fix Endianess issue (#162881)anoopkg6
Fix Endianess issue with getting shadow 4 bytes corresponding to the first origin pointer. --------- Co-authored-by: anoopkg6 <anoopkg6@github.com>
2025-11-13[sanitizer-common] [Darwin] Fix overlapping dyld segment addresses (attempt ↵Andrew Haberlandt
2) (#167800) This re-lands #166005, which was reverted due to the issue described in #167797. There are 4 small changes: - Fix LoadedModule leak by calling Clear() on the modules list - Fix internal_strncpy calls that are not null-terminated - Improve test to accept the dylib being loaded from a different path than compiled `{{.*}}[[DYLIB]]` - strcmp => internal_strncmp This should not be merged until after #167797. rdar://163149325
2025-11-13[sanitizer_common] Add darwin-specific MemoryRangeIsAvailable (#167797)Andrew Haberlandt
The fixes a TOCTOU bug in the code that initializes shadow memory in ASAN: https://github.com/llvm/llvm-project/blob/4b05581bae0e3432cfa514788418fb2fc2144904/compiler-rt/lib/asan/asan_shadow_setup.cpp#L66-L91 1. During initialization, we call `FindDynamicShadowStart` to search the memory mapping for enough space to dynamically allocate shadow memory. 2. We call `MemoryRangeIsAvailable(shadow_start, kHighShadowEnd);`, which goes into `MemoryMappingLayout`. 3. We actually map the shadow with `ReserveShadowMemoryRange`. In step 2, `MemoryMappingLayout` makes various allocations using the internal allocator. This can cause the allocator to map more memory! In some cases, this can actually allocate memory that overlaps with the shadow region returned by` FindDynamicShadowStart` in step 1. This is not actually fatal, but it memory corruption; MAP_FIXED is allowed to overlap other regions, and the effect is any overlapping memory is zeroed. ------ To address this, this PR implements `MemoryRangeIsAvailable` on Darwin without any heap allocations: - Move `IntervalsAreSeparate` into sanitizer_common.h - Guard existing sanitizer_posix implementation of `MemoryRangeIsAvailable` behind !SANITIZER_APPLE - `IsAddressInMappedRegion` in sanitizer_mac becomes `MemoryRangeIsAvailable`, which also checks for overlap with the DYLD shared cache. After this fix, it should be possible to re-land #166005, which triggered this issue on the x86 iOS simulators. rdar://164208439
2025-11-13[scudo] Always zero on linux even if the memory cannot be released. (#167788)Christopher Ferris
If a caller has locked memory, then the madvise call will fail. In that case, zero the memory so that we don't return non-zeroed memory for calloc calls since we thought the memory had been released.
2025-11-13Revert "[compiler-rt][ARM] Optimized mulsf3 and divsf3" (#167906)Simon Tatham
Reverts llvm/llvm-project#161546 One of the buildbots reported a cmake error I don't understand, and which I didn't get in my own test builds: ``` CMake Error at /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/compiler-rt/cmake/Modules/CheckAssemblerFlag.cmake:23 (try_compile): COMPILE_DEFINITIONS specified on a srcdir type TRY_COMPILE ``` My best guess is that the thing I did in `CheckAssemblerFlag.cmake` only works on some versions of cmake. But I don't understand the problem well enough to fix it quickly, so I'm reverting the whole patch and will reland it later.
2025-11-13[compiler-rt][ARM] Optimized mulsf3 and divsf3 (#161546)Simon Tatham
This commit adds optimized assembly versions of single-precision float multiplication and division. Both functions are implemented in a style that can be assembled as either of Arm and Thumb2; for multiplication, a separate implementation is provided for Thumb1. Also, extensive new tests are added for multiplication and division. These implementations can be removed from the build by defining the cmake variable COMPILER_RT_ARM_OPTIMIZED_FP=OFF. Outlying parts of the functionality which are not on the fast path, such as NaN handling and underflow, are handled in helper functions written in C. These can be shared between the Arm/Thumb2 and Thumb1 implementations, and also reused by other optimized assembly functions we hope to add in future.
2025-11-13Revert "[compiler-rt] [builtins] Remove unused/misnamed x86 chkstk functions"Martin Storsjö
This reverts parts of commit 885d7b759b5c166c07c07f4c58c6e0ba110fb0c2, and adds verbose comments explaining all the variants of this function, for clarity for future readers. It turns out that those functions actually weren't misnamed or unused after all: Apparently Clang doesn't match GCC when it comes to what stack probe function is referenced on i386 mingw. GCC < 4.6 references a symbol named "___chkstk", with three leading underscores, and GCC >= 4.6 references "___chkstk_ms". Restore these functions, to allow linking object files built with GCC with compiler-rt.
2025-11-13Revert "[compiler-rt] Rename the now lone i386/chkstk2.S to i386/chkstk.S"Martin Storsjö
This reverts commit 1f9eff100ce8faea1284d68b779d844c6e019b77. This is done in preparation of reverting parts of 885d7b759b5c166c07c07f4c58c6e0ba110fb0c2.
2025-11-13[ASan] Fix forward 141c2bAiden Grossman
When landing 141c2b I didn't realize that none of these files actually got built either locally or by premerge. I had some minor syntax mistakes that caused the build to fail. This patch fixes those issues and has been verified on a Windows machine.
2025-11-12[ASan][Windows] Add new instruction sizes (#167734)Aiden Grossman
These instructions show up when building asan in the premerge container and do not on other bots, likely due to different standard library versions.