From ec20361165dc6e84d1a26fd7d938d3fc4bab669b Mon Sep 17 00:00:00 2001 From: buty4649 Date: Sat, 27 Jan 2024 01:52:11 +0900 Subject: [PATCH] Always use optimization flags --- build_config.rb | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/build_config.rb b/build_config.rb index f67b6fc..fcd4aa6 100644 --- a/build_config.rb +++ b/build_config.rb @@ -12,14 +12,15 @@ def debug_config(conf) conf.enable_debug end -def build_config(conf, target = nil, optimize: false) +def build_config(conf, target = nil, strip: false) + flags = %w[-O3] + flags += ['-target', target] if target + flags += %w[-mtune=native -march=native] if target == 'x86_64-linux-musl' + flags << '-s' if strip + [conf.cc, conf.linker].each do |cc| cc.command = 'zig cc' - cc.flags += ['-target', target] if target - if optimize - cc.flags += %w[-s -O3] - cc.flags += %w[-mtune=native -march=native] if target == 'x86_64-linux-musl' - end + cc.flags += flags end conf.archiver.command = 'zig ar' @@ -28,7 +29,7 @@ def build_config(conf, target = nil, optimize: false) end MRuby::Build.new do |conf| - build_config(conf, optimize: true) + build_config(conf, strip: true) debug_config(conf) gem_config(conf) end @@ -42,7 +43,7 @@ def build_config(conf, target = nil, optimize: false) next unless build_targets.include?(arch) MRuby::CrossBuild.new(arch) do |conf| - build_config(conf, target, optimize: true) + build_config(conf, target, strip: true) debug_config(conf) gem_config(conf) end @@ -52,7 +53,7 @@ def build_config(conf, target = nil, optimize: false) MRuby::CrossBuild.new('darwin-amd64') do |conf| macos_sdk = ENV.fetch('MACOSX_SDK_PATH').shellescape - build_config(conf, 'x86_64-macos', optimize: true) + build_config(conf, 'x86_64-macos', strip: true) conf.cc.flags += ['-Wno-overriding-t-option', '-mmacosx-version-min=10.14', '-isysroot', macos_sdk, '-iwithsysroot', '/usr/include', '-iframeworkwithsysroot', '/System/Library/Frameworks'] @@ -71,7 +72,7 @@ def build_config(conf, target = nil, optimize: false) MRuby::CrossBuild.new('darwin-arm64') do |conf| macos_sdk = ENV.fetch('MACOSX_SDK_PATH').shellescape - build_config(conf, 'aarch64-macos', optimize: true) + build_config(conf, 'aarch64-macos', strip: true) conf.cc.flags += ['-Wno-overriding-t-option', '-mmacosx-version-min=11.1', '-isysroot', macos_sdk, '-iwithsysroot', '/usr/include', '-iframeworkwithsysroot', '/System/Library/Frameworks'] @@ -96,7 +97,7 @@ def build_config(conf, target = nil, optimize: false) [conf.cc, conf.linker].each do |cc| cc.command = "#{conf.host_target}-gcc-posix" - cc.flags += %w[-static -O3] + cc.flags += %w[-static -O3 -s] end conf.cc.defines += %w[MRB_STR_LENGTH_MAX=0 MRB_UTF8_STRING MRUBY_YAML_NO_CANONICAL_NULL MRB_IREP_LVAR_MERGE_LIMIT=240]