Commit graph

200 commits

Author SHA1 Message Date
Martin Bříza 41ea37f25a Toolchain/GCC: Declare we don't have memalign
I'm not even sure if this is a hack. However, we don't implement
memalign so it's necessary to tell GCC so it doesn't go looking for it
in their implementation of `new`
2022-01-07 18:38:32 +01:00
Daniel Bertalan 84c6d6649e Toolchain: Fix building the aarch64 toolchain
The `aarch64/t-aarch64` makefile fragment needs to be included for the
aarch64-specific parts of GCC to be built. Before 738e52da5, this was
done implicitly, but now it is not. This caused the following error when
building the toolchain: "aarch64-builtins.o: No such file or directory".
2022-01-04 17:40:09 +00:00
Jean-Paul Balabanian 913511249b Toolchain: Add support for Clang on MacOS
This commit adds Darwin as a possible host for building the toolchain
with Clang.
2022-01-04 00:40:11 +03:30
Andrew Kaster eb672aef31 Toolchain: Add CMAKE_PLATFORM_USES_PATH_WHEN_NO_SONAME to Platform
This property tells CMake that if a library is missing a SONAME field,
the link editor(s) we use will insert the full path to the library into
the binary. This is the behaivor of GNU ld compatible linkers, so let's
avoid that possiblity by telling CMake that it really doesn't want to
let the linker embed the full path to the lib. This is especially
important when cross-compiling things for ports and such, as the full
path to the lib will have absolutely nothing to do with the runtime path
2022-01-03 11:08:45 +00:00
Andrew Kaster c5898806d2 Toolchain: Use Platform/SerenityOS.cmake in LLVM toolchain build
By setting CMAKE_MODULE_PATH in the LLVM initial cache scripts, we can
make the "SerenityOS" CMAKE_SYSTEM_NAME usable in the builds of
compiler-rt, libunwind, libcxxabi and libcxx.

This simplifies some toolchain patches and brings the cross-compiler
patches closer to the Port's patches, and closer to something
upstreamable.
2022-01-03 11:08:45 +00:00
tuftedocelot 5810467c97 Build: Remove gzip -k usage in PCI/USB ID files and crypt for OpenBSD
OpenBSD gzip does not have the -k flag to keep the original after
extraction. Work around this by copying the original gzip to the dest
and then extracting. A bit of a hack, but only needs to be done for the
first-time or rebuilds

OpenBSD provides crypt in libc, not libcrypt. Adjust if/else to check
for either and proceed accordingly

Remove outdated OpenBSD checks when building the toolchain
2021-12-29 03:46:56 -08:00
Daniel Bertalan 738e52da56 Toolchain: Link libgcc_s on an as-needed basis
If we pass `-lgcc_s` explicitly to the linker, it will be added as a
dependency even if no functions are used from it. This behavior is not
consistent with other systems. GCC can already handle passing the
correct flags, so let's rely on that instead.

As an added benefit, we now get support for the `-static-libgcc` flag;
and `-static-pie` will no longer mistakenly link us against the dynamic
version of libgcc.

No toolchain rebuild is required.
2021-12-16 21:27:03 +02:00
Brian Gianforcaro fb53eacefd Toolchain: Update BuildQemu.sh to qemu-6.2
QEMU 6.2 was released on December 14th.
Release Notes: https://wiki.qemu.org/ChangeLog/6.2
2021-12-16 03:15:40 -08:00
Daniel Bertalan 36bd230ffa Toolchain/Clang: Fix CMake using utilities from the LLVM port
If we have the LLVM port installed, CMake might pick up some of the
tools installed as part of it (`llvm-ar`, `llvm-strip`, etc.) instead of
the ones belonging to the host toolchain. These, of course, can't be run
on the host platform, so builds would eventually fail. This made it
impossible to rebuild the LLVM toolchain.

We now set these variables explicitly when compiling the LLVM runtime
libraries in order to avoid this issue.
2021-11-28 09:38:57 -08:00
Daniel Bertalan b1f6bfca7f Toolchain/Clang: Support using libstdc++ as the C++ standard library
This will come in handy if we want to use the LLVM port with a GNU host
compiler.

As of version 13, libc++ uses `__attribute__((using_if_exists))` to
import global LibC functions into the `std` namespace, which allows some
symbols to be absent. GCC does not support this attribute, so it fails
to build libc++ due to some obscure `wchar.h` functions. This means that
cross-compiling libc++ is not possible; and on-target builds would be
tedious, so we'll be better off using the toolchain's `libstdc++`.
2021-11-28 09:38:57 -08:00
Daniel Bertalan ce3b219021 Toolchain/Clang: Allow setting a default unwind library
This will let us use `libgcc` for unwinding when we build the LLVM port
with the GNU toolchain.
2021-11-28 09:38:57 -08:00
Daniel Bertalan ea8335cda1 Toolchain/Clang: Pick up includes when running inside Serenity
The toolchain should work without setting `--sysroot` when we build
inside SerenityOS.
2021-11-28 09:38:57 -08:00
Daniel Bertalan 91546f42f3 Toolchain/Clang: Add support for -static-libstdc++
This option is already used by our GNU toolchain to avoid creating a
circular dependency between LibC and `lib(std)c++`.
2021-11-28 09:38:57 -08:00
Jelle Raaijmakers 8292061f53 Toolchain: Remove git clone of project from Dockerfile
The goal of these more recent additions to the Dockerfile is to provide
a working copy of SerenityOS with the toolchain prebuilt. To me, these
additions feel misplaced:

- The toolchain is built assuming the i686 architecture, which may not
  be what you want.
- You get a shallow clone of the project limiting you in your abilities
  to navigate through the project's history or bisect.
- There's this awkward directory structure of `/serenity/serenity-git`
  and `/serenity/out`.

The Dockerfile is immensely useful for building SerenityOS in a
containerized environment, separate from the host's environment. If we
want to automate builds, we can always use CI or extend this image to
do so. For now, let's remove the `git clone` and associated actions.

Fixes #9310.
2021-11-20 21:16:51 +00:00
Jelle Raaijmakers cff3add897 Toolchain: Remove unused gettext package from Dockerfile
It is no longer used to build the git port, it seems.
2021-11-20 21:16:51 +00:00
Jelle Raaijmakers b08a265840 Toolchain: Remove unused wget package from Dockerfile 2021-11-20 21:16:51 +00:00
Jelle Raaijmakers 8744086781 Toolchain: Add Qemu build dependencies to Dockerfile
Also add `libsdl2-dev` as a required dependency and reorder the
list of packages passed to `apt-get`.
2021-11-20 21:16:51 +00:00
Jelle Raaijmakers b7bf1a4330 Toolchain: Update Dockerfile to ubuntu:21.10 2021-11-20 21:16:51 +00:00
Andrew Kaster 6f5b9cc031 Toolchain: Enable clang-tools-extra for LLVM
If we want to use clang-tidy on the codebase, we'll need to build
clang-tidy from an LLVM that has been patched and built with Serenity
cross-compilation support.
2021-11-14 22:52:35 +01:00
Tim Schumacher 292398b585 Toolchain: Load x64 executables at a higher address
Serenity defines a protected range of memory that must not be mmapped,
and is apparently reserved for kernel tasks. In this case, the protected
range is anything below 0x800000.

However, in its default setting, binutils chooses the memory address
0x400000 as the mapping address for executables that do not have PIE
enabled, resulting in mmap being unable to map the file unless the load
address has been overwritten at link time or if it's a PIE.

To mitigate this, move the default base address somewhere outside of
that range (and preferably not anywhere close near the beginning of the
useable virtual memory space, to avoid running into it during sequential
allocations).
2021-11-14 22:25:15 +01:00
Daniel Bertalan 061fa8a1ca Toolchain: Add aligned allocation support to libc++
Now that we have `_aligned_malloc` and `_aligned_free`, we can finally
enable C++17 aligned allocation support.
2021-11-14 16:46:21 +00:00
Tim Schumacher 22562b4b17 CMake: Assume working compiler instead of using static linking
We were previously using TRY_COMPILE_TARGET_TYPE to bypass the compiler
check at the beginning of the CMake build, since we don't have LibC
available and therefore can't link at that point.

However, this breaks a lot of assumptions in try_compile when it comes
to library checks. While this was the main idea behind our usage of the
flag, it also has some really nasty side effects when software wants
to find out what library a symbol is in.

Instead, just manually tell CMake that our compiler works as intended
and keep the target type setting at its default.
2021-11-07 20:11:23 -08:00
Tim Schumacher 8f060bed17 Toolchain: Use dynamic paths for cross-compile CMake toolchains
`CMAKE_INSTALL_PREFIX` is supposed to be the in-system installation
path. The sysroot path on the host doesn't belong there, since other
applications will duplicate that path when applying their respective
sysroot.
2021-10-31 12:09:25 +01:00
Daniel Bertalan 06fc64be13 Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.

The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.

Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.

We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.

The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-10-17 17:09:58 +01:00
Daniel Bertalan c524f58290 Toolchain: Introduce stubs for core system libraries
This allows the linker to link against these dynamic libraries when
compiling libc++/libunwind, without having to do a separate
bootstrapping LibC build.

Without this change, libc++ would fail to pick up the need to link to
`LibPthread` if no prior builds of it existed. Because of this, we'd
immediately have an assertion failure in SystemServer, as mutexes are
used for the safe construction of function-local static variables.
2021-10-17 17:09:58 +01:00
Ben Wiederhake 52e9f25403 Everywhere: Change from http to https where feasible
I used "git grep -FIn http://" to find all occurrences, and looked at
each one. If an occurrence was really just a link, and if a https
version exists, and if our Browser can access it at least as well as the
http version, then I changed the occurrence to https.

I'm happy to report that I didn't run into a single site where Browser
can't deal with the https version.
2021-10-05 02:08:08 +02:00
Eric Seifert 01a06dde0e Ports: Add Ruby 3.0.2 2021-09-24 10:04:47 +02:00
Timothy Flynn 5a2f41fff0 Toolchain: Add --ci option to BuildClang to enable ccache 2021-09-21 15:39:17 +03:00
Tim Schumacher dea43d88e7 Toolchain: Remove breaking mbstate_t define from clang 2021-09-17 00:14:57 +00:00
Andrew Kaster b9e3647e66 Meta+Toolchain: Rename CMAKE_CXXFILT to SERENITY_CXXFILT
The "CMAKE_<foo>" variable namespace is reserved, and CXXFILT is not
currently a variable known to upstream CMake.
2021-09-15 19:04:52 +04:30
Andrew Kaster b5c98ede08 Meta: Switch to a SuperBuild that splits host and target builds
Replace the old logic where we would start with a host build, and swap
all the CMake compiler and target variables underneath it to trick
CMake into building for Serenity after we configured and built the Lagom
code generators.

The SuperBuild creates two ExternalProjects, one for Lagom and one for
Serenity. The Serenity project depends on the install stage for the
Lagom build. The SuperBuild also generates a CMakeToolchain file for the
Serenity build to use that replaces the old toolchain file that was only
used for Ports.

To ensure that code generators are rebuilt when core libraries such as
AK and LibCore are modified, developers will need to direct their manual
`ninja` invocations to the SuperBuild's binary directory instead of the
Serenity binary directory.

This commit includes warning coalescing and option style cleanup for the
affected CMakeLists in the Kernel, top level, and runtime support
libraries. A large part of the cleanup is replacing USE_CLANG_TOOLCHAIN
with the proper CMAKE_CXX_COMPILER_ID variable, which will no longer be
confused by a host clang compiler.
2021-09-15 19:04:52 +04:30
Nico Weber 17ab44e7d7 Meta: Make BuildClang.sh produce less output when running in a TTY
Ninja disables its fancy output mode when it's not writing to a TTY.
So don't pipe its output into something else, so that it writes to
a TTY if the invoking terminal is a TTY.
2021-09-07 20:29:22 +01:00
Nico Weber eb7b8a7bbe Meta: Don't pass LLVM_LLVM_BUILD_LLVM_DYLIB to cmake
`LLVM_LLVM_BUILD_LLVM_DYLIB` does not exist, so passing this does
nothing but make CMake warn.

However, since we pass `LLVM_LINK_LLVM_DYLIB`, `LLVM_BUILD_LLVM_DYLIB`
(the correct spelling) defaults to true anyways.  So let's pass fewer
flags.

No behavior change, but fixes a CMake warning.
2021-09-07 20:29:22 +01:00
Nico Weber 1ed1a57707 Meta: Make serenity.sh rebuild-toolchain aarch64 clang work 2021-09-07 20:29:22 +01:00
Idan Horowitz 783a58dbc7 Toolchain: Build aarch64-gdb for cross-debugging on x86 2021-09-07 12:58:46 +02:00
Tom 77953a937d Meta: Add the ability to specify clang with serenity.sh
This enables maintaining gcc and clang builds side-by-side.
2021-09-03 23:12:17 +02:00
Nico Weber a900792921 Toolchain: Also build aarch64-softmmu in BuildQemu.sh 2021-08-28 21:51:30 +01:00
Nico Weber 7052f403c8 Toolchain: Enough to make rebuild-toolchain aarch64 work
The gcc patch might not be completely correct, but at least the
toolchain completes building.
2021-08-28 14:43:07 +01:00
Nico Weber 61b6f69947 Toolchain: Regenerate binutils.patch and gcc.patch
I locally modified Meta/serenity.sh to pass `--dev` to BuildIt.sh
in build_toolchain(). Then I ran `Meta/serenity.sh rebuild-toolchain`,
cd'd into Toolchain/Tarballs/binutils-2.37, `git add`ed unadded files in
`git status`, and then ran `git diff > ../../Patches/binutils.patch`.
Then I did the same for Toolchain/Tarballs/gcc-11.2.0 (and was careful
not to `git add` serenity-kernel.h, since that's created by
Toolchain/BuildIt.sh).

No behavior change. This just rewrites the patch like git writes it.
2021-08-28 14:43:07 +01:00
Brian Gianforcaro aceea42ba4 Toolchain: Update BuildQemu.sh to latest 6.1.0
Change Log: https://wiki.qemu.org/ChangeLog/6.1
2021-08-25 12:13:13 +02:00
Timothy Flynn 7ea55c883b Toolchain: Make Kernel/API headers available to Clang toolchain build
Copied from 9b79867909.
2021-08-17 13:31:43 +01:00
Andreas Kling 9b79867909 Toolchain: Make Kernel/API/ headers available during toolchain build 2021-08-14 20:25:56 +02:00
Daniel Bertalan 657fbc1e6c Toolchain: Remove static LLVM libraries
We link against these dynamically anyways, so having them around is not
useful. Removing them frees precious storage space on CI.
2021-08-08 23:54:00 +02:00
Daniel Bertalan d3595477d8 Toolchain: Build libLLVM as a dynamic library
This library is used by virtually all executables in the Clang
toolchain. By default, it is linked statically, which leads to huge
file sizes and us running out of artifact storage disk space on CI.
2021-08-08 23:54:00 +02:00
Gunnar Beutner a29c18f969 Toolchain+Ports: Let -nostdlib make us not link against libgcc_s
For now this is not a mandatory toolchain rebuild.
2021-08-08 16:41:51 +02:00
Daniel Bertalan 9809e685c1 Toolchain: Add caching to BuildClang.sh for CI 2021-08-08 10:55:36 +02:00
Daniel Bertalan 15e217ea68 Toolchain: Add LLVM patch and script for building it
This contains all the bits and pieces necessary to build a Clang binary
that will correctly compile SerenityOS.

I had some trouble with getting LLVM building with a single command, so
for now, I decided to build each LLVM component in a separate command
invocation. In the future, we can also make the main llvm build step
architecture-independent, but that would come with extra work to make
library and include paths work.

The binutils build invocation and related boilerplate is duplicated
because we only use `objdump` from GNU binutils in the Clang toolchain,
so most features can be disabled.
2021-08-08 10:55:36 +02:00
Linus Groh a613e00caa Ports: Change Python's auth_type to sha256 2021-08-03 21:01:07 +01:00
Gunnar Beutner 5df8c274bb Toolchain+Ports: Fix building ports on x86_64
Fixes #8377.
2021-07-28 21:28:31 +02:00
Gunnar Beutner 9c431ae7ef Toolchain: Update GCC to version 11.2.0 2021-07-28 21:28:31 +02:00