1

I want to send arguments to the erlang vm, but 'emu_args: "+A32"' appears after the "-escript main parallel_tree_walk_escript" and appears to become arguments for the elixir program instead of affecting the erlang VM.

Without 'emu_args: "+A32"', the file created by "mix escript.build" contains line three

%%! -escript main parallel_tree_walk_escript

I seem to get the results I want if I alter that line with emacs (copes well with the non-ascii contents) to

%%! +A32 -escript main parallel_tree_walk_escript

However, if I use 'emu_args: "+A32" in mix.esx, the line becomes

%%! -escript main parallel_tree_walk_escript +A32

...and "+A32" appears not to go to the erlang vm, but instead appear as the first command line element of the args array.

# permits emacs edit of parallel_tree_walk result
  def escript do
    [
      main_module: ParallelTreeWalk,
    ]
  end

But this apparently puts the argument in the wrong location:

  def escript do
    [
      main_module: ParallelTreeWalk,
      emu_args: "+A32"
    ]
  end

I hoped for

%%! +A32 -escript main parallel_tree_walk_escript

but the result was

%%! -escript main parallel_tree_walk_escript +A32

which doesn't work.

1 Answers1

0

If I generate an escript, and manually add the -emu_args flag, in the same way you moved the +A32 flag, I get the same output whether +A32 is before or after the escript name:

# %%! -emu_args -escript main test_escript +A32 
# %%! +A32 -emu_args -escript main test_escript

Both produce (truncated some paths for brevity):

Executing: …beam.smp ./test -B -A32 -- -root …erlang/21.3 -progname erl -- -home /Users/adam -- -boot no_dot_erlang -noshell -escript main test_escript -run escript start -extra ./test

Maybe you could try adding the emu_args parameter to see what's happening. It could be that the +A32 flag is getting to the VM.

This is the first time I've looked at escripts, so I was curious that the argument to beam ended up as -A32 instead of +A32, but that seems to be a difference between executing the emulator directly, or via a script. Calling …beam.smp --help does indeed list the -A version along with a final note that says:

Note that if the emulator is started with erlexec (typically from the erl script), these flags should be specified with +.

Adam Millerchip
  • 20,844
  • 5
  • 51
  • 74
  • Well, now I don't know what to think: the "+A32" at the end of the third line which I thought was failing ("doesn't work") is working exactly as intended today, in that the argument list to main(args \\ []) are what they are supposed to be with the "./parallel_tree_walk ." invocation, and ":erlang.system_info(:thread_pool_size)" is returning 32 exactly as intended. I don't know what happened. Perhaps I had a typo which got removed during my various attempts.Thank you for your time. – Thomas Buttler Jul 11 '19 at 06:01