使用替换后make编译内核3.18.4时出现segmentation fault错误导致无法使用, 方案放弃

前言

因为要编译低版本的内核, 但是高版本make在编译时会因为编译规则问题而报错,因此要考虑降低 make 版本

实现

  1. 下载 make 3.81

    在官网 https://ftp.gnu.org/gnu/make/ 下载对应版本的 make, 如:

    wget http://ftp.gnu.org/gnu/make/make-3.81.tar.gz
  2. 解压

    tar xf make-3.81.tar.gz
  3. 执行 configuration

    ./configure --prefix=/usr/local/make-3.81
  4. 执行build.sh

    sh build.sh
  5. 安装 make

    sudo make install
  6. 替换 make

    sudo cp make /usr/bin/make
  7. 可以看到版本已经降下来了

    ➜  make-3.81 make --version
    GNU Make 3.81
    Copyright (C) 2006 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.
    There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
    PARTICULAR PURPOSE.

    This program built for x86_64-unknown-linux-gnu

问题

  1. 在执行sh build.sh时, 遇到如下错误

    glob.o: In function `glob_in_dir':
    /mnt/d/Users/Lantern/Desktop/work/kernal/make-3.81/./glob/glob.c:1336: undefined reference to `__alloca'
    /mnt/d/Users/Lantern/Desktop/work/kernal/make-3.81/./glob/glob.c:1250: undefined reference to `__alloca'
    /mnt/d/Users/Lantern/Desktop/work/kernal/make-3.81/./glob/glob.c:1277: undefined reference to `__alloca'
    /mnt/d/Users/Lantern/Desktop/work/kernal/make-3.81/./glob/glob.c:1361: undefined reference to `__alloca'
    glob.o: In function `glob':
    /mnt/d/Users/Lantern/Desktop/work/kernal/make-3.81/./glob/glob.c:575: undefined reference to `__alloca'
    glob.o:/mnt/d/Users/Lantern/Desktop/work/kernal/make-3.81/./glob/glob.c:726: more undefined references to `__alloca' follow
    collect2: error: ld returned 1 exit status

    https://stackoverflow.com/questions/51675200/install-older-version-of-gnu-make-in-ubuntu-18-04 找到解决方法:

    glob.c中的

    # if _GNU_GLOB_INTERFACE_VERSION == GLOB_INTERFACE_VERSION

    改为

    # if _GNU_GLOB_INTERFACE_VERSION >= GLOB_INTERFACE_VERSION

    即可成功编译