Skip to content

Commit

Permalink
(PA-4867) Build ruby on Solaris 11 SPARC
Browse files Browse the repository at this point in the history
I couldn't find a way to to make solaris-11-sparc platform definition take into
account the project, because of the way vanagon creates the Platform and then
later the Project. So create a new solaris-113-sparc platform definition for
native Solaris compiles.

Since the name of the file contains 113, vanagon assumes that's the
`os_version`. Setting the os_version from within the platform definition doesn't
seem to work, so I had to specialy case some logic to check for the
platform.name

Ruby and all of its dependencies successfully build, but there are still some
issues to be worked out.
  • Loading branch information
joshcooper committed Jul 20, 2023
1 parent 6f987a9 commit 8980a87
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 21 deletions.
13 changes: 9 additions & 4 deletions configs/components/_base-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,15 @@
elsif platform.is_solaris?
# See PA-5639, if we decide to go without OpenCSW GCC then we can simplify this logic
if ruby_version_y >= '3.0'
pkg.environment 'PATH', "#{settings[:bindir]}:/opt/csw/bin:/usr/ccs/bin:/usr/sfw/bin:$(PATH)"
pkg.environment 'CC', '/opt/csw/bin/gcc'
pkg.environment 'LD', '/opt/csw/bin/gld'
pkg.environment 'AR', '/opt/csw/bin/gar'
if platform.name == 'solaris-113-sparc'
pkg.environment 'PATH', "#{settings[:bindir]}:/opt/pl-build-tools/bin:/opt/csw/bin:/usr/ccs/bin:/usr/sfw/bin:$(PATH)"
pkg.environment 'CC', "/opt/pl-build-tools/bin/#{settings[:platform_triple]}-gcc"
else
pkg.environment 'PATH', "#{settings[:bindir]}:/opt/csw/bin:/usr/ccs/bin:/usr/sfw/bin:$(PATH)"
pkg.environment 'CC', '/opt/csw/bin/gcc'
pkg.environment 'LD', '/opt/csw/bin/gld'
pkg.environment 'AR', '/opt/csw/bin/gar'
end
else
pkg.environment 'PATH', "#{settings[:bindir]}:/usr/ccs/bin:/usr/sfw/bin:$(PATH):/opt/csw/bin"
pkg.environment 'CC', "/opt/pl-build-tools/bin/#{settings[:platform_triple]}-gcc"
Expand Down
3 changes: 3 additions & 0 deletions configs/components/augeas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@
if platform.os_version == "10"
pkg.environment "PKG_CONFIG_PATH", "/opt/csw/lib/pkgconfig"
pkg.environment "PKG_CONFIG", "/opt/csw/bin/pkg-config"
elsif platform.name == 'solaris-113-sparc'
pkg.environment "PKG_CONFIG_PATH", "#{settings[:libdir]}/pkgconfig"
pkg.environment "PKG_CONFIG", "/usr/bin/pkg-config"
else
pkg.environment "PKG_CONFIG_PATH", "/usr/lib/pkgconfig"
pkg.environment "PKG_CONFIG", "/opt/pl-build-tools/bin/pkg-config"
Expand Down
2 changes: 1 addition & 1 deletion configs/components/curl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
extra_cflags << '-mmacosx-version-min=12.0 -arch arm64' if platform.name =~ /osx-12/
end

if (platform.is_solaris? && platform.os_version == "11") || platform.is_aix?
if (platform.is_solaris? && platform.os_version.start_with?("11")) || platform.is_aix?
# Makefile generation with automatic dependency tracking fails on these platforms
configure_options << "--disable-dependency-tracking"
end
Expand Down
8 changes: 7 additions & 1 deletion configs/components/libffi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@
pkg.environment "LDFLAGS", settings[:ldflags]
elsif platform.is_solaris?
pkg.environment "PATH", "/opt/pl-build-tools/bin:$(PATH):/usr/local/bin:/usr/ccs/bin:/usr/sfw/bin:#{settings[:bindir]}"
pkg.environment "CFLAGS", "#{settings[:cflags]} -std=c99"
if platform.name == 'solaris-113-sparc'
# must use gnu99 due to `asm` keyword
# https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/Extended-Asm.html
pkg.environment "CFLAGS", "#{settings[:cflags]} -std=gnu99"
else
pkg.environment "CFLAGS", "#{settings[:cflags]} -std=c99"
end
pkg.environment "LDFLAGS", settings[:ldflags]
pkg.environment 'MAKE', 'gmake'
elsif platform.is_macos?
Expand Down
11 changes: 8 additions & 3 deletions configs/components/openssl-3.0.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,15 @@
target = 'aix-gcc'
elsif platform.is_solaris?
pkg.environment 'PATH', '/opt/csw/bin:$(PATH):/usr/local/bin:/usr/ccs/bin:/usr/sfw/bin'
pkg.environment 'CC', "/opt/csw/bin/gcc"

if platform.name == 'solaris-113-sparc'
pkg.environment 'CC', "/opt/pl-build-tools/bin/gcc"
gcc_lib = "/opt/pl-build-tools/#{settings[:platform_triple]}/lib"
else
pkg.environment 'CC', "/opt/csw/bin/gcc"
gcc_lib = "/opt/csw/#{settings[:platform_triple]}/lib"
end
cflags = "#{settings[:cflags]} -fPIC"
ldflags = "-R/opt/csw/#{settings[:platform_triple]}/lib -Wl,-rpath=#{settings[:libdir]} -L/opt/csw/#{settings[:platform_triple]}/lib"
ldflags = "-R#{gcc_lib} -Wl,-rpath=#{settings[:libdir]} -L#{gcc_lib}"
target = platform.architecture =~ /86/ ? 'solaris-x86-gcc' : 'solaris-sparcv9-gcc'
elsif platform.is_macos?

Expand Down
18 changes: 16 additions & 2 deletions configs/components/ruby-3.2.2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,14 @@
# https://github.com/ruby/ruby/blob/c9c2245c0a25176072e02db9254f0e0c84c805cd/configure.ac#L2329-L2330
special_flags += " --with-baseruby=#{host_ruby} --with-coroutine=arm64 "
elsif platform.is_solaris? && platform.architecture == "sparc"
special_flags += " --with-baseruby=#{host_ruby} --enable-close-fds-by-recvmsg-with-peek "
if platform.is_cross_compiled?
special_flags += " --with-baseruby=#{host_ruby} "
else
# configure seems to enable dtrace because the executable is present,
# explicitly disable it and don't enable it below
special_flags += " --with-baseruby=no --enable-dtrace=no "
end
special_flags += " --enable-close-fds-by-recvmsg-with-peek "
elsif platform.name =~ /el-6/
special_flags += " --with-baseruby=no "
elsif platform.is_windows?
Expand All @@ -137,6 +144,7 @@
'redhatfips-7-x86_64',
'sles-12-ppc64le',
'solaris-11-sparc',
'solaris-113-sparc',
'windows-2012r2-x64',
'windows-2012r2-x86',
'windows-2019-x64',
Expand Down Expand Up @@ -218,10 +226,16 @@
rbconfig_topdir = "$$(#{ruby_bindir}/ruby -e \"puts RbConfig::CONFIG[\\\"topdir\\\"]\")"
end

# When cross compiling or building on non-linux, we sometimes need to patch
# the rbconfig.rb in the "host" ruby so that later when we try to build gems
# with native extensions, like ffi, the "host" ruby's mkmf will use the CC,
# etc specified below. For example, if we're building on mac Intel for ARM,
# then the CC override allows us to build ffi_c.so for ARM as well. The
# "host" ruby is configured in _shared-agent-settings
rbconfig_changes = {}
if platform.is_aix?
rbconfig_changes["CC"] = "gcc"
elsif platform.is_cross_compiled? || platform.is_solaris?
elsif platform.is_cross_compiled? || (platform.is_solaris? && platform.name != 'solaris-113-sparc') # why are we overriding rbconfig for solaris 10/11 native compiles?
if platform.name =~ /osx-11/
rbconfig_changes["CC"] = 'clang -target arm64-apple-macos11'
elsif platform.name =~ /osx-12/
Expand Down
2 changes: 1 addition & 1 deletion configs/components/rubygem-ffi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
end

# due to contrib/make_sunver.pl missing on solaris 11 we cannot compile libffi, so we provide the opencsw library
pkg.environment "CPATH", "/opt/csw/lib/libffi-3.2.1/include" if platform.name =~ /solaris-11/
pkg.environment "CPATH", "/opt/csw/lib/libffi-3.2.1/include" if platform.name =~ /solaris-11-/
pkg.environment "MAKE", platform[:make] if platform.is_solaris?

if platform.is_cross_compiled_linux?
Expand Down
60 changes: 60 additions & 0 deletions configs/platforms/solaris-113-sparc.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This platform definition is used to build natively on SPARC, unlike
# solaris-10/11-sparc, which are cross compiled. Therefore, this definition does
# not inherit from vanagon defaults.
platform "solaris-11-sparc" do |plat|
plat.servicedir "/lib/svc/manifest"
plat.defaultdir "/lib/svc/method"
plat.servicetype "smf"

plat.vmpooler_template "solaris-11-sparc"
plat.add_build_repository "http://solaris-11-reposync.delivery.puppetlabs.net:81", "puppetlabs.com"
plat.install_build_dependencies_with "pkg install ", " || [[ $? -eq 4 ]]"

packages = [
"pl-gcc10",
"pl-libffi",
"pl-openssl",
"pl-yaml-cpp-sparc",

"autoconf",
"automake",
"cmake",
"gnu-make",
"libtool",
"pkg-config"
]
plat.provision_with("pkg install #{packages.join(' ')}")

plat.provision_with %[echo "# Write the noask file to a temporary directory
# please see man -s 4 admin for details about this file:
# http://www.opensolarisforum.org/man/man4/admin.html
#
# The key thing we don\'t want to prompt for are conflicting files.
# The other nocheck settings are mostly defensive to prevent prompts
# We _do_ want to check for available free space and abort if there is
# not enough
mail=
# Overwrite already installed instances
instance=overwrite
# Do not bother checking for partially installed packages
partial=nocheck
# Do not bother checking the runlevel
runlevel=nocheck
# Do not bother checking package dependencies (We take care of this)
idepend=nocheck
rdepend=nocheck
# DO check for available free space and abort if there isn\'t enough
space=quit
# Do not check for setuid files.
setuid=nocheck
# Do not check if files conflict with other packages
conflict=nocheck
# We have no action scripts. Do not check for them.
action=nocheck
# Install to the default base directory.
basedir=default" > /var/tmp/vanagon-noask;
echo "mirror=https://artifactory.delivery.puppetlabs.net/artifactory/generic__remote_opencsw_mirror/testing" > /var/tmp/vanagon-pkgutil.conf;
pkgadd -n -a /var/tmp/vanagon-noask -d http://get.opencsw.org/now all
/opt/csw/bin/pkgutil -U && /opt/csw/bin/pkgutil -y -i bison || exit 1
]
end
4 changes: 2 additions & 2 deletions configs/projects/_shared-agent-components.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
proj.component 'libxml2' unless platform.is_windows?
proj.component 'libxslt' unless platform.is_windows?

proj.component 'ruby-augeas' unless platform.is_windows?
proj.component 'ruby-shadow' unless platform.is_aix? || platform.is_windows?
proj.component 'ruby-augeas' unless platform.is_windows? || platform.name == 'solaris-113-sparc'
proj.component 'ruby-shadow' unless platform.is_aix? || platform.is_windows? || platform.name == 'solaris-113-sparc'
# We only build ruby-selinux for EL, Fedora, Debian and Ubuntu (amd64/i386)
if platform.is_el? || platform.is_fedora? || platform.name =~ /debian|ubuntu/
if platform.name !~ /ubuntu-.*-ppc64el/
Expand Down
20 changes: 15 additions & 5 deletions configs/projects/_shared-agent-settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,15 @@
platform_triple = "arm-linux-gnueabihf" if platform.architecture == "armhf"
platform_triple = "aarch64-apple-darwin" if platform.is_cross_compiled? && platform.is_macos?

# Ruby's build process needs a functional "baseruby". When native compiling,
# ruby will build "miniruby" and use that as "baseruby". When cross compiling,
# we need a "host" ruby from somewhere else.
#
# Our build process also needs a "host" ruby to install rubygem-* components.
if platform.is_windows?
proj.setting(:host_ruby, File.join(proj.ruby_bindir, "ruby.exe"))
proj.setting(:host_gem, File.join(proj.ruby_bindir, "gem.bat"))
elsif platform.is_cross_compiled_linux? || (platform.is_solaris? && platform.architecture == 'sparc')
# Install a standalone ruby for cross-compiled platforms
elsif platform.is_cross_compiled? && (platform.is_linux? || platform.is_solaris?)
if platform.name =~ /solaris-10-sparc/
proj.setting(:host_ruby, "/opt/csw/bin/ruby")
proj.setting(:host_gem, "/opt/csw/bin/gem2.0")
Expand All @@ -112,12 +116,18 @@

if platform.is_cross_compiled_linux?
host = "--host #{platform_triple}"
elsif platform.is_cross_compiled? && platform.is_macos?
host = "--host aarch64-apple-darwin --build x86_64-apple-darwin --target aarch64-apple-darwin"
elsif platform.is_macos?
if platform.is_cross_compiled?
host = "--host aarch64-apple-darwin --build x86_64-apple-darwin --target aarch64-apple-darwin"
else
host = "--host aarch64-apple-darwin"
end
elsif platform.is_solaris?
# For solaris, we build cross-compilers
if platform.architecture == 'i386'
platform_triple = "#{platform.architecture}-pc-solaris2.#{platform.os_version}"
elsif platform.name == 'solaris-113-sparc'
platform_triple = "#{platform.architecture}-sun-solaris2.11"
host = "--host #{platform_triple}"
else
platform_triple = "#{platform.architecture}-sun-solaris2.#{platform.os_version}"
host = "--host #{platform_triple}"
Expand Down
4 changes: 2 additions & 2 deletions configs/projects/agent-runtime-main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@
proj.component 'rubygem-erubi'
proj.component 'rubygem-prime'

proj.component 'boost' if ENV['NO_PXP_AGENT'].to_s.empty?
proj.component 'yaml-cpp' if ENV['NO_PXP_AGENT'].to_s.empty?
proj.component 'boost' if ENV['NO_PXP_AGENT'].to_s.empty? && platform.name != 'solaris-113-sparc'
proj.component 'yaml-cpp' if ENV['NO_PXP_AGENT'].to_s.empty? && platform.name != 'solaris-113-sparc'
end

0 comments on commit 8980a87

Please sign in to comment.