mirror of
https://github.com/crosstool-ng/crosstool-ng.git
synced 2024-12-18 12:36:23 +00:00
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>
This commit is contained in:
parent
d4953677cd
commit
f9ab04b63a
@ -796,6 +796,7 @@ gen_selection choice kernel "Target OS"
|
||||
gen_selection choice cc "Compiler"
|
||||
gen_selection choice binutils "Binutils"
|
||||
gen_selection choice libc "C library"
|
||||
gen_selection menu linker "Linkers"
|
||||
gen_selection menu debug "Debug facilities"
|
||||
gen_selection menu comp_tools "Companion tools"
|
||||
gen_selection menu comp_libs "Companion libraries"
|
||||
|
@ -8,6 +8,7 @@ source "config/kernel.in"
|
||||
source "config/binutils.in"
|
||||
source "config/libc.in"
|
||||
source "config/cc.in"
|
||||
source "config/linker.in"
|
||||
source "config/debug.in"
|
||||
source "config/comp_libs.in"
|
||||
source "config/comp_tools.in"
|
||||
|
12
config/linker.in
Normal file
12
config/linker.in
Normal file
@ -0,0 +1,12 @@
|
||||
menu "Linkers"
|
||||
|
||||
if BINUTILS_LINKER_LD || BINUTILS_LINKER_BOTH
|
||||
comment "BFD enabled in binutils"
|
||||
endif # BINUTILS_LINKER_LD
|
||||
if BINUTILS_LINKER_GOLD || BINUTILS_LINKER_BOTH
|
||||
comment "GOLD enabled in binutils"
|
||||
endif # BINUTILS_LINKER_GOLD
|
||||
|
||||
source "config/gen/linker.in"
|
||||
|
||||
endmenu
|
7
config/linker/mold.in
Normal file
7
config/linker/mold.in
Normal file
@ -0,0 +1,7 @@
|
||||
# mold options
|
||||
|
||||
config LINKER_MOLD_has_cmake
|
||||
def_bool $(success,which cmake)
|
||||
|
||||
comment "mold requires cmake"
|
||||
depends on !LINKER_MOLD_has_cmake
|
1
ct-ng.in
1
ct-ng.in
@ -275,6 +275,7 @@ CT_STEPS := \
|
||||
companion_tools_for_host \
|
||||
companion_libs_for_host \
|
||||
binutils_for_host \
|
||||
linker \
|
||||
libc_headers \
|
||||
kernel_headers \
|
||||
cc_core \
|
||||
|
4
packages/mold/2.31.0/chksum
vendored
Normal file
4
packages/mold/2.31.0/chksum
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
md5sum v2.31.0.tar.gz fdfcddefc039071f5a7611c051a8f5ea
|
||||
sha1sum v2.31.0.tar.gz 0168ecab12d87a6197cfec4824a3e82115c6a2bd
|
||||
sha256sum v2.31.0.tar.gz 3dc3af83a5d22a4b29971bfad17261851d426961c665480e2ca294e5c74aa1e5
|
||||
sha512sum v2.31.0.tar.gz 343c62d8c67b74988f762c46999d2d866b2e9a0c69d2b910b12384ea5abc620b30468cd1b1bacfe41474d1c97c8ce2e49d55ca70479691238fb73d83d9adc683
|
0
packages/mold/2.31.0/version.desc
vendored
Normal file
0
packages/mold/2.31.0/version.desc
vendored
Normal file
4
packages/mold/package.desc
Normal file
4
packages/mold/package.desc
Normal file
@ -0,0 +1,4 @@
|
||||
repository='git https://github.com/rui314/mold.git'
|
||||
mirrors='https://github.com/rui314/mold/archive/refs/tags'
|
||||
archive_filename='v@{version}'
|
||||
archive_formats='.tar.gz'
|
38
scripts/build/linker.sh
Normal file
38
scripts/build/linker.sh
Normal file
@ -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
|
||||
}
|
||||
|
38
scripts/build/linker/100-mold.sh
Normal file
38
scripts/build/linker/100-mold.sh
Normal file
@ -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
|
||||
}
|
@ -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
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user