The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

Name

spvmcc - Generating Excutable File

Description

The spvmcc command generates an executable file from SPVM classes.

Usage

  usage: spvmcc [<options>] <class name>
    
    spvmcc -I lib/SPVM -o myapp Myapp
  
  options:
    -h, --help                      Shows this message
    -v, --version                   Shows the version
    -o, --output <file>             The output file name
    -I, --include-dir <directory>   Adds a include directory
    -B, --build-dir <directory>     Build diretory
    -q, --quiet                     Stops the output of messages
    -f, --force                     Forces the compile and link
    --no-config                     No configration file is ok
    -m, --mode <mode>               Config mode
    --config-argv <arg>             A config argument
    --config-argv-option <arg pair> Key-value config arguments such as KEY=VALUE
    --optimize <level>              Optimization level such as O3, "-O0 -g"

Details

  spvmcc [<options>] <class name>

The spvmcc command generates an executable file from SPVM classes.

<options> are options.

<class name> is a class name that contains a bootstrap method.

See Class Search Directories about default class search directories.

See SPVM::Document::EnvironmentVariables about available environment variables.

Config File for Executable File

A class specified by <class name> must have a config file for an executable file except for the case that "--no-config" is specified.

The config for an executable file is a SPVM::Builder::Config::Exe object.

MyExe.config:

  use SPVM::Builder::Config::Exe;
  
  my $exe_config = SPVM::Builder::Config::Exe->new_gnu99(file => __FILE__);
  
  $exe_config

Caching System

Compiled object files and an executable file are not rebuilt unless they need to be rebuilt.

"--force" option forces the rebuild.

Resources

There are important points to be aware of when generating executable files. That is, resources are not automatically compiled.

When you run an SPVM program with the spvm command, the resources are contained within the shared library of each class. Therefore, there are no conflicts between resources.

However, in the case of executable files, there are resource conflicts. For this, the resources must be resolved manually in the configuration file.

  $config->use_resource('Resource::Zlib');

This is hard work, but given that the executable file must be compiled from source files and run on a variety of platforms, I think that solving it manually is a better way.

I have published a command that allows you to view the list of classes using resources and the resource settings.

How to dump resource information

Options

--help

Outputs how to use the spvmcc command to standard output.

-h

  -h

Same as "--help".

--version

Outputs the version of the spvmcc command to standard output. This version is the same as the version of SPVM.

-v

  -v

Same as "--version".

--include-dir

  --include-dir <directory>

Prepends <directory> to class search directories

This option can be specified multiple times.

  --include-dir dir1 --include-dir dir2

In this case, class search directories becomes the following.

  [dir1, dir2, default_dirs]

-I

  -I <directory>

Same as "--include-dir".

--build-dir

  --build-dir <directory>

Sets SPVM_BUILD_DIR environment variable to <directory>.

-B

  -B <directory>

Same as "--build-dir".

--output

  --output <file>

Specifies the output file path <file>. This output file is an executable file.

-o

  -o <file>

Same as "--output".

--quiet

  --quiet

Suppresses messages from the spvmcc command.

-q

  -q

Same as "--quiet".

--force

  --force

Forces the rebuild of object files and an executable file.

-f

  -f

Same as "--force".

--no-config

If this option is specified and a config file does not exist, the spvmcc command runs without finising the program.

--mode

  --mode <mode>

Specifies the config mode <mode>.

See Config Mode about config modes.

-m

  -m <mode>

Same as "--mode".

--config-argv

  --config-argv <arg>

Specifies a config argument <arg>.

This option can be specified multiple times.

See Config Arguments about config arguments.

Examples:

  --config-argv FOO

--config-argv-option

  --config-argv-option <arg pair>

Specifies two config arguments <arg pair> as the format KEY=VALUE.

This is expaned to the following options.

  --config-argv KEY --config-argv VALUE

If only KEY exists or VALUE dose not exist, VALUE is set to an empty string "".

This option can be specified multiple times.

See Config Arguments about config arguments.

Examples:

  --config-argv-option FOO=1

--optimize

  --optimize <level>

Sepcifies optimization level <level>.

This affects all source files that are compiled.

Examples:

  --optimize "-O0 -g"

Copyright & License

Copyright 2023 Yuki Kimoto. All Rights Reserved.

MIT License.