Skip to contentSkip to conversation

Floating point usage

DISCUSSION Pavel Roskin 7 participants 8 messages Jun 4, 2008 – Jun 5, 2008

lore
Share & tools
lore
#0 lore raw

Hello!

I tried to compile the current grub on Fedora 9 for PowerPC, but it failed due to floating point usage in ls. Sorry, I don't have the exact message handy.

Anyway, there are several references to "float" and "double" in the code, and I think it's wrong. GRUB should be able to work on systems with no floating point support and on systems where the floating point device needs to be activated. Even Linux kernel avoids using floating point.

If everyone is fine, I'll try to remove all floating point stuff from the code.

Signature · 2 lines
Regards,
Pavel Roskin
#1 lore raw
Quoted 6 lines · Pavel Roskin

Hello!

I tried to compile the current grub on Fedora 9 for PowerPC, but it failed due to floating point usage in ls. Sorry, I don't have the exact message handy.

Quoted 9 lines

Anyway, there are several references to "float" and "double" in the code, and I think it's wrong. GRUB should be able to work on systems with no floating point support and on systems where the floating point device needs to be activated. Even Linux kernel avoids using floating point.

If everyone is fine, I'll try to remove all floating point stuff from the code.

Hi Pavel,

there is no need for hard-float support on the target machine. The libgcc provides all the software-emulation routines. Given that GRUB is linked against it. Which is likely as it is a necessity when compiling with gcc. Maybe your compilation is simply broken because of that one missing. Could you please post the error message?

Jan

#2 lore raw
Quoted 18 lines · Jan Kleinsorge
Quoted 6 lines · Pavel Roskin

Hello!

I tried to compile the current grub on Fedora 9 for PowerPC, but it failed due to floating point usage in ls. Sorry, I don't have the exact message handy.

Quoted 10 lines

Anyway, there are several references to "float" and "double" in the code, and I think it's wrong. GRUB should be able to work on systems with no floating point support and on systems where the floating point device needs to be activated. Even Linux kernel avoids using floating point.

If everyone is fine, I'll try to remove all floating point stuff from the code.

Quoted 7 lines

Hi Pavel,

there is no need for hard-float support on the target machine. The libgcc provides all the software-emulation routines. Given that GRUB is linked against it. Which is likely as it is a necessity when compiling with gcc. Maybe your compilation is simply broken because of that one missing. Could you please post the error message?

Nonetheless, using Floating Point operations in bootloaders and firmware is highly discouraged. If Floating Point is required for a bootloader (except, maybe, possibly, at all, for encryption) the bootloader is definitely broken, either in implementation or in design.

Also keep in mind, most operating systems expect the FPU to be in power on state.

Stefan

Signature · 5 lines
coresystems GmbH • Brahmsstr. 16 • D-79104 Freiburg i. Br.
      Tel.: +49 761 7668825 • Fax: +49 761 7664613
Email: [email protected]  • http://www.coresystems.de/
Registergericht: Amtsgericht Freiburg • HRB 7656
Geschäftsführer: Stefan Reinauer • Ust-IdNr.: DE245674866
#3 lore raw
Quoted 33 lines · On Thu, 05 Jun 2008 17:23:00 +0200 Stefan Reinauer <[email protected]>…
Quoted 18 lines · Jan Kleinsorge
Quoted 6 lines · Pavel Roskin

Hello!

I tried to compile the current grub on Fedora 9 for PowerPC, but it failed due to floating point usage in ls. Sorry, I don't have the exact message handy.

Quoted 10 lines

Anyway, there are several references to "float" and "double" in the code, and I think it's wrong. GRUB should be able to work on systems with no floating point support and on systems where the floating point device needs to be activated. Even Linux kernel avoids using floating point.

If everyone is fine, I'll try to remove all floating point stuff from the code.

Quoted 8 lines

Hi Pavel,

there is no need for hard-float support on the target machine. The libgcc provides all the software-emulation routines. Given that GRUB is linked against it. Which is likely as it is a necessity when compiling with gcc. Maybe your compilation is simply broken because of that one missing. Could you please post the error message?

Nonetheless, using Floating Point operations in bootloaders and firmware is highly discouraged. If Floating Point is required for a bootloader (except, maybe, possibly, at all, for encryption) the bootloader is definitely broken, either in implementation or in design.

Quoted 4 lines

Also keep in mind, most operating systems expect the FPU to be in power on state.

Stefan

The bootloader is "broken" if it uses floating point arithmetic? I think that while GRUB should not REQUIRE an FPU, it could use software floating point if there was a good reason to do so (and it would not be broken as long is it was done portably). Though I only have minimal knowledge of encryption algorithms, I don't think that floating point math is often used.

I think that avoiding floating point math as Pavel Roskin suggested is good, though I don't agree that Stefan's assertion that any use of floating point math is necessarily "broken" -- it might be better to say that we'd prefer not to pull in softfloat libraries (necessary since many targets have no FPU); therefore it is desirable to avoid floating point math.

Colin

#4 lore raw
In reply to Jan Kleinsorge

Le Thursday 05 June 2008 17:12:26 Jan Kleinsorge, vous avez écrit :

Quoted 2 lines

Given that GRUB is linked against it. Which is likely as it is a necessity when compiling with gcc.

...except if -nostdlib is given to gcc, which is the case in grub2. For the bootloader part at least, grub-emu is another question.
And there is an except to this except: If -lgcc is specified it will be used, and it is for the following archs, as far as I can see:
- powerpc-ieee1275
- i386-linuxbios
- i386-ieee1275

So half the supported archs don't need libgcc, I think it's enough to try avoiding that dependency.

Signature · 1 line
Vincent Pelletier
#7 lore raw
In reply to Pavel Roskin
Quoted 6 lines · Pavel Roskin

Hello!

I tried to compile the current grub on Fedora 9 for PowerPC, but it failed due to floating point usage in ls. Sorry, I don't have the exact message handy.

Quoted 8 lines

Anyway, there are several references to "float" and "double" in the code, and I think it's wrong. GRUB should be able to work on systems with no floating point support and on systems where the floating point device needs to be activated. Even Linux kernel avoids using floating point.

If everyone is fine, I'll try to remove all floating point stuff from the code.

Its only for printing units in human readable format. So its only small arithmetics to get it going nicely with integers. While you are there, can you modify it to use more proper units... MiB , KiB,...

#5 lore raw
In reply to Vincent Pelletier
Quoted 5 lines · Vincent Pelletier

And there is an except to this except: If -lgcc is specified it will be used, and it is for the following archs, as far as I can see:
- powerpc-ieee1275
- i386-linuxbios
- i386-ieee1275

Why would i386-linuxbios and i386-ieee1275 need libgcc but i386-pc don't? IIRC the tendency is that CISC platforms tend not to need libgcc for floating point but RISC ones do. Did I make a mistake on these two ports?

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What good is a phone call… if you are unable to speak?
(as seen on /.)
#6 lore raw
Quoted 4 lines · Robert Millan

Why would i386-linuxbios and i386-ieee1275 need libgcc but i386-pc don't? IIRC the tendency is that CISC platforms tend not to need libgcc for floating point but RISC ones do. Did I make a mistake on these two ports?

Those platforms require libgcc even for double precision integer divisions. It's a bit nasty.

Signature · 5 lines
coresystems GmbH • Brahmsstr. 16 • D-79104 Freiburg i. Br.
      Tel.: +49 761 7668825 • Fax: +49 761 7664613
Email: [email protected]  • http://www.coresystems.de/
Registergericht: Amtsgericht Freiburg • HRB 7656
Geschäftsführer: Stefan Reinauer • Ust-IdNr.: DE245674866