зеркало из https://github.com/github/ruby.git
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:
Родитель
9c2807b2df
Коммит
40026a408d
|
@ -3,6 +3,13 @@
|
|||
#include "iseq.h"
|
||||
#include "builtin.h"
|
||||
|
||||
#if CROSS_COMPILING
|
||||
|
||||
#define INCLUDED_BY_BUILTIN_C 1
|
||||
#include "mini_builtin.c"
|
||||
|
||||
#else
|
||||
|
||||
#include "builtin_binary.inc"
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void
|
||||
Init_builtin(void)
|
||||
{
|
||||
|
|
|
@ -1115,7 +1115,7 @@ preludes: {$(srcdir)}golf_prelude.c
|
|||
$(Q) $(BASERUBY) $(srcdir)/tool/mk_builtin_loader.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
|
||||
|
||||
|
|
|
@ -3053,6 +3053,7 @@ AS_IF([test x"$cross_compiling" = xyes], [
|
|||
XRUBY='$(MINIRUBY)'
|
||||
TEST_RUNNABLE=no
|
||||
CROSS_COMPILING=yes
|
||||
AC_DEFINE(CROSS_COMPILING, 1)
|
||||
], [
|
||||
MINIRUBY='./miniruby$(EXEEXT) -I$(srcdir)/lib -I.'
|
||||
MINIRUBY="$MINIRUBY"' -I$(EXTOUT)/common'
|
||||
|
|
|
@ -2,11 +2,15 @@
|
|||
#include "vm_core.h"
|
||||
#include "iseq.h"
|
||||
#include "builtin.h"
|
||||
|
||||
#include "miniprelude.c"
|
||||
|
||||
// included from miniinit.c
|
||||
|
||||
#ifndef INCLUDED_BY_BUILTIN_C
|
||||
static struct st_table *loaded_builtin_table;
|
||||
#endif
|
||||
|
||||
rb_ast_t *rb_builtin_ast(const char *feature_name, VALUE *name_str);
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
#ifndef INCLUDED_BY_BUILTIN_C
|
||||
st_insert(loaded_builtin_table, (st_data_t)feature_name, (st_data_t)iseq);
|
||||
rb_gc_register_mark_object((VALUE)iseq);
|
||||
#endif
|
||||
|
||||
return iseq;
|
||||
}
|
||||
|
@ -39,6 +45,8 @@ rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin
|
|||
rb_iseq_eval(iseq);
|
||||
}
|
||||
|
||||
#ifndef INCLUDED_BY_BUILTIN_C
|
||||
|
||||
static int
|
||||
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
|
||||
builtin_iseq_load("gem_prelude", NULL);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -11,11 +11,6 @@ def dump_bin iseq
|
|||
print "\n"
|
||||
end
|
||||
|
||||
ary = []
|
||||
RubyVM::each_builtin{|feature, iseq|
|
||||
ary << [feature, iseq]
|
||||
}
|
||||
|
||||
$stdout = open('builtin_binary.inc', 'wb')
|
||||
|
||||
puts <<H
|
||||
|
@ -25,17 +20,25 @@ puts <<H
|
|||
|
||||
H
|
||||
|
||||
ary.each{|feature, iseq|
|
||||
print "\n""static const unsigned char #{feature}_bin[] = {"
|
||||
if !ARGV.grep('--cross=yes').empty?
|
||||
# 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)
|
||||
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 "};"
|
||||
}
|
||||
|
||||
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}"
|
||||
puts "#define BUILTIN_BINARY_SIZE #{ary.size}"
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче