On Wednesday 31 October 2001 05:40, Frank Heckenbach wrote:
Andris Pavenis wrote:
Configuring in p/rts fails when host!=build (for example when building native compiler for DJGPP or MINGW under Linux) as newly built xgcc and xgpc cannot be run on build system. In this case we should run corresponding cross-compiler instead.
Yes, I regularly do cross-compilations, including canadian cross. I set GCC_FOR_TARGET and GPC_FOR_TARGET on the command line, then it works for me. Since command line settings take precendence in make, this will override the default `GPC_FOR_TARGET = ./xgpc -B./'.
I'm not sure if that's how it's supposed to be done, but AFAICS, GCC_FOR_TARGET is not set automatically when configuring for a cross-build. Or did I miss this somehow (or is this different in gcc-2.95.x -- I'm using gcc-2.8.1)?
I used gcc-2.95.3-6 from Mingw website (I merged relative prefix related patches in p/gpc.c). GCC_FOR_TARGET and GPC_FOR_TARGET were set both in environment and command line of top level make. One thing was that I forgot to apply patch for top level Makefile to set GPC_FOR_TARGET and add it to flags to pass to submakes (I have that in my patches for DJGPP, but DJGPP and MINGW both uses patched gcc, so it's easy to forget something)
Included patch is tested only for --build=i686-pc-linux-gnu, --host=i586-mingw32msvc --target=i586-mingw32msvc
Andris
--- gpc-20010924/p/Make-lang.in~1 Mon Sep 24 19:59:48 2001 +++ gpc-20010924/p/Make-lang.in Tue Oct 30 17:57:24 2001 @@ -154,8 +154,12 @@ ADD_RTS_PARENT_DIR = sed -e 's,-B([^/][^:]),-B../../\1,g;s,^([^/][^:]),../../\1,'
# The ' ' is there so, e.g., `-B.' will be replaced by ADD_RTS_PARENT_DIR -RTS_COMPILERS = CC="`echo $(GCC_FOR_TARGET)' ' | $(ADD_RTS_PARENT_DIR)`" \ - PC="`echo $(GPC_FOR_TARGET)' ' | $(ADD_RTS_PARENT_DIR)`" +RTS_COMPILERS = CC="`if test "$(build_canonical)" = "$(host_canonical)" ; then \ + echo $(GCC_FOR_TARGET)' ' | $(ADD_RTS_PARENT_DIR); \
else echo $(GCC_FOR_TARGET); fi`" \
PC="`if test \"$(build_canonical)\" =
"$(host_canonical)" ; then \ + echo $(GPC_FOR_TARGET)' ' | $(ADD_RTS_PARENT_DIR);\
else echo $(GPC_FOR_TARGET); fi`"
GPC_GENERATED_SRC = \ $(srcdir)/p/parse.c \
I don't quite understand what this patch does. AFAICS, it skips $(ADD_RTS_PARENT_DIR) in a cross-build. But $(ADD_RTS_PARENT_DIR) only adds the necessary ../.. to relative paths (since the configure and make of the RTS change to p/rts), and leaves absolute paths unchanged (at least this is what it's supposed to do, unless there's a mistake in the regex).
It skips $(ADD_RTS_PARENT_DIR) for Canadian-cross builds only. In this case we should not try to run newly built compilers as they are intended to be run on host but not the build system.
Anyway perhaps more detailed tests are needed.
So, how should this solve the problem if gpc is `./xgpc -B./'? It would not set GPC_FOR_TARGET to <prefix>/bin/i586-mingw32msvc-gpc, and it would omit the ../../, so it searches for xgpc in the p/rts build directory!?
Since it works for you, I must be missing something ...
I tried to build GPC for MINGW. It seems to work after some hacking. But there seems to be more problems. Do You know somebody messing with building GPC for MINGW earlier? Mailing list archives search didn't work for me, so I'm asking that.
Andris