I've noticed that for many years now there have been a recurring Windowsrelated
complaint about "Error: unknown constraint 't'" message, which goes asearly 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 libmfunctions. Following these changes, at least 2 medium sized
projects which tcc couldn'tbuilt on windows (using the windows official
distribution package), now build and appearto 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
From 67b64295332c11641ccdcd582edbb040a5e528e0 Mon Sep 17 00:00:00 2001
From: "Avi Halachmi (:avih)"
Date: Sun, 1 Nov 2015 18:47:03 +0200
Subject: [PATCH] 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, the missing __fpclassify functions were added, as well as
fmin/fmax/round and their variants.
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/cgi