Skip to content

Commit

Permalink
Merge pull request #682 from joshcooper/aix72
Browse files Browse the repository at this point in the history
Build Ruby 3 on AIX 7.2 for Puppet 8
  • Loading branch information
mhashizume committed Jun 20, 2023
2 parents 6ea1d96 + b49b9db commit 1a77733
Show file tree
Hide file tree
Showing 18 changed files with 168 additions and 36 deletions.
9 changes: 7 additions & 2 deletions configs/components/_base-ruby-augeas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@

pkg.environment "PATH", "$(PATH):/opt/pl-build-tools/bin:/usr/local/bin:/opt/csw/bin:/usr/ccs/bin:/usr/sfw/bin"
if platform.is_aix?
# We still use pl-gcc for AIX 7.1
pkg.environment "CC", "/opt/pl-build-tools/bin/gcc"
if platform.name == 'aix-7.1-ppc'
pkg.environment "CC", "/opt/pl-build-tools/bin/gcc"
# pl-build-tools was added to PATH above
else
pkg.environment "CC", "/opt/freeware/bin/gcc"
pkg.environment "PATH", "$(PATH):/opt/freeware/bin"
end
pkg.environment "RUBY", host_ruby
pkg.environment "LDFLAGS", " -brtl #{settings[:ldflags]}"
end
Expand Down
13 changes: 10 additions & 3 deletions configs/components/_base-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
#############

if platform.is_aix?
# We still use pl-gcc for AIX 7.1
pkg.environment "CC", "/opt/pl-build-tools/bin/gcc"
if platform.name == 'aix-7.1-ppc'
pkg.environment "CC", "/opt/pl-build-tools/bin/gcc"
else
pkg.environment "CC", "/opt/freeware/bin/gcc"
end
pkg.environment 'LDFLAGS', "#{settings[:ldflags]} -Wl,-bmaxdata:0x80000000"
elsif platform.is_solaris?
pkg.environment 'PATH', "#{settings[:bindir]}:/usr/ccs/bin:/usr/sfw/bin:$(PATH):/opt/csw/bin"
Expand Down Expand Up @@ -67,7 +70,11 @@

if platform.is_aix?
pkg.build_requires "runtime-#{settings[:runtime_project]}"
pkg.build_requires "libedit"
if platform.name == 'aix-7.1-ppc'
pkg.build_requires "libedit"
else
pkg.build_requires "readline"
end
elsif platform.is_solaris?
pkg.build_requires "runtime-#{settings[:runtime_project]}"
pkg.build_requires "libedit" if platform.name =~ /^solaris-10-sparc/
Expand Down
15 changes: 12 additions & 3 deletions configs/components/augeas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,21 @@
pkg.environment "PKG_CONFIG_PATH", "#{settings[:libdir]}/pkgconfig"

if platform.is_aix?
# We still use pl-gcc for AIX 7.1
pkg.environment "CC", "/opt/pl-build-tools/bin/gcc"
if platform.name == 'aix-7.1-ppc'
pkg.environment "CC", "/opt/pl-build-tools/bin/gcc"
else
pkg.environment "CC", "/opt/freeware/bin/gcc"
pkg.environment "PATH", "/opt/freeware/bin:$(PATH):#{settings[:bindir]}"
end
pkg.build_requires "runtime-#{settings[:runtime_project]}"
if platform.name == 'aix-7.1-ppc'
pkg.build_requires 'libedit'
else
pkg.build_requires 'readline'
end

pkg.environment "LDFLAGS", settings[:ldflags]
pkg.environment "CFLAGS", "-I#{settings[:includedir]}"
pkg.build_requires 'libedit'
end

if platform.is_rpm? && !platform.is_aix?
Expand Down
15 changes: 13 additions & 2 deletions configs/components/boost.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@
install_only_flags = "boost.locale.iconv=off"
elsif platform.is_aix?
pkg.environment "NO_CXX11_CHECK", "1"
pkg.environment "CXX", "/opt/freeware/bin/g++-8"
if platform.name == 'aix-7.1-ppc'
pkg.environment "CXX", "/opt/freeware/bin/g++-8"
else
pkg.environment "CXX", "/opt/freeware/bin/g++-10"
gpp = "/opt/freeware/bin/g++"
end
pkg.environment "CXXFLAGS", "-pthread"
pkg.environment "PATH", "/opt/freeware/bin:/opt/pl-build-tools/bin:$(PATH)"
linkflags = "-Wl,-L#{settings[:libdir]},-L/opt/pl-build-tools/lib"
Expand All @@ -130,8 +135,14 @@
if platform.is_windows?
userconfigjam = %Q{using gcc : : #{gpp} ;}
else
if platform.architecture =~ /arm/ || platform.is_aix?
if platform.architecture =~ /arm/
userconfigjam = %Q{using gcc : 5.2.0 : #{gpp} : <linkflags>"#{linkflags}" <cflags>"#{cflags}" <cxxflags>"#{cxxflags}" ;}
elsif platform.is_aix?
if platform.name == 'aix-7.1-ppc'
userconfigjam = %Q{using gcc : 5.2.0 : #{gpp} : <linkflags>"#{linkflags}" <cflags>"#{cflags}" <cxxflags>"#{cxxflags}" ;}
else
userconfigjam = %Q{using gcc : 10.3.0 : #{gpp} : <linkflags>"#{linkflags}" <cflags>"#{cflags}" <cxxflags>"#{cxxflags}" ;}
end
else
userconfigjam = %Q{using gcc : 4.8.2 : #{gpp} : <linkflags>"#{linkflags}" <cflags>"#{cflags}" <cxxflags>"#{cxxflags}" ;}
end
Expand Down
2 changes: 2 additions & 0 deletions configs/components/curl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
pkg.build_requires "runtime-#{settings[:runtime_project]}"
pkg.environment "PATH", "$(shell cygpath -u #{settings[:gcc_bindir]}):$(PATH)"
pkg.environment "CYGWIN", settings[:cygwin]
elsif platform.is_aix? && platform.name != 'aix-7.1-ppc'
pkg.environment 'PATH', "/opt/freeware/bin:$(PATH):#{settings[:bindir]}"
else
pkg.environment "PATH", "/opt/pl-build-tools/bin:$(PATH):#{settings[:bindir]}"
end
Expand Down
6 changes: 5 additions & 1 deletion configs/components/libffi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
pkg.mirror "#{settings[:buildsources_url]}/#{pkg.get_name}-#{pkg.get_version}.tar.gz"

if platform.is_aix?
pkg.environment "PATH", "/opt/pl-build-tools/bin:$(PATH)"
if platform.name == 'aix-7.1-ppc'
pkg.environment "PATH", "/opt/pl-build-tools/bin:$(PATH)"
else
pkg.environment "PATH", "/opt/freeware/bin:$(PATH)"
end
elsif platform.is_cross_compiled_linux?
pkg.environment "PATH", "/opt/pl-build-tools/bin:$(PATH):#{settings[:bindir]}"
pkg.environment "CFLAGS", settings[:cflags]
Expand Down
6 changes: 5 additions & 1 deletion configs/components/libxml2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
# So we generate a configure file manually, compress as tar.gz, and host internally.

if platform.is_aix?
pkg.environment "PATH", "/opt/pl-build-tools/bin:$(PATH)"
if platform.name == 'aix-7.1-ppc'
pkg.environment "PATH", "/opt/pl-build-tools/bin:$(PATH)"
else
pkg.environment "PATH", "/opt/freeware/bin:$(PATH)"
end
elsif platform.is_cross_compiled_linux?
pkg.environment "PATH", "/opt/pl-build-tools/bin:$(PATH):#{settings[:bindir]}"
pkg.environment "CFLAGS", settings[:cflags]
Expand Down
6 changes: 5 additions & 1 deletion configs/components/libxslt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
pkg.build_requires "libxml2"

if platform.is_aix?
pkg.environment "PATH", "/opt/pl-build-tools/bin:$(PATH)"
if platform.name == 'aix-7.1-ppc'
pkg.environment "PATH", "/opt/pl-build-tools/bin:$(PATH)"
else
pkg.environment "PATH", "/opt/freeware/bin:$(PATH)"
end
elsif platform.is_cross_compiled_linux?
pkg.environment "PATH", "/opt/pl-build-tools/bin:$(PATH):#{settings[:bindir]}"
pkg.environment "CFLAGS", settings[:cflags]
Expand Down
6 changes: 5 additions & 1 deletion configs/components/libyaml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
pkg.mirror "#{settings[:buildsources_url]}/yaml-#{pkg.get_version}.tar.gz"

if platform.is_aix?
pkg.environment "PATH", "/opt/pl-build-tools/bin:$(PATH)"
if platform.name == 'aix-7.1-ppc'
pkg.environment "PATH", "/opt/pl-build-tools/bin:$(PATH)"
else
pkg.environment "PATH", "/opt/freeware/bin:$(PATH)"
end
elsif platform.is_cross_compiled_linux?
pkg.environment "PATH", "/opt/pl-build-tools/bin:$(PATH):#{settings[:bindir]}"
pkg.environment "CFLAGS", settings[:cflags]
Expand Down
26 changes: 16 additions & 10 deletions configs/components/openssl-3.0.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,16 @@
# elsif platform.architecture =~ /ppc64/ # Big-endian
# 'linux-ppc64'
# end
# elsif platform.is_aix?
# pkg.environment 'CC', '/opt/pl-build-tools/bin/gcc'
elsif platform.is_aix?
raise "openssl-3.0 is not supported on older AIX" if platform.name == 'aix-7.1-ppc'

# cflags = '$${CFLAGS} -static-libgcc'
# target = 'aix-gcc'
# REMIND: why not PATH?
pkg.environment 'CC', '/opt/freeware/bin/gcc'

cflags = "#{settings[:cflags]} -static-libgcc"
# see https://github.com/openssl/openssl/issues/18007
ldflags = "#{settings[:ldflags]} -latomic -lm"
target = 'aix-gcc'
# elsif platform.is_solaris?
# pkg.environment 'PATH', '/opt/pl-build-tools/bin:$(PATH):/usr/local/bin:/usr/ccs/bin:/usr/sfw/bin'
# pkg.environment 'CC', "/opt/pl-build-tools/bin/#{settings[:platform_triple]}-gcc"
Expand Down Expand Up @@ -127,9 +132,9 @@
# Individual projects may provide their own openssl configure flags:
project_flags = settings[:openssl_extra_configure_flags] || []
perl_exec = ''
# if platform.is_aix?
# perl_exec = '/opt/freeware/bin/perl'
# end
if platform.is_aix?
perl_exec = '/opt/freeware/bin/perl'
end
configure_flags << project_flags

pkg.environment 'CFLAGS', cflags
Expand Down Expand Up @@ -169,9 +174,10 @@
install_prefix = platform.is_windows? ? '' : 'INSTALL_PREFIX=/'
install_commands = []

# if platform.is_aix?
# install_commands << "slibclean"
# end
if platform.is_aix?
# "Removes any currently unused modules in kernel and library memory."
install_commands << "slibclean"
end

# Skip man and html docs
install_commands << "#{platform[:make]} #{install_prefix} install_sw install_ssldirs"
Expand Down
4 changes: 3 additions & 1 deletion configs/components/readline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
pkg.mirror "#{settings[:buildsources_url]}/#{pkg.get_name}-#{pkg.get_version}.tar.gz"

if platform.is_aix?
pkg.environment "PATH", "/opt/pl-build-tools/bin:$(PATH)"
raise "readline is not supported on older AIX" if platform.name == 'aix-7.1-ppc'

pkg.environment "PATH", "/opt/freeware/bin:$(PATH)"
elsif platform.is_cross_compiled_linux?
pkg.environment "PATH", "/opt/pl-build-tools/bin:$(PATH):#{settings[:bindir]}"
pkg.environment "CFLAGS", settings[:cflags]
Expand Down
17 changes: 16 additions & 1 deletion configs/components/ruby-3.2.2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@
pkg.environment 'MAKE', 'make'
elsif platform.is_cross_compiled?
pkg.environment 'CROSS_COMPILING', 'true'
elsif platform.is_aix?
# When using the default -ggdb3 I was seeing linker errors like, so use -g0 instead:
#
# ld: 0711-759 INTERNAL ERROR: Source file dwarf.c, line 528.
# Depending on where this product was acquired, contact your service
# representative or the approved supplier.
# collect2: error: ld returned 16 exit status

pkg.environment 'optflags', "-O2 -fPIC -g0 "
else
pkg.environment 'optflags', '-O2'
end
Expand Down Expand Up @@ -117,6 +126,7 @@

without_dtrace = [
'aix-7.1-ppc',
'aix-7.2-ppc',
'el-7-ppc64le',
'osx-11-arm64',
'osx-12-arm64',
Expand All @@ -140,7 +150,11 @@
# TODO: Remove this once PA-1607 is resolved.
# TODO: Can we use native autoconf? The dependencies seemed a little too extensive
if platform.is_aix?
pkg.configure { ["/opt/pl-build-tools/bin/autoconf"] }
if platform.name == 'aix-7.1-ppc'
pkg.configure { ["/opt/pl-build-tools/bin/autoconf"] }
else
pkg.configure { ["/opt/freeware/bin/autoconf"] }
end
else
pkg.configure { ["bash autogen.sh"] }
end
Expand Down Expand Up @@ -178,6 +192,7 @@

target_doubles = {
'powerpc-ibm-aix7.1.0.0' => 'powerpc-aix7.1.0.0',
'powerpc-ibm-aix7.2.0.0' => 'powerpc-aix7.2.0.0',
'aarch64-apple-darwin' => 'arm64-darwin',
'aarch64-redhat-linux' => 'aarch64-linux',
'ppc64-redhat-linux' => 'powerpc64-linux',
Expand Down
11 changes: 9 additions & 2 deletions configs/components/runtime-agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
else
libdir = File.join("/opt/pl-build-tools", settings[:platform_triple], "lib")
end
elsif platform.name == "aix-7.1-ppc"
libdir = "/opt/pl-build-tools/lib/gcc/powerpc-ibm-aix7.1.0.0/5.2.0/"
elsif platform.is_aix?
if platform.name == "aix-7.1-ppc"
libdir = "/opt/pl-build-tools/lib/gcc/powerpc-ibm-aix7.1.0.0/5.2.0/"
else
libdir = "/opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/10/"
end
elsif platform.is_solaris? || platform.architecture =~ /i\d86/
libdir = "/opt/pl-build-tools/lib"
elsif platform.architecture =~ /64/
Expand All @@ -23,6 +27,9 @@
if platform.is_aix?
pkg.install_file File.join(libdir, "libstdc++.a"), "/opt/puppetlabs/puppet/lib/libstdc++.a"
pkg.install_file File.join(libdir, "libgcc_s.a"), "/opt/puppetlabs/puppet/lib/libgcc_s.a"
if platform.name != 'aix-7.1-ppc'
pkg.install_file File.join(libdir, "libatomic.a"), "/opt/puppetlabs/puppet/lib/libatomic.a"
end
elsif platform.is_windows?
lib_type = platform.architecture == "x64" ? "seh" : "sjlj"
pkg.install_file "#{settings[:gcc_bindir]}/libgcc_s_#{lib_type}-1.dll", "#{settings[:bindir]}/libgcc_s_#{lib_type}-1.dll"
Expand Down
5 changes: 4 additions & 1 deletion configs/components/yaml-cpp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@
pkg.environment "CYGWIN", settings[:cygwin]
cmake = "C:/ProgramData/chocolatey/bin/cmake.exe -G \"MinGW Makefiles\""
cmake_toolchain_file = "-DCMAKE_TOOLCHAIN_FILE=#{settings[:tools_root]}/pl-build-toolchain.cmake"
elsif platform.is_aix? || platform.name =~ /debian-9|el-[567]|redhatfips-7|sles-(:?11|12)|ubuntu-18.04-amd64/
elsif platform.name =~ /aix-7\.1-ppc|debian-9|el-[567]|redhatfips-7|sles-(?:11|12)|ubuntu-18\.04-amd64/
cmake = "#{settings[:tools_root]}/bin/cmake"
cmake_toolchain_file = "-DCMAKE_TOOLCHAIN_FILE=#{settings[:tools_root]}/pl-build-toolchain.cmake"
else
if platform.is_aix?
pkg.environment "PATH", "$PATH:/opt/freeware/bin"
end
pkg.environment 'CPPFLAGS', settings[:cppflags]
pkg.environment 'CFLAGS', settings[:cflags]
pkg.environment 'LDFLAGS', settings[:ldflags]
Expand Down
45 changes: 45 additions & 0 deletions configs/platforms/aix-7.2-ppc.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
platform "aix-7.2-ppc" do |plat|
# os_version = 7.2
plat.make "gmake"
plat.mktemp "/opt/freeware/bin/mktemp -d -p /var/tmp"
plat.patch "/opt/freeware/bin/patch"
plat.rpmbuild "/usr/bin/rpm"
plat.servicetype "aix"
plat.tar "/opt/freeware/bin/tar"

plat.provision_with %[
curl -O https://artifactory.delivery.puppetlabs.net/artifactory/generic__buildsources/openssl-1.0.2.1800.tar.Z;
uncompress openssl-1.0.2.1800.tar.Z;
tar xvf openssl-1.0.2.1800.tar;
cd openssl-1.0.2.1800 && /usr/sbin/installp -acgwXY -d $PWD openssl.base;
curl --output yum.sh https://artifactory.delivery.puppetlabs.net/artifactory/generic__buildsources/buildsources/aix-yum.sh && sh yum.sh]

packages = %w(
autoconf
cmake
coreutils
gawk
gcc
gcc-c++
gdbm
gmp
libffi
libyaml
make
perl
pkg-config
readline
readline-devel
sed
tar
zlib
zlib-devel
)
plat.provision_with "yum install --assumeyes #{packages.join(' ')}"

# No upstream rsync packages
plat.provision_with "rpm -Uvh https://artifactory.delivery.puppetlabs.net/artifactory/rpm__remote_aix_linux_toolbox/RPMS/ppc/rsync/rsync-3.0.6-1.aix5.3.ppc.rpm"

plat.install_build_dependencies_with "yum install --assumeyes "
plat.vmpooler_template "aix-7.2-power"
end
6 changes: 3 additions & 3 deletions configs/projects/_shared-agent-components.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# Common components required by all agent branches
proj.component 'runtime-agent'

matchdata = platform.settings[:ruby_version].match /(\d+)\.\d+\.\d+/
matchdata = platform.settings[:ruby_version].match(/(\d+)\.\d+\.\d+/)
ruby_major_version = matchdata[1].to_i
# Ruby 3.2 does not package these two libraries so we need to add them as a component
if ruby_major_version >= 3
Expand All @@ -30,7 +30,7 @@
proj.component "openssl-#{proj.openssl_version}"
end

proj.component 'curl'
proj.component 'curl' if platform.name != 'aix-7.2-ppc' # PA-5618
proj.component 'puppet-ca-bundle'
proj.component "ruby-#{proj.ruby_version}"
proj.component "readline" if platform.is_macos?
Expand All @@ -48,7 +48,7 @@
end

# libedit is used instead of readline on these platforms
if platform.is_solaris? || platform.is_aix?
if platform.is_solaris? || platform.name == 'aix-7.1-ppc'
proj.component 'libedit'
end

Expand Down
8 changes: 6 additions & 2 deletions configs/projects/_shared-agent-settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
proj.setting(:ldflags, "-L#{proj.libdir} -Wl,-rpath=#{proj.libdir},-z,relro,-z,now")
end

if ruby_version_x == "3" && !platform.is_aix? && !platform.is_solaris?
if ruby_version_x == "3" && !platform.is_solaris?
proj.setting(:openssl_version, '3.0')
elsif platform.name =~ /^redhatfips-/
proj.setting(:openssl_version, '1.1.1-fips')
Expand Down Expand Up @@ -208,7 +208,11 @@
end

if platform.is_aix?
proj.setting(:ldflags, "-Wl,-brtl -L#{proj.libdir} -L/opt/pl-build-tools/lib")
if platform.name == 'aix-7.1-ppc'
proj.setting(:ldflags, "-Wl,-brtl -L#{proj.libdir} -L/opt/pl-build-tools/lib")
else
proj.setting(:ldflags, "-Wl,-brtl -L#{proj.libdir}")
end
end

if platform.is_solaris?
Expand Down
Loading

0 comments on commit 1a77733

Please sign in to comment.