spvmcc - yuki-kimoto/SPVM GitHub Wiki
If you got segmentation fault from C command, you can debug it in the SPVM repository.
# Original command
spvmcc -o t/.spvm_build/spvm-engine -I lib/SPVM -I t/lib/SPVM t/lib/SPVM/Engine.spvm && t/.spvm_build/spvm-engine
You change your current directory to the SPVM
repository.
cd SPVM
And change the original command to the following one.
Perl Makeifle.PL
make && perl -Mblib blib/script/spvmcc -o ../SPVM-Eg/t/.spvm_build/spvm-engine -I ../SPVM-Eg/lib/SPVM -I ../SPVM-Eg/t/lib/SPVM ../SPVM-Eg/t/lib/SPVM/Engine.spvm && ../SPVM-Eg/t/.spvm_build/spvm-engine
See Config "How to dump resource information".
Why does the spvmcc command require library linking and resource loading when generating an executable file?
When generating an executable file using the spvmcc command, if you are using classes that depend on resources or libraries, you must specify them in the configuration file.
my $config = SPVM::Builder::Config::Exe->new;
# my @libs = ("foo", "bar");
# $config->add_lib(@libs);
$config->use_resource('Resource::SocketUtil');
$config;
When running a program using the spvm
command, the native functions in each class is compiled and linked to a shared library (.so, .dll) and they are safely isolated. Duplicated loadings of libraries and resources are permitted.
However, when running using spvmcc
command, since a single executable file is generated, they are not safely isolated. If there are duplicated loadings of libraries and resources, object file collisions will occur.
For this reason, when generating an executable file using spvmcc command, you must manually write loadings of libraries and resources.
Examples:
myapp.config
my $config = SPVM::Builder::Config::Exe->new;
if ($^O eq 'MSWin32') {
$config->add_static_lib('stdc++', 'winpthread', 'gcc');
}
else {
$config->add_lib('stdc++');
}
$config->add_ldflag('-pthread');
$config->use_resource('Resource::SocketUtil');
$config;
If you want to know dependent resources, use the following command.
spvmdeps --resource-info myapp.spvm
I have considered using the ar command. That is because I wanted to resolve conflicting symbols using a static library generated by the ar command.
Frankly speaking, using the ar command is not as easy as I imagined.
The static library file (.a) generated by the ar command is not intended to specify objects by absolute or relative paths. It is more difficult to understand how it works than simply link multiple object files (.o) by specifying absolute or relative paths.
spvmcc command manages the dependencies of source code and objects by update time, so it becomes even more difficult if I use .a files.
Also, considering the function of the SPVM archive, it is even more difficult to include .a files.
For this reason, we decided that spmvcc will only handle linking multiple object files and generating executable files.
2025/6/9 wrote.