User:Gso321/My kernel setup
From Gentoo Wiki
Jump to:navigation
Jump to:search
Here is my personal kernel setup:
First, emerge the Kernel, Linux-headers, and Git:
root #
emerge --ask =sys-kernel/gentoo-sources-6.3.0 =sys-kernel/linux-headers-6.3 =dev-vcs/git-2.39.2
Symlink, then cd to /usr/src/linux:
user $
cd /usr/src/linux
Finally, make:
root #
make -j9 KCFLAGS="-fipa-pta -march=native -mmovbe" HOSTCFLAGS="-fipa-pta -march=native -mmovbe"
Using -fmerge-all-constants
Warning
This patch may only work on my machine, not yours.
This patch may only work on my machine, not yours.
Important
Kernel PROBLEMS: Screen stuck at "Loading initial ramdisk"
Kernel PROBLEMS: Screen stuck at "Loading initial ramdisk"
Causes: drivers/acpi don't work with -fmerge-all-constants
.
-fmerge-all-constants
or edit ACPI itself (Gigachad move right there :)).First, git apply the patch:
diff --git a/Makefile b/Makefile
index 84447b0..8e1ac0f 100644
--- a/Makefile
+++ b/Makefile
@@ -749,6 +749,10 @@ endif # KBUILD_EXTMOD
# Defaults to vmlinux, but the arch makefile usually adds further targets
all: vmlinux
+ifdef CONFIG_MERGE_ALL_CONSTANTS
+KBUILD_CFLAGS += -fmerge-all-constants
+endif
+
CFLAGS_GCOV := -fprofile-arcs -ftest-coverage
ifdef CONFIG_CC_IS_GCC
CFLAGS_GCOV += -fno-tree-loop-im
diff --git a/arch/Kconfig b/arch/Kconfig
index e3511af..a821b1d 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -37,6 +37,14 @@ config HOTPLUG_SMT
config GENERIC_ENTRY
bool
+config MERGE_ALL_CONSTANTS
+ bool "Set -fmerge-all-constants"
+ depends on $(cc-option,-fmerge-all-constants)
+ help
+ Add -fmerge-all-constants to kernel, a more aggressive optimization
+ than -fmerge-constants. Because so many C code assumes identical
+ variables to be in different locations, this is disabled by default.
+
config KPROBES
bool "Kprobes"
depends on MODULES
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index feb36c0..2ea26d0 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -3,6 +3,8 @@
# Makefile for the Linux ACPI interpreter
#
+subdir-ccflags-$(CONFIG_MERGE_ALL_CONSTANTS) += -fno-merge-all-constants
+
ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT
#
root #
git apply merge-a-const.patch
Then enable CONFIG_MERGE_ALL_CONSTANTS:
General architecture-dependent options --->
[*] Set -fmerge-all-constants