Re: [RFC] code changes/removal in boot2.c and ufsread.c so clang can compile boot2

2011-02-22 Thread Alexander Best
On Tue Feb 22 11, Roman Divacky wrote:
> fwiw, this is what I have:
> 
> http://lev.vlakno.cz/~rdivacky/boot2-diet.patch
> 
> with some llvm changed (-mrtd implementation + earlycse at the
> end of -O2) I am still at -113 bytes short on UFS1+UFS2 boot2

i was wondering...could we get rid of all the PATH_CONFIG and PATH_KERNEL
stuff? i tried this the other day with gptboot (which is pretty much
identical to boot2) and it seems booting a kernel directly got broken a long
time ago. so since invoking the loader is mandatory we could dump the kernel
loading code and the code that looks for entries in /boot.config completely.

you should be able to verify this by hitting a key before boot2 comes up and
enter the path to your kernel directly. for me it failed loading the kernel
(that's on amd64) with some btx error.

cheers.
alex

> 
> this is with latest llvm, with the one in fbsd it was at roughly -80
> (stack alignment changes)
> 
> On Tue, Feb 22, 2011 at 06:30:16PM +, Alexander Best wrote:
> > On Tue Feb 22 11, Warner Losh wrote:
> > > 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?
> > 
> > indeed i removed that part from the newest patch:
> > 
> > http://people.freebsd.org/~arundel/patches/boot2.c.diff3
> > 
> > > 
> > > Warner
> > 
> > -- 
> > a13x
> > ___
> > freebsd-toolchain@freebsd.org mailing list
> > http://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
> > To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"

-- 
a13x
___
freebsd-toolchain@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


Re: [RFC] code changes/removal in boot2.c and ufsread.c so clang can compile boot2

2011-02-22 Thread Roman Divacky
fwiw, this is what I have:

http://lev.vlakno.cz/~rdivacky/boot2-diet.patch

with some llvm changed (-mrtd implementation + earlycse at the
end of -O2) I am still at -113 bytes short on UFS1+UFS2 boot2

this is with latest llvm, with the one in fbsd it was at roughly -80
(stack alignment changes)

On Tue, Feb 22, 2011 at 06:30:16PM +, Alexander Best wrote:
> On Tue Feb 22 11, Warner Losh wrote:
> > 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?
> 
> indeed i removed that part from the newest patch:
> 
> http://people.freebsd.org/~arundel/patches/boot2.c.diff3
> 
> > 
> > Warner
> 
> -- 
> a13x
> ___
> freebsd-toolchain@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
> To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"
___
freebsd-toolchain@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


Re: [RFC] code changes/removal in boot2.c and ufsread.c so clang can compile boot2

2011-02-22 Thread Alexander Best
On Tue Feb 22 11, Warner Losh wrote:
> 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?

indeed i removed that part from the newest patch:

http://people.freebsd.org/~arundel/patches/boot2.c.diff3

> 
> Warner

-- 
a13x
___
freebsd-toolchain@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


Re: [RFC] code changes/removal in boot2.c and ufsread.c so clang can compile boot2

2011-02-22 Thread Warner Losh

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
___
freebsd-toolchain@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


Re: [RFC] code changes/removal in boot2.c and ufsread.c so clang can compile boot2

2011-02-19 Thread Alexander Best
On Sat Feb 19 11, Roman Divacky wrote:
> On Sat, Feb 19, 2011 at 01:01:36AM +, 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.
>  
> no, just copying it to /boot is not enough. you have to run bsdlabel -B to
> actually install it
> 
> > the patchset (against a recent HEAD) can be found here:
> > http://people.freebsd.org/~arundel/patches/boot2.c.diff2
> 
> the patch is wrong - you cant remove a.out support as "loader" still uses that
> 
> I like the int -> unsigned parts of the patch and also the memsize() removal
> may be interesting.

here's an updated patchset:
http://people.freebsd.org/~arundel/patches/boot2.c.diff3

maybe we could somehow get rid of the last printf() in ufsread.c:

while ((n = fsread(*ino, buf, DEV_BSIZE)) > 0)
for (s = buf; s < buf + DEV_BSIZE;) {
d = (void *)s;
if (ls)
printf("%s ", d->d_name);
else if (!strcmp(name, d->d_name)) {
*ino = d->d_ino;
return d->d_type;
}
s += d->d_reclen;
}
if (n != -1 && ls)
printf("\n");
return 0;

this would us gain another 26 bytes.

cheers.
alex

> 
> roman

-- 
a13x
___
freebsd-toolchain@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


Re: [RFC] code changes/removal in boot2.c and ufsread.c so clang can compile boot2

2011-02-19 Thread Alexander Best
On Sat Feb 19 11, Roman Divacky wrote:
> On Sat, Feb 19, 2011 at 01:01:36AM +, 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.
>  
> no, just copying it to /boot is not enough. you have to run bsdlabel -B to
> actually install it

oops. didn't know that.

> 
> > the patchset (against a recent HEAD) can be found here:
> > http://people.freebsd.org/~arundel/patches/boot2.c.diff2
> 
> the patch is wrong - you cant remove a.out support as "loader" still uses that
> 
> I like the int -> unsigned parts of the patch and also the memsize() removal
> may be interesting.

also some bootinfo.bi_* stuff can go. bde@ mentioned that all we actually need
are:

"Support for disk geometry fields in bootinfo was lost long ago.  This
leaves only the following bootinfo fields supported (by boot2) and
used: bi_version, bi_size, bi_symtab, bi_esymtab, bi_kernelname."

let me re-add the a.out code amd see how that works.

cheers.
alex

> 
> roman

-- 
a13x
___
freebsd-toolchain@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


Re: [RFC] code changes/removal in boot2.c and ufsread.c so clang can compile boot2

2011-02-19 Thread Roman Divacky
On Sat, Feb 19, 2011 at 01:01:36AM +, 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.
 
no, just copying it to /boot is not enough. you have to run bsdlabel -B to
actually install it

> the patchset (against a recent HEAD) can be found here:
> http://people.freebsd.org/~arundel/patches/boot2.c.diff2

the patch is wrong - you cant remove a.out support as "loader" still uses that

I like the int -> unsigned parts of the patch and also the memsize() removal
may be interesting.

roman
___
freebsd-toolchain@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"


[RFC] code changes/removal in boot2.c and ufsread.c so clang can compile boot2

2011-02-18 Thread Alexander Best
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

-- 
a13x
___
freebsd-toolchain@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"