<br><br>On Sunday, March 28, 2021, Fawad Lateef <<a href="mailto:fawadlateef@gmail.com">fawadlateef@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi<br>
<br>
I am using an Olimex A20 SOM with NAND and due to some binary blob for<br>
NAND driver, I am stuck with the sunxi kernel 3.4.xxx version. (Repo<br>
here: <a href="https://github.com/linux-sunxi/linux-sunxi" target="_blank">https://github.com/linux-<wbr>sunxi/linux-sunxi</a>)<br>
<br>
I am currently using buildroot-2016 and gcc-5.5 for building the<br>
kernel and every other package needed.<br>
<br>
Now the requirement is to move to the latest version of gcc-9.x, so<br>
that we can have glibc++ provided by the gcc-9.1 toolchain.<br>
<br>
Main problem for moving to later versions of buildroot is the kernel<br>
3.4 which we couldn't to work with gcc-6 a few years ago _but_ now the<br>
gcc-9.1 requirement is mandatory so now have to look into compiling<br>
linux-3.4 with gcc-9.1 or above.<br>
<br>
Now I need some help.<br>
<br>
-- Is it realistic to expect 3.4 kernel compiling and boot<br>
successfully with gcc-9.1?</blockquote><div><br></div><div>Pretty much, but i’m not sure the patches will be acceptable by upstream / stable.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-- Secondly, till now I am able to compile until the point when its<br>
going to generate the vmlinuz image, it failed with error at LD stage:<br>
                  arm-none-linux-gnueabihf-ld: no machine record defined<br>
<br>
Last few lines from compile log:<br>
<br>
------------------------------<wbr>------------------------------<wbr>-------------------<br>
include/linux/init.h:267:24: note: in expansion of macro ‘__initcall’<br>
  267 | #define module_init(x) __initcall(x);<br>
      |                        ^~~~~~~~~~<br>
net/sunrpc/auth_gss/auth_gss.<wbr>c:1721:1: note: in expansion of macro ‘module_init’<br>
 1721 | module_init(init_rpcsec_gss)<br>
      | ^~~~~~~~~~~<br>
In file included from include/linux/kernel.h:20,<br>
                 from include/linux/spinlock.h:55,<br>
                 from include/linux/mmzone.h:7,<br>
                 from include/linux/gfp.h:4,<br>
                 from include/linux/slab.h:12,<br>
                 from net/sunrpc/auth_gss/svcauth_<wbr>gss.c:40:<br>
include/linux/log2.h:22:1: warning: ignoring attribute ‘noreturn’<br>
because it conflicts with attribute ‘const’ [-Wattributes]<br>
   22 | int ____ilog2_NaN(void);<br>
      | ^~~<br>
  LD      net/sunrpc/auth_gss/auth_<wbr>rpcgss.o<br>
  LD      net/sunrpc/auth_gss/built-in.o<br>
  LD      net/sunrpc/built-in.o<br>
  LD      net/built-in.o<br>
  LD      vmlinux.o<br>
  MODPOST vmlinux.o<br>
  GEN     .version<br>
  CHK     include/generated/compile.h<br>
  UPD     include/generated/compile.h<br>
  CC      init/version.o<br>
In file included from include/linux/kernel.h:20,<br>
                 from include/linux/cache.h:4,<br>
                 from include/linux/time.h:7,<br>
                 from include/linux/stat.h:60,<br>
                 from include/linux/module.h:10,<br>
                 from init/version.c:10:<br>
include/linux/log2.h:22:1: warning: ignoring attribute ‘noreturn’<br>
because it conflicts with attribute ‘const’ [-Wattributes]<br>
   22 | int ____ilog2_NaN(void);<br>
      | ^~~<br>
  LD      init/built-in.o<br>
  LD      .tmp_vmlinux1<br>
arm-none-linux-gnueabihf-ld: no machine record defined<br>
Makefile:875: recipe for target '.tmp_vmlinux1' failed<br>
make: *** [.tmp_vmlinux1] Error 1<br>
------------------------------<wbr>------------------------------<wbr>-------------------<br>
<br>
<br>
After some investigation I found that the MACHINE_START macro from<br>
arch/arm/include/asm/mach/<wbr>arch.h  is optimised by compiler and removed<br>
from the object file during compilation of<br>
"arch/arm/plat-sunxi/core.c" due to the error here:<br>
<br>
------------------------------<wbr>------------------------------<wbr>---<br>
<br>
flateef@flateef-XPS-13-9360:~/<wbr>src/tmp/linux-custom-venus-gc-<wbr>9.2$ make<br>
ARCH=arm CROSS_COMPILE=arm-none-linux-<wbr>gnueabihf- EXTRAVERSION=-custom1<br>
uImage LOADADDR="0x40008000" -j4<br>
  CHK     include/linux/version.h<br>
  CHK     include/generated/utsrelease.h<br>
make[1]: 'include/generated/mach-types.<wbr>h' is up to date.<br>
  CALL    scripts/checksyscalls.sh<br>
  CHK     include/generated/compile.h<br>
  CC      arch/arm/plat-sunxi/core.o<br>
In file included from include/linux/kernel.h:20,<br>
                 from arch/arm/plat-sunxi/core.c:20:<br>
include/linux/log2.h:22:1: warning: ignoring attribute ‘noreturn’<br>
because it conflicts with attribute ‘const’ [-Wattributes]<br>
   22 | int ____ilog2_NaN(void);<br>
      | ^~~<br>
In file included from include/linux/scatterlist.h:<wbr>10,<br>
                 from include/linux/dma-mapping.h:9,<br>
                 from arch/arm/plat-sunxi/core.c:24:<br>
arch/arm/plat-sunxi/core.c: In function ‘sw_irq_unmask’:<br>
arch/arm/plat-sunxi/core.c:<wbr>287:14: warning: left shift count >= width<br>
of type [-Wshift-count-overflow]<br>
  287 |    writel((1 << SW_INT_IRQNO_ENMI), SW_INT_IRQ_PENDING_REG0);<br>
      |              ^~<br>
/home/flateef/src/tmp/linux-<wbr>custom-venus-gc-9.2/arch/arm/<wbr>include/asm/io.h:52:88:<br>
note: in definition of macro ‘__raw_writel’<br>
   52 | #define __raw_writel(v,a) (__chk_io_ptr(a), *(volatile<br>
unsigned int __force   *)(a) = (v))<br>
      |<br>
                        ^<br>
include/linux/byteorder/<wbr>generic.h:87:21: note: in expansion of macro<br>
‘__cpu_to_le32’<br>
   87 | #define cpu_to_le32 __cpu_to_le32<br>
      |                     ^~~~~~~~~~~~~<br>
/home/flateef/src/tmp/linux-<wbr>custom-venus-gc-9.2/arch/arm/<wbr>include/asm/io.h:244:36:<br>
note: in expansion of macro ‘writel_relaxed’<br>
  244 | #define writel(v,c)  ({ __iowmb(); writel_relaxed(v,c); })<br>
      |                                    ^~~~~~~~~~~~~~<br>
arch/arm/plat-sunxi/core.c:<wbr>287:4: note: in expansion of macro ‘writel’<br>
  287 |    writel((1 << SW_INT_IRQNO_ENMI), SW_INT_IRQ_PENDING_REG0);<br>
      |    ^~~~~~<br>
In file included from arch/arm/plat-sunxi/core.c:53:<br>
At top level:<br>
/home/flateef/src/tmp/linux-<wbr>custom-venus-gc-9.2/arch/arm/<wbr>include/asm/mach/arch.h:69:34:<br>
warning: ‘__mach_desc_SUN7I’ defined but not used<br>
[-Wunused-const-variable=]<br>
   69 | static const struct machine_desc __mach_desc_##_type  \<br>
      |                                  ^~~~~~~~~~~~<br>
arch/arm/plat-sunxi/core.c:<wbr>424:1: note: in expansion of macro ‘MACHINE_START’<br>
  424 | MACHINE_START(SUN7I, "sun7i")<br>
      | ^~~~~~~~~~~~~<br>
/home/flateef/src/tmp/linux-<wbr>custom-venus-gc-9.2/arch/arm/<wbr>include/asm/mach/arch.h:69:34:<br>
warning: ‘__mach_desc_SUN5I’ defined but not used<br>
[-Wunused-const-variable=]<br>
   69 | static const struct machine_desc __mach_desc_##_type  \<br>
      |                                  ^~~~~~~~~~~~<br>
arch/arm/plat-sunxi/core.c:<wbr>410:1: note: in expansion of macro ‘MACHINE_START’<br>
  410 | MACHINE_START(SUN5I, "sun5i")<br>
      | ^~~~~~~~~~~~~<br>
/home/flateef/src/tmp/linux-<wbr>custom-venus-gc-9.2/arch/arm/<wbr>include/asm/mach/arch.h:69:34:<br>
warning: ‘__mach_desc_SUN4I’ defined but not used<br>
[-Wunused-const-variable=]<br>
   69 | static const struct machine_desc __mach_desc_##_type  \<br>
      |                                  ^~~~~~~~~~~~<br>
arch/arm/plat-sunxi/core.c:<wbr>396:1: note: in expansion of macro ‘MACHINE_START’<br>
  396 | MACHINE_START(SUN4I, "sun4i")<br>
      | ^~~~~~~~~~~~~<br>
  LD      arch/arm/plat-sunxi/built-in.o<br>
  LD      vmlinux.o<br>
  MODPOST vmlinux.o<br>
  GEN     .version<br>
  CHK     include/generated/compile.h<br>
  UPD     include/generated/compile.h<br>
  CC      init/version.o<br>
In file included from include/linux/kernel.h:20,<br>
                 from include/linux/cache.h:4,<br>
                 from include/linux/time.h:7,<br>
                 from include/linux/stat.h:60,<br>
                 from include/linux/module.h:10,<br>
                 from init/version.c:10:<br>
include/linux/log2.h:22:1: warning: ignoring attribute ‘noreturn’<br>
because it conflicts with attribute ‘const’ [-Wattributes]<br>
   22 | int ____ilog2_NaN(void);<br>
      | ^~~<br>
  LD      init/built-in.o<br>
  LD      .tmp_vmlinux1<br>
arm-none-linux-gnueabihf-ld: no machine record defined<br>
Makefile:875: recipe for target '.tmp_vmlinux1' failed<br>
make: *** [.tmp_vmlinux1] Error 1<br>
<br>
------------------------------<wbr>------------------------------<wbr>---<br>
<br>
I modified the MACHINE_START macro in arch/arm/include/asm/mach/<wbr>arch.h<br>
and added "__attribute__((used))" so it became:<br>
<br>
            static const struct machine_desc __mach_desc_##_type<br>
__attribute__((used))    \<br>
<br>
And I managed to get the vmlinux image.<br>
<br>
------------------------------<wbr>------------------------------<wbr>-<br>
<br>
<br>
arch/arm/mm/mmu.c:919:1: note: in expansion of macro ‘early_param’<br>
  919 | early_param("vmalloc", early_vmalloc);<br>
      | ^~~~~~~~~~~<br>
include/linux/init.h:241:33: warning: ‘__setup_noalign_setup’ defined<br>
but not used [-Wunused-variable]<br>
  241 |  static struct obs_kernel_param __setup_##unique_id \<br>
      |                                 ^~~~~~~~<br>
include/linux/init.h:247:2: note: in expansion of macro ‘__setup_param’<br>
  247 |  __setup_param(str, fn, fn, 0)<br>
      |  ^~~~~~~~~~~~~<br>
arch/arm/mm/mmu.c:175:1: note: in expansion of macro ‘__setup’<br>
  175 | __setup("noalign", noalign_setup);<br>
      | ^~~~~~~<br>
include/linux/init.h:241:33: warning: ‘__setup_early_ecc’ defined but<br>
not used [-Wunused-variable]<br>
  241 |  static struct obs_kernel_param __setup_##unique_id \<br>
      |                                 ^~~~~~~~<br>
include/linux/init.h:252:2: note: in expansion of macro ‘__setup_param’<br>
  252 |  __setup_param(str, fn, fn, 1)<br>
      |  ^~~~~~~~~~~~~<br>
arch/arm/mm/mmu.c:165:1: note: in expansion of macro ‘early_param’<br>
  165 | early_param("ecc", early_ecc);<br>
      | ^~~~~~~~~~~<br>
include/linux/init.h:241:33: warning: ‘__setup_early_nowrite’ defined<br>
but not used [-Wunused-variable]<br>
  241 |  static struct obs_kernel_param __setup_##unique_id \<br>
      |                                 ^~~~~~~~<br>
include/linux/init.h:252:2: note: in expansion of macro ‘__setup_param’<br>
  252 |  __setup_param(str, fn, fn, 1)<br>
      |  ^~~~~~~~~~~~~<br>
arch/arm/mm/mmu.c:154:1: note: in expansion of macro ‘early_param’<br>
  154 | early_param("nowb", early_nowrite);<br>
      | ^~~~~~~~~~~<br>
include/linux/init.h:241:33: warning: ‘__setup_early_nocache’ defined<br>
but not used [-Wunused-variable]<br>
  241 |  static struct obs_kernel_param __setup_##unique_id \<br>
      |                                 ^~~~~~~~<br>
include/linux/init.h:252:2: note: in expansion of macro ‘__setup_param’<br>
  252 |  __setup_param(str, fn, fn, 1)<br>
      |  ^~~~~~~~~~~~~<br>
arch/arm/mm/mmu.c:145:1: note: in expansion of macro ‘early_param’<br>
  145 | early_param("nocache", early_nocache);<br>
      | ^~~~~~~~~~~<br>
include/linux/init.h:241:33: warning: ‘__setup_early_cachepolicy’<br>
defined but not used [-Wunused-variable]<br>
  241 |  static struct obs_kernel_param __setup_##unique_id \<br>
      |                                 ^~~~~~~~<br>
include/linux/init.h:252:2: note: in expansion of macro ‘__setup_param’<br>
  252 |  __setup_param(str, fn, fn, 1)<br>
      |  ^~~~~~~~~~~~~<br>
arch/arm/mm/mmu.c:136:1: note: in expansion of macro ‘early_param’<br>
  136 | early_param("cachepolicy", early_cachepolicy);<br>
      | ^~~~~~~~~~~<br>
  AS      arch/arm/kernel/head.o<br>
  LD      arch/arm/kernel/built-in.o<br>
  AS      arch/arm/mm/cache-v7.o<br>
  AS      arch/arm/mm/tlb-v7.o<br>
  AS      arch/arm/mm/proc-v7.o<br>
  LD      arch/arm/mm/built-in.o<br>
  AS      arch/arm/lib/copy_page.o<br>
  AS      arch/arm/lib/<wbr>csumpartialcopyuser.o<br>
  AR      arch/arm/lib/lib.a<br>
  LD      vmlinux.o<br>
  MODPOST vmlinux.o<br>
  GEN     .version<br>
  CHK     include/generated/compile.h<br>
  UPD     include/generated/compile.h<br>
  CC      init/version.o<br>
In file included from include/linux/kernel.h:20,<br>
                 from include/linux/cache.h:4,<br>
                 from include/linux/time.h:7,<br>
                 from include/linux/stat.h:60,<br>
                 from include/linux/module.h:10,<br>
                 from init/version.c:10:<br>
include/linux/log2.h:22:1: warning: ignoring attribute ‘noreturn’<br>
because it conflicts with attribute ‘const’ [-Wattributes]<br>
   22 | int ____ilog2_NaN(void);<br>
      | ^~~<br>
  LD      init/built-in.o<br>
  LD      .tmp_vmlinux1<br>
  KSYM    .tmp_kallsyms1.S<br>
  AS      .tmp_kallsyms1.o<br>
  LD      .tmp_vmlinux2<br>
  KSYM    .tmp_kallsyms2.S<br>
  AS      .tmp_kallsyms2.o<br>
  LD      vmlinux<br>
  SYSMAP  System.map<br>
  SYSMAP  .tmp_System.map<br>
  OBJCOPY arch/arm/boot/Image<br>
  Kernel: arch/arm/boot/Image is ready<br>
  AS      arch/arm/boot/compressed/head.<wbr>o<br>
  XZKERN  arch/arm/boot/compressed/<wbr>piggy.xzkern<br>
  CC      arch/arm/boot/compressed/misc.<wbr>o<br>
  CC      arch/arm/boot/compressed/<wbr>decompress.o<br>
  CC      arch/arm/boot/compressed/<wbr>string.o<br>
In file included from include/linux/kernel.h:20,<br>
                 from<br>
arch/arm/boot/compressed/../..<wbr>/../../lib/xz/xz_private.h:15,<br>
                 from<br>
arch/arm/boot/compressed/../..<wbr>/../../lib/decompress_unxz.c:<wbr>145,<br>
                 from arch/arm/boot/compressed/<wbr>decompress.c:50:<br>
include/linux/log2.h:22:1: warning: ignoring attribute ‘noreturn’<br>
because it conflicts with attribute ‘const’ [-Wattributes]<br>
   22 | int ____ilog2_NaN(void);<br>
      | ^~~<br>
  SHIPPED arch/arm/boot/compressed/<wbr>lib1funcs.S<br>
  SHIPPED arch/arm/boot/compressed/<wbr>ashldi3.S<br>
  AS      arch/arm/boot/compressed/<wbr>lib1funcs.o<br>
  AS      arch/arm/boot/compressed/<wbr>ashldi3.o<br>
  AS      arch/arm/boot/compressed/<wbr>piggy.xzkern.o<br>
  LD      arch/arm/boot/compressed/<wbr>vmlinux<br>
  OBJCOPY arch/arm/boot/zImage<br>
  Kernel: arch/arm/boot/zImage is ready<br>
  UIMAGE  arch/arm/boot/uImage<br>
Image Name:   Linux-3.4.113-custom1<br>
Created:      Sun Mar 28 20:27:03 2021<br>
Image Type:   ARM Linux Kernel Image (uncompressed)<br>
Data Size:    1869496 Bytes = 1825.68 KiB = 1.78 MiB<br>
Load Address: 40008000<br>
Entry Point:  40008000<br>
  Image arch/arm/boot/uImage is ready<br>
<br>
<br>
------------------------------<wbr>------------------------------<wbr>-----------------<br>
<br>
<br>
-- I still can't boot the kernel on the platform. I believe its<br>
because there were lots of warning like above (unused const variables<br>
etc) and might have removed some other code/functions OR macros?<br>
<br>
So please suggest what I can do for compiling working kernel-3.4 with gcc-9.</blockquote><div><br></div><div>Is it possible to switch to new kernel, like v4.4 or even newer?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thanks in advance,<br>
<br>
-- Fawad Lateef<br>
</blockquote><br><br>-- <br>With Best Regards,<br>Andy Shevchenko<br><br><br>