Commit graph

76 commits

Author SHA1 Message Date
Brian Gianforcaro 2ef93a3c07 Build: Use variables when concatenating Toolchain paths.
Make this stuff a bit easier to maintain by using the
root level variables to build up the Toolchain paths.

Also leave a note for future editors of BuildIt.sh to
give them warning about the other changes they'll need
to make.
2021-04-27 13:07:04 +02:00
Gunnar Beutner d71f64b97f Toolchain: Build GCC with optimizations 2021-04-20 23:23:23 +02:00
Gunnar Beutner 75d41657d5 Toolchain+Ports: Enable threads for gcc
This enables POSIX threads for GCC and makes the -pthread
argument available.
2021-04-20 21:08:17 +02:00
xackus 6e2f2cd8b1 Toolchain: Don't produce debug symbols
Previously debug symbols were produced and then stripped.
2021-04-19 09:49:14 +02:00
Emanuele Torre 685556ae84 Toolchain/BuildIt.sh: let's have colours on macOS too :^)
MacOS's sed doesn't support "\x1b" expansion unlike GNU sed, but we can
still use bash's $'\x1b' to expand it.
2021-04-18 19:00:49 +02:00
Gunnar Beutner 05d140e7bd Toolchain: Add missing buildstep calls 2021-04-18 15:51:56 +02:00
Gunnar Beutner 8a50c8431b Toolchain: Cache the output of uname -s 2021-04-18 15:51:56 +02:00
Gunnar Beutner c60f02fbc2 Toolchain: Build fix for macOS
Unfortunately their sed behaves a tiny bit different to how
GNU sed does.
2021-04-18 15:51:56 +02:00
Gunnar Beutner a1e0cf80e8 Toolchain: Colorize the toolchain build script's output 2021-04-18 10:55:25 +02:00
Gunnar Beutner d7978a3317 Toolchain: Enable -fexceptions and build a separate libstdc++ for the kernel
This enables building usermode programs with exception handling. It also
builds a libstdc++ without exception support for the kernel.

This is necessary because the libstdc++ that gets built is different
when exceptions are enabled. Using the same library binary would
require extensive stubs for exception-related functionality in the
kernel.
2021-04-18 10:55:25 +02:00
Brian Gianforcaro 73fab93ef5 Toolchain: Update to the latest gcc release 10.3.0
10.3.0 is a bugfix release, with 178 bugs fixed.
See: https://gcc.gnu.org/bugzilla/buglist.cgi?bug_status=RESOLVED&resolution=FIXED&target_milestone=10.3
2021-04-14 21:49:54 +02:00
Brian Gianforcaro 5d59affc18 Toolchain: Update binutils to version to latest 2.36.1 release
This updates binutils to the latest release. It looks like some
lines where shuffled around, so I had to fixup out patch to
apply cleanly again.
2021-04-14 21:49:54 +02:00
Gunnar Beutner e95cb252be Toolchain: Install system headers before building GCC
GCC determines whether the system's <limits.h> header is usable
and installs a different version of its own <limits.h> header
depending on whether the system header file exists.

If the system header is missing GCC's <limits.h> header does not
include the system header via #include_next.

For this to work we need to install LibC's headers before
attempting to build GCC.

Also, re-running BuildIt.sh "hides" this problem because at that
point the sysroot directory also already has a <limits.h> header
file from the previous build.
2021-04-12 22:37:34 +02:00
Ben Wiederhake 100ce8fc1f Toolchain: Always strip compiler, not just on CI 2021-03-13 22:42:20 +01:00
Tom 389dddd4b3 Meta: Add a build helper script
This script automatically manages the toolchain and cmake/ninja folders
making it easier to manage the different target architectures.
2021-03-09 07:28:59 +01:00
AnotherTest bd318dcdcd Toolchain: Always remove the previous artifacts when building 2021-02-21 23:50:34 +01:00
joshua stein 4a2209d0e0 Toolchain: Explicitly enable LTO, fix build on OpenBSD 2021-02-14 09:29:22 +01:00
joshua stein 0d215b5548 Build: Sprinkle some portability, fix on OpenBSD
realpath(1) is specific to coreutils and its behavior can be had
with readlink -f

Create the Toolchain Build directory if it doesn't exist before
calling readlink, since realpath(3) on at least OpenBSD will error
on a non-existent path
2021-02-14 09:29:22 +01:00
Andreas Kling 13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
meme 23b23cee5a Build: Support non-i686 toolchains
* Add SERENITY_ARCH option to CMake for selecting the target toolchain
* Port all build scripts but continue to use i686
* Update GitHub Actions cache to include BuildIt.sh
2020-12-29 17:42:04 +01:00
Luke 3bdaba0b28 Meta: Add macOS workflow to CI
A good number of contributors use macOS. However, we have a bit of
a tendency of breaking the macOS build without realising it.

Luckily, GitHub Actions does actually supply macOS environments,
so let's use it.
2020-12-28 19:35:32 +01:00
Itamar 758fc8c063 Toolchain: Fix usage of libgcc_s & build PIE executables by default
We can now build the porst with the shared libraries toolchain.
2020-12-14 23:05:53 +01:00
Ben Wiederhake a82a17eee8 Toolchain: Trust cache blindly
This is necessary because cache reusability will be determined by Github Actions.

Note that we only cache if explicitly asked to do so,
which only happens on Github Actions.
2020-11-08 09:58:55 +01:00
Laurent Cimon b4790010a8 Build: Modify various parts to allow the build to succeed on FreeBSD 2020-10-20 14:40:47 +02:00
Linus Groh 8fe89cf441 Toolchain: Set CACHED_TOOLCHAIN_ARCHIVE after computing hash 2020-10-19 21:11:39 +02:00
Linus Groh 602eb98479 Toolchain: Remove cached archive and rebuild if extracting fails
This is currently the case on Travis CI: the file exists but fails to
extract, breaking all the CI builds.
2020-10-19 20:06:59 +02:00
Andreas Kling 583bfa04e2 Toolchain: Upgrade to Binutils 2.35.1 2020-10-12 19:53:25 +02:00
Andreas Kling 75d5f436bc Toolchain: Upgrade to GCC 10.2.0 2020-10-12 19:53:25 +02:00
Ben Wiederhake 3ab706cac3 Travis: Strip every executable
This cuts down the size of a Toolchain cache entry by another quarter.
(About 250 MiB to about 190 MiB).
2020-09-14 11:40:48 +02:00
Ben Wiederhake 5f724b6ca1 Travis: Toolchain only depends on headers, not impls
When libstdc++ was added in 4977fd22b8, just calling
'make install' was the easiest way to install the headers. And the headers are all
that is needed for libstdc++ to determine the ABI. Since then, BuildIt.sh was
rewritten again and again, and somehow everyone just silently assumed that
libstdc++ also depends on libc.a and libm.a, because surely it does?

Turns out, it doesn't! This massively reduces the dependencies of libstdc++,
hopefully meaning that the Toolchain doesn't need to be rebuilt so often on Travis.

Furthermore, the old method of trying to determine the dependency tree with
bash/grep/etc. has finally broken anyways:

    https://travis-ci.com/github/SerenityOS/serenity/builds/179805569#L567

In summary, this should eliminate most of the Toolchain rebuilds on Travis,
and therefore make Travis build blazingly fast! :^)
2020-08-15 16:49:55 +02:00
Ben Wiederhake 3f2b78a063 Build: Build libstdc++ in parallel 2020-08-02 18:50:28 +02:00
Ben Wiederhake cdcc09f63b Travis: 'configure' is too chatty for CI
./configure generates about 3500 lines in a few seconds. Noone will ever read
those lines and they make loading the Travis webpage slower. And if there is
ever a problem, it will be because the Travis base image changed (which happens
only rarely) in a way that interferes with compiling gcc (which is incredibly
unlikely), or we update gcc (which happens very rarely) and gcc doesn't like
the Travis iamge (which again is incredibly unlikely). In all of these cases,
finding the culprit will be self-evident.
2020-08-02 18:50:28 +02:00
Nico Weber 06c59cce6f Toolchain: Strip cc1 2020-07-29 17:36:38 +02:00
Andreas Kling 9dcd776da9 Toolchain: Let's leave cc1 in place for now 2020-07-29 15:10:00 +02:00
Ben Wiederhake f29fbe3c76 Meta: Fix shellcheck issues in BuildIt.sh 2020-07-29 01:24:24 +02:00
Ben Wiederhake 962e7855c5 Travis: Reduce Toolchain cache item size by 73%
Empirically, every single push or PR has to download *and then upload*
about 3.6 GiB of "cache stuff", which takes up about 400 seconds:
https://travis-ci.com/github/SerenityOS/serenity/builds/177500795
On every single push/PR! No matter what!

Those 3.6 GB consist of:
- 3.2 GB Toolchain cache (around 260 MB per compressed item)
- 0.4 GB ccache, but is capped at 0.5 GB: https://travis-ci.com/github/BenWiederhake/serenity/builds/177528549
- (And 200 KB for some weird debian package? Dunno.)

Investigating in the size, the Toolchain consists mostly of *DEBUG SYMBOLS IN
THE COMPILER BINARIES* which comically misses the point. If we ever run into
compiler crashes, any stacktrace would be lost anyway as soon as the Travis VM
shuts down. Furthermore, Travis will only ever compile Serenity itself, and
Serenity forbids C in it's Contribution Guidelines. That's another 20 MB we
don't need to cache.

Stripping the binaries and deleting the C compiler reduces the uncompressed size
from 1200 MB down to 220 MB. The compressed size gets reduced from 260 MB to 70MB.
That's a reduction of 73%.

It'll take a while until the 'old' toolchains get deleted.
I guess it'll take less than a week.

From that point onward, the Travis cache will be 1.2 GB, consisting of:
- 0.7 GB Toolchain cache
- 0.5 GB ccache
- (And that weird 200 KB deb file)

If network speeds are linear, then this should reduce the "cache network
overhead time" from about 400 seconds to about 120 seconds.

tl;dr: Strip unnecessary debug infos, delete an unused files, and speed
everything up by two minutes. (Both Toolchain cache hits and Toolchain rebuilds!)
2020-07-29 01:24:24 +02:00
Stefano Cristiano a1e1aa96fb Toolchain: Allow building using CMake on macOS 2020-07-13 08:46:44 +02:00
Érico Nogueira Rolim fef9ad520b
Toolchain: Use curl instead of wget (#2574)
- For Linux: curl is already listed as a dependency;
- For macOS: curl is pre-installed;
- For OpenBSD and FreeBSD: curl is a dependecy of git.
2020-06-18 16:31:12 +02:00
Paul Redmond 1a56fe714c
Toolchain: Support building the toolchain with Ninja (#2504)
This change allows users to use CMAKE_GENERATOR=Ninja ./BuildIt.sh

BuildIt.sh assumes the default cmake generator is Make. However,
the user may specify CMAKE_GENERATOR=Ninja, for example, to set the
default generator. Therefore, instead of calling make to build the
LibC target we should call cmake --build to use the correct generated
files.
2020-06-05 09:31:10 +02:00
Andreas Kling 8876bfc3ac Revert "AK: Don't demangle in serenity :("
This reverts commit 4361a50225.
2020-05-20 16:24:26 +02:00
Andreas Kling ef776c1e68 Revert "LibC: Implement Itanium C++ ABI for static variable guards"
This reverts commit cdbbe14062.
2020-05-20 16:24:26 +02:00
Andreas Kling 3d02b23af5 Revert "Toolchain: Don't pre-build LibC and LibM, nor pre-install their headers"
This reverts commit 4e051c6c15.
2020-05-20 16:24:26 +02:00
Andrew Kaster 4e051c6c15 Toolchain: Don't pre-build LibC and LibM, nor pre-install their headers
We can do away with that shenanigans now that libstdc++ is gone.
Also, simplify the toolchain dependency hash calculation to only depend
on the toolchain build script(s) and the Patches files we use to modify
the toolchain itself.
2020-05-20 08:37:50 +02:00
Andrew Kaster cdbbe14062 LibC: Implement Itanium C++ ABI for static variable guards
This is __cxa_guard_acquire, __cxa_guard_release, and __cxa_guard_abort.

We put these symbols in a 'fake' libstdc++ to trick gcc into thinking it
has libstdc++. These symbols are necessary for C++ programs and not C
programs, so, seems file. There's no way to tell gcc that, for example,
the standard lib it should use is libc++ or libc. So, this is what we
have for now.

When threaded code enters a block that is trying to call the constructor
for a block-scope static, the compiler will emit calls to these methods
to handle the "call_once" nature of block-scope statics.

The compiler creates a 64-bit guard variable, which it checks the first
byte of to determine if the variable should be intialized or not.

If the compiler-generated code reads that byte as a 0, it will call
__cxa_guard_acquire to try and be the thread to call the constructor for
the static variable. If the first byte is 1, it will assume that the
variable's constructor was called, and go on to access it.

__cxa_guard_acquire uses one of the 7 implementation defined bytes of
the guard variable as an atomic 8 bit variable. To control a state
machine that lets each entering thread know if they gained
'initialization rights', someone is working on the varaible, someone is
working on the varaible and there's at least one thread waiting for it
to be intialized, or if the variable was initialized and it's time to
access it. We only store a 1 to the byte the compiler looks at in
__cxa_guard_release, and use a futex to handle waiting.
2020-05-20 08:37:50 +02:00
Andrew Kaster 4361a50225 AK: Don't demangle in serenity :(
In order to remove libstdc++ completely, we need to give up on their
implementation of abi::__cxa_demangle. The demangler logic will actually
have to be quite complex, and included in both the kernel and userspace.

A definite fixme for the future, to parse the mangled names into real
deal names.
2020-05-20 08:37:50 +02:00
Shannon Booth 2ffbdf5680 Toolchain/Ports: Update to gcc 10.1.0 2020-05-16 09:51:31 +02:00
Sergey Bugaev 450a2a0f9c Build: Switch to CMake :^)
Closes https://github.com/SerenityOS/serenity/issues/2080
2020-05-14 20:15:18 +02:00
Ben Wiederhake 29a44bc325 Travis: Fix Cache spam
Back in 36ba0a35ee I thought that Travis would
automagically delete theoldest files. Apparently it does not.

Note that no dummy changes are needed, because BuildIt.sh lists itself
as a dependency for the Toolchain. Hooray for something that works!
2020-05-11 10:27:19 +02:00
Devashish c4d05049c4 Toolchain: Don't create repository for patches if not necessary
The toolchain builds just fine without the git repository (tested on
windows and linux). We can skip setting up the repo and apply the
patches directly when we aren't working on the toolchain itself. A
flag `--dev` has been added for cases when git repo is needed. Without
the flag, regular patch is applied. This significantly improves build
times for first time builds.
2020-04-27 17:59:33 +02:00
Shannon Booth c47ef61ed8 Toolchain/Ports: Update gcc to 9.3.0
Ever closer to C++20! Also fix up some of those pesky "'s
2020-03-23 08:22:41 +01:00