RE: Building GDB 7.3.92 with MinGW

Pierre Muller
2012-01-15T22:03:53Z

> -----Message d'origine-----
> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Eli Zaretskii
> Envoyé : dimanche 15 janvier 2012 19:55
> À : Pierre Muller
> Cc : asmwarrior@gmail.com; brobecker@adacore.com; dje@google.com; gdb-
> patches@sourceware.org
> Objet : Re: Building GDB 7.3.92 with MinGW
>
> > From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
> > Cc: <asmwarrior@gmail.com>, <brobecker@adacore.com>, <dje@google.com>,
> > <gdb-patches@sourceware.org>
> > Date: Sun, 15 Jan 2012 18:00:51 +0100
> >
> > I also wrongly supposed that configure prefix or related entries
should
> > be msys pathes.
>
> If the configury supports d:/foo/bar file names (and most modern
> versions of Autoconf and libtool do), then using MSYS /d/foo/bar style
> of file names is not necessary. Only of d:/foo fails, you should fall
> back on the MSYS style.

In fact, I think I have now finally found where the problem starts
if you do not specify any --prefix to configure:
--prefix has a default /usr/local value,
this sets prefix inside gdb/Makefile
and three directories inside config.h
$ grep 'DIR "' *.h
config.h:#define DEBUGDIR "/usr/local/lib/debug"
config.h:#define GDB_DATADIR "/usr/local/share/gdb"
config.h:#define JIT_READER_DIR "/usr/local/lib/gdb"

But what about BINDIR which is used for reloacate_gdb_directory..
This one is not inside config.h :

$ grep -n -C 3 BINDIR *
Makefile-1520-# Some files need explicit build rules (due to -Werror
problems) or due
Makefile-1521-# to sub-directory fun 'n' games.
Makefile-1522-
Makefile:1523:# main.o needs an explicit build rule to get
TARGET_SYSTEM_ROOT and BINDIR.
Makefile-1524-main.o: $(srcdir)/main.c
Makefile:1525: $(COMPILE) $(TARGET_SYSTEM_ROOT_DEFINE)
-DBINDIR=\"$(bindir)\" $(srcdir)/main.c
Makefile-1526- $(POSTCOMPILE)
Makefile-1527-

OK, but defining a macro inside config.h or on command line should
not make any difference, no?
The following will prove otherwise!

For testing purpose, I tried to recompile main.o
adding --verbose option to compiler
$ make main.o CFLAGS="-g -O0 --save-temps --verbose"
make[1]: Entering directory
`/usr/local/src/gdbcvs/mingw32-puresrc-python/gdb'
make[2]: Entering directory
`/usr/local/src/gdbcvs/mingw32-puresrc-python/gdb/gn
ulib'
make all-recursive
make[3]: Entering directory
`/usr/local/src/gdbcvs/mingw32-puresrc-python/gdb/gn
ulib'
make[4]: Entering directory
`/usr/local/src/gdbcvs/mingw32-puresrc-python/gdb/gn
ulib'
make[4]: Nothing to be done for `all-am'.
make[4]: Leaving directory
`/usr/local/src/gdbcvs/mingw32-puresrc-python/gdb/gnu
lib'
make[3]: Leaving directory
`/usr/local/src/gdbcvs/mingw32-puresrc-python/gdb/gnu
lib'
make[2]: Leaving directory
`/usr/local/src/gdbcvs/mingw32-puresrc-python/gdb/gnu
lib'
make[1]: Leaving directory
`/usr/local/src/gdbcvs/mingw32-puresrc-python/gdb'
gcc -g -O0 --save-temps --verbose -I. -I../../puresrc/gdb
-I../../puresrc/gdb/
common -I../../puresrc/gdb/config -DLOCALEDIR="\"/usr/local/share/locale\""
-DHA
VE_CONFIG_H -I../../puresrc/gdb/../include/opcode
-I../../puresrc/gdb/../opcodes
/.. -I../../puresrc/gdb/../readline/.. -I../bfd -I../../puresrc/gdb/../bfd
-I../
../puresrc/gdb/../include -I../libdecnumber
-I../../puresrc/gdb/../libdecnumber
-I../../puresrc/gdb/gnulib -Ignulib -Ic:/Python27/include
-Ic:/Python27/incl
ude -Wall -Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral
-Wno
-pointer-sign -Wno-unused -Wunused-value -Wunused-function -Wno-switch
-Wno-char
-subscripts -Wno-format -Werror -c -o main.o -MT main.o -MMD -MP -MF
.deps/main.
Tpo -DTARGET_SYSTEM_ROOT=\"\" -DTARGET_SYSTEM_ROOT_RELOCATABLE=0
-DBINDIR=\"/usr
/local/bin\" ../../puresrc/gdb/main.c
Using built-in specs.
COLLECT_GCC=E:\msys\mingw32\bin\gcc.exe
COLLECT_LTO_WRAPPER=e:/msys/mingw32/bin/../libexec/gcc/mingw32/4.6.1/lto-wra
pper
.exe
Target: mingw32
Configured with: ../gcc-4.6.1/configure
--enable-languages=c,c++,fortran,objc,ob
j-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared
--enable-libgomp -
-disable-win32-registry --enable-libstdcxx-debug
--enable-version-specific-runti
me-libs --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.6.1 (GCC)
COLLECT_GCC_OPTIONS='-g' '-O0' '-save-temps' '-v' '-I' '.' '-I'
'../../puresrc/g
db' '-I' '../../puresrc/gdb/common' '-I' '../../puresrc/gdb/config' '-D'
'LOCALE
DIR="E:/msys/mingw32/msys/1.0/local/share/locale"' '-D' 'HAVE_CONFIG_H' '-I'
'..
/../puresrc/gdb/../include/opcode' '-I' '../../puresrc/gdb/../opcodes/..'
'-I' '
../../puresrc/gdb/../readline/..' '-I' '../bfd' '-I'
'../../puresrc/gdb/../bfd'
'-I' '../../puresrc/gdb/../include' '-I' '../libdecnumber' '-I'
'../../puresrc/g
db/../libdecnumber' '-I' '../../puresrc/gdb/gnulib' '-I' 'gnulib' '-I'
'c:/Pytho
n27/include' '-I' 'c:/Python27/include' '-Wall'
'-Wdeclaration-after-statement'
'-Wpointer-arith' '-Wformat-nonliteral' '-Wno-pointer-sign' '-Wno-unused'
'-Wunu
sed-value' '-Wunused-function' '-Wno-switch' '-Wno-char-subscripts'
'-Wno-format
' '-Werror' '-c' '-o' 'main.o' '-MT' 'main.o' '-MMD' '-MP' '-MF'
'.deps/main.Tpo
' '-D' 'TARGET_SYSTEM_ROOT=""' '-D' 'TARGET_SYSTEM_ROOT_RELOCATABLE=0' '-D'
'BIN
DIR="E:/msys/mingw32/msys/1.0/local/bin"' '-mtune=i386' '-march=i386'
e:/msys/mingw32/bin/../libexec/gcc/mingw32/4.6.1/cc1.exe -E -quiet -v -I .
-I .
./../puresrc/gdb -I ../../puresrc/gdb/common -I ../../puresrc/gdb/config -I
../.
./puresrc/gdb/../include/opcode -I ../../puresrc/gdb/../opcodes/.. -I
../../pure
src/gdb/../readline/.. -I ../bfd -I ../../puresrc/gdb/../bfd -I
../../puresrc/gd
b/../include -I ../libdecnumber -I ../../puresrc/gdb/../libdecnumber -I
../../pu
resrc/gdb/gnulib -I gnulib -I c:/Python27/include -I c:/Python27/include
-iprefi
x e:\msys\mingw32\bin\../lib/gcc/mingw32/4.6.1/ -MMD main.d -MF
.deps/main.Tpo -
MP -MT main.o -D LOCALEDIR="E:/msys/mingw32/msys/1.0/local/share/locale" -D
HAVE
_CONFIG_H -D TARGET_SYSTEM_ROOT="" -D TARGET_SYSTEM_ROOT_RELOCATABLE=0 -D
BINDIR
="E:/msys/mingw32/msys/1.0/local/bin" ../../puresrc/gdb/main.c -mtune=i386
-marc
h=i386 -Wall -Wdeclaration-after-statement -Wpointer-arith
-Wformat-nonliteral -
Wno-pointer-sign -Wno-unused -Wunused-value -Wunused-function -Wno-switch
-Wno-c
har-subscripts -Wno-format -Werror -g -fworking-directory -O0
-fpch-preprocess -
o main.i

Did you see want happens?
-DBINDIR="/usr/local/bin\"
gets transformed into '-D' 'BINDIR="E:/msys/mingw32/msys/1.0/local/bin"'
inside COLLECT_GCC_OPTIONS!

So that once this compiled gdb executable is put to e:\pas\fpc-2.7.1\gdb\bin
relocate_gdb_directory function doesn't find any
common part between E:/msys/mingw32/msys/1.0/local/bin
and /usr/local/share/gdb
which leads to failure in directory relocation.

I think that moving BINDIR also into config.h
should fix that msys specific failure.

Pierre Muller