Allow setting up the projects with symlinks by passing --symlink-projects
to the build script.
The setup with symlinks is mostly useful in development setups, where
one wants to share ccache across multiple checkouts.
If the SYNC variable is set when running build-all.sh, all the
individual scripts will try to check out the intended version
before building. All scripts that build projects from llvm-project
(build-libcxx.sh, build-compiler-rt.sh, build-openmp.sh) call
build-llvm.sh with CHECKOUT_ONLY=1 to make sure the right version
is checked out (as one can call the scripts individually too).
If the llvm-project directory was a full (non-shallow) checkout,
the repeated fetch was quick as git knew that it had the fetched
reference already. But in a shallow clone, a new shallow fetch
would refetch the whole object tree for the targeted reference.
Using "git cat-file -e" we can check whether a specific object
exists in the local checkout, avoiding needlessly refetching
everything.
However, when fetching a tag using shallow fetch (git fetch
--depth 1 origin "$LLVM_VERSION"), it would only fetch the
commit object for that tag, not the tag itself. By specifying
'tag "$LLVM_VERSION"' in this case, we get the tag object itself,
so that we later can check whether "$LLVM_VERSION" exists in the
local checkout. But this requires guessing whether a specific
"$LLVM_VERSION" is a tag or a commit.
This reverts commit bd9e16f732.
It turns out this actually isn't needed; since switching to
building via the llvm-project/runtimes directory (in
7b1d05f545), the cmake build
pulls in HandleLLVMOptions.cmake, which checks for and adds
-ffunction-sections and -fdata-sections if supported. Therefore,
we don't need to specify it manually at all.
Notable changes include:
- Default to DWARF 4 instead of 5 for the mingw target
- Fix the section name encoding in llvm-objcopy/llvm-strip, if the output
binary has more than 10^6 bytes of string table
Clang's general default dwarf version was raised from 4 to 5 in
d3b26dea16108c427b19b5480c9edc76edf8f5b4 in llvm-project (Jan 23
2022) before the 14.0.0 branch, but dwarf 5 on Windows seems to not
work with either LLDB or GDB.
Thus force the default back to 4 here as a temporary workaround, and try
to set the default back to 4 for mingw targets in Clang for later
releases (https://reviews.llvm.org/D119326).
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.)
This makes warnings for other unused arguments visible to the user.
This requires a version of llvm-project past
50ec1306d060e46e0d53c9f5d8a052e1b0d10d3b (Jan 2022) which added these
new options.
This reverts parts of commit e35ef3b7d7.
This is now handled better upstream, since
7af584ed87cc6eddb6adbc451c90fb8867469e06 in llvm-project
(November 5th 2021).
When --unwindlib=libunwind is implicit, we need to build libunwind
to have a complete working C compiler too. Currently this is worked
around by initially creating a dummy, empty libunwind.a, but with
the current version of libcxx/libunwind, we can get rid of that
workaround if we build it as soon as possible.
Since df0ba47c36f6bd0865e3286853b76d37e037c2d7 in llvm-project
(November 5th 2021), clang built with mingw defaults to producing
paths with forward slashes - thus, this hack no longer is needed.
Since a8d15a926689c126c4d316788786e0160cfc1d5d in llvm-project
(October 5th), libcxx stopped autodetecting pthreads on mingw,
making pthreads opt-in instead of opt-out.
Notable changes include:
- LLVM can be configured to prefer forward slashes on Windows, avoiding
the need to manually filter the Clang output in a wrapper for some
commands.
- New Clang options for silencing warnings about unused arguments,
avoiding the need to turn off the warning altogether. This makes
llvm-mingw produce warnings about unused arguments among the user
provided arguments, which never were seen before.
- Improvements to building libunwind/libcxxabi/libcxx, allowing
simplifying the build a lot.
- Fixed generated calls to support routines for converting 128 bit integers
from/to floats on x86_64.
- Fixed the -m32 flag, to let it figure out the right i386/arm
architecture variant (where it previously looked for a sysroot named
e.g. i386-*, which wasn't found).
- Fixed code generation for AArch64 in large object files (over 1 MB of
code), where relocations against temporary symbols (jump tables,
constant pools etc) were broken.
- Fixed continuing from breakpoints and singlestepping in LLDB on
ARM/AArch64
- Fixed unwind info for overridden weak symbols (e.g. if overriding
operator new with a statically linked libc++, and unwinding an exception
through the operator).
- Set proper COFF symbol types for function aliases (e.g. for some C++
constructors), making GNU ld export all of the correctly as the right
type, when linking a DLL.
- Improved code generation for ARM, by assuming less strict alignment
requirements for some instructions.
This is the build host python, run during the build/install,
not to be run on the target device. LLVM's build system itself
detects the python to use for that and overwrites the
Python3_EXECUTABLE variable anyway, so it's value isn't currently
used.
Even if we don't patch cpython-mingw any longer, we still run
autoreconf on it (and libffi), which can cause changes to
committed files. If trying to check out a different version of
the source, this would fail unless the local changes have been
discarded.
LLVM's default host detection doesn't always work (cmake doesn't
detect and provide the target architecture, but it provides the
bitness, thus LLVM's GetHostTriple.cmake guesses on the same
architecture as running the build), thus pass it manually.
This didn't use to matter, as the tests for whether --target=<target>
works used to fail, as the toolchain isn't complete at that point.
But since 7af584ed87cc6eddb6adbc451c90fb8867469e06 in llvm-project
(November 5th 2021), the libunwind cmake tests for --target do
succeed (without noticing that linking actually will fail), and thus
can end up using the incorrectly guessed compiler target.
Thus, this fixes building the runtimes with current git main
versions of llvm-project.
Specifying -lunwind isn't needed if building a version of libcxx
after 5f9be2c3e37c0428ba56876dd84af04b8d9d8915 (Feb 2021); then
libcxx is built with -nostdlib++ which keeps automatically linking
in -lunwind if -unwindlib=libunwind is used.
In addition to the changes in 13.0.0 RC1 (listed in
9188cce153), the following changes
relevant to llvm-mingw were made:
- Allow specifying language to llvm-rc with an 0x prefix
- Let the last specified option of -mconsole/-mwindows take effect
- Support both "--opt value" and "--opt=value" for more options in lld
- Add support for the --disable-dynamicbase option spelling in lld,
in addition to the old existing --no-dynamicbase
- Fix linking with when enabling profiling
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.
The import libraries for libLLVM/libclang-cpp are rather large
(21 and 15 MB each), while it hasn't been too much of an issue
with liblldb.dll.a (which was 600 KB).