From: Stephen L. <sld...@so...> - 2008-02-12 20:36:57
|
Hi all, Here are my working draft on rebuilding gcc-4.2.1-dw2. If there is enough interest I can clean it up and perhaps put it into the mingw wiki. A few questions: - I have only built C & C++. What packages are needed for the other languages? - Does hard links only work on NTFS? - How do you create the binary packages (gcc-core-*, etc) from the install tree? - How do you change the version string? - Does it matter if you build with --prefix=/mingw but finally install it somewhere else? Recompiling MinGW GCC 1. Setting up the environment ============================= x. Decide where to build your packages. You need a directory that is mounted "identically", that is, accessible with the same path under Windows and cygwin/mingw. We'll put the source and build tree there. Here I'll use the directory x:\develop. x. Install MSYS/MinGW. Only the base packages is needed here. I did not install GCC here as it defaults to the 3.x version. Here I assume you installed it under x: \mingw. Mount the build directory under MSYS by editing its /etc/fstab file. x. Install gcc 4.x. Download gcc-4.x from the MinGW release page and untar it to the mingw installation directory. You'll need the core package (gcc), and g++ also to build pthreads. I used the 4.2.1-dw2 version. msys$ cd /mingw msys$ tar zxvf gcc-core-4.2.1-dw2.tar.gz msys$ tar zxvf gcc-g++-4.2.1-dw2.tar.gz msys$ cd /mingw/bin msys$ ln gcc-dw2.exe gcc.exe msys$ ln g++-dw2.exe g++.exe msys$ ln cpp-dw2.exe cpp.exe /* draft: rm c++-dw2.exe mingw32-c++-dw2.exe mingw32-g++-dw2.exe ln g++-dw2.exe c++-dw2.exe ln g++-dw2.exe mingw32-c++-dw2.exe ln g++-dw2.exe mingw32-g++-dw2.exe ln g++-dw2.exe g++.exe ln g++-dw2.exe c++.exe rm gcc-dw2.exe mingw32-gcc-dw2.exe ln mingw32-gcc-4.2.1-dw2.exe gcc-dw2.exe ln mingw32-gcc-4.2.1-dw2.exe mingw32-gcc-dw2.exe ln mingw32-gcc-4.2.1-dw2.exe gcc.exe ln cpp-dw2.exe cpp.exe ln gccbug-dw2 gccbug ln gcov-dw2.exe gcov.exe */ x. Install a minimal cygwin <www.cygwin.com> environment. It is possible to build under MinGW, however the release packages are build under cygwin and I am trying to duplicate the setup used. You'll only need the default install, plus the following packages. Cygwin GCC is not needed. - make (GNU make) - diffutils (for cmp and patch) Cygwin softlinks are unusable under native windows, so we need to disable Cygwin's "ln" command and let gcc's build scripts use "cp" instead. cygwin$ mv /usr/bin/ln /usr/bin/ln-bak Mount the build and mingw directories under cygwin. cygwin$ mkdir /develop cygwin$ mkdir /mingw cygwin$ mount "x:/develop" "/develop" cygwin$ mount "x:/mingw" "/mingw" x. Install pthreads-win32 <http://sourceware.org/pthreads-win32/>. This is needed if you want to build libgomp. Get the pthreads-win32 source from ftp://sourceware.org/pub/pthreads-win32/. I used pthreads-w32-2-8-0-release.tar.gz. Build it under MSYS. You need "-fkeep-inline-functions" otherwise it won't build. msys$ make clean GC msys$ make clean GCE "GCE_CFLAGS += -fkeep-inline-functions" Copy the relevent files to /mingw so libgomp build can find it. (draft: if this doesn't work, use /mingw/mingw32 instead) /mingw/bin: pthreadGC2.dll pthreadGCE2.dll /mingw/include: pthread.h sched.h semaphore.h /mingw/lib: libpthreadGC2.a libpthreadGCE2.a Create a link so gcc can find it: msys$ ln /mingw/lib/libpthreadGCE2 /mingw/lib/libpthread x. Installing ??? (for fortran) x. Installing ??? (for ada) 2. Building GCC =============== Basically, follow gcc-4.2.1-build-dw2-2.sh but use cygwin for the build. Get the source. I used gcc-4.2.1-2-src.tar.gz from MinGW. Unpack it under the build directory. msys$ cd /develop msys$ tar zxvf gcc-4.2.1-2-src.tar.gz Create a directory for building. msys$ mkdir /develop/build Patch libgomp/configure. Replace all lines that read fopen ("conftest.val", "w"); with fopen ("conftest.val", "wb"); To build the -dw2 version: (from gcc-4.2.1-build-dw2-2.sh): msys$ cd /develop/build msys$ rm ../gcc-4.2.1-2-src/gcc/BASE-VER \ ../gcc-4.2.1-2-src/gcc/config/i386/t-mingw32 \ ../gcc-4.2.1-2-src/libstdc ++-v3/config/os/mingw32/x-mingw32 msys$ ln ../gcc-4.2.1-2-src/gcc/BASE-VER-dw2 \ ../gcc-4.2.1-2-src/gcc/BASE-VER \ msys$ ln ../gcc-4.2.1-2-src/gcc/config/i386/t-mingw32dw2 \ ../gcc-4.2.1-2-src/gcc/config/i386/t-mingw32 msys$ ln ../gcc-4.2.1-2-src/libstdc++-v3/config/os/mingw32/x-mingw32dw2 \ ../gcc-4.2.1-2-src/libstdc++-v3/config/os/mingw32/x-mingw32 Switch to cygwin to build. I only build C and C++ for the moment. cygwin$ cd /develop/build cygwin$ ../gcc-4.2.1-2-src/configure --with-gcc --enable-libgomp \ --host=mingw32 --build=mingw32 --target=mingw32 --program-suffix=-dw2 \ --with-arch=i486 --with-tune=generic --disable-werror --prefix=/mingw \ --with-local-prefix=/mingw --enable-threads --disable-nls \ --enable-languages=c,c++ --disable-win32-registry \ --disable-sjlj-exceptions --enable-libstdcxx-debug \ --enable-cxx-flags='-fno-function-sections -fno-data-sections' \ --enable-version-specific-runtime-libs --disable-bootstrap cygwin$ make BOOTCFLAGS="-O2 -D__USE_MINGW_ACCESS" \ CFLAGS="-O2 -D__USE_MINGW_ACCESS" \ CXXFLAGS="-mthreads -O2" \ LDFLAGS="-s -Wl,--stack=0x2000000" 2>err.log 1>out.log 3. Packaging ============ cygwin$ DEST=/develop/install cygwin$ mkdir ${DEST} cygwin$ make prefix=${DEST} install cygwin$ make prefix=${DEST} -C gcc install-shared-libgcc cygwin$ make prefix=${DEST} -C mingw32/libstdc++-v3/ install-shared-libstdc++ ... 4. Cleanup ============ Restore "ln" under cygwin. cygwin$ mv /usr/bin/ln-bak /usr/bin/ln -- Stephen Lee <sld...@so...> |