Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

No floating point headers under MinGW #2

Closed
rafalrusin opened this Issue · 13 comments

3 participants

@rafalrusin

$ gcc -I ivmai-JCGO-eadc2b4/include/ -I ivmai-JCGO-eadc2b4/include/boehmgc/ -I ivmai-JCGO-eadc2b4/native/ -I classpath-0.93/native/fdlibm/ out/Main.c
In file included from ivmai-JCGO-eadc2b4/include/jcgortl.c:151:0,
from out/Main.c:640:
ivmai-JCGO-eadc2b4/include/jcgofp.h:106:25: fatal error: fpu_control.h: No such file or directory
compilation terminated.

Before, I had no ieeefp.h error, but this I found in gnu classpath (-I classpath-0.93/native/fdlibm/)

$ gcc --version
gcc.exe (GCC) 4.6.1

system MinGW

I used JCGO version 1.14

@rafalrusin

Actually I saw that it compiled with NOFP, but I don't think that it's a proper fix.

gcc -DJCGO_NOFP -I ivmai-JCGO-eadc2b4/include/ -I ivmai-JCGO-eadc2b4/include/boehmgc/ -I ivmai-JCGO-eadc2b4/native/ out/Main.c libs/x86/mingw/libgc.a

@ivmai
Owner

Proper fix is to use -D_FPU_CONTROL_H

@ivmai
Owner

It looks like you do not have a true MinGW otherwise you would have MCW_EM defined in float.h.
Your system looks like Cygwin. I suggest to use build commands like [4102] (from Samples files)

@rafalrusin

Yeah, I might have something old.
Anyway, I was surprised it all worked on multithreaded, socket app, on Windows. It translated dependent library fine (commons cli 1.2).
I wrote an article on it: http://rrusin.blogspot.com/2012/08/how-to-create-native-java-app.html.
Great job!

@rafalrusin

Closing

@rafalrusin rafalrusin closed this
@ivmai
Owner

Interesting article. Thanks.
Some remarks:
1. I don't recommend to put your app source into JCGO tree, instead go to your app folder and execute (I suppose JCGO is unpacked to C:\JCGO):
c:\JCGO\jcgo.exe -sourcepath src;commons-cli-1.2-src/src/java netcat.NetCat @$~/stdpaths.in

  • it will produce "jcgo_Out" folder (in your apps folder) containing generated C source

  1. About GCC options: "-DJCGO_INET -DJCGO_NOFP -DJCGO_WIN32 -DJCGO_THREADS" works for your app but this is not optimal, I could recommend the following GCC invocation args (for your case):
    gcc -IC:\JCGO\include -IC:\JCGO\include\boehmgc -IC:\JCGO\native -O2 -fwrapv -fno-strict-aliasing -DJCGO_MATHEXT -DJCGO_FFDATA -DJCGO_THREADS -DJCGO_WIN32 -DJCGO_PARALLEL -DJCGO_USEGCJ -DJCGO_INET -DJCGO_SYSWCHAR -DJCGO_NOJNI -fno-optimize-sibling-calls -s jcgo_Out/Main.c C:\JCGO\libs\x86\mingw\libgcmt.a -lws2_32

  2. About compiler: both mingw.org are mingw-w64.sourceforge.net toolchains are supported (but the latter is more fresh and could produce code for Win64); other compilers for Windows (Cygwin, Visual Studio, Intel C++ compiler, Watcom, Digital Mars) are also supported by JCGO but the compiler options would differ from that for mingw.

@ivmai
Owner

About iOS: you are right and I'm aware of some apps in the Apple Store that are written in Java and translated using JCGO

@ivmai
Owner

About use of GC based on reference-counting (instead of BDWGC):
Java apps may contain cycles in the data structures (which cannot be handled correctly by reference counting).
More over, reference counting in a multi-threaded (on multi-core CPU) environment has a significant performance penalty on incrementing/decrementing a reference counter as this should be an atomic operation involving CPU core cache flushing (speaking in simple words).
On the other hand, there are algorithms that minimizes (or even eliminates) garbage collection pauses (e.g. BDWGC uses parallel mark algorithm running on all available CPU cores; about pause-less GC algorithms you could read, e.g., in http://www.azulsystems.com/sites/www.azulsystems.com/c4_paper_acm.pdf)

@rafalrusin

Thank you. I will refer these comments from the article.

@FreakMurderer

Problem with hello world
gcc -IC:\JCGO\include -IC:\JCGO\include\boehmgc -IC:\JCGO\native -DJCGO_FFDATA -o hello jcgo_Out\Main.c C:\JCGO\libs\x86\mingw\libgc.a

In file included from C:\JCGO\include/jcgortl.c:151:0,
from jcgo_Out\Main.c:641:
C:\JCGO\include/jcgofp.h:95:20: fatal error: ieeefp.h: No such file or directory
#include

@ivmai
Owner

Which compiler do you use? (The command that you use is for MinGW.) Anyway you could add -D_IEEEFP_H compiler argument.

@FreakMurderer

I'm, use current version of http://www.mingw.org/

  • JCGO quick start tips (for Win32)
  • my System win 7 x 64

I suppose, you should make fix for current libs or change documentation...

@ivmai
Owner

It is a bug of MinGW (actually a bug of GCC that used by MinGW). The problem that C:\MinGW\lib\gcc\mingw32\4.8.1\include\float.h does not contain #include_next at the end of file (thus C:\MinGW\mingw32\include\float.h is never included thus _MCW_EM is not defined causing JCGO to try to get necessary definitions in fpu_control.h).
As far as I know, GCC 4.6.3 and 4.7.0 have correct float.h.
There are some discussions raised by MinGW maintainers, e.g. https://gcc.gnu.org/ml/gcc-patches/2010-01/msg01114.html
As a workaround, I suggest to add the following command-line parameter: --include C:\MinGW\mingw32\include\float.h).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.