Skip to content

Commit aae73b4

Browse files
committed
Added the required gdb buildsystem patches in order to build statically
1 parent 0c794ef commit aae73b4

File tree

2 files changed

+71
-1
lines changed

2 files changed

+71
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Clone gdb from sourceware - https://sourceware.org/git/binutils-gdb.git.
4444
I checked out to the 15.1 tag.
4545

4646
Work according to the following steps:
47-
I) Apply my patches - if you are not on the exact tag i used (15.1) - you might need to apply them manually.
47+
I) Apply my patches (gdb_static.patch). If you are not on the exact tag i used (15.1) - you might need to apply them manually, and change some stuff.
4848
II) create a build dir.
4949
III) run `../configure --enable-static --with-static-standard-libraries --disable-tui --disable-inprocess-agent --with-libiconv-prefix=<COMPILATION_DIR_PATH>/lib/.libs/ --with-libiconv-type=static`
5050
IV) run `make all-gdb -j$(nproc)` - for gdbserver, run `make all-gdbserver -j$(nproc)`.

gdb_static.patch

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
diff --git a/Makefile.in b/Makefile.in
2+
index f12c251f9c8..eed512b2d18 100644
3+
--- a/Makefile.in
4+
+++ b/Makefile.in
5+
@@ -31593,7 +31593,7 @@ configure-readline:
6+
$$s/$$module_srcdir/configure \
7+
--srcdir=$${topdir}/$$module_srcdir \
8+
$(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
9+
- --target=${target_alias} \
10+
+ --target=${target_alias} --enable-static \
11+
|| exit 1
12+
@endif readline
13+
14+
@@ -40793,7 +40793,7 @@ configure-libcc1:
15+
$$s/$$module_srcdir/configure \
16+
--srcdir=$${topdir}/$$module_srcdir \
17+
$(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
18+
- --target=${target_alias} --enable-shared \
19+
+ --target=${target_alias} --enable-static --disable-shared \
20+
|| exit 1
21+
@endif libcc1
22+
23+
diff --git a/configure b/configure
24+
index 6466b97f3ec..2ab23dcb81e 100755
25+
--- a/configure
26+
+++ b/configure
27+
@@ -9398,7 +9398,7 @@ case " $configdirs " in
28+
*" lto-plugin "* | *" libcc1 "* | *" gdbserver "*)
29+
# When these are to be built as shared libraries, the same applies to
30+
# libiberty.
31+
- extra_host_libiberty_configure_flags=--enable-shared
32+
+ extra_host_libiberty_configure_flags="--enable-static --disable-shared"
33+
;;
34+
esac
35+
36+
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
37+
index 84bc54b303e..c81269ced78 100644
38+
--- a/gdb/Makefile.in
39+
+++ b/gdb/Makefile.in
40+
@@ -148,7 +148,7 @@ LIBTOOL = @LIBTOOL@
41+
# Set this up with gcc if you have gnu ld and the loader will print out
42+
# line numbers for undefined references.
43+
#CC_LD = g++ -static
44+
-CC_LD = $(LIBTOOL) $(SILENT_FLAG) --mode=link $(CXX) $(CXX_DIALECT)
45+
+CC_LD = $(LIBTOOL) $(SILENT_FLAG) --mode=link $(CXX) -all-static $(CXX_DIALECT)
46+
47+
# Where is our "include" directory? Typically $(srcdir)/../include.
48+
# This is essentially the header file directory for the library
49+
diff --git a/gdbserver/Makefile.in b/gdbserver/Makefile.in
50+
index 6148ccf9121..2a9c9720d1a 100644
51+
--- a/gdbserver/Makefile.in
52+
+++ b/gdbserver/Makefile.in
53+
@@ -83,7 +83,7 @@ COMPILE = $(ECHO_CXX) $(COMPILE.pre) $(INTERNAL_CFLAGS) $(INCLUDE_SERVER_H) \
54+
# Set this up with gcc if you have gnu ld and the loader will print out
55+
# line numbers for undefinded refs.
56+
#CC_LD = g++ -static
57+
-CC_LD = $(CXX) $(CXX_DIALECT)
58+
+CC_LD = $(CXX) -static $(CXX_DIALECT)
59+
60+
# Where is the "include" directory? Traditionally ../include or ./include
61+
INCLUDE_DIR = ${srcdir}/../include
62+
@@ -405,7 +405,7 @@ IPA_LIB = libinproctrace.so
63+
64+
$(IPA_LIB): $(sort $(IPA_OBJS)) ${CDEPS}
65+
$(SILENCE) rm -f $(IPA_LIB)
66+
- $(ECHO_CXXLD) $(CC_LD) -shared -fPIC -Wl,--soname=$(IPA_LIB) \
67+
+ $(ECHO_CXXLD) $(CC_LD) -static -fPIC -Wl,--soname=$(IPA_LIB) \
68+
-Wl,--no-undefined $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) \
69+
$(CXXFLAGS) \
70+
-o $(IPA_LIB) ${IPA_OBJS} $(LIBIBERTY_FOR_SHLIB) -ldl -pthread

0 commit comments

Comments
 (0)