[macruby-changes] [4244] MacRuby/trunk/rakelib

source_changes at macosforge.org source_changes at macosforge.org
Fri Jun 18 15:38:11 PDT 2010


Revision: 4244
          http://trac.macosforge.org/projects/ruby/changeset/4244
Author:   lsansonetti at apple.com
Date:     2010-06-18 15:38:10 -0700 (Fri, 18 Jun 2010)
Log Message:
-----------
honor current builder archs when generating kernel bitcode

Modified Paths:
--------------
    MacRuby/trunk/rakelib/builder/builder.rb
    MacRuby/trunk/rakelib/builder.rake

Modified: MacRuby/trunk/rakelib/builder/builder.rb
===================================================================
--- MacRuby/trunk/rakelib/builder/builder.rb	2010-06-18 21:58:37 UTC (rev 4243)
+++ MacRuby/trunk/rakelib/builder/builder.rb	2010-06-18 22:38:10 UTC (rev 4244)
@@ -37,7 +37,7 @@
     end.each { |t| t.join }
   end
 
-  attr_reader :objs, :objsdir, :cflags, :cxxflags
+  attr_reader :objs, :archs, :objsdir, :cflags, :cxxflags
   attr_accessor :cflags, :cxxflags, :objc_cflags, :ldflags, :dldflags
 
   def initialize(objs)
@@ -51,6 +51,7 @@
       case @mode
         when :full
           @objs = @all_objs
+          @archs = ARCHS
           @cflags = CFLAGS
           @cxxflags = CXXFLAGS
           @objc_cflags = OBJC_CFLAGS
@@ -58,6 +59,7 @@
           @objsdir = FULL_OBJS_DIR
         when :static
           @objs = @all_objs - %w{bs compiler debugger interpreter MacRubyDebuggerConnector}
+          @archs = ARCHS_STATIC
           @cflags = CFLAGS_STATIC
           @cxxflags = CXXFLAGS_STATIC
           @objc_cflags = OBJC_CFLAGS_STATIC

Modified: MacRuby/trunk/rakelib/builder.rake
===================================================================
--- MacRuby/trunk/rakelib/builder.rake	2010-06-18 21:58:37 UTC (rev 4243)
+++ MacRuby/trunk/rakelib/builder.rake	2010-06-18 22:38:10 UTC (rev 4244)
@@ -27,7 +27,8 @@
   if !File.exist?('node_name.inc') or File.mtime('include/ruby/node.h') > File.mtime('node_name.inc')
     sh("/usr/bin/ruby -n tool/node_name.rb include/ruby/node.h > node_name.inc")
   end
-  if !File.exist?('kernel_data.c') or File.mtime('kernel.c') > File.mtime('kernel_data.c')
+  kernel_data_c = File.join($builder.objsdir, 'kernel_data.c')
+  if !File.exist?(kernel_data_c) or File.mtime('kernel.c') > File.mtime(kernel_data_c)
     # Locate llvm-gcc...
     path = ENV['PATH'].split(':')
     path.unshift('/Developer/usr/bin')
@@ -40,18 +41,21 @@
     unless File.exist?(opt)
       $stderr.puts "Cannot locate opt in given LLVM path: #{LLVM_PATH}"
     end
-    sh "echo '' > kernel_data.c"
-    includes = CFLAGS.scan(/-I[^\s]+/).join(' ')
-    ARCHS.each do |x| 
-      output = "kernel-#{x}.bc"
+    sh "echo '' > #{kernel_data_c}"
+    cflags = $builder.cflags.scan(/-I[^\s]+/).join(' ')
+    cflags << ' ' << $builder.cflags.scan(/-D[^\s]+/).join(' ')
+    $builder.archs.each do |x| 
+      output = File.join($builder.objsdir, "kernel-#{x}.bc")
       # Compile the IR for the kernel.c source file & optimize it.
-      sh "#{llvm_gcc} -arch #{x} -fexceptions -fno-stack-protector #{includes} --emit-llvm -c kernel.c -o #{output}"
+      sh "#{llvm_gcc} -arch #{x} -fexceptions -fno-stack-protector #{cflags} --emit-llvm -c kernel.c -o #{output}"
       sh "#{opt} -O3 #{output} -o=#{output}"
-      # Convert the bitcode into a C static array. We append a null byte to the bitcode file because
-      # xxd doesn't, and it's needed by the bitcode reader later at runtime.
+      # Convert the bitcode into a C static array. We append a null byte to the
+      # bitcode file because xxd doesn't, and it's needed by the bitcode
+      # reader later at runtime.
+      cp output, "#{output}.old"
       sh "/bin/dd if=/dev/zero count=1 bs=1 conv=notrunc >> #{output} 2>/dev/null"
-      sh "/usr/bin/xxd -i #{output} >> kernel_data.c"
-      sh "/bin/rm #{output}"
+      sh "/usr/bin/xxd -i #{output} >> #{kernel_data_c}"
+      mv "#{output}.old", output
     end
   end
   dispatcher_o = File.join($builder.objsdir, 'dispatcher.o')
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100618/66d7a663/attachment-0001.html>


More information about the macruby-changes mailing list