[patch] Regression on CFLAGS=-m32 build [Re: [rfa/rfc] Build libcommon.a for gdb and gdbserver]

Jan Kratochvil
2011-02-21T18:45:01Z

Hi Yao,

wrt
commit 8c5a634bffb212fadf96c090f12551160fffca3f
2011-02-11 Yao Qi <yao@codesourcery.com>
* Makefile.in: Remove signals.o from COMMON_OBS. Link
libcommon.a.
* configure.ac: Add common to sub dir.
* configure: Regenerate.
common/
2011-02-11 Yao Qi <yao@codesourcery.com>
Build libcommon.a.
* Makefile.in: New.
* configure.ac: New.
* aclocal.m4: New.
* configure: Generate.
gdbserver/
2011-02-11 Yao Qi <yao@codesourcery.com>
* configure.ac: Call AC_PROG_RANLIB.
* Makefile.in: Remove signals.o from OBS. Link libcommon.a.
* configure: Regenerate.

there is a regression for common/ as it no longer uses @CFLAGS@ now.
This will crash compilation on x86_64 box using:
CFLAGS=-m32 ./configure i386-unknown-linux-gnu;make
->
common/libcommon.a: could not read symbols: File in wrong format
->
libcommon/signals.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped

I put $(CFLAGS) to the end, so that a user can override other options.
Currently in gdb/Makefile.in $(CFLAGS) is at the beginning of the line.

It may all get obsoleted soon by Tom's automake.

I will check it in today with no comments, it seems serious + safe to me.

Thanks,
Jan

gdb/
2011-02-21 Jan Kratochvil <jan.kratochvil@redhat.com>

* common/Makefile.in (CFLAGS): New.
(COMPILE): Add $(CFLAGS).

--- a/gdb/common/Makefile.in
+++ b/gdb/common/Makefile.in
@@ -23,6 +23,10 @@ AUTOHEADER = @AUTOHEADER@
RANLIB = @RANLIB@
COMMON_CPU_OBJ = @COMMON_CPU_OBJ@

+# CFLAGS is specifically reserved for setting from the command line
+# when running make. I.E. "make CFLAGS=-Wmissing-prototypes".
+CFLAGS = @CFLAGS@
+
BFD_DIR = ../../bfd
BFD_SRC = $(srcdir)/$(BFD_DIR)
BFD_CFLAGS = -I$(BFD_DIR) -I$(BFD_SRC)
@@ -37,7 +41,8 @@ all: libcommon.a
signals.o: $(srcdir)/signals.c
$(COMPILE) $(srcdir)/signals.c

-COMPILE = source='$<' object='$@' libtool=no $(CC) $(DEFS) $(INCLUDES) @GDB_FLAGS@ $(CPPFLAGS) $(ALL_CFLAGS) -c
+COMPILE = source='$<' object='$@' libtool=no $(CC) $(DEFS) $(INCLUDES) \
+ @GDB_FLAGS@ $(CPPFLAGS) $(ALL_CFLAGS) $(CFLAGS) -c

# Implicit rules