From 4ff870e756b0da3ebdd4a17d75c47dcb7fdcd3b1 Mon Sep 17 00:00:00 2001 From: Jeffrey Clark Date: Wed, 24 Apr 2024 12:29:40 -0500 Subject: [PATCH] (PA-6383) build ruby and gems with PIE flags --- configs/components/_base-ruby.rb | 3 +++ configs/components/ruby-2.7.8.rb | 10 +++++++++- configs/components/ruby-3.2.3.rb | 10 +++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/configs/components/_base-ruby.rb b/configs/components/_base-ruby.rb index 1f9cd82dd..f302a7d53 100644 --- a/configs/components/_base-ruby.rb +++ b/configs/components/_base-ruby.rb @@ -76,6 +76,9 @@ elsif platform.architecture == 'arm64' && platform.os_version.to_i >= 13 pkg.environment 'CC', 'clang' end +else + pkg.environment 'LDFLAGS', settings[:ldflags] + pkg.environment 'optflags', settings[:cflags] end #################### diff --git a/configs/components/ruby-2.7.8.rb b/configs/components/ruby-2.7.8.rb index 73936bd9b..5e5e71cf9 100644 --- a/configs/components/ruby-2.7.8.rb +++ b/configs/components/ruby-2.7.8.rb @@ -98,7 +98,15 @@ special_flags = " --prefix=#{ruby_dir} --with-opt-dir=#{settings[:prefix]} " - if platform.name =~ /sles-15|el-8|debian-10/ + # conditional taken from projects/_shared-compiler-settings + # TODO: refactor condition + if ((platform.is_sles? && platform.os_version.to_i >= 15) || + (platform.is_el? && platform.os_version.to_i >= 8) || + platform.is_debian? || + (platform.is_ubuntu? && platform.os_version.to_i >= 20) || + (platform.is_amazon? && platform.os_version.to_i >= 2023) || + platform.is_fedora? + ) special_flags += " CFLAGS='#{settings[:cflags]}' LDFLAGS='#{settings[:ldflags]}' CPPFLAGS='#{settings[:cppflags]}' " end diff --git a/configs/components/ruby-3.2.3.rb b/configs/components/ruby-3.2.3.rb index b7e4a69df..9b29cb214 100644 --- a/configs/components/ruby-3.2.3.rb +++ b/configs/components/ruby-3.2.3.rb @@ -93,7 +93,15 @@ special_flags = " --prefix=#{ruby_dir} --with-opt-dir=#{settings[:prefix]} " - if platform.name =~ /sles-15|el-8|debian-10/ + # conditional taken from projects/_shared-compiler-settings + # TODO: refactor condition + if ((platform.is_sles? && platform.os_version.to_i >= 15) || + (platform.is_el? && platform.os_version.to_i >= 8) || + platform.is_debian? || + (platform.is_ubuntu? && platform.os_version.to_i >= 20) || + (platform.is_amazon? && platform.os_version.to_i >= 2023) || + platform.is_fedora? + ) special_flags += " CFLAGS='#{settings[:cflags]}' LDFLAGS='#{settings[:ldflags]}' CPPFLAGS='#{settings[:cppflags]}' " end