support cross-compilation.
On cross-compilation, compiled binary can no be created because compiled binary should be created by same interpreter (on cross- compilation, host ruby is used to build ruby (BASERUBY)). So that cross-compilation system loads required scripts in text. It is same as miniruby.
This commit is contained in:
parent
9c2807b2df
commit
40026a408d
Notes:
git
2019-12-11 11:25:18 +09:00
@ -3,6 +3,13 @@
|
|||||||
#include "iseq.h"
|
#include "iseq.h"
|
||||||
#include "builtin.h"
|
#include "builtin.h"
|
||||||
|
|
||||||
|
#if CROSS_COMPILING
|
||||||
|
|
||||||
|
#define INCLUDED_BY_BUILTIN_C 1
|
||||||
|
#include "mini_builtin.c"
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
#include "builtin_binary.inc"
|
#include "builtin_binary.inc"
|
||||||
|
|
||||||
static const unsigned char*
|
static const unsigned char*
|
||||||
@ -36,6 +43,8 @@ rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin
|
|||||||
rb_iseq_eval(iseq);
|
rb_iseq_eval(iseq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
Init_builtin(void)
|
Init_builtin(void)
|
||||||
{
|
{
|
||||||
|
@ -1115,7 +1115,7 @@ preludes: {$(srcdir)}golf_prelude.c
|
|||||||
$(Q) $(BASERUBY) $(srcdir)/tool/mk_builtin_loader.rb $<
|
$(Q) $(BASERUBY) $(srcdir)/tool/mk_builtin_loader.rb $<
|
||||||
|
|
||||||
builtin_binary.inc: $(PREP) $(BUILTIN_RB_SRCS) $(srcdir)/tool/mk_builtin_binary.rb
|
builtin_binary.inc: $(PREP) $(BUILTIN_RB_SRCS) $(srcdir)/tool/mk_builtin_binary.rb
|
||||||
$(Q) $(MINIRUBY) $(srcdir)/tool/mk_builtin_binary.rb
|
$(Q) $(MINIRUBY) $(srcdir)/tool/mk_builtin_binary.rb --cross=$(CROSS_COMPILING)
|
||||||
|
|
||||||
$(BUILTIN_RB_INCS): $(top_srcdir)/tool/mk_builtin_loader.rb
|
$(BUILTIN_RB_INCS): $(top_srcdir)/tool/mk_builtin_loader.rb
|
||||||
|
|
||||||
|
@ -3053,6 +3053,7 @@ AS_IF([test x"$cross_compiling" = xyes], [
|
|||||||
XRUBY='$(MINIRUBY)'
|
XRUBY='$(MINIRUBY)'
|
||||||
TEST_RUNNABLE=no
|
TEST_RUNNABLE=no
|
||||||
CROSS_COMPILING=yes
|
CROSS_COMPILING=yes
|
||||||
|
AC_DEFINE(CROSS_COMPILING, 1)
|
||||||
], [
|
], [
|
||||||
MINIRUBY='./miniruby$(EXEEXT) -I$(srcdir)/lib -I.'
|
MINIRUBY='./miniruby$(EXEEXT) -I$(srcdir)/lib -I.'
|
||||||
MINIRUBY="$MINIRUBY"' -I$(EXTOUT)/common'
|
MINIRUBY="$MINIRUBY"' -I$(EXTOUT)/common'
|
||||||
|
@ -2,11 +2,15 @@
|
|||||||
#include "vm_core.h"
|
#include "vm_core.h"
|
||||||
#include "iseq.h"
|
#include "iseq.h"
|
||||||
#include "builtin.h"
|
#include "builtin.h"
|
||||||
|
|
||||||
#include "miniprelude.c"
|
#include "miniprelude.c"
|
||||||
|
|
||||||
// included from miniinit.c
|
// included from miniinit.c
|
||||||
|
|
||||||
|
#ifndef INCLUDED_BY_BUILTIN_C
|
||||||
static struct st_table *loaded_builtin_table;
|
static struct st_table *loaded_builtin_table;
|
||||||
|
#endif
|
||||||
|
|
||||||
rb_ast_t *rb_builtin_ast(const char *feature_name, VALUE *name_str);
|
rb_ast_t *rb_builtin_ast(const char *feature_name, VALUE *name_str);
|
||||||
|
|
||||||
static const rb_iseq_t *
|
static const rb_iseq_t *
|
||||||
@ -26,8 +30,10 @@ builtin_iseq_load(const char *feature_name, const struct rb_builtin_function *ta
|
|||||||
rb_io_write(rb_stdout, rb_iseq_disasm((const rb_iseq_t *)iseq));
|
rb_io_write(rb_stdout, rb_iseq_disasm((const rb_iseq_t *)iseq));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef INCLUDED_BY_BUILTIN_C
|
||||||
st_insert(loaded_builtin_table, (st_data_t)feature_name, (st_data_t)iseq);
|
st_insert(loaded_builtin_table, (st_data_t)feature_name, (st_data_t)iseq);
|
||||||
rb_gc_register_mark_object((VALUE)iseq);
|
rb_gc_register_mark_object((VALUE)iseq);
|
||||||
|
#endif
|
||||||
|
|
||||||
return iseq;
|
return iseq;
|
||||||
}
|
}
|
||||||
@ -39,6 +45,8 @@ rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin
|
|||||||
rb_iseq_eval(iseq);
|
rb_iseq_eval(iseq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef INCLUDED_BY_BUILTIN_C
|
||||||
|
|
||||||
static int
|
static int
|
||||||
each_builtin_i(st_data_t key, st_data_t val, st_data_t dmy)
|
each_builtin_i(st_data_t key, st_data_t val, st_data_t dmy)
|
||||||
{
|
{
|
||||||
@ -70,3 +78,4 @@ Init_builtin_features(void)
|
|||||||
// register for ruby
|
// register for ruby
|
||||||
builtin_iseq_load("gem_prelude", NULL);
|
builtin_iseq_load("gem_prelude", NULL);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -11,11 +11,6 @@ def dump_bin iseq
|
|||||||
print "\n"
|
print "\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
ary = []
|
|
||||||
RubyVM::each_builtin{|feature, iseq|
|
|
||||||
ary << [feature, iseq]
|
|
||||||
}
|
|
||||||
|
|
||||||
$stdout = open('builtin_binary.inc', 'wb')
|
$stdout = open('builtin_binary.inc', 'wb')
|
||||||
|
|
||||||
puts <<H
|
puts <<H
|
||||||
@ -25,17 +20,25 @@ puts <<H
|
|||||||
|
|
||||||
H
|
H
|
||||||
|
|
||||||
ary.each{|feature, iseq|
|
if !ARGV.grep('--cross=yes').empty?
|
||||||
print "\n""static const unsigned char #{feature}_bin[] = {"
|
# do nothing
|
||||||
|
else
|
||||||
|
ary = []
|
||||||
|
RubyVM::each_builtin{|feature, iseq|
|
||||||
|
ary << [feature, iseq]
|
||||||
|
}
|
||||||
|
|
||||||
|
ary.each{|feature, iseq|
|
||||||
|
print "\n""static const unsigned char #{feature}_bin[] = {"
|
||||||
dump_bin(iseq)
|
dump_bin(iseq)
|
||||||
|
puts "};"
|
||||||
|
}
|
||||||
|
|
||||||
|
print "\n""static const struct builtin_binary builtin_binary[] = {\n"
|
||||||
|
ary.each{|feature, iseq|
|
||||||
|
puts " {#{feature.dump}, #{feature}_bin, sizeof(#{feature}_bin)},"
|
||||||
|
}
|
||||||
|
puts " {NULL}," # dummy sentry
|
||||||
puts "};"
|
puts "};"
|
||||||
}
|
puts "#define BUILTIN_BINARY_SIZE #{ary.size}"
|
||||||
|
end
|
||||||
print "\n""static const struct builtin_binary builtin_binary[] = {\n"
|
|
||||||
ary.each{|feature, iseq|
|
|
||||||
puts " {#{feature.dump}, #{feature}_bin, sizeof(#{feature}_bin)},"
|
|
||||||
}
|
|
||||||
puts " {NULL}," # dummy sentry
|
|
||||||
puts "};"
|
|
||||||
|
|
||||||
puts "#define BUILTIN_BINARY_SIZE #{ary.size}"
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user