Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 409815 - sys-freebsd/boot0-9.0 fails to build with USE=zfs and either Clang or GCC 4.6
Summary: sys-freebsd/boot0-9.0 fails to build with USE=zfs and either Clang or GCC 4.6
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: FreeBSD (show other bugs)
Hardware: All FreeBSD
: Normal normal (vote)
Assignee: Gentoo/BSD Team
URL:
Whiteboard:
Keywords: Bug, Goal
: 417703 419503 (view as bug list)
Depends on:
Blocks: new-fbsd-stage freebsd-clang-3.1 426838 427430 broken-system
  Show dependency tree
 
Reported: 2012-03-27 02:15 UTC by Richard Yao (RETIRED)
Modified: 2013-08-27 23:08 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
sys-freebsd/boot0-9.0 build.log of failure (build.log,25.80 KB, text/plain)
2012-03-27 02:15 UTC, Richard Yao (RETIRED)
Details
Fix a compilation error with LLVM/Clang 3.1 (boot0-9.0-fix-clang-builds.patch,564 bytes, patch)
2012-05-27 16:46 UTC, Richard Yao (RETIRED)
Details | Diff
sample patch for boot0-9.0-ebuild (409815-gcc+clang.patch,1.03 KB, patch)
2012-06-14 12:01 UTC, Yuta SATOH
Details | Diff
Fix a compilation error with GCC 4.6 (boot0-9.0-fix-cc-as-ld.patch,3.95 KB, patch)
2012-06-14 21:13 UTC, Richard Yao (RETIRED)
Details | Diff
sample patch for boot0-9.1_rc3.ebuild (boot0-9.1_rc3_409815.patch,888 bytes, patch)
2012-11-24 17:30 UTC, Yuta SATOH
Details | Diff
files/boot0-9.1-gcc46.patch (boot0-9.1-gcc46.patch,530 bytes, patch)
2012-11-24 17:33 UTC, Yuta SATOH
Details | Diff
sample patch for boot0-9.1_rc3.ebuild (409815-new.patch,976 bytes, patch)
2012-11-25 11:41 UTC, Yuta SATOH
Details | Diff
sample patch for boot0-9.1_rc3.ebuild (409815-final.patch,1.02 KB, patch)
2012-11-26 11:28 UTC, Yuta SATOH
Details | Diff
backport patch for boot0-9.1.ebuild (409815-boot0-9.1.ebuild.patch,361 bytes, patch)
2013-08-13 13:32 UTC, Yuta SATOH
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Yao (RETIRED) gentoo-dev 2012-03-27 02:15:21 UTC
Created attachment 306809 [details]
sys-freebsd/boot0-9.0 build.log of failure

It looks like the stage2 bootloader is too large. It claims "-669 bytes available" with GCC 4.6. If I do `env CC=clang emerge -1v sys-freebsd/boot0`, it will claim "-141 bytes available". This occurs regardless of CFLAGS.

# emerge --info
Portage 2.2.0_alpha93 (default/bsd/fbsd/x86/9.0, gcc-4.6.2, freebsd-lib-9.0, 9.0-RELEASE i386)
=================================================================
System uname: FreeBSD-9.0-RELEASE-i386-32bit-ELF
Timestamp of tree: Wed, 21 Mar 2012 22:00:01 +0000
ccache version 3.1.7 [enabled]
app-shells/bash:         4.2_p24
dev-lang/python:         2.7.2-r3, 3.2.2-r1
dev-util/ccache:         3.1.7
dev-util/pkgconfig:      0.26
sys-apps/baselayout:     2.1
sys-apps/openrc:         0.9.9.3
sys-devel/autoconf:      2.68
sys-devel/automake:      1.9.6-r3, 1.11.3
sys-devel/binutils:      2.20.1-r1
sys-devel/gcc:           4.5.3-r2, 4.6.2
sys-devel/gcc-config:    1.5.1-r1
sys-devel/libtool:       2.4.2
sys-devel/make:          3.82-r3
sys-freebsd/freebsd-lib: 9.0 (virtual/os-headers)
Repositories: gentoo local_overlay
Installed sets: 
ACCEPT_KEYWORDS="x86-fbsd ~x86-fbsd"
ACCEPT_LICENSE="* -@EULA"
CBUILD="i686-gentoo-freebsd9.0"
CFLAGS="-O2 -pipe -march=amdfam10 -mcx16 -msahf -mpopcnt -mabm --param l1-cache-size=64 --param l1-cache-line-size=64 --param l2-cache-size=512 -mtune=amdfam10"
CHOST="i686-gentoo-freebsd9.0"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/terminfo"
CXXFLAGS="-O2 -pipe -march=amdfam10 -mcx16 -msahf -mpopcnt -mabm --param l1-cache-size=64 --param l1-cache-line-size=64 --param l2-cache-size=512 -mtune=amdfam10"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests binpkg-logs buildpkg ccache chflags distlocks ebuild-locks fixlafiles news noinfo parallel-fetch parallel-install preserve-libs protect-owned sfperms split-log strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync"
FFLAGS="-O2 -pipe -march=amdfam10 -mcx16 -msahf -mpopcnt -mabm --param l1-cache-size=64 --param l1-cache-line-size=64 --param l2-cache-size=512 -mtune=amdfam10"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--sort-common"
MAKEOPTS="-j7"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="3dnow 3dnowext acl berkdb cli cracklib crypt cups cxx dri gdbm iconv ipv6 java5 java6 modules ncurses nls nptlonly oss pam pcre perl python readline session sse3 sse4a ssl sysfs tcpd unicode x86-fbsd xorg zfs zlib" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan stage tables krita karbon braindump" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="FreeBSD" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="keyboard mouse" KERNEL="FreeBSD" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" PHP_TARGETS="php5-3" RUBY_TARGETS="ruby18" USERLAND="BSD" VIDEO_CARDS="apm ark chips cirrus cyrix dummy i128 intel mach64 mga neomagic nv r128 radeon rendition s3 s3virge savage siliconmotion sis tga trident tseng vmware fbdev" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LINGUAS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Richard Yao (RETIRED) gentoo-dev 2012-03-27 03:40:29 UTC
Running `CC=gcc-4.5.3 emerge -1v sys-freebsd/boot0` will workaround this problem.
Comment 2 Naohiro Aota gentoo-dev 2012-05-14 21:59:33 UTC
Also no problem with gcc-4.5.3-r2 here. >=gcc-4.6.0 is still masked for testing. I don't take much look at this while it's masked.
Comment 3 Richard Yao (RETIRED) gentoo-dev 2012-05-14 22:08:49 UTC
(In reply to comment #2)
> Also no problem with gcc-4.5.3-r2 here. >=gcc-4.6.0 is still masked for
> testing. I don't take much look at this while it's masked.

It might be worthwhile to make a tracker bug for GCC 4.6.0 support. Anyway, I agree that fixing this is a low priority.
Comment 4 Richard Yao (RETIRED) gentoo-dev 2012-05-27 02:33:00 UTC
*** Bug 417703 has been marked as a duplicate of this bug. ***
Comment 5 Richard Yao (RETIRED) gentoo-dev 2012-05-27 16:46:46 UTC
Created attachment 313301 [details, diff]
Fix a compilation error with LLVM/Clang 3.1

I am attaching the patch from bug #417703. It addresses a build failure caused by an invalid flag. It does not address the issue where the boot code is too large.
Comment 6 Richard Yao (RETIRED) gentoo-dev 2012-06-05 04:47:34 UTC
*** Bug 419503 has been marked as a duplicate of this bug. ***
Comment 7 Yuta SATOH 2012-06-14 12:01:07 UTC
Created attachment 315285 [details, diff]
sample patch for boot0-9.0-ebuild

Change to compile it using the clang or gcc-4.5.* .

for the compile to be successful with a clang, it is necessary to modify the following.

 src_prepare() {
-	sed -e '/-fomit-frame-pointer/d' -e '/-mno-align-long-strings/d' \
+	sed -e '/-mno-align-long-strings/d' \
 		-i "${S}"/i386/boot2/Makefile \
Comment 8 Richard Yao (RETIRED) gentoo-dev 2012-06-14 21:13:15 UTC
Created attachment 315343 [details, diff]
Fix a compilation error with GCC 4.6

I have attached a patch that pass '-Wl,-m,elf_i386_fbsd' to the compiler instead of '-m elf_i386_fbsd'. This prevents GCC 4.6 from throwing an error, but unfortunately, the binaries produced by GCC 4.6 are too big:

btxld -v -E 0x2000 -f bin -b /var/tmp/portage/sys-freebsd/boot0-9.0/work/sys/boot/i386/boot2/../btx/btx/btx -l boot2.ldr  -o boot2.ld -P 1 boot2.bin
kernel: ver=1.02 size=690 load=9000 entry=9010 map=16M pgctl=1:1
client: fmt=bin size=1759 text=0 data=0 bss=0 entry=0
output: fmt=bin size=1fe9 text=200 data=1de9 org=0 entry=0
-489 bytes available
Comment 9 Naohiro Aota gentoo-dev 2012-06-15 23:44:07 UTC
(In reply to comment #8)
> Created attachment 315343 [details, diff] [details, diff]
> Fix a compilation error with GCC 4.6
> 
> I have attached a patch that pass '-Wl,-m,elf_i386_fbsd' to the compiler
> instead of '-m elf_i386_fbsd'. This prevents GCC 4.6 from throwing an error,
> but unfortunately, the binaries produced by GCC 4.6 are too big:
> 
> btxld -v -E 0x2000 -f bin -b
> /var/tmp/portage/sys-freebsd/boot0-9.0/work/sys/boot/i386/boot2/../btx/btx/
> btx -l boot2.ldr  -o boot2.ld -P 1 boot2.bin
> kernel: ver=1.02 size=690 load=9000 entry=9010 map=16M pgctl=1:1
> client: fmt=bin size=1759 text=0 data=0 bss=0 entry=0
> output: fmt=bin size=1fe9 text=200 data=1de9 org=0 entry=0
> -489 bytes available

We can follow upstream discussion here.

http://lists.freebsd.org/pipermail/freebsd-current/2012-March/032345.html

Some patch are available
- Build boot2 separating for ufs1 and ufs2
http://people.freebsd.org/~jkim/boot2.diff
- Boot2 shirinking (Seems to have bugs. Be careful)
http://lists.freebsd.org/pipermail/freebsd-current/2012-March/032378.html

Also there's a branch to support big boot block
http://svnweb.freebsd.org/base/projects/bigbb/
Comment 10 Richard Yao (RETIRED) gentoo-dev 2012-06-16 02:01:35 UTC
We could try patching boot0 to let us disable ufs support entirely. Then we could have a USE flag that people could disable as a workaround.
Comment 11 Richard Yao (RETIRED) gentoo-dev 2012-06-21 03:00:12 UTC
(In reply to comment #7)
> Created attachment 315285 [details, diff] [details, diff]
> sample patch for boot0-9.0-ebuild
> 
> Change to compile it using the clang or gcc-4.5.* .
> 
> for the compile to be successful with a clang, it is necessary to modify the
> following.
> 
>  src_prepare() {
> -	sed -e '/-fomit-frame-pointer/d' -e '/-mno-align-long-strings/d' \
> +	sed -e '/-mno-align-long-strings/d' \
>  		-i "${S}"/i386/boot2/Makefile \

This is correct, but the code generated by GCC 4.6 (and GCC 4.7) is still too large.

It might be worthwhile to try implementing support for -mno-align-long-strings in our toolchain. The changes are isolated to a single file:

https://github.com/freebsd/freebsd-head/blob/master/contrib/gcc/config/i386/i386.c

Would anyone like to volunteer to forward port that to our toolchain?
Comment 12 Yuta SATOH 2012-11-24 17:30:43 UTC
Created attachment 330476 [details, diff]
sample patch for boot0-9.1_rc3.ebuild

sample patch for compiling boot0 using gcc4.6.
Comment 13 Yuta SATOH 2012-11-24 17:33:03 UTC
Created attachment 330478 [details, diff]
files/boot0-9.1-gcc46.patch

Fixed an issue too big of boot2
Comment 14 Yuta SATOH 2012-11-25 11:41:21 UTC
Created attachment 330530 [details, diff]
sample patch for boot0-9.1_rc3.ebuild

This patch changes that can be compiled using gcc-4.6 and clang-3.1

Tested on amd64-fbsd 9.1_rc3
* gcc-4.5.4
* gcc-4.6.3
* gcc-4.7.2
* changed clang-3.1-r5 (see bug #427430)


(In reply to comment #5)
> Created attachment 313301 [details, diff] [details, diff]
> Fix a compilation error with LLVM/Clang 3.1

not required in boot0-9.1_rc3.
Comment 15 Naohiro Aota gentoo-dev 2012-11-26 01:59:55 UTC
(In reply to comment #14)
> Created attachment 330530 [details, diff] [details, diff]
> sample patch for boot0-9.1_rc3.ebuild
> 
> This patch changes that can be compiled using gcc-4.6 and clang-3.1

It would be possible to use gcc-{majour,minor}-version() from toolchain-funcs.eclass instead of -dumpversion.
Comment 16 Yuta SATOH 2012-11-26 11:28:55 UTC
Created attachment 330604 [details, diff]
sample patch for boot0-9.1_rc3.ebuild

(In reply to comment #15)
> (In reply to comment #14)
> > Created attachment 330530 [details, diff] [details, diff] [details, diff]
> > sample patch for boot0-9.1_rc3.ebuild
> > 
> > This patch changes that can be compiled using gcc-4.6 and clang-3.1
> 
> It would be possible to use gcc-{majour,minor}-version() from
> toolchain-funcs.eclass instead of -dumpversion.

Thank you for your comment.
I changed to conditional branches using gcc-{major,minor}-version.

When >=gcc-4.6, add CFLAGS+= -fno-asynchronous-unwind-tables to i386/boot2/Makefile.
If set -m32 in CFLAGS, given to linker automatically LDFLAGS="-m elf_i386_fbsd".
so, add LDFLAGS="-m elf_i386_fbsd" in part minimum required for compile, remove the rest.

If you think no problem to apply in all cases, please remove the conditional branches.


Notes for Developers
Checked CPP env when toolchain-funcs get the version of gcc.
Please run the following in order to properly do a version check.
Of course, it is not necessary if you have changed the version with gcc-config in advance.

e.g.)
CC=gcc-4.5.4 CPP=${CC} emerge sys-freebsd/boot0
CC=clang CPP=${CC} emerge sys-freebsd/boot0


FYI,
toolchain-funcs.eclass
<snip>
_gcc_fullversion() {
        local ver="$1"; shift
        set -- `$(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__"`
        eval echo "$ver"
}
<snip>

# gcc-4.6.3 -Os -Q --help=optimize | grep unwind-tables
  -fasynchronous-unwind-tables          [enabled]
  -funwind-tables                       [disabled]

# gcc -dumpspecs
*link:
%{!static:--eh-frame-hdr}   %{m32:-m elf_i386_fbsd}   %{p:%nconsider using '-pg' instead of '-p' with gprof(1)}   %{v:-V}   %{assert*} %{R*} %{rpath*} %{defsym*}   %{shared:-Bshareable %{h*} %{soname*}}     %{!shared:       %{!static:         %{rdynamic:-export-dynamic} -dynamic-linker %(fbsd_dynamic_linker) }     %{static:-Bstatic}}   %{symbolic:-Bsymbolic}

# clang -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__"
4 2 1
Comment 17 Yuta SATOH 2013-08-13 13:32:39 UTC
Created attachment 355870 [details, diff]
backport patch for boot0-9.1.ebuild

fixed in 9.2_rc1.

Backport to boot0-9.1.
Comment 18 Alexis Ballier gentoo-dev 2013-08-27 23:08:17 UTC
(In reply to Yuta SATOH from comment #17)
> Created attachment 355870 [details, diff] [details, diff]
> backport patch for boot0-9.1.ebuild
> 
> fixed in 9.2_rc1.
> 
> Backport to boot0-9.1.

+  27 Aug 2013; Alexis Ballier <aballier@gentoo.org> boot0-9.1.ebuild:
+  backport fix from 9.2 for bug #409815 by Yuta SATOH
+