Permalink
Browse files

move the AOT compilation of the stdlib into the main build task, intr…

…oduce the VM_DISABLE_RBO environment variable to disable the load of rbo files, change instruby.rb to install the .rbo files

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@2601 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
1 parent 42b32fc commit 3ae269b513b43babbd490533e790c3916ef5ff58 @lrz lrz committed Sep 22, 2009
Showing with 30 additions and 16 deletions.
  1. +2 −0 HACKING.rdoc
  2. +2 −2 Rakefile
  3. +1 −9 instruby.rb
  4. +12 −5 load.c
  5. +13 −0 rakelib/builder.rake
View
@@ -102,6 +102,8 @@ The following environment variables might help you debug easy bugs.
* GC_DEBUG: set it to any value to enable GC debugging on $stderr.
+* VM_DISABLE_RBO: set it to any value to disable the load of .rbo files.
+
* VM_DUMP_IR: set it to any value to dump the LLVM IR on $stderr before the
interpreter quits.
View
@@ -46,7 +46,7 @@ desc "Clean local and extension build files"
task :clean => ['clean:local', 'clean:ext']
desc "Build MacRuby and extensions"
-task :all => [:macruby, :extensions]
+task :all => [:macruby, :aot_compile_stdlib, :extensions]
desc "Create an archive (GIT only)"
task :git_archive do
@@ -59,4 +59,4 @@ task :spec => 'spec:ci'
desc "Run IRB"
task :irb do
exec './miniruby -I./lib ./bin/irb'
-end
+end
View
@@ -361,7 +361,7 @@ def with_destdir(dir)
Dir.chdir srcdir
makedirs [rubylibdir]
- for f in Dir["lib/**/*{.rb,help-message}"]
+ for f in Dir["lib/**/*{.rb,.rbo,help-message}"]
dir = File.dirname(f).sub!(/\Alib/, rubylibdir) || rubylibdir
makedirs dir
install f, dir, :mode => $data_mode
@@ -517,14 +517,6 @@ def install_stuff(what, from, to, mode)
ln_sfh File.join("../../..", CONFIG['bindir'], 'rb_nibtool'), ib_dest
install('tool/rb_nibtool.old', ib_dest, :mode => $prog_mode)
-puts "compiling (parts of) the standard library"
-files = ['universal-darwin*/rbconfig.rb', 'irb.rb', 'irb/**/*.rb']
-files.map { |file| Dir.glob(File.join(with_destdir(rubylibdir), file)) }.flatten.each do |path|
- line = "./miniruby -I. -I./lib bin/rubyc --internal -C \"#{path}\""
- $stderr.puts line
- raise 'AOT compilation failed' unless system(line)
-end
-
end # unless $installing_rdoc
# vi:set sw=2:
View
17 load.c
@@ -12,6 +12,9 @@
#include "vm.h"
#include "dln.h"
+extern bool ruby_is_miniruby;
+static bool rbo_enabled = true;
+
VALUE
rb_get_load_path(void)
{
@@ -173,7 +176,7 @@ check_path(const char *path, VALUE *out, int *type)
if (strcmp(p + 1, "rb") == 0) {
t = TYPE_RB;
}
- else if (strcmp(p + 1, "rbo") == 0) {
+ else if (rbo_enabled && strcmp(p + 1, "rbo") == 0) {
t = TYPE_RBO;
}
else if (strcmp(p + 1, "bundle") == 0) {
@@ -188,10 +191,12 @@ check_path(const char *path, VALUE *out, int *type)
// No valid extension, let's append the valid ones and try to validate
// the path.
char buf[PATH_MAX];
- snprintf(buf, sizeof buf, "%s.rbo", path);
- if (path_ok(buf, out)) {
- *type = TYPE_RBO;
- return true;
+ if (rbo_enabled) {
+ snprintf(buf, sizeof buf, "%s.rbo", path);
+ if (path_ok(buf, out)) {
+ *type = TYPE_RBO;
+ return true;
+ }
}
snprintf(buf, sizeof buf, "%s.rb", path);
if (path_ok(buf, out)) {
@@ -377,6 +382,8 @@ Init_load()
const char *var_load_path = "$:";
ID id_load_path = rb_intern(var_load_path);
+ rbo_enabled = !ruby_is_miniruby && getenv("VM_DISABLE_RBO") == NULL;
+
rb_define_virtual_variable("$:", rb_vm_load_path, 0);
rb_alias_variable((rb_intern)("$-I"), id_load_path);
rb_alias_variable((rb_intern)("$LOAD_PATH"), id_load_path);
View
@@ -346,6 +346,19 @@ task :extensions => [:miniruby, "macruby:static"] do
perform_extensions_target(:all)
end
+AOT_STDLIB = ['rbconfig.rb', 'lib/irb.rb', 'lib/irb/**/*.rb', 'lib/fileutils.rb']
+desc "AOT compile parts of the stdlib"
+task :aot_compile_stdlib => [:miniruby] do
+ AOT_STDLIB.each do |pat|
+ Dir.glob(pat).each do |path|
+ out = File.join(File.dirname(path), File.basename(path, '.rb') + '.rbo')
+ if !File.exist?(out) or File.mtime(path) > File.mtime(out) or File.mtime('./miniruby') > File.mtime(out)
+ sh "./miniruby -I. -I./lib bin/rubyc --internal -C \"#{path}\" -o \"#{out}\""
+ end
+ end
+ end
+end
+
desc "Same as extensions"
task :ext => 'extensions'

0 comments on commit 3ae269b

Please sign in to comment.