Bug 42886 - [4.5 Regression] GCC is not relocatable anymore on Windows (mingw32)
Summary: [4.5 Regression] GCC is not relocatable anymore on Windows (mingw32)
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: 4.5.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-27 20:34 UTC by Andriy Syrovenko
Modified: 2010-04-01 15:27 UTC (History)
4 users (show)

See Also:
Host: i386-pc-mingw32
Target: i386-pc-mingw32
Build: i386-pc-mingw32
Known to work: 4.4.0 3.4.2 3.4.5
Known to fail: 4.5.0
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andriy Syrovenko 2010-01-27 20:34:27 UTC
When invoking gcc from where it was installed by 'make install' (C:\MinGW\bin) everything works as expected. But as soon as I move the C:\MinGW directory into some other location standard header files are not looked up at the default locations any more. For example if MinGW directory is moved to C:\DevTools and gcc is invoked from C:\DevTools\MinGW\bin, standard headers are not looked up in the C:\DevTools\MinGW\include directory.

Additionally, localization stops working after the relocation.

To illustrate the problem:

C:\>set PATH=C:\MinGW\bin;%PATH%

C:\>echo "" | cpp -v
Используются внутренние спецификации.
COLLECT_GCC=cpp
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.5.0/lto-wrapper.exe
Целевая архитектура: mingw32
Параметры конфигурации: ../gcc_trunk/configure --enable-languages=c,c++ --disable-sjlj-exceptions --enable-shared --with-dwarf2 --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --prefix=/mingw --build=mingw32
Модель многопоточности: win32
gcc версия 4.5.0 20100122 (experimental) [trunk revision 150484] (GCC)
COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=i386'
 c:/mingw/bin/../libexec/gcc/mingw32/4.5.0/cc1.exe -E -quiet -v -iprefix c:\mingw\bin\../lib/gcc/mingw32/4.5.0/ - -mtune=i386
повторное задание каталога "/mingw/include" проигнорировано
повторное задание каталога "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.5.0/include" проигнорировано
повторное задание каталога "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.5.0/include-fixed" проигнорировано
повторное задание каталога "/mingw/include" проигнорировано
порядок поиска для #include "...":
&#1087;&#1086;&#1088;&#1103;&#1076;&#1086;&#1082; &#1087;&#1086;&#1080;&#1089;&#1082;&#1072; &#1076;&#1083;&#1103; #include <...>:
 c:\mingw\bin\../lib/gcc/mingw32/4.5.0/include
 c:\mingw\bin\../lib/gcc/mingw32/4.5.0/include-fixed
 c:/MinGW/include
 c:/mingw/lib/gcc/../../mingw32/include
&#1082;&#1086;&#1085;&#1077;&#1094; &#1089;&#1087;&#1080;&#1089;&#1082;&#1072; &#1087;&#1086;&#1080;&#1089;&#1082;&#1072;
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "<stdin>"
COMPILER_PATH=c:/mingw/bin/../libexec/gcc/mingw32/4.5.0/;c:/mingw/bin/../libexec/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../../mingw32/bin/
LIBRARY_PATH=c:/mingw/bin/../lib/gcc/mingw32/4.5.0/;c:/mingw/bin/../lib/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../../mingw32/lib/;c:/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../;/mingw/lib/
COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=i386'

C:\>move MinGW C:\DevTools\

C:\>set PATH=C:\DevTools\MinGW\bin;%PATH%

C:\>echo "" | cpp -v
Using built-in specs.
COLLECT_GCC=cpp
COLLECT_LTO_WRAPPER=c:/devtools/mingw/bin/../libexec/gcc/mingw32/4.5.0/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc_trunk/configure --enable-languages=c,c++ --disable-sjlj-exceptions --enable-shared --with-dwarf2 --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --prefix=/mingw --build=mingw32
Thread model: win32
gcc version 4.5.0 20100122 (experimental) [trunk revision 150484] (GCC)
COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=i386'
 c:/devtools/mingw/bin/../libexec/gcc/mingw32/4.5.0/cc1.exe -E -quiet -v -iprefix c:\devtools\mingw\bin\../lib/gcc/mingw32/4.5.0/ - -mtune=i386
ignoring nonexistent directory "c:/MinGW/include"
ignoring nonexistent directory "/mingw/include"
ignoring duplicate directory "c:/devtools/mingw/lib/gcc/../../lib/gcc/mingw32/4.5.0/include"
ignoring duplicate directory "c:/devtools/mingw/lib/gcc/../../lib/gcc/mingw32/4.5.0/include-fixed"
ignoring nonexistent directory "/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
 c:\devtools\mingw\bin\../lib/gcc/mingw32/4.5.0/include
 c:\devtools\mingw\bin\../lib/gcc/mingw32/4.5.0/include-fixed
 c:/devtools/mingw/lib/gcc/../../mingw32/include
End of search list.
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "<stdin>"
COMPILER_PATH=c:/devtools/mingw/bin/../libexec/gcc/mingw32/4.5.0/;c:/devtools/mingw/bin/../libexec/gcc/;c:/devtools/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../../mingw32/bin/
LIBRARY_PATH=c:/devtools/mingw/bin/../lib/gcc/mingw32/4.5.0/;c:/devtools/mingw/bin/../lib/gcc/;c:/devtools/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../../mingw32/lib/;c:/devtools/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../
COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=i386'
Comment 1 nightstrike 2010-03-19 14:25:57 UTC
This is probably due to the way you built GCC.  To have a completely relocatable toolchain, you need to use the --with-sysroot option to configure, and you need to set it equal to prefix or below prefix in the directory structure.  I don't think this is a bug with GCC.
Comment 2 Steven Bosscher 2010-03-20 13:02:46 UTC
Waiting for OP to try suggestion of comment #1.
Comment 3 Andriy Syrovenko 2010-03-21 08:15:35 UTC
(In reply to comment #1)
> This is probably due to the way you built GCC.  To have a completely
> relocatable toolchain, you need to use the --with-sysroot option to configure,
I've just checked out the latest sources from trunk, as well as consulted the previously fetched sources. There are no such option to configure as --with-sysroot. Did you mean --with-build-sysroot?
Comment 4 nightstrike 2010-03-21 14:56:13 UTC
(In reply to comment #3)
> (In reply to comment #1)
> > This is probably due to the way you built GCC.  To have a completely
> > relocatable toolchain, you need to use the --with-sysroot option to configure,
> I've just checked out the latest sources from trunk, as well as consulted the
> previously fetched sources. There are no such option to configure as
> --with-sysroot. Did you mean --with-build-sysroot?
> 

No, --with-build-sysroot is used to specify the location of the sysroot during the build.  --with-sysroot does so for during+after.  So for instance, let's say that I wanted to build a toolchain that would run on a system where the sysroot was located at /opt/sys, but while building it, on my build machine, it's located at /build/sys.  Therefore, I would do --with-build-sysroot=/build/sys --with-sysroot=/opt/sys.

It's explained and documented on this page:
http://gcc.gnu.org/install/configure.html

Scroll down to "--with-sysroot" and you'll see it.  Pay attention to this sentence in the description:
"If the specified directory is a subdirectory of ${exec_prefix}, then it will be found relative to the GCC binaries if the installation tree is moved."

I believe that's what you want.

Note also that you can see the options used to build gcc in your "gcc -v" line in your first post.  In there, it's clear that the toolchain you are using is not relocatable.
Comment 5 Dmitry Gorbachev 2010-03-21 18:00:43 UTC
My GCC (4.4 and 4.5) were configured with the following options: `--build=mingw32 --enable-languages=c,c++ --enable-version-specific-runtime-libs --disable-win32-registry --disable-nls --disable-shared'. I move the GCC directories to, for example, `C:\gcc\', the headers to `C:\gcc\mingw32\include\', the libraries to `C:\gcc\mingw32\lib\'. I don't know how the localization, but everything else seem to work well.
Comment 6 Chen Chen 2010-03-22 01:00:11 UTC
In my recent build
I configured the binutils as:
../src/configure --target=x86_64-w64-mingw32 --enable-targets=x86_64-w64-mingw32,i686-w64-mingw32 --disable-shared --enable-static --disable-nls --with-mpc=/local --with-gmp=/local --with-mpfr=/local --with-ppl=/local --with-cloog=/local --prefix=/mingw64 --with-sysroot=/mingw64 CFLAGS="-O3 -fomit-frame-pointer -pipe -march=k8 -mfpmath=sse -mmmx -m3dnow -m64 -Wa,-march=k8" LDFLAGS="-s -Wl,--as-needed"

and the gcc as:
 ../src/configure --target=x86_64-w64-mingw32 --enable-targets=all --enable-multilib --enable-64bit --prefix=/mingw64 --with-sysroot=/mingw64 --disable-shared --enable-static --disable-nls --enable-version-specific-runtime-libs --with-dwarf --with-mpc=/local --with-mpfr=/local --with-gmp=/local --with-ppl=/local --with-cloog=/local --enable-fully-dynamic-string --enable-languages=c,c++,fortran,java --disable-libgomp --enable-libjava-multilib --with-host-libstdcxx='-lstdc++ -lsupc++' --with-pkgversion='LunarShaddow - for my Helen' CFLAGS='-O3 -fomit-frame-pointer -pipe -march=k8 -mfpmath=sse -mmmx -m3dnow -Wa,-march=k8' LDFLAGS='-s -Wl,--as-needed'

Just omit the optimization options and you'll find the use of prefix and sysroot.
ensure that you use the same sysroot while building binutils.
Comment 7 Richard Biener 2010-03-31 11:52:53 UTC
Back to P3 due to waiting state.
Comment 8 nightstrike 2010-04-01 11:54:02 UTC
I'd recommend closing this as invalid.  We build 12 relocatable toolchains for windows daily for http://mingw-w64.sf.net/

I'm pretty sure it works :)
Comment 9 Chen Chen 2010-04-01 13:48:35 UTC
(In reply to comment #8)
> I'd recommend closing this as invalid.  We build 12 relocatable toolchains for
> windows daily for http://mingw-w64.sf.net/
> 
> I'm pretty sure it works :)
> 

Agree. I've made a bootstrap a week before and copied and merged it with the dev-cpp. Before i did this version i've moved a cross-compiled version from /msys/1.0/mingw64 to /msys/1.0/mingw for pretty look :)
Comment 10 Chen Chen 2010-04-01 13:58:03 UTC
night-strike can i ask a question that had x86_64-w64-mingw32 supported libgcj yet? I failed even explictly --enable-libgcj... and a so-called wiki of mingw-w64 (http://www.cadforte.com/wiki/index.php/Java) said "Java is, unfortunately, not supported in 64-bit by gcc at this time.", i don't know if it's true...
Comment 11 Richard Biener 2010-04-01 14:18:12 UTC
Invalid then.
Comment 12 nightstrike 2010-04-01 15:27:43 UTC
(In reply to comment #10)
> night-strike can i ask a question that had x86_64-w64-mingw32 supported libgcj
> yet? I failed even explictly --enable-libgcj... and a so-called wiki of
> mingw-w64 (http://www.cadforte.com/wiki/index.php/Java) said "Java is,
> unfortunately, not supported in 64-bit by gcc at this time.", i don't know if
> it's true...
> 

This is kind of off topic for this bug, and I invite you to use our resources at mingw-w64.sf.net (mailing list, forum, irc).  As for java, libffi works, and boehm-gc works.  Those are dependencies for java.  I don't know if the in-tree boehm-gc was ever updated from upstream, so you might have to do that manually (the in-tree version was very out of date when we were porting it).  As for libgcj itself.... I never tried to build it.  I can try, and we can work on it if you like.  Please take replies to one of the aforementioned places.  Thanks!