ext/ffi/hydrogen/Rakefile in ffi-hydrogen-0.1.3 vs ext/ffi/hydrogen/Rakefile in ffi-hydrogen-0.1.4
- old
+ new
@@ -13,19 +13,25 @@
" -Wbad-function-cast -Wcast-align -Wcast-qual -Wfloat-equal"\
" -Wmissing-declarations -Wnested-externs -Wno-unknown-pragmas"\
" -Wpointer-arith -Wredundant-decls -Wstrict-prototypes -Wswitch-enum"\
" -Wno-type-limits"
- cflags = "-O3 -march=native -fPIC -fno-exceptions #{wflags}"
+ cpuflag = if RUBY_PLATFORM =~ /arm64/ && RUBY_PLATFORM =~ /darwin/
+ "-mcpu=apple-m1"
+ else
+ "-march=native"
+ end
+
+ cflags = "-O3 #{cpuflag} -fPIC -fno-exceptions #{wflags}"
cwd = ::File.expand_path(::File.dirname(__FILE__))
::Dir.chdir(cwd) do
# main.o: main.c
# $(CC) -c $(CFLAGS) $< -o $@
sys("cc -c #{cflags} main.c -o main.o")
# main.dylib: main.o
- # $(CC) $< -shared -o $@
+ # $(CC) $< -shared -o $@
sys("cc main.o -shared -o main.#{::FFI::Platform::LIBSUFFIX}")
end
end
task :default => [:compile_shared]