Commit Graph
91 Commits
Author SHA1 Message Date
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ö 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ö 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ö 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ö 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ö 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
Long Nguyen 977a8b41db build-llvm: Add --with-python flag 2021-08-16 11:26:37 +03:00
Martin Storsjö 177cd0d33d Include the llvm-readelf tool 2021-08-16 11:26:37 +03:00
Martin Storsjö 63a5d3c09f build-llvm: Include the llvm-ml tool 2021-08-09 12:08:16 +03:00
Martin Storsjö 9188cce153 build-llvm.sh: Bump to llvmorg-13.0.0-rc1
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
2021-08-09 12:08:13 +03:00
Adrian Antkowiak 9b6966484f Use git depth=1 when cloning llvm 2021-07-05 23:32:07 +03:00
Martin Storsjö 46efff459a build-llvm: Build with a shared libLLVM and libclang-cpp
This reduces the size of e.g. the zipped toolchain for Windows
from 183 MB to 85 MB.
2021-07-01 23:33:28 +03:00
Martin Storsjö 37936ec0ea build-llvm: Install llvm-windres if available
The current llvm main branch contains the tool llvm-windres; make
sure to install and include it, if it exists.
2021-04-26 22:21:42 +03:00
Martin Storsjö 2094638569 patches: Patch the llvm 12.x release to include support for std::filesystem in libcxx 2021-04-23 10:58:42 +03:00
Martin Storsjö 2a323ac869 build-llvm: Bump to the LLVM 12.0.0
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
2021-04-15 11:29:57 +03:00
Martin Storsjö 4012843f3e built-llvm: Add options for doing a stage2 build, and for building with LTO 2021-03-22 14:07:49 +02: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ö 4b063063f2 build-llvm: Don't explicitly disable LLDB's dependencies
They are supposed to be autodetected these days, and the build
shouldn't fail if they aren't available.
2021-01-25 10:44:39 +02:00
Martin Storsjö d5d30fae23 build-llvm: If cross compiling, look for llvm-tblgen with an exe suffix
If cross compiling on MSYS, the native llvm-tblgen needs this suffix.
2020-10-15 23:20:32 +03:00
Martin Storsjö 06cf71558e build-llvm: Update to the 11.0.0 release of llvm
Notable changes since LLVM 10.0.0:

- Enable -mms-bitfields by default (like GCC), don't produce errors
  if the -mms-bitfields option is used together with non-trivial C++
  classes
- Support for more linker flags in LLD (--disable-auto-import,
  --disable-runtime-pseudo-reloc, --file-alignment, --section-alignment),
  and fixed the handling of the --no-seh flag
- Clearly error out on unsupported relocation types in aarch64 assembly
- Proper support for __attribute__((weak))
- Minor improvements to details in llvm-rc
- Fixed a regression in LLD about exporting symbols containing periods ('.')
  with a def file
2020-10-12 14:21:41 +03:00
Martin Storsjö d8aefd7b1a build-llvm: Fix a typo in the flags for disabling external libs
These aren't strictly necessary any longer, as the external libs
are used automatically if found (instead of erroring out if not
found, unless explicitly disabled as before).

Still keeping the explicit disables, to avoid potential issues if
e.g. the libs are found but exist in an incompatible version.
2020-03-27 13:29:25 +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ö b89cdef107 build-llvm: Generalize the build command 2020-03-25 00:29:07 +02:00
Martin Storsjö 13e441d60e build-llvm: Only pass -j to ninja if CORES was set originally
If CORES was unset, let ninja pick the core count (which normally
is set higher than the number of cores).
2020-03-25 00:29:07 +02:00
Martin Storsjö 91c1339222 Only use the newer form for disabling LLDB's external dependencies
Also pass the new form properly when cross compiling LLDB.
2020-03-25 00:19:49 +02:00
Martin Storsjö 68280abd1a build-llvm: Update to the 10.0.0 release of llvm
Notable changes since the previously pinned (early December 2019)
version:
- Implicitly add the .exe suffix if not provided in the clang
  -o argument, when running on windows (to match GCC's behaviour)
- Fixes for accesses to TLS variables in another object file
- Fixes for accessing weak functions that may be undefined, on ARM and AArch64
  (x86 was fixed earlier)
- Fixed many instances of locale handling in libcxx
2020-03-24 23:07:21 +02:00
Martin Storsjö 93d8fb4a8b build-llvm: Install the LLVM license 2020-03-05 11:31:31 +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ö 6513708aff build-llvm: Use more cmake variables for disbling python and other lldb external libs
These defines were renamed in lldb git master, soon after the current
pinned version.

This fixes building with a later version of llvm than the pinned one.
2020-01-05 21:59:37 +02:00
Martin Storsjö de510f07b5 build-llvm: Enable building LLDB 2019-12-28 13:59:42 +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ö 056c1f5cd2 build-llvm: Update to a recent git master version of llvm
Notable changes since the previous version are:
- Added a lld option for requesting delay loading libraries
- Allowing using custom .edata from input object files in lld (for Wine)
- Fixed llvm-dlltool with symbol renaming with stdcall decorations
- Supporting merging resources from more than one resource object file in lld
- Improved error messages for duplicate or undefined symbols in lld
  (including demangling C++ symbols and printing source locations
  where possible)
- Made lld look for for more library name patterns, matching GNU ld
- Brushed up support for using LLDB for, and building on, mingw
- Implemented initial support for armv7 and aarch64 windows in LLDB
2019-12-19 23:09:29 +02:00
Jacek Caban f862f91c1c Allow overriding default llvm and msvcrt versions.
build-mingw-w64.sh already provides --with-default-msvcrt option, but
this makes it more convenient to use build-all.sh with non-default
msvcrt config.
2019-12-19 22:18:22 +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ö 255286eb72 build-llvm: Fix only checking out the source
This is used if calling build-compiler-rt.sh or build-libcxx.sh with
the environment variable SYNC set.
2019-10-23 13:21:56 +00:00
Martin Storsjö c7821ce27d build-llvm, strip-llvm: Include llvm-symbolizer
This is necessary for getting addr2line included.
2019-10-23 13:21:56 +00:00
Martin Storsjö ef9af0d3ad build-llvm: Update to the 9.0.0 release 2019-09-20 11:27:27 +03:00
Martin Storsjö c2f25a93ad build-llvm: Remove a redundant -b parameter to git clone 2019-09-20 11:27:27 +03:00
Martin Storsjö 3024fbc50f build-llvm: Set LLVM_HOST_TRIPLE when cross compiling
This makes the bare executables know what their default triple
is.
2019-09-17 13:59:59 +03:00
Martin Storsjö d31dc46137 build-llvm: Use symlinks in the llvm/tools directory instead of LLVM_ENABLE_PROJECTS
This makes cmake use relative paths to all source files, allowing ccache
to reuse compilation results from different source trees in different
directories.

Keep using LLVM_ENABLE_PROJECTS on msys, where symlinks aren't supported.
2019-09-12 14:32:14 +03: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ö 4670446157 Install llvm-addr2line 2019-07-01 22:30:24 +03:00
Martin Storsjö 0c7aac99ad Update llvm/clang/lld to the latest version
This version adds support for a version of the -pdb option to the MinGW
frontend to lld that can work without a parameter, and implements --help
and -v for the same frontend.
2019-05-28 00:03:05 +03:00
Steve Lhomme b31ef612fb also pass the number of CORES to Ninja
It may automatically get a value but we can't override it
2019-05-21 14:26:26 +03:00
Martin Storsjö d009355b91 build-llvm: Remove the now unnecessary BUILDTARGETS variable 2019-05-09 09:22:26 +03:00
Martin Storsjö 873243acc2 build-llvm: Use the built-in recursive cmake for building llvm-tblgen if necessary
This requires setting a flag to use the system default compiler
for this, instead of the cross compiler.
2019-05-09 09:22:26 +03:00