Don't set CC in config/i386/go32.mh

Message ID 1416041503-29957-1-git-send-email-yao@codesourcery.com
State New, archived
Headers

Commit Message

Yao Qi Nov. 15, 2014, 8:51 a.m. UTC
  I cross-compile gdb for msdosdjgpp (both target and host is
i586-pc-msdosdjgpp), so the CC should be i586-pc-msdosdjgpp-gcc.
However, CC is set incorrectly to gcc after config/i386/go32.mh is inlined
into the Makefile.

This patch is to remove the CC setting in config/i386/go32.mh.  Is it
OK?

gdb:

2014-11-15  Yao Qi  <yao@codesourcery.com>

	* config/i386/go32.mh (CC): Remove.
---
 gdb/config/i386/go32.mh | 1 -
 1 file changed, 1 deletion(-)
  

Comments

Eli Zaretskii Nov. 15, 2014, 9 a.m. UTC | #1
> From: Yao Qi <yao@codesourcery.com>
> Date: Sat, 15 Nov 2014 16:51:43 +0800
> 
> I cross-compile gdb for msdosdjgpp (both target and host is
> i586-pc-msdosdjgpp), so the CC should be i586-pc-msdosdjgpp-gcc.
> However, CC is set incorrectly to gcc after config/i386/go32.mh is inlined
> into the Makefile.
> 
> This patch is to remove the CC setting in config/i386/go32.mh.  Is it
> OK?

Who will set it to GCC when GDB is compiled natively for
i586-pc-msdosdjgpp?
  
Joel Brobecker Nov. 15, 2014, 10:14 a.m. UTC | #2
> Who will set it to GCC when GDB is compiled natively for
> i586-pc-msdosdjgpp?

It should already be set. See gdb/Makefile.in where CC is set to
@CC@, which means CC is what the configure script determines it
should be, based on how GDB is being configured.

I agree with Yao's patch. Forcing CC to gcc like this seems odd,
and definitely breaks cross-building to that host.
  
Eli Zaretskii Nov. 15, 2014, 10:55 a.m. UTC | #3
> Date: Sat, 15 Nov 2014 14:14:05 +0400
> From: Joel Brobecker <brobecker@adacore.com>
> Cc: Yao Qi <yao@codesourcery.com>, gdb-patches@sourceware.org
> 
> > Who will set it to GCC when GDB is compiled natively for
> > i586-pc-msdosdjgpp?
> 
> It should already be set. See gdb/Makefile.in where CC is set to
> @CC@, which means CC is what the configure script determines it
> should be, based on how GDB is being configured.
> 
> I agree with Yao's patch. Forcing CC to gcc like this seems odd,
> and definitely breaks cross-building to that host.

How come this never came up before, then?  AFAIR, Pedro built the
DJGPP port several times.
  
Yao Qi Nov. 15, 2014, 11:45 a.m. UTC | #4
Eli Zaretskii <eliz@gnu.org> writes:

> How come this never came up before, then?  AFAIR, Pedro built the
> DJGPP port several times.

I don't know.  I built DJGPP port some time ago (last year maybe?), but
I didn't see this problem before either.
  
Eli Zaretskii Nov. 15, 2014, 12:54 p.m. UTC | #5
> From: Yao Qi <yao@codesourcery.com>
> CC: Joel Brobecker <brobecker@adacore.com>, <gdb-patches@sourceware.org>
> Date: Sat, 15 Nov 2014 19:45:51 +0800
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > How come this never came up before, then?  AFAIR, Pedro built the
> > DJGPP port several times.
> 
> I don't know.  I built DJGPP port some time ago (last year maybe?), but
> I didn't see this problem before either.

OK, I guess we go for it, then.

Thanks.
  
Yao Qi Nov. 19, 2014, 7:45 a.m. UTC | #6
Eli Zaretskii <eliz@gnu.org> writes:

>> I don't know.  I built DJGPP port some time ago (last year maybe?), but
>> I didn't see this problem before either.
>
> OK, I guess we go for it, then.

Patch is pushed in.
  
Pedro Alves Nov. 19, 2014, 10:08 a.m. UTC | #7
On 11/15/2014 10:55 AM, Eli Zaretskii wrote:
>> Date: Sat, 15 Nov 2014 14:14:05 +0400
>> From: Joel Brobecker <brobecker@adacore.com>
>> Cc: Yao Qi <yao@codesourcery.com>, gdb-patches@sourceware.org
>>
>>> Who will set it to GCC when GDB is compiled natively for
>>> i586-pc-msdosdjgpp?
>>
>> It should already be set. See gdb/Makefile.in where CC is set to
>> @CC@, which means CC is what the configure script determines it
>> should be, based on how GDB is being configured.
>>
>> I agree with Yao's patch. Forcing CC to gcc like this seems odd,
>> and definitely breaks cross-building to that host.
> 
> How come this never came up before, then?  AFAIR, Pedro built the
> DJGPP port several times.

I did, but I always saw a related problem that I had never
tracked down, which very much sounds like fixed by this.

From https://sourceware.org/ml/gdb-patches/2013-05/msg00057.html:

~~~~~~~
Another issue is that in the gdb/Makefile, I end up with
CC set twice:

$ grep "^CC.*gcc" Makefile
CC=i586-pc-msdosdjgpp-gcc
CC= gcc

and the second one is of course, wrong.  configure does find
i586-pc-msdosdjgpp-gcc:

...
checking for i586-pc-msdosdjgpp-gcc... i586-pc-msdosdjgpp-gcc
checking for C compiler default output file name... a.out
...

and I don't get this on the other subdirs (bfd, etc.)

So if I cd into build/gdb and do "make", the system gcc instead
of the djgpp gcc is invoked:

$ make
make[1]: Entering directory `/home/pedro/gdb/mygit/build-djgpp-2/gdb'
...
gcc -g -O2 -I../../src/gdb/config/djgpp  -I. -I../../src/gdb -I../../src/gdb/common -I../../src/gdb/config -DLOCALEDIR="\"/usr/local/share/locale\"" -DHAVE_CONFIG_H -I../../src/gdb/../include/opcode -I../../src/gdb/../opcodes/.. -I../../src/gdb/../readline/.. -I../bfd -I../../src/gdb/../bfd -I../../src/gdb/../include -I../libdecnumber -I../../src/gdb/../libdecnumber -I./../intl -I../../src/gdb/gnulib/import -Ibuild-gnulib/import    -Wall -Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral -Wpointer-sign -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wmissing-prototypes -Wdeclaration-after-statement -Wempty-body -Werror -c -o init.o -MT init.o -MMD -MP -MF .deps/init.Tpo init.c
rm -f gdb.exe
gcc -g -O2 -I../../src/gdb/config/djgpp  -static-libstdc++ -static-libgcc    \
        -o gdb.exe gdb.o i386-tdep.o i387-tdep.o ser-go32.o go32-nat.o i386-nat.o remote.o dcache.o tracepoint.o ax-general.o ax-gdb.o remote-fileio.o remote-notif.o ctf.o  cli-dump.o cli-decode.o cli-script.o cli-cmds.o cli-setshow.o cli-logging.o cli-interp.o cli-utils.o mi-out.o mi-console.o mi-cmds.o mi-cmd-catch.o mi-cmd-env.o mi-cmd-var.o mi-cmd-break.o mi-cmd-stack.o mi-cmd-file.o mi-cmd-disas.o mi-symbol-cmds.o mi-cmd-target.o mi-cmd-info.o mi-interp.o mi-main.o mi-parse.o mi-getopt.o python.o py-value.o py-prettyprint.o py-auto-load.o posix-hdep.o c-exp.o cp-name-parser.o ada-exp.o jv-exp.o f-exp.o go-exp.o m2-exp.o p-exp.o version.o annotate.o addrmap.o auto-load.o auxv.o agent.o bfd-target.o blockframe.o breakpoint.o break-catch-sig.o break-catch-throw.o findvar.o regcache.o cleanups.o charset.o continuations.o corelow.o disasm.o dummy-frame.o dfp.o source.o value.o eval.o valops.o valarith.o valprint.o printcmd.o block.o symtab.o psymtab.o symfile.o symmisc.o lin!
 espec.o
dictionary.o infcall.o infcmd.o infrun.o expprint.o environ.o stack.o thread.o exceptions.o filesystem.o filestuff.o inf-child.o interps.o minidebug.o main.o macrotab.o macrocmd.o macroexp.o macroscope.o mi-common.o event-loop.o event-top.o inf-loop.o completer.o gdbarch.o arch-utils.o gdbtypes.o gdb_bfd.o gdb_obstack.o osabi.o copying.o memattr.o mem-break.o target.o parse.o language.o buildsym.o findcmd.o std-regs.o signals.o exec.o reverse.o bcache.o objfiles.o observer.o minsyms.o maint.o demangle.o dbxread.o coffread.o coff-pe-read.o dwarf2read.o mipsread.o stabsread.o corefile.o dwarf2expr.o dwarf2loc.o dwarf2-frame.o dwarf2-frame-tailcall.o ada-lang.o c-lang.o d-lang.o f-lang.o objc-lang.o ada-tasks.o ada-varobj.o ui-out.o cli-out.o varobj.o vec.o go-lang.o go-valprint.o go-typeprint.o jv-lang.o jv-valprint.o jv-typeprint.o m2-lang.o opencl-lang.o p-lang.o p-typeprint.o p-valprint.o sentinel-frame.o complaints.o typeprint.o ada-typeprint.o c-typeprint.o f-typeprint.o
m2-typeprint.o ada-valprint.o c-valprint.o cp-valprint.o d-valprint.o f-valprint.o m2-valprint.o serial.o mdebugread.o top.o utils.o ui-file.o user-regs.o frame.o frame-unwind.o doublest.o frame-base.o inline-frame.o gnu-v2-abi.o gnu-v3-abi.o cp-abi.o cp-support.o cp-namespace.o reggroups.o regset.o trad-frame.o tramp-frame.o solib.o solib-target.o prologue-value.o memory-map.o memrange.o xml-support.o xml-syscall.o xml-utils.o target-descriptions.o target-memory.o xml-tdesc.o xml-builtin.o inferior.o osdata.o gdb_usleep.o record.o record-full.o gcore.o gdb_vecs.o jit.o progspace.o skip.o probe.o common-utils.o buffer.o ptid.o gdb-dlfcn.o common-agent.o format.o registry.o btrace.o record-btrace.o inflow.o    init.o \
           ../readline/libreadline.a ../opcodes/libopcodes.a ../bfd/libbfd.a ./../intl/libintl.a ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a -ldbg   -lm    ../libiberty/libiberty.a  build-gnulib/import/libgnu.a
gdb.o: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
make: *** [gdb.exe] Error 1

and that of course isn't the right compiler to use, and things
fall apart.

When make is invoked from the top build dir, the correct CC is passed
down to the gdb/ sub make, so the workaround is to "cd ..; make".
~~~~~~~

Thanks,
Pedro Alves
  

Patch

diff --git a/gdb/config/i386/go32.mh b/gdb/config/i386/go32.mh
index b0ab60c..f1edfad 100644
--- a/gdb/config/i386/go32.mh
+++ b/gdb/config/i386/go32.mh
@@ -6,7 +6,6 @@  MH_CFLAGS= -I$(srcdir)/config/djgpp
 NATDEPFILES= go32-nat.o x86-nat.o x86-dregs.o
 
 HOST_IPC=
-CC= gcc
 XM_CLIBS= -ldbg