简体   繁体   中英

How do I send flags to the erlang vm using :emu_args?

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.

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 +.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM