Compiling GCC for coLinix's gcc, Windows Cygwin's gcc and Windows Msys (MinGW) gcc
Introduction[]
This procedure is NOT recommended for almost everyone, it is complicated !!!
You will need to increase coLinux's memory to at least 512 MB and have a swap file at least that big. You will need to increase your coLinux partition to at least 8 GB (and that would be tight).
You will want to apt-get gcc 4.1.2 but can use gcc-3.4.4 or even 3.3.5 .
You might want to get gtk installed if you intend to compile all the languages for SVN gcc-4_2-branch (prerelease) but you only need to use "--enable-languages=c,ada,c++", if you don't add Ada to the list you will break your ada compiler. You could re-install the old gcc after you install gcc 4.2.0 and then use "export CC" and "export CXX" to specify the 4.2.0 version when compiling coLinux daemons and the Linux kernel.
You will probably end up downloading a few 100 MB's of files. It can take a smart / fast person a week to get everything setup and working correct.
If you feel the need to click the [BACK] button - now is the time to do it ...
Recommended steps to build GCC and coLinux from source are written in doc/building in your coLinux source, you will find also here in wiki.
Gentoo users[]
Tip for Gentoo users, add gcc:4.2 to your world file and emerge -auDN world. This way you have both versions of gcc working side-by-side: gcc to compile Gentoo packages and gcc to compile coLinux. To add gcc:4.2 to your world file:
# echo "sys-devel/gcc:4.2" >> /var/lib/portage/world # emerge -auDN world
Once gcc:4.2 is installed on your system, use gcc-config to switch compilers. gcc-config -l will list your available gcc compilers. gcc-config 1 will switch to the first compiler, gcc-config 2 to the 2nd, etc:
# gcc-config -l # gcc-config 1
Of course you want gcc:4.2 to compile coLinux.
Note: I currently am able to compile coLinux flawlessly with gcc-4.4.4 so the requirement of 4.2 may be outdated.
Expert[]
Download coLinux source. Compile it under the coLinux shell (not cygwin).
For enjoyable compiling under coLinux start Cygwin's X11 and then start xterm under coLinux with a script like this (alter it as needed!):
#!/bin/sh echo Starting Xterm export DISPLAY=192.168.37.20:0 xterm -bg black -fg white -fa Arial -fs 12 -geometry 120x32+15+5 \ -title "coLinux Xterm" -sb -rightbar -sl 10000 +cm +bdc
Download and install gcc-4_2-branch (the SVN is quite good and almost every week has a working version - use "make -i check" to test).
Recompile coLinux by simply re-making after installing gcc-4.2.0. The build scripts will see that you already downloaded and installed the required files and won't detect gcc-4.2.0 (but WILL use it) after you do this:
Use nano to edit bin/build-common.sh and change this line:
GCC_VERSION="3.4.5"
To this:
GCC_VERSION="4.2.0"
That is all you need to do to trick the scripts to use the newly installed GCC (after you have already ran them successfully once).
You need to "cp System.map /boot" to remove one message from startup logs.
Tips for altering the kernel configuration[]
More info appears in the rest of this doc but here are a few tips.
You can configure your kernel to accept nearly everything but follow the advice in the "Building Cooperative Linux" documentation included with the source code.
Warning: Don't enable device drivers with direct hardware access (ISA-, PCI- or VL-Bus) and don't change cpu specific configs. This will likely crash your system. |
Don't enable "Use register arguments" (CONFIG_REGPARM) in the "Processor types and features" section of .config - You are able to do so since it is not locked out. Your computer will re-boot instantly when you attempt to start coLinux.
Many changes to the coLinux daemons (that I'd like to see) are needed to use that feature. It would speed things up with GCC 4.x.
CoLinux kernel 2.6.22 is usable with regparms. This is not a CONFIG option, it is permanently enabled in Linux Kernel in file arch/i386/Makefile now.
I have compiled the kernel and clicked-on almost every feature and installed a lot of programs. The kernel is not crashing, everything works well. Follow these instructions carefully (where they don't have mistakes) and do what you should where these instructions have mis-typing and you will have the newest version of coLinux (with almost the newest kernel) working perfectly.
When altering configuration options you must set CRYPTO_CRC32C in .config to "Y" and NOT "M" (or "N") to avoid the boot message "crc32c: Unknown symbol crc32c_le". This occurs before modules are loaded so you must choose "Y".
I tried SMP (for the kernel) but my system rebooted immediatly. I used nano to edit .config and tried adding SMP=Y, NR_CPUS=8, SCHED_SMT=Y, and SCHED_MC=Y (right after HPET_TIMER and before PREEMPT_NONE).
Added these lines to .config
# # Processor type and features # CONFIG_SMP=y ... CONFIG_HPET_TIMER=y CONFIG_NR_CPUS=8 CONFIG_SCHED_SMT=y CONFIG_SCHED_MC=y
CoLinux driver (on windows host side) only supports one CPU. And only the first CPU, if you have more as one. You should leave CONFIG_SMP disabled.
Getting SMP to work - advice for everyone[]
On older versions of coLinux the colinux-daemon.exe program only runs on a single processor in a Dual-Core system. With 0.8.0 you can allow it to use BOTH cores by doing this to your colinux.bat file:
set COLINUX_CONSOLE_FONT=:14 set COLINUX_NO_SMP_WORKAROUND=Y colinux-daemon.exe -v 1 @coLinux.conf %1 %2 %3 %4 -t fltk
That gives you bigger fonts, Dual-Core, and multiple logins. To login on tty1 just login, it is the default. To login on tty2 hit CTRL-F2 - you have 6 tty's to use.
CTRL-F7 gives the background terminal. You can swap back to tty1 by hitting CTRL-F1 and switch between the different terminals at any time. Log in as root or different users on each one.
You can run "top" in one of the windows and switch there to get running stats. You can run aptitude in another while updating coLinux X11 programs (since you don't want to do some X11 updates under X11 - you'd disconnect yourself). All that can go on in the background while you use the huge/wonderful xterm window shown in the script above.
Note: multiple logins were available with older version of coLinux as well in FLTK console. To switch between terminals, use ALT-F1, ALT-F2, up-to ALT-F6. Alternatively, you can use ALT-RightArrow (ALT-LeftArrow) to switch to the next(previous) terminal. To paste into an FLTK coColinux console, use the combination Windows-V (Windows key and the V key). As of now, there's no easy way to copy from coLinux FLTK console to Windows.
coLinux author's advice[]
I corrected the building documentation and posted it on this page: BuildingColinux0.8.0
If you need no more help then read no more - your ready to go. Come back when your stuck :) !
Rambling notes[]
These notes will help to guide you. They were written over a period of weeks and MIGHT conflict in some parts when I figured out a better way to do something and went back to make changes (but did not catch all the changes needed ;).
Since you are an expert you should be fine. After compiling everything you should be able to type this and get this message (or similar):
colinux:/opt/colinux/build/linux-2.6.17-build# dmesg | grep gcc
Linux version 2.6.17-co-0.8.0 (root@colinux) (gcc version 4.2.0 20070323 (prerelease)) #2 PREEMPT Tue Apr 10 17:05:16 PDT 2007
Onward[]
The coLinux people use MinGW gcc for part of their compile. The "building.txt" docs say you must use the same version of the compiler to build the daemon and the Linux kernel (on the internal coLinux side) otherwise the daemon will halt.
Instead of trying to find matching old versions of gcc for the three (four?) different platforms (one for Cygwin, one for MinGW, one for coLinux and maybe the Linux MinGW gcc version) why not build gcc-4_2-branch (prerelease) CVS version instead. Why not - because it is difficult to do. It is worth it because there are so many new features you can hardly afford to be without AND when you run "make check" it gives FEWER errors than the older ('stable?') versions!
If you are cross-compiling (or cross-object-format compiling, EG: Windows' object format is coff-like "pe" and Linux object format is often "elf") then you might want to compile a Cygwin elf object format compiler (i686-none-elf) to enable the extra features that elf provides (even for Windows) like TLS (that works), which a few unix programs rely on (and thus are harder to port to Windows).
Get GCC 4.2.0 (prerelease)[]
Lets start with the easy compile of gcc-4_2-branch (inside coLinux). Use Tortoise SVN (or Cygwin's SVN) to get gcc-4_2-branch from gnu.org's site. Un-tar it under Windows. Use coLinux's configuration file (not for the source code, for the daemon.exe) to set "cofs0=c:\" so when you start coLinux you can mount your Windows drive and "cp -r" the source into a coLinux filesystem (this saves downloading it twice). You will want to compile through Xterm's Bash shell to use a bigger screen and have scroll-back available. You'll need X11 setup under Cygwin to do this.
It is easier to download GCC to your Windows directory and save it there later transfering it to your coLinux directories than it would be to do it the other way since you'll likely want to try out gcc-4.2.0-branch under Windows (with Cygwin) first.
You may want to do it the other way (download it to your coLinux drive with "svn" and then copy it through a cobd'd mount onto your Windows directory) since it is easier to compile under Linux. If you only enable two languages then you'll have less to fix (and a lousy version of a great toolchain). If your that lame just apt-get gcc 4.1.2 pre-compiled!
After copying gcc from a Windows directory to a coLinux directory you will need to "chmod 755" the scripts called configure *.sh *.pl compile config.guess config.sub config.rpath depcomp missing mkdep mkinstalldirs move-if-change libtool-ldflags ltconfig symlink-tree contrib/test_summary - I hope that is all.
With Windows the Bash shell doesn't care if they are chmod'd properly but Linux does and will say you don't have permission to execute (and thus break the make). This is another reason to "svn" it to the Linux side and then "cp" it through the cobd'd mount.
You will find many differences with gcc-4.2.0 - study carefully what is happening. It is not easy and not for beginners. It is worth doing because the new tools have features like stack smashing protection and mudflap debugging and Gomp (like SMP). There are nearly twice as many options to play with over the old 3.x series.
... (Note: These dots mean I was going to add something in here - probably more rambling ;( ).
When using the newest gcc toolchain and typing ./config.guess the target is called i686-pc-linux-gnu but the installed Debian version has a few different pieces put together. The best I can tell they were configured as i386-linux and i486-linux.
When you run ./configure do NOT set the --host let configure figure it out - that is what it does - if it can't then report that as a bug (unless your linux is broken).
The Debian (coLinux) gcc is Configured with (all one line): ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --enable-__cxa_atexit --with-system-zlib --enable-nls --without-included-gettext --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gci486-linux
You will want to type "gcc -v" to find out what parameters your system was configured with
and duplicate that when you compile the newest gcc-4_2-branch SVN version (unless you know
what you are doing and would like to add or subtract something).
There have been many changes in the last few years. Language f77 is now called fortran and you can remove pascal from --enable-languages, it is no longer part of the main toolchain. To build ada you need a pre-existing version of ada installed - so install one or remove it. Change --with-gxx-include-dir=/usr/include/c++/3.3 to --with-gxx-include-dir=/usr/include/c++/4.2
Now you should save the resulting command to a file and name it something like makegcc.sh then type chmod 755 makegcc.sh so it is executable (you don't need to do that for Window but you do need to do it for linux).
(Old comment "FIX THESE INSTRUCTIONS")
(New comment - I did go back and do a bit of fixing here, carry on).
Try compiling gcc4_2-branch with this:
./coLinux.bat
cd /opt/gcc-4_2-build
/mnt/windows/makecygwin/gcc-4_2-branch/configure -v --enable-languages=c,c++,java,fortran,objc --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/4.2 --enable-shared --enable-__cxa_atexit --with-system-zlib --enable-nls --without-included-gettext --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gci486-linux
Don't forget to "apt-get install mpfr gmp texinfo"
cp -r /mnt/windows/makecygwin/gcc-4_2-branch /opt/gcc-4_2-branch
../gcc-4_2-branch/configure -v --enable-languages=c,c++,java,fortran,objc --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/4.2 --enable-shared --enable-__cxa_atexit --with-system-zlib --enable-nls --without-included-gettext --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gci486-linux
Currently using: ../gcc-4_2-branch/configure --verbose --enable-languages=c,c++,objc,obj-c++ --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/4.2 --enable-libstdcxx-debug --enable-concept-checks --enable-shared --enable-__cxa_atexit --enable-initfini-array --enable-version-specific-runtime-libs --enable-libssp --enable-libmudflap --enable-libgomp --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-decimal-float --with-long-double-128 --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --with-stabs
Now using: ../gcc-4_2-branch/configure --verbose --enable-languages=c,ada,c++,fortran,java,objc,obj-c++ --prefix=/usr --enable-objc-gc --enable-concept-checks --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/4.2 --enable-libstdcxx-debug --enable-shared --enable-__cxa_atexit --enable-initfini-array --enable-threads=posix --enable-version-specific-runtime-libs --enable-libssp --enable-libmudflap --enable-libgomp --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-decimal-float --with-long-double-128 --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --with-stabs --enable-sjlj-exceptions --enable-hash-synchronization --enable-stage1-checking=all
Now run the "makegcc.sh" file you created (which runs configure with a lengthy set of parameters). Type "make bootstrap". Sit tight because the make will likely stop shortly, there are a few fixes shown at the bottom. Exactly what you must fix depends on which version of Linux and which version of gcc (and thus which OS and compiler ".h" files) you have. You may well need to type "make -i -k bootstrap" to push your way through. Java may not work.
The "C" compiler has MANY new features and optimizations (and nearly no errors) so it is well worth getting. The fortran compiler is almost perfect. Everything passes more tests and has more features than your old gcc 3.4.
Your compiler will be different under linux (with elf object file format) than it is under Windows (a coff-like "pe" format). Using Elf enables many more features (like tls) and it is worth recompiling your whole toolchain to use Elf format with Cygwin under Windows. You can hack dlltool to work with Elf object files so your makefiles won't break. Now you can easily compile even more linux programs with cygwin (using elf format) than you can with "pe" objects.
Using QEmu (and it's accelerator) you can run unix at nearly full speed. When coLinux docs (or wiki) mentions "cross-compiling" it is "cross-object-format" and OFTEN "cross-ABI" (your still using the same processor). When QEmu uses "cross-compiling" it is OFTEN "cross-object-format" AND also "cross-processor" AND "cross-ABI" depending on the target platform.
You can compile gdb with --target=i686-pc-elf and run Cygwin Windows programs (in Elf object format) under Windows at full speed (obviously with the ability to debug too). You can write a batch file and use Window's file association to get debug to execute the Elf objects. When the program you wrote works OK you can simply copy the source code to coLinux and recompile it. This makes porting back and forth less painful and makes working with mixed platform executables (like coLinux) easier too.
You might need to fixup gcc-4_2-build/prev-gcc/configargs.h so configuration_arguments is correct and
re-build the last stage by typing "make bootstrap" again. Currently the script that builds this file
is broken and it is likely to have this line as:
static const char configuration_arguments[] = "../gcc-4_2-branch/configure linux gnu";
Depending on what arguments you start configure with it with it ought to say something different.
Change it to remove the leading "../xyz/configure ..." (since you are modifying it anyways) to simply read "configure ..." - it should be (almost) the same as your origonal "gcc -v" output.
You can have the "--enable-languages=" part be similar to the origonal so you don't lose pascal or ada even if you won't be compiling and installing these languages.
Origonal: --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang New: --enable-languages=c,c++,java,fortran,pascal,objc,ada (you don't need treelang).
If the configure_default_options[] structure says "cpu", "generic" you might want to put your cpu there.
After making gcc you should exit coLinux and save your filesystem file to keep a backup copy. Restart coLinux and then type "make install-gcc" if you don't want all the languages installed. Check that it works OK and that you won't need to type "make -i -k install" .
Tip: use "make install > install.log" since coLinux has a small screen and no scrollback.
If you have trouble with the stage comparisons (and are too lazy to find out why) fix with this:
echo timestamp > compare
Now type "make bootstrap" again and the third stage will complete.
Running "make check" (prior to make install) is a good way to see that things are reasonable. Running it AFTER installing is the only way to prove that it really is OK - you'll get different results for some of the tests (since not all the scripts are fully debugged).
When I run "make check-gcc" I get these impressive results for gcc 4.2.0 20070323 (prerelease):
= == gcc Summary == = Number of expected passes 41944 Number of unexpected failures 6 Number of expected failures 112 Number of untested testcases 28 Number of unsupported tests 291
Those result are better than previous versions and with all the new features and better optimization it is worth having. Unfortunatley Java has quite a few errors, not a lot more than other releases but more than I am comfortable with. Fortran has also come a long way since version 3.3 as has the c++ compiler. It makes sense to use 4.2 even though it is not officially released yet. Version 4.1.1 has more errors and no gomp.
Now you can type "make install" - possibly "make -i install" (if you tried Java and could not get it to compile). Once it is installed remove all the files (except the "makegcc.sh" you wrote) and then type "make bootstrap" again. Now use apt-get to re-install the old gcc toolchain. Now type "make install" to re-install 4.2 and it is now guaranteed to work (if you leave Java off your --enable-languages list). It is possible to use prefixing to have both toolchains at the same time if you wish. The reason to compile java (and indeed have everything turned on) the first time is to get the headers and libs installed.
To re-iterate:
1): Use apt-get to obtain the newest gcc toolchain available (it will be old).
2): Compile gcc-4.2-branch (CVS)
3): Exit coLinux and save a copy of your root filesystem, then restart coLinux.
4): Install gcc-4.2-branch over the old tools and compile gcc-4.2 again (with working options).
5): Use apt-get to put the old tools in place (and fix breakage in the event of a faulty install).
6): Install gcc-4.2-branch (with working options) again.
That will give you old (but "working") Java (any breakage not the fault of 4.2 tools) and the rest of your tools will be new. You can not do this with Ada since it needs to be compiled with the same version of gcc throughout it's compilation (of course you can use old Ada and gcc to compile new Ada - you just can't use gcc-4.2 compiled Ada tools with gcc-3.3 Ada).
You may notice that the first time you compile gcc-4.2 with gcc-3.3 it compiles FAST. Then after you install gcc-4.2 and compile gcc-4.2 again it seems slower. This is because gcc-4.2 is thinking more and making better code choices. You can compile with -O0 to speed up the compile (and slow the resulting program). You can compile with -O3 and get crash free code (assuming there are no bugs) since the "c" compiler works very well. With the ssp and mudflap librarys you can protect your code from problems and debug coding errors.
You might want to clean /usr/bin up a bit. I don't understand what they tried to accomplish.
They have link files called i386-linux-gcc and i486-linux-gcc which both link to gcc-3.3 why?
They do this for part of the toolchain but not all of it. If a configure script detects the partial toolchain and decides that is going to be "gcc" (for example) then you'll get breakage.
Configure scripts that do that sort of thing (check prefixes to "gcc") can be found in binutils and when configuring with --target and --host set differently (building a cross compiler).
I suggest you look at the files with this command "ls -l /usr/bin/i?86*" and rename all those i386-* files (that are not present as i486-* versions) to files called i486-* so if a configure script detects the prefixes then you'll have a full chain. Remove the remaining i386-* files.
Now you should be able to type "gcc-3.3 -v" "i486-linux-gcc -v" and "gcc -v" and they should look SIMILAR, but obviously not all the same - if you chose the same configure commands. If you added a few new features then those parts will be different. This gives you your old toolchain and the newest gcc gcc-4_2-branch (prerelease) together without using prefixing for gcc-4.2.0.
Here is a directory listing example:
ls -l /usr/bin/*gcc*
-rwxr-xr-x 3 root root 420123 Mar 20 18:20 /usr/bin/gcc
-rwxr-xr-x 1 root root 85196 May 24 2005 /usr/bin/gcc-3.3
-rwxr-xr-x 1 root root 85004 Aug 5 2006 /usr/bin/gcc-3.4
-rwxr-xr-x 1 root root 15848 Mar 27 18:20 /usr/bin/gccbug
-rwxr-xr-x 1 root root 16056 May 24 2005 /usr/bin/gccbug-3.3
-rwxr-xr-x 1 root root 16204 Aug 5 2006 /usr/bin/gccbug-3.4
lrwxrwxrwx 1 root root 7 Mar 20 18:21 /usr/bin/gnatgcc -> gcc-3.4
lrwxrwxrwx 1 root root 7 Mar 20 12:41 /usr/bin/i386-linux-gcc-3.3 -> gcc-3.3
lrwxrwxrwx 1 root root 7 Mar 20 18:21 /usr/bin/i386-linux-gcc-3.4 -> gcc-3.4
lrwxrwxrwx 1 root root 7 Mar 19 2:41 /usr/bin/i486-linux-gcc -> gcc-3.3
lrwxrwxrwx 1 root root 7 Mar 19 12:41 /usr/bin/i486-linux-gcc-3.3 -> gcc-3.3
lrwxrwxrwx 1 root root 7 Mar 19 18:21 /usr/bin/i486-linux-gcc-3.4 -> gcc-3.4
-rwxr-xr-x 2 root root 81644 Feb 6 2005 /usr/bin/i586-mingw32msvc-gcc
-rwxr-xr-x 2 root root 81644 Feb 6 2005 /usr/bin/i586-mingw32msvc-gcc-3.4.2
-rwxr-xr-x 1 root root 15888 Feb 6 2005 /usr/bin/i586-mingw32msvc-gccbug
-rwxr-xr-x 3 root root 420123 Mar 20 18:20 /usr/bin/i686-pc-linux-gnu-gcc
-rwxr-xr-x 3 root root 420123 Mar 20 18:20 /usr/bin/i686-pc-linux-gnu-gcc-4.2.0
Notice you have:
lrwxrwxrwx 1 root root 7 Mar 20 12:41 /usr/bin/i386-linux-gcc-3.3 -> gcc-3.3
lrwxrwxrwx 1 root root 7 Mar 20 18:21 /usr/bin/i386-linux-gcc-3.4 -> gcc-3.4
lrwxrwxrwx 1 root root 7 Mar 19 2:41 /usr/bin/i486-linux-gcc -> gcc-3.3
lrwxrwxrwx 1 root root 7 Mar 19 12:41 /usr/bin/i486-linux-gcc-3.3 -> gcc-3.3
lrwxrwxrwx 1 root root 7 Mar 19 18:21 /usr/bin/i486-linux-gcc-3.4 -> gcc-3.4
There is a "/usr/bin/i486-linux-gcc -> gcc-3.3" but no "/usr/bin/i386-linux-gcc -> gcc-3.3". So my suggestion is to rename all the "/usr/bin/i386-*" files (that do NOT already have a "/usr/bin/i486-*" file) into "/usr/bin/i486-*" files. There are very few "i386" files to rename (or delete) so it is easier than making all the "i486" files into "i386" files.
Be sure to fix your "info" command links to point to your new gcc info files.
Type "ls -l /usr/share/info/gcc*" and check what it says for gcc.info.gz, if it is this: lrwxrwxrwx 1 root root 15 Mar 20 2:41 gcc.info.gz -> gcc-3.3.info.gz
then when you type "info gcc" you probably will not get the 4.2.0 info file.
Be sure you used "apt-get install texinfo" to install makeinfo otherwise your Makefile will use "gcc-4_2-branch/missing " instead of "makeinfo" and you won't have new info files.
Check by typing "info gcc" and "info gccint" - both should say 4.2.0 in the first paragraph.
MinGW gcc-4_2-branch[]
These instructions are for the MinGW Gnu gcc toolchain. They are not for Cygming.
Cygming is when you use Cygwin gcc with the parameter -mno-cygwin to produce files that are similar (but not the same) as if you had used MinGW's gcc, they are not completly compatable. The libraries, header files, ABI and the interaction with Windows (MinGW can use "DOS" paths EG: C:\file). are all different.
Many programs for MinGW can be compiled with Cygwin by using the -mno-cygwin parameter; but not all programs. Similarly many Linux programs can be compiled with Cygwin, but not all Linux programs. If you really are required to use MinGW then you do not want to use Cygwin. If you could use Cygwin it is a good idea to try since it is more up to date. MinGW produces better standalone (no DLLs) programs than Cygwin.
Get MinGW from this site:
About MinGW - Minimalist GNU for Windows https://sourceforge.net/project/showfiles.php?group_id=2435
Get the Installer:
MingW Installer - like Cygwin's setup.exe http://downloads.sourceforge.net/mingw/MinGW-5.1.3.exe?modtime=1168794334&big_mirror=1
Download the "current" version (don't choose "previous" since it is older and the
installer doesn't let you go back and change your choice once you've downloaded).
You probably only need "c" and "c++" but you can get the other languages too.
_IF_ you already have MinGW installed then choose that directory instead of the installer's choice of "c:\mingw" (IE: you might have to use "c:\msys\1.0\mingw"). Download the files.
Start the MinGW Bash shell (not the Cygwin Bash shell - use MinGW and Msys).
Don't build in your source directory - use a different directory.
Run "../src/configure" with parameters obtained from "/mingw/bin/gcc -v" (hopefully it is gcc 3.4.5, since that is the newest MinGW gcc commonly available).
You might want to try enabling every language for the first attempt at compiling to get a gcc.exe driver file that will support "dropping in" of MinGW languages without having to compile 4.2.0 again. All languages are not likely to build with MinGW (or even Cygwin, depending on what additional features you choose - the Linux build will work a bit better since there are more people with Linux systems working on gcc-4.2.0). Then you can drop-in an older Java version that you were able to compile and gcc-4.2.0 will then call Java from the 3.4.5 version.
Here is a command line that will compile without error (after a few small fixes):
$ gcc -v Using built-in specs. Target: i686-pc-mingw32 Configured with: ../gcc-4_2-branch/configure --verbose --prefix=/mingw --disable-werror --enable-threads --disable-nls --enable-languages=c,c++,objc,obj-c++ --disable-win32-registry --disable-shared --enable-sjlj-exceptions --without-x --enable-hash-synchronization --enable-libstdcxx-debug Thread model: win32 gcc version 4.2.0 20070323 (prerelease)
The configuration shown above will work without fixing the Makefile. You only
need to add a null function in ../gcc-4_2-branch/gcc/unwind-sjlj.c to fix the
undefined function __w32_sharedptr_initialize.
After this line:
#ifdef __USING_SJLJ_EXCEPTIONS__
Add this:
#ifdef __MINGW32__ /* c++ mangles this as __Z25_w32_sharedptr_initializev */ #ifdef __cplusplus extern "C" { #endif void __w32_sharedptr_initialize (void); /* c++ would give a warning about no prototype */ void __w32_sharedptr_initialize (void) {} #ifdef __cplusplus } #endif #endif /* __MINGW32__ */
After configuration is finished you will likely have to fix the Makefile. Look at the way the stages are written after running ./configure on the gcc-4.1.1 source (you MIGHT be able to Google it or just web-CVS the Makefile.in file for 4.1.1). Yes, annoying!
Now re-write the stages for the gcc-4_2-branch Makefile (in your 'building' directory, not the source directory - where you ran ./configure). This is not neccesary to compile under Linux since the Makefile and scripts all work 'fairly' well there but break under Windows with the "make.exe" and "bash.exe" that are used (along with the OS and it's difference in 'links' ln.exe). Figure that out and on to the next problem. :)
You will need to alter occurances of the word "ln " (with space after makes it easier to find) and change to "$(LN) ", then look for the word "LN" (all caps) near the top of the makefile. You don't want to use MinGW's "ln", you want to use Cygwin's. :)
Change the makefile's definition of LN from "ln" to "/c/cygwin/bin/ln" (or wherever the MinGW Bash shell thinks that Cygwin's "ln" is). Add a definition below that for "RM" by copying what you did for "LN" (the "LN" definition would already be there and need to be changed, the "RM" definition would NOT be there and need to be written from scratch).
Now go through the makefile and change the makefile's occurances of the word "rm" to "$(RM)". You also what to fix the words "missing Makeinfo" and change it to Cygwin's Makeinfo (or compile and install Makeinfo for MinGW). It is easy to use Cygwin's accessory tools but you must use MinGW's gcc toolchain (to compile a "TRUE" MinGW program).
Part of the Makefile will look like this when fixed:
#LN = ln LN = /c/cygwin/bin/ln LN_S = cp -p RM = /c/cygwin/bin/rm ... BISON = /c/cygwin/bin/bison YACC = /c/cygwin/bin/bison -y FLEX = /c/cygwin/bin/flex LEX = /c/cygwin/bin/flex #M4 = m4 M4 = /c/cygwin/bin/m4 #MAKEINFO = /c/makecygwin/gcc-4_2-branch/missing makeinfo MAKEINFO = /c/cygwin/bin/makeinfo EXPECT = /c/cygwin/bin/expect RUNTEST = /c/cygwin/bin/runtest
You may still get Makefile breakage - complaints about no g++ compiler. If that occurs then alter the main Makefile to compile more languages on the first stage.
Type "cd stage1-gcc; make restage1" and that should re-do stage1 and create a gcc.exe that knows there is a g++ compiler as part of the chain. Here is the makefile fix:
# Selection of languages to be made. #CONFIG_LANGUAGES = CONFIG_LANGUAGES = ada c++ fortran java objc obj-c++ LANGUAGES = c gcov$(exeext) gcov-dump$(exeext) $(CONFIG_LANGUAGES) # Selection of languages to be made during stage1 build. #BOOT_LANGUAGES = c ada BOOT_LANGUAGES = c
Sometimes CONFIG_LANGUAGES gets set to blank and then c++ can't be compiled with the completed gcc driver. Set it as shown above (so you can add languages later). For BOOT_LANGUAGES you would only want "c" (unless you have a pre-exisiting version of Ada installed - needed to compile 4.2.0 Ada) but you can also have the other "c"-like languages (c++, objc, and obj-c++) since they can be compiled on the first pass.
Now you can type "cd ..;make bootstrap" and start it up again (with g++ supported).
I still got breakage when it got to the i686-pc-mingw/libstdc++-v3 and the i686-pc-mingw/libobjc directories - first no g++ (which I fix above) then no objc compiler.
I fixed this by renaming gcc/xgcc.exe to gcc/xgcc-orig.exe and copying the file /mingw/bin/gcc.exe to gcc/xgcc.exe - then MinGW-3.4.5 gcc was running the gcc-4_2-branch toolchain. Keep both a copy of xgcc-mingw.exe (MinGW's) and xgcc-orig.exe (4.2.0's) along with a file called xgcc.exe (of either version. Then just type "cp gcc/xgcc-mingw.exe gcc/xgcc.exe" or "cp gcc/xgcc-orig.exe gcc/xgcc.exe" (use up-arrow to go back in bash history) to switch xgcc's.
Only do this for the libraries that require this hack and re-name the xgcc.exe back for the other parts of the compile. Yes this is annoying - you could pick through the source code and fix it, then file a bug report - much appreciated.
Don't forget to save a copy of the MinGW gcc.exe in case you install gcc 4.2.0 over your mingw directory and wind up breaking your compiler for other languages.
You will likely have to go into the gcc directory and edit the Makefile there (after it is created) and fix the line that says this:
POD2MAN = pod2man --center="GNU" --release="gcc-$(version)"
Change it to: POD2MAN = /c/cygwin/bin/pod2man --center="GNU" --release="gcc-$(version)"
After using "make -i -k bootstrap" and getting as much made as you can then
type "make -i -k info" to check that the info files are all made.
Now type "make -i -k install" and then go back and check that all the .exe's and .la / .a files are in the correct locations. Yes, annoying - but wait.
Now rename your build directory (to save a copy) and create another build directory with the same name you used before. Go into the backup directory and select the oldest files (IE: Makefile, config.status and serdep.tmp) and copy them to the new build directory.
Re-check to make sure gcc-4.2.0 is installed correctly EXCEPT use MinGW's gcc.exe for the file called /msys/1.0/mingw/bin/gcc.exe .
Now (after installing 4.2.0) when you type gcc -v it should say you are using gcc 3.4.5 but gcc will call the 4.2.0 tools when you re-make gcc-4.2.0 the second time. If you compile a file using the gcc -v option the driver (gcc) will print a message that it is 3.4.5 but that the tools it is calling are version 4.2.0. The reason to install and recompile is so that MinGW's system headers and libraries are replaced (in some cases) by the gcc-4_2-branch version headers and libraries, this will enable more features during configure.
Re-apply all the fixes mentioned above (like flex, bison, m4, pod2man) and anything else you had to do when you typed "make bootstrap". The second time you can simply type "make" in MinGW bash (since your already bootstrapped).
Now you should have a correct MinGW gcc 4.2.0 when make finishes. Now type "make install" again. Now you can type "make check" to test it. If you don't install it before checking it you can't be certain that the expect scripts are all correct and using the proper compiler (sometimes they break. Since the installed version (gcc.exe and other files) and the tested version (xgcc.exe and other files) are the same the expect scripts can't fail.
You just need to hope that when you downloaded the SVN files that you picked a good day to do it - rarely they are broken, just go back a week to get a working version (or check the build logs to see if someone ran PROPER tests).
To fix c++ linking error: "__w32_sharedptr_initialize" you may need:
http://gcc.gnu.org/svn/gcc/branches/csl-gxxpro-3_4-branch/gcc/unwind-sjlj.c
http://gcc.gnu.org/svn/gcc/branches/csl-gxxpro-3_4-branch/gcc/unwind.h (no?)
http://dev.gentoo.org/~kugelfang/patches/01_all_gcc4-cell-support-for-gcc-4.0.2.patch
http://gcc.gnu.org/svn/gcc/branches/csl-gxxpro-3_4-branch/gcc/config/i386/w32-shared-ptr.h
http://gcc.gnu.org/svn/gcc/branches/csl-gxxpro-3_4-branch/gcc/config/i386/w32-shared-ptr.c
Fix is in C:\gcc-4_2-branch\gcc\unwind-sjlj.c
(Note: these "-------"'s indicate a break in my note writing. The "flow" might not
always connect perfectly when I take a few days off to make fixes and come back to
write more notes.)
coLinux Cross-Compiler colinux/mingw32/bin/i686-pc-mingw32-gcc -v Configured with: /opt/colinux/build/gcc-3.4.5-20060117-1/configure -v --prefix=/opt/colinux/mingw32 --target=i686-pc-mingw32 --with-headers=/opt/colinux/mingw32/i686-pc-mingw32/include --with-gnu-as --with-gnu-ld --disable-nls --without-newlib --disable-multilib --enable-languages=c,c++ --disable-checking
/opt/colinux/build/gcc-3.4.5-20060117-1/configure -v --prefix=/opt/colinux/mingw32
--target=i686-pc-mingw32 --with-headers=/opt/colinux/mingw32/i686-pc-mingw32/include
--with-gnu-as --with-gnu-ld --disable-nls --without-newlib --disable-multilib
--enable-languages=c,c++ --disable-checking
If you will not be making Ada then you need to change gcc/Makefile (after it is created) so that make will not try to compile Ada during stage1; like this:
#BOOT_LANGUAGES = c ada BOOT_LANGUAGES = c
Need to ensure that i686-pc-mingw-ar and i686-pc-mingw-ranlib are in your path (use which to check for them). If you previously build coLinux under cOlinux then you will have copies of these files in /opt/colinux/mingw32/bin directory.
Didn't need to edit libiberty/Makefile (after it is created) so underscores would match.
CFLAGS = -g -O2 #CFLAGS = -g -O2 -fno-leading-underscore
Needed to edit build-i686-pc-linux-gnu/libiberty/Makefile (after it is created) so underscores would match when compiling /opt/gcc-4_2-branch/gcc/genmodes.c .
#CFLAGS = -g -O2 CFLAGS = -g -O2 -fno-leading-underscore
Needed to edit gcc/build/Makefile (after it is created) so underscores would match when compiling /opt/gcc-4_2-branch/gcc/genmodes.c .
#STAGE1_CFLAGS = -g STAGE1_CFLAGS = -g -fno-leading-underscore
Without that change we would get this type of error:
make[4]: Entering directory `/opt/gcc-4_2-build-mingw32/gcc' stage1/xgcc -Bstage1/ -B/opt/colinux/mingw32/i686-pc-mingw32/bin/ -O2 -g -fomit-frame- pointer -DIN_GCC -DCROSS_COMPILE -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing- prototypes -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Wold-style-definition -Wmissing-format-attribute -DHAVE_CONFIG_H -DGENERATOR_FILE -o build/genmodes build/genmodes.o build/errors.o ../build-i686-pc-linux-gnu/libiberty/libiberty.a :/opt/gcc-4_2-build-mingw32/gcc/../../gcc-4_2-branch/gcc/genmodes.c:233: undefined reference to `_xmalloc' :/opt/gcc-4_2-build-mingw32/gcc/../../gcc-4_2-branch/gcc/genmodes.c:161: undefined reference to `_xmalloc' :/opt/gcc-4_2-build-mingw32/gcc/../../gcc-4_2-branch/gcc/genmodes.c:174: undefined reference to `_htab_find_slot'
Use of -fno-leading-underscore is more standard for gcc-4.2.0 and elf object format with Linux.
With Windows you are probably used to having leading underscores. All it really serves to accomplish is to take up space. Use of them is unneccesary since if every function has them then they can just as easily not have them. It is only if some have, and some have NOT, and you try to call xmalloc when your function is called _xmalloc (or vise versa); then you get a problem. If all functions have NO underlines then any function can call any other function.
I don't know why gcc-4.2.0-branch configure scripts don't catch this and cause make to fail. Just another challenge to add to cross-compiling ;) ...
make[2]: Entering directory `/opt/gcc-4_2-build-mingw32/gcc' stage1/xgcc -Bstage1/ -B/opt/colinux/mingw32/i686-pc-mingw32/bin/ -c -O2 -g -fomit-frame-pointer -DIN_GCC -DCROSS_COMPILE -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Wold-style-definition -Wmissing-format-attribute -DHAVE_CONFIG_H -DGENERATOR_FILE -I. -Ibuild -I../../gcc-4_2-branch/gcc -I../../gcc-4_2-branch/gcc/build -I../../gcc-4_2-branch/gcc/../include -I../../gcc-4_2-branch/gcc/../libcpp/include -I../../gcc-4_2-branch/gcc/../libdecnumber -I../libdecnumber -o build/genmodes.o ../../gcc-4_2-branch/gcc/genmodes.c ../../gcc-4_2-branch/gcc/genmodes.c: In function 'main': ../../gcc-4_2-branch/gcc/genmodes.c:1297: warning: implicit declaration of function 'fflush_unlocked'
For some reason the make was trying to build genmodes.c with the cross-compiler. The resulting ".exe" files (actually it does NOT have a ".exe" suffix since it is being compiled for Linux) would have a object format of pe-i386 (according to "objdump -f")
I couldn't find anything in the make that was specifically causing this (other than it was simply one of the files to be compiled and we are cross compiling).
I had to re-do configure and add different parameters
--build=i686-pc-linux-gnu --target=i686-pc-mingw32
Old coLinux gcc-3.4.5 cross-compiler ./configure command:
/opt/colinux/build/gcc-3.4.5-20060117-1/configure -v --prefix=/opt/colinux/mingw32 --target=i686-pc-mingw32 --with-headers=/opt/colinux/mingw32/i686-pc-mingw32/include --with-gnu-as --with-gnu-ld --disable-nls --without-newlib --disable-multilib --enable-languages=c,c++ --disable-checking
NEW resulting gcc-4.2.0 cross-compiler ./configure command is:
../gcc-4_2-branch/configure --verbose --prefix/opt/colinux/mingw32 --build=i686-pc-linux-gnu --target=i686-pc-mingw32 --with-headers=/opt/colinux/mingw32/i686-pc-mingw32/include --enable-nls --enable-languages=c,c++,objc,obj-c++ --enable-concept-checks --with-gxx-include-dir=/opt/colinux/mingw32/include/c++/4.2.0 --enable-libstdcxx-debug --enable-shared --enable-__cxa_atexit --enable-initfini-array --enable-version-specific-runtime-libs --enable-libssp --enable-libmudflap --enable-libgomp --disable-werror --with-system-zlib --without-included-gettext --enable-decimal-float --with-long-double-128 --enable-clocale=gnu --enable-debug --with-stabs
Don't use: --with-headers --enable-shared --enable-version-specific-runtime-libs --enable-clocale=gnu
../gcc-4_2-branch/configure --verbose --prefix/opt/colinux/mingw32 --build=i686-pc-linux-gnu --target=i686-pc-mingw32 --enable-nls --enable-languages=c,c++,objc,obj-c++ --enable-objc-gc --enable-concept-checks --with-gxx-include-dir=/opt/colinux/mingw32/include/c++/4.2.0 --enable-libstdcxx-debug --enable-__cxa_atexit --enable-initfini-array --enable-libssp --enable-libmudflap --enable-libgomp --disable-werror --with-system-zlib --without-included-gettext --enable-decimal-float --with-long-double-128 --enable-debug --with-stabs --enable-stage1-checking=all
Simply type "make".
Try --with-headers=/usr/include (copies /usr/include to /opt/colinux/mingw32/i686-pc-mingw/sys-include)
../gcc-4_2-branch/configure --verbose --prefix/opt/colinux/mingw32 --build=i686-pc-linux-gnu --target=i686-pc-mingw32 --with-headers=/usr/include --enable-nls --enable-languages=c,c++,objc,obj-c++ --enable-objc-gc --enable-concept-checks --with-gxx-include-dir=/opt/colinux/mingw32/include/c++/4.2.0 --enable-libstdcxx-debug --enable-__cxa_atexit --enable-initfini-array --enable-libssp --enable-libmudflap --enable-libgomp --disable-werror --with-system-zlib --without-included-gettext --enable-decimal-float --with-long-double-128 --enable-debug --with-stabs --enable-stage1-checking=all
Try "make bootstrap"
Simply type "make" and copy by hand. cp gcc/stage1/build/* gcc/build
edit gcc/Makefile and change this:
- STAGE1_LANGUAGES=c
STAGE1_LANGUAGES=c,c++,objc,obj-c++
Now copy a Windows MinGW gcc-4.2.0 compiled version of any missing .a and .la files (and if you find some .h files copy them too) over to the coLinux MinGW cross-compiler directories. Do NOT copy any executables. Now you should have a very complete version of a coLinux MinGW cross-compiler for gcc-4.2.0 . It should produce (within coLinux) executables that can only run on Windows (and do not run on coLinux, but _might_ run using "wine" - though this is NOT a requirement).
You will need to edit any .la files if you expect pkg-config to work correctly.
Don't forget to copy (or keep / edit) the specs file to support all features.
Use this:
Change:
--enable-nls --disable-nls
Add: --enable-threads (not --enable-threads=posix)
Add: --disable-win32-registry --disable-shared --enable-sjlj-exceptions --without-x --enable-hash-synchronization
../gcc-4_2-branch/configure --verbose --prefix/opt/colinux/mingw32 --build=i686-pc-linux-gnu --target=i686-pc-mingw32 --with-headers=/usr/include --disable-nls --enable-languages=c,c++,objc,obj-c++ --enable-objc-gc --enable-concept-checks --with-gxx-include-dir=/opt/colinux/mingw32/include/c++/4.2.0 --enable-libstdcxx-debug --enable-__cxa_atexit --enable-initfini-array --enable-threads=posix --enable-libssp --enable-libmudflap --enable-libgomp --disable-werror --with-system-zlib --without-included-gettext --enable-decimal-float --with-long-double-128 --enable-debug --with-stabs --disable-win32-registry --disable-shared --enable-sjlj-exceptions --without-x --enable-hash-synchronization --enable-stage1-checking=all
Compiling coLinux with 4.2.0 - Make some changes to use 4.2.0 features[]
First type "./configure & make" to make everything and check that things work before you make any changes. Then copy your gcc 4.2.0 cross compiler (for WinXP to /opt/colinux/mingw and check it with "mingw/bin/i686-pc-mingw32-gcc -v" .
I found that the "cp" command "seemed" to work but actually did NOT let the executable files overwrite the gcc-3.4.5 executables. I re-did the copy with this command:
cp -rvp --remove-destination mingw32-WinXP/* mingw32 ( just one directory use: cp -rvp --remove-destination mingw32-WinXP/bin/* mingw32/bin )
Check that you can compile a working program (and run it using wine, or copy it to your Windows directory and run it from WindowsXP). You might need to copy a specs file to /opt/colinux/mingw32/libexec/gcc/i686-pc-mingw32/4.2.0/ and you might need to create "as" and "ld" scripts (and use chmod 755 as ld) like these:
File /opt/colinux/mingw32/libexec/gcc/i686-pc-mingw32/4.2.0/as
#!/bin/sh exec /opt/colinux/mingw32/bin/i686-pc-mingw32-as "$@"
File /opt/colinux/mingw32/libexec/gcc/i686-pc-mingw32/4.2.0/ld
#!/bin/sh exec /opt/colinux/mingw32/bin/i686-pc-mingw32-ld "$@"
Now fix a build script to check for the new version instead of the old one.
Use nano to edit bin/build-common.sh and change this line:
#GCC_VERSION="3.4.5" GCC_VERSION="4.2.0"
You might need to type this in your bash shell:
export CC=/usr/bin/gcc-3.4 export CXX=/usr/bin/g++-3.4
OR
export CC=/usr/bin/i686-pc-linux-gnu-gcc export CXX=/usr/bin/i686-pc-linux-gnu-g++
To switch between compilers. That way AFTER you install GCC 4.2.0 (and typing gcc -v says that you have 4.2.0) you can use "apt-get reinstall gcc" to re-install the OLD gcc (and other languages) and use the above "export" commands to switch to GCC 4.2.0 when you are not compiling coLinux.
I have GCC 4.2.0 installed as my default compiler - that might not be good for YOU to do that.
Try out GCC 4.2.0 new features[]
Now we have gcc-4.2.0 installed, lets use some new features. Stack smashing protection is a good thing and using -O3 will super-optimize the code (compared to gcc-3.4.5).
Type "info gcc" to see all the great features that have been added!
1): Change file: /opt/colinux/devel-colinux-20070302/src/build.comake.py
Alter this line:
compiler_flags = ['-mpush-args', '-mno-accumulate-outgoing-args']
To this:
compiler_flags = ['-mpush-args', '-mno-accumulate-outgoing-args', '-fstack-protector']
2): Change file: /opt/colinux/devel-colinux-20070302/bin/comake/tools.py
Alter this line:
compiler_optimization = tool_run_inf.options.get('compiler_optimization', "-O2")
To this:
compiler_optimization = tool_run_inf.options.get('compiler_optimization', "-O3")
3): Also do this:
Change /opt/colinux/build/linux-2.6.17-source/Makefile (near line 188):
- HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
- HOSTCXXFLAGS = -O2
HOSTCFLAGS = -Wall -Wstrict-prototypes -O3 -fstack-protector -fomit-frame-pointer HOSTCXXFLAGS = -O3 -fstack-protector
Change /opt/colinux/build/linux-2.6.17-source/Makefile (near line 473):
- CFLAGS += -O2
CFLAGS += -O3 -fstack-protector
When making I got an error about undefined reference to `___stack_chk_guard' and `___stack_chk_fail' etc. This is caused by not having -lssp on the command line. I need to find out how to fix the specs file to handle .res files so I don't need to do these fixes by hand.
Origonal (as printed on the screen):
i686-pc-mingw32-gcc src/colinux/os/winnt/user/daemon/res/daemon.res src/colinux/os/winnt/user/daemon/daemon.o src/colinux/os/winnt/user/user-all.a -luser32 -lgdi32 -lws2_32 -lntdll -lkernel32 -lole32 -luuid -lgdi32 -lmsvcrt -lcrtdll -lshlwapi -o src/colinux/os/winnt/build/colinux-daemon.exe && i686-pc-mingw32-strip --strip-debug src/colinux/os/winnt/build/colinux-daemon.exe
New (with paths to command's location AND "-L../mingw32/lib" "-lssp" added to command): ../mingw32/bin/i686-pc-mingw32-gcc -v -L../mingw32/lib src/colinux/os/winnt/user/daemon/res/daemon.res src/colinux/os/winnt/user/daemon/daemon.o src/colinux/os/winnt/user/user-all.a -luser32 -lgdi32 -lws2_32 -lntdll -lkernel32 -lole32 -luuid -lgdi32 -lmsvcrt -lcrtdll -lshlwapi -lssp -o src/colinux/os/winnt/build/colinux-daemon.exe && ../mingw32/bin/i686-pc-mingw32-strip --strip-debug src/colinux/os/winnt/build/colinux-daemon.exe
Next error is "/opt/colinux/mingw32/bin/i686-pc-mingw32-ld: cannot find -lstdc++" and
some "undefined reference to `___gxx_personality_sj0'" errors:
Origonal (as printed on the screen): i686-pc-mingw32-g++ -Wl,--start-group src/colinux/os/winnt/user/daemon/res/daemon.res src/colinux/os/winnt/user/conet-daemon/build.a src/colinux/user/daemon-base/build.a src/colinux/os/winnt/user/user-all.a -luser32 -lgdi32 -lws2_32 -lntdll -lkernel32 -lole32 -luuid -lgdi32 -lmsvcrt -lcrtdll -lshlwapi -Wl,--end-group -o src/colinux/os/winnt/build/colinux-net-daemon.exe && i686-pc-mingw32-strip --strip-debug src/colinux/os/winnt/build/colinux-net-daemon.exe
New (with paths to command's location AND "-L../mingw32/lib -lssp -lstdc++" added to command): ../mingw32/bin/i686-pc-mingw32-g++ -Wl,--start-group src/colinux/os/winnt/user/daemon/res/daemon.res src/colinux/os/winnt/user/conet-daemon/build.a src/colinux/user/daemon-base/build.a src/colinux/os/winnt/user/user-all.a -luser32 -lgdi32 -lws2_32 -lntdll -lkernel32 -lole32 -luuid -lgdi32 -lmsvcrt -lcrtdll -lshlwapi -Wl,--end-group -L../mingw32/lib -lssp -lstdc++ -o src/colinux/os/winnt/build/colinux-net-daemon.exe && ../mingw32/bin/i686-pc-mingw32-strip --strip-debug src/colinux/os/winnt/build/colinux-net-daemon.exe
Next error is undefined reference to `___stack_chk_guard' and `___gxx_personality_sj0'" :
Origonal (as printed on the screen): i686-pc-mingw32-g++ -mwindows -Wl,--start-group src/colinux/os/winnt/user/daemon/res/daemon.res src/colinux/os/winnt/user/console/build.a src/colinux/user/console/build.a src/colinux/os/winnt/user/user-all.a -lfltk -lmingw32 -luser32 -lgdi32 -lws2_32 -lntdll -lkernel32 -lole32 -luuid -lgdi32 -lmsvcrt -lcrtdll -lshlwapi -Wl,--end-group -o src/colinux/os/winnt/build/colinux-console-fltk.exe && i686-pc-mingw32-strip --strip-debug src/colinux/os/winnt/build/colinux-console-fltk.exe
New (with paths to command's location AND "-L../mingw32/lib -lssp -lstdc++ -lobjc" added to command): ../mingw32/bin/i686-pc-mingw32-g++ -mwindows -Wl,--start-group src/colinux/os/winnt/user/daemon/res/daemon.res src/colinux/os/winnt/user/console/build.a src/colinux/user/console/build.a src/colinux/os/winnt/user/user-all.a -lfltk -lmingw32 -luser32 -lgdi32 -lws2_32 -lntdll -lkernel32 -lole32 -luuid -lgdi32 -lmsvcrt -lcrtdll -lshlwapi -Wl,--end-group -L../mingw32/lib -lssp -lstdc++ -o src/colinux/os/winnt/build/colinux-console-fltk.exe && ../mingw32/bin/i686-pc-mingw32-strip --strip-debug src/colinux/os/winnt/build/colinux-console-fltk.exe
Still gives errors about: ___dso_handle ___cxa_atexit /opt/colinux/mingw32/lib/gcc/i686-pc-mingw32/4.2.0/../../../../i686-pc-mingw32/lib/libfltk.a(Fl_get_system_colors.o):Fl_get_system_colors.cxx:(.text+0xa0): undefined reference to `___dso_handle' /opt/colinux/mingw32/lib/gcc/i686-pc-mingw32/4.2.0/../../../../i686-pc-mingw32/lib/libfltk.a(Fl_get_system_colors.o):Fl_get_system_colors.cxx:(.text+0xb4): undefined reference to `___cxa_atexit'
Origonal: ../mingw32/bin/i686-pc-mingw32-g++ -mwindows -Wl,--start-group src/colinux/os/winnt/user/daemon/res/daemon.res src/colinux/os/winnt/user/console/build.a src/colinux/user/console/build.a src/colinux/os/winnt/user/user-all.a -lfltk -lmingw32 -luser32 -lgdi32 -lws2_32 -lntdll -lkernel32 -lole32 -luuid -lgdi32 -lmsvcrt -lcrtdll -lshlwapi -Wl,--end-group -L../mingw32/lib -lssp -lstdc++ -o src/colinux/os/winnt/build/colinux-console-fltk.exe && ../mingw32/bin/i686-pc-mingw32-strip --strip-debug src/colinux/os/winnt/build/colinux-console-fltk.exe
Old Fix:
Until I get c++ compiler working better, simply copy fltk console from windows drive:
cp /mnt/windows/coLinux3/colinux-console-fltk.exe src/colinux/os/winnt/build/
InProgress - New Fix - Use WinXP's msys MinGW gcc-4_2-branch:
1): Run above "../mingw32/bin/i686-pc-mingw32-g++" command as "g++" under WinXP Msys
in /opt/devel-colinux-20070302 to get list of missing files. Use these for next step.
2): Copy files from coLinux's directory tree to WinXP directory tree
cp src/colinux/os/winnt/user/daemon/res/.comake.build/daemon.res-bf5fb5dfb14f4746259b1ac8d5a735da /mnt/windows/opt/devel-colinux-20070302/src/colinux/os/winnt/user/daemon/res/daemon.res cp src/colinux/os/winnt/user/console/.comake.build/build.a-7ddbac6e740dc800992ce058716eab1b /mnt/windows/opt/devel-colinux-20070302/src/colinux/os/winnt/user/console/build.a cp src/colinux/user/console/.comake.build/build.a-5534efb302f570d30c380a6236f647e7 /mnt/windows/opt/devel-colinux-20070302/src/colinux/user/console/build.a cp src/colinux/os/winnt/user/.comake.build/user-all.a-4a52ff87701278fd6bd8ae2c52f55b9d /mnt/windows/opt/devel-colinux-20070302/src/colinux/os/winnt/user/user-all.a and cp /opt/colinux/mingw32/i686-pc-mingw32/lib/libfltk.a /mnt/windows/msys/1.0/lib
3): Run above "../mingw32/bin/i686-pc-mingw32-g++" command as "g++ -L/lib" under WinXP Msys in /opt/devel-colinux-20070302 to get these errors:
(NOTE: had some trouble with the OLD binutils not linking the new code correctly. If you don't see the answer above or below then don't ask how I fixed it. I used the newest available everything (without compiling source for any programs EXCEPT (of course) I did compile coLinux and the Linux kernel - I did NOT recompile Cygwin, msys, MinGW, binutils, or anything on my Windows system - only coLinux and the kernel).
_SOMEDAY_ I will come back and clean these notes up a bit - not this month.
C:/msys/1.0/lib/libfltk.a(Fl_get_system_colors.o):Fl_get_system_colors.cxx:(.text+0xa0): undefined reference to `__dso_handle'
C:/msys/1.0/lib/libfltk.a(Fl_get_system_colors.o):Fl_get_system_colors.cxx:(.text+0xb4): undefined reference to `__cxa_atexit'
C:/msys/1.0/lib/libstdc++.a(eh_terminate.o):eh_terminate.cc:(.text+0x67): undefined reference to `__w32_sharedptr_terminate'
C:/msys/1.0/lib/libstdc++.a(eh_terminate.o):eh_terminate.cc:(.text+0x97): undefined reference to `__w32_sharedptr_unexpected'
C:/msys/1.0/lib/libstdc++.a(eh_terminate.o):eh_terminate.cc:(.text+0xb3): undefined reference to `__w32_sharedptr_terminate'
C:/msys/1.0/lib/libstdc++.a(eh_terminate.o):eh_terminate.cc:(.text+0xd3): undefined reference to `__w32_sharedptr_unexpected'
C:/msys/1.0/lib/libstdc++.a(eh_throw.o):eh_throw.cc:(.text+0x7b): undefined reference to `__w32_sharedptr_unexpected'
C:/msys/1.0/lib/libstdc++.a(eh_throw.o):eh_throw.cc:(.text+0x8c): undefined reference to `__w32_sharedptr_terminate'
collect2: ld returned 1 exit status
Errors about undefined reference to `___stack_chk_guard' and `___stack_chk_fail' etc.
Origonal (as printed on the screen): i686-pc-mingw32-gcc src/colinux/os/winnt/user/daemon/res/daemon.res src/colinux/os/winnt/user/debug/build.o src/colinux/user/debug/build.o src/colinux/os/winnt/user/user-all.a -luser32 -lgdi32 -lws2_32 -lntdll -lkernel32 -lole32 -luuid -lgdi32 -lmsvcrt -lcrtdll -lshlwapi -o src/colinux/os/winnt/build/colinux-debug-daemon.exe && i686-pc-mingw32-strip --strip-debug src/colinux/os/winnt/build/colinux-debug-daemon.exe
New (with paths to command's location AND "-L../mingw32/lib" "-lssp" added to command): ../mingw32/bin/i686-pc-mingw32-gcc -L../mingw32/lib src/colinux/os/winnt/user/daemon/res/daemon.res src/colinux/os/winnt/user/debug/build.o src/colinux/user/debug/build.o src/colinux/os/winnt/user/user-all.a -luser32 -lgdi32 -lws2_32 -lntdll -lkernel32 -lole32 -luuid -lgdi32 -lmsvcrt -lcrtdll -lshlwapi -lssp -o src/colinux/os/winnt/build/colinux-debug-daemon.exe && ../mingw32/bin/i686-pc-mingw32-strip --strip-debug src/colinux/os/winnt/build/colinux-debug-daemon.exe
Next error is undefined reference to `___stack_chk_guard' and `___gxx_personality_sj0'" :
i686-pc-mingw32-g++ -Wl,--start-group src/colinux/os/winnt/user/daemon/res/daemon.res src/colinux/os/winnt/user/console-nt/build.a src/colinux/user/console-base/build.a src/colinux/os/winnt/user/user-all.a -luser32 -lgdi32 -lws2_32 -lntdll -lkernel32 -lole32 -luuid -lgdi32 -lmsvcrt -lcrtdll -lshlwapi -Wl,--end-group -o src/colinux/os/winnt/build/colinux-console-nt.exe && i686-pc-mingw32-strip --strip-debug src/colinux/os/winnt/build/colinux-console-nt.exe
New (with paths to command's location AND "-L../mingw32/lib -lssp -lstdc++ -lobjc" added to command): ../mingw32/bin/i686-pc-mingw32-g++ -Wl,--start-group src/colinux/os/winnt/user/daemon/res/daemon.res src/colinux/os/winnt/user/console-nt/build.a src/colinux/user/console-base/build.a src/colinux/os/winnt/user/user-all.a -luser32 -lgdi32 -lws2_32 -lntdll -lkernel32 -lole32 -luuid -lgdi32 -lmsvcrt -lcrtdll -lshlwapi -Wl,--end-group -o src/colinux/os/winnt/build/colinux-console-nt.exe && ../mingw32/bin/i686-pc-mingw32-strip --strip-debug src/colinux/os/winnt/build/colinux-console-nt.exe
Until I get c++ compiler working better, simply copy nt console from windows drive: cp /mnt/windows/coLinux3/colinux-console-nt.exe src/colinux/os/winnt/build/
Errors about undefined reference to `___stack_chk_guard' and `___stack_chk_fail' etc.
Origonal (as printed on the screen): i686-pc-mingw32-gcc src/colinux/os/winnt/user/daemon/res/daemon.res src/colinux/os/winnt/user/conet-bridged-daemon/build.o src/colinux/os/winnt/user/user-all.a -lwpcap -luser32 -lgdi32 -lws2_32 -lntdll -lkernel32 -lole32 -luuid -lgdi32 -lmsvcrt -lcrtdll -lshlwapi -o src/colinux/os/winnt/build/colinux-bridged-net-daemon.exe && i686-pc-mingw32-strip --strip-debug src/colinux/os/winnt/build/colinux-bridged-net-daemon.exe
New (with paths to command's location AND "-L../mingw32/lib" "-lssp" added to command): ../mingw32/bin/i686-pc-mingw32-gcc -L../mingw32/lib src/colinux/os/winnt/user/daemon/res/daemon.res src/colinux/os/winnt/user/conet-bridged-daemon/build.o src/colinux/os/winnt/user/user-all.a -lwpcap -luser32 -lgdi32 -lws2_32 -lntdll -lkernel32 -lole32 -luuid -lgdi32 -lmsvcrt -lcrtdll -lshlwapi -lssp -o src/colinux/os/winnt/build/colinux-bridged-net-daemon.exe && ../mingw32/bin/i686-pc-mingw32-strip --strip-debug src/colinux/os/winnt/build/colinux-bridged-net-daemon.exe
Errors about undefined reference to `___stack_chk_guard' and `___stack_chk_fail' etc.
Origonal (as printed on the screen): i686-pc-mingw32-gcc src/colinux/os/winnt/user/daemon/res/daemon.res src/colinux/os/winnt/user/conet-slirp-daemon/build.o src/colinux/user/slirp/build.o src/colinux/os/winnt/user/user-all.a -liphlpapi -luser32 -lgdi32 -lws2_32 -lntdll -lkernel32 -lole32 -luuid -lgdi32 -lmsvcrt -lcrtdll -lshlwapi -o src/colinux/os/winnt/build/colinux-slirp-net-daemon.exe && i686-pc-mingw32-strip --strip-debug src/colinux/os/winnt/build/colinux-slirp-net-daemon.exe
New (with paths to command's location AND "-L../mingw32/lib" "-lssp" added to command): ../mingw32/bin/i686-pc-mingw32-gcc -L../mingw32/lib src/colinux/os/winnt/user/daemon/res/daemon.res src/colinux/os/winnt/user/conet-slirp-daemon/build.o src/colinux/user/slirp/build.o src/colinux/os/winnt/user/user-all.a -liphlpapi -luser32 -lgdi32 -lws2_32 -lntdll -lkernel32 -lole32 -luuid -lgdi32 -lmsvcrt -lcrtdll -lshlwapi -lssp -o src/colinux/os/winnt/build/colinux-slirp-net-daemon.exe && ../mingw32/bin/i686-pc-mingw32-strip --strip-debug src/colinux/os/winnt/build/colinux-slirp-net-daemon.exe
Errors about undefined reference to `___stack_chk_guard' and `___stack_chk_fail' etc.
Origonal (as printed on the screen): i686-pc-mingw32-gcc src/colinux/os/winnt/user/daemon/res/daemon.res src/colinux/os/winnt/user/coserial-daemon/build.o src/colinux/os/winnt/user/user-all.a -luser32 -lgdi32 -lws2_32 -lntdll -lkernel32 -lole32 -luuid -lgdi32 -lmsvcrt -lcrtdll -lshlwapi -o src/colinux/os/winnt/build/colinux-serial-daemon.exe && i686-pc-mingw32-strip --strip-debug src/colinux/os/winnt/build/colinux-serial-daemon.exe
New (with paths to command's location AND "-L../mingw32/lib" "-lssp" added to command): ../mingw32/bin/i686-pc-mingw32-gcc -L../mingw32/lib src/colinux/os/winnt/user/daemon/res/daemon.res src/colinux/os/winnt/user/coserial-daemon/build.o src/colinux/os/winnt/user/user-all.a -luser32 -lgdi32 -lws2_32 -lntdll -lkernel32 -lole32 -luuid -lgdi32 -lmsvcrt -lcrtdll -lshlwapi -lssp -o src/colinux/os/winnt/build/colinux-serial-daemon.exe && ../mingw32/bin/i686-pc-mingw32-strip --strip-debug src/colinux/os/winnt/build/colinux-serial-daemon.exe
Errors about undefined reference to ___stack_chk_guard, ___stack_chk_fail and _open, _close etc.
Origonal (as printed on the screen): i686-pc-mingw32-gcc -Wl,--subsystem,native -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -Wl,--entry,_DriverEntry@8 -Wl,src/colinux/os/winnt/build/driver.base.exp -mdll -nostartfiles -nostdlib -o src/colinux/os/winnt/build/linux.sys src/colinux/os/winnt/build/driver.o -lntoskrnl -lhal -lgcc
New (with paths to command's location AND "-L../mingw32/lib -lssp -lcoldname -lmsvcr70" added to command): ../mingw32/bin/i686-pc-mingw32-gcc -Wl,--subsystem,native -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -Wl,--entry,_DriverEntry@8 -Wl,src/colinux/os/winnt/build/driver.base.exp -mdll -nostartfiles -nostdlib -o src/colinux/os/winnt/build/linux.sys src/colinux/os/winnt/build/driver.o -lntoskrnl -lhal -lgcc -L../mingw32/lib -lssp -lcoldname -lmsvcr70
(NOTE: ended up compiling without using stack-guard, currently trying to re-enable it. That
is why I won't be updating these notes this week).
Now this error:
/opt/colinux/mingw32/lib/gcc/i686-pc-mingw32/4.2.0/../../../../i686-pc-mingw32/include/winsock2.h:56: error: conflicting types for 'fd_set' /opt/colinux/build/linux-2.6.17-source/include/linux/types.h:22: error: previous declaration of 'fd_set' was here Error: Target not build (TargetNotBuildError)
/opt/colinux/mingw32/i686-pc-mingw32/include/winsock2.h
typedef struct fd_set {
u_int fd_count; SOCKET fd_array[FD_SETSIZE];
} fd_set;
/opt/colinux/build/linux-2.6.17-source/include/linux/types.h
typedef __kernel_fd_set fd_set;
Re-installed coLinux using "make all" and setting config to allow overwriting kernel tar
Now, typing "make" builds nothing. That is GOOD. Everything above worked.
coLinux is in directory /opt/colinux/devel-colinux-20070302/src/colinux/os/winnt/build/
and vmlinux can be found in /opt/colinux/build/linux-2.6.17-build . Finished building
on to packaging. Type "make package". After packaging look in /opt/colinux/dist .
Now (after installing wine) type "make installer". It prints this on the screen:
Starting build [installer] [colinux] [src/build] [src/colinux/os/winnt/build/installer] [src/colinux/os/winnt/user/install/coLinux.exe] [src/colinux/os/winnt/user/install/colinux_def.inc] Building: target requires creation sh -c ". src/colinux/os/winnt/user/install/colinux_def.sh src/colinux/VERSION src/colinux/os/winnt/user/install/colinux_def.inc" [src/colinux/os/winnt/user/install/coLinux.exe] Building: target is older than dependencies wine -- "/mnt/windows/Program\\ Files\\NSIS\\makensis" /V3 src/colinux/os/winnt/user/install/colinux.nsi Invoking /usr/lib/wine/wine.bin -- /mnt/windows/Program\ Files\NSIS\makensis /V3 src/colinux/os/winnt/user/install/colinux.nsi ... wine: cannot find '--' Wine failed with return code 1 Error: Target not build (TargetNotBuildError) make[1]: *** [installer] Error 1 make[1]: Leaving directory `/opt/colinux/devel-colinux-20070302/src' make: *** [installer] Error 2
Origonal (as printed on the screen): /usr/lib/wine/wine.bin -- /mnt/windows/Program\ Files\NSIS\makensis /V3 src/colinux/os/winnt/user/install/colinux.nsi
New (with "\" changed): wine /mnt/windows/Program\ Files/NSIS/makensis /V3 src/colinux/os/winnt/user/install/colinux.nsi
(NOTE: needed to edit the makefile to fix the path and filename to makensis.exe)
The resulting file (coLinux.exe) ends up in: src/colinux/os/winnt/user/install/
Need to add "cp System.map /boot" to remove one message from startup
Fixing the modules[]
You will now have coLinux (daemons) and Linux kernel compiled but the modules need to have been built under a Linux kernel that is compiled with GCC 4.2.0
You will need to re-boot coLinux and your modules will fail to install since they are the wrong version. It doesn't affect coLinux (in it's default .configuration) just ignore the errors and re-compile by typing "make modules modules_install" - then re-boot without error.
After everything is build and you've ran the installer (or manually copied vmlinux
to your WinXP c:\colinux directory) you will get some startup errors the next time
you bootup, this is normal. They _might_ look like this:
colinux:~# dmesg | grep gcc
Linux version 2.6.17-co-0.8.0 (root@colinux) (gcc version 4.2.0 20070323 (prerelease)) #1 PREEMPT Sat Mar 31 04:41:17 PDT 2007
ipv6: version magic '2.6.17-co-0.8.0 preempt mod_unload 586 gcc-3.4' should be '2.6.17-co-0.8.0 preempt mod_unload 586 gcc-4.2'
x_tables: version magic '2.6.17-co-0.8.0 preempt mod_unload 586 gcc-3.4' should be '2.6.17-co-0.8.0 preempt mod_unload 586 gcc-4.2'
ip_tables: version magic '2.6.17-co-0.8.0 preempt mod_unload 586 gcc-3.4' should be '2.6.17-co-0.8.0 preempt mod_unload 586 gcc-4.2'
x_tables: version magic '2.6.17-co-0.8.0 preempt mod_unload 586 gcc-3.4' should be '2.6.17-co-0.8.0 preempt mod_unload 586 gcc-4.2'
ip_tables: version magic '2.6.17-co-0.8.0 preempt mod_unload 586 gcc-3.4' should be '2.6.17-co-0.8.0 preempt mod_unload 586 gcc-4.2'
iptable_filter: version magic '2.6.17-co-0.8.0 preempt mod_unload 586 gcc-3.4' should be '2.6.17-co-0.8.0 preempt mod_unload 586 gcc-4.2'
iptable_mangle: version magic '2.6.17-co-0.8.0 preempt mod_unload 586 gcc-3.4' should be '2.6.17-co-0.8.0 preempt mod_unload 586 gcc-4.2'
If they go by too quickly on the tiny screen simply use Xterm (for a larger screen
with scrollback) and type "dmesg | grep gcc" - you may not see these errors if
you have not installed any extra someware on your system but you still have this
problem. It means your module's version does not match your new kernel's version.
To fix this type:
cd /opt/colinux/build/linux-2.6.17-build/ make modules
(then, as root, type)
make modules_install cp System.map /boot shutdown -h now
Now re-boot coLinux and the above errors will be fixed.
More tips[]
If using menuconfig, gconfig or xconfig don't set REGPARM to true it causes an instant re-boot of your system when coLinux is started. Recompiling (and, most likely, rewriting) the daemon may be neccesary.
colinux:~# diff -Naur linux-2.6.17-config-broken-3 linux-2.6.17-config-works-4 --- linux-2.6.17-config-broken-3 2007-04-09 22:24:25.000000000 -0700 +++ linux-2.6.17-config-works-4 2007-04-09 21:48:33.000000000 -0700 -# Mon Apr 9 22:07:04 2007 +# Mon Apr 9 20:54:11 2007 # Firmware Drivers -CONFIG_REGPARM=y +# CONFIG_REGPARM is not set
Broken: Don't Use register arguments (REGPARM)
(This is what xconfig displays as help text for REGPARM)
Compile the kernel with -mregparm=3. This instructs gcc to use a more efficient function call ABI which passes the first three arguments of a function call via registers, which results in denser and faster code.
If this option is disabled, then the default ABI of passing arguments via the stack is used.
(Sounds great but coLinux will need a lot of fixing to use it.)
Patches to get things to compile[]
First error when compiling with coLinux (Debian) gcc:
gcc-4_2-branch/include/libiberty.h
/*extern const char *strsignal (int); */
gcc-4_2-branch/gcc/system.h
/*extern const char *strsignal (int); */
/*struct rlimit; extern int getrlimit (int, struct rlimit *);*/
/*struct rlimit; extern int setrlimit (int, const struct rlimit *);*/
gcc-4_2-branch/gcc/timevar.c
/*typedef int clock_t;*/
/*struct tms {
clock_t tms_utime; clock_t tms_stime; clock_t tms_cutime; clock_t tms_cstime;
};
- /
/* Don't fix this - since fixing the two above fixes this */
extern clock_t times (struct tms *);
End[]
This is the abrupt end of the notes. I will pretty up this page sometime in the future.
--- END OF NOTES ---
Now off you go ...