This fixes the v*scanf functions when using msvcrt.dll, if using more
than 30 format conversions, fixes error handling in the btowc
function in libmingwex, and adds a missing (void) in a function
prototype in winpthreads, adds the fwpuclnt import library for aarch64,
plus other assorted header/interface updates.
This installs a bunch of new tools in the bin dir, namely the following:
clang-apply-replacements
clang-change-namespace
clang-doc
clang-include-fixer
clang-move
clang-query
clang-reorder-fields
clang-tidy
clangd
find-all-symbols
modularize
pp-trace
run-clang-tidy
These are stripped out by strip-llvm, but clangd and clang-tidy
are kept.
While lldb can be used as a cross debugger, it's probably mostly
used when run on the same target as the code is executed on.
Since it's a mostly optional component in the toolchain, allow
passing --disable-lldb to build-llvm.sh to skip it.
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).
Building this tool requires having a full LLVM build available;
either by installing without LLVM_INSTALL_TOOLCHAIN_ONLY (and not
stripping the llvm installation yet) or by pointing it at the
LLVM build directory instead. The latter works better for our
normal build flows.
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.
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)
Notable changes since 12.0.0 for llvm-mingw are:
llvm:
- Produce proper cross-section relative relocations on ARM and AArch64
- Fixed the calling convention for AArch64 for variadic functions involving
floats in the fixed arguments
- Added a windres compatible frontend in llvm-rc, avoiding the need for
external wrappers
- Build LLVM with -ffunction-sections and --gc-sections, shrinking
a full build of llvm-mingw without LLVM_BUILD_LLVM_DYLIB by 22%
(but llvm-mingw uses LLVM_BUILD_LLVM_DYLIB these days, which shrinks
the build even more)
- Avoid optimizing/changing function calls into stpcpy due to optimizations
- llvm-ml has improved to the point where it can build the OpenMP assembly
file without needing to use another assembler tool
lld:
- Support linking directly against DLLs without using import libraries
- Improved reliability when running on Windows, avoiding some hangs
when terminating
- Fixed linking with --export-all-symbols in combination with
-ffunction-sections
- Fixed --export-all-symbols when linking EXEs
- Fixed autoexport from LTO objects with comdat symbols
- Print warnings with a "ld.lld" prefix instead of "lld-link"
- Avoid thread exhaustion on 32 bit Windows
- Accepting more forms of options, like -static and --stack=
clang:
- Fixed reading long doubles with va_arg on x86_64
- Fixed calling std::once in a dynamically linked libstdc++
runtimes:
- Complete support for std::filesystem in libc++ (which was previously
backported to 12.0.0 in llvm-mingw too, but the previous release had
a bug in using e.g. the u8path() method when linking against the DLL
version of libc++)
- Implemented semaphores in libc++
- Provide the __gcc_personality_seh0 symbol, fixing building C code with
-fexceptions and __attribute__((cleanup))
- Simplified building/installing compiler-rt and libunwind
- Silenced lots of build warnings in OpenMP
These don't seem to be necessary in practice at the moment.
If building on top of a stripped llvm install, while there's an
older version of llvm (providing llvm-config) installed system
wide, we currently still manage to build things correctly.
(If llvm-config from LLVM 6.0 is available, build-compiler-rt.sh
fails though, but that's unaffected by this change. In current
git versions of compiler-rt, it first and foremost looks inside
the monorepo checkout instead of looking for a potentially
unrelated llvm-config binary.)
Instead set the cmake defines that indicate that libcxx is going
to be linked dynamically and going to link in libcxxabi statically,
so that libcxxabi is built statically but with dllexport attributes.
Since libcxx includes libcxxabi with
_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS defined, the libcxxabi
declarations contain neither dllimport nor dllexport.
Earlier, we didn't use to include the libcxxabi headers with
_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS defined, but defining
_LIBCXXABI_BUILDING_LIBRARY instead. This caused libcxxabi
declarations to be marked dllexport. If any such functions would
end up emitted as part of the libcxx object files, this would
have been necessary to get them properly exported.
In practice libcxxabi functions aren't generated while included
in libcxx (they aren't templates and/or header inline functions),
_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS gets defined by the cmake
files, so we don't need to set this at all any longer.
Since before the LLVM 12.x branch, these aren't necessary any
longer.
(9c30bafd59bf1078bbe1c235c7c25bf7e278e2e9 and
8a73aa8c4c3ee82e7d650c6a957937713a4a9ab4 in llvm-project)
Since 9c30bafd59bf1078bbe1c235c7c25bf7e278e2e9 in llvm-project,
libcxxabi unconditionally defines _LIBCPP_BUILDING_LIBRARY while
building.
Since 8a73aa8c4c3ee82e7d650c6a957937713a4a9ab4 in llvm-project,
libcxx defines _LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS if
LIBCXX_ENABLE_STATIC_ABI_LIBRARY is set.
This fixes linking against a DLL of libc++ while using the common headers
(generated from the static version of the library, but which work for
both shared and static versions) when calling e.g. std::filesystem::u8path.
This allows easier testing of continuing from manually set
breakpoints.
Also fix compilation for non-windows platforms where __debugbreak()
isn't defined.
This matches how it is set by default in current master versions.
This requires building a version that includes
https://reviews.llvm.org/D89863, otherwise the new/delete operators
aren't properly weak.
For x86_64 and aarch64, this requires https://reviews.llvm.org/D89231.
The C++ destructors aren't executed while doing the longjmp (contrary
to how it works MSVC's C++ exceptions), but it no longer crashes.
Notable changes in this release:
- Implicitly add the .exe suffix, even when cross compiling (matching
a behaviour change in GCC since GCC 8)
- Enable the dynamicbase flag by default in LLD
- Implemented the -wrap option in LLD
- Optimized the generated unwind data for aarch64, reducing the size
of the unwind data by around 60%
- Error out of LLD if trying to create a DLL with too many exports