Permalink
Browse files

Courtesy of Jordan Breeding, a patch to build with Clang and llvm-gcc…

…. To do so, build with 'rake use_clang=true miniruby'.

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/branches/experimental@1919 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
1 parent d23657e commit 0c5e41a6fdf4a44c8544c64106877b8b8c342357 Patrick Thomson committed Jun 23, 2009
Showing with 25 additions and 9 deletions.
  1. +13 −5 rakelib/builder.rb
  2. +2 −1 signal.c
  3. +10 −3 variable.c
View
@@ -19,6 +19,7 @@ def do_option(name, default)
end
end
+USE_CLANG = do_option('use_clang', false)
RUBY_INSTALL_NAME = do_option('ruby_install_name', 'macruby')
RUBY_SO_NAME = do_option('ruby_so_name', RUBY_INSTALL_NAME)
ARCHS =
@@ -84,7 +85,14 @@ def do_option(name, default)
INSTALL_NAME = File.join(FRAMEWORK_USR_LIB, 'lib' + RUBY_SO_NAME + '.dylib')
ARCHFLAGS = ARCHS.map { |a| '-arch ' + a }.join(' ')
LLVM_MODULES = "core jit nativecodegen interpreter bitwriter"
-CFLAGS = "-I. -I./include -I./onig -I/usr/include/libxml2 #{ARCHFLAGS} -fno-common -pipe -O3 -g -Wall -fexceptions"
+if (USE_CLANG) and (`sw_vers -productVersion`.strip >= '10.6')
+ CC = '/usr/bin/clang'
+ CPP = '/usr/bin/llvm-g++-4.2'
+elsif
+ CC = '/usr/bin/gcc'
+ CPP = '/usr/bin/g++'
+end
+CFLAGS = "-I. -I./include -I./onig -I./giants/libDGiants -I/usr/include/libxml2 #{ARCHFLAGS} -fno-common -pipe -O3 -g -Wall -fexceptions"
CFLAGS << " -Wno-parentheses -Wno-deprecated-declarations -Werror" if NO_WARN_BUILD
OBJC_CFLAGS = CFLAGS + " -fobjc-gc-only"
CXXFLAGS = `#{LLVM_CONFIG} --cxxflags #{LLVM_MODULES}`.strip
@@ -130,9 +138,9 @@ def build(objs=nil)
s = obj_source(obj)
cc, flags =
case File.extname(s)
- when '.c' then ['/usr/bin/gcc', @cflags]
- when '.cpp' then ['/usr/bin/g++', @cxxflags]
- when '.m' then ['/usr/bin/gcc', @objc_cflags]
+ when '.c' then [CC, @cflags]
+ when '.cpp' then [CPP, @cxxflags]
+ when '.m' then [CC, @objc_cflags]
end
sh("#{cc} #{flags} -c #{s} -o #{obj}.o")
end
@@ -166,7 +174,7 @@ def link(objs, ldflags, args, name)
objs ||= @objs
ldflags ||= @ldflags
if should_link?(name, objs)
- sh("/usr/bin/g++ #{@cflags} #{objs.map { |x| x + '.o' }.join(' ') } #{ldflags} #{args}")
+ sh("#{CPP} #{@cflags} #{objs.map { |x| x + '.o' }.join(' ') } #{ldflags} #{args}")
end
end
View
@@ -416,8 +416,9 @@ rb_gc_mark_trap_list(void)
int i;
for (i=0; i<NSIG; i++) {
- if (trap_list[i].cmd)
+ if (trap_list[i].cmd) {
rb_gc_mark(trap_list[i].cmd);
+ }
}
#endif /* MACOS_UNUSE_SIGNAL */
}
View
@@ -437,7 +437,9 @@ val_setter(VALUE val, ID id, void *data, struct global_variable *var)
static void
val_marker(VALUE data)
{
- if (data) rb_gc_mark_maybe(data);
+ if (data) {
+ rb_gc_mark_maybe(data);
+ }
}
static VALUE
@@ -456,7 +458,9 @@ var_setter(VALUE val, ID id, VALUE *var)
static void
var_marker(VALUE *var)
{
- if (var) rb_gc_mark_maybe(*var);
+ if (var) {
+ rb_gc_mark_maybe(*var);
+ }
}
static void
@@ -474,7 +478,10 @@ mark_global_entry(ID key, struct global_entry *entry)
(*var->marker)(var->data);
trace = var->trace;
while (trace) {
- if (trace->data) rb_gc_mark_maybe(trace->data);
+ if (trace->data)
+ {
+ rb_gc_mark_maybe(trace->data);
+ }
trace = trace->next;
}
return ST_CONTINUE;

0 comments on commit 0c5e41a

Please sign in to comment.