Skip to content

Instantly share code, notes, and snippets.

@paranlee
Created May 25, 2021 13:43
Show Gist options
  • Save paranlee/8d83db088e766c0409f3d69146ebfe14 to your computer and use it in GitHub Desktop.
Save paranlee/8d83db088e766c0409f3d69146ebfe14 to your computer and use it in GitHub Desktop.
Linux kernel build for qemu runtime to source code review.
make clean
make defconfig
sed -i 's/-O2/-Og/g' Makefile
make -j $(nproc)
make -j8 cscope tags
<< 'MULTILINE-COMMENT'
~/linux$ git diff
diff --git a/Makefile b/Makefile
index 18b4cebe5564..cd61d89aebfb 100644
--- a/Makefile
+++ b/Makefile
@@ -401,10 +401,10 @@ else
HOSTCC = gcc
HOSTCXX = g++
endif
-KBUILD_HOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 \
+KBUILD_HOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes -Og \
-fomit-frame-pointer -std=gnu89 $(HOST_LFS_CFLAGS) \
$(HOSTCFLAGS)
-KBUILD_HOSTCXXFLAGS := -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
+KBUILD_HOSTCXXFLAGS := -Og $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
@@ -719,7 +719,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
-KBUILD_CFLAGS += -O2
+KBUILD_CFLAGS += -Og
else ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3
KBUILD_CFLAGS += -O3
else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
index f3040b0b4b23..2cd2681480aa 100644
--- a/include/linux/thread_info.h
+++ b/include/linux/thread_info.h
@@ -151,7 +151,7 @@ static __always_inline __must_check bool
check_copy_size(const void *addr, size_t bytes, bool is_source)
{
int sz = __compiletime_object_size(addr);
- if (unlikely(sz >= 0 && sz < bytes)) {
+ if (false && unlikely(sz >= 0 && sz < bytes)) {
if (!__builtin_constant_p(bytes))
copy_overflow(sz, bytes);
else if (is_source)
MULTILINE-COMMENT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment