bootlin / toolchains-builder

http://toolchains.free-electrons.com
94 stars 26 forks source link

Please support older kernels #52

Closed wdlkmpx closed 2 years ago

wdlkmpx commented 2 years ago

Testing x86-i686--glibc--stable-2021.11-1.tar.bz2

I get this error on debian stretch

# ./lzip-1.13-linux-i686gnu
FATAL: kernel too old
Aborted

currently using kernel 4.1...

# uname -a
Linux xxpc14850 4.1.48 #1 SMP Thu Dec 21 17:45:19 EST 2017 i686 GNU/Linux
# 
# file lzip-1.13-linux-i686gnu
lzip-1.13-linux-i686gnu: ELF 32-bit LSB executable, Intel 80386
   version 1 (GNU/Linux), statically linked, for GNU/Linux 4.9.0, stripped

Perhaps adding something like

https://unix.stackexchange.com/questions/9705/can-new-glibc-versions-be-used-with-an-old-kernel

wdlkmpx commented 2 years ago

I managed to fix this locally by discarding the xxx-buildroot-linux-gnu/sysroot directory

I compiled glibc 2.36, it automatically decided that kernel 3.2.0 is the minimum linux version supported, so you guys should remove --enable-kernel=... from the glibc configure params

These are the params I used to compile glibc for the cross compiler, the only problem here is it takes so long to compile glibc in an old 2008 laptop, so it really should be fixed by default

compile_glibc() # assuming we're inside da toolchain sysroot
{
    #glibc_url=https://ftp.gnu.org/gnu/glibc/glibc-2.36.tar.xz
    if [ -f "lib/libc.a" ] ; then
        return 0
    fi
    PKG_URL=${glibc_url}
    PKG_FILE=${PKG_URL##*/}    # basename
    PKG_DIR=${PKG_FILE%.tar.*} # remove trailing .tar.*
    # --
    retrieve ${PKG_URL}
    extract_pkg_and_cd
    #--
    src_dir=$(pwd)
    build_dir=${src_dir}-build
    mkdir -p ${build_dir}
    cd ${build_dir}
    #--
    GPREFIX=${XPATH}/${TARGET_TRIPLET}
    # discarded
    #  --enable-kernel=4.4 --enable-stack-protector=strong
    #  --enable-systemtap ## error: systemtap support needs sys/sdt.h with asm support
    #  --enable-cet
    #  --disable-shared     # <command-line>: fatal error: .../glibc-2.36-build/libc-modules.h: No such file or directory
    #  --enable-static-nss  # nss_module.c:153:7: error: 'is_nscd' undeclared (first use in this function)
    CFLAGS="-I${GPREFIX}/include" CXXFLAGS="-I${GPREFIX}/include" \
    ${src_dir}/configure \
        --disable-build-nscd \
        --host=${TARGET_TRIPLET} \
        --build=$(gcc -dumpmachine) \
        --disable-timezone-tools \
        --prefix=${GPREFIX} \
        --with-headers=${GPREFIX}/inlcude \
        --enable-bind-now \
        --disable-multi-arch \
        --disable-profile \
        --disable-crypt \
        --disable-werror \
        --libdir=${GPREFIX}/lib \
        --libexecdir=${GPREFIX}/lib || exit 1
    make install || exit 1
    rm -rf ${src_dir} ${build_dir}
}
tpetazzoni commented 2 years ago

I'm not sure why this issue got closed, it seems like a very good thing to fix in our toolchains, IMO.

wdlkmpx commented 2 years ago

Yeah it should be fixed, just find and remove --enable-kernel=... from the glibc configure params

II've been testing these toolchains in older distros:

Both work fine on

So the cross compilers run fine on old distros but the produced binaries require linux 5.4.0 (glibc), I recompiled glibc without the kernel limitation, no need to change headers, and the compiled binaries work fine on old distros

This is a glibc-specific problem, there's no need to restrict the kernel version, people use the cross compilers at their own risk...

wdlkmpx commented 2 years ago

Talking about buildroot, the option to support older kernels was introduced on 2022-02-06 https://github.com/buildroot/buildroot/commit/525ffc2bb17fa11fc128124d2d3a92d8698eaab8

All the toolchains using Builroot 2016.02.23+ (git) are affected by the glibc kernel restriction https://github.com/buildroot/buildroot/commit/fd5bcd0eda8fb21f639c34a09b212e6f9b066a04

tpetazzoni commented 2 years ago

This is normally fixed by the recently released 2022.08 toolchains. Let me know if it works for you.

wdlkmpx commented 2 years ago

Yeah it works fine, thanks