我在重新編譯核心時遇到問題。下載源碼包,解壓縮並運行
fakeroot make-kpkg kernel_image
導致我犯了錯誤
[...]
CHK include/generated/utsrelease.h
UPD include/generated/utsrelease.h
CHK include/generated/package.h
UPD include/generated/package.h
CC kernel/bounds.s
kernel/bounds.c:1:0: error: code model kernel does not support PIC mode
該問題可以透過更改使用 獲得的核心配置來解決make menuconfig
。
如何擺脫這個錯誤並成功編譯
答案1
您可以嘗試以下補丁:
diff --git a/Makefile b/Makefile
index 5c18baa..e342473 100644
--- a/Makefile
+++ b/Makefile
@@ -612,6 +612,12 @@ endif # $(dot-config)
# Defaults to vmlinux, but the arch makefile usually adds further targets
all: vmlinux
+# force no-pie for distro compilers that enable pie by default
+KBUILD_CFLAGS += $(call cc-option, -fno-pie)
+KBUILD_CFLAGS += $(call cc-option, -no-pie)
+KBUILD_AFLAGS += $(call cc-option, -fno-pie)
+KBUILD_CPPFLAGS += $(call cc-option, -fno-pie)
+
# The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default
# values of the respective KBUILD_* variables
ARCH_CPPFLAGS :=
一些相關的 Debian 票證:
- https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=835148
- https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=841420
以及相關的海灣合作委員會報告: