Bug 55175 - i386/sfp-exceptions.c:52:7: error: impossible constraint in 'asm'
Summary: i386/sfp-exceptions.c:52:7: error: impossible constraint in 'asm'
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: 4.7.3
Assignee: Uroš Bizjak
URL: http://gcc.gnu.org/ml/gcc-patches/201...
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-02 05:24 UTC by Ralf Corsepius
Modified: 2012-11-05 14:38 UTC (History)
2 users (show)

See Also:
Host:
Target: x86
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
*.i of the file raising the breakdown (561 bytes, application/octet-stream)
2012-11-02 05:24 UTC, Ralf Corsepius
Details
Proposed patch (608 bytes, patch)
2012-11-02 10:01 UTC, Uroš Bizjak
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Corsepius 2012-11-02 05:24:05 UTC
Created attachment 28594 [details]
*.i of the file raising the breakdown

Bootstrapping gcc-trunk (xgcc (GCC) 4.8.0 20120927 (experimental)) fails with this error for --target=i386-rtems4.11:

...
/users/rtems/src/rtems.org/rtems-gcc/BUILD-i386/./gcc/xgcc -B/users/rtems/src/rtems.org/rtems-gcc/BUILD-i386/./gcc/ -nostdinc -B/users/rtems/src/rtems.org/rtems-gcc/BUILD-i386/i386-rtems4.11/soft-float/newlib/ -isystem /users/rtems/src/rtems.org/rtems-gcc/BUILD-i386/i386-rtems4.11/soft-float/newlib/targ-include -isystem /users/rtems/src/rtems.org/rtems-gcc/newlib/libc/include -B/opt/rtems-4.11/i386-rtems4.11/bin/ -B/opt/rtems-4.11/i386-rtems4.11/lib/ -isystem /opt/rtems-4.11/i386-rtems4.11/include -isystem /opt/rtems-4.11/i386-rtems4.11/sys-include  -msoft-float -g -O2 -Wall -O2 -I../../../../libgcc/../newlib/libc/sys/rtems/include -g -O2 -Wall -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -Dinhibit_libc  -I. -I. -I../../.././gcc -I../../../../libgcc -I../../../../libgcc/. -I../../../../libgcc/../gcc -I../../../../libgcc/../include  -DHAVE_CC_TLS  -o sfp-exceptions.o -MT sfp-exceptions.o -MD -MP -MF sfp-exceptions.dep  -c ../../../../libgcc/config/i386/sfp-exceptions.c -fvisibility=hidden -DHIDE_EXPORTS
../../../../libgcc/config/i386/sfp-exceptions.c: In function '__sfp_handle_exceptions':
../../../../libgcc/config/i386/sfp-exceptions.c:52:7: error: impossible constraint in 'asm'
       asm volatile ("fdiv\t{%y0, %0|%0, %y0}" : "+t" (f));
       ^
../../../../libgcc/config/i386/sfp-exceptions.c:62:7: error: impossible constraint in 'asm'
       asm volatile ("fdivs\t%1" : "+t" (f) : "m" (g));
       ^
make: *** [sfp-exceptions.o] Error 1
Comment 1 Uroš Bizjak 2012-11-02 10:01:44 UTC
Created attachment 28596 [details]
Proposed patch

Patch that disables relevant parts of soft-fp library
Comment 2 Uroš Bizjak 2012-11-02 10:05:24 UTC
Can you please try to build with attached (untested) patch?

The patch disables the part that handles exceptions and where rounding mode is set. We need either x87 or SSE control register for this functionality.
Comment 3 Joel Sherrill 2012-11-02 13:29:45 UTC
(In reply to comment #2)
> Can you please try to build with attached (untested) patch?
> 
> The patch disables the part that handles exceptions and where rounding mode is
> set. We need either x87 or SSE control register for this functionality.

The patch lets the tool build. I successfully built i386-rtems4.11 using binutils and newlib cvs heads.

Please commit and close this.

Thanks for fixing this. i386 soft float doesn't attract much attention but some people still care. :)
Comment 4 uros 2012-11-02 14:09:09 UTC
Author: uros
Date: Fri Nov  2 14:09:02 2012
New Revision: 193095

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=193095
Log:
	PR target/55175
	* config/i386/sfp-exceptions.c: Guard with _SOFT_FLOAT.
	* config/i386/sfp-machine.h: Guard exception handling
	code with _SOFT_FLOAT.
	* config/i386/32/sfp-machine.h: Guard rounding handling
	code with _SOFT_FLOAT.
	* config/i386/64/sfp-machine.h: Ditto.


Modified:
    trunk/libgcc/ChangeLog
    trunk/libgcc/config/i386/32/sfp-machine.h
    trunk/libgcc/config/i386/64/sfp-machine.h
    trunk/libgcc/config/i386/sfp-exceptions.c
    trunk/libgcc/config/i386/sfp-machine.h
Comment 5 Uroš Bizjak 2012-11-02 14:26:09 UTC
Fixed.
Comment 6 Ralf Corsepius 2012-11-03 06:25:33 UTC
I can confirm i386-rtems4.11-gcc now builds.

@Uros: I am inclined to believe this patch probably should be backported to 4.7.x.

At least, RTEMS is facing bizarre compilation issues, which I would not want to be related to similar issues as this.
Comment 7 uros 2012-11-04 18:58:32 UTC
Author: uros
Date: Sun Nov  4 18:58:29 2012
New Revision: 193140

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=193140
Log:
	PR target/55175
	* config/i386/32/sfp-machine.h: Guard exception handling and
	rounding handling code with _SOFT_FLOAT.
	* config/i386/64/sfp-machine.h: Ditto.


Modified:
    branches/gcc-4_7-branch/libgcc/ChangeLog
    branches/gcc-4_7-branch/libgcc/config/i386/32/sfp-machine.h
    branches/gcc-4_7-branch/libgcc/config/i386/64/sfp-machine.h
Comment 8 Uroš Bizjak 2012-11-04 18:59:53 UTC
(In reply to comment #6)
> I can confirm i386-rtems4.11-gcc now builds.
> 
> @Uros: I am inclined to believe this patch probably should be backported to
> 4.7.x.

H have backported similar change to 4.7 branch. Please reopen the PR if there are still problems.
Comment 9 Ralf Corsepius 2012-11-05 11:44:22 UTC
(In reply to comment #8)
> H have backported similar change to 4.7 branch.
Thanks for the backport.

> Please reopen the PR if there are still problems.
Unfortunately, your patch doesn't seem to help much:

GCC-4.7's soft-float still seems to be pulling in fp routine from inside of newlib:
...
/opt/rtems-4.11/lib/gcc/i386-rtems4.11/4.7.2/../../../../i386-rtems4.11/lib/soft-float/libc.a(lib_a-svfprintf.o): In function `_svfprintf_r':
/builddir/build/BUILD/rtems-4.11-i386-rtems4.11-gcc-4.7.2/build/i386-rtems4.11/soft-float/newlib/libc/stdio/../../../../../../gcc-4.7.2/newlib/libc/stdio/vfprintf.c:1072: undefined reference to `__truncxfdf2'
/builddir/build/BUILD/rtems-4.11-i386-rtems4.11-gcc-4.7.2/build/i386-rtems4.11/soft-float/newlib/libc/stdio/../../../../../../gcc-4.7.2/newlib/libc/stdio/vfprintf.c:1084: undefined reference to `__ltdf2'
/builddir/build/BUILD/rtems-4.11-i386-rtems4.11-gcc-4.7.2/build/i386-rtems4.11/soft-float/newlib/libc/stdio/../../../../../../gcc-4.7.2/newlib/libc/stdio/vfprintf.c:1556: undefined reference to `__eqdf2'
/builddir/build/BUILD/rtems-4.11-i386-rtems4.11-gcc-4.7.2/build/i386-rtems4.11/soft-float/newlib/libc/stdio/../../../../../../gcc-4.7.2/newlib/libc/stdio/vfprintf.c:1603: undefined reference to `__nedf2'
Comment 10 Uroš Bizjak 2012-11-05 12:11:53 UTC
(In reply to comment #9)
> (In reply to comment #8)
> > H have backported similar change to 4.7 branch.
> Thanks for the backport.
> 
> > Please reopen the PR if there are still problems.
> Unfortunately, your patch doesn't seem to help much:
> 
> GCC-4.7's soft-float still seems to be pulling in fp routine from inside of
> newlib:

This is the other way around: newlib doesn't find libgcc.

This is newlib's problem.
Comment 11 Uroš Bizjak 2012-11-05 12:28:53 UTC
(In reply to comment #9)
> (In reply to comment #8)
> > H have backported similar change to 4.7 branch.
> Thanks for the backport.
> 
> > Please reopen the PR if there are still problems.
> Unfortunately, your patch doesn't seem to help much:
> 
> GCC-4.7's soft-float still seems to be pulling in fp routine from inside of
> newlib:

You should use t-softfp instead of 386/t-softfp for i[34567]86-*-rtems* in libgcc/config.host.

In fact, there should be no i386/t-softfp for any x86 target.
Comment 12 Ralf Corsepius 2012-11-05 12:41:56 UTC
(In reply to comment #11)

> You should use t-softfp instead of 386/t-softfp for i[34567]86-*-rtems* in
> libgcc/config.host.
> 
> In fact, there should be no i386/t-softfp for any x86 target.

You mean, we should apply a patch similar to this?

--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -568,7 +568,7 @@ i[34567]86-*-nto-qnx*)
        extra_parts=crtbegin.o
        ;;
 i[34567]86-*-rtems*)
-       tmake_file="$tmake_file i386/t-softfp i386/t-crtstuff"
+       tmake_file="$tmake_file i386/t-crtstuff"
        extra_parts="$extra_parts crti.o crtn.o"
        ;;
 i[34567]86-*-solaris2* | x86_64-*-solaris2.1[0-9]*)
@@ -1165,6 +1165,7 @@ i[34567]86-*-darwin* | x86_64-*-darwin* | \
   i[34567]86-*-kfreebsd*-gnu | x86_64-*-kfreebsd*-gnu | \
   i[34567]86-*-linux* | x86_64-*-linux* | \
   i[34567]86-*-gnu* | \
+  i[34567]86-*-rtems* | \
   i[34567]86-*-solaris2* | x86_64-*-solaris2.1[0-9]* | \
   i[34567]86-*-cygwin* | i[34567]86-*-mingw* | x86_64-*-mingw* | \
   i[34567]86-*-freebsd* | x86_64-*-freebsd*)


The breakdown above is with this patch applied.
Comment 13 Uroš Bizjak 2012-11-05 14:15:16 UTC
(In reply to comment #12)

> > You should use t-softfp instead of 386/t-softfp for i[34567]86-*-rtems* in
> > libgcc/config.host.
> > 
> > In fact, there should be no i386/t-softfp for any x86 target.
> 
> You mean, we should apply a patch similar to this?

Yes.

> The breakdown above is with this patch applied.

Then the problem is either in newlib or generic libgcc configury.

Anyway, original problem with soft-fp was fixed.
Comment 14 Uroš Bizjak 2012-11-05 14:24:43 UTC
(In reply to comment #13)

> Then the problem is either in newlib or generic libgcc configury.

Please note that t-fdpbit is not enabled by default for x86 anymore. I don't know if this was intentional omission during libgcc conversion, but nobody missed it until today.

The second part of your patch enables TFmode soft-float, probably not needed for RTEMS. I think that you need either t-fdpbit or t-softfp-sfdf added to i[34567]86-*-rtems*)
Comment 15 Ralf Corsepius 2012-11-05 14:38:44 UTC
(In reply to comment #14)
> (In reply to comment #13)
> 
> > Then the problem is either in newlib or generic libgcc configury.

I meanwhile came to the latter conclusion. 

The math calls are being pulled-in by gcc's code generation from inside of newlib's libm, but soft-fp emulation is missing in libgcc. As we have both hard and soft-float multilib variants, I think RTEMS needs a "softfp wrapper".

> Please note that t-fdpbit is not enabled by default for x86 anymore. I don't
> know if this was intentional omission during libgcc conversion, but nobody
> missed it until today.

OK, will check.

> The second part of your patch enables TFmode soft-float, probably not needed
> for RTEMS. I think that you need either t-fdpbit or t-softfp-sfdf added to
> i[34567]86-*-rtems*)

Thanks for these hints - I am currently investigating, but ... things like these take _a lot of time_.