ruby/tool
KJ Tsanaktsidis 0ccb80d6bf Extract hardening CFLAGS to a special $hardenflags variable
This changes the automatic detection of -fstack-protector,
-D_FORTIFY_SOURCE, and -mbranch-protection to write to $hardenflags
instead of $XCFLAGS. The definition of $cflags is changed to
"$hardenflags $orig_cflags $optflags $debugflags $warnflags" to match.

Furthermore, these flags are _prepended_ to $hardenflags, rather than
appended.

The implications of doing this are as follows:

* If a CRuby builder specifies cflags="-mbranch-protection=foobar" at
  the ./configure script, and the configure script detects that
  -mbranch-protection=pac-ret is accepted, then GCC will be invoked as
  "gcc -mbranch-protection=pac-ret -mbranch-protection=foobar". Since
  the last flags take precedence, that means that user-supplied values
  of these flags in $cflags will take priority.
* Likewise, if a CRuby builder explicitly specifies
  "hardenflags=-mbranch-protection=foobar", because we _prepend_ to
  $hardenflags in our autoconf script, we will still invoke GCC as
  "gcc -mbranch-protection=pac-ret -mbranch-protection=foobar".
* If a CRuby builder specifies CFLAGS="..." at the configure line,
  automatic detection of hardening flags is ignored as before.
* C extensions will _also_ be built with hardening flags now as well
  (this was not the case by default before because the detected flags
  went into $XCFLAGS).

Additionally, as part of this work, I changed how the detection of
PAC/BTI in Context.S works. Rather than appending the autodetected
option to ASFLAGS, we simply compile a set of test programs with the
actual CFLAGS in use to determine what PAC/BTI settings were actually
chosen by the builder. Context.S is made aware of these choices through
some custom macros.

The result of this work is that:

* Ruby will continue to choose some sensible defaults for hardening
  options for the C compiler
* Distributors are able to specify CFLAGS that are consistent with their
  distribution and override these defaults
* Context.S will react to whatever -mbranch-protection is actually in
  use, not what was autodetected
* Extensions get built with hardening flags too.

[Bug #20154]
[Bug #20520]
2024-06-11 20:48:55 +10:00
..
annocheck
bundler Update turbo_tests to 2.2.3 or higher 2024-04-19 08:32:01 +09:00
lib Re-use strscan with ruby repo 2024-05-20 18:10:09 +09:00
lrama Lrama v0.6.9 2024-05-02 13:32:04 +09:00
m4 Extract hardening CFLAGS to a special $hardenflags variable 2024-06-11 20:48:55 +10:00
releng
rjit Introduce a specialize instruction for Array#pack 2024-05-23 12:11:50 -07:00
ruby_vm Drop support for old ERB 2024-03-03 00:55:45 +09:00
test Show the caller location of assertion methods 2024-05-08 17:24:36 +09:00
test_for_warn_bundled_gems [Bug #20450] Remove rubyarchdir from bootsnap paths 2024-04-25 13:29:28 +09:00
asm_parse.rb
bisect.sh
build-transcode
checksum.rb
colors
darwin-ar
darwin-cc Ignore warnings about currently unsupported .debug_macinfo 2023-11-07 23:19:51 +09:00
disable_ipv6.sh
downloader.rb Ignore errors on prerelease gems 2024-03-27 16:18:14 +09:00
enc-case-folding.rb
enc-emoji-citrus-gen.rb
enc-emoji4unicode.rb
enc-unicode.rb Use the hexdigit character class 2023-10-02 00:49:05 +09:00
eval.rb
expand-config.rb
extlibs.rb
fake.rb [Bug #19967] Ignore library before build 2023-10-21 23:47:29 +09:00
fetch-bundled_gems.rb Highlight messages in fetch-bundled_gems 2024-03-18 23:29:54 +09:00
file2lastrev.rb
format-release fix regexp pattern of diff 2023-12-12 11:22:40 +09:00
gen-github-release.rb Set prerelease flag if tag includes preview or rc 2024-01-12 15:36:08 +09:00
gen-mailmap.rb
gen_dummy_probes.rb
gen_ruby_tapset.rb
generic_erb.rb Drop support for old ERB 2024-03-03 00:55:45 +09:00
git-refresh
gperf.sed
id2token.rb
ifchange
insns2vm.rb
install-sh
intern_ids.rb
leaked-globals Ignore retguard symbols when looking for leaked symbols 2024-06-04 13:04:41 -07:00
ln_sr.rb Fix tool/ln_sr.rb passing 2 arguments to String#chomp! 2023-12-13 07:05:21 -08:00
make-snapshot make-snapshot: update RUBY_PATCHLEVEL_STR regexp 2023-11-13 11:28:48 +09:00
make_hgraph.rb
mdoc2man.rb
merger.rb merger.rb: Put spaces in between revisions 2024-06-04 11:31:20 -07:00
missing-baseruby.bat Manage required baseruby version in one place 2024-03-31 00:54:38 +09:00
mk_builtin_loader.rb show warning for unused block 2024-04-15 12:08:07 +09:00
mkconfig.rb
mkrunnable.rb Install binary executable files to architecture dependent path 2024-02-18 15:07:42 +09:00
node_name.rb
outdate-bundled-gems.rb Deprecate `--dryrun` options in favor of `--dry-run` 2024-03-15 14:12:08 +09:00
parse.rb
prereq.status
probes_to_wiki.rb
rbinstall.rb Show destination directory after installation 2024-06-02 17:21:22 +09:00
rbs_skip_tests Bundle rbs-3.4.3 (#9702) 2024-01-26 08:47:29 +09:00
rbuninstall.rb Report non-empty directories [ci skip] 2024-03-09 23:08:37 +09:00
rdoc-srcdir Set executable on rdoc-srcdir [ci skip] 2024-04-26 19:22:16 +09:00
redmine-backporter.rb Suppress warnings about frozen string literal feature 2024-05-30 10:32:33 +09:00
release.sh release.sh: Explain example usages 2024-05-29 20:25:41 -07:00
rmdirs
run-gcov.rb
run-lcov.rb
runruby.rb Support RUNRUBY_USE_RR for rr debugger 2023-11-29 17:54:58 -05:00
search-cgvars.rb
strip-rdoc.rb
sync_default_gems.rb Sync strscan HEAD again. 2024-06-04 12:40:08 +09:00
test-annocheck.sh
test-bundled-gems.rb Skip test task for resolv-replace 2024-01-19 17:44:58 +09:00
test-coverage.rb
transcode-tblgen.rb Drop support for old ERB 2024-03-03 00:55:45 +09:00
travis_retry.sh
travis_wait.sh
update-NEWS-gemlist.rb [DOC] "is now bundled" is ambiguous 2023-10-19 16:37:11 -07:00
update-NEWS-refs.rb Support Misc tracker [ci skip] 2024-04-18 08:10:23 +09:00
update-bundled_gems.rb Update newer version gems only 2023-11-04 11:29:42 +09:00
update-deps [PRISM] Update dependencies for prism diagnostics 2024-03-06 21:42:54 -05:00
vtlh.rb
wasm-clangw