Skip to content

Commit e8263f9

Browse files
committed
build: added libexpat build support
This allows commands such as "info os files" previously we had expat support on x86_64 only.
1 parent f7e97ca commit e8263f9

File tree

4 files changed

+71
-6
lines changed

4 files changed

+71
-6
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@
66
path = src/submodule_packages/binutils-gdb
77
url = [email protected]:guyush1/binutils-gdb.git
88
branch = gdb-static
9+
[submodule "src/submodule_packages/libexpat"]
10+
path = src/submodule_packages/libexpat
11+
url = [email protected]:guyush1/libexpat.git

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ RUN apt update && apt install -y \
1919
gcc-powerpc-linux-gnu \
2020
git \
2121
libncurses-dev \
22+
libtool \
2223
m4 \
2324
make \
2425
patch \

src/compilation/build.sh

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,18 @@ function set_compliation_variables() {
5757
export LDFLAGS="-s"
5858
}
5959

60-
function set_ncurses_link_variables() {
61-
# Set up ncurses library link variables
60+
function set_up_lib_search_paths() {
61+
# Set up library-related linker search paths.
6262
#
6363
# Parameters:
6464
# $1: ncursesw build dir
65+
# $2: libexpat build dir
6566
local ncursesw_build_dir="$1"
67+
local libexpat_build_dir="$2"
6668

67-
# Allow tui mode by adding our custom built static ncursesw library to the linker search path.
68-
export LDFLAGS="-L$ncursesw_build_dir/lib $LDFLAGS"
69+
# I) Allow tui mode by adding our custom built static ncursesw library to the linker search path.
70+
# II) Allow parsing xml files by adding libexpat library to the linker search path.
71+
export LDFLAGS="-L$ncursesw_build_dir/lib -L$libexpat_build_dir/lib/.libs $LDFLAGS"
6972
}
7073

7174
function build_iconv() {
@@ -214,6 +217,56 @@ function build_ncurses() {
214217
popd > /dev/null
215218
}
216219

220+
function build_libexpat() {
221+
# Build libexpat.
222+
#
223+
# Parameters:
224+
# $1: libexpat package directory
225+
# $2: target architecture
226+
#
227+
# Echoes:
228+
# The libexpat build directory
229+
#
230+
# Returns:
231+
# 0: success
232+
# 1: failure
233+
local libexpat_dir="$1"
234+
local target_arch="$2"
235+
local libexpat_build_dir="$(realpath "$libexpat_dir/build-$target_arch")"
236+
237+
echo "$libexpat_build_dir"
238+
mkdir -p "$libexpat_build_dir"
239+
240+
if [[ -f "$libexpat_build_dir/lib/.libs/libexpat.a" ]]; then
241+
>&2 echo "Skipping build: libexpat already built for $target_arch"
242+
return 0
243+
fi
244+
245+
pushd "$libexpat_build_dir" > /dev/null
246+
247+
>&2 fancy_title "Building libexpat for $target_arch"
248+
249+
# Generate configure if it doesnt exist.
250+
if [[ ! -f "$libexpat_build_dir/../expat/configure" ]]; then
251+
>&2 ../expat/buildconf.sh ../expat/
252+
fi
253+
254+
../expat/configure --enable-static "CC=$CC" "CXX=$CXX" "--host=$HOST" \
255+
"CFLAGS=$CFLAGS" "CXXFLAGS=$CXXFLAGS" 1>&2
256+
if [[ $? -ne 0 ]]; then
257+
return 1
258+
fi
259+
260+
make -j$(nproc) 1>&2
261+
if [[ $? -ne 0 ]]; then
262+
return 1
263+
fi
264+
265+
>&2 fancy_title "Finished building libexpat for $target_arch"
266+
267+
popd > /dev/null
268+
}
269+
217270
function build_python() {
218271
# Build python.
219272
#
@@ -373,10 +426,11 @@ function build_gdb() {
373426

374427
../configure -C --enable-static --with-static-standard-libraries --disable-inprocess-agent \
375428
--enable-tui "$python_flag" \
429+
--with-expat --with-libexpat-type="static" \
376430
"--with-libiconv-prefix=$libiconv_prefix" --with-libiconv-type=static \
377431
"--with-gmp=$libgmp_prefix" \
378432
"--with-mpfr=$libmpfr_prefix" \
379-
"CC=$CC" "CXX=$CXX" "--host=$HOST" \
433+
"CC=$CC" "CXX=$CXX" "LDFLAGS=$LDFLAGS" "--host=$HOST" \
380434
"CFLAGS=$CFLAGS" "CXXFLAGS=$CXXFLAGS" 1>&2
381435
if [[ $? -ne 0 ]]; then
382436
return 1
@@ -515,7 +569,13 @@ function build_gdb_with_dependencies() {
515569
if [[ $? -ne 0 ]]; then
516570
return 1
517571
fi
518-
set_ncurses_link_variables "$ncursesw_build_dir"
572+
573+
libexpat_build_dir="$(build_libexpat "$packages_dir/libexpat" "$target_arch")"
574+
if [[ $? -ne 0 ]]; then
575+
return 1
576+
fi
577+
578+
set_up_lib_search_paths "$ncursesw_build_dir" "$libexpat_build_dir"
519579

520580
if [[ "$with_python" == "yes" ]]; then
521581
build_python "$packages_dir/cpython-static" "$target_arch"

src/submodule_packages/libexpat

Submodule libexpat added at 2691aff

0 commit comments

Comments
 (0)