Building ATS2 HEAD on OS X

I’m trying to build ATS2 on OS X (Maverick, Darwin 13) from the latest
source on GitHub. So far I’ve seen two problems:

First, I need to build ATS1 (anairiats) to bootstrap ATS2, but ATS1 uses
pthread_spin_lock(), which is not available on OS X. Is there a way to
build ATS1 without multithread support, just for the purpose
of bootstrapping ATS2? (Or better, when can we drop the ATS1 requirement
and bootstrap ATS2 with itself?)

Second, in both ATS1 and ATS2’s prelude/CATS/char.cats file, there are
definitions like:

#ifndef isascii

extern int isascii (int c) ; // _XOPEN_SOURCE

#endif // end of [isascii]

It’s the same thing for isblank() and toascii(). These functions are inline
functions in OS X’s ctype.h, but because they are declared as extern
functions here, they are not inline anymore and are included in the objects
files. As char.cats is included verbatim in many source files, I get
duplicate symbols when the linker tries to link their object files
together. If I delete these extern declarations the linking will succeed.

What’s the purpose of these conditionals? I think all the supported
platforms should have these C functions provided. Can we remove them?

Thanks in advance!

I have fixed the memset issue in gcats1.cats.

I think that the problem of atsopt not functioning properly was caused by a
faulty GC.

If you drop -O2 (or change it to -O1) when using gcc to compile the GC of
ATS, then the
problem may disappear.On Monday, December 9, 2013 12:12:11 AM UTC-5, Ming Lei wrote:

I’m trying to build ATS2 on OS X (Maverick, Darwin 13) from the latest
source on GitHub. So far I’ve seen two problems:

First, I need to build ATS1 (anairiats) to bootstrap ATS2, but ATS1 uses
pthread_spin_lock(), which is not available on OS X. Is there a way to
build ATS1 without multithread support, just for the purpose
of bootstrapping ATS2? (Or better, when can we drop the ATS1 requirement
and bootstrap ATS2 with itself?)

Second, in both ATS1 and ATS2’s prelude/CATS/char.cats file, there are
definitions like:

#ifndef isascii

extern int isascii (int c) ; // _XOPEN_SOURCE

#endif // end of [isascii]

It’s the same thing for isblank() and toascii(). These functions are
inline functions in OS X’s ctype.h, but because they are declared as
extern functions here, they are not inline anymore and are included in the
objects files. As char.cats is included verbatim in many source files, I
get duplicate symbols when the linker tries to link their object files
together. If I delete these extern declarations the linking will succeed.

What’s the purpose of these conditionals? I think all the supported
platforms should have these C functions provided. Can we remove them?

Thanks in advance!

So the process is indeed repeatable, although even if I re-compile ATS1
after GMP is installed, I will still need to run atslib manually on those
two files. Maybe it’s because my GMP is not at a standard location. I tried
several examples in the project Euler directory and the compiler seemed to
be working.

So basically:

  1. Install GMP.
  2. Download the latest version of ATS1 source from SourceForge.
  3. Remove all the occurrences of the “-O2” flags in ATS1’s makefiles,
    make then install it. Set $ATSHOME properly.
  4. Copy the directories libatsdoc and utils from the build directory to
    the libraries directory in $ATSHOME.
  5. Compile the two GMP related files with atslib.
  6. Set $PATSHOME to point to ATS2’s source tree. Build it.On Tuesday, December 10, 2013 12:23:03 AM UTC-6, Ming Lei wrote:

With these instructions I finally got ATS2 successfully built, and so far
the compiler seems to be working for simple problems.

Tomorrow I will re-do the whole building process again, just to make sure,
and also try more test cases.

Thank you.

On Monday, December 9, 2013 11:53:27 PM UTC-6, gmhwxi wrote:

After installing GMP, you need to re-do ./configure and then try to build
ATS1 again.

Here is a shortcut:

cd ${ATSHOME}
atslib libc/SATS/gmp.sats
atslib libc/DATS/gmp.dats

Then try to re-build ATS2. I don’t see any problems from this point on.

On Monday, December 9, 2013 12:12:11 AM UTC-5, Ming Lei wrote:

I’m trying to build ATS2 on OS X (Maverick, Darwin 13) from the latest
source on GitHub. So far I’ve seen two problems:

First, I need to build ATS1 (anairiats) to bootstrap ATS2, but ATS1 uses
pthread_spin_lock(), which is not available on OS X. Is there a way to
build ATS1 without multithread support, just for the purpose
of bootstrapping ATS2? (Or better, when can we drop the ATS1 requirement
and bootstrap ATS2 with itself?)

Second, in both ATS1 and ATS2’s prelude/CATS/char.cats file, there are
definitions like:

#ifndef isascii

extern int isascii (int c) ; // _XOPEN_SOURCE

#endif // end of [isascii]

It’s the same thing for isblank() and toascii(). These functions are
inline functions in OS X’s ctype.h, but because they are declared as
extern functions here, they are not inline anymore and are included in the
objects files. As char.cats is included verbatim in many source files,
I get duplicate symbols when the linker tries to link their object files
together. If I delete these extern declarations the linking will succeed.

What’s the purpose of these conditionals? I think all the supported
platforms should have these C functions provided. Can we remove them?

Thanks in advance!

Thanks for the quick response.

Not all the extern definitions for isascii() and isblank() have been
commented out in the updated ATS1 source. There are redundant definitions
start from line 255. I suggest we just remove them all.

I still see spin_lock related errors, for example:

*/Users/minglei/Downloads/ats-lang-anairiats-0.2.11/ccomp/lib64/output/_2fUsers_2fminglei_2fDownloads_2fats_2dlang_2danairiats_2d0_2e2_2e11_2flibc_2fDATS_2fpthread_2edats.c:55:28:
**error: **use of *undeclared identifier ‘pthread_spinlock_t’; did you
mean ‘pthread_rwlock_t’?

err = pthread_spin_init((pthread_spinlock_t*)p, pshared) ;

Is the installation instructions you linked meant for the release version
of ATS2 (Postiats 0.0.4) or the GitHub sources? For the 0.0.4 release I can
already build it successfully with the ctype.h related extern definitions
removed. For the sources from GitHub, I tried “make -f Makefile_devl”, but
some other makefiles it invokes still have ATS1 references like:

ATSCC=$(ATSHOME)/bin/atscc

That’s why I tried to build a working ATS1 first. Maybe there is a better
way to build from the GitHub sources without ATS1? If so I’d just skip the
ATS1 part for good.On Sunday, December 8, 2013 11:58:33 PM UTC-6, gmhwxi wrote:

  1. I have just uploaded an ATS1 package in which spinlock-related code is
    commented out.

  2. Also, the ifndef-stuff in char.cats has been commented out for now. It
    is not really needed.

  3. You can build ATS2 directly without relying on ATS1. See:

http://www.ats-lang.org/DOWNLOAD/#installation_srccomp

On Monday, December 9, 2013 12:12:11 AM UTC-5, Ming Lei wrote:

I’m trying to build ATS2 on OS X (Maverick, Darwin 13) from the latest
source on GitHub. So far I’ve seen two problems:

First, I need to build ATS1 (anairiats) to bootstrap ATS2, but ATS1 uses
pthread_spin_lock(), which is not available on OS X. Is there a way to
build ATS1 without multithread support, just for the purpose
of bootstrapping ATS2? (Or better, when can we drop the ATS1 requirement
and bootstrap ATS2 with itself?)

Second, in both ATS1 and ATS2’s prelude/CATS/char.cats file, there are
definitions like:

#ifndef isascii

extern int isascii (int c) ; // _XOPEN_SOURCE

#endif // end of [isascii]

It’s the same thing for isblank() and toascii(). These functions are
inline functions in OS X’s ctype.h, but because they are declared as
extern functions here, they are not inline anymore and are included in the
objects files. As char.cats is included verbatim in many source files, I
get duplicate symbols when the linker tries to link their object files
together. If I delete these extern declarations the linking will succeed.

What’s the purpose of these conditionals? I think all the supported
platforms should have these C functions provided. Can we remove them?

Thanks in advance!

With these instructions I finally got ATS2 successfully built, and so far
the compiler seems to be working for simple problems.

Tomorrow I will re-do the whole building process again, just to make sure,
and also try more test cases.

Thank you.On Monday, December 9, 2013 11:53:27 PM UTC-6, gmhwxi wrote:

After installing GMP, you need to re-do ./configure and then try to build
ATS1 again.

Here is a shortcut:

cd ${ATSHOME}
atslib libc/SATS/gmp.sats
atslib libc/DATS/gmp.dats

Then try to re-build ATS2. I don’t see any problems from this point on.

On Monday, December 9, 2013 12:12:11 AM UTC-5, Ming Lei wrote:

I’m trying to build ATS2 on OS X (Maverick, Darwin 13) from the latest
source on GitHub. So far I’ve seen two problems:

First, I need to build ATS1 (anairiats) to bootstrap ATS2, but ATS1 uses
pthread_spin_lock(), which is not available on OS X. Is there a way to
build ATS1 without multithread support, just for the purpose
of bootstrapping ATS2? (Or better, when can we drop the ATS1 requirement
and bootstrap ATS2 with itself?)

Second, in both ATS1 and ATS2’s prelude/CATS/char.cats file, there are
definitions like:

#ifndef isascii

extern int isascii (int c) ; // _XOPEN_SOURCE

#endif // end of [isascii]

It’s the same thing for isblank() and toascii(). These functions are
inline functions in OS X’s ctype.h, but because they are declared as
extern functions here, they are not inline anymore and are included in the
objects files. As char.cats is included verbatim in many source files, I
get duplicate symbols when the linker tries to link their object files
together. If I delete these extern declarations the linking will succeed.

What’s the purpose of these conditionals? I think all the supported
platforms should have these C functions provided. Can we remove them?

Thanks in advance!

  1. I have just uploaded an ATS1 package in which spinlock-related code is
    commented out.

  2. Also, the ifndef-stuff in char.cats has been commented out for now. It
    is not really needed.

  3. You can build ATS2 directly without relying on ATS1. See:

http://www.ats-lang.org/DOWNLOAD/#installation_srccompOn Monday, December 9, 2013 12:12:11 AM UTC-5, Ming Lei wrote:

I’m trying to build ATS2 on OS X (Maverick, Darwin 13) from the latest
source on GitHub. So far I’ve seen two problems:

First, I need to build ATS1 (anairiats) to bootstrap ATS2, but ATS1 uses
pthread_spin_lock(), which is not available on OS X. Is there a way to
build ATS1 without multithread support, just for the purpose
of bootstrapping ATS2? (Or better, when can we drop the ATS1 requirement
and bootstrap ATS2 with itself?)

Second, in both ATS1 and ATS2’s prelude/CATS/char.cats file, there are
definitions like:

#ifndef isascii

extern int isascii (int c) ; // _XOPEN_SOURCE

#endif // end of [isascii]

It’s the same thing for isblank() and toascii(). These functions are
inline functions in OS X’s ctype.h, but because they are declared as
extern functions here, they are not inline anymore and are included in the
objects files. As char.cats is included verbatim in many source files, I
get duplicate symbols when the linker tries to link their object files
together. If I delete these extern declarations the linking will succeed.

What’s the purpose of these conditionals? I think all the supported
platforms should have these C functions provided. Can we remove them?

Thanks in advance!

I have just uploaded an ATS1 package in which the issues you reported are
fixed.
Hopefully, it will work this time. I myself don’t have access to a MAC
right now.

In order to build the “bleeding edge” version of ATS2 on Github, you do
need to have ATS1
installed first.On Monday, December 9, 2013 12:12:11 AM UTC-5, Ming Lei wrote:

I’m trying to build ATS2 on OS X (Maverick, Darwin 13) from the latest
source on GitHub. So far I’ve seen two problems:

First, I need to build ATS1 (anairiats) to bootstrap ATS2, but ATS1 uses
pthread_spin_lock(), which is not available on OS X. Is there a way to
build ATS1 without multithread support, just for the purpose
of bootstrapping ATS2? (Or better, when can we drop the ATS1 requirement
and bootstrap ATS2 with itself?)

Second, in both ATS1 and ATS2’s prelude/CATS/char.cats file, there are
definitions like:

#ifndef isascii

extern int isascii (int c) ; // _XOPEN_SOURCE

#endif // end of [isascii]

It’s the same thing for isblank() and toascii(). These functions are
inline functions in OS X’s ctype.h, but because they are declared as
extern functions here, they are not inline anymore and are included in the
objects files. As char.cats is included verbatim in many source files, I
get duplicate symbols when the linker tries to link their object files
together. If I delete these extern declarations the linking will succeed.

What’s the purpose of these conditionals? I think all the supported
platforms should have these C functions provided. Can we remove them?

Thanks in advance!

With optimization completely turned off I finally managed to build ATS1. I
had to first build GMP because OS X doesn’t have it by default.

I had to manually copy the libatsdoc and utils directories to $ATSHOME/libbecause it seemed ATS2 needed them and they were not automatically
installed by ATS1’s Makefile.

Building ATS2 was smooth but when it got to the point to generate patsoptfrom object files, the linker complained about undefined symbols:

Undefined symbols for architecture x86_64:

_ATS_2d0_2e2_2e11_2libc_2SATS_2gmp_2esats__staload”, referenced from:

__2Users_2minglei_2Downloads_2ATS_2dPostiats_2src_2pats_intinf_2esats__staload
in pats_intinf_sats.o

__2Users_2minglei_2Downloads_2ATS_2dPostiats_2src_2pats_intinf_2edats__staload
in pats_intinf_dats.o

__2Users_2minglei_2Downloads_2ATS_2dPostiats_2src_2pats_intinf_2edats__dynload
in pats_intinf_dats.o

__2Users_2minglei_2Downloads_2ATS_2dPostiats_2src_2pats_lintprgm_myint_intinf_2edats__staload
in pats_lintprgm_myint_intinf_dats.o

__2Users_2minglei_2Downloads_2ATS_2dPostiats_2src_2pats_lintprgm_myint_intinf_2edats__dynload
in pats_lintprgm_myint_intinf_dats.o

__2Users_2minglei_2Downloads_2ATS_2dPostiats_2src_2pats_constraint3_solve_2edats__staload
in pats_constraint3_solve_dats.o

_atslib_mpz_out_str_exn”, referenced from:

__2Users_2minglei_2Downloads_2ATS_2dPostiats_2src_2pats_intinf_2esats__fprint_intinf
in pats_intinf_dats.o

__2Users_2minglei_2Downloads_2ATS_2dPostiats_2src_2pats_intinf_2esats__fprint_intinfset
in pats_intinf_dats.o

ld: symbol(s) not found for architecture x86_64

These two symbols look to be GMP related. Is it because somehow GMP support
was not included in my ATS1’s libraries?On Monday, December 9, 2013 5:53:38 PM UTC-6, gmhwxi wrote:

Forgot to mention that I had already uploaded an ATS1 package
containing the fixes.

On Monday, December 9, 2013 6:51:04 PM UTC-5, gmhwxi wrote:

I have fixed the memset issue in gcats1.cats.

I think that the problem of atsopt not functioning properly was caused by
a faulty GC.

If you drop -O2 (or change it to -O1) when using gcc to compile the GC of
ATS, then the
problem may disappear.

On Monday, December 9, 2013 12:12:11 AM UTC-5, Ming Lei wrote:

I’m trying to build ATS2 on OS X (Maverick, Darwin 13) from the latest
source on GitHub. So far I’ve seen two problems:

First, I need to build ATS1 (anairiats) to bootstrap ATS2, but ATS1 uses
pthread_spin_lock(), which is not available on OS X. Is there a way to
build ATS1 without multithread support, just for the purpose
of bootstrapping ATS2? (Or better, when can we drop the ATS1 requirement
and bootstrap ATS2 with itself?)

Second, in both ATS1 and ATS2’s prelude/CATS/char.cats file, there are
definitions like:

#ifndef isascii

extern int isascii (int c) ; // _XOPEN_SOURCE

#endif // end of [isascii]

It’s the same thing for isblank() and toascii(). These functions are
inline functions in OS X’s ctype.h, but because they are declared as
extern functions here, they are not inline anymore and are included in the
objects files. As char.cats is included verbatim in many source files,
I get duplicate symbols when the linker tries to link their object files
together. If I delete these extern declarations the linking will succeed.

What’s the purpose of these conditionals? I think all the supported
platforms should have these C functions provided. Can we remove them?

Thanks in advance!

Forgot to mention that I had already uploaded an ATS1 package
containing the fixes.On Monday, December 9, 2013 6:51:04 PM UTC-5, gmhwxi wrote:

I have fixed the memset issue in gcats1.cats.

I think that the problem of atsopt not functioning properly was caused by
a faulty GC.

If you drop -O2 (or change it to -O1) when using gcc to compile the GC of
ATS, then the
problem may disappear.

On Monday, December 9, 2013 12:12:11 AM UTC-5, Ming Lei wrote:

I’m trying to build ATS2 on OS X (Maverick, Darwin 13) from the latest
source on GitHub. So far I’ve seen two problems:

First, I need to build ATS1 (anairiats) to bootstrap ATS2, but ATS1 uses
pthread_spin_lock(), which is not available on OS X. Is there a way to
build ATS1 without multithread support, just for the purpose
of bootstrapping ATS2? (Or better, when can we drop the ATS1 requirement
and bootstrap ATS2 with itself?)

Second, in both ATS1 and ATS2’s prelude/CATS/char.cats file, there are
definitions like:

#ifndef isascii

extern int isascii (int c) ; // _XOPEN_SOURCE

#endif // end of [isascii]

It’s the same thing for isblank() and toascii(). These functions are
inline functions in OS X’s ctype.h, but because they are declared as
extern functions here, they are not inline anymore and are included in the
objects files. As char.cats is included verbatim in many source files, I
get duplicate symbols when the linker tries to link their object files
together. If I delete these extern declarations the linking will succeed.

What’s the purpose of these conditionals? I think all the supported
platforms should have these C functions provided. Can we remove them?

Thanks in advance!

After installing GMP, you need to re-do ./configure and then try to build
ATS1 again.

Here is a shortcut:

cd ${ATSHOME}
atslib libc/SATS/gmp.sats
atslib libc/DATS/gmp.dats

Then try to re-build ATS2. I don’t see any problems from this point on.On Monday, December 9, 2013 12:12:11 AM UTC-5, Ming Lei wrote:

I’m trying to build ATS2 on OS X (Maverick, Darwin 13) from the latest
source on GitHub. So far I’ve seen two problems:

First, I need to build ATS1 (anairiats) to bootstrap ATS2, but ATS1 uses
pthread_spin_lock(), which is not available on OS X. Is there a way to
build ATS1 without multithread support, just for the purpose
of bootstrapping ATS2? (Or better, when can we drop the ATS1 requirement
and bootstrap ATS2 with itself?)

Second, in both ATS1 and ATS2’s prelude/CATS/char.cats file, there are
definitions like:

#ifndef isascii

extern int isascii (int c) ; // _XOPEN_SOURCE

#endif // end of [isascii]

It’s the same thing for isblank() and toascii(). These functions are
inline functions in OS X’s ctype.h, but because they are declared as
extern functions here, they are not inline anymore and are included in the
objects files. As char.cats is included verbatim in many source files, I
get duplicate symbols when the linker tries to link their object files
together. If I delete these extern declarations the linking will succeed.

What’s the purpose of these conditionals? I think all the supported
platforms should have these C functions provided. Can we remove them?

Thanks in advance!

Thanks again. The fixes worked.

On line 54 of ccomp/runtime/GCATS/gcats1.cats file there is an extern
definition for memset(), which causes compilation error because this
identifier is defined as a macro in Apple’s string.h.

After commenting that line out, the building process proceeded until it got
to the step of building atslex. The atsopt command got SIGSEGV in the
symtbl_search_probe_3() function. It faults even when given no command line
arguments at all.

If I can fix it I’ll let you know.On Monday, December 9, 2013 3:19:56 PM UTC-6, gmhwxi wrote:

I have just uploaded an ATS1 package in which the issues you reported are
fixed.
Hopefully, it will work this time. I myself don’t have access to a MAC
right now.

In order to build the “bleeding edge” version of ATS2 on Github, you do
need to have ATS1
installed first.

On Monday, December 9, 2013 12:12:11 AM UTC-5, Ming Lei wrote:

I’m trying to build ATS2 on OS X (Maverick, Darwin 13) from the latest
source on GitHub. So far I’ve seen two problems:

First, I need to build ATS1 (anairiats) to bootstrap ATS2, but ATS1 uses
pthread_spin_lock(), which is not available on OS X. Is there a way to
build ATS1 without multithread support, just for the purpose
of bootstrapping ATS2? (Or better, when can we drop the ATS1 requirement
and bootstrap ATS2 with itself?)

Second, in both ATS1 and ATS2’s prelude/CATS/char.cats file, there are
definitions like:

#ifndef isascii

extern int isascii (int c) ; // _XOPEN_SOURCE

#endif // end of [isascii]

It’s the same thing for isblank() and toascii(). These functions are
inline functions in OS X’s ctype.h, but because they are declared as
extern functions here, they are not inline anymore and are included in the
objects files. As char.cats is included verbatim in many source files, I
get duplicate symbols when the linker tries to link their object files
together. If I delete these extern declarations the linking will succeed.

What’s the purpose of these conditionals? I think all the supported
platforms should have these C functions provided. Can we remove them?

Thanks in advance!