From d8a59d5a7d8ef2762689b771c59a04c1c096657c Mon Sep 17 00:00:00 2001 From: Shubham Shinde Date: Thu, 22 Jun 2023 15:25:19 +0530 Subject: [PATCH] (PA-4774) Enable macOS 13 for agent-runtime main --- configs/components/_base-ruby-augeas.rb | 5 +++-- configs/components/_base-ruby.rb | 3 ++- configs/components/augeas.rb | 14 +++++++++++--- configs/components/boost.rb | 2 ++ configs/components/curl.rb | 3 ++- configs/components/openssl-1.1.1.rb | 4 +++- configs/components/openssl-3.0.rb | 9 +++++++-- configs/components/ruby-3.2.2.rb | 6 +++++- configs/components/yaml-cpp.rb | 7 ++++++- configs/platforms/osx-13-arm64.rb | 9 +++++++++ configs/projects/_shared-agent-settings.rb | 2 +- 11 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 configs/platforms/osx-13-arm64.rb diff --git a/configs/components/_base-ruby-augeas.rb b/configs/components/_base-ruby-augeas.rb index 7f17a2291..4ee0ccb58 100644 --- a/configs/components/_base-ruby-augeas.rb +++ b/configs/components/_base-ruby-augeas.rb @@ -19,7 +19,7 @@ pkg.build_requires "ruby-#{ruby_version}" pkg.build_requires "augeas" -pkg.environment "PATH", "$(PATH):/opt/pl-build-tools/bin:/usr/local/bin:/opt/csw/bin:/usr/ccs/bin:/usr/sfw/bin" +pkg.environment "PATH", "$(PATH):/opt/homebrew/bin:/opt/pl-build-tools/bin:/usr/local/bin:/opt/csw/bin:/usr/ccs/bin:/usr/sfw/bin" if platform.is_aix? if platform.name == 'aix-7.1-ppc' pkg.environment "CC", "/opt/pl-build-tools/bin/gcc" @@ -40,11 +40,12 @@ pkg.environment "RUBY", host_ruby end ruby = "#{host_ruby} -r#{settings[:datadir]}/doc/rbconfig-#{ruby_version}-orig.rb" -elsif platform.is_cross_compiled? +elsif platform.architecture == 'arm64' if platform.is_linux? || platform.is_macos? pkg.environment "RUBY", host_ruby pkg.environment 'CC', 'clang -target arm64-apple-macos11' if platform.name =~ /osx-11/ pkg.environment 'CC', 'clang -target arm64-apple-macos12' if platform.name =~ /osx-12/ + pkg.environment 'CC', 'clang -target arm64-apple-macos13' if platform.name =~ /osx-13/ ruby = "#{host_ruby} -r#{settings[:datadir]}/doc/rbconfig-#{ruby_version}-orig.rb" pkg.environment "LDFLAGS", settings[:ldflags] end diff --git a/configs/components/_base-ruby.rb b/configs/components/_base-ruby.rb index d3b6e67bb..9bf06b1cd 100644 --- a/configs/components/_base-ruby.rb +++ b/configs/components/_base-ruby.rb @@ -50,7 +50,7 @@ pkg.environment 'optflags', settings[:cflags] + ' -O3' elsif platform.is_macos? pkg.environment 'optflags', settings[:cflags] - if platform.is_cross_compiled? + if platform.architecture == 'arm64' # Pin to an older version of ruby@2.5. This can be removed once we're no longer cross-compiling if ruby_version_y == "2.5" pkg.build_requires "puppetlabs/puppet/ruby@2.5" @@ -59,6 +59,7 @@ end pkg.environment 'CC', 'clang -target arm64-apple-macos11' if platform.name =~ /osx-11/ pkg.environment 'CC', 'clang -target arm64-apple-macos12' if platform.name =~ /osx-12/ + pkg.environment 'CC', 'clang -target arm64-apple-macos13' if platform.name =~ /osx-13/ end end diff --git a/configs/components/augeas.rb b/configs/components/augeas.rb index 84556ca22..4afabd2b2 100644 --- a/configs/components/augeas.rb +++ b/configs/components/augeas.rb @@ -103,13 +103,14 @@ pkg.environment "PKG_CONFIG", "/opt/pl-build-tools/bin/pkg-config" end elsif platform.is_macos? - pkg.environment "PATH", "$(PATH):/usr/local/bin" + pkg.environment "PATH", "$(PATH):/usr/local/bin:/opt/homebrew/bin" pkg.environment 'CFLAGS', settings[:cflags] pkg.environment 'CPPFLAGS', settings[:cppflags] pkg.environment "LDFLAGS", settings[:ldflags] - if platform.is_cross_compiled? + if platform.architecture == 'arm64' pkg.environment 'CC', 'clang -target arm64-apple-macos11' if platform.name =~ /osx-11/ pkg.environment 'CC', 'clang -target arm64-apple-macos12' if platform.name =~ /osx-12/ + pkg.environment 'CC', 'clang -target arm64-apple-macos13' if platform.name =~ /osx-13/ end end @@ -120,7 +121,14 @@ end # fix libtool linking on big sur - pkg.configure { ["/usr/local/bin/autoreconf --force --install"] } if platform.is_macos? + if platform.is_macos? + if(platform.os_version.to_i >= 13 && platform.architecture == 'arm64') + pkg.configure { ["/opt/homebrew/bin/autoreconf --force --install"] } + else + pkg.configure { ["/usr/local/bin/autoreconf --force --install"] } + end + end + pkg.configure do ["./configure #{extra_config_flags} --prefix=#{settings[:prefix]} #{settings[:host]}"] diff --git a/configs/components/boost.rb b/configs/components/boost.rb index dfc93ccaf..5bfe1ad5b 100644 --- a/configs/components/boost.rb +++ b/configs/components/boost.rb @@ -67,6 +67,8 @@ 'clang++ -target arm64-apple-macos11' elsif platform.is_cross_compiled? && platform.name =~ /osx-12/ 'clang++ -target arm64-apple-macos12' + elsif platform.name =~ /osx-13/ + 'clang++ -target arm64-apple-macos13' else 'clang++' end diff --git a/configs/components/curl.rb b/configs/components/curl.rb index 2faf0cdb5..e8e6145d7 100644 --- a/configs/components/curl.rb +++ b/configs/components/curl.rb @@ -31,9 +31,10 @@ configure_options << "--with-ssl=#{settings[:prefix]}" extra_cflags = [] - if platform.is_cross_compiled? && platform.is_macos? + if platform.architecture == 'arm64' && platform.is_macos? extra_cflags << '-mmacosx-version-min=11.0 -arch arm64' if platform.name =~ /osx-11/ extra_cflags << '-mmacosx-version-min=12.0 -arch arm64' if platform.name =~ /osx-12/ + extra_cflags << '-mmacosx-version-min=12.0 -arch arm64' if platform.name =~ /osx-13/ end if (platform.is_solaris? && platform.os_version == "11") || platform.is_aix? diff --git a/configs/components/openssl-1.1.1.rb b/configs/components/openssl-1.1.1.rb index 77ac5da01..566858117 100644 --- a/configs/components/openssl-1.1.1.rb +++ b/configs/components/openssl-1.1.1.rb @@ -57,7 +57,9 @@ pkg.environment 'PATH', '/opt/pl-build-tools/bin:$(PATH):/usr/local/bin' cflags = settings[:cflags] - target = if platform.is_cross_compiled? + puts "HEY, #{platform.is_cross_compiled?}" + puts "platform.name = #{platform.name} $##############################" + target = if platform.is_cross_compiled? or 'darwin64-arm64-cc' else 'darwin64-x86_64-cc' diff --git a/configs/components/openssl-3.0.rb b/configs/components/openssl-3.0.rb index 3240a0c44..f041d4d72 100644 --- a/configs/components/openssl-3.0.rb +++ b/configs/components/openssl-3.0.rb @@ -64,9 +64,14 @@ # ldflags = "-R/opt/pl-build-tools/#{settings[:platform_triple]}/lib -Wl,-rpath=#{settings[:libdir]} -L/opt/pl-build-tools/#{settings[:platform_triple]}/lib" # target = platform.architecture =~ /86/ ? 'solaris-x86-gcc' : 'solaris-sparcv9-gcc' elsif platform.is_macos? - pkg.environment 'PATH', '/opt/pl-build-tools/bin:$(PATH):/usr/local/bin' - target = if platform.is_cross_compiled? + if platform.os_version.to_i >= 13 && platform.architecture == 'arm64' + pkg.environment 'PATH', '$(PATH):/opt/homebrew/bin:/usr/local/bin' + else + pkg.environment 'PATH', '/opt/pl-build-tools/bin:$(PATH):/usr/local/bin' + end + + target = if platform.architecture == "arm64" 'darwin64-arm64' else 'darwin64-x86_64' diff --git a/configs/components/ruby-3.2.2.rb b/configs/components/ruby-3.2.2.rb index 88023608a..4b8e7fdce 100644 --- a/configs/components/ruby-3.2.2.rb +++ b/configs/components/ruby-3.2.2.rb @@ -70,7 +70,8 @@ if platform.is_macos? pkg.environment 'optflags', settings[:cflags] - pkg.environment 'PATH', '$(PATH):/usr/local/bin' + pkg.environment 'PATH', '/opt/homebrew/bin:$(PATH):/usr/local/bin' + elsif platform.is_windows? pkg.environment 'optflags', settings[:cflags] + ' -O3' pkg.environment 'MAKE', 'make' @@ -215,6 +216,9 @@ end rbconfig_changes = {} + if platform.is_macos? && platform.os_version.to_i >= 13 + rbconfig_changes["CC"] = 'clang -target arm64-apple-macos13' if platform.name =~ /osx-13/ + end if platform.is_aix? rbconfig_changes["CC"] = "gcc" elsif platform.is_cross_compiled? || platform.is_solaris? diff --git a/configs/components/yaml-cpp.rb b/configs/components/yaml-cpp.rb index 62ad3367f..18e695cd4 100644 --- a/configs/components/yaml-cpp.rb +++ b/configs/components/yaml-cpp.rb @@ -23,9 +23,14 @@ elsif platform.is_macos? cmake_toolchain_file = "" cmake = "/usr/local/bin/cmake" - if platform.is_cross_compiled? + pkg.environment "PATH", "$(PATH):/opt/csw/bin" + if platform.architecture == 'arm64' pkg.environment 'CXX', 'clang++ -target arm64-apple-macos11' if platform.name =~ /osx-11/ pkg.environment 'CXX', 'clang++ -target arm64-apple-macos12' if platform.name =~ /osx-12/ + pkg.environment 'CXX', 'clang++ -target arm64-apple-macos13' if platform.name =~ /osx-13/ + if(platform.architecture == "arm64" and platform.os_version.to_i >= 13) + cmake = "/opt/homebrew/bin/cmake" + end end elsif platform.is_windows? make = "#{settings[:gcc_bindir]}/mingw32-make" diff --git a/configs/platforms/osx-13-arm64.rb b/configs/platforms/osx-13-arm64.rb new file mode 100644 index 000000000..b55864edf --- /dev/null +++ b/configs/platforms/osx-13-arm64.rb @@ -0,0 +1,9 @@ +platform 'osx-13-arm64' do |plat| + plat.inherit_from_default + + packages = %w[automake cmake pkg-config yaml-cpp] + plat.provision_with "su test -c '/opt/homebrew/bin/brew install #{packages.join(' ')}'" + + plat.output_dir File.join('apple', '13', 'PC1', 'arm64') + end + \ No newline at end of file diff --git a/configs/projects/_shared-agent-settings.rb b/configs/projects/_shared-agent-settings.rb index eec0e18d7..76b289101 100644 --- a/configs/projects/_shared-agent-settings.rb +++ b/configs/projects/_shared-agent-settings.rb @@ -200,7 +200,7 @@ # break gcc or clang if they try to use the RPATH values we forced. proj.setting(:cppflags, "-I#{proj.includedir}") proj.setting(:ldflags, "-L#{proj.libdir}") - if platform.is_cross_compiled? + if platform.architecture == 'arm64' proj.setting(:cflags, "#{proj.cppflags}") else proj.setting(:cflags, "-march=core2 -msse4 #{proj.cppflags}")