<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -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.
 </diff>
      <filename>HACKING.rdoc</filename>
    </modified>
    <modified>
      <diff>@@ -46,7 +46,7 @@ desc &quot;Clean local and extension build files&quot;
 task :clean =&gt; ['clean:local', 'clean:ext']
 
 desc &quot;Build MacRuby and extensions&quot;
-task :all =&gt; [:macruby, :extensions]
+task :all =&gt; [:macruby, :aot_compile_stdlib, :extensions]
 
 desc &quot;Create an archive (GIT only)&quot;
 task :git_archive do
@@ -59,4 +59,4 @@ task :spec =&gt; 'spec:ci'
 desc &quot;Run IRB&quot;
 task :irb do
   exec './miniruby -I./lib ./bin/irb'
-end
\ No newline at end of file
+end</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -361,7 +361,7 @@ install?(:local, :comm, :lib) do
   Dir.chdir srcdir
   makedirs [rubylibdir]
 
-  for f in Dir[&quot;lib/**/*{.rb,help-message}&quot;]
+  for f in Dir[&quot;lib/**/*{.rb,.rbo,help-message}&quot;]
     dir = File.dirname(f).sub!(/\Alib/, rubylibdir) || rubylibdir
     makedirs dir
     install f, dir, :mode =&gt; $data_mode
@@ -517,14 +517,6 @@ mkdir_p ib_dest
 ln_sfh File.join(&quot;../../..&quot;, CONFIG['bindir'], 'rb_nibtool'), ib_dest
 install('tool/rb_nibtool.old', ib_dest, :mode =&gt; $prog_mode)
 
-puts &quot;compiling (parts of) the standard library&quot;
-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 = &quot;./miniruby -I. -I./lib bin/rubyc --internal -C \&quot;#{path}\&quot;&quot;
-  $stderr.puts line
-  raise 'AOT compilation failed' unless system(line)
-end
-
 end # unless $installing_rdoc
 
 # vi:set sw=2:</diff>
      <filename>instruby.rb</filename>
    </modified>
    <modified>
      <diff>@@ -12,6 +12,9 @@
 #include &quot;vm.h&quot;
 #include &quot;dln.h&quot;
 
+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, &quot;rb&quot;) == 0) {
 	    t = TYPE_RB;
 	}
-	else if (strcmp(p + 1, &quot;rbo&quot;) == 0) {
+	else if (rbo_enabled &amp;&amp; strcmp(p + 1, &quot;rbo&quot;) == 0) {
 	    t = TYPE_RBO;
 	}
 	else if (strcmp(p + 1, &quot;bundle&quot;) == 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, &quot;%s.rbo&quot;, path);
-    if (path_ok(buf, out)) {
-	*type = TYPE_RBO;
-	return true;
+    if (rbo_enabled) {
+	snprintf(buf, sizeof buf, &quot;%s.rbo&quot;, path);
+	if (path_ok(buf, out)) {
+	    *type = TYPE_RBO;
+	    return true;
+	}
     }
     snprintf(buf, sizeof buf, &quot;%s.rb&quot;, path);
     if (path_ok(buf, out)) {
@@ -377,6 +382,8 @@ Init_load()
     const char *var_load_path = &quot;$:&quot;;
     ID id_load_path = rb_intern(var_load_path);
 
+    rbo_enabled = !ruby_is_miniruby &amp;&amp; getenv(&quot;VM_DISABLE_RBO&quot;) == NULL;
+
     rb_define_virtual_variable(&quot;$:&quot;, rb_vm_load_path, 0);
     rb_alias_variable((rb_intern)(&quot;$-I&quot;), id_load_path);
     rb_alias_variable((rb_intern)(&quot;$LOAD_PATH&quot;), id_load_path);</diff>
      <filename>load.c</filename>
    </modified>
    <modified>
      <diff>@@ -346,6 +346,19 @@ task :extensions =&gt; [:miniruby, &quot;macruby:static&quot;] do
   perform_extensions_target(:all)
 end
 
+AOT_STDLIB = ['rbconfig.rb', 'lib/irb.rb', 'lib/irb/**/*.rb', 'lib/fileutils.rb']
+desc &quot;AOT compile parts of the stdlib&quot;
+task :aot_compile_stdlib =&gt; [: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) &gt; File.mtime(out) or File.mtime('./miniruby') &gt; File.mtime(out)
+        sh &quot;./miniruby -I. -I./lib bin/rubyc --internal -C \&quot;#{path}\&quot; -o \&quot;#{out}\&quot;&quot;
+      end
+    end
+  end 
+end
+
 desc &quot;Same as extensions&quot;
 task :ext =&gt; 'extensions'
 </diff>
      <filename>rakelib/builder.rake</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>90a8581d99e2669e38017b34b4628f69303eaa9d</id>
    </parent>
  </parents>
  <author>
    <name>lsansonetti@apple.com</name>
    <email>lsansonetti@apple.com@23306eb0-4c56-4727-a40e-e92c0eb68959</email>
  </author>
  <url>http://github.com/masterkain/macruby/commit/4d7d05fcc6115a80e5ff05bea7148bd9cdbdc9d3</url>
  <id>4d7d05fcc6115a80e5ff05bea7148bd9cdbdc9d3</id>
  <committed-date>2009-09-21T22:14:51-07:00</committed-date>
  <authored-date>2009-09-21T22:14:51-07:00</authored-date>
  <message>move the AOT compilation of the stdlib into the main build task, introduce 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</message>
  <tree>0211054fbd1fd9a4879296a3cbf91823691e7c63</tree>
  <committer>
    <name>lsansonetti@apple.com</name>
    <email>lsansonetti@apple.com@23306eb0-4c56-4727-a40e-e92c0eb68959</email>
  </committer>
</commit>
