Skip to content

Commit e636212

Browse files
committed
Changes to enable building all MacOS types on any MacOS host
This makes several changes that enable us to build for all supported MacOS versions on any kind of MacOS host running the latest version. It sets some flags to tell clang to generate binaries compatible with everything since MacOS 13. This also adds an osx-15-x86_64 platform, and tweaks the build task to make sure you are running in a shell for the architecture you are trying to build for. By using the 'arch' command to open a shell for x86_64 before invoking the build rake task, we use Rosetta 2 to allow us to build for x86_64 on an arm64 host just like we would if we were building on an x86_64 host. This allows us to avoid any of the many workarounds needed for cross compiling. While this method is rather slow, it easier and potentially safer than all of the workarounds needed for cross-compilation. This also uses a platform string of macos-all-<arch> since we are now able to build for all supported MacOS versions in one binary. This also modifies the build action to allow overriding the vanagon branch and to be able to use a "dev" branch of shared-actions for testing. Unfortunately, the 'uses' parameter has to be a static string, which is why we are limited to a specific branch named 'dev'.
1 parent f5281d8 commit e636212

25 files changed

+124
-126
lines changed

.github/workflows/build.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
---
22
name: Build puppet-runtime
33

4+
permissions:
5+
contents: read
6+
47
on:
58
workflow_dispatch:
69
inputs:
@@ -15,15 +18,36 @@ on:
1518
description: 'A comma-separated list of platforms to build for. Do not include spaces. If not provided, will use the default list of platform supported by OpenVox.'
1619
required: false
1720
type: string
21+
vanagon_branch:
22+
description: 'The branch of the vanagon repository to use'
23+
required: false
24+
type: string
25+
default: 'main'
26+
use_dev:
27+
description: 'Use the "dev" branch of the shared-actions repo'
28+
required: false
29+
type: boolean
30+
default: false
1831

1932
permissions:
2033
contents: read # minimal required permissions to clone repo
2134

2235
jobs:
2336
build:
37+
if: ${{ github.event.inputs.use_dev == 'false' }}
2438
uses: 'openvoxproject/shared-actions/.github/workflows/build_vanagon.yml@main'
2539
with:
2640
ref: ${{ inputs.ref }}
2741
project_name: ${{ inputs.project_name }}
2842
platform_list: ${{ inputs.platform_list }}
43+
vanagon_branch: ${{ inputs.vanagon_branch }}
44+
secrets: inherit
45+
build_dev:
46+
if: ${{ github.event.inputs.use_dev == 'true' }}
47+
uses: 'openvoxproject/shared-actions/.github/workflows/build_vanagon.yml@dev'
48+
with:
49+
ref: ${{ inputs.ref }}
50+
project_name: ${{ inputs.project_name }}
51+
platform_list: ${{ inputs.platform_list }}
52+
vanagon_branch: ${{ inputs.vanagon_branch }}
2953
secrets: inherit

configs/components/_base-ruby-augeas.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,14 @@
6868
ruby = "#{host_ruby} -r#{settings[:datadir]}/doc/rbconfig-#{ruby_version}-orig.rb"
6969
pkg.environment "LDFLAGS", settings[:ldflags]
7070
end
71-
elsif platform.is_macos? && platform.architecture == 'arm64' && platform.os_version.to_i >= 13
72-
pkg.environment "PATH", "$(PATH):/opt/homebrew/bin"
73-
pkg.environment 'CC', 'clang'
71+
elsif platform.is_macos?
72+
if platform.architecture == 'arm64'
73+
pkg.environment "PATH", "$(PATH):/opt/homebrew/bin"
74+
end
75+
pkg.environment 'CC', settings[:cc]
76+
pkg.environment 'CFLAGS', settings[:cflags]
7477
pkg.environment "LDFLAGS", settings[:ldflags]
78+
pkg.environment 'MACOSX_DEPLOYMENT_TARGET', settings[:deployment_target]
7579
ruby = File.join(ruby_bindir, 'ruby')
7680
else
7781
ruby = File.join(ruby_bindir, 'ruby')

configs/components/_base-ruby.rb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,9 @@
6565
pkg.environment 'CFLAGS', optflags
6666
elsif platform.is_macos?
6767
pkg.environment 'optflags', settings[:cflags]
68-
if platform.is_cross_compiled?
69-
pkg.build_requires "ruby@#{ruby_version_y}"
70-
pkg.environment 'CC', 'clang -target arm64-apple-macos11' if platform.name =~ /osx-11/
71-
pkg.environment 'CC', 'clang -target arm64-apple-macos12' if platform.name =~ /osx-12/
72-
elsif platform.architecture == 'arm64' && platform.os_version.to_i >= 13
73-
pkg.environment 'CC', 'clang'
74-
end
68+
pkg.environment 'CFLAGS', settings[:cflags]
69+
pkg.environment 'CC', settings[:cc]
70+
pkg.environment 'MACOSX_DEPLOYMENT_TARGET', settings[:deployment_target]
7571
elsif settings[:supports_pie]
7672
pkg.environment 'LDFLAGS', settings[:ldflags]
7773
pkg.environment 'optflags', settings[:cflags]

configs/components/augeas.rb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,9 @@
116116
pkg.environment 'CFLAGS', settings[:cflags]
117117
pkg.environment 'CPPFLAGS', settings[:cppflags]
118118
pkg.environment "LDFLAGS", settings[:ldflags]
119-
if platform.is_cross_compiled?
120-
pkg.environment 'CC', 'clang -target arm64-apple-macos11' if platform.name =~ /osx-11/
121-
pkg.environment 'CC', 'clang -target arm64-apple-macos12' if platform.name =~ /osx-12/
122-
elsif platform.architecture == 'arm64' && platform.os_version.to_i >= 13
123-
pkg.environment 'CC', 'clang'
124-
end
119+
pkg.environment 'CC', settings[:cc]
120+
pkg.environment 'CXX', settings[:cxx]
121+
pkg.environment 'MACOSX_DEPLOYMENT_TARGET', settings[:deployment_target]
125122
end
126123

127124
if settings[:supports_pie]
@@ -132,7 +129,7 @@
132129

133130
# fix libtool linking on big sur
134131
if platform.is_macos?
135-
if platform.os_version.to_i >= 13 && platform.architecture == 'arm64'
132+
if platform.architecture == 'arm64'
136133
pkg.configure { ["/opt/homebrew/bin/autoreconf --force --install"] }
137134
else
138135
pkg.configure { ["/usr/local/bin/autoreconf --force --install"] }

configs/components/curl.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,19 @@
6767
configure_options << "--disable-ntlm"
6868
end
6969

70-
extra_cflags = []
71-
if platform.is_cross_compiled? && platform.is_macos?
72-
extra_cflags << '-mmacosx-version-min=11.0 -arch arm64' if platform.name =~ /osx-11/
73-
extra_cflags << '-mmacosx-version-min=12.0 -arch arm64' if platform.name =~ /osx-12/
74-
end
75-
7670
if (platform.is_solaris? && platform.os_version == '11') || platform.is_aix?
7771
# Makefile generation with automatic dependency tracking fails on these platforms
7872
configure_options << "--disable-dependency-tracking"
7973
end
8074

75+
if platform.is_macos?
76+
pkg.environment 'MACOSX_DEPLOYMENT_TARGET', settings[:deployment_target]
77+
pkg.environment 'CFLAGS', settings[:cflags]
78+
pkg.environment 'CC', settings[:cc]
79+
pkg.environment 'CPPFLAGS', settings[:cppflags]
80+
pkg.environment 'CXX', settings[:cxx]
81+
end
82+
8183
pkg.configure do
8284
["CPPFLAGS='#{settings[:cppflags]}' \
8385
LDFLAGS='#{ldflags}' \
@@ -89,7 +91,7 @@
8991
--with-ca-bundle=#{settings[:prefix]}/ssl/cert.pem \
9092
--with-ca-path=#{settings[:prefix]}/ssl/certs \
9193
--without-nghttp2 \
92-
CFLAGS='#{settings[:cflags]} #{extra_cflags.join(" ")}' \
94+
CFLAGS='#{settings[:cflags]}' \
9395
#{settings[:host]}"]
9496
end
9597

configs/components/libffi.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@
3131
elsif platform.is_macos?
3232
pkg.environment "LDFLAGS", settings[:ldflags]
3333
pkg.environment "CFLAGS", settings[:cflags]
34-
if platform.is_cross_compiled?
35-
pkg.environment 'CC', 'clang -target arm64-apple-macos11' if platform.name =~ /osx-11/
36-
pkg.environment 'CC', 'clang -target arm64-apple-macos12' if platform.name =~ /osx-12/
37-
end
34+
pkg.environment 'CC', settings[:cc]
35+
pkg.environment 'MACOSX_DEPLOYMENT_TARGET', settings[:deployment_target]
3836
elsif platform.is_windows?
3937
pkg.environment "PATH", "$(shell cygpath -u #{settings[:gcc_bindir]}):$(PATH)"
4038
pkg.environment "LDFLAGS", settings[:ldflags]

configs/components/libxml2.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@
2828
elsif platform.is_macos?
2929
pkg.environment "LDFLAGS", settings[:ldflags]
3030
pkg.environment "CFLAGS", settings[:cflags]
31-
if platform.is_cross_compiled?
32-
pkg.environment 'CC', 'clang -target arm64-apple-macos11' if platform.name =~ /osx-11/
33-
pkg.environment 'CC', 'clang -target arm64-apple-macos12' if platform.name =~ /osx-12/
34-
end
31+
pkg.environment 'CC', settings[:cc]
32+
pkg.environment 'MACOSX_DEPLOYMENT_TARGET', settings[:deployment_target]
3533
else
3634
pkg.environment "LDFLAGS", settings[:ldflags]
3735
pkg.environment "CFLAGS", settings[:cflags]

configs/components/libxslt.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,10 @@
3333
pkg.environment "CFLAGS", settings[:cflags]
3434
pkg.environment "LDFLAGS", settings[:ldflags]
3535
elsif platform.is_macos?
36-
if platform.is_cross_compiled?
37-
pkg.environment 'CC', 'clang -target arm64-apple-macos11' if platform.name =~ /osx-11/
38-
pkg.environment 'CC', 'clang -target arm64-apple-macos12' if platform.name =~ /osx-12/
39-
end
4036
pkg.environment "LDFLAGS", settings[:ldflags]
4137
pkg.environment "CFLAGS", settings[:cflags]
38+
pkg.environment 'CC', settings[:cc]
39+
pkg.environment 'MACOSX_DEPLOYMENT_TARGET', settings[:deployment_target]
4240
else
4341
pkg.environment "LDFLAGS", settings[:ldflags]
4442
pkg.environment "CFLAGS", settings[:cflags]

configs/components/libyaml.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@
2424
elsif platform.is_macos?
2525
pkg.environment "LDFLAGS", settings[:ldflags]
2626
pkg.environment "CFLAGS", settings[:cflags]
27-
if platform.is_cross_compiled?
28-
pkg.environment 'CC', 'clang -target arm64-apple-macos11' if platform.name =~ /osx-11/
29-
pkg.environment 'CC', 'clang -target arm64-apple-macos12' if platform.name =~ /osx-12/
30-
end
27+
pkg.environment 'CC', settings[:cc]
28+
pkg.environment 'MACOSX_DEPLOYMENT_TARGET', settings[:deployment_target]
3129
elsif platform.is_windows?
3230
pkg.environment "PATH", "$(shell cygpath -u #{settings[:gcc_bindir]}):$(PATH)"
3331
pkg.environment "LDFLAGS", settings[:ldflags]

configs/components/openssl-1.1.1.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
ldflags = "-R/opt/pl-build-tools/#{settings[:platform_triple]}/lib -Wl,-rpath=#{settings[:libdir]} -L/opt/pl-build-tools/#{settings[:platform_triple]}/lib"
6363
target = platform.architecture =~ /86/ ? 'solaris-x86-gcc' : 'solaris-sparcv9-gcc'
6464
elsif platform.is_macos?
65-
if platform.os_version.to_i >= 13 && platform.architecture == 'arm64'
65+
if platform.architecture == 'arm64'
6666
pkg.environment 'PATH', '/opt/homebrew/bin:$(PATH):/usr/local/bin'
6767
else
6868
pkg.environment 'PATH', '/opt/pl-build-tools/bin:$(PATH):/usr/local/bin'

0 commit comments

Comments
 (0)