aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorArnaud Vrac <avrac@freebox.fr>2023-09-19 12:42:19 +0200
committerChris Packham <judge.packham@gmail.com>2024-06-05 19:31:45 +1200
commitf9ab04b63aee614ddfd3b50a4c6a0eac2094a2fe (patch)
tree1eaa45408e35d60d8358443f04cdc360a2c47973 /scripts
parentd4953677cdb286c12409b2b5b215de56c521a8b8 (diff)
downloadcrosstool-ng-f9ab04b63aee614ddfd3b50a4c6a0eac2094a2fe.tar.gz
crosstool-ng-f9ab04b63aee614ddfd3b50a4c6a0eac2094a2fe.tar.bz2
crosstool-ng-f9ab04b63aee614ddfd3b50a4c6a0eac2094a2fe.zip
Add mold linker build
Allows building the #mold linker, which can then be used in the cross-toolchain by passing the -fuse-ld=mold to the gcc flags. It is much faster than ld or gold. This requires a C++20 compiler and cmake. Initially implemented by Arnaud, and HC added configure check for cmake. Outstanding task to validate compiler is C++20 compatible. Signed-off-by: Arnaud Vrac <avrac@freebox.fr> Signed-off-by: Hans-Christian Noren Egtvedt <egtvedt@samfundet.no>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/build/linker.sh38
-rw-r--r--scripts/build/linker/100-mold.sh38
-rw-r--r--scripts/crosstool-NG.sh2
-rw-r--r--scripts/functions1
-rw-r--r--scripts/show-config.sh1
5 files changed, 80 insertions, 0 deletions
diff --git a/scripts/build/linker.sh b/scripts/build/linker.sh
new file mode 100644
index 00000000..235d7cf6
--- /dev/null
+++ b/scripts/build/linker.sh
@@ -0,0 +1,38 @@
+# Wrapper to build the standalone linkers
+
+# List all linkers, and parse their scripts
+CT_LINKER_LIST=
+for f in "${CT_LIB_DIR}/scripts/build/linker/"*.sh; do
+ _f="$(basename "${f}" .sh)"
+ _f="${_f#???-}"
+ __f="CT_LINKER_${_f^^}"
+ if [ "${!__f}" = "y" ]; then
+ CT_DoLog DEBUG "Enabling linker '${_f}'"
+ . "${f}"
+ CT_LINKER_LIST="${CT_LINKER_LIST} ${_f}"
+ else
+ CT_DoLog DEBUG "Disabling linker '${_f}'"
+ fi
+done
+
+# Download the linkers
+do_linker_get() {
+ for f in ${CT_LINKER_LIST}; do
+ do_linker_${f}_get
+ done
+}
+
+# Extract and patch the linkers
+do_linker_extract() {
+ for f in ${CT_LINKER_LIST}; do
+ do_linker_${f}_extract
+ done
+}
+
+# Build the linkers
+do_linker() {
+ for f in ${CT_LINKER_LIST}; do
+ do_linker_${f}_build
+ done
+}
+
diff --git a/scripts/build/linker/100-mold.sh b/scripts/build/linker/100-mold.sh
new file mode 100644
index 00000000..710ca969
--- /dev/null
+++ b/scripts/build/linker/100-mold.sh
@@ -0,0 +1,38 @@
+# Build script for the mold linker
+
+do_linker_mold_get() {
+ CT_Fetch MOLD
+}
+
+do_linker_mold_extract() {
+ CT_ExtractPatch MOLD
+}
+
+do_linker_mold_build() {
+ local target_dir="${CT_PREFIX_DIR}/${CT_TARGET}"
+
+ CT_DoStep INFO "Installing mold for host"
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-mold"
+
+ CT_DoLog EXTRA "Configuring mold for host"
+ CT_DoExecLog CFG \
+ CFLAGS="${CT_CFLAGS_FOR_HOST}" \
+ LDFLAGS="${CT_LDFLAGS_FOR_HOST}" \
+ cmake "${CT_SRC_DIR}/mold" \
+ -DBUILD_TESTING=OFF \
+ -DMOLD_MOSTLY_STATIC=ON \
+ -DCMAKE_BUILD_TYPE=Release
+
+ CT_DoLog EXTRA "Building mold for host"
+ CT_DoExecLog ALL make ${CT_JOBSFLAGS}
+
+ CT_DoLog EXTRA "Installing mold for host"
+ mkdir -p "${target_dir}/bin"
+ cp mold "${target_dir}/bin"
+ ln -s mold "${target_dir}/bin/ld.mold"
+ mkdir -p "${target_dir}/lib/mold"
+ cp mold-wrapper.so "${target_dir}/lib/mold"
+
+ CT_Popd
+ CT_EndStep
+}
diff --git a/scripts/crosstool-NG.sh b/scripts/crosstool-NG.sh
index 900dcb18..fdcfe4b3 100644
--- a/scripts/crosstool-NG.sh
+++ b/scripts/crosstool-NG.sh
@@ -660,6 +660,7 @@ if [ -z "${CT_RESTART}" ]; then
do_companion_libs_get
do_binutils_get
do_cc_get
+ do_linker_get
do_libc_get
do_debug_get
do_test_suite_get
@@ -677,6 +678,7 @@ if [ -z "${CT_RESTART}" ]; then
do_companion_libs_extract
do_binutils_extract
do_cc_extract
+ do_linker_extract
do_libc_extract
do_debug_extract
do_test_suite_extract
diff --git a/scripts/functions b/scripts/functions
index a86c528f..0453fe32 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -25,6 +25,7 @@ CT_LoadConfig() {
. "${CT_LIB_DIR}/scripts/build/binutils/${CT_BINUTILS}.sh"
. "${CT_LIB_DIR}/scripts/build/libc.sh"
. "${CT_LIB_DIR}/scripts/build/cc/${CT_CC}.sh"
+ . "${CT_LIB_DIR}/scripts/build/linker.sh"
. "${CT_LIB_DIR}/scripts/build/debug.sh"
. "${CT_LIB_DIR}/scripts/build/test_suite.sh"
diff --git a/scripts/show-config.sh b/scripts/show-config.sh
index 36ade9ec..295e29e3 100644
--- a/scripts/show-config.sh
+++ b/scripts/show-config.sh
@@ -96,6 +96,7 @@ dump_single_sample()
dump_pkgs_desc KERNEL "OS"
dump_pkgs_desc BINUTILS "Binutils"
dump_pkgs_desc CC "Compiler"
+ dump_pkgs_desc LINKER "Linkers"
dump_pkgs_desc LIBC "C library"
dump_pkgs_desc DEBUG "Debug tools"
dump_pkgs_desc COMP_LIBS "Companion libs"