From owner-freebsd-toolchain@FreeBSD.ORG Tue Feb 22 18:17:05 2011 Return-Path: Delivered-To: freebsd-toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 11AAC106566B for ; Tue, 22 Feb 2011 18:17:05 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id C19768FC08 for ; Tue, 22 Feb 2011 18:17:04 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.3/8.14.1) with ESMTP id p1MIDPqa024544 for ; Tue, 22 Feb 2011 11:13:26 -0700 (MST) (envelope-from imp@bsdimp.com) Message-ID: <4D63FCC1.4040108@bsdimp.com> Date: Tue, 22 Feb 2011 11:13:21 -0700 From: Warner Losh User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.13) Gecko/20101211 Thunderbird/3.1.7 MIME-Version: 1.0 To: freebsd-toolchain@freebsd.org References: <20110219010136.GA92824@freebsd.org> In-Reply-To: <20110219010136.GA92824@freebsd.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [RFC] code changes/removal in boot2.c and ufsread.c so clang can compile boot2 X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Feb 2011 18:17:05 -0000 On 02/18/2011 18:01, Alexander Best wrote: > hi everybody, > > r218745 triggered quite a discussion about dead code in boot2.c. i talked to > roman (rdivacky@) and we were trying to improve the situation so that boot2 > would build with clang 2.8 (base) and the latest development version of > clang (trunk). a lot of the ideas came from Bruce (bde@). > > i'd really appreciate, if somebody could have a look at this patchset. for me > it strips down the boot2 code so clang is able to compile it just fine. please > bear in mind that this has to work with boot2 supporting UFS1 *and* UFS2. so > please be sure not to override BOOT2_UFS in your src.conf or some place else. > > you should be able to test the (hopefully sucessfully) compiled boot2 binary > by copying it to /boot. please be sure to keep a backup of your existing boot2 > file in case something breaks. > > the patchset (against a recent HEAD) can be found here: > http://people.freebsd.org/~arundel/patches/boot2.c.diff2 > > cheers. > alex > Here's some comments: @@ -88,7 +97,7 @@ static ino_t lookup(const char *); static ssize_t fsread(ino_t, void *, size_t); static int ls, dsk_meta; -static uint32_t fs_off; +static uint32_t fs_off = 0; static __inline int fsfind(const char *name, ino_t * ino) @@ -98,7 +107,6 @@ fsfind(const char *name, ino_t * ino) char *s; ssize_t n; - fs_off = 0; while ((n = fsread(*ino, buf, DEV_BSIZE))> 0) for (s = buf; s< buf + DEV_BSIZE;) { d = (void *)s; How does the first part of this diff change things? bss gets the uninitialized and the data initialized to 0. but we also have this later: @@ -238,7 +245,6 @@ fsread(ino_t inode, void *buf, size_t nbyte) #endif inomap = inode; - fs_off = 0; blkmap = indmap = 0; } s = buf; - if (N_GETMAGIC(hdr.ex) == ZMAGIC) - fmt = 0; - else if (IS_ELF(hdr.eh)) + if (IS_ELF(eh)) fmt = 1; Doesn't this remove a.out support? Warner