Skip to content
Permalink
Browse files

Allow building rakudo without relocatability.

  • Loading branch information...
patzim committed Feb 12, 2019
1 parent 52b80c4 commit 27adb5536ca354e2e67708667348e0ffd79c1e25
Showing with 43 additions and 9 deletions.
  1. +15 −0 Configure.pl
  2. +15 −7 src/main.nqp
  3. +11 −0 src/vm/moar/runner/main.c
  4. +2 −2 tools/build/Makefile-Moar.in
@@ -36,6 +36,7 @@
my %options;
GetOptions(\%options, 'help!', 'prefix=s', 'libdir=s',
'sysroot=s', 'sdkroot=s',
'no-relocatable',
'backends=s', 'no-clean!',
'with-nqp=s', 'gen-nqp:s',
'gen-moar:s', 'moar-option=s@',
@@ -147,6 +148,18 @@
$config{libdir} = $options{libdir};
$config{sdkroot} = $options{sdkroot} || '';
$config{sysroot} = $options{sysroot} || '';
if ($options{'no-relocatable'}) {
$config{static_nqp_home} = File::Spec->catdir($prefix, 'share', 'nqp');
$config{static_perl6_home} = File::Spec->catdir($prefix, 'share', 'perl6');
$config{static_nqp_home_define} = '-DSTATIC_NQP_HOME=' . $config{static_nqp_home};
$config{static_perl6_home_define} = '-DSTATIC_PERL6_HOME=' . $config{static_perl6_home};
}
else {
$config{static_nqp_home} = '';
$config{static_perl6_home} = '';
$config{static_nqp_home_define} = '';
$config{static_perl6_home_define} = '';
}
$config{slash} = $slash;
$config{'makefile-timing'} = $options{'makefile-timing'};
$config{'stagestats'} = '--stagestats' if $options{'makefile-timing'};
@@ -422,6 +435,8 @@ sub print_help {
--help Show this text
--prefix=<path> Install files in dir; also look for executables there
--libdir=<path> Install architecture-specific files in dir; Perl6 modules included
--no-relocatable
Create a perl6 with a fixed NQP and Perl6 home dir instead of dynamically identifying it
--sdkroot=<path> When given, use for searching build tools here, e.g.
nqp, java, node etc.
--sysroot=<path> When given, use for searching runtime components here
@@ -12,22 +12,30 @@ my $exec-dir := nqp::substr($execname, 0, nqp::rindex($execname, $sep));
my $exec-dir := nqp::substr(nqp::execname(), 0, nqp::rindex(nqp::execname(), $sep));
#?endif

my $perl6-home := nqp::getenvhash()<PERL6_HOME> // $exec-dir ~ '/../share/perl6';

# Initialize Rakudo runtime support.
nqp::p6init();

# Create and configure compiler object.
my $comp := Perl6::Compiler.new();

my $perl6-home := $comp.config<static_perl6_home>
// nqp::getenvhash()<PERL6_HOME>
// $exec-dir ~ '/../share/perl6';
if nqp::substr($perl6-home, nqp::chars($perl6-home) - 1) eq $sep {
$perl6-home := nqp::substr($perl6-home, 0, nqp::chars($perl6-home) - 1);
}
my $nqp-home := nqp::getenvhash()<NQP_HOME> // $exec-dir ~ '/../share/nqp';

my $nqp-home := $comp.config<static_nqp_home>
// nqp::getenvhash()<NQP_HOME>
// $exec-dir ~ '/../share/nqp';
if nqp::substr($nqp-home, nqp::chars($nqp-home) - 1) eq $sep {
$nqp-home := nqp::substr($nqp-home, 0, nqp::chars($nqp-home) - 1);
}

nqp::bindhllsym('perl6', '$PERL6_HOME', $perl6-home);
nqp::bindhllsym('perl6', '$NQP_HOME', $nqp-home);

# Initialize Rakudo runtime support.
nqp::p6init();

# Create and configure compiler object.
my $comp := Perl6::Compiler.new();
$comp.language('perl6');
$comp.parsegrammar(Perl6::Grammar);
$comp.parseactions(Perl6::Actions);
@@ -24,6 +24,9 @@
#define strtoll _strtoi64
#endif

#define STRINGIFY1(x) #x
#define STRINGIFY(x) STRINGIFY1(x)

/* flags need to be sorted alphabetically */

enum {
@@ -258,18 +261,26 @@ int wmain(int argc, wchar_t *wargv[])

/* Retrieve PERL6_HOME and NQP_HOME. */

#ifdef STATIC_NQP_HOME
nqp_home = STRINGIFY(STATIC_NQP_HOME);
#else
nqp_home = (char*)malloc(dir_path_size + 50);
if (!retrieve_home(nqp_home, "/../share/nqp", "NQP_HOME", dir_path, dir_path_size, "/lib/NQPCORE.setting.moarvm")) {
fprintf(stderr, "ERROR: NQP_HOME is invalid: %s\n", nqp_home);
return EXIT_FAILURE;
}
#endif
nqp_home_size = strlen(nqp_home);

#ifdef STATIC_PERL6_HOME
perl6_home = STRINGIFY(STATIC_PERL6_HOME);
#else
perl6_home = (char*)malloc(dir_path_size + 50);
if (!retrieve_home(perl6_home, "/../share/perl6", "PERL6_HOME", dir_path, dir_path_size, "/runtime/perl6.moarvm")) {
fprintf(stderr, "ERROR: PERL6_HOME is invalid: %s\n", perl6_home);
return EXIT_FAILURE;
}
#endif
perl6_home_size = strlen(perl6_home);

/* Put together the lib paths and perl6_file path. */
@@ -227,14 +227,14 @@ $(M_VALGRIND_RUNNER): tools/build/create-moar-runner.p6 $(M_C_RUNNER) $(PERL6_MO
$(M_C_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@ $(M_CFLAGS) $(M_LDFLAGS) -I$(M_INCPATH) -I$(M_INCPATH)/moar \
$(M_CC) @moar::ccshared@ @static_nqp_home_define@ @static_perl6_home_define@ $(M_CFLAGS) $(M_LDFLAGS) -I$(M_INCPATH) -I$(M_INCPATH)/moar \
-I$(M_INCPATH)/libatomic_ops -I$(M_INCPATH)/dyncall -I$(M_INCPATH)/sha1 -I$(M_INCPATH)/tinymt -I$(M_INCPATH)/libtommath -I$(M_INCPATH)/libuv \
-L@moar::libdir@ $(M_LDRPATH) $(M_MINGW_UNICODE) @moar::ccout@$@ src/vm/moar/runner/main.c -lmoar $(M_C_RUNNER_LIBS)

$(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 \
$(M_CC) @moar::ccshared@ @static_nqp_home_define@ @static_perl6_home_define@ -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@ $(M_LDRPATH) $(M_MINGW_UNICODE) @moar::ccout@$@ src/vm/moar/runner/main.c -lmoar $(M_C_RUNNER_LIBS)

0 comments on commit 27adb55

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