Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to cross-compile very old kernel?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
M95D
n00b
n00b


Joined: 03 Jan 2020
Posts: 52

PostPosted: Thu Dec 01, 2022 3:20 pm    Post subject: How to cross-compile very old kernel? Reply with quote

Hi.

I need to cross-compile a series of very old kernels (starting around v3.0), for arm. I need them to debug a driver issue that may have worked in the past but is now broken.

I tried to use OpenWrt to build a toolchain with gcc-4 from a long time ago but that didn't work. It failed to build the cross-gcc-4.8 using Gentoo's current gcc.
I tried using an already built OpenWrt SDK from Chaos Calmer release, but even that didn't work.
Code:

export TOOLCHAIN_DIR=/build/toolchain-arm_cortex-a9+vfpv3_gcc-4.8-linaro_uClibc-0.9.33.2_eabi
export STAGING_DIR=$TOOLCHAIN_DIR
export PATH=$TOOLCHAIN_DIR/bin:$PATH
export ARCH=arm
export CROSS_COMPILE=arm-openwrt-linux-uclibcgnueabi-
make menuconfig
make V=s
...
/usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x50): multiple definition of `yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [scripts/Makefile.host:127: scripts/dtc/dtc] Error 1
make[1]: *** [scripts/Makefile.build:465: scripts/dtc] Error 2
make: *** [Makefile:542: scripts] Error 2


1) Can I use crossdev to generate a functional toolchain that can build very old kernel versions?
How do I use that toolchain? As you can see above, with OpenWrt toolchain, the kernel still uses Gentoo's ld, and it fails.

2) Are there any abandonware linux projects that can help me build very old kernel versions?

Thanks.
Back to top
View user's profile Send private message
pingtoo
l33t
l33t


Joined: 10 Sep 2021
Posts: 926
Location: Richmond Hill, Canada

PostPosted: Thu Dec 01, 2022 5:05 pm    Post subject: Reply with quote

May be this https://github.com/BPI-SINOVOIP/BPI-M4-bsp/issues/4 will help you solve the dtc compile issue.

Or you can look into a patch file package/boot/uboot-zynq/patches/010-fix_dtc_compilation_on_host_gcc10.patch in your openwrt source code tree. It does explain the error and provide a solution.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54237
Location: 56N 3W

PostPosted: Thu Dec 01, 2022 5:26 pm    Post subject: Reply with quote

M95D,

Try adding -fcommon to the CFLAGS and CXXFLAGS used to build the kernel. That's not make.conf.
gcc-11 made -fno-common the default, so
Code:
/usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x50): multiple definition of `yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here
became an error.

It always should have been an error but before gcc-11, it wasn't flagged.

The kernel Makefile says

Code:
# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments
KBUILD_CPPFLAGS += $(KCPPFLAGS)
KBUILD_AFLAGS   += $(KAFLAGS)
KBUILD_CFLAGS   += $(KCFLAGS)


It looks like you may need something like
Code:
KCPPFLAGS="-fcommon" KCFLAGS="-fcommon" make V=s

to get the old behaviour.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
M95D
n00b
n00b


Joined: 03 Jan 2020
Posts: 52

PostPosted: Fri Dec 02, 2022 8:40 am    Post subject: Reply with quote

Adding flags didn't fix it.
Patching dtc-lexer-lex.c works.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21633

PostPosted: Fri Dec 02, 2022 4:27 pm    Post subject: Reply with quote

How did you add the flags, and did the build system actually pass them to the relevant invocation of the compiler?
Back to top
View user's profile Send private message
M95D
n00b
n00b


Joined: 03 Jan 2020
Posts: 52

PostPosted: Fri Dec 02, 2022 4:49 pm    Post subject: Reply with quote

Code:
/build/linux $ cat ../cross-build.sh
#!/bin/sh

export TOOLCHAIN_DIR=/build/openwrt.a/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-12.2.0_musl_eabi
#export TOOLCHAIN_DIR=/build/toolchain-arm_cortex-a9+vfpv3_gcc-4.8-linaro_uClibc-0.9.33.2_eabi
export STAGING_DIR=$TOOLCHAIN_DIR
export PATH=$TOOLCHAIN_DIR/bin:$PATH
export ARCH=arm
export CROSS_COMPILE=arm-openwrt-linux-
export KCPPFLAGS="-fcommon"
export KCFLAGS="-fcommon"
# printenv|sort
$*
/build/linux $ ../cross-build.sh make -j1 V=s
...

printenv, if uncommented, shows that variables are set.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum