* Re: [2.6.8.1/x86] The kernel is _always_ compiled with -msoft-float
2004-09-14 20:14 [2.6.8.1/x86] The kernel is _always_ compiled with -msoft-float Denis Zaitsev
@ 2004-09-14 19:36 ` Alan Cox
2004-09-14 20:39 ` Brian Gerst
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Alan Cox @ 2004-09-14 19:36 UTC (permalink / raw)
To: Denis Zaitsev; +Cc: Linux Kernel Mailing List
On Maw, 2004-09-14 at 21:14, Denis Zaitsev wrote:
> Why this kernel is always compiled with the FP emulation for x86?
> This is the line from the beginning of arch/i386/Makefile:
To catch incorrect use of FPU code in the kernel
^ permalink raw reply [flat|nested] 9+ messages in thread
* [2.6.8.1/x86] The kernel is _always_ compiled with -msoft-float
@ 2004-09-14 20:14 Denis Zaitsev
2004-09-14 19:36 ` Alan Cox
` (6 more replies)
0 siblings, 7 replies; 9+ messages in thread
From: Denis Zaitsev @ 2004-09-14 20:14 UTC (permalink / raw)
To: linux-kernel
Why this kernel is always compiled with the FP emulation for x86?
This is the line from the beginning of arch/i386/Makefile:
CFLAGS += -pipe -msoft-float
And it's hardcoded, it does not depend on CONFIG_MATH_EMULATION. So,
is this just a typo or not?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [2.6.8.1/x86] The kernel is _always_ compiled with -msoft-float
2004-09-14 20:14 [2.6.8.1/x86] The kernel is _always_ compiled with -msoft-float Denis Zaitsev
2004-09-14 19:36 ` Alan Cox
@ 2004-09-14 20:39 ` Brian Gerst
2004-09-14 20:40 ` Arjan van de Ven
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Brian Gerst @ 2004-09-14 20:39 UTC (permalink / raw)
To: Denis Zaitsev; +Cc: linux-kernel
Denis Zaitsev wrote:
> Why this kernel is always compiled with the FP emulation for x86?
> This is the line from the beginning of arch/i386/Makefile:
>
> CFLAGS += -pipe -msoft-float
>
> And it's hardcoded, it does not depend on CONFIG_MATH_EMULATION. So,
> is this just a typo or not?
To trap use of floating point in the kernel (not allowed). FPU
emulation is only for userspace.
--
Brian Gerst
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [2.6.8.1/x86] The kernel is _always_ compiled with -msoft-float
2004-09-14 20:14 [2.6.8.1/x86] The kernel is _always_ compiled with -msoft-float Denis Zaitsev
2004-09-14 19:36 ` Alan Cox
2004-09-14 20:39 ` Brian Gerst
@ 2004-09-14 20:40 ` Arjan van de Ven
2004-09-14 20:45 ` Dave Jones
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Arjan van de Ven @ 2004-09-14 20:40 UTC (permalink / raw)
To: Denis Zaitsev; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 439 bytes --]
On Tue, 2004-09-14 at 22:14, Denis Zaitsev wrote:
> Why this kernel is always compiled with the FP emulation for x86?
> This is the line from the beginning of arch/i386/Makefile:
>
> CFLAGS += -pipe -msoft-float
>
> And it's hardcoded, it does not depend on CONFIG_MATH_EMULATION. So,
> is this just a typo or not?
this is on purpose; this way we get an error if someone uses floating
point in the kernel.... which is BAD
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [2.6.8.1/x86] The kernel is _always_ compiled with -msoft-float
2004-09-14 20:14 [2.6.8.1/x86] The kernel is _always_ compiled with -msoft-float Denis Zaitsev
` (2 preceding siblings ...)
2004-09-14 20:40 ` Arjan van de Ven
@ 2004-09-14 20:45 ` Dave Jones
2004-09-14 20:48 ` Matt Mackall
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Dave Jones @ 2004-09-14 20:45 UTC (permalink / raw)
To: linux-kernel
On Wed, Sep 15, 2004 at 02:14:18AM +0600, Denis Zaitsev wrote:
> Why this kernel is always compiled with the FP emulation for x86?
> This is the line from the beginning of arch/i386/Makefile:
>
> CFLAGS += -pipe -msoft-float
>
> And it's hardcoded, it does not depend on CONFIG_MATH_EMULATION. So,
> is this just a typo or not?
It deliberatly causes build failures if folks use fp math in their code.
Dave
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [2.6.8.1/x86] The kernel is _always_ compiled with -msoft-float
2004-09-14 20:14 [2.6.8.1/x86] The kernel is _always_ compiled with -msoft-float Denis Zaitsev
` (3 preceding siblings ...)
2004-09-14 20:45 ` Dave Jones
@ 2004-09-14 20:48 ` Matt Mackall
2004-09-14 21:39 ` Denis Zaitsev
2004-09-15 15:35 ` Tonnerre
6 siblings, 0 replies; 9+ messages in thread
From: Matt Mackall @ 2004-09-14 20:48 UTC (permalink / raw)
To: linux-kernel
On Wed, Sep 15, 2004 at 02:14:18AM +0600, Denis Zaitsev wrote:
> Why this kernel is always compiled with the FP emulation for x86?
> This is the line from the beginning of arch/i386/Makefile:
>
> CFLAGS += -pipe -msoft-float
>
> And it's hardcoded, it does not depend on CONFIG_MATH_EMULATION. So,
> is this just a typo or not?
It catches bogus attempts to use floating point in the kernel by
making them error at link-time.
--
Mathematics is the supreme nostalgia of our time.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [2.6.8.1/x86] The kernel is _always_ compiled with -msoft-float
2004-09-14 20:14 [2.6.8.1/x86] The kernel is _always_ compiled with -msoft-float Denis Zaitsev
` (4 preceding siblings ...)
2004-09-14 20:48 ` Matt Mackall
@ 2004-09-14 21:39 ` Denis Zaitsev
2004-09-15 15:35 ` Tonnerre
6 siblings, 0 replies; 9+ messages in thread
From: Denis Zaitsev @ 2004-09-14 21:39 UTC (permalink / raw)
To: linux-kernel
Cc: Alan Cox, Brian Gerst, Arjan van de Ven, Dave Jones, Matt Mackall
Thank everybody.
Whould it be better to document the trick? At least, this will
prevent the others from suspicions.
--- arch/i386/Makefile.orig 2004-08-14 16:55:10.000000000 +0600
+++ arch/i386/Makefile 2004-09-15 03:37:49.000000000 +0600
@@ -20,6 +20,8 @@ OBJCOPYFLAGS := -O binary -R .note -R .c
LDFLAGS_vmlinux :=
CHECK := $(CHECK) -D__i386__=1
+# The FP must not be used in the kernel code. So, the bogus compiler
+# flag is here to catch such an attempts at the link stage.
CFLAGS += -pipe -msoft-float
# prevent gcc from keeping the stack 16 byte aligned
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [2.6.8.1/x86] The kernel is _always_ compiled with -msoft-float
2004-09-14 20:14 [2.6.8.1/x86] The kernel is _always_ compiled with -msoft-float Denis Zaitsev
` (5 preceding siblings ...)
2004-09-14 21:39 ` Denis Zaitsev
@ 2004-09-15 15:35 ` Tonnerre
2004-09-15 15:51 ` Ian Campbell
6 siblings, 1 reply; 9+ messages in thread
From: Tonnerre @ 2004-09-15 15:35 UTC (permalink / raw)
To: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1253 bytes --]
Salut,
On Wed, Sep 15, 2004 at 02:14:18AM +0600, Denis Zaitsev wrote:
> Why this kernel is always compiled with the FP emulation for x86?
> This is the line from the beginning of arch/i386/Makefile:
>
> CFLAGS += -pipe -msoft-float
>
> And it's hardcoded, it does not depend on CONFIG_MATH_EMULATION. So,
> is this just a typo or not?
The problem is that the kernel can't use the FPU. I think this is
because its context is not saved on context switch (userland ->
kernel), so we'd end up messing up the FPU state, and userland
applications would get silly results for calculations with context
switches in between.
Thus we force gcc to use the library functions for floating point
arith, and since we don't link against gcc's lib, FPU users get a
fancy linker error.
If you want to use floating point arith inside the kernel, you're
probably wrong wanting it. If you really need it, you can
a) emulate it using fixed-point math on unsigned long or
b) manually save the FPU state, load your operations into it, operate,
get the results and restore the FPU state.
I have yet to see someone who really needs to do floating point maths
inside the kernel.
Tonnerre
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [2.6.8.1/x86] The kernel is _always_ compiled with -msoft-float
2004-09-15 15:35 ` Tonnerre
@ 2004-09-15 15:51 ` Ian Campbell
0 siblings, 0 replies; 9+ messages in thread
From: Ian Campbell @ 2004-09-15 15:51 UTC (permalink / raw)
To: Tonnerre; +Cc: Linux Kernel Mailing List
On Wed, 2004-09-15 at 16:35, Tonnerre wrote:
> On Wed, Sep 15, 2004 at 02:14:18AM +0600, Denis Zaitsev wrote:
> > Why this kernel is always compiled with the FP emulation for x86?
> > This is the line from the beginning of arch/i386/Makefile:
> >
> > CFLAGS += -pipe -msoft-float
> >
> > And it's hardcoded, it does not depend on CONFIG_MATH_EMULATION. So,
> > is this just a typo or not?
[snip]
> Thus we force gcc to use the library functions for floating point
> arith, and since we don't link against gcc's lib, FPU users get a
> fancy linker error.
It's a shame that gcc doesn't have -mno-float which could disable
floating point completely and produce a more useful error message than a
missing symbol at link time
I searched for ages just yesterday for the "float" in some kernel code I
acquired recently... To be fair I was grepping for float and it was a
double that was being used so if I'd had my brain turned on I would have
found it quite quickly, but you get the point.
Has anyone ever suggested such a flag to the gcc folks?
Ian.
--
Ian Campbell
Current Noise: Megadeth - Pyschotron
Mind your own business, Spock. I'm sick of your halfbreed interference.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2004-09-15 15:53 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-14 20:14 [2.6.8.1/x86] The kernel is _always_ compiled with -msoft-float Denis Zaitsev
2004-09-14 19:36 ` Alan Cox
2004-09-14 20:39 ` Brian Gerst
2004-09-14 20:40 ` Arjan van de Ven
2004-09-14 20:45 ` Dave Jones
2004-09-14 20:48 ` Matt Mackall
2004-09-14 21:39 ` Denis Zaitsev
2004-09-15 15:35 ` Tonnerre
2004-09-15 15:51 ` Ian Campbell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox