summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-01-25 16:09:40 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-01-26 16:31:08 +0900
commit6422fef90c30a9662392a918533851f9ca41405e (patch)
treeec83b4685a457acb3d41103c3f3cb476583bac1a /tool
parent9794e49c88b507e1bde102edc5df0add7b3135f3 (diff)
Fix `target_cpu` at runtime
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/7186
Diffstat (limited to 'tool')
-rwxr-xr-xtool/mkconfig.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/tool/mkconfig.rb b/tool/mkconfig.rb
index fb35522401..29a70287d0 100755
--- a/tool/mkconfig.rb
+++ b/tool/mkconfig.rb
@@ -122,11 +122,11 @@ File.foreach "config.status" do |line|
universal, val = val, 'universal' if universal
when /^arch$/
if universal
- platform = val.sub(/universal/, %q[#{arch && universal[/(?:\A|\s)#{Regexp.quote(arch)}=(\S+)/, 1] || RUBY_PLATFORM[/\A[^-]*/]}])
+ platform = val.sub(/universal/, '$(arch)')
end
when /^target_cpu$/
if universal
- val = 'arch'
+ val = 'cpu'
end
when /^target$/
val = '"$(target_cpu)-$(target_vendor)-$(target_os)"'
@@ -193,11 +193,13 @@ print " # Ruby installed directory.\n"
print " TOPDIR = File.dirname(__FILE__).chomp!(#{relative_archdir.dump})\n"
print " # DESTDIR on make install.\n"
print " DESTDIR = ", (drive ? "TOPDIR && TOPDIR[/\\A[a-z]:/i] || " : ""), "'' unless defined? DESTDIR\n"
-print <<'ARCH' if universal
+print <<"UNIVERSAL", <<'ARCH' if universal
+ universal = #{universal}
+UNIVERSAL
arch_flag = ENV['ARCHFLAGS'] || ((e = ENV['RC_ARCHS']) && e.split.uniq.map {|a| "-arch #{a}"}.join(' '))
arch = arch_flag && arch_flag[/\A\s*-arch\s+(\S+)\s*\z/, 1]
+ cpu = arch && universal[/(?:\A|\s)#{Regexp.quote(arch)}=(\S+)/, 1] || RUBY_PLATFORM[/\A[^-]*/]
ARCH
-print " universal = #{universal}\n" if universal
print " # The hash configurations stored.\n"
print " CONFIG = {}\n"
print " CONFIG[\"DESTDIR\"] = DESTDIR\n"