Skip to content
Permalink
Browse files

Mod CORE.d setting compilation to propagate indicator flags

I need a flag to know when to set default lang and load any
extra setting, but current design looks to be largely
CORE.c-centered and treats CORE.d as just a usercode module[^1]

Fix by using NULL.d instead of NULL for compiling `d` core, and
temporarily modding NULL-careing things to care about NULL.d too.

[1] #2432
  • Loading branch information...
zoffixznet committed Oct 27, 2018
1 parent 84039f9 commit 4a6d910839f9c9acee768bccfd4882626ff3e1d8
@@ -1304,6 +1304,8 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
:my $*NEXT_STATEMENT_ID := 1; # to give each statement an ID
:my $*IN_STMT_MOD := 0; # are we inside a statement modifier?
:my $*COMPILING_CORE_SETTING := 0; # are we compiling CORE.setting?
# TODO XXX: see https://github.com/rakudo/rakudo/issues/2432
:my $*SET_DEFAULT_LANG_VER := 1;
:my %*SIG_INFO; # information about recent signature
# Various interesting scopes we'd like to keep to hand.
@@ -210,6 +210,8 @@ class Perl6::ModuleLoader does Perl6::ModuleLoaderVMConfig {
my $setting;

if $setting_name ne 'NULL' {
# XXX TODO: see https://github.com/rakudo/rakudo/issues/2432
$setting_name := 'CORE' if $setting_name eq 'NULL.d';
# Unless we already did so, locate and load the setting.
unless nqp::defined(%settings_loaded{$setting_name}) {
DEBUG("Loading settings $setting_name") if $DEBUG;
@@ -555,6 +555,8 @@ class Perl6::World is HLL::World {
else {
$setting_name := %*COMPILING<%?OPTIONS><setting> // 'CORE';
$*COMPILING_CORE_SETTING := 1 if $setting_name eq 'NULL';
$*SET_DEFAULT_LANG_VER := 0
if nqp::eqat($setting_name, 'NULL', 0);
self.load_setting($/,$setting_name);
$*UNIT.annotate('IN_DECL', 'mainline');
}
@@ -791,6 +793,8 @@ class Perl6::World is HLL::World {
method load_setting($/, $setting_name) {
# Do nothing for the NULL setting.
if $setting_name ne 'NULL' {
# XXX TODO: see https://github.com/rakudo/rakudo/issues/2432
$setting_name := 'CORE' if $setting_name eq 'NULL.d';
# Load it immediately, so the compile time info is available.
# Once it's loaded, set it as the outer context of the code
# being compiled.
@@ -153,7 +153,7 @@ $(SETTING_JAR): $(PERL6_JAR) $(PERL6_B_JAR) $(J_CORE_SOURCES)
$(SETTING_D_JAR): $(PERL6_JAR) $(PERL6_B_JAR) $(SETTING_JAR) $(J_CORE_SOURCES)
$(J_NQP) $(J_GEN_CAT) $(J_CORE_D_SOURCES) > $(J_BUILD_DIR)/CORE.d.setting
@echo "The following step can take a long time, please be patient."
NQP_LIB=blib $(J_RUN_PERL6) --ll-exception --optimize=3 --target=jar --stagestats --output=$(SETTING_D_JAR) --nqp-lib=blib $(J_BUILD_DIR)/CORE.d.setting
NQP_LIB=blib $(J_RUN_PERL6) --setting=NULL.d --ll-exception --optimize=3 --target=jar --stagestats --output=$(SETTING_D_JAR) --nqp-lib=blib $(J_BUILD_DIR)/CORE.d.setting

$(J_RUNNER): tools/build/create-jvm-runner.pl
$(PERL5) tools/build/create-jvm-runner.pl dev . . $(NQP_PREFIX) --nqp-lib=blib $(NQP_JARS)
@@ -177,7 +177,7 @@ $(SETTING_MOAR): $(PERL6_MOAR) $(PERL6_B_MOAR) $(M_CORE_SOURCES)
$(SETTING_D_MOAR): $(PERL6_MOAR) $(PERL6_B_MOAR) $(SETTING_MOAR) $(M_CORE_D_SOURCES)
$(M_NQP) $(M_GEN_CAT) -f tools/build/moar_core_d_sources > $(M_BUILD_DIR)/CORE.d.setting
@echo "The following step can take a long time, please be patient."
$(M_RUN_PERL6) --ll-exception --optimize=3 --target=mbc --stagestats --output=$(SETTING_D_MOAR) $(M_BUILD_DIR)/CORE.d.setting
$(M_RUN_PERL6) --setting=NULL.d --ll-exception --optimize=3 --target=mbc --stagestats --output=$(SETTING_D_MOAR) $(M_BUILD_DIR)/CORE.d.setting

$(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)
@@ -133,7 +133,7 @@ rule($CORE, "$CORE-combined rakudo.js $Perl6-Bootstrap",

my $CORE-d := "$blib/CORE.d.setting.js";
rule($CORE-d, "$CORE-d-combined rakudo.js $Perl6-Bootstrap $CORE",
"node --max-old-space-size=8192 rakudo.js \$(JS_FLAGS) --source-map --target=js --output=$CORE-d $CORE-d-combined"
"node --max-old-space-size=8192 rakudo.js \$(JS_FLAGS) --source-map --target=js --setting=NULL.d --output=$CORE-d $CORE-d-combined"
);

say("js-all: check_nqp_version $ModuleLoader-nqp $Perl6-Grammar $Perl6-Actions $Perl6-Compiler $Perl6-Pod $Perl6-main $Perl6-Bootstrap $CORE $CORE-d \$(JS_RUNNER) $load-compiler\n");

0 comments on commit 4a6d910

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