Skip to content

Commit b9b2171

Browse files
committed
build: build gdb with tui mode enabled
This was acheived by forcing gdb to use our own static libncurses
1 parent 5ed28ef commit b9b2171

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ RUN apt update && apt install -y \
1414
gcc-powerpc-linux-gnu \
1515
gcc-mips-linux-gnu \
1616
gcc-mipsel-linux-gnu \
17+
libncurses-dev \
1718
m4 \
1819
make \
1920
patch \

src/build.sh

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ function set_compliation_variables() {
5151
export CXXFLAGS="-O2"
5252
}
5353

54+
function set_library_link_variables() {
55+
# Set up library-related link variables
56+
#
57+
# Parameters:
58+
# $1: ncursesw build dir
59+
60+
local ncursesw_build_dir="$1"
61+
62+
# Allow tui mode by adding our custom built static ncursesw library to the linker search path.
63+
export LDFLAGS="-L$ncursesw_build_dir/lib $LDFLAGS"
64+
}
65+
5466
function build_iconv() {
5567
# Build libiconv.
5668
#
@@ -152,6 +164,51 @@ function build_libgmp() {
152164
popd > /dev/null
153165
}
154166

167+
function build_libncurses() {
168+
# Build libncursesw.
169+
#
170+
# Parameters:
171+
# $1: libncursesw package directory
172+
# $2: target architecture
173+
#
174+
# Echoes:
175+
# The libncursesw build directory
176+
#
177+
# Returns:
178+
# 0: success
179+
# 1: failure
180+
local ncurses_dir="$1"
181+
local target_arch="$2"
182+
local ncurses_build_dir="$(realpath "$ncurses_dir/build-$target_arch")"
183+
184+
echo "$ncurses_build_dir"
185+
mkdir -p "$ncurses_build_dir"
186+
187+
if [[ -f "$ncurses_build_dir/lib/libncursesw.a" ]]; then
188+
>&2 echo "Skipping build: libncursesw already built for $target_arch"
189+
return 0
190+
fi
191+
192+
pushd "$ncurses_build_dir" > /dev/null
193+
194+
>&2 fancy_title "Building libncursesw for $target_arch"
195+
196+
../configure --enable-static "CC=$CC" "CXX=$CXX" "--host=$HOST" \
197+
"CFLAGS=$CFLAGS" "CXXFLAGS=$CXXFLAGS" "--enable-widec" 1>&2
198+
if [[ $? -ne 0 ]]; then
199+
return 1
200+
fi
201+
202+
make -j$(nproc) 1>&2
203+
if [[ $? -ne 0 ]]; then
204+
return 1
205+
fi
206+
207+
>&2 fancy_title "Finished building libncursesw for $target_arch"
208+
209+
popd > /dev/null
210+
}
211+
155212
function build_libmpfr() {
156213
# Build libmpfr.
157214
#
@@ -242,7 +299,7 @@ function build_gdb() {
242299

243300
>&2 fancy_title "Building gdb for $target_arch"
244301

245-
../configure --enable-static --with-static-standard-libraries --disable-tui --disable-inprocess-agent \
302+
../configure --enable-static --enable-tui --with-static-standard-libraries --disable-inprocess-agent \
246303
"--with-libiconv-prefix=$libiconv_prefix" --with-libiconv-type=static \
247304
"--with-gmp=$libgmp_prefix" \
248305
"--with-mpfr=$libmpfr_prefix" \
@@ -367,6 +424,13 @@ function build_gdb_with_dependencies() {
367424
return 1
368425
fi
369426

427+
ncursesw_build_dir="$(build_libncurses "$packages_dir/ncurses" "$target_arch")"
428+
if [[ $? -ne 0 ]]; then
429+
return 1
430+
fi
431+
432+
set_library_link_variables "$ncursesw_build_dir"
433+
370434
build_and_install_gdb "$packages_dir/gdb" \
371435
"$iconv_build_dir/lib/.libs/" \
372436
"$gmp_build_dir/.libs/" \

0 commit comments

Comments
 (0)