This repository has been archived by the owner on Jan 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: sbwml <[email protected]>
- Loading branch information
Showing
11 changed files
with
480 additions
and
8 deletions.
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
32 changes: 32 additions & 0 deletions
32
...rt/patch/openwrt-6.x/mold/0001-build-add-support-to-use-the-mold-linker-for-package.patch
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,32 @@ | ||
From 18d4007ad731dfa625a6c03d1a946c453d7b92f2 Mon Sep 17 00:00:00 2001 | ||
From: Andre Heider <[email protected]> | ||
Date: Fri, 27 Jan 2023 16:35:46 +0100 | ||
Subject: [PATCH 1/8] build: add support to use the mold linker for packages | ||
|
||
If CONFIG_USE_MOLD is set, all target packages will use the mold linker. | ||
Except the ones which opted-out via setting PKG_BUILD_FLAGS:=no-mold. | ||
|
||
Signed-off-by: Andre Heider <[email protected]> | ||
--- | ||
include/package.mk | 5 +++++ | ||
1 file changed, 5 insertions(+) | ||
|
||
diff --git a/include/package.mk b/include/package.mk | ||
index c391d320aa..1791d6d9d4 100644 | ||
--- a/include/package.mk | ||
+++ b/include/package.mk | ||
@@ -55,6 +55,11 @@ ifeq ($(call pkg_build_flag,lto,$(if $(CONFIG_USE_LTO),1,0)),1) | ||
TARGET_CXXFLAGS+= -flto=auto -fno-fat-lto-objects | ||
TARGET_LDFLAGS+= -flto=auto -fuse-linker-plugin | ||
endif | ||
+ifdef CONFIG_USE_MOLD | ||
+ ifeq ($(call pkg_build_flag,mold,1),1) | ||
+ TARGET_LINKER:=mold | ||
+ endif | ||
+endif | ||
|
||
include $(INCLUDE_DIR)/hardening.mk | ||
include $(INCLUDE_DIR)/prereq.mk | ||
-- | ||
2.39.3 | ||
|
81 changes: 81 additions & 0 deletions
81
openwrt/patch/openwrt-6.x/mold/0002-treewide-opt-out-of-tree-wide-mold-usage.patch
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,81 @@ | ||
From b7619a40b1497d974fef2bcc07bfef6da93e049a Mon Sep 17 00:00:00 2001 | ||
From: Andre Heider <[email protected]> | ||
Date: Fri, 27 Jan 2023 18:22:43 +0100 | ||
Subject: [PATCH 2/8] treewide: opt-out of tree-wide mold usage | ||
|
||
These use linker scripts, which mold doesn't support. | ||
|
||
Signed-off-by: Andre Heider <[email protected]> | ||
--- | ||
include/package.mk | 2 +- | ||
package/boot/grub2/Makefile | 2 +- | ||
package/kernel/lantiq/ltq-ifxos/Makefile | 1 + | ||
package/kernel/lantiq/ltq-vdsl-vr11-mei/Makefile | 1 + | ||
package/kernel/lantiq/ltq-vdsl-vr11/Makefile | 1 + | ||
5 files changed, 5 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/include/package.mk b/include/package.mk | ||
index 1791d6d9d4..61a26f0c43 100644 | ||
--- a/include/package.mk | ||
+++ b/include/package.mk | ||
@@ -24,7 +24,7 @@ PKG_JOBS?=$(if $(PKG_BUILD_PARALLEL),$(MAKE_J),-j1) | ||
endif | ||
|
||
PKG_BUILD_FLAGS?= | ||
-__unknown_flags=$(filter-out no-iremap no-mips16 gc-sections no-gc-sections lto no-lto,$(PKG_BUILD_FLAGS)) | ||
+__unknown_flags=$(filter-out no-iremap no-mips16 gc-sections no-gc-sections lto no-lto no-mold,$(PKG_BUILD_FLAGS)) | ||
ifneq ($(__unknown_flags),) | ||
$(error unknown PKG_BUILD_FLAGS: $(__unknown_flags)) | ||
endif | ||
diff --git a/package/boot/grub2/Makefile b/package/boot/grub2/Makefile | ||
index 865feee9ad..44dafe1ef1 100644 | ||
--- a/package/boot/grub2/Makefile | ||
+++ b/package/boot/grub2/Makefile | ||
@@ -25,7 +25,7 @@ ifneq ($(BUILD_VARIANT),none) | ||
endif | ||
|
||
PKG_FLAGS:=nonshared | ||
-PKG_BUILD_FLAGS:=no-lto | ||
+PKG_BUILD_FLAGS:=no-lto no-mold | ||
|
||
include $(INCLUDE_DIR)/host-build.mk | ||
include $(INCLUDE_DIR)/package.mk | ||
diff --git a/package/kernel/lantiq/ltq-ifxos/Makefile b/package/kernel/lantiq/ltq-ifxos/Makefile | ||
index d941a9d56f..97f7ca78ce 100644 | ||
--- a/package/kernel/lantiq/ltq-ifxos/Makefile | ||
+++ b/package/kernel/lantiq/ltq-ifxos/Makefile | ||
@@ -23,6 +23,7 @@ PKG_LICENSE_FILES:=LICENSE | ||
PKG_EXTMOD_SUBDIRS:=src | ||
|
||
PKG_FIXUP:=autoreconf | ||
+PKG_BUILD_FLAGS:=no-mold | ||
|
||
include $(INCLUDE_DIR)/package.mk | ||
|
||
diff --git a/package/kernel/lantiq/ltq-vdsl-vr11-mei/Makefile b/package/kernel/lantiq/ltq-vdsl-vr11-mei/Makefile | ||
index f2dcf8db84..7b8a948179 100644 | ||
--- a/package/kernel/lantiq/ltq-vdsl-vr11-mei/Makefile | ||
+++ b/package/kernel/lantiq/ltq-vdsl-vr11-mei/Makefile | ||
@@ -25,6 +25,7 @@ PKG_EXTMOD_SUBDIRS:=src | ||
|
||
PKG_FIXUP:=autoreconf | ||
PKG_FLAGS:=nonshared | ||
+PKG_BUILD_FLAGS:=no-mold | ||
|
||
include $(INCLUDE_DIR)/package.mk | ||
|
||
diff --git a/package/kernel/lantiq/ltq-vdsl-vr11/Makefile b/package/kernel/lantiq/ltq-vdsl-vr11/Makefile | ||
index 8284cba9a7..11f96d744a 100644 | ||
--- a/package/kernel/lantiq/ltq-vdsl-vr11/Makefile | ||
+++ b/package/kernel/lantiq/ltq-vdsl-vr11/Makefile | ||
@@ -23,6 +23,7 @@ PKG_LICENSE:=GPL-2.0 BSD-2-Clause | ||
PKG_LICENSE_FILES:=LICENSE | ||
|
||
PKG_FIXUP:=autoreconf | ||
+PKG_BUILD_FLAGS:=no-mold | ||
|
||
include $(INCLUDE_DIR)/package.mk | ||
|
||
-- | ||
2.39.3 | ||
|
58 changes: 58 additions & 0 deletions
58
openwrt/patch/openwrt-6.x/mold/0003-toolchain-add-mold-as-additional-linker.patch
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,58 @@ | ||
From a667acae2ed1d0a99a52e07916b01f42bc9f8f9d Mon Sep 17 00:00:00 2001 | ||
From: Andre Heider <[email protected]> | ||
Date: Fri, 27 Jan 2023 17:53:02 +0100 | ||
Subject: [PATCH 3/8] toolchain: add mold as additional linker | ||
|
||
Install it as $tripple-ld.mold in order to use -fuse-ld=mold. | ||
|
||
Signed-off-by: Andre Heider <[email protected]> | ||
--- | ||
toolchain/Makefile | 2 +- | ||
toolchain/mold/Makefile | 22 ++++++++++++++++++++++ | ||
2 files changed, 23 insertions(+), 1 deletion(-) | ||
create mode 100644 toolchain/mold/Makefile | ||
|
||
diff --git a/toolchain/Makefile b/toolchain/Makefile | ||
index c0046293c9..09c16f72a7 100644 | ||
--- a/toolchain/Makefile | ||
+++ b/toolchain/Makefile | ||
@@ -27,7 +27,7 @@ | ||
curdir:=toolchain | ||
|
||
# subdirectories to descend into | ||
-$(curdir)/builddirs := $(if $(CONFIG_GDB),gdb) $(if $(CONFIG_EXTERNAL_TOOLCHAIN),wrapper,kernel-headers binutils gcc/initial gcc/final $(LIBC) fortify-headers) $(if $(CONFIG_NASM),nasm) | ||
+$(curdir)/builddirs := $(if $(CONFIG_GDB),gdb) $(if $(CONFIG_EXTERNAL_TOOLCHAIN),wrapper,kernel-headers binutils gcc/initial gcc/final $(LIBC) fortify-headers) $(if $(CONFIG_NASM),nasm) $(if $(CONFIG_USE_MOLD),mold) | ||
|
||
# builddir dependencies | ||
ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),) | ||
diff --git a/toolchain/mold/Makefile b/toolchain/mold/Makefile | ||
new file mode 100644 | ||
index 0000000000..a2acba89d3 | ||
--- /dev/null | ||
+++ b/toolchain/mold/Makefile | ||
@@ -0,0 +1,22 @@ | ||
+# | ||
+# This is free software, licensed under the GNU General Public License v2. | ||
+# See /LICENSE for more information. | ||
+# | ||
+include $(TOPDIR)/rules.mk | ||
+include $(INCLUDE_DIR)/toolchain-build.mk | ||
+ | ||
+define Host/Configure | ||
+endef | ||
+ | ||
+define Host/Compile | ||
+endef | ||
+ | ||
+define Host/Install | ||
+ $(INSTALL_DIR) $(TOOLCHAIN_DIR)/bin | ||
+ $(INSTALL_BIN) $(STAGING_DIR_HOST)/bin/mold $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-ld.mold | ||
+endef | ||
+ | ||
+define Host/Clean | ||
+endef | ||
+ | ||
+$(eval $(call HostBuild)) | ||
-- | ||
2.39.3 | ||
|
71 changes: 71 additions & 0 deletions
71
openwrt/patch/openwrt-6.x/mold/0004-tools-add-mold-a-modern-linker.patch
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,71 @@ | ||
From a500032a30152630e058c3ee6afbbe787325db43 Mon Sep 17 00:00:00 2001 | ||
From: Andre Heider <[email protected]> | ||
Date: Fri, 27 Jan 2023 17:53:02 +0100 | ||
Subject: [PATCH 4/8] tools: add mold, a modern linker | ||
|
||
mold is a faster drop-in replacement for existing Unix linkers. | ||
|
||
A single binary is able to link various targets, which is why this lives | ||
in tools/. | ||
|
||
All toolchain builds then just need to copy the linker over, hence avoiding | ||
multiple builds with the same outcome. | ||
|
||
Signed-off-by: Andre Heider <[email protected]> | ||
--- | ||
tools/Makefile | 2 ++ | ||
tools/mold/Makefile | 22 ++++++++++++++++++++++ | ||
2 files changed, 24 insertions(+) | ||
create mode 100644 tools/mold/Makefile | ||
|
||
diff --git a/tools/Makefile b/tools/Makefile | ||
index 40c3ec1ab0..bf525d34a0 100644 | ||
--- a/tools/Makefile | ||
+++ b/tools/Makefile | ||
@@ -83,6 +83,7 @@ tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_TARGET_tegra),y) += cbootimage | ||
tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_USES_MINOR),y) += kernel2minor | ||
tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_USE_SPARSE),y) += sparse | ||
tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_USE_LLVM_BUILD),y) += llvm-bpf | ||
+tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_USE_MOLD),y) += mold | ||
|
||
# builddir dependencies | ||
$(curdir)/autoconf/compile := $(curdir)/m4/compile | ||
@@ -114,6 +115,7 @@ $(curdir)/meson/compile := $(curdir)/ninja/compile | ||
$(curdir)/missing-macros/compile := $(curdir)/autoconf/compile | ||
$(curdir)/mkimage/compile += $(curdir)/bison/compile $(curdir)/libressl/compile | ||
$(curdir)/mklibs/compile := $(curdir)/libtool/compile | ||
+$(curdir)/mold/compile := $(curdir)/cmake/compile $(curdir)/zlib/compile $(curdir)/zstd/compile | ||
$(curdir)/mpc/compile := $(curdir)/mpfr/compile $(curdir)/gmp/compile | ||
$(curdir)/mpfr/compile := $(curdir)/gmp/compile | ||
$(curdir)/mtd-utils/compile := $(curdir)/libtool/compile $(curdir)/e2fsprogs/compile $(curdir)/zlib/compile | ||
diff --git a/tools/mold/Makefile b/tools/mold/Makefile | ||
new file mode 100644 | ||
index 0000000000..e8fcecbfed | ||
--- /dev/null | ||
+++ b/tools/mold/Makefile | ||
@@ -0,0 +1,22 @@ | ||
+# SPDX-License-Identifier: GPL-2.0-only | ||
+ | ||
+include $(TOPDIR)/rules.mk | ||
+ | ||
+PKG_NAME:=mold | ||
+PKG_VERSION:=1.11.0 | ||
+ | ||
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz | ||
+PKG_SOURCE_URL_FILE:=v$(PKG_VERSION).tar.gz | ||
+PKG_SOURCE_URL:=https://github.com/rui314/mold/archive/refs/tags | ||
+PKG_HASH:=99318eced81b09a77e4c657011076cc8ec3d4b6867bd324b8677974545bc4d6f | ||
+ | ||
+include $(INCLUDE_DIR)/host-build.mk | ||
+include $(INCLUDE_DIR)/cmake.mk | ||
+ | ||
+CMAKE_HOST_OPTIONS += \ | ||
+ -DMOLD_LTO=ON \ | ||
+ -DMOLD_MOSTLY_STATIC=ON \ | ||
+ -DMOLD_USE_SYSTEM_MIMALLOC=OFF \ | ||
+ -DMOLD_USE_SYSTEM_TBB=OFF | ||
+ | ||
+$(eval $(call HostBuild)) | ||
-- | ||
2.39.3 | ||
|
63 changes: 63 additions & 0 deletions
63
...rt/patch/openwrt-6.x/mold/0005-build-replace-SSTRIP_ARGS-with-SSTRIP_DISCARD_TRAILI.patch
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,63 @@ | ||
From 55d51626b8a3fd48a980e5d033ecdbef071137c4 Mon Sep 17 00:00:00 2001 | ||
From: Andre Heider <[email protected]> | ||
Date: Sat, 28 Jan 2023 21:16:16 +0100 | ||
Subject: [PATCH 5/8] build: replace SSTRIP_ARGS with | ||
SSTRIP_DISCARD_TRAILING_ZEROES | ||
|
||
sstrip only has one functional arg. Make that a bool option, which can | ||
easily depend on other knobs then. | ||
|
||
This is required to be disabled for the mold linker. | ||
|
||
Signed-off-by: Andre Heider <[email protected]> | ||
--- | ||
config/Config-build.in | 10 ++++------ | ||
rules.mk | 2 +- | ||
2 files changed, 5 insertions(+), 7 deletions(-) | ||
|
||
diff --git a/config/Config-build.in b/config/Config-build.in | ||
index fe16d81d36..a96ed2f63b 100644 | ||
--- a/config/Config-build.in | ||
+++ b/config/Config-build.in | ||
@@ -190,7 +190,6 @@ menu "Global build settings" | ||
help | ||
This will install binaries stripped using strip from binutils. | ||
|
||
- | ||
config USE_SSTRIP | ||
bool "sstrip" | ||
depends on !USE_GLIBC | ||
@@ -207,13 +206,12 @@ menu "Global build settings" | ||
help | ||
Specifies arguments passed to the strip command when stripping binaries. | ||
|
||
- config SSTRIP_ARGS | ||
- string | ||
- prompt "Sstrip arguments" | ||
+ config SSTRIP_DISCARD_TRAILING_ZEROES | ||
+ bool "Strip trailing zero bytes" | ||
depends on USE_SSTRIP | ||
- default "-z" | ||
+ default y | ||
help | ||
- Specifies arguments passed to the sstrip command when stripping binaries. | ||
+ Use sstrip's -z option to discard trailing zero bytes | ||
|
||
config STRIP_KERNEL_EXPORTS | ||
bool "Strip unnecessary exports from the kernel image" | ||
diff --git a/rules.mk b/rules.mk | ||
index 58c53705a2..c768ccc9b3 100644 | ||
--- a/rules.mk | ||
+++ b/rules.mk | ||
@@ -325,7 +325,7 @@ else | ||
STRIP:=$(TARGET_CROSS)strip $(call qstrip,$(CONFIG_STRIP_ARGS)) | ||
else | ||
ifneq ($(CONFIG_USE_SSTRIP),) | ||
- STRIP:=$(STAGING_DIR_HOST)/bin/sstrip $(call qstrip,$(CONFIG_SSTRIP_ARGS)) | ||
+ STRIP:=$(STAGING_DIR_HOST)/bin/sstrip $(if $(CONFIG_SSTRIP_DISCARD_TRAILING_ZEROES),-z) | ||
endif | ||
endif | ||
RSTRIP= \ | ||
-- | ||
2.39.3 | ||
|
Oops, something went wrong.