PDA

View Full Version : HOWTO: Install FreeBSD with gcc45


Pavick
November 8th, 2010, 23:07
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 (http://pastebin.com/cexSdKZd), patch-c-format.h (http://pastebin.com/GLTkS2NV), patch-common.opt (http://pastebin.com/4JfaZvaF), patch-function.c (http://pastebin.com/q5U1VjPn), patch-gcc.c (http://pastebin.com/CXuF3pWX), patch-i386.c (http://pastebin.com/XsFJcjdk), and patch-i386.opt (http://pastebin.com/ipY46zDw) 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. cd /usr/ports/lang/gcc45 && make install.

3. Update your source tree. See here (http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/cvsup.html) for help. csup SUPFILE.

4. Copy patch-src (http://pastebin.com/W7LVxHfQ) to /usr/src, make.conf (http://pastebin.com/VbveXCWU) to /etc, and libmap.conf (http://pastebin.com/7Ai8C7tV) 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 (http://pastebin.com/Ym2MwY59) is a minimally correct version.

5. Update your source tree. cd /usr/src && patch -p0 < patch-src.

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

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. make buildworld (if you get the error /usr/obj/usr/src/make.amd64/usr/share/man/man1 does not exists), then try mkdir /usr/obj/usr/src/make.amd64/usr/share, mkdir /usr/obj/usr/src/make.amd64/usr/share/man,
mkdir /usr/obj/usr/src/make.amd64/usr/share/man/man1, and make buildworld.

8. Build kernel. See here (http://www.freebsd.org/doc/handbook/makeworld.html) 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.

luna
November 9th, 2010, 03:49
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.

Pavick
November 9th, 2010, 05:02
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.

luna
November 9th, 2010, 08:11
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$ 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