ats and mingw

78 views
Skip to first unread message

Brandon Barker

unread,
Dec 15, 2014, 9:41:33 PM12/15/14
to ats-lang-users

Hi,

I know ATS hasn't been compiled using mingw. Has anyone had any problems using mingw to build ats programs though? Or foresee problems? I haven't used it myself, but cygwin is problematic for JNI.

--
Brandon Barker
brandon...@gmail.com

gmhwxi

unread,
Dec 15, 2014, 11:29:26 PM12/15/14
to ats-lan...@googlegroups.com
This is my *understanding*. Have not tried it.

Step 1: Build ATS under Cygwin
Step 2: Use patscc/patsopt under Cygwin to generate C code
Step 3: Use -mno-cygwin to generate "native" code for Windows:

gcc –mno-cygwin

In order for Step3 to work, you need to have a new set of the following
files:

ccomp/runtime/pats_ccomp_*.h
${ATSHOME}/prelude/CATS/*.cats

I basically did this to support kernel programming:


You can use my code to get started quickly. How to use it?

Please take a look at the setup for the Arduino example:

gmhwxi

unread,
Dec 16, 2014, 3:53:18 AM12/16/14
to ats-lan...@googlegroups.com

It seems that the flag -mno-cygwin has been deprecated.
So you need MinGW to do Step 3.

In short, use Cygwin to build ATS2 and use MinGW to compile
the C output generated from ATS2 source code. Of course, using
Miscirsoft C/C++ compiler is another option.

H Zhang

unread,
Dec 17, 2014, 11:31:34 AM12/17/14
to ats-lan...@googlegroups.com
See this thread for a detailed discussion of this earlier this year. How time flies.
https://groups.google.com/forum/#!searchin/ats-lang-users/zhang/ats-lang-users/D218JKFWgew/cqdl8Ef-VeYJ

Brandon Barker

unread,
Dec 17, 2014, 11:35:46 AM12/17/14
to ats-lang-users
Indeed. I actually did look at that thread again during this process, but I thought the gist of it was more about trying to build ATS itself using mingw. Which is a great goal but one I'm not currently up to pursuing.

On Wed, Dec 17, 2014 at 11:31 AM, H Zhang <zht...@gmail.com> wrote:
See this thread for a detailed discussion of this earlier this year. How time flies.
https://groups.google.com/forum/#!searchin/ats-lang-users/zhang/ats-lang-users/D218JKFWgew/cqdl8Ef-VeYJ

--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/b735e3a4-e76d-4f17-98ab-772ff3697d74%40googlegroups.com.


--
Brandon Barker
brandon...@gmail.com

H Zhang

unread,
Dec 17, 2014, 11:39:00 AM12/17/14
to ats-lan...@googlegroups.com
Or you can specify the target platform to be windows native but you do need to install the corresponding gcc packages under Cygwin and you will live with the Cygwin version of mingw/gcc. If you want more up-to-date gcc versions then you need to go with mingw itself.

H Zhang

unread,
Dec 17, 2014, 11:42:15 AM12/17/14
to ats-lan...@googlegroups.com
Yes that was how it started but soon it was apparent that I need to use the cygwin to compile the tool chain:
https://groups.google.com/d/msg/ats-lang-users/D218JKFWgew/td7MQEYd7aAJ

Brandon Barker

unread,
Dec 17, 2014, 11:49:02 AM12/17/14
to ats-lang-users
Thanks, I'll have a more careful read when I switch back to this in a few days. From skimming, an interesting point of discussion on github recently is that patscc/patsopt should probably be rewritten if it is meant to be run using Windows file paths (I am not sure if the idea is to have two separate implementations, or just a more generalized single implementation). 

I am trying to sidestep the issue by starting patscc in cygwin's bash (which, when used with bash -l, can also have the advantage of loading environment variables from .bash_profile). I suppose/hope mingw's bash could work just as well.

Brandon Barker

unread,
Dec 25, 2014, 12:21:37 AM12/25/14
to ats-lang-users
To expand a bit on this process, I found the following relevant lines in a Makefile for adruino, which all seem like they will be relevant except the D_ATS_CCOMP_EXCEPTION_NONE; I assume there is no reason why this couldn't be supported on windows (supposedly Boehm GC supports Windows but I have not tried it yet).

MYCFLAGS := -fpermissive -w
MYCFLAGS += -D_ATS_CCOMP_HEADER_NONE
MYCFLAGS += -D_ATS_CCOMP_PRELUDE_NONE
MYCFLAGS += -D_ATS_CCOMP_PRELUDE_USER=\"arduino/H/pats_ccomp.h\"
MYCFLAGS += -D_ATS_CCOMP_EXCEPTION_NONE
MYCFLAGS += -D_ATSTYPE_VAR_SIZE=1024
MYCFLAGS += -I$(PATSHOME) -I$(PATSHOME)/ccomp/runtime -I${PATSHOMERELOC}/contrib
I will try to start with your kernelats code and modify as necessary to work with windows. Perhaps afterwards, we can somehow separate platform-dependent portions out elsewhere to make it easier to maintain (assuming the majority of the code in ccomp/runtime/pats_ccomp_*.h and  ${PATSHOME}/prelude/CATS/*.cats is not platform-dependent).

--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.

Hongwei Xi

unread,
Dec 26, 2014, 3:54:26 PM12/26/14
to ats-lan...@googlegroups.com
For now, there is no need to support exceptions on Windows. This piece can always be added later.


Brandon Barker

unread,
Dec 26, 2014, 6:37:33 PM12/26/14
to ats-lan...@googlegroups.com
OK, good point.

Now I wonder, what is the missing link here (likely not an ATS issue but a "user error"): 

 patscc -atsccomp /usr/bin/x86_64-w64-mingw32-gcc -D_XOPEN_SOURCE -D_JNI_IMPLEMENTATION -D_GNU_SOURCE -DATS_MEMALLOC_LIBC -fPIC -I/home/brand_000/ATS-Postiats -I/home/brand_000/ATS-Postiats/ccomp/runtime -IIATS /home/brand_000/ATS-Postiats-contrib/contrib -I/usr/Java/jdk1.8.0_25/include -I/usr/Java/jdk1.8.0_25/include/win32 -D__int64=int64_t -D_ATS_CCOMP_HEADER_NONE -D_ATS_CCOMP_PRELUDE_NONE -D_ATS_CCOMP_PRELUDE_USER=\"/home/brand_000/ATS-Postiats-contrib/contrib/libats-/bbarker/winats/pats_ccomp.h\" -c Calculator_controller.dats -verbose 2> tmp~

Excerpt from 'tmp~' (stderr):

exec(patsopt -IATS /home/brand_000/ATS-Postiats-contrib/contrib --output Calculator_controller_dats.c --dynamic Calculator_controller.dats)
exec(patsopt -IATS /home/brand_000/ATS-Postiats-contrib/contrib --output Calculator_controller_dats.c --dynamic Calculator_controller.dats) = 0
exec(/usr/bin/x86_64-w64-mingw32-gcc -D_XOPEN_SOURCE -D_JNI_IMPLEMENTATION -D_GNU_SOURCE -DATS_MEMALLOC_LIBC -fPIC -I/home/brand_000/ATS-Postiats -I/home/brand_000/ATS-Postiats/ccomp/runtime -I /home/brand_000/ATS-Postiats-contrib/contrib -I/usr/Java/jdk1.8.0_25/include -I/usr/Java/jdk1.8.0_25/include/win32 -D__int64=int64_t -D_ATS_CCOMP_HEADER_NONE -D_ATS_CCOMP_PRELUDE_NONE -D_ATS_CCOMP_PRELUDE_USER="/home/brand_000/ATS-Postiats-contrib/contrib/libats-/bbarker/winats/pats_ccomp.h" -c Calculator_controller_dats.c)
Calculator_controller_dats.c:1:0: warning: -fPIC ignored for target (all code is position independent) [enabled by default]
 /*
 ^
Calculator_controller_dats.c:57:10: error: #include expects "FILENAME" or <FILENAME>
 #include _ATS_CCOMP_PRELUDE_USER

Hongwei Xi

unread,
Dec 26, 2014, 9:44:45 PM12/26/14
to ats-lan...@googlegroups.com
Not sure how to make it work on Cygwin. Maybe:

-D_ATS_CCOMP_PRELUDE_USER='"/home/brand_000/ATS-Postiats-contrib/contrib/libats-/bbarker/winats/pats_ccomp.h"'

(putting double quotes inside single quotes).

Brandon Barker

unread,
Dec 27, 2014, 1:11:57 AM12/27/14
to ats-lan...@googlegroups.com
Your intuition seems to be correct (though I have no idea why, but it may be one of those things I don't want to know =)).
Reply all
Reply to author
Forward
0 new messages