64 Commits
Author SHA1 Message Date
Jacek Caban 986847858c Add ARM64X support
Extend the aarch64-w64-mingw32 prefix to provide ARM64EC libraries
alongside standard AArch64 libraries, replacing the separate
arm64ec-w64-mingw32 prefix. This aligns with how MSVC distributes
ARM64EC libraries and enables the linker to process both targets
simultaneously into a single hybrid binary.

This extensively utilizes LLVM's -marm64x option, compiling both
targets in a single compiler invocation to produce hybrid object
files (unlike MSVC tools, which require separate compilation passes).
2026-08-12 12:18:44 +03:00
Martin Storsjö 975930b5b7 Revert "Add ARM64X support"
This reverts commit 64effa9a71.

It turns out that the LLD handling of the TLS data structures
("_tls_used" and "_tls_index") needs more work, causing the
arm64ec side of arm64x binaries to not get them hooked up properly.
2026-07-28 18:44:59 +03:00
Jacek Caban 64effa9a71 Add ARM64X support
Extend the aarch64-w64-mingw32 prefix to provide ARM64EC libraries
alongside standard AArch64 libraries, replacing the separate
arm64ec-w64-mingw32 prefix. This aligns with how MSVC distributes
ARM64EC libraries and enables the linker to process both targets
simultaneously into a single hybrid binary.

This extensively utilizes LLVM's -marm64x option, compiling both
targets in a single compiler invocation to produce hybrid object
files (unlike MSVC tools, which require separate compilation passes).
2026-07-27 19:08:32 +02:00
Martin Storsjö abc77c22a8 build-compiler-rt: Stop providing asan in msvcrt builds
See 0b296aefc0 for context, where
we stopped testing asan in msvcrt builds - see discussion at
https://github.com/llvm/llvm-project/pull/120397,
https://github.com/mstorsjo/llvm-mingw/issues/224 and
https://github.com/mstorsjo/llvm-mingw/issues/552.

This should make it clearer that asan isn't supported in msvcrt
builds, instead of silently just providing files that are known
not to work.

See 4718b81419 for earlier context
for where we remove the asan runtimes in armv7/aarch64 builds,
where the files do get built, but they don't work properly yet
(even on UCRT).
2026-03-22 12:45:58 +02:00
Martin Storsjö cb92de78e7 Include arm64ec in the lists of all architectures
Since LLVM 21.x, the upstream support for ARM64EC in LLD and
compiler-rt is complete enough for us to be able to build it.
2025-07-17 22:48:39 +03:00
Martin Storsjö 454962132a build-compiler-rt: Add an option for compiling runtimes for the native OS 2025-06-25 11:51:06 +03:00
Jacek Caban 486d72ff9e Merge aarch64 and arm64ec compiler-rt libs
Clang expects the aarch64 compiler-rt name on ARM64EC. While this could be adjusted
in Clang, the current approach mirrors MSVC, where the core CRT is provided as
archives containing both EC and native support. Ideally, the LLVM build system would
handle this automatically, but for now we can merge it here.
2025-05-18 22:28:25 +03:00
Martin Storsjö c4d1bda332 build-compiler-rt: Don't assume that the build produced asan files for armv7/aarch64
When removing them, also accept that they are missing to begin
with.

Since 655933070219f2b6f3a457c7e5af7edd4b5291b4 in llvm-project
(Apr 25th), asan only gets built for x86.
2025-04-26 07:21:14 +03:00
Martin Storsjö 4718b81419 build-compiler-rt: Build all runtimes for aarch64 and armv7 too
Since 0c391133c9201ef29273554a1505ef855ce17668 in llvm-project
(LLVM 17), the sanitizers can be built for aarch64, and since
5ea9dd8c7076270695a1d90b9c73718e7d95e0bf (backported to
LLVM 19.1.0 RC 4), they can be built for armv7 too.

While they can be built, address sanitizer doesn't work for the
non-x86 architecture, so omit those files from the install,
to make it clear that they aren't expected to work.

Thus, in practice, this builds the ubsan and profile runtimes for
aarch64 and armv7.
2024-09-10 11:17:05 +03:00
Martin Storsjö ae5aa36b95 build-compiler-rt: Only use a temp directory as install prefix if necessary
This makes the build script output more legible, when the cmake
install output actually shows where the files are installed in the
end.
2024-08-30 10:52:32 +03:00
Martin Storsjö 29367bd1b0 build-compiler-rt: Avoid failing for --build-sanitizer if only building for e.g. aarch64
If nothing was built and installed, the installation merging command
fails with an error like this:

    cp: cannot stat '/tmp/tmp.OAj9E7UBhI/install/.': No such file or directory

Therefore, skip this step if nothing really was built and installed.
2024-07-29 17:13:09 +03:00
Norbert Lange 47355937ad support using an existing clang installation
add an option --host-clang which will skip building llvm,
and instead provide symlinks and wrappers for clang and
llvm tools.

Currently the clang version is detected, but it does not
affect the llvm version that will be downloaded and used.
2024-02-26 00:22:14 +02:00
Martin Storsjö c6f48859d8 build-compiler-rt: Include atomics helpers in the builtins library
These helpers are statically linked into each DLL/EXE that uses
them.

They are primarily used for atomic access to variables that are
larger than what the platform natively can support - i.e. primarily
for accessing atomic variables larger than 8 bytes.

The fallback implementations rely on explicit locks (spinlocks
in practice).

As the locks are statically linked into each module that uses the
atomic variable, any concurrent access to such an atomic variable
from two different DLLs/EXEs wouldn't actually end up being
properly atomic.

However cross-module atomic variables (larger than 8 bytes) is
very rare so this isn't deemed to be much of a practical issue.

In GCC based toolchains, the corresponding helpers reside in
a separate shared library, libatomic-1.dll (although it can also
be linked statically).
2024-01-24 09:11:40 +02:00
Norbert Lange d0a03c46c0 Use CMake's build and install functionality
This allows simplification, this functionality was added long
ago to CMake.

Further motivation is to be able to re-direct the installation,
make/ninja install allow this by setting DESTDIR but this
generally doesnt work well with window paths (see [1]).

[1] - https://cmake.org/cmake/help/latest/envvar/DESTDIR.html#envvar:DESTDIR
2023-09-27 22:53:01 +03:00
Norbert Lange 97cd12a63a Ignore set but empty CORES variable
Change the behavior when the CORES environment variable
is set and empty.
Now `-j` will not be added to make/ninja.
2023-09-27 22:53:01 +03:00
Martin Storsjö 2bfe3e7c48 Remove setting the unused variable NINJA in build shell scripts
This variable ended up unused in
b89cdef107.
2023-09-21 12:42:03 +03:00
Martin Storsjö 0b185b62d1 build-compiler-rt: Make the CMAKE_C_COMPILER_TARGET vendor field consistent
Currently, there's no practical difference if the spelling of this
triple is inconsistent, but if we'd enable e.g. the per-target
runtime directories, the exact spelling does make a difference.

For consistency, pass CMAKE_C_COMPILER_TARGET with the exact right
spelling everywhere.
2023-04-29 22:30:41 +03:00
Martin Storsjö 06ff1fdd4f Revert "build-compiler-rt: Stop setting CMAKE_*_COMPILER_WORKS"
This reverts commit 056cb22fb5.

The fix for avoiding needing to set CMAKE_*_COMPILER_WORKS,
which means setting CMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY
when intiailizing the CMake project setup, was only possible to
apply on compiler-rt/lib/builtins, not other similar projects
like libunwind/libcxxabi/libcxx - so it's expected to keep needing
to set the CMAKE_*_COMPILER_WORKS flags.

Therefore it's also possible that the code in compiler-rt/lib/builtins
could be reverted, as it does have some other minor inconveniences
(it causes some other feature detections to fail, even if they're
harmless within the builtins).

Thus keep setting CMAKE_*_COMPILER_WORKS everywhere consistently.
2023-04-29 22:26:35 +03:00
Martin Storsjö af99275e2e Remove unnecessary empty cases in shell scripts 2023-04-26 10:01:21 +03:00
Martin Storsjö 36f8c1359e Switch the default to enabling CFGuard in all individual build-* scripts 2023-01-29 01:09:17 +02:00
Martin Storsjö 486dcf3227 build-compiler-rt: Avoid finding an unrelated LLVMConfig.cmake
Since 23c665371a98c7a16765d12bf2db19b0626b7181 in llvm-project
(Nov 2, 2022), compiler-rt uses CMake's find_package() for
finding potentially installed LLVM files, instead of using
llvm-config.

If the surrounding distribution does have an unrelated install
of LLVM packages, compiler-rt's CMake files would find this, and
add include directories from it into the include paths used
when building compiler-rt.

The ORC runtimes include libc++ headers, and those error out
on these unexpected include topologies (when libc++'s cstddef
includes stddef.h and expects to get libc++'s stddef.h, but ends
up getting a different stddef.h included). (Without this,
it wouldn't have been noticed that the build ends up using a
mismatched sysroot's headers.)

This fixes building in msys2 in the clang64 environment, where
the base toolchain packages end up including LLVM packages,
including LLVMConfig.cmake.

This fixes the same issue as
3b96433cdf did, for the new form of
compiler-rt cmake files.
2022-11-03 11:49:05 +02:00
Martin Storsjö 972b3b2725 Wipe the cmake cache before rerunning cmake
When rebuilding in an already built directory, cmake does use
the cache file, containing what variables were set to previously.
When changing build configuration (building with a different prefix,
or changing build configurations) this can often result in failed
cmake runs.

Wipe the cache (and the rest of the cmake temp files) by default.
This makes sure that the full cmake configuration is run each time
when running the build scripts, just like it does the first time.
(This doesn't remove the build artifacts; if nothing of significance
has changed, ninja would still reuse old built files.)

By setting the env variable NO_RECONF, this behaviour can be skipped,
rerunning cmake without wiping the cache inbetween. (For cases where
the user knows that the configuration hasn't changed since the last
build, this can speed up the cmake execution time a bit.)
2022-10-01 13:29:15 +03:00
Alvin Wong e9401c8bfe Add CFGuard options to build scripts (disabled by default) 2022-10-01 13:25:52 +03:00
Alvin Wong 0af177bf4f build-compiler-rt: Don't rebuild builtins when building sanitizers 2022-10-01 13:25:52 +03:00
Martin Storsjö 3b96433cdf build-compiler-rt: Make sure that compiler-rt doesn't pick up an external llvm-config
We normally don't install all tools (including llvm-config), or we might
have stripped them out, but the system distro might have installed a copy
of llvm-config (for a different unrelated installation of llvm).

Some compiler-rt runtimes (such as xray and orc) use this for finding
the main llvm headers.

When building compiler-rt, we really don't want it to pick up any random
version of llvm headers found on the system, but keep using the matching
headers from the monorepo instead.

Adding the include directory of a system provided set of llvm headers
is especially fatal if that directory isn't a subdirectory containing
only llvm headers, but contains other system headers too.

In particular, on msys2, the include directory (pointed at by "llvm-config
--includedir", and also set by including LLVMConfig.cmake which is
pointed at by "llvm-config --cmakedir") is the main system include
directory. Including this can also get headers for a system install
of libc++ headers (for the clang64 msys2 distro) - and using libc++
headers with a second set of libc++ headers in the include path is
fatal (due to include_next not finding the plain C header but finding
a second libc++ header).

Just try to make sure that we don't pick up any unintended headers.
2022-08-15 00:31:28 +03:00
Martin Storsjö 3d4e36806a Avoid using the nonstandard "which" command
This command isn't a standard tool; different distributions have
different implementations, and e.g. Fedora doesn't ship it by
default.

Settle on using "command -v $tool >/dev/null" for tests about whether
a tool is available. (We could also use "hash $tool 2>/dev/null" as we
already had in build-all.sh, but settling on using "command -v"
everywhere, for consistency and simplicity.)
2022-08-02 15:17:24 +03:00
Martin Storsjö eb365d8eee build-compiler-rt: Simplify referring to the clang resource directory 2022-06-12 23:06:14 +03:00
Martin Storsjö 89af3e6a71 Remove the workaround with the initial, dummy empty libunwind.a
This reverts parts of commit e35ef3b7d7.

This is now handled better upstream, since
7af584ed87cc6eddb6adbc451c90fb8867469e06 in llvm-project
(November 5th 2021).
2022-02-09 14:02:20 +02:00
Martin Storsjö e35ef3b7d7 Use -unwindlib=libunwind instead of merging libunwind into libc++
This makes the build of libcxx a bit cleaner, and simplifies later
building and testing of libcxx.
2021-10-01 12:31:51 +03:00
Martin Storsjö 86630da230 build-compiler-rt: Stop creating an i386-w64-mingw32 sysroot symlink
This shouldn't be needed any longer since
8bd2722f65cfd7883ed9769f7bad3ff50e4c6905 in llvm-project (March 2021).
2021-08-09 12:08:16 +03:00
Martin Storsjö 056cb22fb5 build-compiler-rt: Stop setting CMAKE_*_COMPILER_WORKS
Since 8368e4d54c459fe173d76277f17c632478e91add in llvm-project (pushed
on March 11 2021), the lib/builtins CMakeLists.txt sets
CMAKE_TRY_COMPILE_TARGET_TYPE to STATIC_LIBRARY, which makes the
compiler tests pass before the toolchain is fully functional, by not
doing linking tests.
2021-08-09 12:08:16 +03:00
Martin Storsjö 98583d7bd9 build-compiler-rt: Do a plain "ninja install" instead of manually copying files
This still requires manually moving the dll files to the arch specific
runtime directory.

This requires building a version of llvm past
8e11bede3a6ac11ebcc05c82fac39899feaf9534 (March 18th 2021)
2021-08-09 12:08:16 +03:00
Martin Storsjö 84fc501cf8 build-compiler-rt: Tolerate cases where the output libs already have normalized arch names
This is needed since 8bd2722f65cfd7883ed9769f7bad3ff50e4c6905
(and 8e11bede3a6ac11ebcc05c82fac39899feaf9534) in llvm-project
(past the 12.x release branch), which will allow us to get rid of the
whole arch renaming part (once we can assume we're building a version
newer than that).
2021-03-22 14:06:11 +02:00
Martin Storsjö fcafcacc58 build-compiler-rt: Signal that sanitizers should use libc++ for the cxxabi parts
This fixes building with the latest master version of compiler-rt,
that uses the itanium cxxabi bits for resolving type info.
2020-11-03 11:16:38 +02:00
Martin Storsjö 8e461131cf Clean the build dirs before building, if the env var CLEAN is set 2020-03-25 23:24:31 +02:00
Martin Storsjö 36fc0f6432 build-compiler-rt, build-libcxx: Use ninja for building, if available 2020-03-25 00:29:07 +02:00
Martin Storsjö 92f5caa918 build-compiler-rt: Move CMake generator selection further out in the script 2020-03-25 00:29:07 +02:00
Martin Storsjö c1882530c3 Add copyright and license headers to all shell script files, for clarity 2020-03-05 11:31:31 +02:00
Martin Storsjö bcfb883687 build-compiler-rt.sh: Don't make the i386-w64-mingw32 symlink if not building i686 2019-12-03 23:31:08 +02:00
Martin Storsjö af1099048a Fix building only certain architectures when building on windows
On windows, we rename clang.exe to clang-$MAJOR.exe, and later
install clang.exe as a wrapper for the default architecture. But
if only building certain architectures, and the host architecture
isn't one of them, we shouldn't install any unprefixed clang.exe at
all.
2019-12-03 23:31:01 +02:00
Martin Storsjö 64d39428b6 Quote uses of $PREFIX in the build script, to improve support for installing into a path that contains spaces
For build-mingw-w64.sh to succeed when installing to such a path,
the mingw-w64 version has to be updated to the latest git master.

build-mingw-w64-libraries.sh still fails in this case, as libtool
fails to properly quote $LD in a test for whether the linker is GNU ld.
2019-12-03 21:49:53 +02:00
Martin Storsjö ee555b9013 Fix building when $PATH contains spaces 2019-11-30 10:37:19 +02:00
Martin Storsjö 0f9d9f1986 Check out llvm sources using the new llvm git monorepo
This updates compiler-rt, libunwind, libcxxabi and libcxx to a newer
version, matching the compiler.

This will be the official, canonical repo in the future.

For the non-dev Dockerfile build, this means that all the llvm based
subprojects need to be built in one RUN to avoid storing the llvm
checkout in the docker layers.
2019-09-12 13:14:19 +03:00
Martin Storsjö 0933a30500 Avoid printing an error when rerunning build-compiler-rt.sh on msys2 2019-06-28 00:14:32 +03:00
Martin Storsjö 13d73ee670 Update compiler-rt to a new version
This version fixes undefined symbols in the profiling library.
2019-03-29 23:07:57 +02:00
Martin Storsjö f39d45162e Update compiler-rt to the 8.0 release version
This doesn't fix any particular known issue, but the release branch
should generally be a safe version.
2019-03-19 09:34:19 +02:00
Martin Storsjö a8064cfdb5 Install the sanitizer headers 2019-02-22 22:34:54 +02:00
Martin Storsjö e45e9ab98e Update compiler-rt to a newer version
This fixes building sanitizers natively on windows/msys.
2018-11-30 12:03:09 +02:00
Martin Storsjö fdd0a116ae Try to set "MSYS Makefiles" as cmake generator in mingw environments 2018-11-30 12:03:09 +02:00
Martin Storsjö 53db1c3a4c Resolve $PREFIX to an absolute path at the start of shell scripts
This fixes building/installing into a relative path.
2018-11-23 13:51:05 +02:00