Skip to content

Commit

Permalink
(PA-6383) build ruby and gems with PIE flags
Browse files Browse the repository at this point in the history
  • Loading branch information
h0tw1r3 committed Apr 24, 2024
1 parent ac05640 commit 4ff870e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
3 changes: 3 additions & 0 deletions configs/components/_base-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

####################
Expand Down
10 changes: 9 additions & 1 deletion configs/components/ruby-2.7.8.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 9 additions & 1 deletion configs/components/ruby-3.2.3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 4ff870e

Please sign in to comment.