From owner-freebsd-current@FreeBSD.ORG Thu Mar 8 19:06:23 2012 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 474C8106566C for ; Thu, 8 Mar 2012 19:06:23 +0000 (UTC) (envelope-from peter@wemm.org) Received: from mail-yw0-f54.google.com (mail-yw0-f54.google.com [209.85.213.54]) by mx1.freebsd.org (Postfix) with ESMTP id 01EB28FC0A for ; Thu, 8 Mar 2012 19:06:22 +0000 (UTC) Received: by yhgm50 with SMTP id m50so521484yhg.13 for ; Thu, 08 Mar 2012 11:06:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wemm.org; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=KHh9WE1odna3espDFwt8AMPSEXLZLmiB7IQuCvn1ELU=; b=J5R9Sze1Ze9RLIRusRxycsqrXhceBWlrRbmHYJyWDncZ0vC4w1j/83S5zbxm9KUTw2 Ksmm0CzW676I/mNECKjJ9+lmPgp7awPIooydk93HfW+b0qWos7uvZpw5XAGrcvtjpOWL SIXEjy9jd9U2mVK9zuxsLb6iVp16FD/pokjQ0= MIME-Version: 1.0 Received: by 10.50.182.138 with SMTP id ee10mr18632839igc.43.1331232208852; Thu, 08 Mar 2012 10:43:28 -0800 (PST) Received: by 10.231.172.138 with HTTP; Thu, 8 Mar 2012 10:43:28 -0800 (PST) In-Reply-To: <201203071919.01511.jkim@FreeBSD.org> References: <201203071919.01511.jkim@FreeBSD.org> Date: Thu, 8 Mar 2012 10:43:28 -0800 Message-ID: From: Peter Wemm To: Jung-uk Kim Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQnYskjoHIWXQFluaf7Hhc0DUp5oouMXURl+2DIppjB+VeM6UYTi7At207VgzgTkFok1nvqp Cc: freebsd-current@freebsd.org, Jia-Shiun Li Subject: Re: boot2 overflow when building with clang X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Mar 2012 19:06:23 -0000 On Wed, Mar 7, 2012 at 4:18 PM, Jung-uk Kim wrote: > On Tuesday 06 March 2012 11:51 pm, Jia-Shiun Li wrote: >> I am not familiar with boot2, but it looks like allocated size for >> boot2 is not enough to hold code generated by clang. Reverting >> r232570 fixes it. >> >> =3D=3D=3D> sys/boot/i386/boot2 (all) >> objcopy -S -O binary boot1.out boot1 >> dd if=3D/dev/zero of=3Dboot2.ldr bs=3D512 count=3D1 >> clang -Os =A0-fno-guess-branch-probability =A0-fomit-frame-pointer >> -fno-unit-at-a-time =A0-mno-align-long-strings =A0-mrtd =A0-mregparm=3D3 >> -DUSE_XREAD =A0-DUFS1_AND_UFS2 =A0-DFLAGS=3D0x80 =A0-DSIOPRT=3D0x3f8 >> -DSIOFMT=3D0x3 =A0-DSIOSPD=3D9600 >> -I/usr/src/sys/boot/i386/boot2/../../common >> -I/usr/src/sys/boot/i386/boot2/../btx/lib -I. =A0-Wall >> -Waggregate-return -Wbad-function-cast -Wcast-align >> -Wmissing-declarations -Wmissing-prototypes -Wnested-externs >> -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings >> -Winline --param max-inline-insns-single=3D100 =A0-mllvm >> -stack-alignment=3D8 -mllvm -inline-threshold=3D3 =A0-mllvm >> -enable-load-pre=3Dfalse -ffreestanding -mpreferred-stack-boundary=3D2 >> -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float >> -std=3Dgnu99 =A0 =A0-S -o boot2.s.tmp >> /usr/src/sys/boot/i386/boot2/boot2.c >> sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s >> rm -f boot2.s.tmp >> clang =A0-c boot2.s >> clang -Os =A0-fno-guess-branch-probability =A0-fomit-frame-pointer >> -fno-unit-at-a-time =A0-mno-align-long-strings =A0-mrtd =A0-mregparm=3D3 >> -DUSE_XREAD =A0-DUFS1_AND_UFS2 =A0-DFLAGS=3D0x80 =A0-DSIOPRT=3D0x3f8 >> -DSIOFMT=3D0x3 =A0-DSIOSPD=3D9600 >> -I/usr/src/sys/boot/i386/boot2/../../common >> -I/usr/src/sys/boot/i386/boot2/../btx/lib -I. =A0-Wall >> -Waggregate-return -Wbad-function-cast -Wcast-align >> -Wmissing-declarations -Wmissing-prototypes -Wnested-externs >> -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings >> -Winline --param max-inline-insns-single=3D100 =A0-mllvm >> -stack-alignment=3D8 -mllvm -inline-threshold=3D3 =A0-mllvm >> -enable-load-pre=3Dfalse -ffreestanding -mpreferred-stack-boundary=3D2 >> -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float >> -std=3Dgnu99 =A0 =A0 -c >> /usr/src/sys/boot/i386/boot2/sio.S >> ld -static -N --gc-sections -nostdlib -Ttext 0x2000 -o boot2.out >> /usr/obj/usr/src/sys/boot/i386/boot2/../btx/lib/crt0.o boot2.o >> sio.o objcopy -S -O binary boot2.out boot2.bin >> btxld -v -E 0x2000 -f bin -b >> /usr/obj/usr/src/sys/boot/i386/boot2/../btx/btx/btx -l boot2.ldr >> -o boot2.ld -P 1 boot2.bin >> kernel: ver=3D1.02 size=3D690 load=3D9000 entry=3D9010 map=3D16M pgctl= =3D1:1 >> client: fmt=3Dbin size=3D15a1 text=3D0 data=3D0 bss=3D0 entry=3D0 >> output: fmt=3Dbin size=3D1e31 text=3D200 data=3D1c31 org=3D0 entry=3D0 >> -49 bytes available >> *** [boot2] Error code 1 >> >> Stop in /usr/src/sys/boot/i386/boot2. >> *** [all] Error code 1 >> >> Stop in /usr/src/sys/boot/i386. >> *** [all] Error code 1 >> >> Stop in /usr/src/sys/boot. >> *** [all] Error code 1 >> >> Stop in /usr/src/sys. >> *** [sys.all__D] Error code 1 >> >> Stop in /usr/src. >> *** [everything] Error code 1 >> >> Stop in /usr/src. >> *** [buildworld] Error code 1 >> >> Stop in /usr/src. > > Here is a patch to work around the problem: > > http://people.freebsd.org/~jkim/boot2.diff > > Please note this patch creates two separate boot codes, one for UFS1 > and one for UFS2. =A0To generate previous boot code (i.e., UFS1+UFS2) > with GCC, clean objects, add the following line to > your /etc/make.conf, rebuild, and install: > > BOOT2_UFS=3DUFS1_AND_UFS2 I think this should be committed. If you're concerned about separating them, you can make this case default for gcc. There's glue in src/Makefile.inc1 that gives some hints about how this is d= one .if ${MK_CLANG} !=3D "no" && (${MK_CLANG_IS_CC} !=3D "no" || ${CC:T:Mclang} =3D=3D "clang") eg: if building with clang, default to UFS2, else UFS1_AND_UFS2 But please commit something. Personally I think we could use the spare space in boot2 in any case. --=20 Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com; KI6FJV "All of this is for nothing if we don't go to the stars" - JMS/B5 "If Java had true garbage collection, most programs would delete themselves upon execution." -- Robert Sewell