ememos / GiantVM

9 stars 9 forks source link

Build error: compile with latest gcc version #25

Open ChoKyuWon opened 3 years ago

ChoKyuWon commented 3 years ago

With gcc-9 and gcc-10, kernel is not able to build. Major error is like this:

  1. error: ‘-mindirect-branch’ and ‘-fcf-protection’ are not compatible
  2. warning: objtool: $(CODE_LOCATION): sibling call from callable instruction with modified stack frame

First error can suppress by this patch:

diff --git a/Linux-DSM-4.18/Makefile b/Linux-DSM-4.18/Makefile
index 15be63c27..a38d2ce4b 100644
--- a/Linux-DSM-4.18/Makefile
+++ b/Linux-DSM-4.18/Makefile
@@ -492,8 +492,8 @@ KBUILD_CFLAGS += $(call cc-option, -no-integrated-as)
 KBUILD_AFLAGS += $(call cc-option, -no-integrated-as)
 endif

-RETPOLINE_CFLAGS_GCC := -mindirect-branch=thunk-extern -mindirect-branch-register
-RETPOLINE_VDSO_CFLAGS_GCC := -mindirect-branch=thunk-inline -mindirect-branch-register
+RETPOLINE_CFLAGS_GCC := -mindirect-branch=thunk-extern -mindirect-branch-register -fcf-protection=none
+RETPOLINE_VDSO_CFLAGS_GCC := -mindirect-branch=thunk-extern -mindirect-branch-register -fcf-protection=none
 RETPOLINE_CFLAGS_CLANG := -mretpoline-external-thunk
 RETPOLINE_VDSO_CFLAGS_CLANG := -mretpoline
 RETPOLINE_CFLAGS := $(call cc-option,$(RETPOLINE_CFLAGS_GCC),$(call cc-option,$(RETPOLINE_CFLAGS_CLANG)))

However, the second warning can't be suppressed by this one. vmlinux and bzImage is come out normally, but I didn't test it so I'm not sure it works properly.


References

  1. First error patch
  2. Second warning patch?