Fix cross-compiling with static linking in gdbserver Makefile.in
Commit Message
Hi Filipe,
On 11/10/2014 10:46 AM, Filipe Utzig wrote:
> The Makefile.in of gdbserver is written to use gcc instead ${CC} when
> you choose to compile the target with libraries linked statically. In
> fact is not a bug itself, but the comment says to set that line if you
> want/need to compile with the -static flag, and I saw some users
> having troubles with this, so I believe that's a good idea do the
> comment in the right way.
Hmm, odd comment.
> This patch should fix that.
> index 8b0318a..c2ef44c 100644
> --- a/gdb/gdbserver/Makefile.in
> +++ b/gdb/gdbserver/Makefile.in
> @@ -78,7 +78,7 @@ VPATH = @srcdir@
>
> # Set this up with gcc if you have gnu ld and the loader will print out
> # line numbers for undefinded refs.
> -#CC-LD=gcc -static
> +#CC-LD=${CC} -static
> CC-LD=${CC}
IMO, afterwards, the comment makes even less sense, for still
talking about gcc.
Why not just use LDFLAGS, as in:
$ make LDFLAGS="-static"
?
I see that gdb/Makefile.in has the same comment. I think we should just
delete that comment and the commented out bit.
From 1fa406f22d6f62db3421426c2b868295c7526846 Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Tue, 11 Nov 2014 12:55:02 +0000
Subject: [PATCH] gdb/gdbserver: don't suggest overriding CC_LD/CC-LD in
Makefile.in
Ref: <https://sourceware.org/ml/gdb-patches/2014-11/msg00165.html>.
Looking at git history, I traced this commented out the -static all
the way back to gdb-3.3 (4187119d):
/* Set this up with gcc if you have gnu ld and the loader will print out
line numbers for undefinded refs. */
/* CC-LD=gcc -static */
CC-LD=${CC}
And, before that, gdb-3.1 (e91b87a3) already had the comment in
gdb/Makefile:
# Set this up with gcc if you have gnu ld and the loader will print out
# line numbers for undefinded refs.
CC-LD=${CC}
(but no explicit mention of -static).
There's a standard mechanism to pass linker flags to the linker
(override LDFLAGS, e.g.: 'make LDFLAGS="-static"'), no need to
suggest a custom way.
gdb/
2014-11-11 Pedro Alves <palves@redhat.com>
* Makefile.in: Remove comment suggesting setting up CC_LD to gcc
-static.
gdb/gdbserver/
2014-11-11 Pedro Alves <palves@redhat.com>
* Makefile.in: Remove comment suggesting setting up CC_LD to gcc
-static.
---
gdb/ChangeLog | 5 +++++
gdb/gdbserver/ChangeLog | 5 +++++
gdb/Makefile.in | 3 ---
gdb/gdbserver/Makefile.in | 3 ---
4 files changed, 10 insertions(+), 6 deletions(-)
@@ -1,3 +1,8 @@
+2014-11-11 Pedro Alves <palves@redhat.com>
+
+ * Makefile.in: Remove comment suggesting setting up CC_LD to gcc
+ -static.
+
2014-11-07 Pedro Alves <palves@redhat.com>
* infrun.c (process_event_stop_test) <subroutine check>: Don't
@@ -1,3 +1,8 @@
+2014-11-11 Pedro Alves <palves@redhat.com>
+
+ * Makefile.in: Remove comment suggesting setting up CC_LD to gcc
+ -static.
+
2014-10-15 Pedro Alves <palves@redhat.com>
PR server/17487
@@ -120,9 +120,6 @@ MAKEINFO_CMD = $(MAKEINFO) $(MAKEINFOFLAGS) $(MAKEINFO_EXTRA_FLAGS)
MAKEHTML = $(MAKEINFO_CMD) --html
MAKEHTMLFLAGS =
-# Set this up with gcc if you have gnu ld and the loader will print out
-# line numbers for undefined references.
-#CC_LD=gcc -static
CC_LD=$(CC)
# Where is our "include" directory? Typically $(srcdir)/../include.
@@ -76,9 +76,6 @@ VPATH = @srcdir@
# CFLAGS section if your system doesn't have fcntl.h in /usr/include (which
# is where it should be according to Posix).
-# Set this up with gcc if you have gnu ld and the loader will print out
-# line numbers for undefinded refs.
-#CC-LD=gcc -static
CC-LD=${CC}
# Where is the "include" directory? Traditionally ../include or ./include