Compiling ACE on MacOS

As I recall, the nested functions issue was also the main reason ACE wouldn’t compile on Windows. The use of the executable stack for nested functions is a known security vulnerability, so I’m doubtful that macOS will enable it in the future, but maybe GCC can emulate it somehow via another mechanism.

In the long term, removing the use of nested functions in ACE would be a good thing, but unfortunately I think it’d be more work than anyone wants to put in right now.

1 Like

Thanks @sweaglesw for that special ACE binary. It’s mostly OK on my new M1 MacBook Pro, except that compiling ERG 2018 hangs when including the ubertagger. Commenting out all the ut/ lines in ace/config.tdl allows the compilation to complete, and the resulting grammar image seems to work fine.

The special binary also works on my (x86_64) iMac - so would it make sense just to move the freezer to 0x7000000000 on macOS?

1 Like

Update for posterity:
My wife just got an M1 Pro MBP. I tried @sweaglesw’s binary and I’m getting the same freezer error:

mmap returned 0x7000000000
mmap didn't put the freezer where i wanted it: Undefined error: 0

The GCC folks announced in September that they would add support for the new architecture in 2022 with GCC 12. So, only 2 - 14 more months…

@trimblet Did you recompile the grammar image with the new binary? That would put the freezer at 0x7000000000 so then it should load OK.

Just FYI that this binary worked great on my M1 mac, after compiling the 2020 ERG grammar with it. Thanks @sweaglesw!

@sweaglesw, any chance I could convince you to “officially” put that binary up on your ACE Page? As I’m putting together developer docs I’ve had to put in notes like this:

The mac download in the ACE link above does not support the Mac M1 processor. You’ll need a special build that is only available on the forum at the moment if you have an M1. Download that here.

Love to not have to send people to a deep forum post for install…

BTW, I’ve had a couple of interns test it now (they all seem to have M1 macs) and it seems to be pretty solid.

1 Like

@johnca I’ve been thinking about this a lot over the last 18 months :slight_smile: – to finally respond to your question, I’m getting this error during grammar compilation after building with the homebrew install:

$ brew reinstall delph-in/delphin/ace
🍺  /Users/ttrimble/homebrew/Cellar/ace/0.9.34: 4 files, 872.2KB, built in 7 seconds
$ ace
usage: ace [-1 | -n COUNT] [-R] [-f] [-e] [-g grammar-to-load] [-G grammar-to-save] [sentences-file] [--license-info]
$ ace -g erg/ace/config.tdl -G erg.dat
reading configuration       from `erg/ace/config.tdl'
reading types               from `erg/ace/../mtr.tdl'
grammar version             ERG (trunk)
loaded grammar in 9.11633s
mmap returned 0x7000000000
mmap didn't put the freezer where I wanted it: Undefined error: 0

@trimblet I’ve had no problems with that special ace-0.9.34-m1-test binary. Creating a new grammar image was straightforward – although I did have to disable the ubertagger.

Thanks Eric and John for the feedback that it is working as expected for you. It sounds like it’s not for TJ? I’m going to order myself an M2 MBP for the purpose of being able to do this work on my own machine (previous work was on a borrowed M1 laptop). For all I know the GCC folks have resolved the nested functions problem by now, but I also took the step of purging the nested functions from the code last year, so either way I expect it should be much more straightforward to produce a new binary these days – at least from the SVN trunk.

Sorry, I think this thread has ended up with two different purposes and I lost the thread a bit in my latest response.

  1. My original purpose was to figure out how to compile ACE on macOS, especially for the homebrew installation script.
  2. The additional purpose was to figure out ACE on ARM.

In my most recent reply, I was thinking in terms of (1) but I think everyone else was thinking in terms of (2), so that’s my bad. I’ve sorted things out and here’s my re-reply :slight_smile:

@sweaglesw Regarding purpose (2), I was able to use the provided ARM binary with no trouble to 1. compile the ERG, 2. parse a sample sentence, 3. generate from the top MRS for that sentence.

Regarding purpose (1), I realize now that my quoted info was naïve in that I didn’t update anything in the formula since the ARM updates. I’ve since tried using SVN trunk and gotten ACE to compile, but I’m getting the same error when compiling a grammar.

Thanks for clarifying, TJ. And thanks also for working on teaching homebrew how to compile ACE – that’s awesome. I got ACE to compile on an M2 machine yesterday, using the Apple-supplied clang compiler. It was mostly straightforward, but there were a couple of speedbumps.

  1. (Installing developer tools, then homebrew, then brew install boost, then brew install svn… all worked without any hitch)
  2. Compiling REPP revealed that although I had purged nested functions from the ACE code I hadn’t yet done that from REPP. I will have to make a new REPP library release. I assume you are using GCC and therefore this isn’t a problem in your brew recipe.
  3. I had to change the freezer location in freeze.h. As far as I know the new location will make all OSes happy (at least I am going to assume that until I find evidence to the contrary), so I committed that change to SVN tonight. I believe that should resolve the problem you are currently seeing.
  4. Compiled grammar files are not portable between Intel Macs and M1/2 Macs. There is a way around this involving cross compiling and making “fat” binaries, and I have it working, but it will need a little more nuance to be included in the SVN tree (i.e. it would break other platforms at the moment).
1 Like

Great! I can try again with brew soon. By the way, if you want to play around with the homebrew installation, you can do brew install delph-in/delphin/ace --HEAD --debug. The debug flag falls into some options on an exception, including accessing the shell. There’s a similar flag that hits the options at the end of compilation on failure or success.

Regarding portable grammar files, my opinion is that this isn’t necessary. I understand that may not be a universally held opinion.

@sweaglesw I have moved beyond the freezer error, so that’s good. Unfortunately now after running brew install delph-in/delphin/ace --HEAD && ace -g ~/Code/erg/ace/config.tdl -G ~/Code/erg.dat I get a segfault very shortly after :slight_smile:

$ ace -g erg/ace/config.tdl -G erg.dat
reading configuration       from `erg/ace/config.tdl'
reading types               from `erg/ace/../mtr.tdl'
grammar version             ERG (trunk)
loaded grammar in 7.80826s
 types: 101.3M rules: 20.6M lex-info: 3.4M 
zsh: segmentation fault  ace -g erg/ace/config.tdl -G erg.dat

Any debugging tips?

Any update in this thread! I got a new MacBook with M1 chip. The installation with brew worked but Ace can’t compile ERG grammar.

From the last message from @sweaglesw, I understood some modifications are still needed, right?

1 Like

@simo thanks for posting! I think you’re looking for help with a different ACE system. This thread is about the DELPH-IN ACE parser/generator for Natural Language Processing. Good luck!