Skip to content
Permalink
Browse files

Create working runners in build directory. Generate perl6-debug execu…

…table.

The debug runner fails when starting at the moment though. Not sure what
it is yet.
The previous commit did not manage to fix the executables during build,
because it relied on the binary perl6. That one sadly can't work in a build
environment because the folder structure of PERL6_HOME doesn't match. Thus
we rely on the old .bat runnersin the build dir again.
  • Loading branch information...
patzim committed Jan 28, 2019
1 parent 98a0df6 commit 4b461bf7527b546060675c2423c6d361d507d4d5
Showing with 177 additions and 86 deletions.
  1. +2 −0 .gitignore
  2. +3 −3 Configure.pl
  3. +8 −0 src/vm/moar/runner/main.c
  4. +36 −26 tools/build/Makefile-Moar.in
  5. +128 −57 tools/build/create-moar-runner.p6
@@ -65,6 +65,8 @@ perl6-mc
perl6-mc.exe
perl6-debug-m
perl6-debug-m.bat
perl6-debug-mc
perl6-debug-mc.exe
perl6-js
perl6-js.bat
t/localtest.data
@@ -300,9 +300,9 @@
unless ($win) {
$config{'m_cleanups'} = " \$(M_GDB_RUNNER) \\\n \$(M_LLDB_RUNNER) \\\n \$(M_VALGRIND_RUNNER)";
$config{'m_all'} = '$(M_GDB_RUNNER) $(M_LLDB_RUNNER) $(M_VALGRIND_RUNNER)';
$config{'m_install'} = "\t" . '$(M_RUN_PERL6) tools/build/create-moar-runner.p6 "$(MOAR)" perl6.moarvm $(DESTDIR)$(PREFIX)/bin/perl6-gdb-m "$(PERL6_HOME)/runtime" "gdb" "" relocatable "$(M_LIBPATH)" "$(PERL6_HOME)/lib" "$(PERL6_HOME)/runtime"' . "\n"
. "\t" . '$(M_RUN_PERL6) tools/build/create-moar-runner.p6 "$(MOAR)" perl6.moarvm $(DESTDIR)$(PREFIX)/bin/perl6-lldb-m "$(PERL6_HOME)/runtime" "lldb" "" relocatable "$(M_LIBPATH)" "$(PERL6_HOME)/lib" "$(PERL6_HOME)/runtime"' . "\n"
. "\t" . '$(M_RUN_PERL6) tools/build/create-moar-runner.p6 "$(MOAR)" perl6.moarvm $(DESTDIR)$(PREFIX)/bin/perl6-valgrind-m "$(PERL6_HOME)/runtime" "valgrind" "" relocatable "$(M_LIBPATH)" "$(PERL6_HOME)/lib" "$(PERL6_HOME)/runtime"';
$config{'m_install'} = "\t" . '$(M_RUN_PERL6) tools/build/create-moar-runner.p6 perl6 $(M_RUNNER) $(DESTDIR)$(PREFIX)/bin/perl6-gdb-m "gdb" "" "" ""' . "\n"
. "\t" . '$(M_RUN_PERL6) tools/build/create-moar-runner.p6 perl6 $(M_RUNNER) $(DESTDIR)$(PREFIX)/bin/perl6-lldb-m "lldb" "" "" ""' . "\n"
. "\t" . '$(M_RUN_PERL6) tools/build/create-moar-runner.p6 perl6 $(M_RUNNER) $(DESTDIR)$(PREFIX)/bin/perl6-valgrind-m "valgrind" "" "" ""';
}

unless (@errors) {
@@ -285,12 +285,20 @@ int wmain(int argc, wchar_t *wargv[])
strcpy(lib_path[0] + nqp_home_size, "\\lib");
strcpy(lib_path[1] + perl6_home_size, "\\lib");
strcpy(lib_path[2] + perl6_home_size, "\\runtime");
#ifdef MOAR_PERL6_RUNNER_DEBUG
strcpy(perl6_file + perl6_home_size, "\\runtime\\perl6-debug.moarvm");
#else
strcpy(perl6_file + perl6_home_size, "\\runtime\\perl6.moarvm");
#endif
#else
strcpy(lib_path[0] + nqp_home_size, "/lib");
strcpy(lib_path[1] + perl6_home_size, "/lib");
strcpy(lib_path[2] + perl6_home_size, "/runtime");
#ifdef MOAR_PERL6_RUNNER_DEBUG
strcpy(perl6_file + perl6_home_size, "/runtime/perl6-debug.moarvm");
#else
strcpy(perl6_file + perl6_home_size, "/runtime/perl6.moarvm");
#endif
#endif

/* Start up the VM. */
@@ -17,9 +17,12 @@ M_INCPATH = $(MOAR_PREFIX)@slash@include
M_RUN_PERL6 = $(MOAR) --libpath="blib" --libpath="$(M_LIBPATH)" perl6.moarvm --nqp-lib=blib

M_BAT = @runner_suffix@
M_RUNNER = perl6-m@runner_suffix@
M_BAT_RUNNER = perl6-m@runner_suffix@

M_RUNNER = perl6-m@exe@
M_DEBUG_RUNNER = perl6-debug-m@exe@
M_C_RUNNER = perl6-mc@exe@
M_C_DEBUG_RUNNER = perl6-debug-mc@exe@

# files we create
PERL6_MOAR = perl6.moarvm
@@ -67,7 +70,7 @@ M_CORE_D_SOURCES = \
@moar_core_d_sources@

PERL6_DEBUG_MOAR = perl6-debug.moarvm
M_DEBUG_RUNNER = perl6-debug-m@runner_suffix@
M_BAT_DEBUG_RUNNER = perl6-debug-m@runner_suffix@
M_GDB_RUNNER = perl6-gdb-m@runner_suffix@
M_LLDB_RUNNER = perl6-lldb-m@runner_suffix@
M_VALGRIND_RUNNER = perl6-valgrind-m@runner_suffix@
@@ -80,13 +83,13 @@ M_CLEANUPS = \
$(R_SETTING_MOAR) \
$(PERL6_MOAR) \
rakudo_test_run.tar.gz \
$(M_RUNNER) \
$(M_BAT_RUNNER) \
$(M_PERL6_OPS_DLL) \
$(M_PERL6_OPS_OBJ) \
$(M_PERL6_CONT_OBJ) \
$(M_PERL6_OPS_DLL) \
$(PERL6_DEBUG_MOAR) \
$(M_DEBUG_RUNNER) \
$(M_BAT_DEBUG_RUNNER) \
$(M_BUILD_DIR)@slash@*.* \
@m_cleanups@

@@ -95,12 +98,12 @@ HARNESS_TYPE = 5
M_HARNESS5 = $(PERL5) t/harness5
M_HARNESS5_WITH_FUDGE = $(M_HARNESS5) --fudge --moar --keep-exit-code

M_HARNESS6 = .@slash@$(M_RUNNER) -Ilib t/harness6
M_HARNESS6 = .@slash@$(M_BAT_RUNNER) -Ilib t/harness6
M_HARNESS6_WITH_FUDGE = $(M_HARNESS6) --fudge

M_RUN_CLEAN_TARGET_FILES = $(M_RUN_PERL6) -e "for @*ARGS.head(*-1) { given (@*ARGS[*-1] ~ '/' ~ .IO.basename.Str) { say 'rm -f ' ~ .Str; .IO.unlink if .IO.e } }"

m-all: check_nqp_version $(PERL6_MOAR) $(SETTING_MOAR) $(SETTING_D_MOAR) $(R_SETTING_MOAR) $(M_RUNNER) $(PERL6_DEBUG_MOAR) $(M_DEBUG_RUNNER) @m_all@
m-all: check_nqp_version $(PERL6_MOAR) $(SETTING_MOAR) $(SETTING_D_MOAR) $(R_SETTING_MOAR) $(M_BAT_RUNNER) $(PERL6_DEBUG_MOAR) $(M_BAT_DEBUG_RUNNER) @m_all@

check_nqp_version: tools/build/check-nqp-version.pl
$(PERL5) tools/build/check-nqp-version.pl $(M_NQP)
@@ -183,37 +186,37 @@ $(SETTING_D_MOAR): $(PERL6_MOAR) $(PERL6_B_MOAR) $(SETTING_MOAR) $(M_CORE_D_SOUR
$(R_SETTING_MOAR): $(PERL6_MOAR) $(SETTING_MOAR) $(R_SETTING_SRC) $(SETTING_MOAR)
$(M_RUN_PERL6) --target=mbc --ll-exception --output=$(R_SETTING_MOAR) $(R_SETTING_SRC)

$(M_RUNNER): tools/build/create-moar-runner.p6 $(PERL6_MOAR) $(SETTING_MOAR)
$(RM_F) $(M_RUNNER)
$(M_RUN_PERL6) tools/build/create-moar-runner.p6 "$(MOAR)" perl6.moarvm perl6-m . "" --nqp-lib=blib norelocatable $(PERL6_HOME) $(NQP_HOME) . blib "$(M_LIBPATH)"
-$(CHMOD) 755 $(M_RUNNER)
$(M_BAT_RUNNER): tools/build/create-moar-runner.p6 $(M_C_RUNNER) $(PERL6_MOAR) $(SETTING_MOAR)
$(RM_F) $(M_BAT_RUNNER)
$(M_RUN_PERL6) tools/build/create-moar-runner.p6 moar "$(MOAR)" perl6-m perl6.moarvm . "" $(PERL6_HOME) $(NQP_HOME) --nqp-lib=blib $(M_LIBPATH) . blib
-$(CHMOD) 755 $(M_BAT_RUNNER)

m-runner-default: $(M_RUNNER)
m-runner-default: $(M_BAT_RUNNER)
$(RM_F) perl6@runner_suffix@
-$(CP) $(M_RUNNER) perl6@runner_suffix@
-$(CP) $(M_BAT_RUNNER) perl6@runner_suffix@
-$(CHMOD) 755 perl6@runner_suffix@

$(PERL6_DEBUG_MOAR): src/perl6-debug.nqp $(PERL6_MOAR)
$(M_NQP) $(M_GEN_CAT) src/perl6-debug.nqp $(M_BUILD_DIR)/main-version.nqp > $(M_BUILD_DIR)/perl6-debug.nqp
$(M_NQP) --module-path=blib --target=mbc --output=$(PERL6_DEBUG_MOAR) \
--vmlibs=$(M_PERL6_OPS_DLL)=Rakudo_ops_init $(M_BUILD_DIR)/perl6-debug.nqp

$(M_DEBUG_RUNNER): tools/build/create-moar-runner.p6 $(PERL6_DEBUG_MOAR) $(SETTING_MOAR)
$(M_RUN_PERL6) tools/build/create-moar-runner.p6 "$(MOAR)" perl6-debug.moarvm perl6-debug-m . "" --nqp-lib=blib norelocatable $(PERL6_HOME) $(NQP_HOME) . blib "$(M_LIBPATH)"
$(M_BAT_DEBUG_RUNNER): tools/build/create-moar-runner.p6 $(M_C_DEBUG_RUNNER) $(PERL6_DEBUG_MOAR) $(SETTING_MOAR)
$(M_RUN_PERL6) tools/build/create-moar-runner.p6 moar "$(MOAR)" perl6-debug-m perl6-debug.moarvm . "" $(PERL6_HOME) $(NQP_HOME) --nqp-lib=blib $(M_LIBPATH) . blib

$(M_GDB_RUNNER): tools/build/create-moar-runner.p6 $(PERL6_MOAR) $(SETTING_MOAR)
$(M_GDB_RUNNER): tools/build/create-moar-runner.p6 $(M_C_RUNNER) $(PERL6_MOAR) $(SETTING_MOAR)
$(RM_F) $(M_GDB_RUNNER)
$(M_RUN_PERL6) tools/build/create-moar-runner.p6 "$(MOAR)" perl6.moarvm perl6-gdb-m . "gdb" --nqp-lib=blib norelocatable $(PERL6_HOME) $(NQP_HOME) . blib "$(M_LIBDEFPATH)" "$(M_LIBPATH)"
$(M_RUN_PERL6) tools/build/create-moar-runner.p6 moar "$(MOAR)" perl6-gdb-m perl6.moarvm . "gdb" $(PERL6_HOME) $(NQP_HOME) --nqp-lib=blib $(M_LIBPATH) . blib
-$(CHMOD) 755 $(M_GDB_RUNNER)

$(M_LLDB_RUNNER): tools/build/create-moar-runner.p6 $(PERL6_MOAR) $(SETTING_MOAR)
$(M_LLDB_RUNNER): tools/build/create-moar-runner.p6 $(M_C_RUNNER) $(PERL6_MOAR) $(SETTING_MOAR)
$(RM_F) $(M_LLDB_RUNNER)
$(M_RUN_PERL6) tools/build/create-moar-runner.p6 "$(MOAR)" perl6.moarvm perl6-lldb-m . "lldb" --nqp-lib=blib norelocatable $(PERL6_HOME) $(NQP_HOME) . blib "$(M_LIBPATH)"
$(M_RUN_PERL6) tools/build/create-moar-runner.p6 moar "$(MOAR)" perl6-lldb-m perl6.moarvm . "lldb" $(PERL6_HOME) $(NQP_HOME) --nqp-lib=blib $(M_LIBPATH) . blib
-$(CHMOD) 755 $(M_LLDB_RUNNER)

$(M_VALGRIND_RUNNER): tools/build/create-moar-runner.p6 $(PERL6_MOAR) $(SETTING_MOAR)
$(M_VALGRIND_RUNNER): tools/build/create-moar-runner.p6 $(M_C_RUNNER) $(PERL6_MOAR) $(SETTING_MOAR)
$(RM_F) $(M_VALGRIND_RUNNER)
$(M_RUN_PERL6) tools/build/create-moar-runner.p6 "$(MOAR)" perl6.moarvm perl6-valgrind-m . "valgrind" --nqp-lib=blib norelocatable $(PERL6_HOME) $(NQP_HOME) . blib "$(M_LIBPATH)"
$(M_RUN_PERL6) tools/build/create-moar-runner.p6 moar "$(MOAR)" perl6-valgrind-m perl6.moarvm . "valgrind" $(PERL6_HOME) $(NQP_HOME) --nqp-lib=blib $(M_LIBPATH) . blib
-$(CHMOD) 755 $(M_VALGRIND_RUNNER)

$(M_C_RUNNER): src/vm/moar/runner/main.c
@@ -223,6 +226,13 @@ $(M_C_RUNNER): src/vm/moar/runner/main.c
-I$(M_INCPATH)/libatomic_ops -I$(M_INCPATH)/dyncall -I$(M_INCPATH)/moar -I$(M_INCPATH)/sha1 -I$(M_INCPATH)/tinymt -I$(M_INCPATH)/libtommath -I$(M_INCPATH)/libuv \
-L@moar::libdir@ -Wl,-z,origin,-rpath,'$$ORIGIN/../lib' -lmoar @moar::ccout@$@ src/vm/moar/runner/main.c

$(M_C_DEBUG_RUNNER): src/vm/moar/runner/main.c
$(RM_F) $(M_C_RUNNER)
# Using only the pkgconfig moar includes does not work, because moar.h assumes all the specific includes below.
$(M_CC) @moar::ccshared@ -DMOAR_PERL6_RUNNER_DEBUG $(M_CFLAGS) $(M_LDFLAGS) -I$(M_INCPATH) -I$(M_INCPATH)/moar \
-I$(M_INCPATH)/libatomic_ops -I$(M_INCPATH)/dyncall -I$(M_INCPATH)/moar -I$(M_INCPATH)/sha1 -I$(M_INCPATH)/tinymt -I$(M_INCPATH)/libtommath -I$(M_INCPATH)/libuv \
-L@moar::libdir@ -Wl,-z,origin,-rpath,'$$ORIGIN/../lib' -lmoar @moar::ccout@$@ src/vm/moar/runner/main.c


## testing targets
m-test : m-coretest$(HARNESS_TYPE)
@@ -311,12 +321,12 @@ m-install: m-all tools/build/create-moar-runner.p6 tools/build/install-core-dist
$(CP) $(PERL6_MOAR) $(PERL6_DEBUG_MOAR) $(DESTDIR)$(PERL6_HOME)/runtime
$(MKPATH) $(DESTDIR)$(PERL6_HOME)/runtime/dynext
$(CP) $(M_PERL6_OPS_DLL) $(DESTDIR)$(PERL6_HOME)/runtime/dynext
.@slash@$(M_RUNNER) tools/build/upgrade-repository.p6 $(DESTDIR)$(PERL6_HOME)
.@slash@$(M_RUNNER) tools/build/upgrade-repository.p6 $(DESTDIR)$(PERL6_HOME)/vendor
.@slash@$(M_RUNNER) tools/build/upgrade-repository.p6 $(DESTDIR)$(PERL6_HOME)/site
.@slash@$(M_RUNNER) tools/build/install-core-dist.p6 $(DESTDIR)$(PERL6_HOME)
$(CP) $(M_C_RUNNER) $(DESTDIR)$(PREFIX)/bin/perl6-m@exe@
$(M_RUN_PERL6) tools/build/create-moar-runner.p6 "$(MOAR)" perl6-debug.moarvm $(DESTDIR)$(PREFIX)/bin/perl6-debug-m "$(PERL6_HOME)/runtime" "" "" relocatable $(PERL6_HOME) $(NQP_HOME) "$(M_LIBPATH)" "$(PERL6_HOME)/lib" "$(PERL6_HOME)/runtime"
.@slash@$(M_BAT_RUNNER) tools/build/upgrade-repository.p6 $(DESTDIR)$(PERL6_HOME)
.@slash@$(M_BAT_RUNNER) tools/build/upgrade-repository.p6 $(DESTDIR)$(PERL6_HOME)/vendor
.@slash@$(M_BAT_RUNNER) tools/build/upgrade-repository.p6 $(DESTDIR)$(PERL6_HOME)/site
.@slash@$(M_BAT_RUNNER) tools/build/install-core-dist.p6 $(DESTDIR)$(PERL6_HOME)
$(CP) $(M_C_RUNNER) $(DESTDIR)$(PREFIX)/bin/$(M_RUNNER)
$(CP) $(M_C_DEBUG_RUNNER) $(DESTDIR)$(PREFIX)/bin/$(M_DEBUG_RUNNER)
@m_install@

m-runner-default-install: m-install
@@ -2,30 +2,98 @@
# Copyright (C) 2013-2018, The Perl Foundation.

use v6;
my ($moar, $mbc, $install_to, $p6_mbc_path, $toolchain, $blib, $relocatable, $perl6-home, $nqp-home, @libpaths) = @*ARGS;
$relocatable = $relocatable eq "relocatable";

$p6_mbc_path = $*SPEC.rel2abs($p6_mbc_path || $*SPEC.curdir);
$blib = ' ' ~ $blib if $blib;
my $libpaths = '--libpath="%s"'.sprintf: @libpaths.join('" --libpath="');
my $libpath-line = '%s %s/%s%s'.sprintf: $libpaths, $p6_mbc_path, $mbc, $blib;
if $*DISTRO eq 'mswin32' {
exit if $toolchain;
$install_to ~= '.bat';
my $fh = open $install_to, :w;
$fh.print(sprintf(qq[@ "%s" --execname="%%\~dpf0" %s %s\\%s%s %%*\n],
$moar, $libpaths, $p6_mbc_path, $mbc, $blib));

multi sub MAIN("perl6", $perl6, $install-to, $toolchain, $ld-lib-path, $perl6-home, $nqp-home) {
exit if $*DISTRO eq 'mswin32';

my $env-vars = '';
$env-vars ~= "LD_LIBRARY_PATH=$ld-lib-path " if $ld-lib-path;
$env-vars ~= "PERL6_HOME=$perl6-home " if $perl6-home;
$env-vars ~= "NQP_HOME=$nqp-home " if $nqp-home;

my $fh = open $install-to, :w;

if $toolchain eq any('gdb','lldb') {
$fh.print(get-perl6-debug-runner($toolchain, $perl6, $env-vars));
}
elsif ($toolchain eq 'valgrind') {
$fh.print(get-perl6-valgrind-runner($perl6, $env-vars));
}
else {
$fh.print(get-perl6-runner($perl6, $env-vars));
}

$fh.close;

chmod(0o755, $install-to) if $*DISTRO ne 'mswin32';
}
elsif $toolchain eq any('gdb','lldb') {
my $fh = open $install_to, :w;
my $cmdline = $toolchain eq 'gdb' ?? 'gdb --quiet --ex=run --args %s --execname="$0" %s "$@"'.sprintf($moar, $libpath-line)
!! $toolchain eq 'lldb' ?? 'lldb %s -- --execname="$0" %s "$@"'.sprintf($moar, $libpath-line) !! die;

multi sub MAIN("moar", $moar, $install-to, $mbc, $p6-mbc-path, $toolchain, $perl6-home is copy, $nqp-home is copy, $blib is copy, *@libpaths) {
$perl6-home = "PERL6_HOME=$perl6-home" if $perl6-home;
$nqp-home = "NQP_HOME=$nqp-home" if $nqp-home;
my $env-vars = join(' ', $nqp-home, $perl6-home).trim;

$blib = ' ' ~ $blib if $blib;
my $libpaths = '--libpath="%s"'.sprintf: @libpaths.join('" --libpath="');
my $libpath-line = '%s %s/%s%s'.sprintf: $libpaths, $p6-mbc-path, $mbc, $blib;

my $fh = open $install-to, :w;

if $*DISTRO eq 'mswin32' {
$fh.print(get-moar-win-runner($moar, $libpaths, $blib));
}
elsif $toolchain eq any('gdb','lldb') {
$fh.print(get-moar-debug-runner($toolchain, $moar, $libpath-line));
}
elsif ($toolchain eq 'valgrind') {
$fh.print(get-moar-valgrind-runner($moar, $libpath-line));
}
else {
$fh.print(get-moar-runner($moar, $libpath-line));
}

$fh.close;

chmod(0o755, $install-to) if $*DISTRO ne 'mswin32';
}

my $bash-prelude = q:to/EOS/;
#!/bin/bash
# Sourced from https://stackoverflow.com/a/246128/1975049
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null && pwd )"
EOS

sub get-moar-win-runner($moar, $libpaths, $p6-mbc-path, $mbc, $blib) {
return sprintf(qq[@ "%s" --execname="%%\~dpf0" %s %s\\%s%s %%*\n],
$moar, $libpaths, $p6-mbc-path, $mbc, $blib);
}

sub get-perl6-runner($perl6, $env-vars) {
return sprintf(q:to/EOS/, $bash-prelude, $env-vars, $perl6);
%s
%sexec $DIR/%s "$@"
EOS
}

sub get-moar-runner($moar, $libpath-line) {
return sprintf(q:to/EOS/, $moar, $libpath-line);
#!/bin/sh
exec %s --execname="$0" %s "$@"
EOS
}

sub get-debugger-text($toolchain) {
my $debugger-name = $toolchain eq 'gdb' ?? 'GNU'
!! $toolchain eq 'lldb' ?? 'LLVM' !! die;
$fh.print(sprintf(q:to/EOS/, $moar, $libpath-line, $debugger-name, $cmdline));
#!/bin/sh
%s --execname="$0" %s -e '
return sprintf(q:to/EOS/, $debugger-name);
say "=" x 96;
say "This is Rakudo Perl 6 running in the %s debugger, which often allows the user to generate useful back-\ntraces to debug or report issues in Rakudo, the MoarVM backend or the currently running code.\n";
@@ -37,17 +105,33 @@ elsif $toolchain eq any('gdb','lldb') {
say "Type `bt full` to generate a backtrace if applicable, type `q` to quit or `help` for help.";
say "-" x 96;'
say "-" x 96;
EOS
}

sub get-perl6-debug-runner($toolchain, $perl6, $env-vars) {
my $cmdline = $toolchain eq 'gdb' ?? '%sgdb --quiet --ex=run --args %s "$@"'.sprintf($env-vars, $perl6)
!! $toolchain eq 'lldb' ?? '%slldb %s -- "$@"'.sprintf($env-vars, $perl6) !! die;
return sprintf(q:to/EOS/, $bash-prelude, $env-vars, $perl6, get-debugger-text($toolchain), $cmdline);
%s
%s$DIR/%s -e '%s'
%s
EOS
$fh.close;
chmod(0o755, $install_to);
}
elsif ($toolchain eq 'valgrind') {
my $fh = open $install_to, :w;
$fh.print(sprintf(q:to/EOS/, ($moar, $libpath-line) xx 2));

sub get-moar-debug-runner($toolchain, $moar, $libpath-line) {
my $cmdline = $toolchain eq 'gdb' ?? 'gdb --quiet --ex=run --args %s --execname="$0" %s "$@"'.sprintf($moar, $libpath-line)
!! $toolchain eq 'lldb' ?? 'lldb %s -- --execname="$0" %s "$@"'.sprintf($moar, $libpath-line) !! die;
return sprintf(q:to/EOS/, $moar, $libpath-line, get-debugger-text($toolchain), $cmdline);
#!/bin/sh
%s --execname="$0" %s -e '
%s --execname="$0" %s -e '%s'
%s
EOS
}


my $valgrind-text = q:to/EOS/;
say "=" x 96;
say qq:to/END/;
@@ -59,36 +143,23 @@ elsif ($toolchain eq 'valgrind') {
say "This Rakudo version is $*PERL.compiler.version() built on MoarVM version $*VM.version(),";
say "running on $*DISTRO.gist() / $*KERNEL.gist()";
say "-" x 96;'
valgrind ${MVM_VALGRIND_OPTS} %s --execname="$0" %s "$@"
say "-" x 96;
EOS

sub get-perl6-valgrind-runner($perl6, $env-vars) {
return sprintf(q:to/EOS/, $bash-prelude, $env-vars, $perl6, $valgrind-text, $env-vars, $perl6);
%s
%s$DIR/%s -e '%s'
%svalgrind ${MVM_VALGRIND_OPTS} $DIR/%s "$@"
EOS
$fh.close;
chmod(0o755, $install_to);
}
else {
my $fh = open $install_to, :w;
if $relocatable {
$fh.print(sprintf(q:to/EOS/));
#!/bin/bash
# Sourced from https://stackoverflow.com/a/246128/1975049
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null && pwd )"
exec $DIR/moar --execname="$0" --libpath="$DIR/../share/nqp/lib" --libpath="$DIR/../share/perl6/lib" --libpath="$DIR/../share/perl6/runtime" $DIR/../share/perl6/runtime/perl6.moarvm "$@"
EOS
}
else {
$fh.print(sprintf(q:to/EOS/, $perl6-home, $nqp-home, $moar, $libpath-line));
#!/bin/sh
PERL6_HOME=%s NQP_HOME=%s exec %s --execname="$0" %s "$@"
EOS
}
$fh.close;
chmod(0o755, $install_to);

sub get-moar-valgrind-runner($moar, $libpath-line) {
return sprintf(q:to/EOS/, $moar, $libpath-line, $valgrind-text, $moar, $libpath-line);
#!/bin/sh
%s --execname="$0" %s -e '%s'
valgrind ${MVM_VALGRIND_OPTS} %s --execname="$0" %s "$@"
EOS
}

0 comments on commit 4b461bf

Please sign in to comment.
You can’t perform that action at this time.