6.4. Bash-5.1.8

The Bash package contains the Bourne-Again SHell.

Approximate build time: 0.4 SBU
Required disk space: 64 MB

6.4.1. Installation of Bash

Update helper scripts to allow cross compilation for loongarch:

tar xf ../config-20210826.tar.xz --strip-components=1 -C support

We need to override a lot of configuration variables building this package to fix a severe runtime issue. Create a file containing those variables:

cat > config.cache << "EOF"
ac_cv_func_mmap_fixed_mapped=yes
ac_cv_func_strcoll_works=yes
ac_cv_func_working_mktime=yes
bash_cv_func_sigsetjmp=present
bash_cv_getcwd_malloc=yes
bash_cv_job_control_missing=present
bash_cv_printf_a_format=yes
bash_cv_sys_named_pipes=present
bash_cv_ulimit_maxfds=yes
bash_cv_under_sys_siglist=yes
bash_cv_unusable_rtsigs=no
gt_cv_int_divbyzero_sigfpe=yes
EOF

Prepare Bash for compilation:

./configure --prefix=/usr                   \
            --build=$(support/config.guess) \
            --host=$LFS_TGT                 \
            --without-bash-malloc           \
            --cache-file=config.cache

The meaning of the configure options:

--without-bash-malloc

This option turns off the use of Bash's memory allocation (malloc) function which is known to cause segmentation faults. By turning this option off, Bash will use the malloc functions from Glibc which are more stable.

Compile the package:

make

Install the package:

make DESTDIR=$LFS install

Make a link for the programs that use sh for a shell:

ln -sv bash $LFS/bin/sh

Details on this package are located in Section 8.34.2, “Contents of Bash.”