Commit Graph
747 Commits
Author SHA1 Message Date
Martin Storsjö 5ae5b1aa37 build-llvm: Build clang-tools-extra
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.
2022-03-23 13:07:39 +02:00
Martin Storsjö 0dbd9baba3 build-llvm: Allow disabling building lldb
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.
2022-03-23 13:07:39 +02:00
Martin Storsjö b3f63b4ac8 build-llvm: Default to using LLVM_ENABLE_PROJECTS even on unix
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.
2022-03-23 13:07:39 +02:00
Martin Storsjö 0cffa112e0 build-llvm: Avoid unnecessary repeated git fetches if SYNC=1 is set
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.
2022-03-23 13:07:39 +02:00
Martin Storsjö 58cfd46b25 build-llvm: Remove a special case, allow using lld for stage2 builds on macOS
In the currently targeted version of LLVM, lld is usable enough
for targeting macOS.
2022-03-23 13:07:38 +02:00
Martin Storsjö 67b61cfb22 release-macos: Remove a leftover listing of a nonexistent argument 2022-03-23 11:30:18 +02:00
Martin Storsjö 3fa0e8906b license: Fix a typo 2022-03-14 22:54:12 +02:00
Martin Storsjö e9e53d581d test: Remove a workaround for an old clang version 2022-03-14 11:36:32 +02:00
Martin Storsjö 7ff4a34668 Revert "build-libcxx: Build with -ffunction-sections -fdata-sections"
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.
2022-03-10 13:48:08 +02:00
Martin Storsjö faa0a22955 Revert "wrappers: Force the default dwarf version back to 4"
This reverts commit e384109cbf.

This workaround no longer is necessary after LLVM 14.0.0 RC2.
2022-03-03 22:58:32 +02:00
Martin Storsjö c837cd6806 build-llvm: Bump to llvmorg-14.0.0-rc2
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
2022-03-02 13:14:16 +02:00
Martin Storsjö 26dd3e46fe Add a script for building releases for macOS 2022-02-09 15:49:43 +02:00
Martin Storsjö e384109cbf wrappers: Force the default dwarf version back to 4
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).
2022-02-09 15:39:43 +02:00
Martin Storsjö 977df0d83e wrappers: Fix an incorrect check for the max number of arguments in clang-target-wrapper.c 2022-02-09 15:39:43 +02:00
Martin Storsjö bd9e16f732 build-libcxx: Build with -ffunction-sections -fdata-sections
This allows shrinking binaries somewhat, if linking the runtimes
statically and using the -Wl,--gc-sections option.
2022-02-09 14:02:20 +02: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ö 14db168cd6 wrappers: Use --{start,end}-no-unused-arguments instead of -Qunused-arguments
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.
2022-02-09 14:02:20 +02:00
Martin Storsjö 7b1d05f545 build-libcxx: Build libunwind+libcxxabi+libcxx with one single cmake build
This simplifies their interdependencies quite a bit.
2022-02-09 14:02:20 +02: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ö 81c39dda6a Build libunwind before mingw-w64-libraries
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.
2022-02-09 14:02:20 +02:00
Martin Storsjö 56d0ef7900 wrappers: Remove hacks for filtering the stdout from clang
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.
2022-02-09 14:02:20 +02:00
Martin Storsjö 73f7c4ceca build-libcxx: Stop hardcoding LIBCXX_HAS_WIN32_THREAD_API
Since a8d15a926689c126c4d316788786e0160cfc1d5d in llvm-project
(October 5th), libcxx stopped autodetecting pthreads on mingw,
making pthreads opt-in instead of opt-out.
2022-02-09 14:02:20 +02:00
Martin Storsjö 77d293e95f test: Add tests for conversions between int128 and floats
These require a newer version of LLVM, past
d6216e2cd1a5e07f8509215ee5422ff5ee358da8 in llvm-project (September
29th).
2022-02-09 14:02:20 +02:00
Martin Storsjö ee1b52812a build-mingw-w64: Update to the current version from February 9th
Among lots of other changes, this now includes import libraries for
OpenGL for arm targets, and also hooks up timespec_get for UCRT.
2022-02-09 14:02:20 +02:00
Martin Storsjö 45cc868505 build-lldb-mi: Update to the latest version as of February 9th 2022-02-09 14:02:20 +02:00
Martin Storsjö 578afb1a6d build-python: Bump to the latest version on the mingw-v3.9.7 branch
This makes the armv7 build of python work correctly.
2022-02-09 14:02:20 +02:00
Martin Storsjö 9f5b66197f build-llvm: Bump to llvmorg-14.0.0-rc1
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.
2022-02-09 14:01:53 +02:00
Martin Storsjö f3b6f0fa45 test: Don't use std::chrono_literals, fix building hello-exception in C++11 mode
std::chrono_literals require C++14.

This simplifies building hello-exception on macOS, where current
Apple Clang still default to C++11.
2021-12-03 11:42:11 +02:00
Martin Storsjö e3866b9df2 test: Fix a symbol collision when building hello-exception on macOS
On macOS, the included headers end up including sys/wait.h, which
declares a different symbol "wait".
2021-12-03 11:39:31 +02:00
Martin Storsjö 6f30aabe97 build-llvm: Set more variables for cross compiling LLDB with Python
These are needed with the latest version from git main since
November 2021.
2021-11-19 13:12:03 +02:00
Martin Storsjö 9eac155de2 build-llvm: Stop setting Python3_EXECUTABLE
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.
2021-11-19 00:59:18 +02:00
Martin Storsjö 7e7344281d build-python: Discard local changes before checking out a new revision
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.
2021-11-16 12:37:59 +02:00
Long Nguyen fefa34fd04 build-python: Update to v3.9.7, remove patches
Also add gitignores/dockerignores for directories created during
the python build.
2021-11-15 21:47:55 +02:00
Martin Storsjö 4b34c42cbc build-libcxx: Set CMAKE_CXX_COMPILER_TARGET when building
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.
2021-11-05 14:38:38 +02:00
Martin Storsjö fe57d608de test: Add tests for conversion between 64 bit integers and long double 2021-10-14 12:34:00 +03:00
Martin Storsjö 13d48841a0 build-libcxx: Stop specifying a number of build settings that are set to their defaults 2021-10-14 12:33:22 +03:00
Martin Storsjö 378525eb9b build-mingw-w64: Update to the current version from October 1st 2021-10-01 22:27:39 +03:00
Martin Storsjö 214b775065 build-lldb-mi: Update to the latest upstream version
This fixes a bunch of build warnings in some setups.
2021-10-01 22:22:53 +03:00
Martin Storsjö 0adff0df7d build-libcxx: Stop manually specifying -lunwind
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.
2021-10-01 12:32:47 +03: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ö e40ff6ab49 build-llvm: Bump to llvmorg-13.0.0
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
2021-10-01 12:25:25 +03: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ö 671c408b9b readme: Mention that asan doesn't work properly with msvcrt
This was concluded in https://github.com/mstorsjo/llvm-mingw/issues/224.
2021-08-27 11:03:12 +03:00
Martin Storsjö 69d3d40f00 build-python: Fix rebuilding with an already checked out directory
After applying patches (with plain 'patch' instead of 'git am'), we
need to reset the tree to be able to check out the targeted version
again.
2021-08-17 11:13:45 +03:00
Martin Storsjö b0864ea9ae strip-llvm: Remove import libraries for liblldb/libLLVM/libclang-cpp
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).
2021-08-16 14:00:04 +03:00
Martin Storsjö d8ab02f1dd release: Include python in the cross built toolchains 2021-08-16 12:29:52 +03:00
Martin Storsjö 6769ecda7b Dockerfile.cross: Add an option for building python 2021-08-16 12:29:52 +03:00
Long Nguyen 52f07a108d README: Add autoconf and libtool as required MSYS2 packages 2021-08-16 11:26:37 +03:00
Long Nguyen 8da020bc38 build-cross-tools: Add --with-python flag 2021-08-16 11:26:37 +03:00
Long Nguyen 977a8b41db build-llvm: Add --with-python flag 2021-08-16 11:26:37 +03:00