From fb126f661ceba90ecacb689d75e5a1482182fad8 Mon Sep 17 00:00:00 2001 From: skyamgarp <130442619+skyamgarp@users.noreply.github.com> Date: Thu, 22 Jun 2023 16:44:06 +0530 Subject: [PATCH] (PA-5594) Enable macOS 13 (ARM) puppet-runtime builds for agent-runtime-7.x --- configs/components/openssl-1.1.1.rb | 17 +++++++++++------ configs/components/ruby-2.7.8.rb | 6 ++++++ configs/components/yaml-cpp.rb | 2 +- configs/platforms/osx-13-arm64.rb | 15 +++++++-------- 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/configs/components/openssl-1.1.1.rb b/configs/components/openssl-1.1.1.rb index 63ed2d5be..745d0b8f8 100644 --- a/configs/components/openssl-1.1.1.rb +++ b/configs/components/openssl-1.1.1.rb @@ -54,14 +54,19 @@ 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' + if platform.os_version.to_i >= 13 && platform.architecture == 'arm64' + pkg.environment 'PATH', '/opt/homebrew/bin:$(PATH):/usr/local/bin' + else + pkg.environment 'PATH', '/opt/pl-build-tools/bin:$(PATH):/usr/local/bin' + end cflags = settings[:cflags] - target = if platform.is_cross_compiled? - 'darwin64-arm64-cc' - else - 'darwin64-x86_64-cc' - end + + target = if platform.architecture == 'arm64' + 'darwin64-arm64-cc' + else + 'darwin64-x86_64-cc' + end elsif platform.is_linux? pkg.environment 'PATH', '/opt/pl-build-tools/bin:$(PATH):/usr/local/bin' diff --git a/configs/components/ruby-2.7.8.rb b/configs/components/ruby-2.7.8.rb index 6b1015efa..f78948704 100644 --- a/configs/components/ruby-2.7.8.rb +++ b/configs/components/ruby-2.7.8.rb @@ -111,6 +111,9 @@ # implementation instead of 'arm64', so specify 'amd64' explicitly # https://github.com/ruby/ruby/blob/c9c2245c0a25176072e02db9254f0e0c84c805cd/configure.ac#L2329-L2330 special_flags += " --with-baseruby=#{host_ruby} --with-coroutine=arm64 " + elsif platform.is_macos? && platform.architecture == 'arm64' && platform.os_version.to_i >= 13 + pkg.environment 'PATH', '/opt/homebrew/bin:$(PATH):/usr/local/bin' + special_flags += " --with-openssl-dir=#{settings[:prefix]} " elsif platform.is_solaris? && platform.architecture == "sparc" special_flags += " --with-baseruby=#{host_ruby} --enable-close-fds-by-recvmsg-with-peek " elsif platform.name =~ /el-6/ @@ -194,6 +197,7 @@ 'x86_64-w64-mingw32' => 'x64-mingw32', 'i686-w64-mingw32' => 'i386-mingw32' } + if target_doubles.key?(settings[:platform_triple]) rbconfig_topdir = File.join(ruby_dir, 'lib', 'ruby', '2.7.0', target_doubles[settings[:platform_triple]]) else @@ -225,6 +229,8 @@ # the ancient gcc version on sles-12-ppc64le does not understand -fstack-protector-strong, so remove the `strong` part rbconfig_changes["LDFLAGS"] = "-L. -Wl,-rpath=/opt/puppetlabs/puppet/lib -fstack-protector -rdynamic -Wl,-export-dynamic -L/opt/puppetlabs/puppet/lib" end + elsif platform.is_macos? && platform.architecture == 'arm64' && platform.os_version.to_i >= 13 + rbconfig_changes["CC"] = 'clang' elsif platform.is_windows? rbconfig_changes["CC"] = "x86_64-w64-mingw32-gcc" end diff --git a/configs/components/yaml-cpp.rb b/configs/components/yaml-cpp.rb index 5d05af6de..2836d8e5c 100644 --- a/configs/components/yaml-cpp.rb +++ b/configs/components/yaml-cpp.rb @@ -28,7 +28,7 @@ pkg.environment 'CXX', 'clang++ -target arm64-apple-macos12' if platform.name =~ /osx-12/ elsif platform.architecture == 'arm64' && platform.os_version.to_i >= 13 pkg.environment 'CXX', 'clang++' - cmake = "/opt/homebrew/bin/cmake" if platform.architecture == "arm64" + cmake = "/opt/homebrew/bin/cmake" end elsif platform.is_windows? diff --git a/configs/platforms/osx-13-arm64.rb b/configs/platforms/osx-13-arm64.rb index b55864edf..c4b7f5a67 100644 --- a/configs/platforms/osx-13-arm64.rb +++ b/configs/platforms/osx-13-arm64.rb @@ -1,9 +1,8 @@ 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 + 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