public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/gcc-patches:master commit in: 13.3.0/gentoo/
@ 2025-04-18 23:23 Sam James
  0 siblings, 0 replies; 7+ messages in thread
From: Sam James @ 2025-04-18 23:23 UTC (permalink / raw
  To: gentoo-commits

commit:     05d9c70131be267bfe5b36e663acda8729da6456
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Apr 18 23:00:00 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Apr 18 23:03:26 2025 +0000
URL:        https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=05d9c701

13.3.0: tweak backport for gimple match

Signed-off-by: Sam James <sam <AT> gentoo.org>

 ...h-Reject-non-ssa-name-min-invariants-in-g.patch | 346 +++++++++++++++++++++
 ...t-non-ssa-name-min-invariants-in-gimple_e.patch |  77 +++++
 13.3.0/gentoo/README.history                       |   5 +
 3 files changed, 428 insertions(+)

diff --git a/13.3.0/gentoo/32_all_Revert-match-Reject-non-ssa-name-min-invariants-in-g.patch b/13.3.0/gentoo/32_all_Revert-match-Reject-non-ssa-name-min-invariants-in-g.patch
new file mode 100644
index 0000000..76f40ec
--- /dev/null
+++ b/13.3.0/gentoo/32_all_Revert-match-Reject-non-ssa-name-min-invariants-in-g.patch
@@ -0,0 +1,346 @@
+From 9dd5291b00687516217068d9e9500f59c42e906c Mon Sep 17 00:00:00 2001
+Message-ID: <9dd5291b00687516217068d9e9500f59c42e906c.1745017007.git.sam@gentoo.org>
+From: Sam James <sam@gentoo.org>
+Date: Fri, 18 Apr 2025 23:54:56 +0100
+Subject: [PATCH] Revert "match: Reject non-ssa name/min invariants in
+ gimple_extract [PR116412]"
+
+This reverts commit de622c307743cc03f45f1ba7b0c2f8df0b378206.
+
+Let's apply the version from master instead as it applies cleanly
+with our gimple split backports.
+---
+ gcc/gimple-match-head.cc                  | 6 ------
+ gcc/testsuite/gcc.dg/torture/pr116412-1.c | 6 ------
+ 2 files changed, 12 deletions(-)
+ delete mode 100644 gcc/testsuite/gcc.dg/torture/pr116412-1.c
+
+diff --git a/gcc/gimple-match-head.cc b/gcc/gimple-match-head.cc
+index b3e7792a8fae..21843d7870b3 100644
+--- a/gcc/gimple-match-head.cc
++++ b/gcc/gimple-match-head.cc
+@@ -945,9 +945,6 @@ gimple_extract (gimple *stmt, gimple_match_op *res_op,
+ 		|| code == VIEW_CONVERT_EXPR)
+ 	      {
+ 		tree op0 = TREE_OPERAND (gimple_assign_rhs1 (stmt), 0);
+-		/* op0 needs to be a SSA name or an min invariant. */
+-		if (TREE_CODE (op0) != SSA_NAME && !is_gimple_min_invariant (op0))
+-		  return false;
+ 		res_op->set_op (code, type, valueize_op (op0));
+ 		return true;
+ 	      }
+@@ -955,9 +952,6 @@ gimple_extract (gimple *stmt, gimple_match_op *res_op,
+ 	      {
+ 		tree rhs1 = gimple_assign_rhs1 (stmt);
+ 		tree op0 = valueize_op (TREE_OPERAND (rhs1, 0));
+-		/* op0 needs to be a SSA name or an min invariant. */
+-		if (TREE_CODE (op0) != SSA_NAME && !is_gimple_min_invariant (op0))
+-		  return false;
+ 		res_op->set_op (code, type, op0,
+ 				TREE_OPERAND (rhs1, 1),
+ 				TREE_OPERAND (rhs1, 2),
+diff --git a/gcc/testsuite/gcc.dg/torture/pr116412-1.c b/gcc/testsuite/gcc.dg/torture/pr116412-1.c
+deleted file mode 100644
+index 3bc26ecd8b83..000000000000
+--- a/gcc/testsuite/gcc.dg/torture/pr116412-1.c
++++ /dev/null
+@@ -1,6 +0,0 @@
+-/* { dg-do compile } */
+-double f(_Complex double a, _Complex double *b, int c)
+-{
+-  if (c) return __real__ a;
+-  return __real__ *b;
+-}
+
+base-commit: e8e9c25cbaee08f54b7be3051ba5c444a042a958
+prerequisite-patch-id: 4000f228fd3953eb9877fab7b9493cd86f6bc771
+prerequisite-patch-id: d61e09af01bb7358c1df6abf5d2c4b7849ab4676
+prerequisite-patch-id: 54a4cfb376547141937d7e321d7b4554c1e3afe7
+prerequisite-patch-id: f33957dc1b64edeb4a61c8cab68f8d3d83364a29
+prerequisite-patch-id: 7ce45196fe80b18512fadb50fc103fab4428d4fc
+prerequisite-patch-id: 91222abe57fbe0d242ef3c8c9d2b3c90434ca452
+prerequisite-patch-id: c121f50ebb95ace4d0265345daa0e7dc7b7f32e3
+prerequisite-patch-id: 10defea0d9b839e7a1dbacb051fa9228c4fb4625
+prerequisite-patch-id: 19438a1e2a41164df78f94a8c4ccd7720201b546
+prerequisite-patch-id: 6bc290482177e8770fcc08796a829b92a889b8c8
+prerequisite-patch-id: 51d285ed9ee0440cf1b3c7e5951ee7d72b8037ff
+prerequisite-patch-id: 6c9d8dee84130dc5654c6cdbe79cadc1c8c6ea01
+prerequisite-patch-id: c29ac39a9aa0b2f57b8630f94068de3c615c2aff
+prerequisite-patch-id: 39267d318bda1c6274f085b6ad0fa6033ba91775
+prerequisite-patch-id: aa5f357645bad3e273e9ad8c46909741b8645df5
+prerequisite-patch-id: 13e454b7c162f4fa60cc8f3a16923cb5b36e45b5
+prerequisite-patch-id: 1060dae5225651943f0407eba3dcce8086b8bde8
+prerequisite-patch-id: 26881a346914ff9c275ca61ab3a568c03cf9bbe9
+prerequisite-patch-id: 063c13e33fbdf446f7f28b26c88c60536ee56519
+prerequisite-patch-id: fe9ba680bbfc289ca761c3861cff1811e74eb4b0
+prerequisite-patch-id: 09d88e096bf253c83e6ebdc0b642826e9879942d
+prerequisite-patch-id: a84430c6349f1ce57b286dadec379dc165e67272
+prerequisite-patch-id: 1b83a611e9c183aef02cdba17bc27e1bf46b6a82
+prerequisite-patch-id: b350801c3eeeb3c80130687e8985f74188fc994f
+prerequisite-patch-id: 18ed2ed229344f5bdc6a533189452d61a7b9e0c6
+prerequisite-patch-id: 678cf62a5f3f39c471bf5edaedf6e59939294158
+prerequisite-patch-id: 73c6eff6ab4f6306617ae5899f8368ce59205084
+prerequisite-patch-id: 201acda3e16c581f13d9348fdfc4a4325c86ec78
+prerequisite-patch-id: ee35d1ccc78b44a74f630328981b8d9cf46e9468
+prerequisite-patch-id: 0c66af4c70e7009524b7d16c79599d6878f13d1e
+prerequisite-patch-id: 9b9f795264fb537d7a0b523529eb94bc2f28a912
+prerequisite-patch-id: e64a9e239738ff1af9753893372bb0fff907d8e6
+prerequisite-patch-id: edab03f98cda6e515b46641380a89363fb348f27
+prerequisite-patch-id: 28c6a5c9c0794adf089c24e5f59586631c5d6b4c
+prerequisite-patch-id: 1592351558023ed19f4d4cce450a7e5405c4c477
+prerequisite-patch-id: 1f6ceda2c5f0cc58d7792c113786168d26ded64e
+prerequisite-patch-id: ec4f5a1f5caad415297ed94fa087ac1b1794edec
+prerequisite-patch-id: accea82f9287261c369823223dfaf4fcb8b0b04b
+prerequisite-patch-id: 7f04c14f63aa50e011361fba1c2c0b179ae89926
+prerequisite-patch-id: 58c2460e281789a969f88192db772864c849b43a
+prerequisite-patch-id: 3d876e98b0d481d6c7e2b52a554af0453b09061e
+prerequisite-patch-id: fa6ade15971b59c537df92a80bac5db80c73eeda
+prerequisite-patch-id: b9dc7fcafec64cc21b25e6d562cbfd0da53ada13
+prerequisite-patch-id: 31e4c4ece4f81f8a56cb1dc9dd2c6a2b2b189e41
+prerequisite-patch-id: c714645ae913506bbbc8c6f830f34495f09887ad
+prerequisite-patch-id: 45ab2bc42bd191cfb931e411b7470a11d54c60b6
+prerequisite-patch-id: 3e4db23ce7ced910d59208fda696f160d443e39e
+prerequisite-patch-id: ed5b4dfd1b1553d5e2b865c4191a992c30c21132
+prerequisite-patch-id: dfee1a6a00ebca2d5cb7a2eee81a340cc89b7d49
+prerequisite-patch-id: fea03dfb92db40bca9bd07688d5d3d3c8ce896d1
+prerequisite-patch-id: 15025215942f585a037956d31abe7f2b373ee13f
+prerequisite-patch-id: 7263cf35bd75fbe9833a5f88de04ffdfcb5f253b
+prerequisite-patch-id: e285aa1cbf2a4e243d14e4cdff950f30a5789c71
+prerequisite-patch-id: a3a7f88920dcaec397cdce89680dd341da6b7d50
+prerequisite-patch-id: 7600dcc6bf999fab9607d4c2cba27189ee0564a5
+prerequisite-patch-id: 7402bf8989dddb67dd1559acca2e01aa83140123
+prerequisite-patch-id: cfea7aa3c6017fdbfc11f1a08806db122fc5295c
+prerequisite-patch-id: 9e2538496d48ee88c8bc71a455a8f7cbea90fd27
+prerequisite-patch-id: 76350633625ea8ebf6642d0e961fc95bcd395252
+prerequisite-patch-id: 48b1cf84bbb0b656161a73838e6238a4f3d38468
+prerequisite-patch-id: 8599a7e709b6fa302480edbf806f6ec9f954e23d
+prerequisite-patch-id: 50cb90d34e425f04b2d764fb65ec508aafcad2df
+prerequisite-patch-id: e98b69d7ea1c4dba058e00c57f4ff9e3e8fb2559
+prerequisite-patch-id: d28c36be561ed8fca4910a4cb321bc08b5b7708b
+prerequisite-patch-id: 7ea170b0341982c21e60e465e8c625d2960f2b16
+prerequisite-patch-id: 3982e9fbbf57e762ed696345f8bcad3c0a6e1086
+prerequisite-patch-id: 0305ac3424f89aa4aba5ce5435b8fd85943828c3
+prerequisite-patch-id: 969dd08cc76edf9b6102c4a4c01cbbca722597f2
+prerequisite-patch-id: a51e8bf8edeb57333f9c42336e2158600cb004b7
+prerequisite-patch-id: 7ccf51887ed93b633625b4694a59641c76890ef5
+prerequisite-patch-id: 4bfb12d943bd6ecb048488305e63e46817dec176
+prerequisite-patch-id: a82ff80cfd39451cfb765814559b967ff93f4c38
+prerequisite-patch-id: b7fc31e5e57057b6546b9ae65f51c1af8e905e50
+prerequisite-patch-id: 1937f4fd85004468bf2d5d0a148fbf2587a9705a
+prerequisite-patch-id: 62818f51c736d0fb646f742a0e479f3b858233c7
+prerequisite-patch-id: 11552ea3abae2eacb46f625bbc617117436849bf
+prerequisite-patch-id: 6afee34bc46041d68820e3f122a23fd24fc545c1
+prerequisite-patch-id: 6cbe24165de74cd2950e6b9c449285e2a9996a3a
+prerequisite-patch-id: f6f4f9d25d70c9c984601cb0a841ef0056a96f8e
+prerequisite-patch-id: 6beeb7f9dd28f462ce4edfc097c1035d0fdbf4b4
+prerequisite-patch-id: d6ccd36c9f0bfd88e0560d88e6d6290dc9cc2f6f
+prerequisite-patch-id: bcaa6733db1855ea6436baff8fc76a47906c2825
+prerequisite-patch-id: ff0a6dc87bbfcc75e2af148a774dcf63dd0bcf59
+prerequisite-patch-id: debdb70f1a346c3d4da763514cc147d9e870f28e
+prerequisite-patch-id: 88735a130a1e69a473780b06cf47f56055b1c436
+prerequisite-patch-id: ec0bdca250dcfca9de48472ebff0f91dda8261c2
+prerequisite-patch-id: 63402b6a4ee2eae396ec8ab14e95187ee9c469d2
+prerequisite-patch-id: 3414159afddcacb863eb6c22034f1e6c077a3efd
+prerequisite-patch-id: 84dafcbf3467b841fb4eb487e2c6578895e944eb
+prerequisite-patch-id: 6a70c983260d7aae40cf031a38874f75259b3b3b
+prerequisite-patch-id: 9eebe9af364b17be1e226eb2c7d8e0bb06231c81
+prerequisite-patch-id: cb12ebd5f640e96b04363ad3ce005ddeb0dd0723
+prerequisite-patch-id: b430927d8b00100c498c8dd8870727506d1dfe0d
+prerequisite-patch-id: f968419372ed5926fcb57beb4c7c72737481d952
+prerequisite-patch-id: 6ccb24a636aa485529d30df1641e344462fbc909
+prerequisite-patch-id: 032b9d6f8b184657a26307d41cfce6c615335309
+prerequisite-patch-id: bd1bf0d256e303c70a2dcde06623804a2cbdf28c
+prerequisite-patch-id: 156300b14794c263c3c432dde6d5024786795554
+prerequisite-patch-id: e8cb13f0278ae3bc29c9de4c3dc113885689d276
+prerequisite-patch-id: ff268f12fe17287fd7ad35d49872c4a58dfd3cae
+prerequisite-patch-id: 41d85acb48f0505a07c09e78227728ad6c14ca7b
+prerequisite-patch-id: 6fc18578f4297af3ed307d107ea7d219a4137857
+prerequisite-patch-id: 7e733c8718ac018ff9f561a4f6e15f4acc009044
+prerequisite-patch-id: aa1a67fca9e40c55a805f9823b126e0a8776f58b
+prerequisite-patch-id: c790af738adad0ed0952809d7d5858cb33efa903
+prerequisite-patch-id: 54b40b27df66648905ad03e31b28262497349ff6
+prerequisite-patch-id: 818c9dd45838b5a37c7470e6af7b4a4fef7899f0
+prerequisite-patch-id: 47fae69b45075e7a5e74ff5430d17192985d56ae
+prerequisite-patch-id: 98acde088eda4d69a67ec69bb23ab5609f14b4f8
+prerequisite-patch-id: fff1a6094f38821bc9530a1222d9db3545fff4bf
+prerequisite-patch-id: 2992ff74566833f01a9d5c5a02370d40a62e8149
+prerequisite-patch-id: b7bdccfd5ab045a7de1e87406e2e0c8a420831be
+prerequisite-patch-id: 1d406d1e2c1fc5c98e7b41216ab782209fdf7e11
+prerequisite-patch-id: 46ff326c8793791903bec66def9e98c5a5dbb72f
+prerequisite-patch-id: 650d8ab6f84909d14d1f9b2f54507c5115abcafa
+prerequisite-patch-id: 0bac576999fa0d969da86c0927fc341c0410e390
+prerequisite-patch-id: 11698f88600663672ecdb56482548eed99bfc544
+prerequisite-patch-id: 6444daa0bf5487ea735a3c56eb6d8ce35eaea1a0
+prerequisite-patch-id: 7363ebadd5fc24e0d0dc1e02a26d455ec343ea1e
+prerequisite-patch-id: a927d87484196cf40563167226f6354e9b084b82
+prerequisite-patch-id: 2477e04339f77befb8dedecf6a68b856fc4a7426
+prerequisite-patch-id: 331f4e188bbfc392de6fd1c9ad2f26dae92088ce
+prerequisite-patch-id: 5b48614ae4317c26283bea218d0c87e2fe2323ad
+prerequisite-patch-id: b7bed4280bfe2098f78ff3d612ce158466dc61c7
+prerequisite-patch-id: 2363d5b1c546e6487f009f8517c43e489e2ac912
+prerequisite-patch-id: 57dd7fedb604c3836a83554711d3b3b365861281
+prerequisite-patch-id: 6e3fb71fe560825a0355840a2b82e8f3665f7691
+prerequisite-patch-id: 9c59d3707980df2ecc974a2b0f33fc04cbce3c63
+prerequisite-patch-id: 854e8a7592f24f650706e9ee842b728315f86150
+prerequisite-patch-id: 96843265d6233d73319a857ea922bef352e65723
+prerequisite-patch-id: f24ba9138beb1103f26743250623864e94af31a6
+prerequisite-patch-id: ed65f7c0ab161f517d7e9a52bf659c96a499009b
+prerequisite-patch-id: 6970114ec1dc352ce3286e4864883d94d2c53e72
+prerequisite-patch-id: d9cccf7a6513eb12377aa033295563d714ec7e76
+prerequisite-patch-id: 7ac4059bf34412de9016fd9bd94b2fc08118f22e
+prerequisite-patch-id: 8e55da2dd496d68aca0e23caa7caf2e8aed4fcd2
+prerequisite-patch-id: b2a32567c61d16415e5f34d158118d59820c54f4
+prerequisite-patch-id: 8602ef48c789b5383cf601f4690cf361da033e43
+prerequisite-patch-id: 92450377cf2de31f9ac0595c8ccbf39bcc66089c
+prerequisite-patch-id: 37ebe40f9a712784fdf6eae589ca3b7f4e2eba89
+prerequisite-patch-id: 242fbf4814f72946650e5d1fc544ef7344ce1551
+prerequisite-patch-id: 1fd6b5d6f4dbc93018cf16fbb7476c9f2ddd937a
+prerequisite-patch-id: 176ba2d32cfcd316f7114686ba53530a48a98170
+prerequisite-patch-id: 9d33d24dfdacffb6b9c02bec16a99bd99f431750
+prerequisite-patch-id: eb933df4ae544de44b9d72b9786135ae3fbd3dc5
+prerequisite-patch-id: 5a718f2ad842a8338da577682e0aa79da82b24e2
+prerequisite-patch-id: 0e0eaa7590ebc1d71eb2092b967853364e95a3e6
+prerequisite-patch-id: f1d7f2c93482a2e592ed1fd528d6b699524e0eff
+prerequisite-patch-id: 04a4ddcad10e249f4e8cd96ade03c16997e8f83f
+prerequisite-patch-id: d4eb06f1933395d3e2a2d8e01819143fefdc1ab1
+prerequisite-patch-id: 7bfca3d72d913ab20ce4542ecc3a79b71ab4b34b
+prerequisite-patch-id: cec8674786e5709c1ba564312ae7ff7e63023406
+prerequisite-patch-id: 443db6f3f21ac47028dd548756fd3c5e2f25c589
+prerequisite-patch-id: cda72279d48792063744b4c519e3c6993f81885f
+prerequisite-patch-id: b01592891e2c41822dc61b1301175f4062ac3d8d
+prerequisite-patch-id: e186039cf949ca74ac9fe92deeb20e9e17002a23
+prerequisite-patch-id: 44663ba254e07b5d54ed49baea61ef2b220b33aa
+prerequisite-patch-id: e671b0a855da853426828d2ffdb3473436ff19bf
+prerequisite-patch-id: afeddd66e941b1ac625bb880b2486690f89878f7
+prerequisite-patch-id: 7a3c41238533c9cf8c159db069832f859798c3f2
+prerequisite-patch-id: 387d4ce4dd0793ea76c0e39065b86601bf62bc70
+prerequisite-patch-id: 34860adccc757aa463d52202ce0bf498aa6de4db
+prerequisite-patch-id: b68fe90bf65ac752a5fede52f6f22c935bfb3c2e
+prerequisite-patch-id: 089542ef54c958626cd52ae38aca0b7a6583ac48
+prerequisite-patch-id: 606fd2295d4a435682d44f41dff543880d72c6b0
+prerequisite-patch-id: 3ffad8cb09328205160313a8fddd18996cfd03c0
+prerequisite-patch-id: 03f8d2df058110dfbafc42f9b5676e6e448e6f1b
+prerequisite-patch-id: 615c37510c2d423ff2b699519bc73360ec42c4cc
+prerequisite-patch-id: e6bb243b318e54a228d13c73044d1990cff90274
+prerequisite-patch-id: 1ecd5357bbe3778efb77e2a1d36c19b4cbd88018
+prerequisite-patch-id: c8c690a9f0bb8d0da10c6c580b1ea572298b6f12
+prerequisite-patch-id: 5625d0da64401d3c4ed61700ac6f44ee17734cc9
+prerequisite-patch-id: 9587a58836badf710b6afed29aa8fb46469e7134
+prerequisite-patch-id: 08b614d746c685fe9201a3fddaa56b261725a9c7
+prerequisite-patch-id: e80e703932f3d360cd018550266c89f5037bb916
+prerequisite-patch-id: aa181fabbc78d656c00758c662dbec2ab3400bec
+prerequisite-patch-id: 679ff648f4069f60c25d8a5b9029dade17793f63
+prerequisite-patch-id: ad53fc07735fdcf14f4b046ceeca03db8758c9e7
+prerequisite-patch-id: 4cee7d8d5735802a6052bd90c9cdbf7bd4ed3980
+prerequisite-patch-id: 2adf47d0706c23431ff3b1f7e78bf5918b2f3567
+prerequisite-patch-id: 353bc5a2fcc179076073137766deda46ebb9ceec
+prerequisite-patch-id: 2e282c12c0bb8c8a74490fb77ddfafe0706f483e
+prerequisite-patch-id: 4932b89a2b8281fdcb7ee9d2614d705002186687
+prerequisite-patch-id: 194cc76655f0e1894d85100b87499d2c6b8f0f79
+prerequisite-patch-id: 6cbc30fa3b1c681c193baaec07e5d039cbb0e57b
+prerequisite-patch-id: 19161fe841569e007138c6a1d9c72a63fd833460
+prerequisite-patch-id: 698bd67ad1caaa862d66239a0be98c2e409db6e2
+prerequisite-patch-id: 5397622fd4a81b0c12f71f5c0f853e750d58714f
+prerequisite-patch-id: caabcccfd5dc523471a56af1fd97c18fdaa47b2b
+prerequisite-patch-id: e1cd7aecd0d76a07b38b7941020183d33590ba1d
+prerequisite-patch-id: 9132942115937a933f4fc1d8e10ffd4064a588a3
+prerequisite-patch-id: a9f8c23f38963000c24d79409fcdf41a75b902eb
+prerequisite-patch-id: 71c5b3d293c3c751115a8396b3da3ef379cc2bb1
+prerequisite-patch-id: 4b6bdf4fea45aa937f1948f0a31331902538c7d6
+prerequisite-patch-id: fbc41bd99c5398ecb18e0cd69208cc22f73c3519
+prerequisite-patch-id: 03e457be8ce0c5bba40258f0a05988214b0aa943
+prerequisite-patch-id: 611ca786e319c6eaad1220104b9c59956f3a737c
+prerequisite-patch-id: 37c85c06e7e6f71c5fcaf501b3c231ebdda0de25
+prerequisite-patch-id: 2950d7602c252ae6c52ab5eee625e099880ad4a3
+prerequisite-patch-id: 9f06a91013a6470c4d12d6b8d8cc9916db731206
+prerequisite-patch-id: b9b5fe94042334d549909e3fe0bfc89bbff47804
+prerequisite-patch-id: 9f5f9d934c9f3df5950b4a309c686990f6ad6c5f
+prerequisite-patch-id: cfdea290c851441658fb74fba2a6e01a2808753b
+prerequisite-patch-id: 6ee38d522d7f36f1677c044cfc92727ae8989d50
+prerequisite-patch-id: a0c291be10cfcde10af5a9f98085e366b27cd51d
+prerequisite-patch-id: 7269e54eaac036c1f56547e8126c21aa07965990
+prerequisite-patch-id: 743f1e5f91963fe3d39919415c206965fe3a6440
+prerequisite-patch-id: 424ef441392b7bde4e437f53824613b124d6dbd3
+prerequisite-patch-id: 8632e82489e773fb5249436e9e31e1065fd218f1
+prerequisite-patch-id: 74018ff327e6224cc8b49723ef3428b93f3fb213
+prerequisite-patch-id: 19237c0d4945c6de2f78bb203c433d489aa612d9
+prerequisite-patch-id: effcb0d6394408c9ff3b749520c45e86b595b172
+prerequisite-patch-id: 0172ae2c60bf591f075ab8494c3decb82b41c7b1
+prerequisite-patch-id: 1437321584a9c64af6745d17cbc47241344bcc03
+prerequisite-patch-id: e78ab6cbcc6fd294ffc30e07aa04f4ceb2d4fc79
+prerequisite-patch-id: 61621d78d2c4f94785ad379b18f780dd104f5bb3
+prerequisite-patch-id: 62c5daf26e76cc0214b4074add9eb0cf104937df
+prerequisite-patch-id: 43e88973169b8053bf951eabafc374e21eb772a4
+prerequisite-patch-id: abc2a406d74ff20b74a578f6ed5d82b7964ed4ef
+prerequisite-patch-id: b9fc489e4fa8105e1c26aa19eb4fe39219e878c0
+prerequisite-patch-id: 047db5e0bb9036899a99055bc19eef9fc04d2365
+prerequisite-patch-id: 3ba2f422b4b9db70becb0cb2383b5090c2a7a264
+prerequisite-patch-id: 8bafd081a2871875c21c928af872b4e2e370babb
+prerequisite-patch-id: 96a0f212a7a766dce87722c023ad314ec1ddc089
+prerequisite-patch-id: 217b76140030b0f2fe68b62a506668ab2d87e09e
+prerequisite-patch-id: 4a9ec2b685ad7898ecb11e0b5080c76bd66a88c2
+prerequisite-patch-id: c9e34f723bba04ebb7f0082d35b4878401ca4225
+prerequisite-patch-id: bc4e3b5d9e56150b67e246ca8243a16d8e81a7a3
+prerequisite-patch-id: 880a56e163a69583440c5a306db024b5d1a87e73
+prerequisite-patch-id: 405b8ded54e162c4bee8fd262797a646f6aa3a90
+prerequisite-patch-id: 8230b5c9e7bf22592ca0e7e24b1a9be62903e739
+prerequisite-patch-id: 389e09111729163dc93126f2e3f703d60cf99686
+prerequisite-patch-id: b67d2e019bec68385b8b8334b96f65496b02fdfe
+prerequisite-patch-id: 8b31569a2db2f8dc93b5c4950c734b9ff1d4ec10
+prerequisite-patch-id: d0b74f170c5e52fa9a68b25b060b1701dacae94b
+prerequisite-patch-id: dd954615469140f580d029ba81a5b77aad8fa29e
+prerequisite-patch-id: 8f66cfc254ffcffd6b1858af7d9bf64655c00b36
+prerequisite-patch-id: 93ab9804f3f6b7772147cc623b1d69d7be1e454a
+prerequisite-patch-id: 43f1234eced90d70f3ae9f606bffa48f24e3dd92
+prerequisite-patch-id: 3b38cdb1a0b08f40467facb70ca0d547dcff8163
+prerequisite-patch-id: eb0ed7947d2ba792d5ec1cdf0abb6c6d951afd45
+prerequisite-patch-id: af50aee54c356fc4455fe10b73d1fe63ebedc589
+prerequisite-patch-id: d5f8a47d5556e2fefcdcaed3acf0538179c8cf8f
+prerequisite-patch-id: a61e7edc4591a5dd4fbbad46ebefca9b0dd366ef
+prerequisite-patch-id: d0a3e49cbfc8b1008dd81c5dc774cc346511f43a
+prerequisite-patch-id: 217f44c419e22f75a042f2a8ef3c4a9d54526df8
+prerequisite-patch-id: fca77347bd5662931a48a5cd8831e4d81fcb3788
+prerequisite-patch-id: 8152afe30ef294e594f965a22ea8e9e6d80440aa
+prerequisite-patch-id: d3930b2ee1ea2752e7b18028c830a8d9612ffcc6
+prerequisite-patch-id: d1982b9ea82f575d723cd6ce8fd7f30bce266a9f
+prerequisite-patch-id: 403ba6fa34cdc2edb87f95f81fa8960a31e48170
+prerequisite-patch-id: 2602a564a4b8fb30a0145ad876395515db731db5
+prerequisite-patch-id: 73822021c209efca62480958d6c0982a4dcae9c6
+prerequisite-patch-id: 0b8b98a7382b63ce17c7ca3bfd4dc6ad59d6844c
+prerequisite-patch-id: 55f262e1d03052c46f2ec8218404173c87c220ea
+prerequisite-patch-id: 553bc879c60074fdd2221896cfc2c0ba1d142330
+prerequisite-patch-id: 6252c8110e5ccb1921e665231e078f2647f7ca44
+prerequisite-patch-id: 38e7acd0eafe65723775565c9f582af6774cf082
+prerequisite-patch-id: 1dde2b41a618209bde1a097104380a107b8f08fc
+prerequisite-patch-id: 7f6b5f1d9b57aa4b31894fa470bbcb780128e68c
+prerequisite-patch-id: b75427f17633a73e70c81aab993df11bcf530903
+prerequisite-patch-id: 3313c5e4f64130c2045f9c9ef80b0ae40aadef4f
+prerequisite-patch-id: 6fc511fa0ec824aed9871cb679b0b6b9ecb13183
+prerequisite-patch-id: 296fe91b963aa091f580f9f85350005b536bb796
+prerequisite-patch-id: de5f2c4a44ab2d3f898349db687614286bfffa7f
+prerequisite-patch-id: b4dc4f7b714d5f4b3796299446d7c22710a00acf
+prerequisite-patch-id: 53b4a07974ffac8d2e3b45c2379af5f8fcbb6835
+prerequisite-patch-id: 12f5f295d06fceb946e4ca558d28133859afb289
+prerequisite-patch-id: 8161319cbdd3163dc32c9ccfa8d40bb3a356bbc5
+prerequisite-patch-id: d7a6747c5ed93f25940e8088cf616edfe19d9bed
+prerequisite-patch-id: c2fa0cf3850f239b06833884e774a2427150b96f
+prerequisite-patch-id: dd6a6e3d7104e745a39b56d222869217f4fcf5f4
+prerequisite-patch-id: bb4f6c0100db86ef1b3d96f16f9a6f289d520783
+prerequisite-patch-id: 4e17f6b465f87cd015b19e9890a9348a4700fe30
+prerequisite-patch-id: a90a84b76b13ea9d5b0839412893b8ca7c81923a
+prerequisite-patch-id: 8619c75413d9dbcd0ec7ab042dd99a19990e7a99
+prerequisite-patch-id: ad1902dd37f1c4affbc788c0eeb740426a79cde1
+prerequisite-patch-id: 22f3d65eacf7faf4ca640fc8aeab5bc198b84756
+prerequisite-patch-id: 7d1161aa0c17298f35cc5311bc16ce09e17e406c
+prerequisite-patch-id: b78967f514ed500e0817c01000e255cbdb71273e
+prerequisite-patch-id: 368c2487edab1d95f4cf3d7afa44b3d5fd6cf6c9
+prerequisite-patch-id: 002b0474e9725459039fc305e799c9dcf052ee68
+prerequisite-patch-id: 1bbfbc90f9fd8e85fabce81ddb38b28a51d2c45b
+prerequisite-patch-id: daab4fe626801f253a4d3a7fd4a88db276751186
+prerequisite-patch-id: 678ac52a47649ea6712227032fdcba869b30e71a
+prerequisite-patch-id: 07fcba7a0210098e023d303440d945720b2f2813
+prerequisite-patch-id: 75dce98230c3c470ca0fe01f93ba8567e9f11506
+prerequisite-patch-id: 778a46802fb72c7cf1e884978513e0f070278cb0
+-- 
+2.49.0
+

diff --git a/13.3.0/gentoo/93_all_match-Reject-non-ssa-name-min-invariants-in-gimple_e.patch b/13.3.0/gentoo/93_all_match-Reject-non-ssa-name-min-invariants-in-gimple_e.patch
new file mode 100644
index 0000000..95d7677
--- /dev/null
+++ b/13.3.0/gentoo/93_all_match-Reject-non-ssa-name-min-invariants-in-gimple_e.patch
@@ -0,0 +1,77 @@
+From c7b76a076cb2c6ded7ae208464019b04cb0531a2 Mon Sep 17 00:00:00 2001
+Message-ID: <c7b76a076cb2c6ded7ae208464019b04cb0531a2.1745017147.git.sam@gentoo.org>
+From: Andrew Pinski <quic_apinski@quicinc.com>
+Date: Mon, 19 Aug 2024 08:06:36 -0700
+Subject: [PATCH] match: Reject non-ssa name/min invariants in gimple_extract
+ [PR116412]
+
+After the conversion for phiopt's conditional operand
+to use maybe_push_res_to_seq, it was found that gimple_extract
+will extract out from REALPART_EXPR/IMAGPART_EXPR/VCE and BIT_FIELD_REF,
+a memory load. But that extraction was not needed as memory loads are not
+simplified in match and simplify. So gimple_extract should return false
+in those cases.
+
+Changes since v1:
+* Move the rejection to gimple_extract from factor_out_conditional_operation.
+
+Bootstrapped and tested on x86_64-linux-gnu.
+
+	PR tree-optimization/116412
+
+gcc/ChangeLog:
+
+	* gimple-match-exports.cc (gimple_extract): Return false if op0
+	was not a SSA name nor a min invariant for REALPART_EXPR/IMAGPART_EXPR/VCE
+	and BIT_FIELD_REF.
+
+gcc/testsuite/ChangeLog:
+
+	* gcc.dg/torture/pr116412-1.c: New test.
+
+Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
+---
+ gcc/gimple-match-exports.cc               | 6 ++++++
+ gcc/testsuite/gcc.dg/torture/pr116412-1.c | 6 ++++++
+ 2 files changed, 12 insertions(+)
+ create mode 100644 gcc/testsuite/gcc.dg/torture/pr116412-1.c
+
+diff --git a/gcc/gimple-match-exports.cc b/gcc/gimple-match-exports.cc
+index 15d54b7d8438..86e40100899a 100644
+--- a/gcc/gimple-match-exports.cc
++++ b/gcc/gimple-match-exports.cc
+@@ -740,6 +740,9 @@ gimple_extract (gimple *stmt, gimple_match_op *res_op,
+ 		|| code == VIEW_CONVERT_EXPR)
+ 	      {
+ 		tree op0 = TREE_OPERAND (gimple_assign_rhs1 (stmt), 0);
++		/* op0 needs to be a SSA name or an min invariant. */
++		if (TREE_CODE (op0) != SSA_NAME && !is_gimple_min_invariant (op0))
++		  return false;
+ 		res_op->set_op (code, type, valueize_op (op0));
+ 		return true;
+ 	      }
+@@ -747,6 +750,9 @@ gimple_extract (gimple *stmt, gimple_match_op *res_op,
+ 	      {
+ 		tree rhs1 = gimple_assign_rhs1 (stmt);
+ 		tree op0 = valueize_op (TREE_OPERAND (rhs1, 0));
++		/* op0 needs to be a SSA name or an min invariant. */
++		if (TREE_CODE (op0) != SSA_NAME && !is_gimple_min_invariant (op0))
++		  return false;
+ 		res_op->set_op (code, type, op0,
+ 				TREE_OPERAND (rhs1, 1),
+ 				TREE_OPERAND (rhs1, 2),
+diff --git a/gcc/testsuite/gcc.dg/torture/pr116412-1.c b/gcc/testsuite/gcc.dg/torture/pr116412-1.c
+new file mode 100644
+index 000000000000..3bc26ecd8b83
+--- /dev/null
++++ b/gcc/testsuite/gcc.dg/torture/pr116412-1.c
+@@ -0,0 +1,6 @@
++/* { dg-do compile } */
++double f(_Complex double a, _Complex double *b, int c)
++{
++  if (c) return __real__ a;
++  return __real__ *b;
++}
+-- 
+2.49.0
+

diff --git a/13.3.0/gentoo/README.history b/13.3.0/gentoo/README.history
index d17cd25..a99da58 100644
--- a/13.3.0/gentoo/README.history
+++ b/13.3.0/gentoo/README.history
@@ -1,3 +1,8 @@
+3	18 April 2025
+
+	+ 32_all_Revert-match-Reject-non-ssa-name-min-invariants-in-g.patch
+	+ 93_all_match-Reject-non-ssa-name-min-invariants-in-gimple_e.patch
+
 2	29 Nov 2024
 
 	- 93_all_PR115917-ada-lto.patch


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/gcc-patches:master commit in: 13.3.0/gentoo/
@ 2025-04-24 23:30 Sam James
  0 siblings, 0 replies; 7+ messages in thread
From: Sam James @ 2025-04-24 23:30 UTC (permalink / raw
  To: gentoo-commits

commit:     93f36c1b921e531fd4cdc6aee7af55e1d6eb9d39
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 24 23:30:16 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Apr 24 23:30:16 2025 +0000
URL:        https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=93f36c1b

13.3.0: rebase patches, cut patchset 4

We should really switch to the proper git workflow...

Signed-off-by: Sam James <sam <AT> gentoo.org>

 ...d-Use-splits-in-makefile-and-make-configurabl.patch | 18 ------------------
 ...7_all_Remove-DEFAULT_MATCHPD_PARTITIONS-macro.patch | 18 ------------------
 ...179_genemit-Split-insn-emit.cc-into-ten-files.patch | 18 ------------------
 13.3.0/gentoo/README.history                           |  6 ++++++
 4 files changed, 6 insertions(+), 54 deletions(-)

diff --git a/13.3.0/gentoo/81_all_match.pd-Use-splits-in-makefile-and-make-configurabl.patch b/13.3.0/gentoo/81_all_match.pd-Use-splits-in-makefile-and-make-configurabl.patch
index f525f63..00991c9 100644
--- a/13.3.0/gentoo/81_all_match.pd-Use-splits-in-makefile-and-make-configurabl.patch
+++ b/13.3.0/gentoo/81_all_match.pd-Use-splits-in-makefile-and-make-configurabl.patch
@@ -227,24 +227,6 @@ index ade0af23e8cc..542d100c2b73 100755
  # Enable __cxa_atexit for C++.
  # Check whether --enable-__cxa_atexit was given.
  if test "${enable___cxa_atexit+set}" = set; then :
-@@ -19871,7 +19896,7 @@ else
-   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-   lt_status=$lt_dlunknown
-   cat > conftest.$ac_ext <<_LT_EOF
--#line 19874 "configure"
-+#line 19899 "configure"
- #include "confdefs.h"
- 
- #if HAVE_DLFCN_H
-@@ -19977,7 +20002,7 @@ else
-   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-   lt_status=$lt_dlunknown
-   cat > conftest.$ac_ext <<_LT_EOF
--#line 19980 "configure"
-+#line 20005 "configure"
- #include "confdefs.h"
- 
- #if HAVE_DLFCN_H
 diff --git a/gcc/configure.ac b/gcc/configure.ac
 index bf8ff4d63906..31aa8566a3e7 100644
 --- a/gcc/configure.ac

diff --git a/13.3.0/gentoo/87_all_Remove-DEFAULT_MATCHPD_PARTITIONS-macro.patch b/13.3.0/gentoo/87_all_Remove-DEFAULT_MATCHPD_PARTITIONS-macro.patch
index 1f47154..0382989 100644
--- a/13.3.0/gentoo/87_all_Remove-DEFAULT_MATCHPD_PARTITIONS-macro.patch
+++ b/13.3.0/gentoo/87_all_Remove-DEFAULT_MATCHPD_PARTITIONS-macro.patch
@@ -54,24 +54,6 @@ index 542d100c2b73..cc8247037569 100755
  
  # Enable __cxa_atexit for C++.
  # Check whether --enable-__cxa_atexit was given.
-@@ -19896,7 +19891,7 @@ else
-   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-   lt_status=$lt_dlunknown
-   cat > conftest.$ac_ext <<_LT_EOF
--#line 19899 "configure"
-+#line 19894 "configure"
- #include "confdefs.h"
- 
- #if HAVE_DLFCN_H
-@@ -20002,7 +19997,7 @@ else
-   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-   lt_status=$lt_dlunknown
-   cat > conftest.$ac_ext <<_LT_EOF
--#line 20005 "configure"
-+#line 20000 "configure"
- #include "confdefs.h"
- 
- #if HAVE_DLFCN_H
 diff --git a/gcc/configure.ac b/gcc/configure.ac
 index 31aa8566a3e7..d02ffc22a3a3 100644
 --- a/gcc/configure.ac

diff --git a/13.3.0/gentoo/90_all_PR54179_genemit-Split-insn-emit.cc-into-ten-files.patch b/13.3.0/gentoo/90_all_PR54179_genemit-Split-insn-emit.cc-into-ten-files.patch
index f6ded53..edba21b 100644
--- a/13.3.0/gentoo/90_all_PR54179_genemit-Split-insn-emit.cc-into-ten-files.patch
+++ b/13.3.0/gentoo/90_all_PR54179_genemit-Split-insn-emit.cc-into-ten-files.patch
@@ -219,24 +219,6 @@ index cc8247037569..c98088bea90d 100755
  # Enable __cxa_atexit for C++.
  # Check whether --enable-__cxa_atexit was given.
  if test "${enable___cxa_atexit+set}" = set; then :
-@@ -19891,7 +19911,7 @@ else
-   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-   lt_status=$lt_dlunknown
-   cat > conftest.$ac_ext <<_LT_EOF
--#line 19894 "configure"
-+#line 19914 "configure"
- #include "confdefs.h"
- 
- #if HAVE_DLFCN_H
-@@ -19997,7 +20017,7 @@ else
-   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-   lt_status=$lt_dlunknown
-   cat > conftest.$ac_ext <<_LT_EOF
--#line 20000 "configure"
-+#line 20020 "configure"
- #include "confdefs.h"
- 
- #if HAVE_DLFCN_H
 diff --git a/gcc/configure.ac b/gcc/configure.ac
 index d02ffc22a3a3..7021f95da3ee 100644
 --- a/gcc/configure.ac

diff --git a/13.3.0/gentoo/README.history b/13.3.0/gentoo/README.history
index a99da58..d5fadb0 100644
--- a/13.3.0/gentoo/README.history
+++ b/13.3.0/gentoo/README.history
@@ -1,3 +1,9 @@
+4	25 April 2025
+
+	U 81_all_match.pd-Use-splits-in-makefile-and-make-configurabl.patch
+	U 87_all_Remove-DEFAULT_MATCHPD_PARTITIONS-macro.patch
+	U 90_all_PR54179_genemit-Split-insn-emit.cc-into-ten-files.patch
+
 3	18 April 2025
 
 	+ 32_all_Revert-match-Reject-non-ssa-name-min-invariants-in-g.patch


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/gcc-patches:master commit in: 13.3.0/gentoo/
@ 2025-05-27 14:15 Sam James
  0 siblings, 0 replies; 7+ messages in thread
From: Sam James @ 2025-05-27 14:15 UTC (permalink / raw
  To: gentoo-commits

commit:     6daca622f1773923ccb770f7e8c4b24d53a7920f
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue May 27 14:15:01 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue May 27 14:15:01 2025 +0000
URL:        https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=6daca622

13.3.0: cut patchset 5, time64 patches

Backport time64 bits to 13 on request of dilfridge because 14/15 are broken
on m68k, and this will make it easier to test time64 + new int alignment.

Signed-off-by: Sam James <sam <AT> gentoo.org>

 13.3.0/gentoo/33_all_time64.patch         | 39 ++++++++++++++++++++++++++++
 13.3.0/gentoo/34_all_time64_ssemath.patch | 43 +++++++++++++++++++++++++++++++
 13.3.0/gentoo/README.history              |  5 ++++
 3 files changed, 87 insertions(+)

diff --git a/13.3.0/gentoo/33_all_time64.patch b/13.3.0/gentoo/33_all_time64.patch
new file mode 100644
index 0000000..ac972b9
--- /dev/null
+++ b/13.3.0/gentoo/33_all_time64.patch
@@ -0,0 +1,39 @@
+From b2ee3846dfcea638e0fbf2d550234f1c7594fcdb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Fri, 1 Nov 2024 07:48:37 +0100
+Subject: [PATCH] Support forcing _TIME_BITS=64 for time64 profiles
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Support forcing _TIME_BITS=64 and _FILE_OFFSET_BITS=64
+via -D_GENTOO_TIME64_FORCE=1, for time64 profiles.
+
+Signed-off-by: Michał Górny <mgorny@gentoo.org>
+---
+ gcc/c-family/c-cppbuiltin.cc | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc
+index 8bbfe84b2..962cbd414 100644
+--- a/gcc/c-family/c-cppbuiltin.cc
++++ b/gcc/c-family/c-cppbuiltin.cc
+@@ -1593,6 +1593,15 @@ c_cpp_builtins (cpp_reader *pfile)
+     builtin_define_with_int_value ("_FORTIFY_SOURCE", GENTOO_FORTIFY_SOURCE_LEVEL);
+ #endif
+ 
++#ifndef _GENTOO_TIME64_FORCE
++  #define _GENTOO_TIME64_FORCE 0
++#endif
++
++  if (_GENTOO_TIME64_FORCE) {
++    cpp_define (pfile, "_FILE_OFFSET_BITS=64");
++    cpp_define (pfile, "_TIME_BITS=64");
++  }
++
+   /* Misc.  */
+   if (flag_gnu89_inline)
+     cpp_define (pfile, "__GNUC_GNU_INLINE__");
+-- 
+2.47.0
+

diff --git a/13.3.0/gentoo/34_all_time64_ssemath.patch b/13.3.0/gentoo/34_all_time64_ssemath.patch
new file mode 100644
index 0000000..3701b6b
--- /dev/null
+++ b/13.3.0/gentoo/34_all_time64_ssemath.patch
@@ -0,0 +1,43 @@
+From 33ba5944f2b887fe8bddd541790645b74f1f2655 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Sun, 24 Nov 2024 14:45:37 +0100
+Subject: [PATCH] Default to -mfpmath=sse on x86 with time64
+
+Our time64 stages already default to `-mfpmath=sse`, so let's have
+the time64 flag implicitly enable it as the default to make things more
+consistent.  Furthermore, this also improves compatibility with clang
+that always enables it whenever the target architectures supports SSE.
+
+Note that this works only if `-march=` with SSE support is specified.
+We could technically improve the consistency even further by raising
+the default `-march=`, but that seems a bit intrusive and probably
+unnecessary, given that the vast majority of Gentoo users and/or
+upstream projects will specify `-march=`.
+
+See also:
+https://public-inbox.gentoo.org/gentoo-dev/ce894afe6c2b324fef012da9bb9387cfde7aed03.camel@gentoo.org/
+https://public-inbox.gentoo.org/gentoo-dev/baa1ca92da4941b0999ea2feecf02334b5b20ade.camel@gentoo.org/
+---
+ gcc/config/i386/i386-options.cc | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc
+index 6c212a8ed..03801f382 100644
+--- a/gcc/config/i386/i386-options.cc
++++ b/gcc/config/i386/i386-options.cc
+@@ -2881,7 +2881,11 @@ ix86_option_override_internal (bool main_args_p,
+      Also -mfpmath=387 is overall a lot more compact (bout 4-5%) than SSE
+      codegen.  We may switch to 387 with -ffast-math for size optimized
+      functions. */
+-  else if (fast_math_flags_set_p (&global_options)
++#ifndef _GENTOO_TIME64_FORCE
++  #define _GENTOO_TIME64_FORCE 0
++#endif
++
++  else if ((fast_math_flags_set_p (&global_options) || _GENTOO_TIME64_FORCE)
+ 	   && TARGET_SSE2_P (opts->x_ix86_isa_flags))
+     opts->x_ix86_fpmath = FPMATH_SSE;
+   else
+-- 
+2.47.0
+

diff --git a/13.3.0/gentoo/README.history b/13.3.0/gentoo/README.history
index d5fadb0..bfbf4d7 100644
--- a/13.3.0/gentoo/README.history
+++ b/13.3.0/gentoo/README.history
@@ -1,3 +1,8 @@
+5	27 May 2025
+
+	+ 33_all_time64.patch
+	+ 34_all_time64_ssemath.patcho
+
 4	25 April 2025
 
 	U 81_all_match.pd-Use-splits-in-makefile-and-make-configurabl.patch


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/gcc-patches:master commit in: 13.3.0/gentoo/
@ 2025-07-31  1:11 Sam James
  0 siblings, 0 replies; 7+ messages in thread
From: Sam James @ 2025-07-31  1:11 UTC (permalink / raw
  To: gentoo-commits

commit:     636d9ed6c929921b4705e9fc9eb3dd3d8ac04bfd
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 31 01:11:35 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jul 31 01:11:35 2025 +0000
URL:        https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=636d9ed6

13.3.0: drop upstreamed libsanitizer fixes

Signed-off-by: Sam James <sam <AT> gentoo.org>

 ...ll-libsanitizer-Fix-build-with-glibc-2.42.patch | 82 ----------------------
 ...ommon-Remove-reference-to-obsolete-termio.patch | 76 --------------------
 13.3.0/gentoo/README.history                       |  5 ++
 3 files changed, 5 insertions(+), 158 deletions(-)

diff --git a/13.3.0/gentoo/94_all-libsanitizer-Fix-build-with-glibc-2.42.patch b/13.3.0/gentoo/94_all-libsanitizer-Fix-build-with-glibc-2.42.patch
deleted file mode 100644
index 40c3e67..0000000
--- a/13.3.0/gentoo/94_all-libsanitizer-Fix-build-with-glibc-2.42.patch
+++ /dev/null
@@ -1,82 +0,0 @@
-From faf929fcc361d3ca64c6acb0ee9660c79b5905d2 Mon Sep 17 00:00:00 2001
-Message-ID: <faf929fcc361d3ca64c6acb0ee9660c79b5905d2.1753477197.git.sam@gentoo.org>
-From: Florian Weimer <fweimer@redhat.com>
-Date: Fri, 2 May 2025 17:41:43 +0200
-Subject: [PATCH 1/2] libsanitizer: Fix build with glibc 2.42
-
-The termio structure will be removed from glibc 2.42.  It has
-been deprecated since the late 80s/early 90s.
-
-Cherry-picked from LLVM commit 59978b21ad9c65276ee8e14f26759691b8a65763
-("[sanitizer_common] Remove interceptors for deprecated struct termio
-(#137403)").
-
-Co-Authored-By: Tom Stellard <tstellar@redhat.com>
-
-libsanitizer/
-
-	* sanitizer_common/sanitizer_common_interceptors_ioctl.inc: Cherry
-	picked from LLVM commit 59978b21ad9c65276ee8e14f26759691b8a65763.
-	* sanitizer_common/sanitizer_platform_limits_posix.cpp: Likewise.
-	* sanitizer_common/sanitizer_platform_limits_posix.h: Likewise.
-
-(cherry picked from commit 1789c57dc97ea2f9819ef89e28bf17208b6208e7)
----
- .../sanitizer_common_interceptors_ioctl.inc               | 8 --------
- .../sanitizer_common/sanitizer_platform_limits_posix.cpp  | 3 ---
- .../sanitizer_common/sanitizer_platform_limits_posix.h    | 1 -
- 3 files changed, 12 deletions(-)
-
-diff --git a/libsanitizer/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/libsanitizer/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
-index 49ec4097c900..dda11daa77f4 100644
---- a/libsanitizer/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
-+++ b/libsanitizer/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
-@@ -338,17 +338,9 @@ static void ioctl_table_fill() {
-   _(SOUND_PCM_WRITE_CHANNELS, WRITE, sizeof(int));
-   _(SOUND_PCM_WRITE_FILTER, WRITE, sizeof(int));
-   _(TCFLSH, NONE, 0);
--#if SANITIZER_GLIBC
--  _(TCGETA, WRITE, struct_termio_sz);
--#endif
-   _(TCGETS, WRITE, struct_termios_sz);
-   _(TCSBRK, NONE, 0);
-   _(TCSBRKP, NONE, 0);
--#if SANITIZER_GLIBC
--  _(TCSETA, READ, struct_termio_sz);
--  _(TCSETAF, READ, struct_termio_sz);
--  _(TCSETAW, READ, struct_termio_sz);
--#endif
-   _(TCSETS, READ, struct_termios_sz);
-   _(TCSETSF, READ, struct_termios_sz);
-   _(TCSETSW, READ, struct_termios_sz);
-diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
-index c85cf1626a75..c13811e39a44 100644
---- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
-+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
-@@ -467,9 +467,6 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
-   unsigned struct_input_id_sz = sizeof(struct input_id);
-   unsigned struct_mtpos_sz = sizeof(struct mtpos);
-   unsigned struct_rtentry_sz = sizeof(struct rtentry);
--#if SANITIZER_GLIBC || SANITIZER_ANDROID
--  unsigned struct_termio_sz = sizeof(struct termio);
--#endif
-   unsigned struct_vt_consize_sz = sizeof(struct vt_consize);
-   unsigned struct_vt_sizes_sz = sizeof(struct vt_sizes);
-   unsigned struct_vt_stat_sz = sizeof(struct vt_stat);
-diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
-index 44dd3d9e22d1..45c1e1302f8f 100644
---- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
-+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
-@@ -998,7 +998,6 @@ extern unsigned struct_hd_geometry_sz;
- extern unsigned struct_input_absinfo_sz;
- extern unsigned struct_input_id_sz;
- extern unsigned struct_mtpos_sz;
--extern unsigned struct_termio_sz;
- extern unsigned struct_vt_consize_sz;
- extern unsigned struct_vt_sizes_sz;
- extern unsigned struct_vt_stat_sz;
-
-base-commit: e8e9c25cbaee08f54b7be3051ba5c444a042a958
--- 
-2.50.1
-

diff --git a/13.3.0/gentoo/95_all-sanitizer_common-Remove-reference-to-obsolete-termio.patch b/13.3.0/gentoo/95_all-sanitizer_common-Remove-reference-to-obsolete-termio.patch
deleted file mode 100644
index 589c948..0000000
--- a/13.3.0/gentoo/95_all-sanitizer_common-Remove-reference-to-obsolete-termio.patch
+++ /dev/null
@@ -1,76 +0,0 @@
-From e48245a3cf32b4a1989b0175577e9ee1890a9124 Mon Sep 17 00:00:00 2001
-Message-ID: <e48245a3cf32b4a1989b0175577e9ee1890a9124.1753477197.git.sam@gentoo.org>
-In-Reply-To: <faf929fcc361d3ca64c6acb0ee9660c79b5905d2.1753477197.git.sam@gentoo.org>
-References: <faf929fcc361d3ca64c6acb0ee9660c79b5905d2.1753477197.git.sam@gentoo.org>
-From: Sam James <sam@gentoo.org>
-Date: Fri, 25 Jul 2025 19:45:18 +0100
-Subject: [PATCH 2/2] [sanitizer_common] Remove reference to obsolete termio
- ioctls (#138822)
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Cherry picked from LLVM commit c99b1bcd505064f2e086e6b1034ce0b0c91ea5b9.
-
-The termio ioctls are no longer used after commit 59978b21ad9c
-("[sanitizer_common] Remove interceptors for deprecated struct termio
-(#137403)"), remove them.  Fixes this build error:
-
-../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:765:27: error: invalid application of ‘sizeof’ to incomplete type ‘__sanitizer::termio’
-  765 |   unsigned IOCTL_TCGETA = TCGETA;
-      |                           ^~~~~~
-../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:769:27: error: invalid application of ‘sizeof’ to incomplete type ‘__sanitizer::termio’
-  769 |   unsigned IOCTL_TCSETA = TCSETA;
-      |                           ^~~~~~
-../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:770:28: error: invalid application of ‘sizeof’ to incomplete type ‘__sanitizer::termio’
-  770 |   unsigned IOCTL_TCSETAF = TCSETAF;
-      |                            ^~~~~~~
-../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:771:28: error: invalid application of ‘sizeof’ to incomplete type ‘__sanitizer::termio’
-  771 |   unsigned IOCTL_TCSETAW = TCSETAW;
-      |                            ^~~~~~~
-
-(cherry picked from commit 50cff2194bcb8321414437169d443bf48695972c)
----
- .../sanitizer_common/sanitizer_platform_limits_posix.cpp      | 4 ----
- .../sanitizer_common/sanitizer_platform_limits_posix.h        | 4 ----
- 2 files changed, 8 deletions(-)
-
-diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
-index c13811e39a44..cb50a272c422 100644
---- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
-+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
-@@ -743,13 +743,9 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
-   unsigned IOCTL_SOUND_PCM_WRITE_FILTER = SOUND_PCM_WRITE_FILTER;
- #endif // SOUND_VERSION
-   unsigned IOCTL_TCFLSH = TCFLSH;
--  unsigned IOCTL_TCGETA = TCGETA;
-   unsigned IOCTL_TCGETS = TCGETS;
-   unsigned IOCTL_TCSBRK = TCSBRK;
-   unsigned IOCTL_TCSBRKP = TCSBRKP;
--  unsigned IOCTL_TCSETA = TCSETA;
--  unsigned IOCTL_TCSETAF = TCSETAF;
--  unsigned IOCTL_TCSETAW = TCSETAW;
-   unsigned IOCTL_TCSETS = TCSETS;
-   unsigned IOCTL_TCSETSF = TCSETSF;
-   unsigned IOCTL_TCSETSW = TCSETSW;
-diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
-index 45c1e1302f8f..70ea7e3c1bc2 100644
---- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
-+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
-@@ -1242,13 +1242,9 @@ extern unsigned IOCTL_SNDCTL_COPR_SENDMSG;
- extern unsigned IOCTL_SNDCTL_COPR_WCODE;
- extern unsigned IOCTL_SNDCTL_COPR_WDATA;
- extern unsigned IOCTL_TCFLSH;
--extern unsigned IOCTL_TCGETA;
- extern unsigned IOCTL_TCGETS;
- extern unsigned IOCTL_TCSBRK;
- extern unsigned IOCTL_TCSBRKP;
--extern unsigned IOCTL_TCSETA;
--extern unsigned IOCTL_TCSETAF;
--extern unsigned IOCTL_TCSETAW;
- extern unsigned IOCTL_TCSETS;
- extern unsigned IOCTL_TCSETSF;
- extern unsigned IOCTL_TCSETSW;
--- 
-2.50.1
-

diff --git a/13.3.0/gentoo/README.history b/13.3.0/gentoo/README.history
index a8fa3a7..f6bde9a 100644
--- a/13.3.0/gentoo/README.history
+++ b/13.3.0/gentoo/README.history
@@ -1,3 +1,8 @@
+7	????
+
+	- 94_all-libsanitizer-Fix-build-with-glibc-2.42.patch
+	- 95_all-sanitizer_common-Remove-reference-to-obsolete-termio.patch
+
 6	25 July 2025
 
 	+ 94_all-libsanitizer-Fix-build-with-glibc-2.42.patch


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/gcc-patches:master commit in: 13.3.0/gentoo/
@ 2025-08-02 13:32 Sam James
  0 siblings, 0 replies; 7+ messages in thread
From: Sam James @ 2025-08-02 13:32 UTC (permalink / raw
  To: gentoo-commits

commit:     2c4fba4e9fc0bbf926deb808d4096fdf45b349fc
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Aug  2 13:27:26 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Aug  2 13:27:26 2025 +0000
URL:        https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=2c4fba4e

13.3.0: cut patchset 7

Signed-off-by: Sam James <sam <AT> gentoo.org>

 13.3.0/gentoo/README.history | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/13.3.0/gentoo/README.history b/13.3.0/gentoo/README.history
index f6bde9a..3424374 100644
--- a/13.3.0/gentoo/README.history
+++ b/13.3.0/gentoo/README.history
@@ -1,4 +1,4 @@
-7	????
+7	2 August 2025
 
 	- 94_all-libsanitizer-Fix-build-with-glibc-2.42.patch
 	- 95_all-sanitizer_common-Remove-reference-to-obsolete-termio.patch


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/gcc-patches:master commit in: 13.3.0/gentoo/
@ 2025-08-03 14:14 Sam James
  0 siblings, 0 replies; 7+ messages in thread
From: Sam James @ 2025-08-03 14:14 UTC (permalink / raw
  To: gentoo-commits

commit:     dee36e2a3bc87096002eb97f0bd6847122bb40b1
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Aug  3 09:03:36 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Aug  3 09:03:36 2025 +0000
URL:        https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=dee36e2a

13.3.0: backport more build speed improvements

We already have a bunch so what's a few more?

Signed-off-by: Sam James <sam <AT> gentoo.org>

 ...ut-Accelerate-the-place_operands-function.patch |  247 ++++
 ...nemit-Distribute-evenly-to-files-PR111600.patch |  190 +++
 ...g-Split-into-separate-partitions-PR111600.patch | 1360 ++++++++++++++++++++
 13.3.0/gentoo/README.history                       |    6 +
 4 files changed, 1803 insertions(+)

diff --git a/13.3.0/gentoo/94_all_genoutput-Accelerate-the-place_operands-function.patch b/13.3.0/gentoo/94_all_genoutput-Accelerate-the-place_operands-function.patch
new file mode 100644
index 0000000..7663658
--- /dev/null
+++ b/13.3.0/gentoo/94_all_genoutput-Accelerate-the-place_operands-function.patch
@@ -0,0 +1,247 @@
+From 6b737d8e61fb341317c2cad4dbd68a9eb156c1d4 Mon Sep 17 00:00:00 2001
+Message-ID: <6b737d8e61fb341317c2cad4dbd68a9eb156c1d4.1754207024.git.sam@gentoo.org>
+From: Xianmiao Qu <cooper.qu@linux.alibaba.com>
+Date: Wed, 22 May 2024 15:25:16 +0800
+Subject: [PATCH 1/3] genoutput: Accelerate the place_operands function.
+
+With the increase in the number of modes and patterns for some
+backend architectures, the place_operands function becomes a
+bottleneck int the speed of genoutput, and may even become a
+bottleneck int the overall speed of building the GCC project.
+This patch aims to accelerate the place_operands function,
+the optimizations it includes are:
+1. Use a hash table to store operand information,
+   improving the lookup time for the first operand.
+2. Move mode comparison to the beginning to avoid the scenarios of most strcmp.
+
+I tested the speed improvements for the following backends,
+	Improvement Ratio
+x86_64	197.9%
+aarch64	954.5%
+riscv	2578.6%
+If the build machine is slow, then this improvement can save a lot of time.
+
+I tested the genoutput output for x86_64/aarch64/riscv backends,
+and there was no difference compared to before the optimization,
+so this shouldn't introduce any functional issues.
+
+gcc/
+	* genoutput.cc (struct operand_data): Add member 'eq_next' to
+	point to the next member with the same hash value in the
+	hash table.
+	(compare_operands): Move the comparison of the mode to the very
+	beginning to accelerate the comparison of the two operands.
+	(struct operand_data_hasher): New, a class that takes into account
+	the necessary elements for comparing the equality of two operands
+	in its hash value.
+	(operand_data_hasher::hash): New.
+	(operand_data_hasher::equal): New.
+	(operand_datas): New, hash table of konwn pattern operands.
+	(place_operands): Use a hash table instead of traversing the array
+	to find the same operand.
+	(main): Add initialization of the hash table 'operand_datas'.
+
+(cherry picked from commit ca7936f7764116a39d785bb087584805072a3461)
+---
+ gcc/genoutput.cc | 111 +++++++++++++++++++++++++++++++++++++----------
+ 1 file changed, 88 insertions(+), 23 deletions(-)
+
+diff --git a/gcc/genoutput.cc b/gcc/genoutput.cc
+index 163e8dfef4ca..b8d41d428028 100644
+--- a/gcc/genoutput.cc
++++ b/gcc/genoutput.cc
+@@ -91,6 +91,7 @@ along with GCC; see the file COPYING3.  If not see
+ #include "errors.h"
+ #include "read-md.h"
+ #include "gensupport.h"
++#include "hash-table.h"
+ 
+ /* No instruction can have more operands than this.  Sorry for this
+    arbitrary limit, but what machine will have an instruction with
+@@ -112,6 +113,8 @@ static int next_operand_number = 1;
+ struct operand_data
+ {
+   struct operand_data *next;
++  /* Point to the next member with the same hash value in the hash table.  */
++  struct operand_data *eq_next;
+   int index;
+   const char *predicate;
+   const char *constraint;
+@@ -127,7 +130,7 @@ struct operand_data
+ 
+ static struct operand_data null_operand =
+ {
+-  0, 0, "", "", E_VOIDmode, 0, 0, 0, 0, 0
++  0, 0, 0, "", "", E_VOIDmode, 0, 0, 0, 0, 0
+ };
+ 
+ static struct operand_data *odata = &null_operand;
+@@ -173,8 +176,8 @@ static void output_operand_data (void);
+ static void output_insn_data (void);
+ static void output_get_insn_name (void);
+ static void scan_operands (class data *, rtx, int, int);
+-static int compare_operands (struct operand_data *,
+-			     struct operand_data *);
++static int compare_operands (const struct operand_data *,
++			     const struct operand_data *);
+ static void place_operands (class data *);
+ static void process_template (class data *, const char *);
+ static void validate_insn_alternatives (class data *);
+@@ -527,10 +530,18 @@ scan_operands (class data *d, rtx part, int this_address_p,
+ /* Compare two operands for content equality.  */
+ 
+ static int
+-compare_operands (struct operand_data *d0, struct operand_data *d1)
++compare_operands (const struct operand_data *d0,
++		  const struct operand_data *d1)
+ {
+   const char *p0, *p1;
+ 
++  /* On one hand, comparing strings for predicate and constraint
++     is time-consuming, and on the other hand, the probability of
++     different modes is relatively high. Therefore, checking the mode
++     first can speed up the execution of the program.  */
++  if (d0->mode != d1->mode)
++    return 0;
++
+   p0 = d0->predicate;
+   if (!p0)
+     p0 = "";
+@@ -549,9 +560,6 @@ compare_operands (struct operand_data *d0, struct operand_data *d1)
+   if (strcmp (p0, p1) != 0)
+     return 0;
+ 
+-  if (d0->mode != d1->mode)
+-    return 0;
+-
+   if (d0->strict_low != d1->strict_low)
+     return 0;
+ 
+@@ -561,6 +569,46 @@ compare_operands (struct operand_data *d0, struct operand_data *d1)
+   return 1;
+ }
+ 
++/* This is a class that takes into account the necessary elements for
++   comparing the equality of two operands in its hash value.  */
++struct operand_data_hasher : nofree_ptr_hash <operand_data>
++{
++  static inline hashval_t hash (const operand_data *);
++  static inline bool equal (const operand_data *, const operand_data *);
++};
++
++hashval_t
++operand_data_hasher::hash (const operand_data * op_info)
++{
++  inchash::hash h;
++  const char *pred, *cons;
++
++  pred = op_info->predicate;
++  if (!pred)
++    pred = "";
++  h.add (pred, strlen (pred) + 1);
++
++  cons = op_info->constraint;
++  if (!cons)
++    cons = "";
++  h.add (cons, strlen (cons) + 1);
++
++  h.add_object (op_info->mode);
++  h.add_object (op_info->strict_low);
++  h.add_object (op_info->eliminable);
++  return h.end ();
++}
++
++bool
++operand_data_hasher::equal (const operand_data * op_info1,
++			    const operand_data * op_info2)
++{
++  return compare_operands (op_info1, op_info2);
++}
++
++/* Hashtable of konwn pattern operands.  */
++static hash_table<operand_data_hasher> *operand_datas;
++
+ /* Scan the list of operands we've already committed to output and either
+    find a subsequence that is the same, or allocate a new one at the end.  */
+ 
+@@ -568,6 +616,7 @@ static void
+ place_operands (class data *d)
+ {
+   struct operand_data *od, *od2;
++  struct operand_data **slot;
+   int i;
+ 
+   if (d->n_operands == 0)
+@@ -576,23 +625,24 @@ place_operands (class data *d)
+       return;
+     }
+ 
++  od = operand_datas->find (&d->operand[0]);
+   /* Brute force substring search.  */
+-  for (od = odata, i = 0; od; od = od->next, i = 0)
+-    if (compare_operands (od, &d->operand[0]))
+-      {
+-	od2 = od->next;
+-	i = 1;
+-	while (1)
+-	  {
+-	    if (i == d->n_operands)
+-	      goto full_match;
+-	    if (od2 == NULL)
+-	      goto partial_match;
+-	    if (! compare_operands (od2, &d->operand[i]))
+-	      break;
+-	    ++i, od2 = od2->next;
+-	  }
+-      }
++  for (; od; od = od->eq_next)
++    {
++      od2 = od->next;
++      i = 1;
++      while (1)
++	{
++	  if (i == d->n_operands)
++	    goto full_match;
++	  if (od2 == NULL)
++	    goto partial_match;
++	  if (! compare_operands (od2, &d->operand[i]))
++	    break;
++	  ++i, od2 = od2->next;
++	}
++    }
++  i = 0;
+ 
+   /* Either partial match at the end of the list, or no match.  In either
+      case, we tack on what operands are remaining to the end of the list.  */
+@@ -604,6 +654,20 @@ place_operands (class data *d)
+       *odata_end = od2;
+       odata_end = &od2->next;
+       od2->index = next_operand_number++;
++      /* Insert the operand_data variable OD2 into the hash table.
++	 If a variable with the same hash value already exists in
++	 the hash table, insert the element at the end of the
++	 linked list connected through the eq_next member.  */
++      slot = operand_datas->find_slot (od2, INSERT);
++      if (*slot)
++	{
++	  struct operand_data *last = (struct operand_data *) *slot;
++	  while (last->eq_next)
++	    last = last->eq_next;
++	  last->eq_next = od2;
++	}
++      else
++	*slot = od2;
+     }
+   *odata_end = NULL;
+   return;
+@@ -1007,6 +1071,7 @@ main (int argc, const char **argv)
+   progname = "genoutput";
+ 
+   init_insn_for_nothing ();
++  operand_datas = new hash_table<operand_data_hasher> (1024);
+ 
+   if (!init_rtx_reader_args (argc, argv))
+     return (FATAL_EXIT_CODE);
+-- 
+2.50.1
+

diff --git a/13.3.0/gentoo/95_all_genemit-Distribute-evenly-to-files-PR111600.patch b/13.3.0/gentoo/95_all_genemit-Distribute-evenly-to-files-PR111600.patch
new file mode 100644
index 0000000..34f1730
--- /dev/null
+++ b/13.3.0/gentoo/95_all_genemit-Distribute-evenly-to-files-PR111600.patch
@@ -0,0 +1,190 @@
+From 1c8da06e0460625beb85da920481248d0cac4325 Mon Sep 17 00:00:00 2001
+Message-ID: <1c8da06e0460625beb85da920481248d0cac4325.1754207024.git.sam@gentoo.org>
+In-Reply-To: <6b737d8e61fb341317c2cad4dbd68a9eb156c1d4.1754207024.git.sam@gentoo.org>
+References: <6b737d8e61fb341317c2cad4dbd68a9eb156c1d4.1754207024.git.sam@gentoo.org>
+From: Robin Dapp <rdapp@ventanamicro.com>
+Date: Thu, 21 Nov 2024 15:34:37 +0100
+Subject: [PATCH 2/3] genemit: Distribute evenly to files [PR111600].
+
+currently we distribute insn patterns in genemit, partitioning them
+by the number of patterns per file.  The first 100 into file 1, the
+next 100 into file 2, and so on.  Depending on the patterns this
+can lead to files of very uneven sizes.
+
+Similar to the genmatch split, this patch introduces a dynamic
+choose_output () which considers the size of the output files
+and selects the shortest one for the next pattern.
+
+gcc/ChangeLog:
+
+	PR target/111600
+
+	* genemit.cc (handle_arg): Use files instead of filenames.
+	(main): Ditto.
+	* gensupport.cc (SIZED_BASED_CHUNKS): Define.
+	(choose_output): New function.
+	* gensupport.h (choose_output): Declare.
+
+(cherry picked from commit 2e6b3308af6ddf87925321ddd2d387bfd352e410)
+---
+ gcc/genemit.cc    | 54 +++++++++++++++--------------------------------
+ gcc/gensupport.cc | 33 +++++++++++++++++++++++++++++
+ gcc/gensupport.h  |  1 +
+ 3 files changed, 51 insertions(+), 37 deletions(-)
+
+diff --git a/gcc/genemit.cc b/gcc/genemit.cc
+index 18c95e3f6412..7da969920303 100644
+--- a/gcc/genemit.cc
++++ b/gcc/genemit.cc
+@@ -896,14 +896,15 @@ from the machine description file `md'.  */\n\n");
+   fprintf (file, "#include \"target.h\"\n\n");
+ }
+ 
+-auto_vec<const char *, 10> output_files;
++auto_vec<FILE *, 10> output_files;
+ 
+ static bool
+ handle_arg (const char *arg)
+ {
+   if (arg[1] == 'O')
+     {
+-      output_files.safe_push (&arg[2]);
++      FILE *file = fopen (&arg[2], "w");
++      output_files.safe_push (file);
+       return true;
+     }
+   return false;
+@@ -924,47 +925,21 @@ main (int argc, const char **argv)
+   /* Assign sequential codes to all entries in the machine description
+      in parallel with the tables in insn-output.cc.  */
+ 
+-  int npatterns = count_patterns ();
+   md_rtx_info info;
+ 
+-  bool to_stdout = false;
+-  int npatterns_per_file = npatterns;
+-  if (!output_files.is_empty ())
+-    npatterns_per_file = npatterns / output_files.length () + 1;
+-  else
+-    to_stdout = true;
+-
+-  gcc_assert (npatterns_per_file > 1);
++  if (output_files.is_empty ())
++    output_files.safe_push (stdout);
+ 
+-  /* Reverse so we can pop the first-added element.  */
+-  output_files.reverse ();
++  for (auto f : output_files)
++    print_header (f);
+ 
+-  int count = 0;
+   FILE *file = NULL;
++  unsigned file_idx;
+ 
+   /* Read the machine description.  */
+   while (read_md_rtx (&info))
+     {
+-      if (count == 0 || count == npatterns_per_file)
+-	{
+-	  bool is_last = !to_stdout && output_files.is_empty ();
+-	  if (file && !is_last)
+-	    if (fclose (file) != 0)
+-	      return FATAL_EXIT_CODE;
+-
+-	  if (!output_files.is_empty ())
+-	    {
+-	      const char *const filename = output_files.pop ();
+-	      file = fopen (filename, "w");
+-	    }
+-	  else if (to_stdout)
+-	    file = stdout;
+-	  else
+-	    break;
+-
+-	  print_header (file);
+-	  count = 0;
+-	}
++      file = choose_output (output_files, file_idx);
+ 
+       switch (GET_CODE (info.def))
+ 	{
+@@ -990,10 +965,10 @@ main (int argc, const char **argv)
+ 	default:
+ 	  break;
+ 	}
+-
+-      count++;
+     }
+ 
++  file = choose_output (output_files, file_idx);
++
+   /* Write out the routines to add CLOBBERs to a pattern and say whether they
+      clobber a hard reg.  */
+   output_add_clobbers (&info, file);
+@@ -1006,5 +981,10 @@ main (int argc, const char **argv)
+       handle_overloaded_gen (oname, file);
+     }
+ 
+-  return (fclose (file) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
++  int ret = SUCCESS_EXIT_CODE;
++  for (FILE *f : output_files)
++    if (fclose (f) != 0)
++      ret = FATAL_EXIT_CODE;
++
++  return ret;
+ }
+diff --git a/gcc/gensupport.cc b/gcc/gensupport.cc
+index f941f76a739f..895d544e0721 100644
+--- a/gcc/gensupport.cc
++++ b/gcc/gensupport.cc
+@@ -3369,3 +3369,36 @@ find_optab (optab_pattern *p, const char *name)
+     }
+   return false;
+ }
++
++/* Find the file to write into next.  We try to evenly distribute the contents
++   over the different files.  */
++
++#define SIZED_BASED_CHUNKS 1
++
++FILE *
++choose_output (const vec<FILE *> &parts, unsigned &idx)
++{
++  if (parts.length () == 0)
++    gcc_unreachable ();
++#ifdef SIZED_BASED_CHUNKS
++  FILE *shortest = NULL;
++  long min = 0;
++  idx = 0;
++  for (unsigned i = 0; i < parts.length (); i++)
++    {
++      FILE *part  = parts[i];
++      long len = ftell (part);
++      if (!shortest || min > len)
++	{
++	  shortest = part;
++	  min = len;
++	  idx = i;
++       }
++    }
++  return shortest;
++#else
++  static int current_file;
++  idx = current_file++ % parts.length ();
++  return parts[idx];
++#endif
++}
+diff --git a/gcc/gensupport.h b/gcc/gensupport.h
+index 510ba19405e4..fb0506aba559 100644
+--- a/gcc/gensupport.h
++++ b/gcc/gensupport.h
+@@ -225,5 +225,6 @@ extern file_location get_file_location (rtx);
+ extern const char *get_emit_function (rtx);
+ extern bool needs_barrier_p (rtx);
+ extern bool find_optab (optab_pattern *, const char *);
++extern FILE *choose_output (const vec<FILE *> &, unsigned &);
+ 
+ #endif /* GCC_GENSUPPORT_H */
+-- 
+2.50.1
+

diff --git a/13.3.0/gentoo/96_all_genrecog-Split-into-separate-partitions-PR111600.patch b/13.3.0/gentoo/96_all_genrecog-Split-into-separate-partitions-PR111600.patch
new file mode 100644
index 0000000..5834925
--- /dev/null
+++ b/13.3.0/gentoo/96_all_genrecog-Split-into-separate-partitions-PR111600.patch
@@ -0,0 +1,1360 @@
+From e90ec925b65660ab853120d77b699dc17c8a9814 Mon Sep 17 00:00:00 2001
+Message-ID: <e90ec925b65660ab853120d77b699dc17c8a9814.1754207024.git.sam@gentoo.org>
+In-Reply-To: <6b737d8e61fb341317c2cad4dbd68a9eb156c1d4.1754207024.git.sam@gentoo.org>
+References: <6b737d8e61fb341317c2cad4dbd68a9eb156c1d4.1754207024.git.sam@gentoo.org>
+From: Robin Dapp <rdapp.gcc@gmail.com>
+Date: Tue, 26 Nov 2024 14:44:17 +0100
+Subject: [PATCH 3/3] genrecog: Split into separate partitions [PR111600].
+
+Hi,
+
+this patch makes genrecog split its output into separate files (10 by
+default) in the same vein genemit does.  The changes are mostly
+mechanical again, changing printfs and puts to fprintf.
+As insn-recog.cc relies on being able to call other recog functions a
+header insn-recog.h is introduced that pre declares all of those.
+
+For simplicity the number of files is determined by (re-using)
+--with-insnemit-partitions.  Naming suggestions welcome :)
+
+Bootstrapped and regtested on x86 and power10, regtested on riscv.
+aarch64 bootstrap is currently blocked because of the
+"maybe uninitialized" issue discussed on IRC.
+
+Regards
+ Robin
+
+gcc/ChangeLog:
+
+* Makefile.in:  Add insn-recog split.
+	* configure.ac: Document that the number of insnemit partitions is
+	used for insn-recog as well.
+	* genconditions.cc (write_one_condition): Use fprintf.
+	* genpreds.cc (write_predicate_expr): Ditto.
+	(write_init_reg_class_start_regs): Ditto.
+	* genrecog.cc (write_header): Add header file to includes.
+	(printf_indent): Use fprintf.
+	(change_state): Ditto.
+	(print_code): Ditto.
+	(print_host_wide_int): Ditto.
+	(print_parameter_value): Ditto.
+	(print_test_rtx): Ditto.
+	(print_nonbool_test): Ditto.
+	(print_label_value): Ditto.
+	(print_test): Ditto.
+	(print_decision): Ditto.
+	(print_state): Ditto.
+	(print_subroutine_call): Ditto.
+	(print_acceptance): Ditto.
+	(print_subroutine_start): Ditto.
+	(print_pattern): Ditto.
+	(print_subroutine): Ditto.
+	(print_subroutine_group): Ditto.
+	(handle_arg): Add -O and -H for output and header file handling.
+	(main): Use callback.
+	* gentarget-def.cc (def_target_insn): Use fprintf.
+	* read-md.cc (md_reader::print_c_condition): Ditto.
+	* read-md.h (class md_reader): Ditto.
+---
+ gcc/Makefile.in      |  29 ++-
+ gcc/configure.ac     |   4 +-
+ gcc/genconditions.cc |   4 +-
+ gcc/genpreds.cc      |   2 +-
+ gcc/genrecog.cc      | 552 +++++++++++++++++++++++++------------------
+ gcc/gentarget-def.cc |   2 +-
+ gcc/read-md.cc       |   4 +-
+ gcc/read-md.h        |   2 +-
+ 8 files changed, 357 insertions(+), 242 deletions(-)
+
+diff --git a/gcc/Makefile.in b/gcc/Makefile.in
+index 41abe03f7948..8b197a1e3f4a 100644
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -239,6 +239,12 @@ INSNEMIT_SEQ_SRC = $(patsubst %, insn-emit-%.cc, $(INSNEMIT_SPLITS_SEQ))
+ INSNEMIT_SEQ_TMP = $(patsubst %, tmp-emit-%.cc, $(INSNEMIT_SPLITS_SEQ))
+ INSNEMIT_SEQ_O = $(patsubst %, insn-emit-%.o, $(INSNEMIT_SPLITS_SEQ))
+ 
++# Re-use the split number for insn-recog as well.
++INSNRECOG_SPLITS_SEQ = $(wordlist 1,$(NUM_INSNEMIT_SPLITS),$(one_to_9999))
++INSNRECOG_SEQ_SRC = $(patsubst %, insn-recog-%.cc, $(INSNRECOG_SPLITS_SEQ))
++INSNRECOG_SEQ_TMP = $(patsubst %, tmp-recog-%.cc, $(INSNRECOG_SPLITS_SEQ))
++INSNRECOG_SEQ_O = $(patsubst %, insn-recog-%.o, $(INSNRECOG_SPLITS_SEQ))
++
+ # These files are to have specific diagnostics suppressed, or are not to
+ # be subject to -Werror:
+ # flex output may yield harmless "no previous prototype" warnings
+@@ -1350,7 +1356,7 @@ OBJS = \
+ 	insn-output.o \
+ 	insn-peep.o \
+ 	insn-preds.o \
+-	insn-recog.o \
++	$(INSNRECOG_SEQ_O) \
+ 	insn-enums.o \
+ 	ggc-page.o \
+ 	adjust-alignment.o \
+@@ -1829,8 +1835,8 @@ TREECHECKING = @TREECHECKING@
+ FULL_DRIVER_NAME=$(target_noncanonical)-gcc-$(version)$(exeext)
+ 
+ MOSTLYCLEANFILES = insn-flags.h insn-config.h insn-codes.h \
+- insn-output.cc insn-recog.cc $(INSNEMIT_SEQ_SRC) \
+- insn-extract.cc insn-peep.cc \
++ insn-output.cc $(INSNRECOG_SEQ_SRC) insn-recog.h \
++ $(INSNEMIT_SEQ_SRC) insn-extract.cc insn-peep.cc \
+  insn-attr.h insn-attr-common.h insn-attrtab.cc insn-dfatab.cc \
+  insn-latencytab.cc insn-opinit.cc insn-opinit.h insn-preds.cc insn-constants.h \
+  tm-preds.h tm-constrs.h checksum-options $(GIMPLE_MATCH_PD_SEQ_SRC) \
+@@ -2447,7 +2453,8 @@ $(common_out_object_file): $(common_out_file)
+ # and compile them.
+ 
+ .PRECIOUS: insn-config.h insn-flags.h insn-codes.h insn-constants.h \
+-  $(INSNEMIT_SEQ_SRC) insn-recog.cc insn-extract.cc insn-output.cc \
++  $(INSNEMIT_SEQ_SRC) insn-recog.h $(INSNRECOG_SEQ_SRC) \
++  insn-extract.cc insn-output.cc \
+   insn-peep.cc insn-attr.h insn-attr-common.h insn-attrtab.cc \
+   insn-dfatab.cc insn-latencytab.cc insn-preds.cc \
+   $(GIMPLE_MATCH_PD_SEQ_SRC) $(GENERIC_MATCH_PD_SEQ_SRC) \
+@@ -2476,7 +2483,7 @@ simple_rtl_generated_h	= insn-attr.h insn-attr-common.h insn-codes.h \
+ 
+ simple_rtl_generated_c	= insn-automata.cc \
+ 			  insn-extract.cc insn-output.cc \
+-			  insn-peep.cc insn-recog.cc
++			  insn-peep.cc
+ 
+ simple_generated_h	= $(simple_rtl_generated_h) insn-constants.h
+ 
+@@ -2514,6 +2521,18 @@ s-tmp-emit: build/genemit$(build_exeext) $(MD_DEPS) insn-conditions.md
+ 	  insn-emit-$(id).cc;)
+ 	$(STAMP) s-tmp-emit
+ 
++# Same for genrecog.
++$(INSNRECOG_SEQ_SRC): s-tmp-recog; @true
++insn-recog.h: s-tmp-recog; @true
++s-tmp-recog: build/genrecog$(build_exeext) $(MD_DEPS) insn-conditions.md
++	$(RUN_GEN) build/genrecog$(build_exeext) $(md_file) insn-conditions.md \
++	  -Hinsn-recog.h \
++	  $(addprefix -O,${INSNRECOG_SEQ_TMP})
++	$(foreach id, $(INSNRECOG_SPLITS_SEQ), \
++	  $(SHELL) $(srcdir)/../move-if-change tmp-recog-$(id).cc \
++	  insn-recog-$(id).cc;)
++	$(STAMP) s-tmp-recog
++
+ # gencheck doesn't read the machine description, and the file produced
+ # doesn't use the insn-* convention.
+ 
+diff --git a/gcc/configure.ac b/gcc/configure.ac
+index 1a89f3058f73..12f7d9814889 100644
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -949,10 +949,10 @@ fi
+ 
+ AC_SUBST(DEFAULT_MATCHPD_PARTITIONS)
+ 
+-# Specify the number of splits of insn-emit.cc to generate.
++# Specify the number of splits of insn-emit.cc and insn-recog.cc to generate.
+ AC_ARG_WITH(insnemit-partitions,
+ [AS_HELP_STRING([--with-insnemit-partitions=num],
+-[Set the number of partitions of insn-emit.cc for genemit to create. [default=10]])],
++[Set the number of partitions of insn-emit.cc for genemit and genrecog to create. [default=10]])],
+ [DEFAULT_INSNEMIT_PARTITIONS="$with_insnemit_partitions"], [DEFAULT_INSNEMIT_PARTITIONS=10])
+ if (test $DEFAULT_INSNEMIT_PARTITIONS -lt 1); then
+   AC_MSG_ERROR(m4_normalize([
+diff --git a/gcc/genconditions.cc b/gcc/genconditions.cc
+index 28655fa44706..caa1783ccc65 100644
+--- a/gcc/genconditions.cc
++++ b/gcc/genconditions.cc
+@@ -141,9 +141,9 @@ write_one_condition (void **slot, void * ARG_UNUSED (dummy))
+     }
+ 
+   fputs ("\",\n    __builtin_constant_p ", stdout);
+-  rtx_reader_ptr->print_c_condition (test->expr);
++  rtx_reader_ptr->print_c_condition (stdout, test->expr);
+   fputs ("\n    ? (int) ", stdout);
+-  rtx_reader_ptr->print_c_condition (test->expr);
++  rtx_reader_ptr->print_c_condition (stdout, test->expr);
+   fputs ("\n    : -1 },\n", stdout);
+   return 1;
+ }
+diff --git a/gcc/genpreds.cc b/gcc/genpreds.cc
+index bdd65ef7d7a1..bc01b0fd7a91 100644
+--- a/gcc/genpreds.cc
++++ b/gcc/genpreds.cc
+@@ -538,7 +538,7 @@ write_predicate_expr (rtx exp)
+       break;
+ 
+     case MATCH_TEST:
+-      rtx_reader_ptr->print_c_condition (XSTR (exp, 0));
++      rtx_reader_ptr->print_c_condition (stdout, XSTR (exp, 0));
+       break;
+ 
+     default:
+diff --git a/gcc/genrecog.cc b/gcc/genrecog.cc
+index 6dd375da5e35..17358652b99b 100644
+--- a/gcc/genrecog.cc
++++ b/gcc/genrecog.cc
+@@ -4255,9 +4255,9 @@ match_pattern (state *s, md_rtx_info *info, rtx pattern,
+ /* Begin the output file.  */
+ 
+ static void
+-write_header (void)
++write_header (FILE *f, const char *header_filename)
+ {
+-  puts ("\
++  fprintf (f, "%s", "\
+ /* Generated automatically by the program `genrecog' from the target\n\
+    machine description file.  */\n\
+ \n\
+@@ -4281,10 +4281,12 @@ write_header (void)
+ #include \"diagnostic-core.h\"\n\
+ #include \"reload.h\"\n\
+ #include \"regs.h\"\n\
+-#include \"tm-constrs.h\"\n\
+-\n");
++#include \"tm-constrs.h\"\n");
+ 
+-  puts ("\n\
++  fprintf (f, "#include \"%s\"\n", header_filename);
++  fprintf (f, "%s", "\n");
++
++  fprintf (f, "%s", "\n\
+ /* `recog' contains a decision tree that recognizes whether the rtx\n\
+    X0 is a valid instruction.\n\
+ \n\
+@@ -4293,19 +4295,19 @@ write_header (void)
+    pattern that matched.  This is the same as the order in the machine\n\
+    description of the entry that matched.  This number can be used as an\n\
+    index into `insn_data' and other tables.\n");
+-  puts ("\
++  fprintf (f, "%s", "\
+    The third parameter to recog is an optional pointer to an int.  If\n\
+    present, recog will accept a pattern if it matches except for missing\n\
+    CLOBBER expressions at the end.  In that case, the value pointed to by\n\
+    the optional pointer will be set to the number of CLOBBERs that need\n\
+    to be added (it should be initialized to zero by the caller).  If it");
+-  puts ("\
++  fprintf (f, "%s", "\
+    is set nonzero, the caller should allocate a PARALLEL of the\n\
+    appropriate size, copy the initial entries, and call add_clobbers\n\
+    (found in insn-emit.cc) to fill in the CLOBBERs.\n\
+ ");
+ 
+-  puts ("\n\
++  fprintf (f, "%s", "\n\
+    The function split_insns returns 0 if the rtl could not\n\
+    be split or the split rtl as an INSN list if it can be.\n\
+ \n\
+@@ -4463,13 +4465,13 @@ test_position_available_p (output_state *os, const rtx_test &test)
+ 
+ /* Like printf, but print INDENT spaces at the beginning.  */
+ 
+-static void ATTRIBUTE_PRINTF_2
+-printf_indent (unsigned int indent, const char *format, ...)
++static void ATTRIBUTE_PRINTF_3
++printf_indent (FILE *f, unsigned int indent, const char *format, ...)
+ {
+   va_list ap;
+   va_start (ap, format);
+-  printf ("%*s", indent, "");
+-  vprintf (format, ap);
++  fprintf (f, "%*s", indent, "");
++  vfprintf (f, format, ap);
+   va_end (ap);
+ }
+ 
+@@ -4478,7 +4480,7 @@ printf_indent (unsigned int indent, const char *format, ...)
+    OS with the new state.  */
+ 
+ static void
+-change_state (output_state *os, position *pos, unsigned int indent)
++change_state (FILE *f, output_state *os, position *pos, unsigned int indent)
+ {
+   unsigned int var = os->id_to_var[pos->id];
+   gcc_assert (var < os->var_to_id.length () && os->var_to_id[var] == pos->id);
+@@ -4487,19 +4489,19 @@ change_state (output_state *os, position *pos, unsigned int indent)
+   switch (pos->type)
+     {
+     case POS_PEEP2_INSN:
+-      printf_indent (indent, "x%d = PATTERN (peep2_next_insn (%d));\n",
++      printf_indent (f, indent, "x%d = PATTERN (peep2_next_insn (%d));\n",
+ 		     var, pos->arg);
+       break;
+ 
+     case POS_XEXP:
+-      change_state (os, pos->base, indent);
+-      printf_indent (indent, "x%d = XEXP (x%d, %d);\n",
++      change_state (f, os, pos->base, indent);
++      printf_indent (f, indent, "x%d = XEXP (x%d, %d);\n",
+ 		     var, os->id_to_var[pos->base->id], pos->arg);
+       break;
+ 
+     case POS_XVECEXP0:
+-      change_state (os, pos->base, indent);
+-      printf_indent (indent, "x%d = XVECEXP (x%d, 0, %d);\n",
++      change_state (f, os, pos->base, indent);
++      printf_indent (f, indent, "x%d = XVECEXP (x%d, 0, %d);\n",
+ 		     var, os->id_to_var[pos->base->id], pos->arg);
+       break;
+     }
+@@ -4510,11 +4512,11 @@ change_state (output_state *os, position *pos, unsigned int indent)
+    the name.  */
+ 
+ static void
+-print_code (enum rtx_code code)
++print_code (FILE *f, enum rtx_code code)
+ {
+   const char *p;
+   for (p = GET_RTX_NAME (code); *p; p++)
+-    putchar (TOUPPER (*p));
++    fprintf (f, "%c", TOUPPER (*p));
+ }
+ 
+ /* Emit a uint64_t as an integer constant expression.  We need to take
+@@ -4522,22 +4524,22 @@ print_code (enum rtx_code code)
+    warnings in the resulting code.  */
+ 
+ static void
+-print_host_wide_int (uint64_t val)
++print_host_wide_int (FILE *f, uint64_t val)
+ {
+   uint64_t min = uint64_t (1) << (HOST_BITS_PER_WIDE_INT - 1);
+   if (val == min)
+-    printf ("(" HOST_WIDE_INT_PRINT_DEC_C " - 1)", val + 1);
++    fprintf (f, "(" HOST_WIDE_INT_PRINT_DEC_C " - 1)", val + 1);
+   else
+-    printf (HOST_WIDE_INT_PRINT_DEC_C, val);
++    fprintf (f, HOST_WIDE_INT_PRINT_DEC_C, val);
+ }
+ 
+ /* Print the C expression for actual parameter PARAM.  */
+ 
+ static void
+-print_parameter_value (const parameter &param)
++print_parameter_value (FILE *f, const parameter &param)
+ {
+   if (param.is_param)
+-    printf ("i%d", (int) param.value + 1);
++    fprintf (f, "i%d", (int) param.value + 1);
+   else
+     switch (param.type)
+       {
+@@ -4546,23 +4548,23 @@ print_parameter_value (const parameter &param)
+ 	break;
+ 
+       case parameter::CODE:
+-	print_code ((enum rtx_code) param.value);
++	print_code (f, (enum rtx_code) param.value);
+ 	break;
+ 
+       case parameter::MODE:
+-	printf ("E_%smode", GET_MODE_NAME ((machine_mode) param.value));
++	fprintf (f, "E_%smode", GET_MODE_NAME ((machine_mode) param.value));
+ 	break;
+ 
+       case parameter::INT:
+-	printf ("%d", (int) param.value);
++	fprintf (f, "%d", (int) param.value);
+ 	break;
+ 
+       case parameter::UINT:
+-	printf ("%u", (unsigned int) param.value);
++	fprintf (f, "%u", (unsigned int) param.value);
+ 	break;
+ 
+       case parameter::WIDE_INT:
+-	print_host_wide_int (param.value);
++	print_host_wide_int (f, param.value);
+ 	break;
+       }
+ }
+@@ -4570,90 +4572,90 @@ print_parameter_value (const parameter &param)
+ /* Print the C expression for the rtx tested by TEST.  */
+ 
+ static void
+-print_test_rtx (output_state *os, const rtx_test &test)
++print_test_rtx (FILE *f, output_state *os, const rtx_test &test)
+ {
+   if (test.pos_operand >= 0)
+-    printf ("operands[%d]", test.pos_operand);
++    fprintf (f, "operands[%d]", test.pos_operand);
+   else
+-    printf ("x%d", os->id_to_var[test.pos->id]);
++    fprintf (f, "x%d", os->id_to_var[test.pos->id]);
+ }
+ 
+ /* Print the C expression for non-boolean test TEST.  */
+ 
+ static void
+-print_nonbool_test (output_state *os, const rtx_test &test)
++print_nonbool_test (FILE *f, output_state *os, const rtx_test &test)
+ {
+   switch (test.kind)
+     {
+     case rtx_test::CODE:
+-      printf ("GET_CODE (");
+-      print_test_rtx (os, test);
+-      printf (")");
++      fprintf (f, "GET_CODE (");
++      print_test_rtx (f, os, test);
++      fprintf (f, ")");
+       break;
+ 
+     case rtx_test::MODE:
+-      printf ("GET_MODE (");
+-      print_test_rtx (os, test);
+-      printf (")");
++      fprintf (f, "GET_MODE (");
++      print_test_rtx (f, os, test);
++      fprintf (f, ")");
+       break;
+ 
+     case rtx_test::VECLEN:
+-      printf ("XVECLEN (");
+-      print_test_rtx (os, test);
+-      printf (", 0)");
++      fprintf (f, "XVECLEN (");
++      print_test_rtx (f, os, test);
++      fprintf (f, ", 0)");
+       break;
+ 
+     case rtx_test::INT_FIELD:
+-      printf ("XINT (");
+-      print_test_rtx (os, test);
+-      printf (", %d)", test.u.opno);
++      fprintf (f, "XINT (");
++      print_test_rtx (f, os, test);
++      fprintf (f, ", %d)", test.u.opno);
+       break;
+ 
+     case rtx_test::REGNO_FIELD:
+-      printf ("REGNO (");
+-      print_test_rtx (os, test);
+-      printf (")");
++      fprintf (f, "REGNO (");
++      print_test_rtx (f, os, test);
++      fprintf (f, ")");
+       break;
+ 
+     case rtx_test::SUBREG_FIELD:
+-      printf ("SUBREG_BYTE (");
+-      print_test_rtx (os, test);
+-      printf (")");
++      fprintf (f, "SUBREG_BYTE (");
++      print_test_rtx (f, os, test);
++      fprintf (f, ")");
+       break;
+ 
+     case rtx_test::WIDE_INT_FIELD:
+-      printf ("XWINT (");
+-      print_test_rtx (os, test);
+-      printf (", %d)", test.u.opno);
++      fprintf (f, "XWINT (");
++      print_test_rtx (f, os, test);
++      fprintf (f, ", %d)", test.u.opno);
+       break;
+ 
+     case rtx_test::PATTERN:
+       {
+ 	pattern_routine *routine = test.u.pattern->routine;
+-	printf ("pattern%d (", routine->pattern_id);
++	fprintf (f, "pattern%d (", routine->pattern_id);
+ 	const char *sep = "";
+ 	if (test.pos)
+ 	  {
+-	    print_test_rtx (os, test);
++	    print_test_rtx (f, os, test);
+ 	    sep = ", ";
+ 	  }
+ 	if (routine->insn_p)
+ 	  {
+-	    printf ("%sinsn", sep);
++	    fprintf (f, "%sinsn", sep);
+ 	    sep = ", ";
+ 	  }
+ 	if (routine->pnum_clobbers_p)
+ 	  {
+-	    printf ("%spnum_clobbers", sep);
++	    fprintf (f, "%spnum_clobbers", sep);
+ 	    sep = ", ";
+ 	  }
+ 	for (unsigned int i = 0; i < test.u.pattern->params.length (); ++i)
+ 	  {
+-	    fputs (sep, stdout);
+-	    print_parameter_value (test.u.pattern->params[i]);
++	    fprintf (f, "%s\n", sep);
++	    print_parameter_value (f, test.u.pattern->params[i]);
+ 	    sep = ", ";
+ 	  }
+-	printf (")");
++	fprintf (f, ")");
+ 	break;
+       }
+ 
+@@ -4674,10 +4676,11 @@ print_nonbool_test (output_state *os, const rtx_test &test)
+    decision performs TEST.  Print the C code for the label.  */
+ 
+ static void
+-print_label_value (const rtx_test &test, bool is_param, uint64_t value)
++print_label_value (FILE *f, const rtx_test &test, bool is_param,
++		   uint64_t value)
+ {
+-  print_parameter_value (parameter (transition_parameter_type (test.kind),
+-				    is_param, value));
++  print_parameter_value (f, parameter (transition_parameter_type (test.kind),
++				       is_param, value));
+ }
+ 
+ /* If IS_PARAM, print code to compare TEST with the C variable i<VALUE+1>.
+@@ -4685,7 +4688,7 @@ print_label_value (const rtx_test &test, bool is_param, uint64_t value)
+    Test for inequality if INVERT_P, otherwise test for equality.  */
+ 
+ static void
+-print_test (output_state *os, const rtx_test &test, bool is_param,
++print_test (FILE *f, output_state *os, const rtx_test &test, bool is_param,
+ 	    uint64_t value, bool invert_p)
+ {
+   switch (test.kind)
+@@ -4698,71 +4701,71 @@ print_test (output_state *os, const rtx_test &test, bool is_param,
+     case rtx_test::INT_FIELD:
+     case rtx_test::WIDE_INT_FIELD:
+     case rtx_test::PATTERN:
+-      print_nonbool_test (os, test);
+-      printf (" %s ", invert_p ? "!=" : "==");
+-      print_label_value (test, is_param, value);
++      print_nonbool_test (f, os, test);
++      fprintf (f, " %s ", invert_p ? "!=" : "==");
++      print_label_value (f, test, is_param, value);
+       break;
+ 
+     case rtx_test::SUBREG_FIELD:
+-      printf ("%s (", invert_p ? "maybe_ne" : "known_eq");
+-      print_nonbool_test (os, test);
+-      printf (", ");
+-      print_label_value (test, is_param, value);
+-      printf (")");
++      fprintf (f, "%s (", invert_p ? "maybe_ne" : "known_eq");
++      print_nonbool_test (f, os, test);
++      fprintf (f, ", ");
++      print_label_value (f, test, is_param, value);
++      fprintf (f, ")");
+       break;
+ 
+     case rtx_test::SAVED_CONST_INT:
+       gcc_assert (!is_param && value == 1);
+-      print_test_rtx (os, test);
+-      printf (" %s const_int_rtx[MAX_SAVED_CONST_INT + ",
+-	      invert_p ? "!=" : "==");
+-      print_parameter_value (parameter (parameter::INT,
+-					test.u.integer.is_param,
+-					test.u.integer.value));
+-      printf ("]");
++      print_test_rtx (f, os, test);
++      fprintf (f, " %s const_int_rtx[MAX_SAVED_CONST_INT + ",
++	       invert_p ? "!=" : "==");
++      print_parameter_value (f, parameter (parameter::INT,
++					   test.u.integer.is_param,
++					   test.u.integer.value));
++      fprintf (f, "]");
+       break;
+ 
+     case rtx_test::PEEP2_COUNT:
+       gcc_assert (!is_param && value == 1);
+-      printf ("peep2_current_count %s %d", invert_p ? "<" : ">=",
+-	      test.u.min_len);
++      fprintf (f, "peep2_current_count %s %d", invert_p ? "<" : ">=",
++	       test.u.min_len);
+       break;
+ 
+     case rtx_test::VECLEN_GE:
+       gcc_assert (!is_param && value == 1);
+-      printf ("XVECLEN (");
+-      print_test_rtx (os, test);
+-      printf (", 0) %s %d", invert_p ? "<" : ">=", test.u.min_len);
++      fprintf (f, "XVECLEN (");
++      print_test_rtx (f, os, test);
++      fprintf (f, ", 0) %s %d", invert_p ? "<" : ">=", test.u.min_len);
+       break;
+ 
+     case rtx_test::PREDICATE:
+       gcc_assert (!is_param && value == 1);
+-      printf ("%s%s (", invert_p ? "!" : "", test.u.predicate.data->name);
+-      print_test_rtx (os, test);
+-      printf (", ");
+-      print_parameter_value (parameter (parameter::MODE,
+-					test.u.predicate.mode_is_param,
+-					test.u.predicate.mode));
+-      printf (")");
++      fprintf (f, "%s%s (", invert_p ? "!" : "", test.u.predicate.data->name);
++      print_test_rtx (f, os, test);
++      fprintf (f, ", ");
++      print_parameter_value (f, parameter (parameter::MODE,
++					   test.u.predicate.mode_is_param,
++					   test.u.predicate.mode));
++      fprintf (f, ")");
+       break;
+ 
+     case rtx_test::DUPLICATE:
+       gcc_assert (!is_param && value == 1);
+-      printf ("%srtx_equal_p (", invert_p ? "!" : "");
+-      print_test_rtx (os, test);
+-      printf (", operands[%d])", test.u.opno);
++      fprintf (f, "%srtx_equal_p (", invert_p ? "!" : "");
++      print_test_rtx (f, os, test);
++      fprintf (f, ", operands[%d])", test.u.opno);
+       break;
+ 
+     case rtx_test::HAVE_NUM_CLOBBERS:
+       gcc_assert (!is_param && value == 1);
+-      printf ("pnum_clobbers %s NULL", invert_p ? "==" : "!=");
++      fprintf (f, "pnum_clobbers %s NULL", invert_p ? "==" : "!=");
+       break;
+ 
+     case rtx_test::C_TEST:
+       gcc_assert (!is_param && value == 1);
+       if (invert_p)
+-	printf ("!");
+-      rtx_reader_ptr->print_c_condition (test.u.string);
++	fprintf (f, "!");
++      rtx_reader_ptr->print_c_condition (f, test.u.string);
+       break;
+ 
+     case rtx_test::ACCEPT:
+@@ -4771,7 +4774,7 @@ print_test (output_state *os, const rtx_test &test, bool is_param,
+     }
+ }
+ 
+-static exit_state print_decision (output_state *, decision *,
++static exit_state print_decision (FILE *f, output_state *, decision *,
+ 				  unsigned int, bool);
+ 
+ /* Print code to perform S, indent each line by INDENT spaces.
+@@ -4779,14 +4782,15 @@ static exit_state print_decision (output_state *, decision *,
+    if the state fails then the entire routine fails.  */
+ 
+ static exit_state
+-print_state (output_state *os, state *s, unsigned int indent, bool is_final)
++print_state (FILE *f, output_state *os, state *s, unsigned int indent,
++	     bool is_final)
+ {
+   exit_state es = ES_FALLTHROUGH;
+   for (decision *d = s->first; d; d = d->next)
+-    es = print_decision (os, d, indent, is_final && !d->next);
++    es = print_decision (f, os, d, indent, is_final && !d->next);
+   if (es != ES_RETURNED && is_final)
+     {
+-      printf_indent (indent, "return %s;\n", get_failure_return (os->type));
++      printf_indent (f, indent, "return %s;\n", get_failure_return (os->type));
+       es = ES_RETURNED;
+     }
+   return es;
+@@ -4797,7 +4801,7 @@ print_state (output_state *os, state *s, unsigned int indent, bool is_final)
+    match.  */
+ 
+ static const char *
+-print_subroutine_call (const acceptance_type &acceptance)
++print_subroutine_call (FILE *f, const acceptance_type &acceptance)
+ {
+   switch (acceptance.type)
+     {
+@@ -4805,17 +4809,17 @@ print_subroutine_call (const acceptance_type &acceptance)
+       gcc_unreachable ();
+ 
+     case RECOG:
+-      printf ("recog_%d (x1, insn, pnum_clobbers)",
+-	      acceptance.u.subroutine_id);
++      fprintf (f, "recog_%d (x1, insn, pnum_clobbers)",
++	       acceptance.u.subroutine_id);
+       return ">= 0";
+ 
+     case SPLIT:
+-      printf ("split_%d (x1, insn)", acceptance.u.subroutine_id);
++      fprintf (f, "split_%d (x1, insn)", acceptance.u.subroutine_id);
+       return "!= NULL_RTX";
+ 
+     case PEEPHOLE2:
+-      printf ("peephole2_%d (x1, insn, pmatch_len_)",
+-	      acceptance.u.subroutine_id);
++      fprintf (f, "peephole2_%d (x1, insn, pmatch_len_)",
++	       acceptance.u.subroutine_id);
+       return "!= NULL_RTX";
+     }
+   gcc_unreachable ();
+@@ -4825,63 +4829,65 @@ print_subroutine_call (const acceptance_type &acceptance)
+    INDENT and IS_FINAL are as for print_state.  */
+ 
+ static exit_state
+-print_acceptance (const acceptance_type &acceptance, unsigned int indent,
+-		  bool is_final)
++print_acceptance (FILE *f, const acceptance_type &acceptance,
++		  unsigned int indent, bool is_final)
+ {
+   if (acceptance.partial_p)
+     {
+       /* Defer the rest of the match to a subroutine.  */
+       if (is_final)
+ 	{
+-	  printf_indent (indent, "return ");
+-	  print_subroutine_call (acceptance);
+-	  printf (";\n");
++	  printf_indent (f, indent, "return ");
++	  print_subroutine_call (f, acceptance);
++	  fprintf (f, ";\n");
+ 	  return ES_RETURNED;
+ 	}
+       else
+ 	{
+-	  printf_indent (indent, "res = ");
+-	  const char *res_test = print_subroutine_call (acceptance);
+-	  printf (";\n");
+-	  printf_indent (indent, "if (res %s)\n", res_test);
+-	  printf_indent (indent + 2, "return res;\n");
++	  printf_indent (f, indent, "res = ");
++	  const char *res_test = print_subroutine_call (f, acceptance);
++	  fprintf (f, ";\n");
++	  printf_indent (f, indent, "if (res %s)\n", res_test);
++	  printf_indent (f, indent + 2, "return res;\n");
+ 	  return ES_FALLTHROUGH;
+ 	}
+     }
+   switch (acceptance.type)
+     {
+     case SUBPATTERN:
+-      printf_indent (indent, "return %d;\n", acceptance.u.full.code);
++      printf_indent (f, indent, "return %d;\n", acceptance.u.full.code);
+       return ES_RETURNED;
+ 
+     case RECOG:
+       if (acceptance.u.full.u.num_clobbers != 0)
+-	printf_indent (indent, "*pnum_clobbers = %d;\n",
++	printf_indent (f, indent, "*pnum_clobbers = %d;\n",
+ 		       acceptance.u.full.u.num_clobbers);
+-      printf_indent (indent, "return %d; /* %s */\n", acceptance.u.full.code,
++      printf_indent (f, indent, "return %d; /* %s */\n", acceptance.u.full.code,
+ 		     get_insn_name (acceptance.u.full.code));
+       return ES_RETURNED;
+ 
+     case SPLIT:
+-      printf_indent (indent, "return gen_split_%d (insn, operands);\n",
++      printf_indent (f, indent, "return gen_split_%d (insn, operands);\n",
+ 		     acceptance.u.full.code);
+       return ES_RETURNED;
+ 
+     case PEEPHOLE2:
+-      printf_indent (indent, "*pmatch_len_ = %d;\n",
++      printf_indent (f, indent, "*pmatch_len_ = %d;\n",
+ 		     acceptance.u.full.u.match_len);
+       if (is_final)
+ 	{
+-	  printf_indent (indent, "return gen_peephole2_%d (insn, operands);\n",
++	  printf_indent (f, indent,
++			 "return gen_peephole2_%d (insn, operands);\n",
+ 			 acceptance.u.full.code);
+ 	  return ES_RETURNED;
+ 	}
+       else
+ 	{
+-	  printf_indent (indent, "res = gen_peephole2_%d (insn, operands);\n",
++	  printf_indent (f,
++			 indent, "res = gen_peephole2_%d (insn, operands);\n",
+ 			 acceptance.u.full.code);
+-	  printf_indent (indent, "if (res != NULL_RTX)\n");
+-	  printf_indent (indent + 2, "return res;\n");
++	  printf_indent (f, indent, "if (res != NULL_RTX)\n");
++	  printf_indent (f, indent + 2, "return res;\n");
+ 	  return ES_FALLTHROUGH;
+ 	}
+     }
+@@ -4891,7 +4897,7 @@ print_acceptance (const acceptance_type &acceptance, unsigned int indent,
+ /* Print code to perform D.  INDENT and IS_FINAL are as for print_state.  */
+ 
+ static exit_state
+-print_decision (output_state *os, decision *d, unsigned int indent,
++print_decision (FILE *f, output_state *os, decision *d, unsigned int indent,
+ 		bool is_final)
+ {
+   uint64_t label;
+@@ -4900,7 +4906,7 @@ print_decision (output_state *os, decision *d, unsigned int indent,
+   /* Make sure the rtx under test is available either in operands[] or
+      in an xN variable.  */
+   if (d->test.pos && d->test.pos_operand < 0)
+-    change_state (os, d->test.pos, indent);
++    change_state (f, os, d->test.pos, indent);
+ 
+   /* Look for cases where a pattern routine P1 calls another pattern routine
+      P2 and where P1 returns X + BASE whenever P2 returns X.  If IS_FINAL
+@@ -4924,32 +4930,32 @@ print_decision (output_state *os, decision *d, unsigned int indent,
+     {
+       if (is_final && base == 0)
+ 	{
+-	  printf_indent (indent, "return ");
+-	  print_nonbool_test (os, d->test);
+-	  printf ("; /* [-1, %d] */\n", count - 1);
++	  printf_indent (f, indent, "return ");
++	  print_nonbool_test (f, os, d->test);
++	  fprintf (f, "; /* [-1, %d] */\n", count - 1);
+ 	  return ES_RETURNED;
+ 	}
+       else
+ 	{
+-	  printf_indent (indent, "res = ");
+-	  print_nonbool_test (os, d->test);
+-	  printf (";\n");
+-	  printf_indent (indent, "if (res >= 0)\n");
+-	  printf_indent (indent + 2, "return res");
++	  printf_indent (f, indent, "res = ");
++	  print_nonbool_test (f, os, d->test);
++	  fprintf (f, ";\n");
++	  printf_indent (f, indent, "if (res >= 0)\n");
++	  printf_indent (f, indent + 2, "return res");
+ 	  if (base != 0)
+-	    printf (" + %d", base);
+-	  printf ("; /* [%d, %d] */\n", base, base + count - 1);
++	    fprintf (f, " + %d", base);
++	  fprintf (f, "; /* [%d, %d] */\n", base, base + count - 1);
+ 	  return ES_FALLTHROUGH;
+ 	}
+     }
+   else if (d->test.kind == rtx_test::ACCEPT)
+-    return print_acceptance (d->test.u.acceptance, indent, is_final);
++    return print_acceptance (f, d->test.u.acceptance, indent, is_final);
+   else if (d->test.kind == rtx_test::SET_OP)
+     {
+-      printf_indent (indent, "operands[%d] = ", d->test.u.opno);
+-      print_test_rtx (os, d->test);
+-      printf (";\n");
+-      return print_state (os, d->singleton ()->to, indent, is_final);
++      printf_indent (f, indent, "operands[%d] = ", d->test.u.opno);
++      print_test_rtx (f, os, d->test);
++      fprintf (f, ";\n");
++      return print_state (f, os, d->singleton ()->to, indent, is_final);
+     }
+   /* Handle decisions with a single transition and a single transition
+      label.  */
+@@ -4957,13 +4963,13 @@ print_decision (output_state *os, decision *d, unsigned int indent,
+     {
+       transition *trans = d->singleton ();
+       if (mark_optional_transitions_p && trans->optional)
+-	printf_indent (indent, "/* OPTIONAL IF */\n");
++	printf_indent (f, indent, "/* OPTIONAL IF */\n");
+ 
+       /* Print the condition associated with TRANS.  Invert it if IS_FINAL,
+ 	 so that we return immediately on failure and fall through on
+ 	 success.  */
+-      printf_indent (indent, "if (");
+-      print_test (os, d->test, trans->is_param, label, is_final);
++      printf_indent (f, indent, "if (");
++      print_test (f, os, d->test, trans->is_param, label, is_final);
+ 
+       /* Look for following states that would be handled by this code
+ 	 on recursion.  If they don't need any preparatory statements,
+@@ -4979,13 +4985,13 @@ print_decision (output_state *os, decision *d, unsigned int indent,
+ 	      || !test_position_available_p (os, d->test))
+ 	    break;
+ 	  trans = d->first;
+-	  printf ("\n");
++	  fprintf (f, "\n");
+ 	  if (mark_optional_transitions_p && trans->optional)
+-	    printf_indent (indent + 4, "/* OPTIONAL IF */\n");
+-	  printf_indent (indent + 4, "%s ", is_final ? "||" : "&&");
+-	  print_test (os, d->test, trans->is_param, label, is_final);
++	    printf_indent (f, indent + 4, "/* OPTIONAL IF */\n");
++	  printf_indent (f, indent + 4, "%s ", is_final ? "||" : "&&");
++	  print_test (f, os, d->test, trans->is_param, label, is_final);
+ 	}
+-      printf (")\n");
++      fprintf (f, ")\n");
+ 
+       /* Print the conditional code with INDENT + 2 and the fallthrough
+ 	 code with indent INDENT.  */
+@@ -4994,9 +5000,9 @@ print_decision (output_state *os, decision *d, unsigned int indent,
+ 	{
+ 	  /* We inverted the condition above, so return failure in the
+ 	     "if" body and fall through to the target of the transition.  */
+-	  printf_indent (indent + 2, "return %s;\n",
++	  printf_indent (f, indent + 2, "return %s;\n",
+ 			 get_failure_return (os->type));
+-	  return print_state (os, to, indent, is_final);
++	  return print_state (f, os, to, indent, is_final);
+ 	}
+       else if (to->singleton ()
+ 	       && to->first->test.kind == rtx_test::ACCEPT
+@@ -5004,7 +5010,7 @@ print_decision (output_state *os, decision *d, unsigned int indent,
+ 	{
+ 	  /* The target of the transition is a simple "return" statement.
+ 	     It doesn't need any braces and doesn't fall through.  */
+-	  if (print_acceptance (to->first->test.u.acceptance,
++	  if (print_acceptance (f, to->first->test.u.acceptance,
+ 				indent + 2, true) != ES_RETURNED)
+ 	    gcc_unreachable ();
+ 	  return ES_FALLTHROUGH;
+@@ -5018,9 +5024,9 @@ print_decision (output_state *os, decision *d, unsigned int indent,
+ 	  auto_vec <bool, 32> old_seen;
+ 	  old_seen.safe_splice (os->seen_vars);
+ 
+-	  printf_indent (indent + 2, "{\n");
+-	  print_state (os, trans->to, indent + 4, is_final);
+-	  printf_indent (indent + 2, "}\n");
++	  printf_indent (f, indent + 2, "{\n");
++	  print_state (f, os, trans->to, indent + 4, is_final);
++	  printf_indent (f, indent + 2, "}\n");
+ 
+ 	  os->seen_vars.truncate (0);
+ 	  os->seen_vars.splice (old_seen);
+@@ -5030,48 +5036,48 @@ print_decision (output_state *os, decision *d, unsigned int indent,
+   else
+     {
+       /* Output the decision as a switch statement.  */
+-      printf_indent (indent, "switch (");
+-      print_nonbool_test (os, d->test);
+-      printf (")\n");
++      printf_indent (f, indent, "switch (");
++      print_nonbool_test (f, os, d->test);
++      fprintf (f, ")\n");
+ 
+       /* Each case statement starts with the same set of valid variables.
+ 	 These are also the only variables will be valid on fallthrough.  */
+       auto_vec <bool, 32> old_seen;
+       old_seen.safe_splice (os->seen_vars);
+ 
+-      printf_indent (indent + 2, "{\n");
++      printf_indent (f, indent + 2, "{\n");
+       for (transition *trans = d->first; trans; trans = trans->next)
+ 	{
+ 	  gcc_assert (!trans->is_param);
+ 	  if (mark_optional_transitions_p && trans->optional)
+-	    printf_indent (indent + 2, "/* OPTIONAL CASE */\n");
++	    printf_indent (f, indent + 2, "/* OPTIONAL CASE */\n");
+ 	  for (int_set::iterator j = trans->labels.begin ();
+ 	       j != trans->labels.end (); ++j)
+ 	    {
+-	      printf_indent (indent + 2, "case ");
+-	      print_label_value (d->test, trans->is_param, *j);
+-	      printf (":\n");
++	      printf_indent (f, indent + 2, "case ");
++	      print_label_value (f, d->test, trans->is_param, *j);
++	      fprintf (f, ":\n");
+ 	    }
+-	  if (print_state (os, trans->to, indent + 4, is_final))
++	  if (print_state (f, os, trans->to, indent + 4, is_final))
+ 	    {
+ 	      /* The state can fall through.  Add an explicit break.  */
+ 	      gcc_assert (!is_final);
+-	      printf_indent (indent + 4, "break;\n");
++	      printf_indent (f, indent + 4, "break;\n");
+ 	    }
+-	  printf ("\n");
++	  fprintf (f, "\n");
+ 
+ 	  /* Restore the original set of valid variables.  */
+ 	  os->seen_vars.truncate (0);
+ 	  os->seen_vars.splice (old_seen);
+ 	}
+       /* Add a default case.  */
+-      printf_indent (indent + 2, "default:\n");
++      printf_indent (f, indent + 2, "default:\n");
+       if (is_final)
+-	printf_indent (indent + 4, "return %s;\n",
++	printf_indent (f, indent + 4, "return %s;\n",
+ 		       get_failure_return (os->type));
+       else
+-	printf_indent (indent + 4, "break;\n");
+-      printf_indent (indent + 2, "}\n");
++	printf_indent (f, indent + 4, "break;\n");
++      printf_indent (f, indent + 2, "}\n");
+       return is_final ? ES_RETURNED : ES_FALLTHROUGH;
+     }
+ }
+@@ -5114,10 +5120,10 @@ assign_position_vars (output_state *os, state *s)
+    only ROOT's variable has a valid value.  */
+ 
+ static void
+-print_subroutine_start (output_state *os, state *s, position *root)
++print_subroutine_start (FILE *f, output_state *os, state *s, position *root)
+ {
+-  printf ("{\n  rtx * const operands ATTRIBUTE_UNUSED"
+-	  " = &recog_data.operand[0];\n");
++  fprintf (f, "{\n  rtx * const operands ATTRIBUTE_UNUSED"
++	   " = &recog_data.operand[0];\n");
+   os->var_to_id.truncate (0);
+   os->seen_vars.truncate (0);
+   if (root)
+@@ -5140,9 +5146,9 @@ print_subroutine_start (output_state *os, state *s, position *root)
+ 	{
+ 	  for (unsigned int i = 2; i < num_vars; ++i)
+ 	    /* Print 8 rtx variables to a line.  */
+-	    printf ("%s x%d",
++	    fprintf (f, "%s x%d",
+ 		    i == 2 ? "  rtx" : (i - 2) % 8 == 0 ? ";\n  rtx" : ",", i);
+-	  printf (";\n");
++	  fprintf (f, ";\n");
+ 	}
+ 
+       /* Say that x1 is valid and the rest aren't.  */
+@@ -5150,22 +5156,26 @@ print_subroutine_start (output_state *os, state *s, position *root)
+       os->seen_vars[1] = true;
+     }
+   if (os->type == SUBPATTERN || os->type == RECOG)
+-    printf ("  int res ATTRIBUTE_UNUSED;\n");
++    fprintf (f, "  int res ATTRIBUTE_UNUSED;\n");
+   else
+-    printf ("  rtx_insn *res ATTRIBUTE_UNUSED;\n");
++    fprintf (f, "  rtx_insn *res ATTRIBUTE_UNUSED;\n");
+ }
+ 
+ /* Output the definition of pattern routine ROUTINE.  */
+ 
+ static void
+-print_pattern (output_state *os, pattern_routine *routine)
++print_pattern (FILE *f, output_state *os, pattern_routine *routine,
++	       bool in_header = false)
+ {
+-  printf ("\nstatic int\npattern%d (", routine->pattern_id);
++  if (!in_header)
++    fprintf (f, "\nint\npattern%d (", routine->pattern_id);
++  else
++    fprintf (f, "\nextern int\npattern%d (", routine->pattern_id);
+   const char *sep = "";
+   /* Add the top-level rtx parameter, if any.  */
+   if (routine->pos)
+     {
+-      printf ("%srtx x1", sep);
++      fprintf (f, "%srtx x1", sep);
+       sep = ", ";
+     }
+   /* Add the optional parameters.  */
+@@ -5173,26 +5183,34 @@ print_pattern (output_state *os, pattern_routine *routine)
+     {
+       /* We can't easily tell whether a C condition actually reads INSN,
+ 	 so add an ATTRIBUTE_UNUSED just in case.  */
+-      printf ("%srtx_insn *insn ATTRIBUTE_UNUSED", sep);
++      fprintf (f, "%srtx_insn *insn ATTRIBUTE_UNUSED", sep);
+       sep = ", ";
+     }
+   if (routine->pnum_clobbers_p)
+     {
+-      printf ("%sint *pnum_clobbers", sep);
++      fprintf (f, "%sint *pnum_clobbers", sep);
+       sep = ", ";
+     }
+   /* Add the "i" parameters.  */
+   for (unsigned int i = 0; i < routine->param_types.length (); ++i)
+     {
+-      printf ("%s%s i%d", sep,
+-	      parameter_type_string (routine->param_types[i]), i + 1);
++      fprintf (f, "%s%s i%d", sep,
++	       parameter_type_string (routine->param_types[i]), i + 1);
+       sep = ", ";
+     }
+-  printf (")\n");
++
++  if (!in_header)
++    fprintf (f, ")\n");
++  else
++    {
++      fprintf (f, ");\n");
++      return;
++    }
++
+   os->type = SUBPATTERN;
+-  print_subroutine_start (os, routine->s, routine->pos);
+-  print_state (os, routine->s, 2, true);
+-  printf ("}\n");
++  print_subroutine_start (f, os, routine->s, routine->pos);
++  print_state (f, os, routine->s, 2, true);
++  fprintf (f, "}\n");
+ }
+ 
+ /* Output a routine of type TYPE that implements S.  PROC_ID is the
+@@ -5200,9 +5218,26 @@ print_pattern (output_state *os, pattern_routine *routine)
+    routine.  */
+ 
+ static void
+-print_subroutine (output_state *os, state *s, int proc_id)
+-{
+-  printf ("\n");
++print_subroutine (FILE *f, output_state *os, state *s, int proc_id,
++		  bool in_header = false)
++{
++  fprintf (f, "\n");
++  const char *specifier_ext = "extern";
++  const char *specifier_default = "";
++  const char *specifier;
++  if (!in_header)
++    specifier = specifier_default;
++  else
++    specifier = specifier_ext;
++
++  const char *end;
++  const char *end_default = "";
++  const char *end_header = ";";
++  if (!in_header)
++    end = end_default;
++  else
++    end = end_header;
++
+   switch (os->type)
+     {
+     case SUBPATTERN:
+@@ -5210,46 +5245,54 @@ print_subroutine (output_state *os, state *s, int proc_id)
+ 
+     case RECOG:
+       if (proc_id)
+-	printf ("static int\nrecog_%d", proc_id);
++	fprintf (f, "%s int\nrecog_%d", specifier, proc_id);
+       else
+-	printf ("int\nrecog");
+-      printf (" (rtx x1 ATTRIBUTE_UNUSED,\n"
+-	      "\trtx_insn *insn ATTRIBUTE_UNUSED,\n"
+-	      "\tint *pnum_clobbers ATTRIBUTE_UNUSED)\n");
++	fprintf (f, "%s int\nrecog", specifier);
++      fprintf (f, " (rtx x1 ATTRIBUTE_UNUSED,\n"
++	       "\trtx_insn *insn ATTRIBUTE_UNUSED,\n"
++	       "\tint *pnum_clobbers ATTRIBUTE_UNUSED)%s\n", end);
+       break;
+ 
+     case SPLIT:
+       if (proc_id)
+-	printf ("static rtx_insn *\nsplit_%d", proc_id);
++	fprintf (f, "%s rtx_insn *\nsplit_%d", specifier, proc_id);
+       else
+-	printf ("rtx_insn *\nsplit_insns");
+-      printf (" (rtx x1 ATTRIBUTE_UNUSED, rtx_insn *insn ATTRIBUTE_UNUSED)\n");
++	fprintf (f, "%s rtx_insn *\nsplit_insns", specifier);
++      fprintf (f, " (rtx x1 ATTRIBUTE_UNUSED, "
++		  "rtx_insn *insn ATTRIBUTE_UNUSED)%s\n", end);
+       break;
+ 
+     case PEEPHOLE2:
+       if (proc_id)
+-	printf ("static rtx_insn *\npeephole2_%d", proc_id);
++	fprintf (f, "%s rtx_insn *\npeephole2_%d", specifier, proc_id);
+       else
+-	printf ("rtx_insn *\npeephole2_insns");
+-      printf (" (rtx x1 ATTRIBUTE_UNUSED,\n"
+-	      "\trtx_insn *insn ATTRIBUTE_UNUSED,\n"
+-	      "\tint *pmatch_len_ ATTRIBUTE_UNUSED)\n");
++	fprintf (f, "%s rtx_insn *\npeephole2_insns", specifier);
++      fprintf (f, " (rtx x1 ATTRIBUTE_UNUSED,\n"
++	       "\trtx_insn *insn ATTRIBUTE_UNUSED,\n"
++	       "\tint *pmatch_len_ ATTRIBUTE_UNUSED)%s\n", end);
+       break;
+     }
+-  print_subroutine_start (os, s, &root_pos);
++
++  if (in_header)
++    return;
++
++  print_subroutine_start (f, os, s, &root_pos);
+   if (proc_id == 0)
+     {
+-      printf ("  recog_data.insn = NULL;\n");
++      fprintf (f, "  recog_data.insn = NULL;\n");
+     }
+-  print_state (os, s, 2, true);
+-  printf ("}\n");
++  print_state (f, os, s, 2, true);
++  fprintf (f, "}\n");
+ }
+ 
+ /* Print out a routine of type TYPE that performs ROOT.  */
+ 
+ static void
+-print_subroutine_group (output_state *os, routine_type type, state *root)
++print_subroutine_group (vec<FILE *> &vec, FILE *header, output_state *os,
++			routine_type type, state *root)
+ {
++  FILE *f;
++  unsigned idx;
+   os->type = type;
+   if (use_subroutines_p)
+     {
+@@ -5261,11 +5304,20 @@ print_subroutine_group (output_state *os, routine_type type, state *root)
+       /* Output the subroutines (but not ROOT itself).  */
+       unsigned int i;
+       state *s;
++
++      FILE *f = header;
++      FOR_EACH_VEC_ELT (subroutines, i, s)
++	print_subroutine (header, os, s, i + 1, true);
++
+       FOR_EACH_VEC_ELT (subroutines, i, s)
+-	print_subroutine (os, s, i + 1);
++	{
++	  f = choose_output (vec, idx);
++	  print_subroutine (f, os, s, i + 1);
++	}
+     }
+   /* Output the main routine.  */
+-  print_subroutine (os, root, 0);
++  f = choose_output (vec, idx);
++  print_subroutine (f, os, root, 0);
+ }
+ 
+ /* Return the rtx pattern for the list of rtxes in a define_peephole2.  */
+@@ -5336,6 +5388,29 @@ remove_clobbers (acceptance_type *acceptance_ptr, rtx *pattern_ptr)
+   return true;
+ }
+ 
++auto_vec<FILE *, 10> output_files;
++char header_name[255];
++FILE *header = NULL;
++
++static bool
++handle_arg (const char *arg)
++{
++  printf ("%s\n", arg);
++  if (arg[1] == 'O')
++    {
++      FILE *file = fopen (&arg[2], "w");
++      output_files.safe_push (file);
++      return true;
++    }
++  if (arg[1] == 'H')
++    {
++      snprintf (header_name, 255, "%s", &arg[2]);
++      header = fopen (header_name, "w");
++      return true;
++    }
++  return false;
++}
++
+ int
+ main (int argc, const char **argv)
+ {
+@@ -5343,10 +5418,17 @@ main (int argc, const char **argv)
+ 
+   progname = "genrecog";
+ 
+-  if (!init_rtx_reader_args (argc, argv))
++  if (!init_rtx_reader_args_cb (argc, argv, handle_arg))
+     return (FATAL_EXIT_CODE);
+ 
+-  write_header ();
++  if (output_files.is_empty ())
++    output_files.safe_push (stdout);
++
++  for (auto f : output_files)
++    write_header (f, header_name);
++
++  FILE *file = NULL;
++  unsigned file_idx;
+ 
+   /* Read the machine description.  */
+ 
+@@ -5354,6 +5436,7 @@ main (int argc, const char **argv)
+   while (read_md_rtx (&info))
+     {
+       rtx def = info.def;
++      file = choose_output (output_files, file_idx);
+ 
+       acceptance_type acceptance;
+       acceptance.partial_p = false;
+@@ -5387,8 +5470,8 @@ main (int argc, const char **argv)
+ 
+ 	  /* Declare the gen_split routine that we'll call if the
+ 	     pattern matches.  The definition comes from insn-emit.cc.  */
+-	  printf ("extern rtx_insn *gen_split_%d (rtx_insn *, rtx *);\n",
+-		  info.index);
++	  fprintf (header, "extern rtx_insn *gen_split_%d "
++		   "(rtx_insn *, rtx *);\n", info.index);
+ 	  break;
+ 
+ 	case DEFINE_PEEPHOLE2:
+@@ -5399,8 +5482,8 @@ main (int argc, const char **argv)
+ 
+ 	  /* Declare the gen_peephole2 routine that we'll call if the
+ 	     pattern matches.  The definition comes from insn-emit.cc.  */
+-	  printf ("extern rtx_insn *gen_peephole2_%d (rtx_insn *, rtx *);\n",
+-		  info.index);
++	  fprintf (header, "extern rtx_insn *gen_peephole2_%d "
++		   "(rtx_insn *, rtx *);\n", info.index);
+ 	  break;
+ 
+ 	default:
+@@ -5411,7 +5494,8 @@ main (int argc, const char **argv)
+   if (have_error)
+     return FATAL_EXIT_CODE;
+ 
+-  puts ("\n\n");
++  for (auto f : output_files)
++    fprintf (f, "%s", "\n\n");
+ 
+   /* Optimize each routine in turn.  */
+   optimize_subroutine_group ("recog", &insn_root);
+@@ -5433,15 +5517,27 @@ main (int argc, const char **argv)
+       /* Print out the routines that we just created.  */
+       unsigned int i;
+       pattern_routine *routine;
++
+       FOR_EACH_VEC_ELT (patterns, i, routine)
+-	print_pattern (&os, routine);
++	print_pattern (header, &os, routine, true);
++
++      FOR_EACH_VEC_ELT (patterns, i, routine)
++	{
++	  file = choose_output (output_files, file_idx);
++	  print_pattern (file, &os, routine);
++	}
+     }
+ 
+   /* Print out the matching routines.  */
+-  print_subroutine_group (&os, RECOG, &insn_root);
+-  print_subroutine_group (&os, SPLIT, &split_root);
+-  print_subroutine_group (&os, PEEPHOLE2, &peephole2_root);
++  print_subroutine_group (output_files, header, &os, RECOG, &insn_root);
++  print_subroutine_group (output_files, header, &os, SPLIT, &split_root);
++  print_subroutine_group (output_files, header, &os, PEEPHOLE2, &peephole2_root);
++
++  fclose (header);
+ 
+-  fflush (stdout);
+-  return (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
++  int ret = SUCCESS_EXIT_CODE;
++  for (FILE *f : output_files)
++    if (fclose (f) != 0)
++      ret = FATAL_EXIT_CODE;
++  return ret;
+ }
+diff --git a/gcc/gentarget-def.cc b/gcc/gentarget-def.cc
+index 35f9a3142c86..79e53f724ad2 100644
+--- a/gcc/gentarget-def.cc
++++ b/gcc/gentarget-def.cc
+@@ -191,7 +191,7 @@ def_target_insn (const char *name, const char *prototype)
+ 	      printf ("target_have_%s (void)\n", name);
+ 	      printf ("{\n");
+ 	      printf ("  return ");
+-	      rtx_reader_ptr->print_c_condition (test);
++	      rtx_reader_ptr->print_c_condition (stdout, test);
+ 	      printf (";\n");
+ 	      printf ("}\n");
+ 	    }
+diff --git a/gcc/read-md.cc b/gcc/read-md.cc
+index 46ab9065e3e4..cf726cdfc4bd 100644
+--- a/gcc/read-md.cc
++++ b/gcc/read-md.cc
+@@ -192,9 +192,9 @@ md_reader::fprint_c_condition (FILE *outf, const char *cond)
+ /* Special fprint_c_condition for writing to STDOUT.  */
+ 
+ void
+-md_reader::print_c_condition (const char *cond)
++md_reader::print_c_condition (FILE *outf, const char *cond)
+ {
+-  fprint_c_condition (stdout, cond);
++  fprint_c_condition (outf, cond);
+ }
+ 
+ /* A vfprintf-like function for reporting an error against line LINENO
+diff --git a/gcc/read-md.h b/gcc/read-md.h
+index 2adcb58478fe..bd4d99ec3bdb 100644
+--- a/gcc/read-md.h
++++ b/gcc/read-md.h
+@@ -205,7 +205,7 @@ class md_reader
+ 
+   const char *join_c_conditions (const char *cond1, const char *cond2);
+   void fprint_c_condition (FILE *outf, const char *cond);
+-  void print_c_condition (const char *cond);
++  void print_c_condition (FILE *outf, const char *cond);
+ 
+   /* Defined in read-rtl.cc.  */
+   const char *apply_iterator_to_string (const char *string);
+-- 
+2.50.1
+

diff --git a/13.3.0/gentoo/README.history b/13.3.0/gentoo/README.history
index 3424374..575c188 100644
--- a/13.3.0/gentoo/README.history
+++ b/13.3.0/gentoo/README.history
@@ -1,3 +1,9 @@
+8	3 August 2025
+
+	+ 94_all_genoutput-Accelerate-the-place_operands-function.patch
+	+ 95_all_genemit-Distribute-evenly-to-files-PR111600.patch
+	+ 96_all_genrecog-Split-into-separate-partitions-PR111600.patch
+
 7	2 August 2025
 
 	- 94_all-libsanitizer-Fix-build-with-glibc-2.42.patch


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/gcc-patches:master commit in: 13.3.0/gentoo/
@ 2025-08-22  5:15 Sam James
  0 siblings, 0 replies; 7+ messages in thread
From: Sam James @ 2025-08-22  5:15 UTC (permalink / raw
  To: gentoo-commits

commit:     b6f15fbe2df8c9f317ebde782bba04f141c1dded
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 22 04:58:52 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Aug 22 05:01:01 2025 +0000
URL:        https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=b6f15fbe

13.3.0: backport --enable-host-pie, --enable-host-bind-now

This makes some experiments like -mno-indirect-extern-access much easier.

Requires dropping 09_all_nopie-all-flags.patch which causes a conflict
and is obviously in contradiction to the new patches.

Signed-off-by: Sam James <sam <AT> gentoo.org>

 13.3.0/gentoo/09_all_nopie-all-flags.patch         |   18 -
 ...7_all_configure-Implement-enable-host-pie.patch | 1464 ++++++++++++++++++++
 ..._configure-Implement-enable-host-bind-now.patch |  599 ++++++++
 13.3.0/gentoo/README.history                       |    5 +
 4 files changed, 2068 insertions(+), 18 deletions(-)

diff --git a/13.3.0/gentoo/09_all_nopie-all-flags.patch b/13.3.0/gentoo/09_all_nopie-all-flags.patch
deleted file mode 100644
index fe1cd80..0000000
--- a/13.3.0/gentoo/09_all_nopie-all-flags.patch
+++ /dev/null
@@ -1,18 +0,0 @@
-We need to pass NO_PIE_CFLAGS to ALL_* so gcc don't fail when
-we compile it with older gcc and pie.
-
---- a/gcc/Makefile.in
-+++ b/gcc/Makefile.in
-@@ -1054,10 +1054,10 @@ ALL_CXXFLAGS = $(T_CFLAGS) $(CFLAGS-$@)
- ALL_CPPFLAGS = $(INCLUDES) $(CPPFLAGS)
- 
- # This is the variable to use when using $(COMPILER).
--ALL_COMPILERFLAGS = $(ALL_CXXFLAGS)
-+ALL_COMPILERFLAGS = $(NO_PIE_CFLAGS) $(ALL_CXXFLAGS)
- 
- # This is the variable to use when using $(LINKER).
--ALL_LINKERFLAGS = $(ALL_CXXFLAGS)
-+ALL_LINKERFLAGS = $(NO_PIE_CFLAGS) $(ALL_CXXFLAGS)
- 
- # Build and host support libraries.
- 

diff --git a/13.3.0/gentoo/97_all_configure-Implement-enable-host-pie.patch b/13.3.0/gentoo/97_all_configure-Implement-enable-host-pie.patch
new file mode 100644
index 0000000..33bbc70
--- /dev/null
+++ b/13.3.0/gentoo/97_all_configure-Implement-enable-host-pie.patch
@@ -0,0 +1,1464 @@
+From 6a974df8a779c8220a41919d118e3cf72829bcb9 Mon Sep 17 00:00:00 2001
+Message-ID: <6a974df8a779c8220a41919d118e3cf72829bcb9.1755666309.git.sam@gentoo.org>
+From: Marek Polacek <polacek@redhat.com>
+Date: Wed, 3 May 2023 17:06:13 -0400
+Subject: [PATCH 1/2] configure: Implement --enable-host-pie
+
+[ This is my third attempt to add this configure option.  The first
+version was approved but it came too late in the development cycle.
+The second version was also approved, but I had to revert it:
+<https://gcc.gnu.org/pipermail/gcc-patches/2022-November/607082.html>.
+I've fixed the problem (by moving $(PICFLAG) from INTERNAL_CFLAGS to
+ALL_COMPILERFLAGS).  Another change is that since r13-4536 I no longer
+need to touch Makefile.def, so this patch is simplified. ]
+
+This patch implements the --enable-host-pie configure option which
+makes the compiler executables PIE.  This can be used to enhance
+protection against ROP attacks, and can be viewed as part of a wider
+trend to harden binaries.
+
+It is similar to the option --enable-host-shared, except that --e-h-s
+won't add -shared to the linker flags whereas --e-h-p will add -pie.
+It is different from --enable-default-pie because that option just
+adds an implicit -fPIE/-pie when the compiler is invoked, but the
+compiler itself isn't PIE.
+
+Since r12-5768-gfe7c3ecf, PCH works well with PIE, so there are no PCH
+regressions.
+
+When building the compiler, the build process may use various in-tree
+libraries; these need to be built with -fPIE so that it's possible to
+use them when building a PIE.  For instance, when --with-included-gettext
+is in effect, intl object files must be compiled with -fPIE.  Similarly,
+when building in-tree gmp, isl, mpfr and mpc, they must be compiled with
+-fPIE.
+
+With this patch and --enable-host-pie used to configure gcc:
+
+$ file gcc/cc1{,plus,obj,gm2} gcc/f951 gcc/lto1 gcc/cpp gcc/go1 gcc/rust1 gcc/gnat1
+gcc/cc1:     ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=98e22cde129d304aa6f33e61b1c39e144aeb135e, for GNU/Linux 3.2.0, with debug_info, not stripped
+gcc/cc1plus: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=859d1ea37e43dfe50c18fd4e3dd9a34bb1db8f77, for GNU/Linux 3.2.0, with debug_info, not stripped
+gcc/cc1obj:  ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=1964f8ecee6163182bc26134e2ac1f324816e434, for GNU/Linux 3.2.0, with debug_info, not stripped
+gcc/cc1gm2:  ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=a396672c7ff913d21855829202e7b02ecf42ff4c, for GNU/Linux 3.2.0, with debug_info, not stripped
+gcc/f951:    ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=59c523db893186547ac75c7a71f48be0a461c06b, for GNU/Linux 3.2.0, with debug_info, not stripped
+gcc/lto1:    ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=084a7b77df7be2d63c2d4c655b5bbc3fcdb6038d, for GNU/Linux 3.2.0, with debug_info, not stripped
+gcc/cpp:     ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=3503bf8390d219a10d6653b8560aa21158132168, for GNU/Linux 3.2.0, with debug_info, not stripped
+gcc/go1:     ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=988cc673af4fba5dcb482f4b34957b99050a68c5, for GNU/Linux 3.2.0, with debug_info, not stripped
+gcc/rust1:   ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=b6a5d3d514446c4dcdee0707f086ab9b274a8a3c, for GNU/Linux 3.2.0, with debug_info, not stripped
+gcc/gnat1:   ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=bb11ccdc2c366fe3fe0980476bcd8ca19b67f9dc, for GNU/Linux 3.2.0, with debug_info, not stripped
+
+I plan to add an option to link with -Wl,-z,now.
+
+Bootstrapped on x86_64-pc-linux-gnu with --with-included-gettext
+--enable-host-pie as well as without --enable-host-pie.  Also tested
+on a Debian system where the system gcc was configured with
+--enable-default-pie.
+
+Co-Authored by: Iain Sandoe  <iain@sandoe.co.uk>
+
+ChangeLog:
+
+	* configure.ac (--enable-host-pie): New check.  Set PICFLAG after this
+	check.
+	* configure: Regenerate.
+
+c++tools/ChangeLog:
+
+	* Makefile.in: Rename PIEFLAG to PICFLAG.  Set LD_PICFLAG.  Use it.
+	Use pic/libiberty.a if PICFLAG is set.
+	* configure.ac (--enable-default-pie): Set PICFLAG instead of PIEFLAG.
+	(--enable-host-pie): New check.
+	* configure: Regenerate.
+
+fixincludes/ChangeLog:
+
+	* Makefile.in: Set and use PICFLAG and LD_PICFLAG.  Use the "pic"
+	build of libiberty if PICFLAG is set.
+	* configure.ac:
+	* configure: Regenerate.
+
+gcc/ChangeLog:
+
+	* Makefile.in: Set LD_PICFLAG.  Use it.  Set enable_host_pie.
+	Remove NO_PIE_CFLAGS and NO_PIE_FLAG.  Pass LD_PICFLAG to
+	ALL_LINKERFLAGS.  Use the "pic" build of libiberty if --enable-host-pie.
+	* configure.ac (--enable-host-shared): Don't set PICFLAG here.
+	(--enable-host-pie): New check.  Set PICFLAG and LD_PICFLAG after this
+	check.
+	* configure: Regenerate.
+	* doc/install.texi: Document --enable-host-pie.
+
+gcc/ada/ChangeLog:
+
+	* gcc-interface/Make-lang.in (ALL_ADAFLAGS): Remove NO_PIE_CFLAGS.  Add
+	PICFLAG.  Use PICFLAG when building ada/b_gnat1.o and ada/b_gnatb.o.
+	* gcc-interface/Makefile.in: Use pic/libiberty.a if PICFLAG is set.
+	Remove NO_PIE_FLAG.
+
+gcc/m2/ChangeLog:
+
+	* Make-lang.in: New var, GM2_PICFLAGS.  Use it.
+
+gcc/d/ChangeLog:
+
+	* Make-lang.in: Remove NO_PIE_CFLAGS.
+
+intl/ChangeLog:
+
+	* Makefile.in: Use @PICFLAG@ in COMPILE as well.
+	* configure.ac (--enable-host-shared): Don't set PICFLAG here.
+	(--enable-host-pie): New check.  Set PICFLAG after this check.
+	* configure: Regenerate.
+
+libcody/ChangeLog:
+
+	* Makefile.in: Pass LD_PICFLAG to LDFLAGS.
+	* configure.ac (--enable-host-shared): Don't set PICFLAG here.
+	(--enable-host-pie): New check.  Set PICFLAG and LD_PICFLAG after this
+	check.
+	* configure: Regenerate.
+
+libcpp/ChangeLog:
+
+	* configure.ac (--enable-host-shared): Don't set PICFLAG here.
+	(--enable-host-pie): New check.  Set PICFLAG after this check.
+	* configure: Regenerate.
+
+libdecnumber/ChangeLog:
+
+	* configure.ac (--enable-host-shared): Don't set PICFLAG here.
+	(--enable-host-pie): New check.  Set PICFLAG after this check.
+	* configure: Regenerate.
+
+libiberty/ChangeLog:
+
+	* configure.ac: Also set shared when enable_host_pie.
+	* configure: Regenerate.
+
+zlib/ChangeLog:
+
+	* configure.ac (--enable-host-shared): Don't set PICFLAG here.
+	(--enable-host-pie): New check.  Set PICFLAG after this check.
+	* configure: Regenerate.
+
+(cherry picked from commit b6cb10af12cf869c1ae348c0e5cb2d364ef0abce)
+---
+ c++tools/Makefile.in               | 11 +++++--
+ c++tools/configure                 | 17 +++++++++--
+ c++tools/configure.ac              | 11 +++++--
+ configure                          | 49 ++++++++++++++++++++++++++++--
+ configure.ac                       | 43 ++++++++++++++++++++++++--
+ fixincludes/Makefile.in            | 12 +++++---
+ fixincludes/configure              | 13 ++++++++
+ fixincludes/configure.ac           |  8 +++++
+ gcc/Makefile.in                    | 32 +++++++++++--------
+ gcc/ada/gcc-interface/Make-lang.in |  7 +++--
+ gcc/ada/gcc-interface/Makefile.in  |  8 +++--
+ gcc/configure                      | 43 ++++++++++++++++++--------
+ gcc/configure.ac                   | 36 ++++++++++++++++------
+ gcc/d/Make-lang.in                 |  2 +-
+ gcc/doc/install.texi               | 16 ++++++++--
+ intl/Makefile.in                   |  2 +-
+ intl/configure                     | 24 +++++++++++++--
+ intl/configure.ac                  | 19 ++++++++++--
+ libcody/Makefile.in                |  2 +-
+ libcody/configure                  | 30 +++++++++++++++++-
+ libcody/configure.ac               | 26 ++++++++++++++--
+ libcpp/configure                   | 22 +++++++++++++-
+ libcpp/configure.ac                | 19 ++++++++++--
+ libdecnumber/configure             | 22 +++++++++++++-
+ libdecnumber/configure.ac          | 19 ++++++++++--
+ libiberty/configure                |  4 +--
+ libiberty/configure.ac             |  4 +--
+ zlib/configure                     | 28 ++++++++++++++---
+ zlib/configure.ac                  | 21 +++++++++++--
+ 29 files changed, 464 insertions(+), 86 deletions(-)
+
+diff --git a/c++tools/Makefile.in b/c++tools/Makefile.in
+index 77bda3d56dc1..dcb1029e064f 100644
+--- a/c++tools/Makefile.in
++++ b/c++tools/Makefile.in
+@@ -29,8 +29,9 @@ AUTOCONF := @AUTOCONF@
+ AUTOHEADER := @AUTOHEADER@
+ CXX := @CXX@
+ CXXFLAGS := @CXXFLAGS@
+-PIEFLAG := @PIEFLAG@
+-CXXOPTS := $(CXXFLAGS) $(PIEFLAG) -fno-exceptions -fno-rtti
++PICFLAG := @PICFLAG@
++LD_PICFLAG := @LD_PICFLAG@
++CXXOPTS := $(CXXFLAGS) $(PICFLAG) -fno-exceptions -fno-rtti
+ LDFLAGS := @LDFLAGS@
+ exeext := @EXEEXT@
+ LIBIBERTY := ../libiberty/libiberty.a
+@@ -90,11 +91,15 @@ ifeq (@CXX_AUX_TOOLS@,yes)
+ 
+ all::g++-mapper-server$(exeext)
+ 
++ifneq ($(PICFLAG),)
++override LIBIBERTY := ../libiberty/pic/libiberty.a
++endif
++
+ MAPPER.O := server.o resolver.o
+ CODYLIB = ../libcody/libcody.a
+ CXXINC += -I$(srcdir)/../libcody -I$(srcdir)/../include -I$(srcdir)/../gcc -I. -I../gcc
+ g++-mapper-server$(exeext): $(MAPPER.O) $(CODYLIB)
+-	+$(CXX) $(LDFLAGS) $(PIEFLAG) -o $@ $^ $(LIBIBERTY) $(NETLIBS)
++	+$(CXX) $(LDFLAGS) $(PICFLAG) $(LD_PICFLAG) -o $@ $^ $(LIBIBERTY) $(NETLIBS)
+ 
+ # copy to gcc dir so tests there can run
+ all::../gcc/g++-mapper-server$(exeext)
+diff --git a/c++tools/configure b/c++tools/configure
+index 742816e42539..880870093839 100755
+--- a/c++tools/configure
++++ b/c++tools/configure
+@@ -627,7 +627,8 @@ get_gcc_base_ver
+ EGREP
+ GREP
+ CXXCPP
+-PIEFLAG
++LD_PICFLAG
++PICFLAG
+ MAINTAINER
+ CXX_AUX_TOOLS
+ AUTOHEADER
+@@ -700,6 +701,7 @@ enable_c___tools
+ enable_maintainer_mode
+ enable_checking
+ enable_default_pie
++enable_host_pie
+ with_gcc_major_version_only
+ '
+       ac_precious_vars='build_alias
+@@ -1333,6 +1335,7 @@ Optional Features:
+                           only specific categories of checks. Categories are:
+                           yes,no,all,none,release.
+   --enable-default-pie    enable Position Independent Executable as default
++  --enable-host-pie       build host code as PIE
+ 
+ Optional Packages:
+   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+@@ -2990,12 +2993,20 @@ fi
+ # Check whether --enable-default-pie was given.
+ # Check whether --enable-default-pie was given.
+ if test "${enable_default_pie+set}" = set; then :
+-  enableval=$enable_default_pie; PIEFLAG=-fPIE
++  enableval=$enable_default_pie; PICFLAG=-fPIE
+ else
+-  PIEFLAG=
++  PICFLAG=
+ fi
+ 
+ 
++# Enable --enable-host-pie
++# Check whether --enable-host-pie was given.
++if test "${enable_host_pie+set}" = set; then :
++  enableval=$enable_host_pie; PICFLAG=-fPIE; LD_PICFLAG=-pie
++fi
++
++
++
+ 
+ # Check if O_CLOEXEC is defined by fcntl
+ 
+diff --git a/c++tools/configure.ac b/c++tools/configure.ac
+index 23e98c8e7216..44dfaccbbfaf 100644
+--- a/c++tools/configure.ac
++++ b/c++tools/configure.ac
+@@ -102,8 +102,15 @@ fi
+ AC_ARG_ENABLE(default-pie,
+ [AS_HELP_STRING([--enable-default-pie],
+ 		  [enable Position Independent Executable as default])],
+-[PIEFLAG=-fPIE], [PIEFLAG=])
+-AC_SUBST([PIEFLAG])
++[PICFLAG=-fPIE], [PICFLAG=])
++
++# Enable --enable-host-pie
++AC_ARG_ENABLE(host-pie,
++[AS_HELP_STRING([--enable-host-pie],
++		[build host code as PIE])],
++[PICFLAG=-fPIE; LD_PICFLAG=-pie], [])
++AC_SUBST(PICFLAG)
++AC_SUBST(LD_PICFLAG)
+ 
+ # Check if O_CLOEXEC is defined by fcntl
+ AC_CACHE_CHECK(for O_CLOEXEC, ac_cv_o_cloexec, [
+diff --git a/configure b/configure
+index 117a7ef23f22..d57e453e7ac6 100755
+--- a/configure
++++ b/configure
+@@ -687,7 +687,9 @@ extra_host_zlib_configure_flags
+ extra_host_libiberty_configure_flags
+ stage1_languages
+ host_libs_picflag
++PICFLAG
+ host_shared
++host_pie
+ extra_linker_plugin_flags
+ extra_linker_plugin_configure_flags
+ islinc
+@@ -830,6 +832,7 @@ enable_isl_version_check
+ enable_lto
+ enable_linker_plugin_configure_flags
+ enable_linker_plugin_flags
++enable_host_pie
+ enable_host_shared
+ enable_stage1_languages
+ enable_objc_gc
+@@ -1558,6 +1561,7 @@ Optional Features:
+   --enable-linker-plugin-flags=FLAGS
+                           additional flags for configuring and building linker
+                           plugins [none]
++  --enable-host-pie       build position independent host executables
+   --enable-host-shared    build host code as shared libraries
+   --enable-stage1-languages[=all]
+                           choose additional languages to build during stage1.
+@@ -8645,6 +8649,30 @@ fi
+ 
+ 
+ 
++# Enable --enable-host-pie.
++# Checked early to determine whether jit is an 'all' language
++# Check whether --enable-host-pie was given.
++if test "${enable_host_pie+set}" = set; then :
++  enableval=$enable_host_pie; host_pie=$enableval
++ case $host in
++   x86_64-*-darwin* | aarch64-*-darwin*)
++     if test x$host_pie != xyes ; then
++       # PIC is the default, and actually cannot be switched off.
++       echo configure.ac: warning: PIC code is required for the configured target, host-shared setting ignored. 1>&2
++       host_pie=yes
++     fi ;;
++  *) ;;
++ esac
++else
++  case $host in
++  *-*-darwin2*) host_pie=yes ;;
++  *) host_pie=no ;;
++ esac
++fi
++
++
++
++
+ # Enable --enable-host-shared.
+ # Checked early to determine whether jit is an 'all' language
+ # Check whether --enable-host-shared was given.
+@@ -8657,23 +8685,40 @@ if test "${enable_host_shared+set}" = set; then :
+        echo configure.ac: warning: PIC code is required for the configured target, host-shared setting ignored. 1>&2
+        host_shared=yes
+      fi ;;
++   *-*-darwin*)
++     if test x$host_pie == xyes ; then
++       echo configure.ac: warning: PIC code is required for PIE executables. 1>&2
++       host_shared=yes
++     fi ;;
+   *) ;;
+  esac
+ else
+   case $host in
+   x86_64-*-darwin* | aarch64-*-darwin*) host_shared=yes ;;
+-  *) host_shared=no ;;
++  # Darwin needs PIC objects to link PIE executables.
++  *-*-darwin*) host_shared=host_pie ;;
++  *) host_shared=no;;
+  esac
+ fi
+ 
+ 
+ 
+ 
++if test x$host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$host_pie = xyes; then
++  PICFLAG=-fPIE
++else
++  PICFLAG=
++fi
++
++
++
+ # If we are building PIC/PIE host executables, and we are building dependent
+ # libs (e.g. GMP) in-tree those libs need to be configured to generate PIC
+ # code.
+ host_libs_picflag=
+-if test "$host_shared" = "yes";then
++if test "$host_shared" = "yes" -o "$host_pie" = "yes"; then
+ host_libs_picflag='--with-pic'
+ fi
+ 
+diff --git a/configure.ac b/configure.ac
+index b3e9bbd2aa51..77ae7c2dd442 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1891,6 +1891,28 @@ AC_ARG_ENABLE(linker-plugin-flags,
+   extra_linker_plugin_flags=)
+ AC_SUBST(extra_linker_plugin_flags)
+ 
++# Enable --enable-host-pie.
++# Checked early to determine whether jit is an 'all' language
++AC_ARG_ENABLE(host-pie,
++[AS_HELP_STRING([--enable-host-pie],
++		[build position independent host executables])],
++[host_pie=$enableval
++ case $host in
++   x86_64-*-darwin* | aarch64-*-darwin*)
++     if test x$host_pie != xyes ; then
++       # PIC is the default, and actually cannot be switched off.
++       echo configure.ac: warning: PIC code is required for the configured target, host-shared setting ignored. 1>&2
++       host_pie=yes
++     fi ;;
++  *) ;;
++ esac],
++[case $host in
++  *-*-darwin2*) host_pie=yes ;;
++  *) host_pie=no ;;
++ esac])
++
++AC_SUBST(host_pie)
++
+ # Enable --enable-host-shared.
+ # Checked early to determine whether jit is an 'all' language
+ AC_ARG_ENABLE(host-shared,
+@@ -1904,20 +1926,37 @@ AC_ARG_ENABLE(host-shared,
+        echo configure.ac: warning: PIC code is required for the configured target, host-shared setting ignored. 1>&2
+        host_shared=yes
+      fi ;;
++   *-*-darwin*)
++     if test x$host_pie == xyes ; then
++       echo configure.ac: warning: PIC code is required for PIE executables. 1>&2
++       host_shared=yes
++     fi ;;
+   *) ;;
+  esac],
+ [case $host in
+   x86_64-*-darwin* | aarch64-*-darwin*) host_shared=yes ;;
+-  *) host_shared=no ;;
++  # Darwin needs PIC objects to link PIE executables.
++  *-*-darwin*) host_shared=host_pie ;;
++  *) host_shared=no;;
+  esac])
+ 
+ AC_SUBST(host_shared)
+ 
++if test x$host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$host_pie = xyes; then
++  PICFLAG=-fPIE
++else
++  PICFLAG=
++fi
++
++AC_SUBST(PICFLAG)
++
+ # If we are building PIC/PIE host executables, and we are building dependent
+ # libs (e.g. GMP) in-tree those libs need to be configured to generate PIC
+ # code.
+ host_libs_picflag=
+-if test "$host_shared" = "yes";then
++if test "$host_shared" = "yes" -o "$host_pie" = "yes"; then
+ host_libs_picflag='--with-pic'
+ fi
+ AC_SUBST(host_libs_picflag)
+diff --git a/fixincludes/Makefile.in b/fixincludes/Makefile.in
+index 1937dcaa32d5..e6ce41dba39d 100644
+--- a/fixincludes/Makefile.in
++++ b/fixincludes/Makefile.in
+@@ -73,7 +73,7 @@ default : all
+ # Now figure out from those variables how to compile and link.
+ 
+ .c.o:
+-	$(CC) -c $(CFLAGS) $(WARN_CFLAGS) $(CPPFLAGS) $(FIXINC_CFLAGS) $<
++	$(CC) -c $(CFLAGS) $(PICFLAG) $(WARN_CFLAGS) $(CPPFLAGS) $(FIXINC_CFLAGS) $<
+ 
+ # The only suffixes we want for implicit rules are .c and .o.
+ .SUFFIXES:
+@@ -87,7 +87,11 @@ default : all
+ ##
+ ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+ 
++ifeq ($(PICFLAG),)
+ LIBIBERTY=../libiberty/libiberty.a
++else
++LIBIBERTY=../libiberty/pic/libiberty.a
++endif
+ 
+ ALLOBJ = fixincl.o fixtests.o fixfixes.o server.o procopen.o \
+       fixlib.o fixopts.o
+@@ -107,15 +111,15 @@ oneprocess : full-stamp
+ twoprocess : test-stamp $(AF)
+ 
+ full-stamp : $(ALLOBJ) $(LIBIBERTY)
+-	$(CC) $(CFLAGS) $(LDFLAGS) -o $(FI) $(ALLOBJ) $(LIBIBERTY)
++	$(CC) $(CFLAGS) $(PICFLAG) $(LDFLAGS) $(LD_PICFLAG) -o $(FI) $(ALLOBJ) $(LIBIBERTY)
+ 	$(STAMP) $@
+ 
+ test-stamp : $(TESTOBJ) $(LIBIBERTY)
+-	$(CC) $(CFLAGS) $(LDFLAGS) -o $(FI) $(TESTOBJ) $(LIBIBERTY)
++	$(CC) $(CFLAGS) $(PICFLAG) $(LDFLAGS) $(LD_PICFLAG) -o $(FI) $(TESTOBJ) $(LIBIBERTY)
+ 	$(STAMP) $@
+ 
+ $(AF): $(FIXOBJ) $(LIBIBERTY)
+-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(FIXOBJ) $(LIBIBERTY)
++	$(CC) $(CFLAGS) $(PICFLAG) $(LDFLAGS) $(LD_PICFLAG) -o $@ $(FIXOBJ) $(LIBIBERTY)
+ 
+ $(ALLOBJ)   : $(HDR)
+ fixincl.o   : fixincl.c  $(srcdir)/fixincl.x
+diff --git a/fixincludes/configure b/fixincludes/configure
+index bdcc41f6ddc8..f1748ebef746 100755
+--- a/fixincludes/configure
++++ b/fixincludes/configure
+@@ -623,6 +623,8 @@ ac_subst_vars='LTLIBOBJS
+ LIBOBJS
+ get_gcc_base_ver
+ MAINT
++LD_PICFLAG
++PICFLAG
+ TARGET
+ target_noncanonical
+ WERROR
+@@ -695,6 +697,7 @@ enable_option_checking
+ enable_werror_always
+ with_local_prefix
+ enable_twoprocess
++enable_host_pie
+ enable_maintainer_mode
+ with_gcc_major_version_only
+ '
+@@ -1323,6 +1326,7 @@ Optional Features:
+   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+   --enable-werror-always  enable -Werror despite compiler version
+   --enable-twoprocess       Use a separate process to apply the fixes
++  --enable-host-pie       build host code as PIE
+   --enable-maintainer-mode enable make rules and dependencies not useful
+                           (and sometimes confusing) to the casual installer
+ 
+@@ -4835,6 +4839,15 @@ $as_echo "#define SEPARATE_FIX_PROC 1" >>confdefs.h
+ 
+ fi
+ 
++# Enable --enable-host-pie.
++# Check whether --enable-host-pie was given.
++if test "${enable_host_pie+set}" = set; then :
++  enableval=$enable_host_pie; PICFLAG=-fPIE; LD_PICFLAG=-pie
++fi
++
++
++
++
+ case $host in
+ 	vax-dec-bsd* )
+ 
+diff --git a/fixincludes/configure.ac b/fixincludes/configure.ac
+index ef2227e3c938..4e78511d20fc 100644
+--- a/fixincludes/configure.ac
++++ b/fixincludes/configure.ac
+@@ -68,6 +68,14 @@ if test $TARGET = twoprocess; then
+ 		  [Define if testing and fixing are done by separate process])
+ fi
+ 
++# Enable --enable-host-pie.
++AC_ARG_ENABLE(host-pie,
++[AS_HELP_STRING([--enable-host-pie],
++       [build host code as PIE])],
++[PICFLAG=-fPIE; LD_PICFLAG=-pie], [])
++AC_SUBST(PICFLAG)
++AC_SUBST(LD_PICFLAG)
++
+ case $host in
+ 	vax-dec-bsd* )
+ 		AC_DEFINE(exit, xexit, [Define to xexit if the host system does not support atexit])
+diff --git a/gcc/Makefile.in b/gcc/Makefile.in
+index 1d9e10127ca5..03eed9708371 100644
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -158,6 +158,9 @@ LDFLAGS = @LDFLAGS@
+ # Should we build position-independent host code?
+ PICFLAG = @PICFLAG@
+ 
++# The linker flag for the above.
++LD_PICFLAG = @LD_PICFLAG@
++
+ # Flags to determine code coverage. When coverage is disabled, this will
+ # contain the optimization flags, as you normally want code coverage
+ # without optimization.
+@@ -266,19 +269,19 @@ LINKER = $(CC)
+ LINKER_FLAGS = $(CFLAGS)
+ endif
+ 
++enable_host_pie = @enable_host_pie@
++
+ # Enable Intel CET on Intel CET enabled host if needed.
+ CET_HOST_FLAGS = @CET_HOST_FLAGS@
+ COMPILER += $(CET_HOST_FLAGS)
+ 
+-NO_PIE_CFLAGS = @NO_PIE_CFLAGS@
+-NO_PIE_FLAG = @NO_PIE_FLAG@
+ DO_LINK_MUTEX = @DO_LINK_MUTEX@
+ 
+-# We don't want to compile the compilers with -fPIE, it make PCH fail.
+-COMPILER += $(NO_PIE_CFLAGS)
++# Maybe compile the compilers with -fPIE or -fPIC.
++COMPILER += $(PICFLAG)
+ 
+-# Link with -no-pie since we compile the compiler with -fno-PIE.
+-LINKER += $(NO_PIE_FLAG)
++# Link with -pie, or -no-pie, depending on the above.
++LINKER += $(LD_PICFLAG)
+ 
+ # Like LINKER, but use a mutex for serializing front end links.
+ ifeq (@DO_LINK_MUTEX@,true)
+@@ -1050,7 +1053,7 @@ RTL_SSA_H = $(PRETTY_PRINT_H) insn-config.h splay-tree-utils.h \
+ # programs built during a bootstrap.
+ # autoconf inserts -DCROSS_DIRECTORY_STRUCTURE if we are building a
+ # cross compiler which does not use the native headers and libraries.
+-INTERNAL_CFLAGS = -DIN_GCC $(PICFLAG) @CROSS@
++INTERNAL_CFLAGS = -DIN_GCC @CROSS@
+ 
+ # This is the variable actually used when we compile. If you change this,
+ # you probably want to update BUILD_CFLAGS in configure.ac
+@@ -1068,21 +1071,24 @@ ALL_CXXFLAGS = $(T_CFLAGS) $(CFLAGS-$@) $(CXXFLAGS) $(INTERNAL_CFLAGS) \
+ ALL_CPPFLAGS = $(INCLUDES) $(CPPFLAGS)
+ 
+ # This is the variable to use when using $(COMPILER).
+-ALL_COMPILERFLAGS = $(ALL_CXXFLAGS)
++ALL_COMPILERFLAGS = $(ALL_CXXFLAGS) $(PICFLAG)
+ 
+ # This is the variable to use when using $(LINKER).
+-ALL_LINKERFLAGS = $(ALL_CXXFLAGS)
++ALL_LINKERFLAGS = $(ALL_CXXFLAGS) $(LD_PICFLAG)
+ 
+ # Build and host support libraries.
+ 
+-# Use the "pic" build of libiberty if --enable-host-shared, unless we are
+-# building for mingw.
++# Use the "pic" build of libiberty if --enable-host-shared or --enable-host-pie,
++# unless we are building for mingw.
+ LIBIBERTY_PICDIR=$(if $(findstring mingw,$(target)),,pic)
+-ifeq ($(enable_host_shared),yes)
++ifneq ($(enable_host_shared)$(enable_host_pie),)
+ LIBIBERTY = ../libiberty/$(LIBIBERTY_PICDIR)/libiberty.a
+-BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/$(LIBIBERTY_PICDIR)/libiberty.a
+ else
+ LIBIBERTY = ../libiberty/libiberty.a
++endif
++ifeq ($(enable_host_shared),yes)
++BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/$(LIBIBERTY_PICDIR)/libiberty.a
++else
+ BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/libiberty.a
+ endif
+ 
+diff --git a/gcc/ada/gcc-interface/Make-lang.in b/gcc/ada/gcc-interface/Make-lang.in
+index 9507f2f09203..2b9b0de8273c 100644
+--- a/gcc/ada/gcc-interface/Make-lang.in
++++ b/gcc/ada/gcc-interface/Make-lang.in
+@@ -72,7 +72,8 @@ else
+ endif
+ 
+ ALL_ADAFLAGS = \
+-  $(CFLAGS) $(ADA_CFLAGS) $(ADAFLAGS) $(CHECKING_ADAFLAGS) $(WARN_ADAFLAGS)
++  $(CFLAGS) $(ADA_CFLAGS) $(ADAFLAGS) $(CHECKING_ADAFLAGS) \
++  $(WARN_ADAFLAGS) $(PICFLAG)
+ FORCE_DEBUG_ADAFLAGS = -g
+ ADA_CFLAGS =
+ COMMON_ADA_INCLUDES = -I- -I. -Iada/generated -Iada -I$(srcdir)/ada
+@@ -1109,7 +1110,7 @@ ada/b_gnat1.adb : $(GNAT1_ADA_OBJS)
+ ada/b_gnat1.o : ada/b_gnat1.adb
+         # Do not use ADAFLAGS to get rid of -gnatg which generates a lot
+         # of style messages.
+-	$(CC) -c $(CFLAGS) $(ADA_CFLAGS) -gnatp -gnatws $(ADA_INCLUDES) \
++	$(CC) -c $(CFLAGS) $(ADA_CFLAGS) $(PICFLAG) -gnatp -gnatws $(ADA_INCLUDES) \
+ 	    $< $(ADA_OUTPUT_OPTION)
+ 
+ ada/b_gnatb.adb : $(GNATBIND_OBJS) ada/gnatbind.o
+@@ -1118,7 +1119,7 @@ ada/b_gnatb.adb : $(GNATBIND_OBJS) ada/gnatbind.o
+ 	$(MV) b_gnatb.adb b_gnatb.ads ada/
+ 
+ ada/b_gnatb.o : ada/b_gnatb.adb
+-	$(CC) -c $(CFLAGS) $(ADA_CFLAGS) -gnatp -gnatws $(ADA_INCLUDES) \
++	$(CC) -c $(CFLAGS) $(ADA_CFLAGS) $(PICFLAG) -gnatp -gnatws $(ADA_INCLUDES) \
+ 	    $< $(ADA_OUTPUT_OPTION)
+ 
+ include $(srcdir)/ada/Make-generated.in
+diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in
+index da6a56fcec81..dc0e54f8eb63 100644
+--- a/gcc/ada/gcc-interface/Makefile.in
++++ b/gcc/ada/gcc-interface/Makefile.in
+@@ -91,6 +91,7 @@ LS = ls
+ RANLIB = @RANLIB@
+ RANLIB_FLAGS = @ranlib_flags@
+ AWK = @AWK@
++PICFLAG = @PICFLAG@
+ 
+ COMPILER = $(CC)
+ COMPILER_FLAGS = $(CFLAGS)
+@@ -239,7 +240,11 @@ ALL_CPPFLAGS = $(CPPFLAGS)
+ ALL_COMPILERFLAGS = $(ALL_CFLAGS)
+ 
+ # This is where we get libiberty.a from.
++ifeq ($(PICFLAG),)
+ LIBIBERTY = ../../libiberty/libiberty.a
++else
++LIBIBERTY = ../../libiberty/pic/libiberty.a
++endif
+ 
+ # We need to link against libbacktrace because diagnostic.c in
+ # libcommon.a uses it.
+@@ -256,9 +261,6 @@ TOOLS_LIBS = ../version.o ../link.o ../targext.o ../../ggc-none.o \
+   $(LIBGNAT) $(LIBINTL) $(LIBICONV) ../$(LIBBACKTRACE) ../$(LIBIBERTY) \
+   $(SYSLIBS) $(TGT_LIB)
+ 
+-# Add -no-pie to TOOLS_LIBS since some of them are compiled with -fno-PIE.
+-TOOLS_LIBS += @NO_PIE_FLAG@
+-
+ # Specify the directories to be searched for header files.
+ # Both . and srcdir are used, in that order,
+ # so that tm.h and config.h will be found in the compilation
+diff --git a/gcc/configure b/gcc/configure
+index 6cb58cd6ec60..4d0a6833cb46 100755
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -632,10 +632,10 @@ ac_includes_default="\
+ ac_subst_vars='LTLIBOBJS
+ LIBOBJS
+ CET_HOST_FLAGS
+-NO_PIE_FLAG
+-NO_PIE_CFLAGS
+-enable_default_pie
++LD_PICFLAG
+ PICFLAG
++enable_default_pie
++enable_host_pie
+ enable_host_shared
+ enable_plugin
+ pluginlibs
+@@ -1029,6 +1029,7 @@ enable_link_serialization
+ enable_version_specific_runtime_libs
+ enable_plugin
+ enable_host_shared
++enable_host_pie
+ enable_libquadmath_support
+ with_linker_hash_style
+ with_diagnostics_color
+@@ -1796,6 +1797,7 @@ Optional Features:
+                           in a compiler-specific directory
+   --enable-plugin         enable plugin support
+   --enable-host-shared    build host code as shared libraries
++  --enable-host-pie       build host code as PIE
+   --disable-libquadmath-support
+                           disable libquadmath support for Fortran
+   --enable-default-pie    enable Position Independent Executable as default
+@@ -32305,13 +32307,17 @@ fi
+ # Enable --enable-host-shared
+ # Check whether --enable-host-shared was given.
+ if test "${enable_host_shared+set}" = set; then :
+-  enableval=$enable_host_shared; PICFLAG=-fPIC
+-else
+-  PICFLAG=
++  enableval=$enable_host_shared;
+ fi
+ 
+ 
+ 
++# Enable --enable-host-pie
++# Check whether --enable-host-pie was given.
++if test "${enable_host_pie+set}" = set; then :
++  enableval=$enable_host_pie;
++fi
++
+ 
+ 
+ # Check whether --enable-libquadmath-support was given.
+@@ -32465,10 +32471,6 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_c_no_fpie" >&5
+ $as_echo "$gcc_cv_c_no_fpie" >&6; }
+-if test "$gcc_cv_c_no_fpie" = "yes"; then
+-  NO_PIE_CFLAGS="-fno-PIE"
+-fi
+-
+ 
+ # Check if -no-pie works.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -no-pie option" >&5
+@@ -32493,11 +32495,28 @@ rm -f core conftest.err conftest.$ac_objext \
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_no_pie" >&5
+ $as_echo "$gcc_cv_no_pie" >&6; }
+-if test "$gcc_cv_no_pie" = "yes"; then
+-  NO_PIE_FLAG="-no-pie"
++
++if test x$enable_host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$enable_host_pie = xyes; then
++  PICFLAG=-fPIE
++elif test x$gcc_cv_c_no_fpie = xyes; then
++  PICFLAG=-fno-PIE
++else
++  PICFLAG=
++fi
++
++if test x$enable_host_pie = xyes; then
++  LD_PICFLAG=-pie
++elif test x$gcc_cv_no_pie = xyes; then
++  LD_PICFLAG=-no-pie
++else
++  LD_PICFLAG=
+ fi
+ 
+ 
++
++
+ # Enable Intel CET on Intel CET enabled host if jit is enabled.
+  # Check whether --enable-cet was given.
+ if test "${enable_cet+set}" = set; then :
+diff --git a/gcc/configure.ac b/gcc/configure.ac
+index 8382b4e7b3fe..aaa371746ef5 100644
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -7507,11 +7507,14 @@ fi
+ # Enable --enable-host-shared
+ AC_ARG_ENABLE(host-shared,
+ [AS_HELP_STRING([--enable-host-shared],
+-		[build host code as shared libraries])],
+-[PICFLAG=-fPIC], [PICFLAG=])
++		[build host code as shared libraries])])
+ AC_SUBST(enable_host_shared)
+-AC_SUBST(PICFLAG)
+ 
++# Enable --enable-host-pie
++AC_ARG_ENABLE(host-pie,
++[AS_HELP_STRING([--enable-host-pie],
++		[build host code as PIE])])
++AC_SUBST(enable_host_pie)
+ 
+ AC_ARG_ENABLE(libquadmath-support,
+ [AS_HELP_STRING([--disable-libquadmath-support],
+@@ -7633,10 +7636,6 @@ AC_CACHE_CHECK([for -fno-PIE option],
+      [gcc_cv_c_no_fpie=yes],
+      [gcc_cv_c_no_fpie=no])
+    CXXFLAGS="$saved_CXXFLAGS"])
+-if test "$gcc_cv_c_no_fpie" = "yes"; then
+-  NO_PIE_CFLAGS="-fno-PIE"
+-fi
+-AC_SUBST([NO_PIE_CFLAGS])
+ 
+ # Check if -no-pie works.
+ AC_CACHE_CHECK([for -no-pie option],
+@@ -7647,10 +7646,27 @@ AC_CACHE_CHECK([for -no-pie option],
+      [gcc_cv_no_pie=yes],
+      [gcc_cv_no_pie=no])
+    LDFLAGS="$saved_LDFLAGS"])
+-if test "$gcc_cv_no_pie" = "yes"; then
+-  NO_PIE_FLAG="-no-pie"
++
++if test x$enable_host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$enable_host_pie = xyes; then
++  PICFLAG=-fPIE
++elif test x$gcc_cv_c_no_fpie = xyes; then
++  PICFLAG=-fno-PIE
++else
++  PICFLAG=
+ fi
+-AC_SUBST([NO_PIE_FLAG])
++
++if test x$enable_host_pie = xyes; then
++  LD_PICFLAG=-pie
++elif test x$gcc_cv_no_pie = xyes; then
++  LD_PICFLAG=-no-pie
++else
++  LD_PICFLAG=
++fi
++
++AC_SUBST([PICFLAG])
++AC_SUBST([LD_PICFLAG])
+ 
+ # Enable Intel CET on Intel CET enabled host if jit is enabled.
+ GCC_CET_HOST_FLAGS(CET_HOST_FLAGS)
+diff --git a/gcc/d/Make-lang.in b/gcc/d/Make-lang.in
+index f8885bbcfe3c..a8beb432b7ad 100644
+--- a/gcc/d/Make-lang.in
++++ b/gcc/d/Make-lang.in
+@@ -64,7 +64,7 @@ ALL_DFLAGS = $(DFLAGS-$@) $(GDCFLAGS) -fversion=IN_GCC $(CHECKING_DFLAGS) \
+ 	$(PICFLAG) $(ALIASING_FLAGS) $(NOEXCEPTION_DFLAGS) $(COVERAGE_FLAGS) \
+ 	$(WARN_DFLAGS)
+ 
+-DCOMPILE.base = $(GDC) $(NO_PIE_CFLAGS) -c $(ALL_DFLAGS) -o $@
++DCOMPILE.base = $(GDC) -c $(ALL_DFLAGS) -o $@
+ DCOMPILE = $(DCOMPILE.base) -MT $@ -MMD -MP -MF $(@D)/$(DEPDIR)/$(basename $(@F)).TPo
+ DPOSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(basename $(@F)).TPo $(@D)/$(DEPDIR)/$(basename $(@F)).Po
+ DLINKER = $(GDC) $(NO_PIE_FLAG) -lstdc++
+diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
+index b30d3691fe6f..93d5236f7b3c 100644
+--- a/gcc/doc/install.texi
++++ b/gcc/doc/install.texi
+@@ -1075,14 +1075,26 @@ code.
+ 
+ @item --enable-host-shared
+ Specify that the @emph{host} code should be built into position-independent
+-machine code (with -fPIC), allowing it to be used within shared libraries,
+-but yielding a slightly slower compiler.
++machine code (with @option{-fPIC}), allowing it to be used within shared
++libraries, but yielding a slightly slower compiler.
+ 
+ This option is required when building the libgccjit.so library.
+ 
+ Contrast with @option{--enable-shared}, which affects @emph{target}
+ libraries.
+ 
++@item --enable-host-pie
++Specify that the @emph{host} executables should be built into
++position-independent executables (with @option{-fPIE} and @option{-pie}),
++yielding a slightly slower compiler (but faster than
++@option{--enable-host-shared}).  Position-independent executables are loaded
++at random addresses each time they are executed, therefore provide additional
++protection against Return Oriented Programming (ROP) attacks.
++
++@option{--enable-host-pie}) may be used with @option{--enable-host-shared}),
++in which case @option{-fPIC} is used when compiling, and @option{-pie} when
++linking.
++
+ @item @anchor{with-gnu-as}--with-gnu-as
+ Specify that the compiler should assume that the
+ assembler it finds is the GNU assembler.  However, this does not modify
+diff --git a/intl/Makefile.in b/intl/Makefile.in
+index 409d693c48e8..5beebdc152c5 100644
+--- a/intl/Makefile.in
++++ b/intl/Makefile.in
+@@ -54,7 +54,7 @@ CTAGS = @CTAGS@
+ ETAGS = @ETAGS@
+ MKID = @MKID@
+ 
+-COMPILE = $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(DEFS-$@) $(INCLUDES)
++COMPILE = $(CC) -c $(CPPFLAGS) $(CFLAGS) @PICFLAG@ $(DEFS) $(DEFS-$@) $(INCLUDES)
+ 
+ HEADERS = \
+   gmo.h \
+diff --git a/intl/configure b/intl/configure
+index 03f40487a92b..79bb5831a47c 100755
+--- a/intl/configure
++++ b/intl/configure
+@@ -623,6 +623,8 @@ ac_header_list=
+ ac_subst_vars='LTLIBOBJS
+ LIBOBJS
+ PICFLAG
++enable_host_pie
++enable_host_shared
+ BISON3_NO
+ BISON3_YES
+ INCINTL
+@@ -731,6 +733,7 @@ with_libintl_prefix
+ with_libintl_type
+ enable_maintainer_mode
+ enable_host_shared
++enable_host_pie
+ '
+       ac_precious_vars='build_alias
+ host_alias
+@@ -1356,6 +1359,7 @@ Optional Features:
+   --disable-rpath         do not hardcode runtime library paths
+   --enable-maintainer-mode enable rules only needed by maintainers
+   --enable-host-shared    build host code as shared libraries
++  --enable-host-pie       build host code as PIE
+ 
+ Optional Packages:
+   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+@@ -6852,15 +6856,31 @@ fi
+ 
+ 
+ 
++# Enable --enable-host-shared.
+ # Check whether --enable-host-shared was given.
+ if test "${enable_host_shared+set}" = set; then :
+-  enableval=$enable_host_shared; PICFLAG=-fPIC
++  enableval=$enable_host_shared;
++fi
++
++
++
++# Enable --enable-host-pie.
++# Check whether --enable-host-pie was given.
++if test "${enable_host_pie+set}" = set; then :
++  enableval=$enable_host_pie;
++fi
++
++
++
++if test x$enable_host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$enable_host_pie = xyes; then
++  PICFLAG=-fPIE
+ else
+   PICFLAG=
+ fi
+ 
+ 
+-
+ ac_config_files="$ac_config_files Makefile config.intl"
+ 
+ cat >confcache <<\_ACEOF
+diff --git a/intl/configure.ac b/intl/configure.ac
+index 16a740aa230a..81aa831f59fd 100644
+--- a/intl/configure.ac
++++ b/intl/configure.ac
+@@ -83,10 +83,25 @@ fi
+ AC_SUBST(BISON3_YES)
+ AC_SUBST(BISON3_NO)
+ 
++# Enable --enable-host-shared.
+ AC_ARG_ENABLE(host-shared,
+ [AS_HELP_STRING([--enable-host-shared],
+-		[build host code as shared libraries])],
+-[PICFLAG=-fPIC], [PICFLAG=])
++       [build host code as shared libraries])])
++AC_SUBST(enable_host_shared)
++
++# Enable --enable-host-pie.
++AC_ARG_ENABLE(host-pie,
++[AS_HELP_STRING([--enable-host-pie],
++       [build host code as PIE])])
++AC_SUBST(enable_host_pie)
++
++if test x$enable_host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$enable_host_pie = xyes; then
++  PICFLAG=-fPIE
++else
++  PICFLAG=
++fi
+ AC_SUBST(PICFLAG)
+ 
+ AC_CONFIG_FILES(Makefile config.intl)
+diff --git a/libcody/Makefile.in b/libcody/Makefile.in
+index bb87468cb9a3..cb01b0092d8e 100644
+--- a/libcody/Makefile.in
++++ b/libcody/Makefile.in
+@@ -31,7 +31,7 @@ endif
+ CXXOPTS += $(filter-out -DHAVE_CONFIG_H,@DEFS@) -include config.h
+ 
+ # Linker options
+-LDFLAGS := @LDFLAGS@
++LDFLAGS := @LDFLAGS@ @LD_PICFLAG@
+ LIBS := @LIBS@
+ 
+ # Per-source & per-directory compile flags (warning: recursive)
+diff --git a/libcody/configure b/libcody/configure
+index da52a5cfca5e..0e536c0ccb06 100755
+--- a/libcody/configure
++++ b/libcody/configure
+@@ -591,7 +591,10 @@ configure_args
+ AR
+ RANLIB
+ EXCEPTIONS
++LD_PICFLAG
+ PICFLAG
++enable_host_pie
++enable_host_shared
+ OBJEXT
+ EXEEXT
+ ac_ct_CXX
+@@ -653,6 +656,7 @@ enable_maintainer_mode
+ with_compiler
+ enable_checking
+ enable_host_shared
++enable_host_pie
+ enable_exceptions
+ '
+       ac_precious_vars='build_alias
+@@ -1286,6 +1290,7 @@ Optional Features:
+                           yes,no,all,none,release. Flags are: misc,valgrind or
+                           other strings
+   --enable-host-shared    build host code as shared libraries
++  --enable-host-pie       build host code as PIE
+   --enable-exceptions     enable exceptions & rtti
+ 
+ Optional Packages:
+@@ -2635,11 +2640,34 @@ fi
+ # Enable --enable-host-shared.
+ # Check whether --enable-host-shared was given.
+ if test "${enable_host_shared+set}" = set; then :
+-  enableval=$enable_host_shared; PICFLAG=-fPIC
++  enableval=$enable_host_shared;
++fi
++
++
++
++# Enable --enable-host-pie.
++# Check whether --enable-host-pie was given.
++if test "${enable_host_pie+set}" = set; then :
++  enableval=$enable_host_pie;
++fi
++
++
++
++if test x$enable_host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$enable_host_pie = xyes; then
++  PICFLAG=-fPIE
+ else
+   PICFLAG=
+ fi
+ 
++if test x$enable_host_pie = xyes; then
++  LD_PICFLAG=-pie
++else
++  LD_PICFLAG=
++fi
++
++
+ 
+ 
+ # Check whether --enable-exceptions was given.
+diff --git a/libcody/configure.ac b/libcody/configure.ac
+index 960191ecb72c..14e8dd4a2260 100644
+--- a/libcody/configure.ac
++++ b/libcody/configure.ac
+@@ -63,9 +63,31 @@ fi
+ # Enable --enable-host-shared.
+ AC_ARG_ENABLE(host-shared,
+ [AS_HELP_STRING([--enable-host-shared],
+-		[build host code as shared libraries])],
+-[PICFLAG=-fPIC], [PICFLAG=])
++		[build host code as shared libraries])])
++AC_SUBST(enable_host_shared)
++
++# Enable --enable-host-pie.
++AC_ARG_ENABLE(host-pie,
++[AS_HELP_STRING([--enable-host-pie],
++		[build host code as PIE])])
++AC_SUBST(enable_host_pie)
++
++if test x$enable_host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$enable_host_pie = xyes; then
++  PICFLAG=-fPIE
++else
++  PICFLAG=
++fi
++
++if test x$enable_host_pie = xyes; then
++  LD_PICFLAG=-pie
++else
++  LD_PICFLAG=
++fi
++
+ AC_SUBST(PICFLAG)
++AC_SUBST(LD_PICFLAG)
+ 
+ NMS_ENABLE_EXCEPTIONS
+ 
+diff --git a/libcpp/configure b/libcpp/configure
+index e9937cde3303..1389ddab5440 100755
+--- a/libcpp/configure
++++ b/libcpp/configure
+@@ -625,6 +625,8 @@ ac_includes_default="\
+ ac_subst_vars='LTLIBOBJS
+ CET_HOST_FLAGS
+ PICFLAG
++enable_host_pie
++enable_host_shared
+ MAINT
+ USED_CATALOGS
+ PACKAGE
+@@ -738,6 +740,7 @@ enable_maintainer_mode
+ enable_checking
+ enable_canonical_system_headers
+ enable_host_shared
++enable_host_pie
+ enable_cet
+ enable_valgrind_annotations
+ '
+@@ -1379,6 +1382,7 @@ Optional Features:
+   --enable-canonical-system-headers
+                           enable or disable system headers canonicalization
+   --enable-host-shared    build host code as shared libraries
++  --enable-host-pie       build host code as PIE
+   --enable-cet            enable Intel CET in host libraries [default=auto]
+   --enable-valgrind-annotations
+                           enable valgrind runtime interaction
+@@ -7605,7 +7609,23 @@ esac
+ # Enable --enable-host-shared.
+ # Check whether --enable-host-shared was given.
+ if test "${enable_host_shared+set}" = set; then :
+-  enableval=$enable_host_shared; PICFLAG=-fPIC
++  enableval=$enable_host_shared;
++fi
++
++
++
++# Enable --enable-host-pie.
++# Check whether --enable-host-pie was given.
++if test "${enable_host_pie+set}" = set; then :
++  enableval=$enable_host_pie;
++fi
++
++
++
++if test x$enable_host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$enable_host_pie = xyes; then
++  PICFLAG=-fPIE
+ else
+   PICFLAG=
+ fi
+diff --git a/libcpp/configure.ac b/libcpp/configure.ac
+index 89ac99b04bdb..b29b4d6acf1f 100644
+--- a/libcpp/configure.ac
++++ b/libcpp/configure.ac
+@@ -211,8 +211,23 @@ esac
+ # Enable --enable-host-shared.
+ AC_ARG_ENABLE(host-shared,
+ [AS_HELP_STRING([--enable-host-shared],
+-		[build host code as shared libraries])],
+-[PICFLAG=-fPIC], [PICFLAG=])
++		[build host code as shared libraries])])
++AC_SUBST(enable_host_shared)
++
++# Enable --enable-host-pie.
++AC_ARG_ENABLE(host-pie,
++[AS_HELP_STRING([--enable-host-pie],
++		[build host code as PIE])])
++AC_SUBST(enable_host_pie)
++
++if test x$enable_host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$enable_host_pie = xyes; then
++  PICFLAG=-fPIE
++else
++  PICFLAG=
++fi
++
+ AC_SUBST(PICFLAG)
+ 
+ # Enable Intel CET on Intel CET enabled host if jit is enabled.
+diff --git a/libdecnumber/configure b/libdecnumber/configure
+index fb6db05565a0..84bc4ffc7673 100755
+--- a/libdecnumber/configure
++++ b/libdecnumber/configure
+@@ -626,6 +626,8 @@ ac_subst_vars='LTLIBOBJS
+ LIBOBJS
+ CET_HOST_FLAGS
+ PICFLAG
++enable_host_pie
++enable_host_shared
+ ADDITIONAL_OBJS
+ enable_decimal_float
+ target_os
+@@ -706,6 +708,7 @@ enable_werror_always
+ enable_maintainer_mode
+ enable_decimal_float
+ enable_host_shared
++enable_host_pie
+ enable_cet
+ '
+       ac_precious_vars='build_alias
+@@ -1338,6 +1341,7 @@ Optional Features:
+ 			or 'dpd' choses which decimal floating point format
+ 			to use
+   --enable-host-shared    build host code as shared libraries
++  --enable-host-pie       build host code as PIE
+   --enable-cet            enable Intel CET in host libraries [default=auto]
+ 
+ Some influential environment variables:
+@@ -5186,7 +5190,23 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
+ # Enable --enable-host-shared.
+ # Check whether --enable-host-shared was given.
+ if test "${enable_host_shared+set}" = set; then :
+-  enableval=$enable_host_shared; PICFLAG=-fPIC
++  enableval=$enable_host_shared;
++fi
++
++
++
++# Enable --enable-host-pie.
++# Check whether --enable-host-pie was given.
++if test "${enable_host_pie+set}" = set; then :
++  enableval=$enable_host_pie;
++fi
++
++
++
++if test x$enable_host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$enable_host_pie = xyes; then
++  PICFLAG=-fPIE
+ else
+   PICFLAG=
+ fi
+diff --git a/libdecnumber/configure.ac b/libdecnumber/configure.ac
+index aafd06f8a64e..30a51ca410b6 100644
+--- a/libdecnumber/configure.ac
++++ b/libdecnumber/configure.ac
+@@ -100,8 +100,23 @@ AC_C_BIGENDIAN
+ # Enable --enable-host-shared.
+ AC_ARG_ENABLE(host-shared,
+ [AS_HELP_STRING([--enable-host-shared],
+-		[build host code as shared libraries])],
+-[PICFLAG=-fPIC], [PICFLAG=])
++		[build host code as shared libraries])])
++AC_SUBST(enable_host_shared)
++
++# Enable --enable-host-pie.
++AC_ARG_ENABLE(host-pie,
++[AS_HELP_STRING([--enable-host-pie],
++		[build host code as PIE])])
++AC_SUBST(enable_host_pie)
++
++if test x$enable_host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$enable_host_pie = xyes; then
++  PICFLAG=-fPIE
++else
++  PICFLAG=
++fi
++
+ AC_SUBST(PICFLAG)
+ 
+ # Enable Intel CET on Intel CET enabled host if jit is enabled.
+diff --git a/libiberty/configure b/libiberty/configure
+index 860f981fa183..b8a19c421108 100755
+--- a/libiberty/configure
++++ b/libiberty/configure
+@@ -5258,8 +5258,8 @@ case "${enable_shared}" in
+   *) shared=yes ;;
+ esac
+ 
+-# ...unless --enable-host-shared was passed from top-level config:
+-if [ "${enable_host_shared}" = "yes" ]; then
++# ...unless --enable-host-{shared,pie} was passed from top-level config:
++if [ "${enable_host_shared}" = "yes" ] || [ "${enable_host_pie}" = "yes" ]; then
+   shared=yes
+ fi
+ 
+diff --git a/libiberty/configure.ac b/libiberty/configure.ac
+index 28d996f9cf7b..6747a7b5cffd 100644
+--- a/libiberty/configure.ac
++++ b/libiberty/configure.ac
+@@ -233,8 +233,8 @@ case "${enable_shared}" in
+   *) shared=yes ;;
+ esac
+ 
+-# ...unless --enable-host-shared was passed from top-level config:
+-if [[ "${enable_host_shared}" = "yes" ]]; then
++# ...unless --enable-host-{shared,pie} was passed from top-level config:
++if [[ "${enable_host_shared}" = "yes" ]] || [[ "${enable_host_pie}" = "yes" ]]; then
+   shared=yes
+ fi
+ 
+diff --git a/zlib/configure b/zlib/configure
+index e35ac6e7e178..77be6c284e3e 100755
+--- a/zlib/configure
++++ b/zlib/configure
+@@ -635,6 +635,8 @@ am__EXEEXT_TRUE
+ LTLIBOBJS
+ LIBOBJS
+ PICFLAG
++enable_host_pie
++enable_host_shared
+ TARGET_LIBRARY_FALSE
+ TARGET_LIBRARY_TRUE
+ toolexeclibdir
+@@ -778,6 +780,7 @@ with_gnu_ld
+ enable_libtool_lock
+ with_toolexeclibdir
+ enable_host_shared
++enable_host_pie
+ '
+       ac_precious_vars='build_alias
+ host_alias
+@@ -1420,6 +1423,7 @@ Optional Features:
+                           optimize for fast installation [default=yes]
+   --disable-libtool-lock  avoid locking (might break parallel builds)
+   --enable-host-shared    build host code as shared libraries
++  --enable-host-pie       build host code as PIE
+ 
+ Optional Packages:
+   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+@@ -10759,7 +10763,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 10762 "configure"
++#line 10778 "configure"
+ #include "confdefs.h"
+ 
+ #if HAVE_DLFCN_H
+@@ -10865,7 +10869,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 10868 "configure"
++#line 10884 "configure"
+ #include "confdefs.h"
+ 
+ #if HAVE_DLFCN_H
+@@ -11548,15 +11552,31 @@ else
+   multilib_arg=
+ fi
+ 
++# Enable --enable-host-shared.
+ # Check whether --enable-host-shared was given.
+ if test "${enable_host_shared+set}" = set; then :
+-  enableval=$enable_host_shared; PICFLAG=-fPIC
++  enableval=$enable_host_shared;
++fi
++
++
++
++# Enable --enable-host-pie.
++# Check whether --enable-host-pie was given.
++if test "${enable_host_pie+set}" = set; then :
++  enableval=$enable_host_pie;
++fi
++
++
++
++if test x$enable_host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$enable_host_pie = xyes; then
++  PICFLAG=-fPIE
+ else
+   PICFLAG=
+ fi
+ 
+ 
+-
+ ac_config_files="$ac_config_files Makefile"
+ 
+ cat >confcache <<\_ACEOF
+diff --git a/zlib/configure.ac b/zlib/configure.ac
+index be1cfe296512..adf7aad4e510 100644
+--- a/zlib/configure.ac
++++ b/zlib/configure.ac
+@@ -122,11 +122,26 @@ else
+   multilib_arg=
+ fi
+ 
++# Enable --enable-host-shared.
+ AC_ARG_ENABLE(host-shared,
+ [AS_HELP_STRING([--enable-host-shared],
+-		[build host code as shared libraries])],
+-[PICFLAG=-fPIC], [PICFLAG=])
+-AC_SUBST(PICFLAG)
++		[build host code as shared libraries])])
++AC_SUBST(enable_host_shared)
++
++# Enable --enable-host-pie.
++AC_ARG_ENABLE(host-pie,
++[AS_HELP_STRING([--enable-host-pie],
++		[build host code as PIE])])
++AC_SUBST(enable_host_pie)
++
++if test x$enable_host_shared = xyes; then
++  PICFLAG=-fPIC
++elif test x$enable_host_pie = xyes; then
++  PICFLAG=-fPIE
++else
++  PICFLAG=
++fi
+ 
++AC_SUBST(PICFLAG)
+ AC_CONFIG_FILES([Makefile])
+ AC_OUTPUT
+-- 
+2.51.0
+

diff --git a/13.3.0/gentoo/98_all_configure-Implement-enable-host-bind-now.patch b/13.3.0/gentoo/98_all_configure-Implement-enable-host-bind-now.patch
new file mode 100644
index 0000000..31f25db
--- /dev/null
+++ b/13.3.0/gentoo/98_all_configure-Implement-enable-host-bind-now.patch
@@ -0,0 +1,599 @@
+From 109c6558f9d0815c24a4da3bbf621d6a403561d1 Mon Sep 17 00:00:00 2001
+Message-ID: <109c6558f9d0815c24a4da3bbf621d6a403561d1.1755666309.git.sam@gentoo.org>
+In-Reply-To: <6a974df8a779c8220a41919d118e3cf72829bcb9.1755666309.git.sam@gentoo.org>
+References: <6a974df8a779c8220a41919d118e3cf72829bcb9.1755666309.git.sam@gentoo.org>
+From: Marek Polacek <polacek@redhat.com>
+Date: Thu, 22 Jun 2023 11:30:01 -0400
+Subject: [PATCH 2/2] configure: Implement --enable-host-bind-now
+
+As promised in the --enable-host-pie patch, this patch adds another
+configure option, --enable-host-bind-now, which adds -z now when linking
+the compiler executables in order to extend hardening.  BIND_NOW with RELRO
+allows the GOT to be marked RO; this prevents GOT modification attacks.
+
+This option does not affect linking of target libraries; you can use
+LDFLAGS_FOR_TARGET=-Wl,-z,relro,-z,now to enable RELRO/BIND_NOW.
+
+With this patch:
+$ readelf -Wd cc1{,plus,obj,gm2} f951 lto1 cpp  rust1 gnat1 | grep FLAGS
+ 0x000000000000001e (FLAGS)              BIND_NOW
+ 0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
+ 0x000000000000001e (FLAGS)              BIND_NOW
+ 0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
+ 0x000000000000001e (FLAGS)              BIND_NOW
+ 0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
+ 0x000000000000001e (FLAGS)              BIND_NOW
+ 0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
+ 0x000000000000001e (FLAGS)              BIND_NOW
+ 0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
+ 0x000000000000001e (FLAGS)              BIND_NOW
+ 0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
+ 0x000000000000001e (FLAGS)              BIND_NOW
+ 0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
+ 0x000000000000001e (FLAGS)              BIND_NOW
+ 0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
+ 0x000000000000001e (FLAGS)              BIND_NOW
+ 0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
+
+c++tools/ChangeLog:
+
+	* configure.ac (--enable-host-bind-now): New check.
+	* configure: Regenerate.
+
+gcc/ChangeLog:
+
+	* configure.ac (--enable-host-bind-now): New check.  Add
+	-Wl,-z,now to LD_PICFLAG if --enable-host-bind-now.
+	* configure: Regenerate.
+	* doc/install.texi: Document --enable-host-bind-now.
+
+lto-plugin/ChangeLog:
+
+	* configure.ac (--enable-host-bind-now): New check.  Link with
+	-z,now.
+	* configure: Regenerate.
+
+(cherry picked from commit 33ebb0dff9bb022f1e0709e0e73faabfc3df7931)
+---
+ c++tools/configure                        | 11 +++++++++++
+ c++tools/configure.ac                     |  7 +++++++
+ gcc/configure                             | 20 ++++++++++++++++++--
+ gcc/configure.ac                          | 13 ++++++++++++-
+ gcc/doc/install.texi                      |  6 ++++++
+ libgm2/Makefile.in                        | 10 +++++-----
+ libgm2/aclocal.m4                         | 10 +++++-----
+ libgm2/libm2cor/Makefile.in               | 10 +++++-----
+ libgm2/libm2iso/Makefile.in               | 10 +++++-----
+ libgm2/libm2log/Makefile.in               | 10 +++++-----
+ libgm2/libm2min/Makefile.in               | 10 +++++-----
+ libgm2/libm2pim/Makefile.in               | 10 +++++-----
+ libstdc++-v3/src/experimental/Makefile.in |  2 +-
+ lto-plugin/Makefile.in                    |  1 +
+ lto-plugin/configure                      | 20 ++++++++++++++++++--
+ lto-plugin/configure.ac                   | 11 +++++++++++
+ zlib/Makefile.in                          |  2 ++
+ zlib/configure                            |  4 ++--
+ 18 files changed, 124 insertions(+), 43 deletions(-)
+
+diff --git a/c++tools/configure b/c++tools/configure
+index 880870093839..006efe07b354 100755
+--- a/c++tools/configure
++++ b/c++tools/configure
+@@ -628,6 +628,7 @@ EGREP
+ GREP
+ CXXCPP
+ LD_PICFLAG
++enable_host_bind_now
+ PICFLAG
+ MAINTAINER
+ CXX_AUX_TOOLS
+@@ -702,6 +703,7 @@ enable_maintainer_mode
+ enable_checking
+ enable_default_pie
+ enable_host_pie
++enable_host_bind_now
+ with_gcc_major_version_only
+ '
+       ac_precious_vars='build_alias
+@@ -1336,6 +1338,7 @@ Optional Features:
+                           yes,no,all,none,release.
+   --enable-default-pie    enable Position Independent Executable as default
+   --enable-host-pie       build host code as PIE
++  --enable-host-bind-now  link host code as BIND_NOW
+ 
+ Optional Packages:
+   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+@@ -3007,6 +3010,14 @@ fi
+ 
+ 
+ 
++# Enable --enable-host-bind-now
++# Check whether --enable-host-bind-now was given.
++if test "${enable_host_bind_now+set}" = set; then :
++  enableval=$enable_host_bind_now; LD_PICFLAG="$LD_PICFLAG -Wl,-z,now"
++fi
++
++
++
+ 
+ # Check if O_CLOEXEC is defined by fcntl
+ 
+diff --git a/c++tools/configure.ac b/c++tools/configure.ac
+index 44dfaccbbfaf..c2a16601425c 100644
+--- a/c++tools/configure.ac
++++ b/c++tools/configure.ac
+@@ -110,6 +110,13 @@ AC_ARG_ENABLE(host-pie,
+ 		[build host code as PIE])],
+ [PICFLAG=-fPIE; LD_PICFLAG=-pie], [])
+ AC_SUBST(PICFLAG)
++
++# Enable --enable-host-bind-now
++AC_ARG_ENABLE(host-bind-now,
++[AS_HELP_STRING([--enable-host-bind-now],
++       [link host code as BIND_NOW])],
++[LD_PICFLAG="$LD_PICFLAG -Wl,-z,now"], [])
++AC_SUBST(enable_host_bind_now)
+ AC_SUBST(LD_PICFLAG)
+ 
+ # Check if O_CLOEXEC is defined by fcntl
+diff --git a/gcc/configure b/gcc/configure
+index 4d0a6833cb46..6943cf1a4ab6 100755
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -635,6 +635,7 @@ CET_HOST_FLAGS
+ LD_PICFLAG
+ PICFLAG
+ enable_default_pie
++enable_host_bind_now
+ enable_host_pie
+ enable_host_shared
+ enable_plugin
+@@ -1030,6 +1031,7 @@ enable_version_specific_runtime_libs
+ enable_plugin
+ enable_host_shared
+ enable_host_pie
++enable_host_bind_now
+ enable_libquadmath_support
+ with_linker_hash_style
+ with_diagnostics_color
+@@ -1798,6 +1800,7 @@ Optional Features:
+   --enable-plugin         enable plugin support
+   --enable-host-shared    build host code as shared libraries
+   --enable-host-pie       build host code as PIE
++  --enable-host-bind-now  link host code as BIND_NOW
+   --disable-libquadmath-support
+                           disable libquadmath support for Fortran
+   --enable-default-pie    enable Position Independent Executable as default
+@@ -19909,7 +19912,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 19910 "configure"
++#line 19915 "configure"
+ #include "confdefs.h"
+ 
+ #if HAVE_DLFCN_H
+@@ -20015,7 +20018,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 20016 "configure"
++#line 20021 "configure"
+ #include "confdefs.h"
+ 
+ #if HAVE_DLFCN_H
+@@ -32320,6 +32323,14 @@ fi
+ 
+ 
+ 
++# Enable --enable-host-bind-now
++# Check whether --enable-host-bind-now was given.
++if test "${enable_host_bind_now+set}" = set; then :
++  enableval=$enable_host_bind_now;
++fi
++
++
++
+ # Check whether --enable-libquadmath-support was given.
+ if test "${enable_libquadmath_support+set}" = set; then :
+   enableval=$enable_libquadmath_support; ENABLE_LIBQUADMATH_SUPPORT=$enableval
+@@ -32506,6 +32517,8 @@ else
+   PICFLAG=
+ fi
+ 
++
++
+ if test x$enable_host_pie = xyes; then
+   LD_PICFLAG=-pie
+ elif test x$gcc_cv_no_pie = xyes; then
+@@ -32514,6 +32527,9 @@ else
+   LD_PICFLAG=
+ fi
+ 
++if test x$enable_host_bind_now = xyes; then
++  LD_PICFLAG="$LD_PICFLAG -Wl,-z,now"
++fi
+ 
+ 
+ 
+diff --git a/gcc/configure.ac b/gcc/configure.ac
+index aaa371746ef5..1b84fa5a677b 100644
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -7516,6 +7516,12 @@ AC_ARG_ENABLE(host-pie,
+ 		[build host code as PIE])])
+ AC_SUBST(enable_host_pie)
+ 
++# Enable --enable-host-bind-now
++AC_ARG_ENABLE(host-bind-now,
++[AS_HELP_STRING([--enable-host-bind-now],
++		[link host code as BIND_NOW])])
++AC_SUBST(enable_host_bind_now)
++
+ AC_ARG_ENABLE(libquadmath-support,
+ [AS_HELP_STRING([--disable-libquadmath-support],
+   [disable libquadmath support for Fortran])],
+@@ -7657,6 +7663,8 @@ else
+   PICFLAG=
+ fi
+ 
++AC_SUBST([PICFLAG])
++
+ if test x$enable_host_pie = xyes; then
+   LD_PICFLAG=-pie
+ elif test x$gcc_cv_no_pie = xyes; then
+@@ -7665,7 +7673,10 @@ else
+   LD_PICFLAG=
+ fi
+ 
+-AC_SUBST([PICFLAG])
++if test x$enable_host_bind_now = xyes; then
++  LD_PICFLAG="$LD_PICFLAG -Wl,-z,now"
++fi
++
+ AC_SUBST([LD_PICFLAG])
+ 
+ # Enable Intel CET on Intel CET enabled host if jit is enabled.
+diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
+index 93d5236f7b3c..1122bc82e0dc 100644
+--- a/gcc/doc/install.texi
++++ b/gcc/doc/install.texi
+@@ -1095,6 +1095,12 @@ protection against Return Oriented Programming (ROP) attacks.
+ in which case @option{-fPIC} is used when compiling, and @option{-pie} when
+ linking.
+ 
++@item --enable-host-bind-now
++Specify that the @emph{host} executables should be linked with the option
++@option{-Wl,-z,now}, which means that the dynamic linker will resolve all
++symbols when the executables are started, and that in turn allows RELRO to
++mark the GOT read-only, resulting in better security.
++
+ @item @anchor{with-gnu-as}--with-gnu-as
+ Specify that the compiler should assume that the
+ assembler it finds is the GNU assembler.  However, this does not modify
+diff --git a/libgm2/Makefile.in b/libgm2/Makefile.in
+index 2b9592b34907..d9950065de19 100644
+--- a/libgm2/Makefile.in
++++ b/libgm2/Makefile.in
+@@ -90,15 +90,15 @@ host_triplet = @host@
+ target_triplet = @target@
+ subdir = .
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+-am__aclocal_m4_deps = $(top_srcdir)/../libtool.m4 \
+-	$(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
+-	$(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
+-	$(top_srcdir)/../config/acx.m4 \
++am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
+ 	$(top_srcdir)/../config/depstand.m4 \
+ 	$(top_srcdir)/../config/lead-dot.m4 \
+ 	$(top_srcdir)/../config/multi.m4 \
+ 	$(top_srcdir)/../config/no-executables.m4 \
+-	$(top_srcdir)/../config/override.m4 $(top_srcdir)/configure.ac
++	$(top_srcdir)/../config/override.m4 \
++	$(top_srcdir)/../libtool.m4 $(top_srcdir)/../ltoptions.m4 \
++	$(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \
++	$(top_srcdir)/../lt~obsolete.m4 $(top_srcdir)/configure.ac
+ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ 	$(ACLOCAL_M4)
+ DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
+diff --git a/libgm2/aclocal.m4 b/libgm2/aclocal.m4
+index c352303012d2..832065fbb9be 100644
+--- a/libgm2/aclocal.m4
++++ b/libgm2/aclocal.m4
+@@ -1187,14 +1187,14 @@ AC_SUBST([am__tar])
+ AC_SUBST([am__untar])
+ ]) # _AM_PROG_TAR
+ 
+-m4_include([../libtool.m4])
+-m4_include([../ltoptions.m4])
+-m4_include([../ltsugar.m4])
+-m4_include([../ltversion.m4])
+-m4_include([../lt~obsolete.m4])
+ m4_include([../config/acx.m4])
+ m4_include([../config/depstand.m4])
+ m4_include([../config/lead-dot.m4])
+ m4_include([../config/multi.m4])
+ m4_include([../config/no-executables.m4])
+ m4_include([../config/override.m4])
++m4_include([../libtool.m4])
++m4_include([../ltoptions.m4])
++m4_include([../ltsugar.m4])
++m4_include([../ltversion.m4])
++m4_include([../lt~obsolete.m4])
+diff --git a/libgm2/libm2cor/Makefile.in b/libgm2/libm2cor/Makefile.in
+index 8daf0eaa054e..4d2d86f3c973 100644
+--- a/libgm2/libm2cor/Makefile.in
++++ b/libgm2/libm2cor/Makefile.in
+@@ -107,15 +107,15 @@ host_triplet = @host@
+ target_triplet = @target@
+ subdir = libm2cor
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+-am__aclocal_m4_deps = $(top_srcdir)/../libtool.m4 \
+-	$(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
+-	$(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
+-	$(top_srcdir)/../config/acx.m4 \
++am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
+ 	$(top_srcdir)/../config/depstand.m4 \
+ 	$(top_srcdir)/../config/lead-dot.m4 \
+ 	$(top_srcdir)/../config/multi.m4 \
+ 	$(top_srcdir)/../config/no-executables.m4 \
+-	$(top_srcdir)/../config/override.m4 $(top_srcdir)/configure.ac
++	$(top_srcdir)/../config/override.m4 \
++	$(top_srcdir)/../libtool.m4 $(top_srcdir)/../ltoptions.m4 \
++	$(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \
++	$(top_srcdir)/../lt~obsolete.m4 $(top_srcdir)/configure.ac
+ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ 	$(ACLOCAL_M4)
+ DIST_COMMON = $(srcdir)/Makefile.am
+diff --git a/libgm2/libm2iso/Makefile.in b/libgm2/libm2iso/Makefile.in
+index 8d6443d39466..dc0c41b17aac 100644
+--- a/libgm2/libm2iso/Makefile.in
++++ b/libgm2/libm2iso/Makefile.in
+@@ -107,15 +107,15 @@ host_triplet = @host@
+ target_triplet = @target@
+ subdir = libm2iso
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+-am__aclocal_m4_deps = $(top_srcdir)/../libtool.m4 \
+-	$(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
+-	$(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
+-	$(top_srcdir)/../config/acx.m4 \
++am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
+ 	$(top_srcdir)/../config/depstand.m4 \
+ 	$(top_srcdir)/../config/lead-dot.m4 \
+ 	$(top_srcdir)/../config/multi.m4 \
+ 	$(top_srcdir)/../config/no-executables.m4 \
+-	$(top_srcdir)/../config/override.m4 $(top_srcdir)/configure.ac
++	$(top_srcdir)/../config/override.m4 \
++	$(top_srcdir)/../libtool.m4 $(top_srcdir)/../ltoptions.m4 \
++	$(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \
++	$(top_srcdir)/../lt~obsolete.m4 $(top_srcdir)/configure.ac
+ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ 	$(ACLOCAL_M4)
+ DIST_COMMON = $(srcdir)/Makefile.am
+diff --git a/libgm2/libm2log/Makefile.in b/libgm2/libm2log/Makefile.in
+index 2188f9ec0c50..3f26f7bd1e5b 100644
+--- a/libgm2/libm2log/Makefile.in
++++ b/libgm2/libm2log/Makefile.in
+@@ -107,15 +107,15 @@ host_triplet = @host@
+ target_triplet = @target@
+ subdir = libm2log
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+-am__aclocal_m4_deps = $(top_srcdir)/../libtool.m4 \
+-	$(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
+-	$(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
+-	$(top_srcdir)/../config/acx.m4 \
++am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
+ 	$(top_srcdir)/../config/depstand.m4 \
+ 	$(top_srcdir)/../config/lead-dot.m4 \
+ 	$(top_srcdir)/../config/multi.m4 \
+ 	$(top_srcdir)/../config/no-executables.m4 \
+-	$(top_srcdir)/../config/override.m4 $(top_srcdir)/configure.ac
++	$(top_srcdir)/../config/override.m4 \
++	$(top_srcdir)/../libtool.m4 $(top_srcdir)/../ltoptions.m4 \
++	$(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \
++	$(top_srcdir)/../lt~obsolete.m4 $(top_srcdir)/configure.ac
+ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ 	$(ACLOCAL_M4)
+ DIST_COMMON = $(srcdir)/Makefile.am
+diff --git a/libgm2/libm2min/Makefile.in b/libgm2/libm2min/Makefile.in
+index 42cba0e37b9f..1c0bebdc3044 100644
+--- a/libgm2/libm2min/Makefile.in
++++ b/libgm2/libm2min/Makefile.in
+@@ -107,15 +107,15 @@ host_triplet = @host@
+ target_triplet = @target@
+ subdir = libm2min
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+-am__aclocal_m4_deps = $(top_srcdir)/../libtool.m4 \
+-	$(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
+-	$(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
+-	$(top_srcdir)/../config/acx.m4 \
++am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
+ 	$(top_srcdir)/../config/depstand.m4 \
+ 	$(top_srcdir)/../config/lead-dot.m4 \
+ 	$(top_srcdir)/../config/multi.m4 \
+ 	$(top_srcdir)/../config/no-executables.m4 \
+-	$(top_srcdir)/../config/override.m4 $(top_srcdir)/configure.ac
++	$(top_srcdir)/../config/override.m4 \
++	$(top_srcdir)/../libtool.m4 $(top_srcdir)/../ltoptions.m4 \
++	$(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \
++	$(top_srcdir)/../lt~obsolete.m4 $(top_srcdir)/configure.ac
+ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ 	$(ACLOCAL_M4)
+ DIST_COMMON = $(srcdir)/Makefile.am
+diff --git a/libgm2/libm2pim/Makefile.in b/libgm2/libm2pim/Makefile.in
+index 4c2d574392b4..f79adb389710 100644
+--- a/libgm2/libm2pim/Makefile.in
++++ b/libgm2/libm2pim/Makefile.in
+@@ -107,15 +107,15 @@ host_triplet = @host@
+ target_triplet = @target@
+ subdir = libm2pim
+ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+-am__aclocal_m4_deps = $(top_srcdir)/../libtool.m4 \
+-	$(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
+-	$(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
+-	$(top_srcdir)/../config/acx.m4 \
++am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
+ 	$(top_srcdir)/../config/depstand.m4 \
+ 	$(top_srcdir)/../config/lead-dot.m4 \
+ 	$(top_srcdir)/../config/multi.m4 \
+ 	$(top_srcdir)/../config/no-executables.m4 \
+-	$(top_srcdir)/../config/override.m4 $(top_srcdir)/configure.ac
++	$(top_srcdir)/../config/override.m4 \
++	$(top_srcdir)/../libtool.m4 $(top_srcdir)/../ltoptions.m4 \
++	$(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \
++	$(top_srcdir)/../lt~obsolete.m4 $(top_srcdir)/configure.ac
+ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ 	$(ACLOCAL_M4)
+ DIST_COMMON = $(srcdir)/Makefile.am
+diff --git a/libstdc++-v3/src/experimental/Makefile.in b/libstdc++-v3/src/experimental/Makefile.in
+index 238c96d9f9a8..e5f8fe0d5147 100644
+--- a/libstdc++-v3/src/experimental/Makefile.in
++++ b/libstdc++-v3/src/experimental/Makefile.in
+@@ -712,8 +712,8 @@ distclean-generic:
+ maintainer-clean-generic:
+ 	@echo "This command is intended for maintainers to use"
+ 	@echo "it deletes files that may require special tools to rebuild."
+-@ENABLE_BACKTRACE_FALSE@install-exec-local:
+ @ENABLE_BACKTRACE_FALSE@uninstall-local:
++@ENABLE_BACKTRACE_FALSE@install-exec-local:
+ clean: clean-am
+ 
+ clean-am: clean-generic clean-libtool clean-toolexeclibLTLIBRARIES \
+diff --git a/lto-plugin/Makefile.in b/lto-plugin/Makefile.in
+index cb568e1e09fc..f6f5b020ff5f 100644
+--- a/lto-plugin/Makefile.in
++++ b/lto-plugin/Makefile.in
+@@ -298,6 +298,7 @@ datadir = @datadir@
+ datarootdir = @datarootdir@
+ docdir = @docdir@
+ dvidir = @dvidir@
++enable_host_bind_now = @enable_host_bind_now@
+ exec_prefix = @exec_prefix@
+ gcc_build_dir = @gcc_build_dir@
+ get_gcc_base_ver = @get_gcc_base_ver@
+diff --git a/lto-plugin/configure b/lto-plugin/configure
+index d522bd24c957..675b9cfa522e 100755
+--- a/lto-plugin/configure
++++ b/lto-plugin/configure
+@@ -663,6 +663,7 @@ accel_dir_suffix
+ gcc_build_dir
+ CET_HOST_FLAGS
+ ac_lto_plugin_ldflags
++enable_host_bind_now
+ ac_lto_plugin_warn_cflags
+ EGREP
+ GREP
+@@ -778,6 +779,7 @@ enable_maintainer_mode
+ with_libiberty
+ enable_dependency_tracking
+ enable_largefile
++enable_host_bind_now
+ enable_cet
+ with_gcc_major_version_only
+ enable_shared
+@@ -1425,6 +1427,7 @@ Optional Features:
+   --disable-dependency-tracking
+                           speeds up one-time build
+   --disable-largefile     omit support for large files
++  --enable-host-bind-now  link host code as BIND_NOW
+   --enable-cet            enable Intel CET in host libraries [default=auto]
+   --enable-shared[=PKGS]  build shared libraries [default=yes]
+   --enable-static[=PKGS]  build static libraries [default=yes]
+@@ -5669,6 +5672,19 @@ if test "x$have_static_libgcc" = xyes; then
+    ac_lto_plugin_ldflags="-Wc,-static-libgcc"
+ fi
+ 
++# Enable --enable-host-bind-now
++# Check whether --enable-host-bind-now was given.
++if test "${enable_host_bind_now+set}" = set; then :
++  enableval=$enable_host_bind_now;
++fi
++
++
++
++if test x$enable_host_bind_now = xyes; then
++  ac_lto_plugin_ldflags="$ac_lto_plugin_ldflags -Wl,-z,now"
++fi
++
++
+ 
+  # Check whether --enable-cet was given.
+ if test "${enable_cet+set}" = set; then :
+@@ -12134,7 +12150,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 12137 "configure"
++#line 12153 "configure"
+ #include "confdefs.h"
+ 
+ #if HAVE_DLFCN_H
+@@ -12240,7 +12256,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 12243 "configure"
++#line 12259 "configure"
+ #include "confdefs.h"
+ 
+ #if HAVE_DLFCN_H
+diff --git a/lto-plugin/configure.ac b/lto-plugin/configure.ac
+index 0a7202782ae4..84f2a60b4800 100644
+--- a/lto-plugin/configure.ac
++++ b/lto-plugin/configure.ac
+@@ -25,6 +25,17 @@ LDFLAGS="$saved_LDFLAGS"
+ if test "x$have_static_libgcc" = xyes; then
+    ac_lto_plugin_ldflags="-Wc,-static-libgcc"
+ fi
++
++# Enable --enable-host-bind-now
++AC_ARG_ENABLE(host-bind-now,
++[AS_HELP_STRING([--enable-host-bind-now],
++       [link host code as BIND_NOW])])
++AC_SUBST(enable_host_bind_now)
++
++if test x$enable_host_bind_now = xyes; then
++  ac_lto_plugin_ldflags="$ac_lto_plugin_ldflags -Wl,-z,now"
++fi
++
+ AC_SUBST(ac_lto_plugin_ldflags)
+ 
+ GCC_CET_HOST_FLAGS(CET_HOST_FLAGS)
+diff --git a/zlib/Makefile.in b/zlib/Makefile.in
+index 3f5102d1b873..80fe3b691166 100644
+--- a/zlib/Makefile.in
++++ b/zlib/Makefile.in
+@@ -353,6 +353,8 @@ datadir = @datadir@
+ datarootdir = @datarootdir@
+ docdir = @docdir@
+ dvidir = @dvidir@
++enable_host_pie = @enable_host_pie@
++enable_host_shared = @enable_host_shared@
+ exec_prefix = @exec_prefix@
+ host = @host@
+ host_alias = @host_alias@
+diff --git a/zlib/configure b/zlib/configure
+index 77be6c284e3e..9308866a636f 100755
+--- a/zlib/configure
++++ b/zlib/configure
+@@ -10763,7 +10763,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 10778 "configure"
++#line 10766 "configure"
+ #include "confdefs.h"
+ 
+ #if HAVE_DLFCN_H
+@@ -10869,7 +10869,7 @@ else
+   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+   lt_status=$lt_dlunknown
+   cat > conftest.$ac_ext <<_LT_EOF
+-#line 10884 "configure"
++#line 10872 "configure"
+ #include "confdefs.h"
+ 
+ #if HAVE_DLFCN_H
+-- 
+2.51.0
+

diff --git a/13.3.0/gentoo/README.history b/13.3.0/gentoo/README.history
index 575c188..e5e675c 100644
--- a/13.3.0/gentoo/README.history
+++ b/13.3.0/gentoo/README.history
@@ -1,3 +1,8 @@
+9	22 August 2025
+
+	+ 97_all_configure-Implement-enable-host-pie.patch
+	+ 98_all_configure-Implement-enable-host-bind-now.patch
+
 8	3 August 2025
 
 	+ 94_all_genoutput-Accelerate-the-place_operands-function.patch


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-08-22  5:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-02 13:32 [gentoo-commits] proj/gcc-patches:master commit in: 13.3.0/gentoo/ Sam James
  -- strict thread matches above, loose matches on Subject: below --
2025-08-22  5:15 Sam James
2025-08-03 14:14 Sam James
2025-07-31  1:11 Sam James
2025-05-27 14:15 Sam James
2025-04-24 23:30 Sam James
2025-04-18 23:23 Sam James

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox