dolohow / uksm

Ultra Kernel Samepage Merging
242 stars 35 forks source link

patch 5.14 cannot compile with gcc 10.3 #72

Closed qifly closed 2 years ago

qifly commented 2 years ago
uu@gentoo /usr/src/linux-5.14.8-xanmod $ doas make -j16
  DESCEND objtool
  CALL    scripts/atomic/check-atomics.sh
  CC      arch/x86/kernel/asm-offsets.s
In file included from ./include/linux/mm.h:33,
                 from ./include/linux/kallsyms.h:13,
                 from ./include/linux/bpf.h:20,
                 from ./include/linux/bpf-cgroup.h:5,
                 from ./include/linux/cgroup-defs.h:22,
                 from ./include/linux/cgroup.h:28,
                 from ./include/linux/memcontrol.h:13,
                 from ./include/linux/swap.h:9,
                 from ./include/linux/suspend.h:5,
                 from arch/x86/kernel/asm-offsets.c:13:
./include/linux/pgtable.h: 在函数‘is_uksm_zero_pfn’中:
./include/linux/pgtable.h:1155:23: 错误:不能为局部变量指定节属性
 1155 |  extern unsigned long uksm_zero_pfn __read_mostly;
      |                       ^~~~~~~~~~~~~
./include/linux/pgtable.h: 在函数‘is_zero_pfn’中:
./include/linux/pgtable.h:1184:23: 错误:不能为局部变量指定节属性
 1184 |  extern unsigned long zero_pfn __read_mostly;
      |                       ^~~~~~~~
make[1]: *** [scripts/Makefile.build:117:arch/x86/kernel/asm-offsets.s] 错误 1
make: *** [Makefile:1220:prepare0] 错误 2
uu@gentoo /usr/src/linux-5.14.8-xanmod $ gcc -v
使用内建 specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/10.3.0/lto-wrapper
目标:x86_64-pc-linux-gnu
配置为:/var/tmp/portage/sys-devel/gcc-10.3.0-r2/work/gcc-10.3.0/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/10.3.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/10.3.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/10.3.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/10.3.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/include/g++-v10 --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/10.3.0/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --disable-libunwind-exceptions --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 10.3.0-r2 p3' --disable-esp --enable-libstdcxx-time --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64 --disable-fixed-point --enable-targets=all --enable-libgomp --disable-libssp --disable-libada --disable-systemtap --disable-vtable-verify --disable-libvtv --with-zstd --enable-lto --without-isl --enable-default-pie --enable-default-ssp
线程模型:posix
Supported LTO compression algorithms: zlib zstd
gcc 版本 10.3.0 (Gentoo 10.3.0-r2 p3) 
MoisesMH commented 2 years ago

Hey there, I've got the same error too, a fix please :'(

In file included from ./include/linux/mm.h:33, from ./include/linux/kallsyms.h:13, from ./include/linux/bpf.h:20, from ./include/linux/bpf-cgroup.h:5, from ./include/linux/cgroup-defs.h:22, from ./include/linux/cgroup.h:28, from ./include/linux/memcontrol.h:13, from ./include/linux/swap.h:9, from ./include/linux/suspend.h:5, from arch/x86/kernel/asm-offsets.c:13: ./include/linux/pgtable.h: In function ‘is_uksm_zero_pfn’: ./include/linux/pgtable.h:1155:30: error: section attribute cannot be specified for local variables 1155 | extern unsigned long uksm_zero_pfn read_mostly; | ^~~~~ ./include/linux/pgtable.h: In function ‘is_zero_pfn’: ./include/linux/pgtable.h:1184:30: error: section attribute cannot be specified for local variables 1184 | extern unsigned long zero_pfn read_mostly; | ^~~~ make[1]: [scripts/Makefile.build:117: arch/x86/kernel/asm-offsets.s] Error 1 make: [Makefile:1220: prepare0] Error 2 make: *** Waiting for unfinished jobs....

Is __read_mostly kind of responsible for the problem? I've used gcc 11.1.0 for compilation

mixere4 commented 2 years ago
uu@gentoo /usr/src/linux-5.14.8-xanmod $ doas make -j16
  DESCEND objtool
  CALL    scripts/atomic/check-atomics.sh
  CC      arch/x86/kernel/asm-offsets.s
In file included from ./include/linux/mm.h:33,
                 from ./include/linux/kallsyms.h:13,
                 from ./include/linux/bpf.h:20,
                 from ./include/linux/bpf-cgroup.h:5,
                 from ./include/linux/cgroup-defs.h:22,
                 from ./include/linux/cgroup.h:28,
                 from ./include/linux/memcontrol.h:13,
                 from ./include/linux/swap.h:9,
                 from ./include/linux/suspend.h:5,
                 from arch/x86/kernel/asm-offsets.c:13:
./include/linux/pgtable.h: 在函数‘is_uksm_zero_pfn’中:
./include/linux/pgtable.h:1155:23: 错误:不能为局部变量指定节属性
 1155 |  extern unsigned long uksm_zero_pfn __read_mostly;
      |                       ^~~~~~~~~~~~~
./include/linux/pgtable.h: 在函数‘is_zero_pfn’中:
./include/linux/pgtable.h:1184:23: 错误:不能为局部变量指定节属性
 1184 |  extern unsigned long zero_pfn __read_mostly;
      |                       ^~~~~~~~
make[1]: *** [scripts/Makefile.build:117:arch/x86/kernel/asm-offsets.s] 错误 1
make: *** [Makefile:1220:prepare0] 错误 2
uu@gentoo /usr/src/linux-5.14.8-xanmod $ gcc -v
使用内建 specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/10.3.0/lto-wrapper
目标:x86_64-pc-linux-gnu
配置为:/var/tmp/portage/sys-devel/gcc-10.3.0-r2/work/gcc-10.3.0/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/10.3.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/10.3.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/10.3.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/10.3.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/include/g++-v10 --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/10.3.0/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --disable-libunwind-exceptions --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 10.3.0-r2 p3' --disable-esp --enable-libstdcxx-time --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64 --disable-fixed-point --enable-targets=all --enable-libgomp --disable-libssp --disable-libada --disable-systemtap --disable-vtable-verify --disable-libvtv --with-zstd --enable-lto --without-isl --enable-default-pie --enable-default-ssp
线程模型:posix
Supported LTO compression algorithms: zlib zstd
gcc 版本 10.3.0 (Gentoo 10.3.0-r2 p3) 

I found only one solution at the moment - use previous version. Excuse my english,

MoisesMH commented 2 years ago

Haha I though about that too. I've used previous commit fce5aa1 with the description "Resync for linux-5.14.y" and everything compiles right.

Just in case, in console:

cd ~/Downloads wget -c https://raw.githubusercontent.com/dolohow/uksm/fce5aa1e75fa8b35da45f94a813c03c9cf203a21/v5.x/uksm-5.14.patch

That's the only solution for now I guess.

tpgxyz commented 2 years ago

Yes i can confirm that latest patch does not compile with gcc >=10

dolohow commented 2 years ago

Yeah, looks like patch for fixing clang warnings is not working with gcc >=10. I was testing compilation on older version (9.3.0)

Reverted in d287282.