@@ -121,6 +121,58 @@ function build_iconv() {
121121 popd > /dev/null
122122}
123123
124+ function build_lzma() {
125+ # Build liblzma.
126+ #
127+ # Parameters:
128+ # $1: lzma package directory
129+ # $2: target architecture
130+ #
131+ # Echoes:
132+ # The lzma build directory
133+ #
134+ # Returns:
135+ # 0: success
136+ # 1: failure
137+
138+ local lzma_dir=" $1 "
139+ local target_arch=" $2 "
140+ local lzma_build_dir=" $( realpath " $lzma_dir /build-$target_arch " ) "
141+
142+ echo " $lzma_build_dir "
143+ mkdir -p " $lzma_build_dir "
144+
145+ if [[ -f " $lzma_build_dir /usr/local/lib/liblzma.a" ]]; then
146+ >&2 echo " Skipping build: lzma already built for $target_arch "
147+ return 0
148+ fi
149+
150+ pushd " $lzma_build_dir " > /dev/null
151+
152+ >&2 fancy_title " Building liblzma for $target_arch "
153+
154+ ../configure --enable-static " CC=$CC " " CXX=$CXX " " --host=$HOST " \
155+ " CFLAGS=$CFLAGS " " CXXFLAGS=$CXXFLAGS " 1>&2
156+ if [[ $? -ne 0 ]]; then
157+ return 1
158+ fi
159+
160+ make -j$( nproc) 1>&2
161+ if [[ $? -ne 0 ]]; then
162+ return 1
163+ fi
164+
165+ make -j$( nproc) install DESTDIR=$lzma_build_dir 1>&2
166+ if [[ $? -ne 0 ]]; then
167+ return 1
168+ fi
169+
170+ >&2 fancy_title " Finished building liblzma for $target_arch "
171+
172+ popd > /dev/null
173+ }
174+
175+
124176function build_libgmp() {
125177 # Build libgmp.
126178 #
@@ -401,9 +453,10 @@ function build_gdb() {
401453 # $1: gdb directory
402454 # $2: target architecture
403455 # $3: libiconv prefix
404- # $4: libgmp prefix
405- # $5: libmpfr prefix
406- # $6: whether to build with python or not
456+ # $4: liblzma prefix
457+ # $5: libgmp prefix
458+ # $6: libmpfr prefix
459+ # $7: whether to build with python or not
407460 #
408461 # Echoes:
409462 # The gdb build directory
@@ -415,9 +468,10 @@ function build_gdb() {
415468 local gdb_dir=" $1 "
416469 local target_arch=" $2 "
417470 local libiconv_prefix=" $3 "
418- local libgmp_prefix=" $4 "
419- local libmpfr_prefix=" $5 "
420- local with_python=" $6 "
471+ local liblzma_prefix=" $4 "
472+ local libgmp_prefix=" $5 "
473+ local libmpfr_prefix=" $6 "
474+ local with_python=" $7 "
421475
422476 if [[ " $with_python " == " yes" ]]; then
423477 local python_flag=" --with-python=/app/gdb/build/packages/cpython-static/build-$target_arch /bin/python3-config"
@@ -443,6 +497,7 @@ function build_gdb() {
443497 --enable-tui " $python_flag " \
444498 --with-expat --with-libexpat-type=" static" \
445499 " --with-libiconv-prefix=$libiconv_prefix " --with-libiconv-type=static \
500+ " --with-liblzma-prefix=$liblzma_prefix " --with-liblzma-type=static --with-lzma=yes \
446501 " --with-gmp=$libgmp_prefix " \
447502 " --with-mpfr=$libmpfr_prefix " \
448503 " CC=$CC " " CXX=$CXX " " LDFLAGS=$LDFLAGS " " --host=$HOST " \
@@ -513,25 +568,27 @@ function build_and_install_gdb() {
513568 # Parameters:
514569 # $1: gdb package directory
515570 # $2: libiconv prefix
516- # $3: libgmp prefix
517- # $4: libmpfr prefix
518- # $5: whether to build with python or not
519- # $6: install directory
520- # $7: target architecture
571+ # $3: liblzma prefix
572+ # $4: libgmp prefix
573+ # $5: libmpfr prefix
574+ # $6: whether to build with python or not
575+ # $7: install directory
576+ # $8: target architecture
521577 #
522578 # Returns:
523579 # 0: success
524580 # 1: failure
525581
526582 local gdb_dir=" $1 "
527583 local libiconv_prefix=" $2 "
528- local libgmp_prefix=" $3 "
529- local libmpfr_prefix=" $4 "
530- local with_python=" $5 "
531- local artifacts_dir=" $6 "
532- local target_arch=" $7 "
584+ local liblzma_prefix=" $3 "
585+ local libgmp_prefix=" $4 "
586+ local libmpfr_prefix=" $5 "
587+ local with_python=" $6 "
588+ local artifacts_dir=" $7 "
589+ local target_arch=" $8 "
533590
534- gdb_build_dir=" $( build_gdb " $gdb_dir " " $target_arch " " $libiconv_prefix " " $libgmp_prefix " " $libmpfr_prefix " " $with_python " ) "
591+ gdb_build_dir=" $( build_gdb " $gdb_dir " " $target_arch " " $libiconv_prefix " " $liblzma_prefix " " $ libgmp_prefix" " $libmpfr_prefix " " $with_python " ) "
535592 if [[ $? -ne 0 ]]; then
536593 return 1
537594 fi
@@ -570,6 +627,11 @@ function build_gdb_with_dependencies() {
570627 return 1
571628 fi
572629
630+ lzma_build_dir=" $( build_lzma " $packages_dir /xz" " $target_arch " ) "
631+ if [[ $? -ne 0 ]]; then
632+ return 1
633+ fi
634+
573635 gmp_build_dir=" $( build_libgmp " $packages_dir /gmp" " $target_arch " ) "
574636 if [[ $? -ne 0 ]]; then
575637 return 1
@@ -603,6 +665,7 @@ function build_gdb_with_dependencies() {
603665
604666 build_and_install_gdb " $packages_dir /binutils-gdb" \
605667 " $iconv_build_dir /lib/.libs/" \
668+ " $lzma_build_dir /usr/local/" \
606669 " $gmp_build_dir /.libs/" \
607670 " $mpfr_build_dir /src/.libs/" \
608671 " $with_python " \
0 commit comments