tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] RFC [PATCH] win: libm: fix "unknown constraint 't'", miss


From: avih
Subject: [Tinycc-devel] RFC [PATCH] win: libm: fix "unknown constraint 't'", missing fpclassify/round/etc
Date: Sun, 1 Nov 2015 18:40:32 +0000 (UTC)

I've noticed that for many years now there have been a recurring Windows
related complaint about "Error: unknown constraint 't'" message, which goes as
early as 2007, e.g. https://lists.nongnu.org/archive/html/tinycc-devel/2007-07/msg00013.html

There appears to be a patch for it (didn't test it), but it seems it was never taken:
http://lists.gnu.org/archive/html/tinycc-devel/2014-08/msg00024.html

I decided to approach it from a different direction, and while at it also add 3 missing libm
functions. Following these changes, at least 2 medium sized projects which tcc couldn't
built on windows (using the windows official distribution package), now build and appear
to be working well (mujs and Duktape).

If there are no objections, I'll push that to the mob branch soon. The patch is attached,
and that's the commit message:
----------------------------------------------------------

win: libm: fix "unknown constraint 't'", missing  fpclassify/round/etc

Some libm functions were broken at win32/include/math.h in few ways:

1. Unknown constraint 't': a similar piece of code was used in several inline
   functions at math.h (from mingw), and currently the tcc asm doesn't support
   it. This broke __fpclassifyl, __isnan* and __signbit*, and indirectly broke
   the macros fpclassify, isfinite, isinf, isnan, isnormal and signbit.

2. Even if 't' was supported by tcc's asm, there were no definitions for
   __fpclassify and __fpclassifyf, therefore breaking the macro fpclassify.
   Newer mingw(w64) math.h doesn't have this issue, but still uses 't' in asm.

3. Other than the above, some common libm functions werere not implemented
   anywhere in the tcc Windows distribution package - mainly fmin/fmax/round.
   Newer mingw(64) math.h stil doesn't include these implementations.

To address these issues, code which used inline asm with 't' was replaced with
a C implementation, and the missing __fpclassify functions were added.

The code is mostly taken from MUSL rs-1.0 (MIT) [*], and is placed as inline
functions at win32/include/tcc/tcc_libm.h, which is now included from math.h,
and is also copied to the win32 install target.

Future enhancements:
- Support 't' contraint in asm. Newer mingw headers still use it, and it would
  make future porting of mingw headers easier.
- Enumerate the still-missing libm functions (if there are such) and add missing
  implementations. Most should be simple and will add good value to tcc.
- Possibly move the code at tcc/tcc_libm.h to a C file and create an actual
  libm.a library, or just create a dummy libm. For build procedures which expect
  libm, this could allow to complete successfully, assuming no yet-unimplemented
  functions are used.
- Add some tests for common libm functions.

[*] - http://git.musl-libc.org/cgit/musl/tree/src/math?h=rs-1.0
    - MUSL's license: http://git.musl-libc.org/cgit/musl/tree/COPYRIGHT?h=rs-1.0

Attachment: tcc.win.libm-fixes.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]