From a1d005e2b80c5dd0a1ebf29f8d3117f968e7d5e2 Mon Sep 17 00:00:00 2001 From: skyamgarp <130442619+skyamgarp@users.noreply.github.com> Date: Tue, 27 Aug 2024 21:34:39 +0530 Subject: [PATCH] (PA-6896) Enable pie on RHEL 9 and up (PA-6896) remove the shared flag --- configs/components/ruby-3.2.5.rb | 2 +- configs/projects/_shared-compiler-settings.rb | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/configs/components/ruby-3.2.5.rb b/configs/components/ruby-3.2.5.rb index feb3e723f..3195b6123 100644 --- a/configs/components/ruby-3.2.5.rb +++ b/configs/components/ruby-3.2.5.rb @@ -94,7 +94,7 @@ special_flags = " --prefix=#{ruby_dir} --with-opt-dir=#{settings[:prefix]} " if settings[:supports_pie] - special_flags += " CFLAGS='#{settings[:cflags]}' LDFLAGS='#{settings[:ldflags]}' CPPFLAGS='#{settings[:cppflags]}' " + special_flags += " CFLAGS='-fPIC -fstack-protector-strong -fno-plt -O2' LDFLAGS='#{settings[:ldflags]}' CPPFLAGS='-fPIE #{settings[:cppflags]}' " end # Ruby's build process requires a "base" ruby and we need a ruby to install diff --git a/configs/projects/_shared-compiler-settings.rb b/configs/projects/_shared-compiler-settings.rb index ef04e6ea9..cf7033d11 100644 --- a/configs/projects/_shared-compiler-settings.rb +++ b/configs/projects/_shared-compiler-settings.rb @@ -12,7 +12,6 @@ # are too old to support these flags. if((platform.is_sles? && platform.os_version.to_i >= 15) || - (platform.is_el? && platform.os_version.to_i == 8 && platform.architecture !~ /ppc64/) || (platform.is_debian? && platform.os_version.to_i >= 10) || (platform.is_ubuntu? && platform.os_version.to_i >= 22) || platform.is_fedora? @@ -21,4 +20,9 @@ proj.setting(:cppflags, "-I#{proj.includedir} -D_FORTIFY_SOURCE=2") proj.setting(:cflags, '-fstack-protector-strong -fno-plt -O2') proj.setting(:ldflags, "-L#{proj.libdir} -Wl,-rpath=#{proj.libdir},-z,relro,-z,now") +elsif(platform.is_el? && platform.os_version.to_i >= 8) + proj.setting(:supports_pie, true) + proj.setting(:cppflags, "-I#{proj.includedir} -D_FORTIFY_SOURCE=2") + proj.setting(:cflags, '-fPIC -pie -fstack-protector-strong -fno-plt -O2') + proj.setting(:ldflags, "-L#{proj.libdir} -Wl,-rpath=#{proj.libdir},-z,relro,-z,now") end \ No newline at end of file