forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Toolchain: Add support for building the userland with the mold linker
This commit adds support for building the SerenityOS userland with the new [mold linker]. This is not enabled by default yet; to link using mold, run the `Toolchain/BuildMold.sh` script to build the latest release of mold, and set the `ENABLE_MOLD_LINKER` CMake variable to ON. This option relies on toolchain support that has been added just recently, so you might need to rebuild your toolchain for mold to work. [mold linker]: https://github.com/rui314/mold
- Loading branch information
Showing
7 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script builds the mold linker that can optionally be used for linking | ||
# the SerenityOS userland. | ||
set -e | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
NPROC="nproc" | ||
SYSTEM_NAME="$(uname -s)" | ||
|
||
if [ "$SYSTEM_NAME" = "OpenBSD" ]; then | ||
NPROC="sysctl -n hw.ncpuonline" | ||
elif [ "$SYSTEM_NAME" = "FreeBSD" ]; then | ||
NPROC="sysctl -n hw.ncpu" | ||
elif [ "$SYSTEM_NAME" = "Darwin" ]; then | ||
NPROC="sysctl -n hw.ncpu" | ||
fi | ||
|
||
[ -z "$MAKEJOBS" ] && MAKEJOBS=$($NPROC) | ||
|
||
mkdir -p "$DIR"/Tarballs | ||
pushd "$DIR"/Tarballs | ||
|
||
if [ "$1" = "--git" ]; then | ||
[ ! -d mold ] && git clone https://github.com/rui314/mold.git | ||
|
||
cd mold | ||
|
||
git pull | ||
else | ||
VERSION=1.0.2 | ||
[ ! -e mold-$VERSION.tar.gz ] && curl -L "https://github.com/rui314/mold/archive/refs/tags/v$VERSION.tar.gz" -o mold-$VERSION.tar.gz | ||
[ ! -e mold-$VERSION ] && tar -xzf mold-$VERSION.tar.gz | ||
cd mold-$VERSION | ||
fi | ||
|
||
make clean | ||
export DESTDIR="$DIR"/Local/mold | ||
export PREFIX= | ||
make -j "$MAKEJOBS" | ||
make install | ||
|
||
popd |