65 Commits

Author SHA1 Message Date
Mateusz Mikuła 9e39b82907 install-wrappers: Add config file symlinks for triples with vendor "pc" 2025-11-18 14:39:16 +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
Steve Lhomme 990ad67759 build-llvm: Install and keep llvm-lib
It's an equivalent to MSVC lib.exe [^1].

It is used by meson to find the DLL name from a .lib/.dll.a [^2].
The other option is dlltool, which is not the same as llvm-dlltool.

[^1] https://llvm.org/docs/CommandGuide/llvm-lib.html
[^2] https://github.com/mesonbuild/meson/blob/1e986554ef2071f59fb796cda5e66c448bde6ac9/mesonbuild/scripts/symbolextractor.py#L209
2025-02-13 12:03:26 +02:00
Martin Storsjö 1f99e3e26e install-wrappers: Pass --config-system-dir in the --host-clang mode
This is required since e2e9216853
for this configuration to be able to find the config files.

Also add the *.cfg files to the Dockerfile COPY line.
2025-01-07 23:08:29 +02:00
Martin Storsjö f84079bb71 macos: Bump the minimum deployment target to macOS 10.12
Since https://github.com/llvm/llvm-project/pull/117252 and
https://github.com/llvm/llvm-project/commit/186fac33d08b34be494caa58fe63972f69c6d6ab,
part of the latest git main branch, LLDB uses std::shared_mutex.

On macOS, std::shared_mutex is only available since macOS 10.12.

This change raises the deployment target from 10.9 to 10.12.
2024-12-13 09:51:58 +02:00
Martin Storsjö 63691c69bc wrappers: Skip the clang-scan-deps wrapper script on Unix
The wrapper script no longer has any purpose on Unix.

Just do a plain symlink to the clang-scan-deps tool.

On Windows, the wrapper executable still is used to inject a
default -target option, if the executable name doesn't contain
a triple.
2024-11-06 11:40:31 +02:00
Martin Storsjö 6bd54a4fc2 wrappers: Move common arguments into a shared config file 2024-11-06 11:40:31 +02:00
Martin Storsjö 866d47cced wrappers: Pick up the Clang config file implicitly
Clang only picks up config files implicitly using the normalized
triple form, so use file names with "-windows-gnu" instead of
"-mingw32".

In theory, we could also want to pick up the config file implicitly
by having "<triple>-<mode>" be a symlink directly to the clang
executable. That works for regular mingw32 targets, but for the
mingw32uwp target, there's no distinction in the normalized
triple, so both would end up using the same "-windows-gnu" config
files. So as long as we want to support the mingw32uwp prefixed
tools, we need to use a wrapper.
2024-11-06 11:40:30 +02:00
Martin Storsjö e2e9216853 wrappers: Use clang config files for defaults
This makes these defaults more easy to get picked up in various
use cases, when not directly executing a compiler.
2024-11-06 11:40:30 +02:00
Martin Storsjö e0964ce24c Revert use of Clang config files
This reverts commit 49db4a3a15,
9f1f0104f1,
4f95c14adf,
c34dc64028,
570fdcd251,
4bff0298c5 and
6939aee0c0.

When relying on Clang config files, two issues appeared:

- Running the compiler-rt tests fails, because the compiler-rt tests
  disable any default config files, breaking the compiler
  in this case:
  https://github.com/llvm/llvm-project/blob/llvmorg-19.1.1/compiler-rt/test/lit.common.cfg.py#L983

- Wine fails to build using llvm-mingw as cross compiler, because
  Wine adds the --no-default-config flag to Clang while compiling,
  if supported:
  https://gitlab.winehq.org/wine/wine/-/blob/wine-9.19/configure.ac?ref_type=tags#L866-868
  This causes llvm-mingw to omit the -rtlib=compiler-rt option
  (specified in a config file), making the compiler look for libgcc
  instead. Doing a check to see that linking succeeds doesn't necessarily
  help here - such a check already exists, but it tests linking with
  -nostdlib -nodefaultlibs:
  https://gitlab.winehq.org/wine/wine/-/blob/wine-9.19/aclocal.m4?ref_type=tags#L193-L206
2024-10-14 16:35:17 +03:00
Martin Storsjö 9f1f0104f1 wrappers: Skip the clang-scan-deps wrapper script on Unix
The wrapper script no longer has any purpose on Unix.

Just do a plain symlink to the clang-scan-deps tool.

On Windows, the wrapper executable still is used to inject a
default -target option, if the executable name doesn't contain
a triple.
2024-10-02 16:06:01 +03:00
Martin Storsjö 570fdcd251 wrappers: Move common arguments into a shared config file 2024-10-02 15:58:01 +03:00
Martin Storsjö 4bff0298c5 wrappers: Pick up the Clang config file implicitly
Clang only picks up config files implicitly using the normalized
triple form, so use file names with "-windows-gnu" instead of
"-mingw32".

In theory, we could also want to pick up the config file implicitly
by having "<triple>-<mode>" be a symlink directly to the clang
executable. That works for regular mingw32 targets, but for the
mingw32uwp target, there's no distinction in the normalized
triple, so both would end up using the same "-windows-gnu" config
files. So as long as we want to support the mingw32uwp prefixed
tools, we need to use a wrapper.
2024-10-02 15:58:00 +03:00
Martin Storsjö 6939aee0c0 wrappers: Use clang config files for defaults
This makes these defaults more easy to get picked up in various
use cases, when not directly executing a compiler.
2024-10-02 15:58:00 +03:00
Martin Storsjö 3cf884f8b7 install-wrappers: Prefer the CRT's implementation of printf functions
This avoids bloating the wrapper executables, when built for
msvcrt (where the default is to enable __USE_MINGW_ANSI_STDIO
when targeting C99 or newer).
2024-06-03 12:36:28 +03:00
Martin Storsjö 74e45715e3 wrappers: Provide the unprefixed clang-scan-deps as a wrapper, on Windows
When setting up wrappers for Windows, rename clang-scan-deps.exe to
clang-scan-deps-real.exe, make clang-scan-deps.exe a wrapper, and
configure the wrapper to target executing clang-scan-deps-real.exe.

This makes sure that we always pass in crucial options like
-stdlib=libc++.

By default, our Clang executables are built with that option
hardcoded, configured with CLANG_DEFAULT_CXX_STDLIB=libc++
when built for Windows. However, we generally don't rely on this;
we assume the tools could be plain default executables, so we
try to provide wrappers on all common access paths.
2024-05-02 20:03:56 +03:00
Martin Storsjö 06bd759e50 wrappers: Add a wrapper for clang-scan-deps
This picks the architecture by looking for a triple prefix in the
nested command, and passes it as an explicit flag, to let
clang-scan-deps find it.

We also pass -stdlib=libc++, to let it find the libc++ headers
as expected.
2024-05-02 20:03:56 +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ö 06f44cda62 Support cross compilation to non-windows targets
Don't have --host/$HOST imply targeting Windows, but actually inspect
the target triple where necessary.
2023-04-26 19:18:24 +03:00
Martin Storsjö 9d96e5745f Include the llvm-size tool like other binutils-like tools
This was requested in
https://github.com/mstorsjo/llvm-mingw/issues/320.
2023-01-12 14:11:03 +02:00
Martin Storsjö 349877296b Allow overriding what archs to build for, or what version to target, for MACOS_REDIST builds 2022-10-21 18:00:20 +03:00
Martin Storsjö d57de8ba8b install-wrappers: Install wrappers named <target>-llvm-ar and <target>-llvm-ranlib
This is necessary for CMake to detect working IPO (LTO); if the
compiler is named <target>-{gcc,clang}, CMake expects to find
matching tools named <target>-llvm-{ar,ranlib} too. (The CMake
module CheckIPOSupported and function check_ipo_supported expects
to have CMAKE_LANG_COMPILER_AR and ..._RANLIB set to working tools;
the Clang-FindBinUtils.cmake module looks for tools named
llvm-ar/llvm-ranlib with the same prefix as the compiler.)
2022-10-01 13:28:41 +03:00
Martin Storsjö 4b8ef36d94 install-wrappers: Don't install cross-prefixed cc/c99/c11 tools
A regular GCC install doesn't provide tools like <triple>-{cc,c99,c11},
so there's probably not much need to include them.

Some distributions of tools may provide tools with the names "cc",
"c99" and "c11" though, as custom frontends or symlinks to the
regular compiler. Therefore, keep the unprefixed tools with these
names.
2022-06-08 23:12:40 +03:00
Martin Storsjö ee6caf31cf Allow building a redistributable package for macOS
This includes building universal binaries (for arm64 and x86_64)
and targeting an older minimum deployment target.

(Before 1919720fdd348ca568b235bf3f1357c198eccd15 in llvm-project,
Jan 2022, building lldb's debugserver failed, if building for macOS
for multiple architectures, or for an architecture other than the
current host.)
2022-02-09 14:02:20 +02:00
Martin Storsjö 42d2eb7346 wrappers: Remove the dlltool wrapper
Since LLVM 13, llvm-dlltool can imply the target architecture from
a triple prefix on the tool name, so there's no more need for a
wrapper.

The *-dlltool tools are now symlinks to the main llvm-dlltool
executable. In the Windows distribution, the *-dlltool.exe used to be
copies of dlltool-wrapper.exe (which is small; 15 KB). Now they
will instead be copies of llvm-dlltool.exe. Luckily, thanks to
building with -DLLVM_LINK_LLVM_DYLIB=ON by default, llvm-dlltool.exe
is only a mere 65 KB, while it used to be much larger, e.g. around
11 MB in older releases.
2021-09-17 11:09:35 +03:00
Martin Storsjö 177cd0d33d Include the llvm-readelf tool 2021-08-16 11:26:37 +03:00
Martin Storsjö 8915db817c wrappers: Remove windres-wrapper; llvm-windres is available since LLVM 13.0.0 2021-08-09 12:08:16 +03:00
Martin Storsjö 459e37f03f wrappers: Convert dlltool-wrapper to a native executable
This allows running it on windows from processes other than msys
based ones.
2021-06-14 11:44:06 +03:00
Martin Storsjö fc1b1ba110 install-wrappers: Use llvm-windres if available
If the llvm-windres tool is available, use that instead of our own
wrapper that calls clang, llvm-rc and llvm-cvtres separately.
2021-04-26 22:22:31 +03:00
Martin Storsjö cc0055bc96 Fix the help printouts in scripts
Printing '<triple>' causes the shell to try to read a file named
triple. One could either quote it, or just remove the angle brackets;
removing the brackets for simplicity.
2021-02-09 13:54:16 +02:00
Martin Storsjö e9708b38a6 install-wrappers: Install <triple>-as as a symlink to clang 2020-08-24 15:34:26 +03: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ö 57c4f47db3 Add the --host flag to the help output in the individual build scripts 2019-12-21 00:04:47 +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ö f1168d3016 Don't rely on EXEEXT as an env variable, infer it from --host instead 2019-11-13 12:59:53 +02:00
Martin Storsjö 577400a5f7 Pass $HOST to individual script with a --host parameter
This avoids ambiguity on distributions (such as openSUSE) where the
HOST environment variable already is set, to the hostname.
2019-11-13 12:55:39 +02:00
Martin Storsjö 4670446157 Install llvm-addr2line 2019-07-01 22:30:24 +03:00
Martin Storsjö f80d067176 Only make the prefixless widl symlink after compiling widl
When building in msys2, symlinks are plain copies, and one can't
make the symlink in advance.
2019-06-21 22:52:34 +03:00
Martin Storsjö c3aeb78576 wrappers: Add a wrapper for running llvm binutils replacements
This saves a lot of diskspace, when symlinks are turned into full
copies of the tools on windows, as the symlinks only point to a small
wrapper instead of to the full tool.
2019-05-06 11:05:25 +03:00
Steve Lhomme ca44a11660 Add wrappers that target Universal Windows 2019-04-18 11:28:05 +03:00
Martin Storsjö 68aa79a99b Create the prefixless objcopy/strip tools from an executable
This is necessary since 62b208aee2.
2019-01-24 13:46:08 +02:00
Martin Storsjö 62b208aee2 Use llvm-objcopy/llvm-strip instead of a shell script wrapper and binutils 2019-01-24 10:58:20 +02:00
Martin Storsjö 4d861b67b5 Don't move clang.exe to clang-<major>.exe if clang-<major>.exe already exists 2018-11-30 12:03:09 +02:00
Martin Storsjö 11a83711ad Check that clang.exe exists before moving it to clang-<major>.exe 2018-11-30 12:03:09 +02:00
Martin Storsjö 32668f336b Keep clang.exe around if we won't be replacing it with an unprefixed wrapper 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
Martin Storsjö 73bd1bc62c Provide wrappers named cc/c99/c11/c++ as well 2018-10-10 23:33:19 +03:00
Martin Storsjö b611bc1904 Convert the windres wrapper from shell script to C
This allow running windres on windows without a surrounding posix shell.
2018-10-10 23:33:19 +03:00
Martin Storsjö 9069c627a9 Install unprefixed tools when cross compiling the toolchain 2018-10-10 23:33:19 +03:00