mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-06-11 00:09:38 +08:00
merge the patches to fix build error of Extension and Framework for arm64
http://hipbyte.myjetbrains.com/youtrack/issue/RM-655
Merged below patches into Extension and Framework:
- 1567487...fde9580
This commit is contained in:
@@ -168,7 +168,6 @@ PLIST
|
||||
raise "Can't locate kernel file" unless File.exist?(kernel)
|
||||
|
||||
# Assembly.
|
||||
asm = File.join(files_build_dir, "#{path}.#{arch}.s")
|
||||
arm64 = false
|
||||
compiler_exec_arch = case arch
|
||||
when /^arm/
|
||||
@@ -176,24 +175,13 @@ PLIST
|
||||
else
|
||||
arch
|
||||
end
|
||||
asm = File.join(files_build_dir, "#{path}.#{arch}.#{arm64 ? 'bc' : 's'}")
|
||||
sh "/usr/bin/env VM_PLATFORM=\"#{platform}\" VM_KERNEL_PATH=\"#{kernel}\" VM_OPT_LEVEL=\"#{config.opt_level}\" /usr/bin/arch -arch #{compiler_exec_arch} #{ruby} #{rubyc_bs_flags} --emit-llvm \"#{asm}\" #{init_func} \"#{path}\""
|
||||
|
||||
# Object
|
||||
arch_obj = File.join(files_build_dir, "#{path}.#{arch}.o")
|
||||
if arm64
|
||||
# At the time of this writing Apple hasn't yet contributed the source code of the LLVM backend for the "arm64" architecture, so the RubyMotion compiler can't emit proper assembly yet. We work around this limitation by generating bitcode instead and giving it to the linker. Ugly but should be temporary (right?).
|
||||
@dummy_object_file ||= begin
|
||||
src_path = '/tmp/__dummy_object_file__.c'
|
||||
obj_path = '/tmp/__dummy_object_file__.o'
|
||||
File.open(src_path, 'w') { |io| io.puts "static int foo(void) { return 42; }" }
|
||||
sh "#{cc} -c #{src_path} -o #{obj_path} -arch arm64 -miphoneos-version-min=7.0"
|
||||
obj_path
|
||||
end
|
||||
ld_path = File.join(App.config.xcode_dir, 'Toolchains/XcodeDefault.xctoolchain/usr/bin/ld')
|
||||
sh "#{ld_path} \"#{asm}\" \"#{@dummy_object_file}\" -arch arm64 -r -o \"#{arch_obj}\""
|
||||
else
|
||||
sh "#{cc} -fexceptions -c -arch #{arch} \"#{asm}\" -o \"#{arch_obj}\""
|
||||
end
|
||||
arch_obj_flags = arm64 ? "-miphoneos-version-min=#{config.deployment_target}" : ''
|
||||
sh "#{cc} -fexceptions -c -arch #{arch} #{arch_obj_flags} \"#{asm}\" -o \"#{arch_obj}\""
|
||||
|
||||
[asm].each { |x| File.unlink(x) } unless ENV['keep_temps']
|
||||
arch_objs << arch_obj
|
||||
|
||||
@@ -126,7 +126,6 @@ module Motion; module Project
|
||||
raise "Can't locate kernel file" unless File.exist?(kernel)
|
||||
|
||||
# Assembly.
|
||||
asm = File.join(files_build_dir, "#{path}.#{arch}.s")
|
||||
arm64 = false
|
||||
compiler_exec_arch = case arch
|
||||
when /^arm/
|
||||
@@ -134,24 +133,13 @@ module Motion; module Project
|
||||
else
|
||||
arch
|
||||
end
|
||||
asm = File.join(files_build_dir, "#{path}.#{arch}.#{arm64 ? 'bc' : 's'}")
|
||||
sh "/usr/bin/env VM_PLATFORM=\"#{platform}\" VM_KERNEL_PATH=\"#{kernel}\" VM_OPT_LEVEL=\"#{config.opt_level}\" /usr/bin/arch -arch #{compiler_exec_arch} #{ruby} #{rubyc_bs_flags} --emit-llvm \"#{asm}\" #{init_func} \"#{path}\""
|
||||
|
||||
# Object
|
||||
arch_obj = File.join(files_build_dir, "#{path}.#{arch}.o")
|
||||
if arm64
|
||||
# At the time of this writing Apple hasn't yet contributed the source code of the LLVM backend for the "arm64" architecture, so the RubyMotion compiler can't emit proper assembly yet. We work around this limitation by generating bitcode instead and giving it to the linker. Ugly but should be temporary (right?).
|
||||
@dummy_object_file ||= begin
|
||||
src_path = '/tmp/__dummy_object_file__.c'
|
||||
obj_path = '/tmp/__dummy_object_file__.o'
|
||||
File.open(src_path, 'w') { |io| io.puts "static int foo(void) { return 42; }" }
|
||||
sh "#{cc} -c #{src_path} -o #{obj_path} -arch arm64 -miphoneos-version-min=7.0"
|
||||
obj_path
|
||||
end
|
||||
ld_path = File.join(App.config.xcode_dir, 'Toolchains/XcodeDefault.xctoolchain/usr/bin/ld')
|
||||
sh "#{ld_path} \"#{asm}\" \"#{@dummy_object_file}\" -arch arm64 -r -o \"#{arch_obj}\""
|
||||
else
|
||||
sh "#{cc} -fexceptions -c -arch #{arch} \"#{asm}\" -o \"#{arch_obj}\""
|
||||
end
|
||||
arch_obj_flags = arm64 ? "-miphoneos-version-min=#{config.deployment_target}" : ''
|
||||
sh "#{cc} -fexceptions -c -arch #{arch} #{arch_obj_flags} \"#{asm}\" -o \"#{arch_obj}\""
|
||||
|
||||
[asm].each { |x| File.unlink(x) } unless ENV['keep_temps']
|
||||
arch_objs << arch_obj
|
||||
|
||||
Reference in New Issue
Block a user