HOWTO: Install FreeBSD with gcc45

I am currently posting this from a FreeBSD amd64 system that has been compiled with gcc45. I believe the following steps are the 'right way' to install FreeBSD with gcc45. I would be happy to respond to questions and comments.

1. Copy the patches patch-c-format.c, patch-c-format.h, patch-common.opt, patch-function.c, patch-gcc.c, patch-i386.c, and patch-i386.opt to /usr/ports/lang/gcc45/files. Make sure to start their names with "patch-".

2. Install gcc45. These patches work with gcc-core-4.5-20101104. [cmd=]cd /usr/ports/lang/gcc45 && make install[/cmd].

3. Update your source tree. See here for help. [cmd=]csup SUPFILE[/cmd].

4. Copy patch-src to /usr/src, make.conf to /etc, and libmap.conf to /etc. Edit make.conf to give the correct CPUTYPE, MACHINE, and MACHINE_ARCH. Depending on your system, use may need to remove -fira-loop-pressure or -maccumulate-outgoing-args. The included make.conf is for a production build. Here is a minimally correct version.

5. Update your source tree. [cmd=]cd /usr/src && patch -p0 < patch-src[/cmd].

6. Refresh your /usr/include and /usr/obj directories. [cmd=]make includes && rm -rf /usr/obj[/cmd].

7. Build world. The make.conf that is provided installs everything except CXX and OBJC. Normally this would imply that gperf, groff, and devd would not be installed; however, among other things the patch-src fixes that. [cmd=]make buildworld[/cmd] (if you get the error /usr/obj/usr/src/make.amd64/usr/share/man/man1 does not exists), then try [cmd=]mkdir /usr/obj/usr/src/make.amd64/usr/share[/cmd], [cmd=]mkdir /usr/obj/usr/src/make.amd64/usr/share/man[/cmd],
[cmd=]mkdir /usr/obj/usr/src/make.amd64/usr/share/man/man1[/cmd], and [cmd=]make buildworld[/cmd].

8. Build kernel. See here for help. Surprisingly, binutils does not need to be patched. However, patch-src coerces ld to use the right format when compiling the kernel. # make buildkernel KERNCONF=MYKERNEL.

9. Install kernel. # make installkernel KERNCONF=MYKERNEL.

10. Reboot into single user mode or root.

11. Save your settings. # mergemaster -p.

11. Install world. # cd /usr/src && make installworld.

12. Restore your settings. # mergemaster.

13. Reboot.
 
Have you tried to build /head? It has world that can be built with clang. Perhaps, it'd reduce the size of the diff for base system.
 
It is true that patch-src is specifically for 8.1-Stable. However, I doubt there would be much overlap between the changes I made and the changes between 8.1-Stable and FreeBSD-Current. The changes consist of a minor bug fix in inetd.c, changing a few warning levels, adding -fno-tree-vrp and -fno-strict-overflow where appropriate, re-enabling the packages that depend on CXX (gperf, groff, and devd), adding compatibility for the current binutils, disabling fstack-protector, forcing a few functions to be inlined, and made minor modifications to ufs_dirhash.c, dirhash.h, and netgraph.

I am rather new to FreeBSD and haven't installed the Current version, but I suspect the patch-src will work directly on most files needed to be patched. If you tell me which files it fails to patch, then I could look at those files and create patches directly for them.
 
Pavick said:
I suspect the patch-src will work directly on most files needed to be patched. If you tell me which files it fails to patch, then I could look at those files and create patches directly for them.
Here is the list for /head@215024
Code:
$ patch -CEfsp3 -i ~/patch-src
1 out of 1 hunks failed--saving rejects to sbin/Makefile.rej
1 out of 1 hunks failed--saving rejects to share/mk/bsd.sys.mk.rej
No file to patch.  Skipping...
1 out of 1 hunks ignored--saving rejects to sys/amd64/acpica/Makefile.rej
1 out of 2 hunks failed--saving rejects to sys/conf/kern.mk.rej
1 out of 1 hunks failed--saving rejects to sys/dev/lmc/if_lmc.c.rej
1 out of 1 hunks failed--saving rejects to sys/net80211/ieee80211_var.h.rej
1 out of 1 hunks failed--saving rejects to sys/netgraph/ng_pipe.c.rej
3 out of 3 hunks failed--saving rejects to sys/sun4v/include/endian.h.rej
1 out of 1 hunks failed--saving rejects to usr.bin/bsdiff/Makefile.inc.rej
1 out of 1 hunks failed--saving rejects to usr.sbin/sysinstall/sysinstall.h.rej
zsh: exit 12
 
Back
Top