From d978ca9aaf8471b90d51ad76480abf9f23ccebbf Mon Sep 17 00:00:00 2001 From: Guy Shimko Date: Thu, 9 Jan 2025 18:01:42 +0200 Subject: [PATCH] build: added libexpat build support This allows commands such as "info os files" previously we had expat support on x86_64 only. --- .gitmodules | 3 ++ Dockerfile | 1 + src/compilation/build.sh | 72 ++++++++++++++++++++++++++++++--- src/submodule_packages/libexpat | 1 + 4 files changed, 71 insertions(+), 6 deletions(-) create mode 160000 src/submodule_packages/libexpat diff --git a/.gitmodules b/.gitmodules index b187d91..cb981e5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -9,3 +9,6 @@ [submodule "src/submodule_packages/pygments"] path = src/submodule_packages/pygments url = git@github.com:pygments/pygments.git +[submodule "src/submodule_packages/libexpat"] + path = src/submodule_packages/libexpat + url = git@github.com:guyush1/libexpat.git diff --git a/Dockerfile b/Dockerfile index 45686b9..43f8daa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,6 +19,7 @@ RUN apt update && apt install -y \ gcc-powerpc-linux-gnu \ git \ libncurses-dev \ + libtool \ m4 \ make \ patch \ diff --git a/src/compilation/build.sh b/src/compilation/build.sh index 10dbf94..41136f2 100755 --- a/src/compilation/build.sh +++ b/src/compilation/build.sh @@ -57,15 +57,18 @@ function set_compliation_variables() { export LDFLAGS="-s" } -function set_ncurses_link_variables() { - # Set up ncurses library link variables +function set_up_lib_search_paths() { + # Set up library-related linker search paths. # # Parameters: # $1: ncursesw build dir + # $2: libexpat build dir local ncursesw_build_dir="$1" + local libexpat_build_dir="$2" - # Allow tui mode by adding our custom built static ncursesw library to the linker search path. - export LDFLAGS="-L$ncursesw_build_dir/lib $LDFLAGS" + # I) Allow tui mode by adding our custom built static ncursesw library to the linker search path. + # II) Allow parsing xml files by adding libexpat library to the linker search path. + export LDFLAGS="-L$ncursesw_build_dir/lib -L$libexpat_build_dir/lib/.libs $LDFLAGS" } function build_iconv() { @@ -214,6 +217,56 @@ function build_ncurses() { popd > /dev/null } +function build_libexpat() { + # Build libexpat. + # + # Parameters: + # $1: libexpat package directory + # $2: target architecture + # + # Echoes: + # The libexpat build directory + # + # Returns: + # 0: success + # 1: failure + local libexpat_dir="$1" + local target_arch="$2" + local libexpat_build_dir="$(realpath "$libexpat_dir/build-$target_arch")" + + echo "$libexpat_build_dir" + mkdir -p "$libexpat_build_dir" + + if [[ -f "$libexpat_build_dir/lib/.libs/libexpat.a" ]]; then + >&2 echo "Skipping build: libexpat already built for $target_arch" + return 0 + fi + + pushd "$libexpat_build_dir" > /dev/null + + >&2 fancy_title "Building libexpat for $target_arch" + + # Generate configure if it doesnt exist. + if [[ ! -f "$libexpat_build_dir/../expat/configure" ]]; then + >&2 ../expat/buildconf.sh ../expat/ + fi + + ../expat/configure --enable-static "CC=$CC" "CXX=$CXX" "--host=$HOST" \ + "CFLAGS=$CFLAGS" "CXXFLAGS=$CXXFLAGS" 1>&2 + if [[ $? -ne 0 ]]; then + return 1 + fi + + make -j$(nproc) 1>&2 + if [[ $? -ne 0 ]]; then + return 1 + fi + + >&2 fancy_title "Finished building libexpat for $target_arch" + + popd > /dev/null +} + function build_python() { # Build python. # @@ -388,10 +441,11 @@ function build_gdb() { ../configure -C --enable-static --with-static-standard-libraries --disable-inprocess-agent \ --enable-tui "$python_flag" \ + --with-expat --with-libexpat-type="static" \ "--with-libiconv-prefix=$libiconv_prefix" --with-libiconv-type=static \ "--with-gmp=$libgmp_prefix" \ "--with-mpfr=$libmpfr_prefix" \ - "CC=$CC" "CXX=$CXX" "--host=$HOST" \ + "CC=$CC" "CXX=$CXX" "LDFLAGS=$LDFLAGS" "--host=$HOST" \ "CFLAGS=$CFLAGS" "CXXFLAGS=$CXXFLAGS" 1>&2 if [[ $? -ne 0 ]]; then return 1 @@ -530,7 +584,13 @@ function build_gdb_with_dependencies() { if [[ $? -ne 0 ]]; then return 1 fi - set_ncurses_link_variables "$ncursesw_build_dir" + + libexpat_build_dir="$(build_libexpat "$packages_dir/libexpat" "$target_arch")" + if [[ $? -ne 0 ]]; then + return 1 + fi + + set_up_lib_search_paths "$ncursesw_build_dir" "$libexpat_build_dir" if [[ "$with_python" == "yes" ]]; then local gdb_python_dir="$packages_dir/binutils-gdb/gdb/python/lib/" diff --git a/src/submodule_packages/libexpat b/src/submodule_packages/libexpat new file mode 160000 index 0000000..2691aff --- /dev/null +++ b/src/submodule_packages/libexpat @@ -0,0 +1 @@ +Subproject commit 2691aff4304a6d7e053199c205620136481b9dd1