summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LICENSE202
-rw-r--r--LICENSE.patches340
-rw-r--r--README.md186
-rw-r--r--doc/BOOTSTRAP.md99
-rw-r--r--doc/COMPILERS.md61
-rw-r--r--doc/TOOLS.md45
-rw-r--r--etc/defaults/CC/clang.TARGETS11
-rw-r--r--etc/defaults/CC/foreign/clang.TARGETS19
-rw-r--r--etc/defaults/CC/foreign/gcc.TARGETS15
-rw-r--r--etc/defaults/CC/foreign/stage-0.TARGETS1
-rw-r--r--etc/defaults/CC/foreign/stage-1.TARGETS15
-rw-r--r--etc/defaults/CC/foreign/static-build.TARGETS15
-rw-r--r--etc/defaults/CC/foreign/test.TARGETS1
-rw-r--r--etc/defaults/CC/gcc.TARGETS11
-rw-r--r--etc/defaults/CC/stage-0.TARGETS26
-rw-r--r--etc/defaults/CC/stage-1.TARGETS11
-rw-r--r--etc/defaults/CC/static-build.TARGETS12
-rw-r--r--etc/defaults/CC/test.TARGETS3
-rw-r--r--etc/defaults/shell/test/test.TARGETS1
-rw-r--r--etc/imports/binutils.TARGETS26
-rw-r--r--etc/imports/boringssl.TARGETS684
-rw-r--r--etc/imports/files.TARGETS1
-rw-r--r--etc/imports/musl-cross-make-fe915821.TARGETS44
-rw-r--r--etc/imports/src/include/openssl/boringssl.TARGETS86
-rw-r--r--etc/imports/zlib.TARGETS17
-rw-r--r--etc/patches/TARGETS8
-rw-r--r--etc/patches/clang-16/libcxx-musl-support.patch57
-rw-r--r--etc/patches/clang-17/libcxx-musl-support.patch57
-rw-r--r--etc/patches/gcc-10/detect-glibc-via-__GLIBC__.patch69
-rw-r--r--etc/patches/gcc-10/reproducibility/0001-strip-build-directory-from-fixinclues.patch29
-rw-r--r--etc/patches/gcc-10/reproducibility/0002-compute-reproducible-checksums.patch75
-rw-r--r--etc/patches/gcc-10/reproducibility/series2
-rw-r--r--etc/patches/gcc-13/reproducibility/0001-strip-build-directory-from-config-arguments.patch42
-rw-r--r--etc/patches/gcc-13/reproducibility/0002-strip-build-directory-from-fixinclues.patch29
-rw-r--r--etc/patches/gcc-13/reproducibility/0003-strip-build-directory-from-mkheaders.conf.patch25
-rw-r--r--etc/patches/gcc-13/reproducibility/0004-compute-reproducible-checksums.patch75
-rw-r--r--etc/patches/gcc-13/reproducibility/0005-do-not-hardcode-rpath-into-cc1-libs.patch26
-rw-r--r--etc/patches/gcc-13/reproducibility/series5
-rw-r--r--etc/patches/gcc-4.7.4/musl-support/0001-config.sub-add-musl-support-for-gmp-mpc-mpfr.patch80
-rw-r--r--etc/patches/gcc-4.7.4/musl-support/0002-config.sub-add-musl-support-for-gcc.patch39
-rw-r--r--etc/patches/gcc-4.7.4/musl-support/0003-musl-libc-config.patch330
-rw-r--r--etc/patches/gcc-4.7.4/musl-support/0004-x86-musl-support.patch50
-rw-r--r--etc/patches/gcc-4.7.4/musl-support/0005-libstdc-workaround-for-musl.patch50
-rw-r--r--etc/patches/gcc-4.7.4/musl-support/0006-config.guess-add-musl-support.patch196
-rw-r--r--etc/patches/gcc-4.7.4/musl-support/0007-config.guess-detect-glibc-via-__GLIBC__.patch70
-rw-r--r--etc/patches/gcc-4.7.4/musl-support/series7
-rw-r--r--etc/patches/gcc-4.7.4/reproducibility/0001-strip-build-directory-from-fixinclues.patch29
-rw-r--r--etc/patches/gcc-4.7.4/reproducibility/0002-compute-reproducible-checksums.patch58
-rw-r--r--etc/patches/gcc-4.7.4/reproducibility/series2
-rw-r--r--etc/patches/gcc-4.7.4/use-ucontext_t.patch153
-rw-r--r--etc/patches/gcc-4.7.4/various-fixes/0001-non-behavioral-changing-fix-in-gcc-cp-rtti.c.patch46
-rw-r--r--etc/patches/gcc-4.7.4/various-fixes/0002-comment-out-M4-m4-not-needed-in-gmp-configure.patch35
-rw-r--r--etc/patches/gcc-4.7.4/various-fixes/0003-cfns-fix-mismatch-in-gnu_inline-attributes.patch62
-rw-r--r--etc/patches/gcc-4.7.4/various-fixes/0004-fix-gmp-configure-to-comply-with-newer-c-standards.patch234
-rw-r--r--etc/patches/gcc-4.7.4/various-fixes/series4
-rw-r--r--etc/patches/musl-cross-make-fe915821/fix-asound-patch.patch167
-rw-r--r--etc/patches/musl-cross-make-fe915821/patches/binutils-latest/0001-j2.diff585
-rw-r--r--etc/patches/musl-cross-make-fe915821/patches/gcc-13/0001-ssp_nonshared.diff14
-rw-r--r--etc/patches/musl-cross-make-fe915821/patches/gcc-13/0002-posix_memalign.diff30
-rw-r--r--etc/patches/musl-cross-make-fe915821/patches/gcc-13/0003-j2.diff346
-rw-r--r--etc/patches/musl-cross-make-fe915821/patches/gcc-13/0004-static-pie.diff92
-rw-r--r--etc/patches/musl-cross-make-fe915821/patches/gcc-13/0005-m68k-sqrt.diff20
-rw-r--r--etc/repos.json651
-rw-r--r--etc/scripts/TARGETS5
-rwxr-xr-xetc/scripts/bootstrap-ar.sh50
-rw-r--r--etc/scripts/bootstrap-busybox/appletlib.c37
-rwxr-xr-xetc/scripts/bootstrap-busybox/bootstrap.sh92
-rw-r--r--etc/scripts/bootstrap-busybox/include/common_bufsiz.h3
-rw-r--r--etc/scripts/bootstrap-busybox/include/libbb.h162
-rw-r--r--src/bootstrap/stage-0-binutils.TARGETS74
-rw-r--r--src/bootstrap/stage-0-busybox.TARGETS63
-rw-r--r--src/bootstrap/stage-0-gcc.TARGETS150
-rw-r--r--src/bootstrap/stage-0-make.TARGETS54
-rw-r--r--src/bootstrap/stage-1-gcc.TARGETS156
-rw-r--r--src/compilers/clang-16-native.TARGETS226
-rw-r--r--src/compilers/clang-17-native.TARGETS226
-rw-r--r--src/compilers/gcc-13-musl-static.TARGETS121
-rw-r--r--src/compilers/gcc-13-musl.TARGETS161
-rw-r--r--src/compilers/gcc-13-native.TARGETS193
-rw-r--r--src/tools/busybox-1.36.TARGETS21
-rw-r--r--src/tools/cmake-3.27.TARGETS43
-rw-r--r--src/tools/make-4.4.TARGETS20
-rw-r--r--src/tools/python-3.12.TARGETS36
-rw-r--r--test/TARGETS260
-rw-r--r--test/main.c6
-rw-r--r--test/main.cpp6
-rw-r--r--test/test.sh5
-rw-r--r--toolchains/CC/clang.TARGETS89
-rw-r--r--toolchains/CC/compiler+tools.TARGETS5
-rw-r--r--toolchains/CC/foreign/busybox.TARGETS13
-rw-r--r--toolchains/CC/foreign/cmake.TARGETS8
-rw-r--r--toolchains/CC/foreign/compiler+tools.TARGETS5
-rw-r--r--toolchains/CC/foreign/make.TARGETS8
-rw-r--r--toolchains/CC/foreign/python.TARGETS7
-rw-r--r--toolchains/CC/foreign/tools-all.TARGETS10
-rw-r--r--toolchains/CC/gcc.TARGETS38
-rw-r--r--toolchains/busybox.TARGETS3
-rw-r--r--toolchains/clang.TARGETS3
-rw-r--r--toolchains/cmake.TARGETS3
-rw-r--r--toolchains/compiler+tools.TARGETS8
-rw-r--r--toolchains/gcc.TARGETS3
-rw-r--r--toolchains/make.TARGETS3
-rw-r--r--toolchains/patch/busybox.TARGETS9
-rw-r--r--toolchains/patch/compiler+tools.TARGETS5
-rw-r--r--toolchains/patch/tools-all.TARGETS5
-rw-r--r--toolchains/python.TARGETS3
-rw-r--r--toolchains/tools-all.TARGETS10
107 files changed, 8189 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/LICENSE.patches b/LICENSE.patches
new file mode 100644
index 0000000..623b625
--- /dev/null
+++ b/LICENSE.patches
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..9af8dad
--- /dev/null
+++ b/README.md
@@ -0,0 +1,186 @@
+# Bootstrappable Toolchain
+
+This repository provides compiler toolchains and additional build tools that are
+acquired via [**Bootstrappable Builds**](https://bootstrappable.org/). *For
+details about the bootstrap process, see [BOOTSTRAP.md](./doc/BOOTSTRAP.md).*
+
+Available compiler toolchains are:
+
+- `gcc-latest-native`
+- `gcc-13.2.0-native`
+- `clang-latest-native`
+- `clang-17.0.1-native`
+- `clang-16.0.6-native`
+- `gcc-latest-musl`
+- `gcc-13.2.0-musl`
+- `gcc-latest-musl-static`
+- `gcc-13.2.0-musl-static`
+
+*For details about how these compilers are built, see
+[COMPILERS.md](./doc/COMPILERS.md).*
+
+Available build tools are:
+
+- `busybox-latest`
+- `busybox-1.36.1`
+- `make-latest`
+- `make-4.4.1`
+- `cmake-latest`
+- `cmake-3.27.1`
+- `python-latest`
+- `python-3.12.0`
+- `tools-all` (bundle of all latest tools)
+
+*All tools are statically linked so that they can run on systems without any
+existing C library. For details about how these tools are built, see
+[TOOLS.md](./doc/TOOLS.md).*
+
+Details about toolchain variants:
+
+- `<compiler>-native`: *native* compiler
+ - runs on the build host
+ - **supports native compilation for the host architecture**
+- `<compiler>-musl`: *cross* compiler with musl support
+ - runs on the build host
+ - **links against bundled *musl libc***
+ (*note that dynamically linked binaries require a working musl ld+libc on
+ the target system*)
+ - **supports fully static linking (unlike *glibc* toolchains)**
+ - **supports cross-compilation for project's `TARGET_ARCH`**
+- `<compiler>-musl-static`: statically linked compiler with musl support
+ - runs on systems without any existing C library
+ - **links against bundled *musl libc***
+ (*note that dynamically linked binaries require a working musl ld+libc on
+ the target system*)
+ - **supports fully static linking (unlike *glibc* toolchains)**
+- `<toolchain>+tools` (e.g., `gcc-13.2.0-native+tools`)
+ - `<toolchain>` bundled with all latest tools (see `tools-all` above)
+
+Non-static `musl` variants support cross-compilation. In your project, make sure
+that the variables `ARCH` and `TARGET_ARCH` are set to one of the following
+values: `x86`, `x86_64`, `arm`, or `arm64`.
+
+## Usage
+
+All provided toolchains can be
+1. imported to an existing
+[Justbuild](https://github.com/just-buildsystem/justbuild) project, or
+2. installed to local disk to obtain a portable toolchain.
+
+### 1. Importing toolchains to Justbuild projects
+
+If your project includes its toolchain via an open name (usually a repository
+named `toolchain`), you can create that repository by importing any of the
+provided toolchains (e.g., `gcc-latest-musl+tools`) with the tool
+`just-import-git`:
+
+~~~ sh
+$ just-import-git -C repos.template.json --as toolchain -b master \
+ https://github.com/just-buildsystem/bootstrappable-toolchain gcc-latest-musl+tools \
+ > repos.json
+~~~
+
+### 2. Obtaining a portable toolchain
+
+You can install a portable version of any provided toolchain (e.g.,
+`gcc-latest-musl`) to your local disk with:
+
+~~~ sh
+$ just-mr --main gcc-latest-musl install toolchain -D'{"ARCH":"x86_64"}' -o /opt/gcc
+~~~
+
+*Note that the configuration variable `ARCH` should be set to the host
+architecture. For installing a cross-compiler, you can additionally set
+`BUILD_ARCH` to specify a different target architecture.*
+
+## Initial requirements
+
+For bootstrapping the toolchains, the build host must be a Linux system with:
+
+1. Coreutils
+2. POSIX-compliant shell (`/bin/sh`)
+3. C compiler (e.g., TinyCC, old GCC)
+
+The C compiler for bootstrapping can be specified by setting the fields
+`BOOTSTRAP_CC` and `BOOTSTRAP_PATH` in configuration variable `TOOLCHAIN_CONFIG`
+(e.g., on command line `-D'{"TOOLCHAIN_CONFIG": {"BOOTSTRAP_CC": "gcc"}}'`). If
+not set, the C compiler is assumed to be `cc` available in the search paths
+`/bin` or `/usr/bin`.
+
+*Note that currently supported build hosts are required to be an `x86_64`
+architecture and use either the GNU or musl C library.*
+
+## Toolchain Targets
+
+All toolchains provide the following target:
+- `["", "toolchain"]`:
+ The portable toolchain file tree (e.g., `bin`, `lib`, etc.)
+ Set `BUILD_ARCH` to specify the target architecture for cross-compilers.
+
+All compiler toolchains additionally provide:
+- `["CC", "defaults"]`:
+ The `CC` toolchain definition for use with
+ [rules-cc](https://github.com/just-buildsystem/rules-cc)
+
+All tool toolchains (including `<compiler>+tools`) provide:
+- `["CC/foreign", "defaults"]`:
+ The `CC/foreign` toolchain definition for use with
+ [rules-cc](https://github.com/just-buildsystem/rules-cc)
+
+The `busybox` toolchain (including `<compiler>+tools`) additionally provides:
+- `["patch", "defaults"]`:
+ The `patch` toolchain definition for use with
+ [rules-cc](https://github.com/just-buildsystem/rules-cc)
+
+## Configuration Variables
+
+The toolchains can be configured via the variable `TOOLCHAIN_CONFIG`, which
+contains an object that may specify multiple fields.
+
+Fields for building the toolchains:
+
+- `BOOTSTRAP_CC`:
+ The initial C compiler for bootstrapping (default: `"cc"`)
+- `BOOTSTRAP_PATH`:
+ Search path for the initial C compiler (default: `["/bin", "/usr/bin"]`)
+- `HOST_SYSTEM_HDR_DIR`:
+ Header directory of the C library on the build host (default: not set)
+- `HOST_SYSTEM_LIB_DIR`:
+ Library directory of the C library on the build host (default: not set)
+- `HOST_DYNAMIC_LINKER`:
+ Absolute path to the dynamic linker on the build host (default: not set)
+
+Fields for using the toolchains
+(within [Justbuild](https://github.com/just-buildsystem/justbuild) projects):
+
+- `STATIC_RUNLIBS`:
+ Statically link runtime libraries, e.g., `libgcc_s`, `libstdc++` (default:
+ `false`)
+- `USE_LIBCXX`:
+ Use LLVM's `libc++` instead of GNU's `libstdc++` (only for `clang` toolchains,
+ default: `false`)
+
+### Building on Hosts with Custom System Paths
+
+Some systems (e.g., NixOS) use custom paths for Coreutils, the C library, and
+the dynamic linker that the autotools cannot determine. On such systems, `PATH`
+is used to locate Coreutils and `TOOLCHAIN_CONFIG` may set additional system
+paths.
+
+Example configuration for bootstrapping on NixOS (hashes may vary):
+
+~~~ json
+{ "ENV": {"PATH": "/root/.nix-profile/bin"}
+, "TOOLCHAIN_CONFIG":
+ { "HOST_SYSTEM_HDR_DIR": "/nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include"
+ , "HOST_SYSTEM_LIB_DIR": "/nix/store/ld03l52xq2ssn4x0g5asypsxqls40497-glibc-2.37-8/lib"
+ , "HOST_DYNAMIC_LINKER": "/nix/store/ld03l52xq2ssn4x0g5asypsxqls40497-glibc-2.37-8/lib/ld-linux-x86-64.so.2"
+ }
+}
+~~~
+
+## License
+
+All files are copyright Huawei Cloud Computing Technology Co., Ltd., license
+Apache-2.0, expect for the patches in `etc/patches`, which are license GPL-2.0
+(the same license as the respective upstream project).
diff --git a/doc/BOOTSTRAP.md b/doc/BOOTSTRAP.md
new file mode 100644
index 0000000..d84a9a2
--- /dev/null
+++ b/doc/BOOTSTRAP.md
@@ -0,0 +1,99 @@
+# Bootstrap Process
+
+The bootstrap process cannot rely on anything existing on the build systems,
+except:
+
+1. Coreutils
+2. POSIX-compliant shell located at `/bin/sh`
+3. C89 compiler (e.g., TinyCC, old GCC) with a working C library (*glibc* /
+ *musl libc*)
+
+Consequently, the process is designed to bootstrap a "minimal distribution" that
+contains everything required for building modern toolchains. The process is
+currently separated into two stages.
+
+## Stage 0
+
+### 1. Bootstrapped Busybox "essentials"
+
+Bootstrapping a minimal set of tools that are needed for this stage includes:
+
+- `sed`/`awk`/`diff` (for building `make`/`binutils`/`gcc-4.7.4`/`busybox`)
+- `patch` (for patching `gcc-4.7.4`)
+- `cmp`/`tar` (for running `gcc-4.7.4`'s install target)
+- `find`/`bzip2` (for building full `busybox`)
+
+All tools are bootstrapped via a custom shell script. Note that Busybox' `ar` is
+not included, due to its missing indexing support.
+
+### 2. Bootstrapped GNU Make
+
+Bootstrapping the `make` build system requires the Busybox "essentials" from the
+previous step. It is compiled via its bootstrap script `build.sh`. However, due
+to missing `ar`, final linking is done via custom compile commands.
+
+### 3. Bootstrapped Archiver (from Binutils)
+
+Bootstrapping the archiver `ar`, requires the Busybox "essentials" and `make`
+from the previous steps. This archiver has proper indexing support and is
+compiled via its `Makefile`. However, due to missing `ar` from earlier stages,
+final linking is done via custom script.
+
+### 4. Binutils
+
+Building binutils requires the Busybox "essentials", `make`, and `ar` from the
+previous steps. This *full collection* of binutils includes `ar`, `as`, `ld`,
+`ranlib`, `strip`, and more.
+
+### 5. GCC 4.7.4
+
+Building GCC requires the Busybox "essentials", `make`, and binutils from the
+previous steps. GCC version 4.7.4 is [the last GCC version that can be built
+without a C++ compiler](https://lists.nongnu.org/archive/html/tinycc-devel/2017-05/msg00099.html).
+
+Patches needed for building on modern systems:
+
+- support [new type name `ucontext_t`](https://github.com/gcc-mirror/gcc/commit/883312dc79806f513275b72502231c751c14ff72)
+- support [building with newer C standard](https://gcc.gnu.org/legacy-ml/gcc-patches/2015-08/msg00375.html)
+
+Patches needed for building on systems with *musl libc*:
+[back-ports from GCC 4.8.0, 6.1.0, 9.1.0, and 11.1.0](../etc/patches/gcc-4.7.4/musl-support).
+
+To achieve reproducibility, we had to apply a few more custom patches that
+ensure [build directory independence](../etc/patches/gcc-4.7.4/reproducibility).
+
+Furthermore, to make this a *portable C/C++ toolchain* (which uses bundled
+binutils), we needed to create a shell launcher (e.g., `gcc` launching
+`gcc.real`) that sets `PATH` to bundled binutils, relative to its own location.
+
+### 6. Busybox
+
+Building Busybox requires the Busybox "essentials", `make`, and GCC 4.7.4 from
+the previous steps. This *full collection* of Busybox is ensured to be built
+with an efficient compiler and contains many useful tools for the next stages.
+
+### 7. GNU Make
+
+Building `make` requires `make`, GCC 4.7.4, and Busybox from the previous steps.
+This version of `make` is ensured to be built with an efficient compiler for use
+in the next stages.
+
+## Stage 1
+
+The result of the previous stage is a toolchain definition, containing Busybox,
+`make`, and GCC 4.7.4 bundled with binutils. Unfortunately, GCC 4.7.4 is not
+sufficient to build modern compilers, because most of them require full C++11
+support. Therefore, we introduced a second bootstrapping stage.
+
+### GCC 10.2.0
+
+GCC 10.2.0 is the first GCC version that fully supports the C++11 standard. GCC
+and binutils are built in separate actions, so we can make sure `ar` is
+configured with `--enable-deterministic-archives`. Both actions build for the
+host using the toolchain `stage-0/gcc`. To achieve reproducibility, we had to
+apply a few patches to GCC that ensure build directory independence.
+Furthermore, the use of `msgfmt` is disabled by setting `check_msgfmt=no`.
+Otherwise, the build process might call `msgfmt` with the `LD_LIBRARY_PATH` set
+to the current toolchain's lib dir, which might contain an insufficient
+`libstdc++` version.
+
diff --git a/doc/COMPILERS.md b/doc/COMPILERS.md
new file mode 100644
index 0000000..d6d29b1
--- /dev/null
+++ b/doc/COMPILERS.md
@@ -0,0 +1,61 @@
+# Bootstrapped Compilers
+
+The initial compilers are built with the GCC resulting from the final bootstrap
+stage (`stage-1/gcc`). For more infomation on the bootstrap process, see
+[BOOTSTRAP.md](./BOOTSTRAP.md).
+
+## GCC Native
+
+GCC and binutils are built separately using the GCC toolchain from the final
+bootstrap stage (`stage-1/gcc`). While GCC generally supports reproducible
+builds, this is not necessarily the case if the build directory and toolchain
+root are located in variable paths. To achieve reproducibility, we had to apply
+a few patches that ensure build directory independence. Unfortunately, even
+though we install via the `install-strip` target, not all binaries will be
+stripped (e.g., `libgcc` ignores `install-strip`). Therefore, we need to
+manually strip all libraries and binaries after building.
+
+## GCC Musl
+
+GCC with Musl support is built using the GCC toolchain from the final bootstrap
+stage (`stage-1/gcc`). For building, we use the project
+[*musl-cross-make*](https://github.com/richfelker/musl-cross-make), which
+conveniently also supports building a cross-compiler. To avoid any fetches by
+*musl-cross-make*, we stage the unpacked file trees to their expected target
+destination (e.g., `gcc-13.orig`, `musl-latest.orig`, etc.). For some reason
+*musl-cross-make* tries to modify files in `musl-latest.orig`, so we have to
+provide a writable copy. Finally, we applied a few patches to support newer
+binutils and GCC versions.
+
+Unfortunately, *musl-cross-make* does not call the `install-strip` target.
+Therefore, we apply manual stripping to achieve reproducibility.
+
+## GCC Musl Static
+
+Static building is achieved by using the GCC 13.2.0 Musl toolchain
+(`gcc-13.2.0-musl`) and a "fake" `cc`/`c++` executable that adds the flag
+`-static` to each compiler call.
+
+## Clang Native
+
+Building Clang requires an existing GCC installation with recent C++ standard
+library features (`gcc-13.2.0-native`) and build tools (`busybox`, `make`,
+`cmake`, `python`). GCC is used to build Clang in a first step, before this
+newly built Clang is used to build any of the remaining targets. To ensure that
+the Clang from the first step can be used during the entire build process, GCC's
+runtime libraries (`libgcc`, `libstdc++`) must be locatable by setting
+`LD_LIBRARY_PATH=${GCC_TOOLCHAIN}/lib{32,64}`. For building reproducibly, it is
+required to set `LIBCXXABI_ENABLE_ASSERTIONS` and `LIBUNWIND_ENABLE_ASSERTIONS`
+to `OFF`, as both are enabled by default and cause leaking absolute paths to
+the build directory.
+
+Futhermore, this newly built Clang needs to link GCC's runtime objects
+(`crt*.o`) for compiling its runtime libraries (`libc++`, `libc++abi`, and
+`libunwind`). Therefore, we additionally need to set
+`LDFLAGS=-gcc-toolchain=${GCC_TOOLCHAIN}` *after* Clang was built (note that
+setting this option earlier will fail, due to it being an unknown option to the
+GCC that is used to build Clang in the very first step).
+
+Finally, we also have to patch Clang's `libc++`, because it is using `strto*_l`
+functions that are [deliberately missing in musl
+libc](https://www.openwall.com/lists/musl/2020/10/01/3).
diff --git a/doc/TOOLS.md b/doc/TOOLS.md
new file mode 100644
index 0000000..5f01e64
--- /dev/null
+++ b/doc/TOOLS.md
@@ -0,0 +1,45 @@
+# Bootstrapped Tools
+
+All tools are statically built with the GCC 13.2.0 with musl support
+(`gcc-13.2.0-musl`). Note that dynamically linking with this compiler will not work on
+non-musl systems. Therefore, all *configure checks* and *build steps* must use
+static linking. For more information on the compilers, see
+[COMPILERS.md](./COMPILERS.md).
+
+## Busybox
+
+Busybox is compiled statically by setting `LDFLAGS='-static'`. It strictly
+requires GCC for building, which can be set via `HOSTCC` and `HOSTCXX`. It
+employs *internal checks* to verify that the compilers are working. However,
+those checks seem to ignore `LDFLAGS`, which causes them to fail on non-musl
+systems. Therefore, we had to forcefully set the compilers to `"${CC} -static"`
+and `"${CXX} -static"`.
+
+For reproducibility, we additionally had to set `SOURCE_DATE_EPOCH=0`.
+
+## Make
+
+Make is compiled statically by setting `LDFLAGS='-static'`. For some reason, the
+binary likes to record the absolute path to the C++ compiler on the build
+machine (despite not even using C++). To achieve reproducibility, we set
+`CXX='unused'`.
+
+## CMake
+
+CMake is compiled statically with bundled dependencies. The only dependency that
+is not bundled with CMake's sources is `libssl`. We use the C++ library
+`boringssl` to satisfy that dependency. However, CMake expects `libssl` to be a
+C library (not C++), which is solved via a small patch. For reproducibility, we
+had to redefine `__FILE__` to `__FILE_NAME__`, which is supported since GCC 12.
+
+## Python
+
+Python is compiled statically with default modules built in. See [Building
+Python Statically](https://wiki.python.org/moin/BuildStatically) for full
+details. Missing modules are:
+- `nis`: deprecated module that caused the static build to fail
+- `ssl`: unsupported, due to missing `libssl` C library
+
+Furthermore, the Python binary likes to record its build time and date, so we
+had to set `SOURCE_DATE_EPOCH=0` to achieve reproducibility.
+
diff --git a/etc/defaults/CC/clang.TARGETS b/etc/defaults/CC/clang.TARGETS
new file mode 100644
index 0000000..a91fced
--- /dev/null
+++ b/etc/defaults/CC/clang.TARGETS
@@ -0,0 +1,11 @@
+{ "defaults":
+ { "type": ["CC", "defaults"]
+ , "CC": ["gcc/bin/gcc"]
+ , "CXX": ["gcc/bin/g++"]
+ , "AR": ["gcc/bin/ar"]
+ , "toolchain": ["staged-gcc"]
+ , "PATH": ["$(TOOLCHAIN)/gcc/bin", "/bin", "/usr/bin"]
+ }
+, "staged-gcc":
+ {"type": "install", "dirs": [[["@", "gcc", "", "toolchain"], "gcc"]]}
+}
diff --git a/etc/defaults/CC/foreign/clang.TARGETS b/etc/defaults/CC/foreign/clang.TARGETS
new file mode 100644
index 0000000..74e376c
--- /dev/null
+++ b/etc/defaults/CC/foreign/clang.TARGETS
@@ -0,0 +1,19 @@
+{ "defaults":
+ { "type": ["CC/foreign", "defaults"]
+ , "base":
+ [ ["@", "cmake", "CC/foreign", "defaults"]
+ , ["@", "python", "CC/foreign", "defaults"]
+ ]
+ , "MAKE": ["make/bin/make"]
+ , "toolchain": ["staged-make", "staged-busybox"]
+ , "PATH":
+ [ "$(TOOLCHAIN)/make/bin"
+ , "$(TOOLCHAIN)/busybox/bin"
+ , "$(TOOLCHAIN)/busybox/usr/bin"
+ ]
+ }
+, "staged-make":
+ {"type": "install", "dirs": [[["@", "make", "", "toolchain"], "make"]]}
+, "staged-busybox":
+ {"type": "install", "dirs": [[["@", "busybox", "", "toolchain"], "busybox"]]}
+}
diff --git a/etc/defaults/CC/foreign/gcc.TARGETS b/etc/defaults/CC/foreign/gcc.TARGETS
new file mode 100644
index 0000000..32ae01b
--- /dev/null
+++ b/etc/defaults/CC/foreign/gcc.TARGETS
@@ -0,0 +1,15 @@
+{ "defaults":
+ { "type": ["CC/foreign", "defaults"]
+ , "MAKE": ["make/bin/make"]
+ , "toolchain": ["staged-make", "staged-busybox"]
+ , "PATH":
+ [ "$(TOOLCHAIN)/make/bin"
+ , "$(TOOLCHAIN)/busybox/bin"
+ , "$(TOOLCHAIN)/busybox/usr/bin"
+ ]
+ }
+, "staged-make":
+ {"type": "install", "dirs": [[["@", "make", "", "toolchain"], "make"]]}
+, "staged-busybox":
+ {"type": "install", "dirs": [[["@", "busybox", "", "toolchain"], "busybox"]]}
+}
diff --git a/etc/defaults/CC/foreign/stage-0.TARGETS b/etc/defaults/CC/foreign/stage-0.TARGETS
new file mode 100644
index 0000000..8b2aad4
--- /dev/null
+++ b/etc/defaults/CC/foreign/stage-0.TARGETS
@@ -0,0 +1 @@
+{"defaults": {"type": ["CC/foreign", "defaults"]}}
diff --git a/etc/defaults/CC/foreign/stage-1.TARGETS b/etc/defaults/CC/foreign/stage-1.TARGETS
new file mode 100644
index 0000000..32ae01b
--- /dev/null
+++ b/etc/defaults/CC/foreign/stage-1.TARGETS
@@ -0,0 +1,15 @@
+{ "defaults":
+ { "type": ["CC/foreign", "defaults"]
+ , "MAKE": ["make/bin/make"]
+ , "toolchain": ["staged-make", "staged-busybox"]
+ , "PATH":
+ [ "$(TOOLCHAIN)/make/bin"
+ , "$(TOOLCHAIN)/busybox/bin"
+ , "$(TOOLCHAIN)/busybox/usr/bin"
+ ]
+ }
+, "staged-make":
+ {"type": "install", "dirs": [[["@", "make", "", "toolchain"], "make"]]}
+, "staged-busybox":
+ {"type": "install", "dirs": [[["@", "busybox", "", "toolchain"], "busybox"]]}
+}
diff --git a/etc/defaults/CC/foreign/static-build.TARGETS b/etc/defaults/CC/foreign/static-build.TARGETS
new file mode 100644
index 0000000..32ae01b
--- /dev/null
+++ b/etc/defaults/CC/foreign/static-build.TARGETS
@@ -0,0 +1,15 @@
+{ "defaults":
+ { "type": ["CC/foreign", "defaults"]
+ , "MAKE": ["make/bin/make"]
+ , "toolchain": ["staged-make", "staged-busybox"]
+ , "PATH":
+ [ "$(TOOLCHAIN)/make/bin"
+ , "$(TOOLCHAIN)/busybox/bin"
+ , "$(TOOLCHAIN)/busybox/usr/bin"
+ ]
+ }
+, "staged-make":
+ {"type": "install", "dirs": [[["@", "make", "", "toolchain"], "make"]]}
+, "staged-busybox":
+ {"type": "install", "dirs": [[["@", "busybox", "", "toolchain"], "busybox"]]}
+}
diff --git a/etc/defaults/CC/foreign/test.TARGETS b/etc/defaults/CC/foreign/test.TARGETS
new file mode 100644
index 0000000..8b2aad4
--- /dev/null
+++ b/etc/defaults/CC/foreign/test.TARGETS
@@ -0,0 +1 @@
+{"defaults": {"type": ["CC/foreign", "defaults"]}}
diff --git a/etc/defaults/CC/gcc.TARGETS b/etc/defaults/CC/gcc.TARGETS
new file mode 100644
index 0000000..a91fced
--- /dev/null
+++ b/etc/defaults/CC/gcc.TARGETS
@@ -0,0 +1,11 @@
+{ "defaults":
+ { "type": ["CC", "defaults"]
+ , "CC": ["gcc/bin/gcc"]
+ , "CXX": ["gcc/bin/g++"]
+ , "AR": ["gcc/bin/ar"]
+ , "toolchain": ["staged-gcc"]
+ , "PATH": ["$(TOOLCHAIN)/gcc/bin", "/bin", "/usr/bin"]
+ }
+, "staged-gcc":
+ {"type": "install", "dirs": [[["@", "gcc", "", "toolchain"], "gcc"]]}
+}
diff --git a/etc/defaults/CC/stage-0.TARGETS b/etc/defaults/CC/stage-0.TARGETS
new file mode 100644
index 0000000..f58d2bf
--- /dev/null
+++ b/etc/defaults/CC/stage-0.TARGETS
@@ -0,0 +1,26 @@
+{ "defaults":
+ { "type": ["CC", "defaults"]
+ , "arguments_config": ["TOOLCHAIN_CONFIG"]
+ , "CC":
+ [ { "type": "lookup"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ , "key": "BOOTSTRAP_CC"
+ , "default": "cc"
+ }
+ ]
+ , "PATH":
+ { "type": "lookup"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ , "key": "BOOTSTRAP_PATH"
+ , "default": ["/bin", "/usr/bin"]
+ }
+ }
+}
diff --git a/etc/defaults/CC/stage-1.TARGETS b/etc/defaults/CC/stage-1.TARGETS
new file mode 100644
index 0000000..a91fced
--- /dev/null
+++ b/etc/defaults/CC/stage-1.TARGETS
@@ -0,0 +1,11 @@
+{ "defaults":
+ { "type": ["CC", "defaults"]
+ , "CC": ["gcc/bin/gcc"]
+ , "CXX": ["gcc/bin/g++"]
+ , "AR": ["gcc/bin/ar"]
+ , "toolchain": ["staged-gcc"]
+ , "PATH": ["$(TOOLCHAIN)/gcc/bin", "/bin", "/usr/bin"]
+ }
+, "staged-gcc":
+ {"type": "install", "dirs": [[["@", "gcc", "", "toolchain"], "gcc"]]}
+}
diff --git a/etc/defaults/CC/static-build.TARGETS b/etc/defaults/CC/static-build.TARGETS
new file mode 100644
index 0000000..4b74449
--- /dev/null
+++ b/etc/defaults/CC/static-build.TARGETS
@@ -0,0 +1,12 @@
+{ "defaults":
+ { "type": ["CC", "defaults"]
+ , "CC": ["gcc/bin/gcc"]
+ , "CXX": ["gcc/bin/g++"]
+ , "AR": ["gcc/bin/ar"]
+ , "LDFLAGS": ["-static"]
+ , "toolchain": ["staged-gcc"]
+ , "PATH": ["$(TOOLCHAIN)/gcc/bin", "/bin", "/usr/bin"]
+ }
+, "staged-gcc":
+ {"type": "install", "dirs": [[["@", "gcc-musl", "", "toolchain"], "gcc"]]}
+}
diff --git a/etc/defaults/CC/test.TARGETS b/etc/defaults/CC/test.TARGETS
new file mode 100644
index 0000000..76dc47d
--- /dev/null
+++ b/etc/defaults/CC/test.TARGETS
@@ -0,0 +1,3 @@
+{ "defaults":
+ {"type": ["CC", "defaults"], "base": [["@", "toolchain", "CC", "defaults"]]}
+}
diff --git a/etc/defaults/shell/test/test.TARGETS b/etc/defaults/shell/test/test.TARGETS
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/etc/defaults/shell/test/test.TARGETS
@@ -0,0 +1 @@
+{}
diff --git a/etc/imports/binutils.TARGETS b/etc/imports/binutils.TARGETS
new file mode 100644
index 0000000..71f9bf8
--- /dev/null
+++ b/etc/imports/binutils.TARGETS
@@ -0,0 +1,26 @@
+{ "files": {"type": "install", "deps": [["TREE", null, "."]]}
+, "binutils":
+ { "type": "export"
+ , "target": "binutils binaries"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ }
+, "binutils binaries":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": ["files"]
+ , "cmds":
+ [ "export NJOBS=$(nproc --all 2>/dev/null || echo 1)"
+ , "unset LDFLAGS"
+ , "if [ -f /lib/ld-musl-$(uname -m).so.1 ]; then"
+ , " ln -s /lib/ld-musl-$(uname -m).so.1 ${TMPDIR}/ldd"
+ , " export PATH=$PATH:${TMPDIR}"
+ , "fi"
+ , "mkdir build"
+ , "cd build"
+ , "../configure --prefix=/ --disable-nls --enable-gprofng=no --disable-werror --enable-deterministic-archives >configure.log 2>&1 || (cat configure.log && exit 1)"
+ , "${MAKE} -j${NJOBS} MAKEINFO=true >build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "${MAKE} -j${NJOBS} MAKEINFO=true DESTDIR=${DESTDIR} install-strip >>build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "find ${DESTDIR} -type f -name '*.la' -exec sed -i 's|'$(pwd)'|/build|g' {} \\;"
+ ]
+ , "out_dirs": ["."]
+ }
+}
diff --git a/etc/imports/boringssl.TARGETS b/etc/imports/boringssl.TARGETS
new file mode 100644
index 0000000..a146ec0
--- /dev/null
+++ b/etc/imports/boringssl.TARGETS
@@ -0,0 +1,684 @@
+{ "crypto":
+ { "type": "export"
+ , "target": "crypto-lib"
+ , "flexible_config": ["OS", "ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ }
+, "ssl":
+ { "type": "export"
+ , "target": "ssl-lib"
+ , "flexible_config": ["OS", "ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ }
+, "crypto-lib":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["crypto"]
+ , "pkg-name": ["libcrypto"]
+ , "hdrs": [["./", "src/include/openssl", "crypto_headers"]]
+ , "private-hdrs": ["fips_fragments", "crypto_internal_headers"]
+ , "srcs": ["crypto_sources", "crypto_sources_asm"]
+ , "pure C": ["YES"]
+ , "private-ldflags": ["-pthread"]
+ }
+, "ssl-lib":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["ssl"]
+ , "pkg-name": ["libssl"]
+ , "hdrs": [["./", "src/include/openssl", "ssl_headers"]]
+ , "private-hdrs": ["ssl_internal_headers", "crypto_internal_headers"]
+ , "srcs": ["ssl_sources"]
+ , "deps": ["crypto"]
+ }
+, "crypto_internal_headers":
+ { "type": "install"
+ , "deps":
+ [ "src/crypto/asn1/charmap.h"
+ , "src/crypto/asn1/internal.h"
+ , "src/crypto/bio/internal.h"
+ , "src/crypto/bytestring/internal.h"
+ , "src/crypto/chacha/internal.h"
+ , "src/crypto/cipher_extra/internal.h"
+ , "src/crypto/conf/conf_def.h"
+ , "src/crypto/conf/internal.h"
+ , "src/crypto/cpu-arm-linux.h"
+ , "src/crypto/curve25519/curve25519_tables.h"
+ , "src/crypto/curve25519/internal.h"
+ , "src/crypto/dsa/internal.h"
+ , "src/crypto/ec_extra/internal.h"
+ , "src/crypto/err/internal.h"
+ , "src/crypto/evp/internal.h"
+ , "src/crypto/fipsmodule/aes/internal.h"
+ , "src/crypto/fipsmodule/bn/internal.h"
+ , "src/crypto/fipsmodule/bn/rsaz_exp.h"
+ , "src/crypto/fipsmodule/cipher/internal.h"
+ , "src/crypto/fipsmodule/delocate.h"
+ , "src/crypto/fipsmodule/des/internal.h"
+ , "src/crypto/fipsmodule/digest/internal.h"
+ , "src/crypto/fipsmodule/digest/md32_common.h"
+ , "src/crypto/fipsmodule/ec/internal.h"
+ , "src/crypto/fipsmodule/ec/p256-x86_64-table.h"
+ , "src/crypto/fipsmodule/ec/p256-x86_64.h"
+ , "src/crypto/fipsmodule/ec/p256_table.h"
+ , "src/crypto/fipsmodule/ecdsa/internal.h"
+ , "src/crypto/fipsmodule/md5/internal.h"
+ , "src/crypto/fipsmodule/modes/internal.h"
+ , "src/crypto/fipsmodule/rand/fork_detect.h"
+ , "src/crypto/fipsmodule/rand/getrandom_fillin.h"
+ , "src/crypto/fipsmodule/rand/internal.h"
+ , "src/crypto/fipsmodule/rsa/internal.h"
+ , "src/crypto/fipsmodule/sha/internal.h"
+ , "src/crypto/fipsmodule/tls/internal.h"
+ , "src/crypto/hrss/internal.h"
+ , "src/crypto/internal.h"
+ , "src/crypto/lhash/internal.h"
+ , "src/crypto/obj/obj_dat.h"
+ , "src/crypto/pkcs7/internal.h"
+ , "src/crypto/pkcs8/internal.h"
+ , "src/crypto/poly1305/internal.h"
+ , "src/crypto/pool/internal.h"
+ , "src/crypto/trust_token/internal.h"
+ , "src/crypto/x509/internal.h"
+ , "src/crypto/x509v3/ext_dat.h"
+ , "src/crypto/x509v3/internal.h"
+ , "src/third_party/fiat/curve25519_32.h"
+ , "src/third_party/fiat/curve25519_64.h"
+ , "src/third_party/fiat/p256_32.h"
+ , "src/third_party/fiat/p256_64.h"
+ ]
+ }
+, "crypto_sources":
+ { "type": "install"
+ , "deps":
+ [ "err_data.c"
+ , "src/crypto/asn1/a_bitstr.c"
+ , "src/crypto/asn1/a_bool.c"
+ , "src/crypto/asn1/a_d2i_fp.c"
+ , "src/crypto/asn1/a_dup.c"
+ , "src/crypto/asn1/a_enum.c"
+ , "src/crypto/asn1/a_gentm.c"
+ , "src/crypto/asn1/a_i2d_fp.c"
+ , "src/crypto/asn1/a_int.c"
+ , "src/crypto/asn1/a_mbstr.c"
+ , "src/crypto/asn1/a_object.c"
+ , "src/crypto/asn1/a_octet.c"
+ , "src/crypto/asn1/a_print.c"
+ , "src/crypto/asn1/a_strex.c"
+ , "src/crypto/asn1/a_strnid.c"
+ , "src/crypto/asn1/a_time.c"
+ , "src/crypto/asn1/a_type.c"
+ , "src/crypto/asn1/a_utctm.c"
+ , "src/crypto/asn1/a_utf8.c"
+ , "src/crypto/asn1/asn1_lib.c"
+ , "src/crypto/asn1/asn1_par.c"
+ , "src/crypto/asn1/asn_pack.c"
+ , "src/crypto/asn1/f_int.c"
+ , "src/crypto/asn1/f_string.c"
+ , "src/crypto/asn1/tasn_dec.c"
+ , "src/crypto/asn1/tasn_enc.c"
+ , "src/crypto/asn1/tasn_fre.c"
+ , "src/crypto/asn1/tasn_new.c"
+ , "src/crypto/asn1/tasn_typ.c"
+ , "src/crypto/asn1/tasn_utl.c"
+ , "src/crypto/asn1/time_support.c"
+ , "src/crypto/base64/base64.c"
+ , "src/crypto/bio/bio.c"
+ , "src/crypto/bio/bio_mem.c"
+ , "src/crypto/bio/connect.c"
+ , "src/crypto/bio/fd.c"
+ , "src/crypto/bio/file.c"
+ , "src/crypto/bio/hexdump.c"
+ , "src/crypto/bio/pair.c"
+ , "src/crypto/bio/printf.c"
+ , "src/crypto/bio/socket.c"
+ , "src/crypto/bio/socket_helper.c"
+ , "src/crypto/blake2/blake2.c"
+ , "src/crypto/bn_extra/bn_asn1.c"
+ , "src/crypto/bn_extra/convert.c"
+ , "src/crypto/buf/buf.c"
+ , "src/crypto/bytestring/asn1_compat.c"
+ , "src/crypto/bytestring/ber.c"
+ , "src/crypto/bytestring/cbb.c"
+ , "src/crypto/bytestring/cbs.c"
+ , "src/crypto/bytestring/unicode.c"
+ , "src/crypto/chacha/chacha.c"
+ , "src/crypto/cipher_extra/cipher_extra.c"
+ , "src/crypto/cipher_extra/derive_key.c"
+ , "src/crypto/cipher_extra/e_aesccm.c"
+ , "src/crypto/cipher_extra/e_aesctrhmac.c"
+ , "src/crypto/cipher_extra/e_aesgcmsiv.c"
+ , "src/crypto/cipher_extra/e_chacha20poly1305.c"
+ , "src/crypto/cipher_extra/e_null.c"
+ , "src/crypto/cipher_extra/e_rc2.c"
+ , "src/crypto/cipher_extra/e_rc4.c"
+ , "src/crypto/cipher_extra/e_tls.c"
+ , "src/crypto/cipher_extra/tls_cbc.c"
+ , "src/crypto/cmac/cmac.c"
+ , "src/crypto/conf/conf.c"
+ , "src/crypto/cpu-aarch64-fuchsia.c"
+ , "src/crypto/cpu-aarch64-linux.c"
+ , "src/crypto/cpu-aarch64-win.c"
+ , "src/crypto/cpu-arm-linux.c"
+ , "src/crypto/cpu-arm.c"
+ , "src/crypto/cpu-intel.c"
+ , "src/crypto/cpu-ppc64le.c"
+ , "src/crypto/crypto.c"
+ , "src/crypto/curve25519/curve25519.c"
+ , "src/crypto/curve25519/spake25519.c"
+ , "src/crypto/dh_extra/dh_asn1.c"
+ , "src/crypto/dh_extra/params.c"
+ , "src/crypto/digest_extra/digest_extra.c"
+ , "src/crypto/dsa/dsa.c"
+ , "src/crypto/dsa/dsa_asn1.c"
+ , "src/crypto/ec_extra/ec_asn1.c"
+ , "src/crypto/ec_extra/ec_derive.c"
+ , "src/crypto/ec_extra/hash_to_curve.c"
+ , "src/crypto/ecdh_extra/ecdh_extra.c"
+ , "src/crypto/ecdsa_extra/ecdsa_asn1.c"
+ , "src/crypto/engine/engine.c"
+ , "src/crypto/err/err.c"
+ , "src/crypto/evp/digestsign.c"
+ , "src/crypto/evp/evp.c"
+ , "src/crypto/evp/evp_asn1.c"
+ , "src/crypto/evp/evp_ctx.c"
+ , "src/crypto/evp/p_dsa_asn1.c"
+ , "src/crypto/evp/p_ec.c"
+ , "src/crypto/evp/p_ec_asn1.c"
+ , "src/crypto/evp/p_ed25519.c"
+ , "src/crypto/evp/p_ed25519_asn1.c"
+ , "src/crypto/evp/p_rsa.c"
+ , "src/crypto/evp/p_rsa_asn1.c"
+ , "src/crypto/evp/p_x25519.c"
+ , "src/crypto/evp/p_x25519_asn1.c"
+ , "src/crypto/evp/pbkdf.c"
+ , "src/crypto/evp/print.c"
+ , "src/crypto/evp/scrypt.c"
+ , "src/crypto/evp/sign.c"
+ , "src/crypto/ex_data.c"
+ , "src/crypto/fipsmodule/bcm.c"
+ , "src/crypto/fipsmodule/fips_shared_support.c"
+ , "src/crypto/hkdf/hkdf.c"
+ , "src/crypto/hpke/hpke.c"
+ , "src/crypto/hrss/hrss.c"
+ , "src/crypto/lhash/lhash.c"
+ , "src/crypto/mem.c"
+ , "src/crypto/obj/obj.c"
+ , "src/crypto/obj/obj_xref.c"
+ , "src/crypto/pem/pem_all.c"
+ , "src/crypto/pem/pem_info.c"
+ , "src/crypto/pem/pem_lib.c"
+ , "src/crypto/pem/pem_oth.c"
+ , "src/crypto/pem/pem_pk8.c"
+ , "src/crypto/pem/pem_pkey.c"
+ , "src/crypto/pem/pem_x509.c"
+ , "src/crypto/pem/pem_xaux.c"
+ , "src/crypto/pkcs7/pkcs7.c"
+ , "src/crypto/pkcs7/pkcs7_x509.c"
+ , "src/crypto/pkcs8/p5_pbev2.c"
+ , "src/crypto/pkcs8/pkcs8.c"
+ , "src/crypto/pkcs8/pkcs8_x509.c"
+ , "src/crypto/poly1305/poly1305.c"
+ , "src/crypto/poly1305/poly1305_arm.c"
+ , "src/crypto/poly1305/poly1305_vec.c"
+ , "src/crypto/pool/pool.c"
+ , "src/crypto/rand_extra/deterministic.c"
+ , "src/crypto/rand_extra/forkunsafe.c"
+ , "src/crypto/rand_extra/fuchsia.c"
+ , "src/crypto/rand_extra/passive.c"
+ , "src/crypto/rand_extra/rand_extra.c"
+ , "src/crypto/rand_extra/windows.c"
+ , "src/crypto/rc4/rc4.c"
+ , "src/crypto/refcount_c11.c"
+ , "src/crypto/refcount_lock.c"
+ , "src/crypto/rsa_extra/rsa_asn1.c"
+ , "src/crypto/rsa_extra/rsa_print.c"
+ , "src/crypto/siphash/siphash.c"
+ , "src/crypto/stack/stack.c"
+ , "src/crypto/thread.c"
+ , "src/crypto/thread_none.c"
+ , "src/crypto/thread_pthread.c"
+ , "src/crypto/thread_win.c"
+ , "src/crypto/trust_token/pmbtoken.c"
+ , "src/crypto/trust_token/trust_token.c"
+ , "src/crypto/trust_token/voprf.c"
+ , "src/crypto/x509/a_digest.c"
+ , "src/crypto/x509/a_sign.c"
+ , "src/crypto/x509/a_verify.c"
+ , "src/crypto/x509/algorithm.c"
+ , "src/crypto/x509/asn1_gen.c"
+ , "src/crypto/x509/by_dir.c"
+ , "src/crypto/x509/by_file.c"
+ , "src/crypto/x509/i2d_pr.c"
+ , "src/crypto/x509/name_print.c"
+ , "src/crypto/x509/rsa_pss.c"
+ , "src/crypto/x509/t_crl.c"
+ , "src/crypto/x509/t_req.c"
+ , "src/crypto/x509/t_x509.c"
+ , "src/crypto/x509/t_x509a.c"
+ , "src/crypto/x509/x509.c"
+ , "src/crypto/x509/x509_att.c"
+ , "src/crypto/x509/x509_cmp.c"
+ , "src/crypto/x509/x509_d2.c"
+ , "src/crypto/x509/x509_def.c"
+ , "src/crypto/x509/x509_ext.c"
+ , "src/crypto/x509/x509_lu.c"
+ , "src/crypto/x509/x509_obj.c"
+ , "src/crypto/x509/x509_req.c"
+ , "src/crypto/x509/x509_set.c"
+ , "src/crypto/x509/x509_trs.c"
+ , "src/crypto/x509/x509_txt.c"
+ , "src/crypto/x509/x509_v3.c"
+ , "src/crypto/x509/x509_vfy.c"
+ , "src/crypto/x509/x509_vpm.c"
+ , "src/crypto/x509/x509cset.c"
+ , "src/crypto/x509/x509name.c"
+ , "src/crypto/x509/x509rset.c"
+ , "src/crypto/x509/x509spki.c"
+ , "src/crypto/x509/x_algor.c"
+ , "src/crypto/x509/x_all.c"
+ , "src/crypto/x509/x_attrib.c"
+ , "src/crypto/x509/x_crl.c"
+ , "src/crypto/x509/x_exten.c"
+ , "src/crypto/x509/x_info.c"
+ , "src/crypto/x509/x_name.c"
+ , "src/crypto/x509/x_pkey.c"
+ , "src/crypto/x509/x_pubkey.c"
+ , "src/crypto/x509/x_req.c"
+ , "src/crypto/x509/x_sig.c"
+ , "src/crypto/x509/x_spki.c"
+ , "src/crypto/x509/x_val.c"
+ , "src/crypto/x509/x_x509.c"
+ , "src/crypto/x509/x_x509a.c"
+ , "src/crypto/x509v3/pcy_cache.c"
+ , "src/crypto/x509v3/pcy_data.c"
+ , "src/crypto/x509v3/pcy_lib.c"
+ , "src/crypto/x509v3/pcy_map.c"
+ , "src/crypto/x509v3/pcy_node.c"
+ , "src/crypto/x509v3/pcy_tree.c"
+ , "src/crypto/x509v3/v3_akey.c"
+ , "src/crypto/x509v3/v3_akeya.c"
+ , "src/crypto/x509v3/v3_alt.c"
+ , "src/crypto/x509v3/v3_bcons.c"
+ , "src/crypto/x509v3/v3_bitst.c"
+ , "src/crypto/x509v3/v3_conf.c"
+ , "src/crypto/x509v3/v3_cpols.c"
+ , "src/crypto/x509v3/v3_crld.c"
+ , "src/crypto/x509v3/v3_enum.c"
+ , "src/crypto/x509v3/v3_extku.c"
+ , "src/crypto/x509v3/v3_genn.c"
+ , "src/crypto/x509v3/v3_ia5.c"
+ , "src/crypto/x509v3/v3_info.c"
+ , "src/crypto/x509v3/v3_int.c"
+ , "src/crypto/x509v3/v3_lib.c"
+ , "src/crypto/x509v3/v3_ncons.c"
+ , "src/crypto/x509v3/v3_ocsp.c"
+ , "src/crypto/x509v3/v3_pci.c"
+ , "src/crypto/x509v3/v3_pcia.c"
+ , "src/crypto/x509v3/v3_pcons.c"
+ , "src/crypto/x509v3/v3_pmaps.c"
+ , "src/crypto/x509v3/v3_prn.c"
+ , "src/crypto/x509v3/v3_purp.c"
+ , "src/crypto/x509v3/v3_skey.c"
+ , "src/crypto/x509v3/v3_utl.c"
+ ]
+ }
+, "fips_fragments":
+ { "type": "install"
+ , "deps":
+ [ "src/crypto/fipsmodule/aes/aes.c"
+ , "src/crypto/fipsmodule/aes/aes_nohw.c"
+ , "src/crypto/fipsmodule/aes/key_wrap.c"
+ , "src/crypto/fipsmodule/aes/mode_wrappers.c"
+ , "src/crypto/fipsmodule/bn/add.c"
+ , "src/crypto/fipsmodule/bn/asm/x86_64-gcc.c"
+ , "src/crypto/fipsmodule/bn/bn.c"
+ , "src/crypto/fipsmodule/bn/bytes.c"
+ , "src/crypto/fipsmodule/bn/cmp.c"
+ , "src/crypto/fipsmodule/bn/ctx.c"
+ , "src/crypto/fipsmodule/bn/div.c"
+ , "src/crypto/fipsmodule/bn/div_extra.c"
+ , "src/crypto/fipsmodule/bn/exponentiation.c"
+ , "src/crypto/fipsmodule/bn/gcd.c"
+ , "src/crypto/fipsmodule/bn/gcd_extra.c"
+ , "src/crypto/fipsmodule/bn/generic.c"
+ , "src/crypto/fipsmodule/bn/jacobi.c"
+ , "src/crypto/fipsmodule/bn/montgomery.c"
+ , "src/crypto/fipsmodule/bn/montgomery_inv.c"
+ , "src/crypto/fipsmodule/bn/mul.c"
+ , "src/crypto/fipsmodule/bn/prime.c"
+ , "src/crypto/fipsmodule/bn/random.c"
+ , "src/crypto/fipsmodule/bn/rsaz_exp.c"
+ , "src/crypto/fipsmodule/bn/shift.c"
+ , "src/crypto/fipsmodule/bn/sqrt.c"
+ , "src/crypto/fipsmodule/cipher/aead.c"
+ , "src/crypto/fipsmodule/cipher/cipher.c"
+ , "src/crypto/fipsmodule/cipher/e_aes.c"
+ , "src/crypto/fipsmodule/cipher/e_des.c"
+ , "src/crypto/fipsmodule/des/des.c"
+ , "src/crypto/fipsmodule/dh/check.c"
+ , "src/crypto/fipsmodule/dh/dh.c"
+ , "src/crypto/fipsmodule/digest/digest.c"
+ , "src/crypto/fipsmodule/digest/digests.c"
+ , "src/crypto/fipsmodule/ec/ec.c"
+ , "src/crypto/fipsmodule/ec/ec_key.c"
+ , "src/crypto/fipsmodule/ec/ec_montgomery.c"
+ , "src/crypto/fipsmodule/ec/felem.c"
+ , "src/crypto/fipsmodule/ec/oct.c"
+ , "src/crypto/fipsmodule/ec/p224-64.c"
+ , "src/crypto/fipsmodule/ec/p256-x86_64.c"
+ , "src/crypto/fipsmodule/ec/p256.c"
+ , "src/crypto/fipsmodule/ec/scalar.c"
+ , "src/crypto/fipsmodule/ec/simple.c"
+ , "src/crypto/fipsmodule/ec/simple_mul.c"
+ , "src/crypto/fipsmodule/ec/util.c"
+ , "src/crypto/fipsmodule/ec/wnaf.c"
+ , "src/crypto/fipsmodule/ecdh/ecdh.c"
+ , "src/crypto/fipsmodule/ecdsa/ecdsa.c"
+ , "src/crypto/fipsmodule/hmac/hmac.c"
+ , "src/crypto/fipsmodule/md4/md4.c"
+ , "src/crypto/fipsmodule/md5/md5.c"
+ , "src/crypto/fipsmodule/modes/cbc.c"
+ , "src/crypto/fipsmodule/modes/cfb.c"
+ , "src/crypto/fipsmodule/modes/ctr.c"
+ , "src/crypto/fipsmodule/modes/gcm.c"
+ , "src/crypto/fipsmodule/modes/gcm_nohw.c"
+ , "src/crypto/fipsmodule/modes/ofb.c"
+ , "src/crypto/fipsmodule/modes/polyval.c"
+ , "src/crypto/fipsmodule/rand/ctrdrbg.c"
+ , "src/crypto/fipsmodule/rand/fork_detect.c"
+ , "src/crypto/fipsmodule/rand/rand.c"
+ , "src/crypto/fipsmodule/rand/urandom.c"
+ , "src/crypto/fipsmodule/rsa/blinding.c"
+ , "src/crypto/fipsmodule/rsa/padding.c"
+ , "src/crypto/fipsmodule/rsa/rsa.c"
+ , "src/crypto/fipsmodule/rsa/rsa_impl.c"
+ , "src/crypto/fipsmodule/self_check/fips.c"
+ , "src/crypto/fipsmodule/self_check/self_check.c"
+ , "src/crypto/fipsmodule/sha/sha1-altivec.c"
+ , "src/crypto/fipsmodule/sha/sha1.c"
+ , "src/crypto/fipsmodule/sha/sha256.c"
+ , "src/crypto/fipsmodule/sha/sha512.c"
+ , "src/crypto/fipsmodule/tls/kdf.c"
+ ]
+ }
+, "crypto_sources_ios_aarch64":
+ { "type": "install"
+ , "deps":
+ [ "ios-aarch64/crypto/chacha/chacha-armv8.S"
+ , "ios-aarch64/crypto/fipsmodule/aesv8-armx64.S"
+ , "ios-aarch64/crypto/fipsmodule/armv8-mont.S"
+ , "ios-aarch64/crypto/fipsmodule/ghash-neon-armv8.S"
+ , "ios-aarch64/crypto/fipsmodule/ghashv8-armx64.S"
+ , "ios-aarch64/crypto/fipsmodule/sha1-armv8.S"
+ , "ios-aarch64/crypto/fipsmodule/sha256-armv8.S"
+ , "ios-aarch64/crypto/fipsmodule/sha512-armv8.S"
+ , "ios-aarch64/crypto/fipsmodule/vpaes-armv8.S"
+ , "ios-aarch64/crypto/test/trampoline-armv8.S"
+ ]
+ }
+, "crypto_sources_ios_arm":
+ { "type": "install"
+ , "deps":
+ [ "ios-arm/crypto/chacha/chacha-armv4.S"
+ , "ios-arm/crypto/fipsmodule/aesv8-armx32.S"
+ , "ios-arm/crypto/fipsmodule/armv4-mont.S"
+ , "ios-arm/crypto/fipsmodule/bsaes-armv7.S"
+ , "ios-arm/crypto/fipsmodule/ghash-armv4.S"
+ , "ios-arm/crypto/fipsmodule/ghashv8-armx32.S"
+ , "ios-arm/crypto/fipsmodule/sha1-armv4-large.S"
+ , "ios-arm/crypto/fipsmodule/sha256-armv4.S"
+ , "ios-arm/crypto/fipsmodule/sha512-armv4.S"
+ , "ios-arm/crypto/fipsmodule/vpaes-armv7.S"
+ , "ios-arm/crypto/test/trampoline-armv4.S"
+ ]
+ }
+, "crypto_sources_linux_aarch64":
+ { "type": "install"
+ , "deps":
+ [ "linux-aarch64/crypto/chacha/chacha-armv8.S"
+ , "linux-aarch64/crypto/fipsmodule/aesv8-armx64.S"
+ , "linux-aarch64/crypto/fipsmodule/armv8-mont.S"
+ , "linux-aarch64/crypto/fipsmodule/ghash-neon-armv8.S"
+ , "linux-aarch64/crypto/fipsmodule/ghashv8-armx64.S"
+ , "linux-aarch64/crypto/fipsmodule/sha1-armv8.S"
+ , "linux-aarch64/crypto/fipsmodule/sha256-armv8.S"
+ , "linux-aarch64/crypto/fipsmodule/sha512-armv8.S"
+ , "linux-aarch64/crypto/fipsmodule/vpaes-armv8.S"
+ , "linux-aarch64/crypto/test/trampoline-armv8.S"
+ ]
+ }
+, "crypto_sources_linux_arm":
+ { "type": "install"
+ , "deps":
+ [ "linux-arm/crypto/chacha/chacha-armv4.S"
+ , "linux-arm/crypto/fipsmodule/aesv8-armx32.S"
+ , "linux-arm/crypto/fipsmodule/armv4-mont.S"
+ , "linux-arm/crypto/fipsmodule/bsaes-armv7.S"
+ , "linux-arm/crypto/fipsmodule/ghash-armv4.S"
+ , "linux-arm/crypto/fipsmodule/ghashv8-armx32.S"
+ , "linux-arm/crypto/fipsmodule/sha1-armv4-large.S"
+ , "linux-arm/crypto/fipsmodule/sha256-armv4.S"
+ , "linux-arm/crypto/fipsmodule/sha512-armv4.S"
+ , "linux-arm/crypto/fipsmodule/vpaes-armv7.S"
+ , "linux-arm/crypto/test/trampoline-armv4.S"
+ , "src/crypto/curve25519/asm/x25519-asm-arm.S"
+ , "src/crypto/poly1305/poly1305_arm_asm.S"
+ ]
+ }
+, "crypto_sources_linux_ppc64le":
+ { "type": "install"
+ , "deps":
+ [ "linux-ppc64le/crypto/fipsmodule/aesp8-ppc.S"
+ , "linux-ppc64le/crypto/fipsmodule/ghashp8-ppc.S"
+ , "linux-ppc64le/crypto/test/trampoline-ppc.S"
+ ]
+ }
+, "crypto_sources_linux_x86":
+ { "type": "install"
+ , "deps":
+ [ "linux-x86/crypto/chacha/chacha-x86.S"
+ , "linux-x86/crypto/fipsmodule/aesni-x86.S"
+ , "linux-x86/crypto/fipsmodule/bn-586.S"
+ , "linux-x86/crypto/fipsmodule/co-586.S"
+ , "linux-x86/crypto/fipsmodule/ghash-ssse3-x86.S"
+ , "linux-x86/crypto/fipsmodule/ghash-x86.S"
+ , "linux-x86/crypto/fipsmodule/md5-586.S"
+ , "linux-x86/crypto/fipsmodule/sha1-586.S"
+ , "linux-x86/crypto/fipsmodule/sha256-586.S"
+ , "linux-x86/crypto/fipsmodule/sha512-586.S"
+ , "linux-x86/crypto/fipsmodule/vpaes-x86.S"
+ , "linux-x86/crypto/fipsmodule/x86-mont.S"
+ , "linux-x86/crypto/test/trampoline-x86.S"
+ ]
+ }
+, "crypto_sources_linux_x86_64":
+ { "type": "install"
+ , "deps":
+ [ "linux-x86_64/crypto/chacha/chacha-x86_64.S"
+ , "linux-x86_64/crypto/cipher_extra/aes128gcmsiv-x86_64.S"
+ , "linux-x86_64/crypto/cipher_extra/chacha20_poly1305_x86_64.S"
+ , "linux-x86_64/crypto/fipsmodule/aesni-gcm-x86_64.S"
+ , "linux-x86_64/crypto/fipsmodule/aesni-x86_64.S"
+ , "linux-x86_64/crypto/fipsmodule/ghash-ssse3-x86_64.S"
+ , "linux-x86_64/crypto/fipsmodule/ghash-x86_64.S"
+ , "linux-x86_64/crypto/fipsmodule/md5-x86_64.S"
+ , "linux-x86_64/crypto/fipsmodule/p256-x86_64-asm.S"
+ , "linux-x86_64/crypto/fipsmodule/p256_beeu-x86_64-asm.S"
+ , "linux-x86_64/crypto/fipsmodule/rdrand-x86_64.S"
+ , "linux-x86_64/crypto/fipsmodule/rsaz-avx2.S"
+ , "linux-x86_64/crypto/fipsmodule/sha1-x86_64.S"
+ , "linux-x86_64/crypto/fipsmodule/sha256-x86_64.S"
+ , "linux-x86_64/crypto/fipsmodule/sha512-x86_64.S"
+ , "linux-x86_64/crypto/fipsmodule/vpaes-x86_64.S"
+ , "linux-x86_64/crypto/fipsmodule/x86_64-mont.S"
+ , "linux-x86_64/crypto/fipsmodule/x86_64-mont5.S"
+ , "linux-x86_64/crypto/test/trampoline-x86_64.S"
+ , "src/crypto/hrss/asm/poly_rq_mul.S"
+ ]
+ }
+, "crypto_sources_mac_x86":
+ { "type": "install"
+ , "deps":
+ [ "mac-x86/crypto/chacha/chacha-x86.S"
+ , "mac-x86/crypto/fipsmodule/aesni-x86.S"
+ , "mac-x86/crypto/fipsmodule/bn-586.S"
+ , "mac-x86/crypto/fipsmodule/co-586.S"
+ , "mac-x86/crypto/fipsmodule/ghash-ssse3-x86.S"
+ , "mac-x86/crypto/fipsmodule/ghash-x86.S"
+ , "mac-x86/crypto/fipsmodule/md5-586.S"
+ , "mac-x86/crypto/fipsmodule/sha1-586.S"
+ , "mac-x86/crypto/fipsmodule/sha256-586.S"
+ , "mac-x86/crypto/fipsmodule/sha512-586.S"
+ , "mac-x86/crypto/fipsmodule/vpaes-x86.S"
+ , "mac-x86/crypto/fipsmodule/x86-mont.S"
+ , "mac-x86/crypto/test/trampoline-x86.S"
+ ]
+ }
+, "crypto_sources_mac_x86_64":
+ { "type": "install"
+ , "deps":
+ [ "mac-x86_64/crypto/chacha/chacha-x86_64.S"
+ , "mac-x86_64/crypto/cipher_extra/aes128gcmsiv-x86_64.S"
+ , "mac-x86_64/crypto/cipher_extra/chacha20_poly1305_x86_64.S"
+ , "mac-x86_64/crypto/fipsmodule/aesni-gcm-x86_64.S"
+ , "mac-x86_64/crypto/fipsmodule/aesni-x86_64.S"
+ , "mac-x86_64/crypto/fipsmodule/ghash-ssse3-x86_64.S"
+ , "mac-x86_64/crypto/fipsmodule/ghash-x86_64.S"
+ , "mac-x86_64/crypto/fipsmodule/md5-x86_64.S"
+ , "mac-x86_64/crypto/fipsmodule/p256-x86_64-asm.S"
+ , "mac-x86_64/crypto/fipsmodule/p256_beeu-x86_64-asm.S"
+ , "mac-x86_64/crypto/fipsmodule/rdrand-x86_64.S"
+ , "mac-x86_64/crypto/fipsmodule/rsaz-avx2.S"
+ , "mac-x86_64/crypto/fipsmodule/sha1-x86_64.S"
+ , "mac-x86_64/crypto/fipsmodule/sha256-x86_64.S"
+ , "mac-x86_64/crypto/fipsmodule/sha512-x86_64.S"
+ , "mac-x86_64/crypto/fipsmodule/vpaes-x86_64.S"
+ , "mac-x86_64/crypto/fipsmodule/x86_64-mont.S"
+ , "mac-x86_64/crypto/fipsmodule/x86_64-mont5.S"
+ , "mac-x86_64/crypto/test/trampoline-x86_64.S"
+ ]
+ }
+, "crypto_sources_win_x86":
+ { "type": "install"
+ , "deps":
+ [ "win-x86/crypto/chacha/chacha-x86.asm"
+ , "win-x86/crypto/fipsmodule/aesni-x86.asm"
+ , "win-x86/crypto/fipsmodule/bn-586.asm"
+ , "win-x86/crypto/fipsmodule/co-586.asm"
+ , "win-x86/crypto/fipsmodule/ghash-ssse3-x86.asm"
+ , "win-x86/crypto/fipsmodule/ghash-x86.asm"
+ , "win-x86/crypto/fipsmodule/md5-586.asm"
+ , "win-x86/crypto/fipsmodule/sha1-586.asm"
+ , "win-x86/crypto/fipsmodule/sha256-586.asm"
+ , "win-x86/crypto/fipsmodule/sha512-586.asm"
+ , "win-x86/crypto/fipsmodule/vpaes-x86.asm"
+ , "win-x86/crypto/fipsmodule/x86-mont.asm"
+ , "win-x86/crypto/test/trampoline-x86.asm"
+ ]
+ }
+, "crypto_sources_win_x86_64":
+ { "type": "install"
+ , "deps":
+ [ "win-x86_64/crypto/chacha/chacha-x86_64.asm"
+ , "win-x86_64/crypto/cipher_extra/aes128gcmsiv-x86_64.asm"
+ , "win-x86_64/crypto/cipher_extra/chacha20_poly1305_x86_64.asm"
+ , "win-x86_64/crypto/fipsmodule/aesni-gcm-x86_64.asm"
+ , "win-x86_64/crypto/fipsmodule/aesni-x86_64.asm"
+ , "win-x86_64/crypto/fipsmodule/ghash-ssse3-x86_64.asm"
+ , "win-x86_64/crypto/fipsmodule/ghash-x86_64.asm"
+ , "win-x86_64/crypto/fipsmodule/md5-x86_64.asm"
+ , "win-x86_64/crypto/fipsmodule/p256-x86_64-asm.asm"
+ , "win-x86_64/crypto/fipsmodule/p256_beeu-x86_64-asm.asm"
+ , "win-x86_64/crypto/fipsmodule/rdrand-x86_64.asm"
+ , "win-x86_64/crypto/fipsmodule/rsaz-avx2.asm"
+ , "win-x86_64/crypto/fipsmodule/sha1-x86_64.asm"
+ , "win-x86_64/crypto/fipsmodule/sha256-x86_64.asm"
+ , "win-x86_64/crypto/fipsmodule/sha512-x86_64.asm"
+ , "win-x86_64/crypto/fipsmodule/vpaes-x86_64.asm"
+ , "win-x86_64/crypto/fipsmodule/x86_64-mont.asm"
+ , "win-x86_64/crypto/fipsmodule/x86_64-mont5.asm"
+ , "win-x86_64/crypto/test/trampoline-x86_64.asm"
+ ]
+ }
+, "crypto_sources_asm":
+ { "type": "install"
+ , "arguments_config": ["OS", "ARCH", "TARGET_ARCH"]
+ , "deps":
+ { "type": "let*"
+ , "bindings":
+ [ [ "PLATFORM"
+ , { "type": "join"
+ , "separator": "_"
+ , "$1":
+ [ {"type": "var", "name": "OS", "default": "linux"}
+ , { "type": "var"
+ , "name": "TARGET_ARCH"
+ , "default":
+ { "type": "var"
+ , "name": "ARCH"
+ , "default":
+ {"type": "fail", "msg": "ARCH is required for boringssl."}
+ }
+ }
+ ]
+ }
+ ]
+ ]
+ , "body":
+ { "type": "case"
+ , "expr": {"type": "var", "name": "PLATFORM"}
+ , "case":
+ { "linux_x86": ["crypto_sources_linux_x86"]
+ , "linux_x86_64": ["crypto_sources_linux_x86_64"]
+ , "linux_arm": ["crypto_sources_linux_arm"]
+ , "linux_arm64": ["crypto_sources_linux_aarch64"]
+ , "linux_ppc64le": ["crypto_sources_linux_ppc64le"]
+ , "mac_x86": ["crypto_sources_mac_x86"]
+ , "mac_x86_64": ["crypto_sources_mac_x86_64"]
+ , "windows_x86": ["crypto_sources_win_x86"]
+ , "windows_x86_64": ["crypto_sources_win_x86_64"]
+ }
+ }
+ }
+ }
+, "ssl_sources":
+ { "type": "install"
+ , "deps":
+ [ "src/ssl/bio_ssl.cc"
+ , "src/ssl/d1_both.cc"
+ , "src/ssl/d1_lib.cc"
+ , "src/ssl/d1_pkt.cc"
+ , "src/ssl/d1_srtp.cc"
+ , "src/ssl/dtls_method.cc"
+ , "src/ssl/dtls_record.cc"
+ , "src/ssl/encrypted_client_hello.cc"
+ , "src/ssl/extensions.cc"
+ , "src/ssl/handoff.cc"
+ , "src/ssl/handshake.cc"
+ , "src/ssl/handshake_client.cc"
+ , "src/ssl/handshake_server.cc"
+ , "src/ssl/s3_both.cc"
+ , "src/ssl/s3_lib.cc"
+ , "src/ssl/s3_pkt.cc"
+ , "src/ssl/ssl_aead_ctx.cc"
+ , "src/ssl/ssl_asn1.cc"
+ , "src/ssl/ssl_buffer.cc"
+ , "src/ssl/ssl_cert.cc"
+ , "src/ssl/ssl_cipher.cc"
+ , "src/ssl/ssl_file.cc"
+ , "src/ssl/ssl_key_share.cc"
+ , "src/ssl/ssl_lib.cc"
+ , "src/ssl/ssl_privkey.cc"
+ , "src/ssl/ssl_session.cc"
+ , "src/ssl/ssl_stat.cc"
+ , "src/ssl/ssl_transcript.cc"
+ , "src/ssl/ssl_versions.cc"
+ , "src/ssl/ssl_x509.cc"
+ , "src/ssl/t1_enc.cc"
+ , "src/ssl/tls13_both.cc"
+ , "src/ssl/tls13_client.cc"
+ , "src/ssl/tls13_enc.cc"
+ , "src/ssl/tls13_server.cc"
+ , "src/ssl/tls_method.cc"
+ , "src/ssl/tls_record.cc"
+ ]
+ }
+, "ssl_internal_headers": {"type": "install", "deps": ["src/ssl/internal.h"]}
+}
diff --git a/etc/imports/files.TARGETS b/etc/imports/files.TARGETS
new file mode 100644
index 0000000..a40146d
--- /dev/null
+++ b/etc/imports/files.TARGETS
@@ -0,0 +1 @@
+{"files": {"type": "install", "deps": [["TREE", null, "."]]}}
diff --git a/etc/imports/musl-cross-make-fe915821.TARGETS b/etc/imports/musl-cross-make-fe915821.TARGETS
new file mode 100644
index 0000000..1c4790c
--- /dev/null
+++ b/etc/imports/musl-cross-make-fe915821.TARGETS
@@ -0,0 +1,44 @@
+{ "config.mak":
+ { "type": "file_gen"
+ , "name": "config.mak"
+ , "data":
+ { "type": "join"
+ , "separator": "\n"
+ , "$1":
+ [ "BINUTILS_VER = latest"
+ , "MUSL_VER = latest"
+ , "GMP_VER = latest"
+ , "MPC_VER = latest"
+ , "MPFR_VER = latest"
+ , "BINUTILS_CONFIG += --enable-gprofng=no # needs bison"
+ , ""
+ ]
+ }
+ }
+, "separate_sources_and_patches":
+ { "type": "install"
+ , "files": {"config.mak": "config.mak"}
+ , "dirs":
+ [ [["TREE", null, "."], "src"]
+ , [["@", "config", "", "files"], "config"]
+ , [["@", "linux-headers", "", "files"], "linux-headers"]
+ , [["@", "patches", "", "musl-cross-make-fe915821"], "patches"]
+ ]
+ }
+, "combined_sources_and_patches":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": ["separate_sources_and_patches"]
+ , "cmds":
+ [ "cp -r src/. ${DESTDIR}/."
+ , "cd ${DESTDIR}"
+ , "chmod -R +w *"
+ , "patch -p1 < ${WORKDIR}/patches/musl-cross-make-fe915821/fix-asound-patch.patch >/dev/null"
+ , "mkdir sources"
+ , "mv \"${WORKDIR}/config.mak\" ."
+ , "mv \"${WORKDIR}/config/config.sub\" sources/config.sub"
+ , "mv \"${WORKDIR}/linux-headers\" linux-headers-4.19.88-1.orig"
+ , "cp -r \"${WORKDIR}/patches/musl-cross-make-fe915821/patches/.\" patches/."
+ ]
+ , "out_dirs": ["."]
+ }
+}
diff --git a/etc/imports/src/include/openssl/boringssl.TARGETS b/etc/imports/src/include/openssl/boringssl.TARGETS
new file mode 100644
index 0000000..c84392a
--- /dev/null
+++ b/etc/imports/src/include/openssl/boringssl.TARGETS
@@ -0,0 +1,86 @@
+{ "crypto_headers":
+ { "type": ["@", "rules", "data", "staged"]
+ , "srcs":
+ [ "aead.h"
+ , "aes.h"
+ , "arm_arch.h"
+ , "asn1.h"
+ , "asn1t.h"
+ , "asn1_mac.h"
+ , "base.h"
+ , "base64.h"
+ , "bio.h"
+ , "blake2.h"
+ , "blowfish.h"
+ , "bn.h"
+ , "buf.h"
+ , "buffer.h"
+ , "bytestring.h"
+ , "cast.h"
+ , "chacha.h"
+ , "cipher.h"
+ , "cmac.h"
+ , "conf.h"
+ , "cpu.h"
+ , "crypto.h"
+ , "curve25519.h"
+ , "des.h"
+ , "dh.h"
+ , "digest.h"
+ , "dsa.h"
+ , "ec.h"
+ , "ecdh.h"
+ , "ecdsa.h"
+ , "ec_key.h"
+ , "engine.h"
+ , "err.h"
+ , "evp.h"
+ , "evp_errors.h"
+ , "ex_data.h"
+ , "e_os2.h"
+ , "hkdf.h"
+ , "hmac.h"
+ , "hpke.h"
+ , "hrss.h"
+ , "is_boringssl.h"
+ , "lhash.h"
+ , "md4.h"
+ , "md5.h"
+ , "mem.h"
+ , "nid.h"
+ , "obj.h"
+ , "objects.h"
+ , "obj_mac.h"
+ , "opensslconf.h"
+ , "opensslv.h"
+ , "ossl_typ.h"
+ , "pem.h"
+ , "pkcs12.h"
+ , "pkcs7.h"
+ , "pkcs8.h"
+ , "poly1305.h"
+ , "pool.h"
+ , "rand.h"
+ , "rc4.h"
+ , "ripemd.h"
+ , "rsa.h"
+ , "safestack.h"
+ , "sha.h"
+ , "siphash.h"
+ , "span.h"
+ , "stack.h"
+ , "thread.h"
+ , "trust_token.h"
+ , "type_check.h"
+ , "x509.h"
+ , "x509v3.h"
+ , "x509_vfy.h"
+ ]
+ , "stage": ["openssl"]
+ }
+, "ssl_headers":
+ { "type": ["@", "rules", "data", "staged"]
+ , "srcs": ["dtls1.h", "srtp.h", "ssl.h", "ssl3.h", "tls1.h"]
+ , "stage": ["openssl"]
+ }
+}
diff --git a/etc/imports/zlib.TARGETS b/etc/imports/zlib.TARGETS
new file mode 100644
index 0000000..a787252
--- /dev/null
+++ b/etc/imports/zlib.TARGETS
@@ -0,0 +1,17 @@
+{ "zlib":
+ { "type": "export"
+ , "target": "libz"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ }
+, "libz":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": [["TREE", null, "."]]
+ , "cmds":
+ [ "export NJOBS=$(nproc --all 2>/dev/null || echo 1)"
+ , "rm Makefile"
+ , "./configure --static --prefix=/ >configure.log 2>&1 || (cat configure.log && exit 1)"
+ , "${MAKE} -j${NJOBS} install DESTDIR=${DESTDIR} >build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ ]
+ , "out_dirs": ["."]
+ }
+}
diff --git a/etc/patches/TARGETS b/etc/patches/TARGETS
new file mode 100644
index 0000000..f3c6084
--- /dev/null
+++ b/etc/patches/TARGETS
@@ -0,0 +1,8 @@
+{ "gcc-4.7.4": {"type": "install", "deps": [["TREE", null, "gcc-4.7.4"]]}
+, "gcc-10": {"type": "install", "deps": [["TREE", null, "gcc-10"]]}
+, "gcc-13": {"type": "install", "deps": [["TREE", null, "gcc-13"]]}
+, "musl-cross-make-fe915821":
+ {"type": "install", "deps": [["TREE", null, "musl-cross-make-fe915821"]]}
+, "clang-16": {"type": "install", "deps": [["TREE", null, "clang-16"]]}
+, "clang-17": {"type": "install", "deps": [["TREE", null, "clang-17"]]}
+}
diff --git a/etc/patches/clang-16/libcxx-musl-support.patch b/etc/patches/clang-16/libcxx-musl-support.patch
new file mode 100644
index 0000000..242ea2d
--- /dev/null
+++ b/etc/patches/clang-16/libcxx-musl-support.patch
@@ -0,0 +1,57 @@
+From 3b3afdadd7d32396a833c10a4e987e7648c2108e Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Wed, 2 Aug 2023 17:04:32 +0200
+Subject: [PATCH] libcxx: Add musl support for __locale
+
+... which does not provide a known rune table and uses
+missing locale-based string to integer conversion functions.
+---
+ libcxx/include/__locale | 32 ++++++++++++++++++++++++++++++++
+ 1 file changed, 32 insertions(+)
+
+diff --git a/libcxx/include/__locale b/libcxx/include/__locale
+index e0ffa0ca0..17b628696 100644
+--- a/libcxx/include/__locale
++++ b/libcxx/include/__locale
+@@ -22,6 +22,38 @@
+ #include <cstddef>
+ #include <cstring>
+
++// Detect musl libc (inspired by musl detection from gcc's config.guess)
++#include <features.h>
++#if !(defined(__UCLIBC__) || defined(__dietlibc__) || defined(__GLIBC__))
++# include <stdarg.h>
++# ifdef __DEFINED_va_list
++# ifndef __MUSL_LIBC__
++# define __MUSL_LIBC__
++# endif
++# endif
++#endif
++
++#ifdef __MUSL_LIBC__
++// Fall back to default rune table for musl libc
++# ifndef _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
++# define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
++# endif
++// Implement missing strto*_l functions for musl libc
++# define __MUSL_LIBC_CREATE_STRTOX_L(X) \
++ static inline auto \
++ strto ## X ## _l(const char* str, char** end, int base, locale_t l) { \
++ locale_t old = uselocale(l); \
++ auto result = strto ## X(str, end, base); \
++ uselocale(old); \
++ return result; \
++ }
++__MUSL_LIBC_CREATE_STRTOX_L(l)
++__MUSL_LIBC_CREATE_STRTOX_L(ll)
++__MUSL_LIBC_CREATE_STRTOX_L(ul)
++__MUSL_LIBC_CREATE_STRTOX_L(ull)
++# undef __MUSL_LIBC_CREATE_STRTOX_L
++#endif
++
+ #if defined(_LIBCPP_MSVCRT_LIKE)
+ # include <__support/win32/locale_win32.h>
+ #elif defined(_AIX) || defined(__MVS__)
+--
+2.30.2
+
diff --git a/etc/patches/clang-17/libcxx-musl-support.patch b/etc/patches/clang-17/libcxx-musl-support.patch
new file mode 100644
index 0000000..e50d541
--- /dev/null
+++ b/etc/patches/clang-17/libcxx-musl-support.patch
@@ -0,0 +1,57 @@
+From 3b3afdadd7d32396a833c10a4e987e7648c2108e Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Wed, 2 Aug 2023 17:04:32 +0200
+Subject: [PATCH] libcxx: Add musl support for __locale
+
+... which does not provide a known rune table and uses
+missing locale-based string to integer conversion functions.
+---
+ libcxx/include/__locale | 32 ++++++++++++++++++++++++++++++++
+ 1 file changed, 32 insertions(+)
+
+diff --git a/libcxx/include/__locale b/libcxx/include/__locale
+index e0ffa0ca0..17b628696 100644
+--- a/libcxx/include/__locale
++++ b/libcxx/include/__locale
+@@ -25,6 +25,38 @@
+ #include <cstddef>
+ #include <cstring>
+
++// Detect musl libc (inspired by musl detection from gcc's config.guess)
++#include <features.h>
++#if !(defined(__UCLIBC__) || defined(__dietlibc__) || defined(__GLIBC__))
++# include <stdarg.h>
++# ifdef __DEFINED_va_list
++# ifndef __MUSL_LIBC__
++# define __MUSL_LIBC__
++# endif
++# endif
++#endif
++
++#ifdef __MUSL_LIBC__
++// Fall back to default rune table for musl libc
++# ifndef _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
++# define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
++# endif
++// Implement missing strto*_l functions for musl libc
++# define __MUSL_LIBC_CREATE_STRTOX_L(X) \
++ static inline auto \
++ strto ## X ## _l(const char* str, char** end, int base, locale_t l) { \
++ locale_t old = uselocale(l); \
++ auto result = strto ## X(str, end, base); \
++ uselocale(old); \
++ return result; \
++ }
++__MUSL_LIBC_CREATE_STRTOX_L(l)
++__MUSL_LIBC_CREATE_STRTOX_L(ll)
++__MUSL_LIBC_CREATE_STRTOX_L(ul)
++__MUSL_LIBC_CREATE_STRTOX_L(ull)
++# undef __MUSL_LIBC_CREATE_STRTOX_L
++#endif
++
+ #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ # include <cwchar>
+ #else
+--
+2.30.2
+
diff --git a/etc/patches/gcc-10/detect-glibc-via-__GLIBC__.patch b/etc/patches/gcc-10/detect-glibc-via-__GLIBC__.patch
new file mode 100644
index 0000000..dcad1e6
--- /dev/null
+++ b/etc/patches/gcc-10/detect-glibc-via-__GLIBC__.patch
@@ -0,0 +1,69 @@
+From c913861c81772b42b5a5279d035430f11dc8a790 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Fri, 4 Aug 2023 17:57:20 +0200
+Subject: [PATCH] config.guess: Detect glibc via __GLIBC__
+
+Backport from GCC 11.1.0
+ Git commit: 53a90650663e59948f86505660604b5769cf808c and
+ 74af13c174714dd3b9f1ded4b39955f003c16361
+
+Co-authored-by: Iain Sandoe <iain@sandoe.co.uk>
+Co-authored-by: Kito Cheng <kito.cheng@sifive.com>
+---
+ config.guess | 28 +++++++++++++++++++---------
+ 1 file changed, 19 insertions(+), 9 deletions(-)
+
+diff --git a/config.guess b/config.guess
+index 97ad073..8792dd3 100755
+--- a/config.guess
++++ b/config.guess
+@@ -136,9 +136,7 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+ case "$UNAME_SYSTEM" in
+ Linux|GNU|GNU/*)
+- # If the system lacks a compiler, then just pick glibc.
+- # We could probably try harder.
+- LIBC=gnu
++ LIBC=unknown
+
+ set_cc_for_build
+ cat <<-EOF > "$dummy.c"
+@@ -147,17 +145,29 @@ Linux|GNU|GNU/*)
+ LIBC=uclibc
+ #elif defined(__dietlibc__)
+ LIBC=dietlibc
+- #else
++ #elif defined(__GLIBC__)
+ LIBC=gnu
++ #else
++ #include <stdarg.h>
++ /* First heuristic to detect musl libc. */
++ #ifdef __DEFINED_va_list
++ LIBC=musl
++ #endif
+ #endif
+ EOF
+ eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`"
+
+- # If ldd exists, use it to detect musl libc.
+- if command -v ldd >/dev/null && \
+- ldd --version 2>&1 | grep -q ^musl
+- then
+- LIBC=musl
++ # Second heuristic to detect musl libc.
++ if [ "$LIBC" = unknown ] &&
++ command -v ldd >/dev/null &&
++ ldd --version 2>&1 | grep -q ^musl; then
++ LIBC=musl
++ fi
++
++ # If the system lacks a compiler, then just pick glibc.
++ # We could probably try harder.
++ if [ "$LIBC" = unknown ]; then
++ LIBC=gnu
+ fi
+ ;;
+ esac
+--
+2.30.2
+
diff --git a/etc/patches/gcc-10/reproducibility/0001-strip-build-directory-from-fixinclues.patch b/etc/patches/gcc-10/reproducibility/0001-strip-build-directory-from-fixinclues.patch
new file mode 100644
index 0000000..d9a545f
--- /dev/null
+++ b/etc/patches/gcc-10/reproducibility/0001-strip-build-directory-from-fixinclues.patch
@@ -0,0 +1,29 @@
+From a097d475fa8806265f445d11f3074f506baf4a3e Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Fri, 18 Aug 2023 14:36:57 +0200
+Subject: [PATCH 1/2] Strip build directory from fixinclues
+
+... to achieve a reproducible binary, which contains the
+configure string. For this to work, the user needs to set
+"BUILD_ROOT_DIR" before building.
+---
+ fixincludes/configure | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/fixincludes/configure b/fixincludes/configure
+index 6e2d67b65..b7d91c7ab 100755
+--- a/fixincludes/configure
++++ b/fixincludes/configure
+@@ -6374,6 +6374,9 @@ cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
+ BEGIN {
+ _ACEOF
+
++# Remove host machine's build path from confdefs.h
++sed -i 's|'${BUILD_ROOT_DIR:-/nonexistent}'|/build|g' confdefs.h
++
+ # Transform confdefs.h into an awk script `defines.awk', embedded as
+ # here-document in config.status, that substitutes the proper values into
+ # config.h.in to produce config.h.
+--
+2.30.2
+
diff --git a/etc/patches/gcc-10/reproducibility/0002-compute-reproducible-checksums.patch b/etc/patches/gcc-10/reproducibility/0002-compute-reproducible-checksums.patch
new file mode 100644
index 0000000..3aeb9fb
--- /dev/null
+++ b/etc/patches/gcc-10/reproducibility/0002-compute-reproducible-checksums.patch
@@ -0,0 +1,75 @@
+From effd0097f1b34616b410473493bd8eeb388835d8 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Mon, 21 Aug 2023 18:03:56 +0200
+Subject: [PATCH 2/2] Compute reproducible checksums
+
+... for variable toolchain paths:
+* remove linker path from gcc's checksum-options
+* disable thin archives (for stripping libbackend.a)
+* strip debug info before computing checksums
+For removing the linker path, the user needs to set
+"BUILD_ROOT_DIR" before building.
+---
+ gcc/Makefile.in | 3 ++-
+ gcc/c/Make-lang.in | 6 +++++-
+ gcc/cp/Make-lang.in | 6 +++++-
+ 3 files changed, 12 insertions(+), 3 deletions(-)
+
+diff --git a/gcc/Makefile.in b/gcc/Makefile.in
+index 5d05e8e0d..1346bbe72 100644
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -284,7 +284,7 @@ USE_THIN_ARCHIVES = no
+ ifeq ($(THIN_ARCHIVE_SUPPORT),yes)
+ ifeq ($(AR_FLAGS),rc)
+ ifeq ($(RANLIB_FLAGS),)
+-USE_THIN_ARCHIVES = yes
++#USE_THIN_ARCHIVES = yes
+ endif
+ endif
+ endif
+@@ -2075,6 +2075,7 @@ gcc-cross$(exeext): xgcc$(exeext)
+
+ checksum-options:
+ echo "$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS)" > checksum-options.tmp \
++ && sed -i 's|'$${BUILD_ROOT_DIR:-/nonexistent}'|/build|g' checksum-options.tmp \
+ && $(srcdir)/../move-if-change checksum-options.tmp checksum-options
+
+ #
+diff --git a/gcc/c/Make-lang.in b/gcc/c/Make-lang.in
+index 8944b9b9f..7ed444c5f 100644
+--- a/gcc/c/Make-lang.in
++++ b/gcc/c/Make-lang.in
+@@ -76,7 +76,11 @@ cc1-checksum.c : build/genchecksum$(build_exeext) checksum-options \
+ && cmp -s ../stage_current ../stage_final; then \
+ cp ../prev-gcc/cc1-checksum.c cc1-checksum.c; \
+ else \
+- build/genchecksum$(build_exeext) $(C_OBJS) $(BACKEND) $(LIBDEPS) \
++ rm -rf stripped_c_checksum_inputs; \
++ mkdir stripped_c_checksum_inputs; \
++ cp $(C_OBJS) $(BACKEND) $(LIBDEPS) stripped_c_checksum_inputs/; \
++ strip -g stripped_c_checksum_inputs/*; \
++ build/genchecksum$(build_exeext) $$(ls stripped_c_checksum_inputs/* | LC_ALL=C sort) \
+ checksum-options > cc1-checksum.c.tmp && \
+ $(srcdir)/../move-if-change cc1-checksum.c.tmp cc1-checksum.c; \
+ fi
+diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in
+index 7896591dd..c65afcb85 100644
+--- a/gcc/cp/Make-lang.in
++++ b/gcc/cp/Make-lang.in
+@@ -111,7 +111,11 @@ cc1plus-checksum.c : build/genchecksum$(build_exeext) checksum-options \
+ && cmp -s ../stage_current ../stage_final; then \
+ cp ../prev-gcc/cc1plus-checksum.c cc1plus-checksum.c; \
+ else \
+- build/genchecksum$(build_exeext) $(CXX_OBJS) $(BACKEND) $(LIBDEPS) \
++ rm -rf stripped_cp_checksum_inputs; \
++ mkdir stripped_cp_checksum_inputs; \
++ cp $(CXX_OBJS) $(BACKEND) $(CODYLIB) $(LIBDEPS) stripped_cp_checksum_inputs; \
++ strip -g stripped_cp_checksum_inputs/*; \
++ build/genchecksum$(build_exeext) $$(ls stripped_cp_checksum_inputs/* | LC_ALL=C sort) \
+ checksum-options > cc1plus-checksum.c.tmp && \
+ $(srcdir)/../move-if-change cc1plus-checksum.c.tmp cc1plus-checksum.c; \
+ fi
+--
+2.30.2
+
diff --git a/etc/patches/gcc-10/reproducibility/series b/etc/patches/gcc-10/reproducibility/series
new file mode 100644
index 0000000..1ec9fe3
--- /dev/null
+++ b/etc/patches/gcc-10/reproducibility/series
@@ -0,0 +1,2 @@
+0001-strip-build-directory-from-fixinclues.patch
+0002-compute-reproducible-checksums.patch
diff --git a/etc/patches/gcc-13/reproducibility/0001-strip-build-directory-from-config-arguments.patch b/etc/patches/gcc-13/reproducibility/0001-strip-build-directory-from-config-arguments.patch
new file mode 100644
index 0000000..20e16d4
--- /dev/null
+++ b/etc/patches/gcc-13/reproducibility/0001-strip-build-directory-from-config-arguments.patch
@@ -0,0 +1,42 @@
+From 0d902bfa02d5b5e6ef4e32dcdbe3b9c201c84fc6 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Mon, 14 Aug 2023 12:33:04 +0200
+Subject: [PATCH 1/5] Strip build directory from config arguments
+
+... to achieve a reproducible binary, which contains the
+configure string. For this to work, the user needs to set
+"BUILD_ROOT_DIR" before building.
+---
+ gcc/configure | 2 ++
+ gcc/configure.ac | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/gcc/configure b/gcc/configure
+index 530f4d695..65d8e64db 100755
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -13162,6 +13162,8 @@ fi
+ sed -e 's/\\/\\\\/g; s/"/\\"/g' <<EOF >conftest.out
+ $gcc_config_arguments
+ EOF
++# Remove host machine's build path from config arguments
++sed -i 's|'${BUILD_ROOT_DIR:-/nonexistent}'|/build|g' conftest.out
+ gcc_config_arguments_str=`cat conftest.out`
+ rm -f conftest.out
+
+diff --git a/gcc/configure.ac b/gcc/configure.ac
+index 09082e8cc..98e33b293 100644
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -2167,6 +2167,8 @@ fi
+ sed -e 's/\\/\\\\/g; s/"/\\"/g' <<EOF >conftest.out
+ $gcc_config_arguments
+ EOF
++# Remove host machine's build path from config arguments
++sed -i 's|'${BUILD_ROOT_DIR:-/nonexistent}'|/build|g' conftest.out
+ gcc_config_arguments_str=`cat conftest.out`
+ rm -f conftest.out
+
+--
+2.30.2
+
diff --git a/etc/patches/gcc-13/reproducibility/0002-strip-build-directory-from-fixinclues.patch b/etc/patches/gcc-13/reproducibility/0002-strip-build-directory-from-fixinclues.patch
new file mode 100644
index 0000000..fd1ea04
--- /dev/null
+++ b/etc/patches/gcc-13/reproducibility/0002-strip-build-directory-from-fixinclues.patch
@@ -0,0 +1,29 @@
+From a6fc1b1f0a05fbd6ba664393695ad20d3577a517 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Fri, 18 Aug 2023 14:36:57 +0200
+Subject: [PATCH 2/5] Strip build directory from fixinclues
+
+... to achieve a reproducible binary, which contains the
+configure string. For this to work, the user needs to set
+"BUILD_ROOT_DIR" before building.
+---
+ fixincludes/configure | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/fixincludes/configure b/fixincludes/configure
+index bdcc41f6d..9dc499bc1 100755
+--- a/fixincludes/configure
++++ b/fixincludes/configure
+@@ -6384,6 +6384,9 @@ cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
+ BEGIN {
+ _ACEOF
+
++# Remove host machine's build path from confdefs.h
++sed -i 's|'${BUILD_ROOT_DIR:-/nonexistent}'|/build|g' confdefs.h
++
+ # Transform confdefs.h into an awk script `defines.awk', embedded as
+ # here-document in config.status, that substitutes the proper values into
+ # config.h.in to produce config.h.
+--
+2.30.2
+
diff --git a/etc/patches/gcc-13/reproducibility/0003-strip-build-directory-from-mkheaders.conf.patch b/etc/patches/gcc-13/reproducibility/0003-strip-build-directory-from-mkheaders.conf.patch
new file mode 100644
index 0000000..356a2f9
--- /dev/null
+++ b/etc/patches/gcc-13/reproducibility/0003-strip-build-directory-from-mkheaders.conf.patch
@@ -0,0 +1,25 @@
+From b3cd904a8b4c35cd399a1c3726547a2edbe575fc Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Fri, 8 Sep 2023 16:16:29 +0200
+Subject: [PATCH 3/5] Strip build directory from mkheaders.conf
+
+---
+ gcc/Makefile.in | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/gcc/Makefile.in b/gcc/Makefile.in
+index f07dfe135..56a3f8e59 100644
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -4014,6 +4014,8 @@ install-mkheaders: stmp-int-hdrs install-itoolsdirs \
+ >> $(DESTDIR)$(itoolsdatadir)/mkheaders.conf
+ echo 'STMP_FIXINC="$(STMP_FIXINC)"' \
+ >> $(DESTDIR)$(itoolsdatadir)/mkheaders.conf
++ sed -i 's|'$${BUILD_ROOT_DIR:-/nonexistent}'|/build|g' \
++ $(DESTDIR)$(itoolsdatadir)/mkheaders.conf
+
+ # Use this target to install the program `collect2' under the name `collect2'.
+ install-collect2: collect2 installdirs
+--
+2.30.2
+
diff --git a/etc/patches/gcc-13/reproducibility/0004-compute-reproducible-checksums.patch b/etc/patches/gcc-13/reproducibility/0004-compute-reproducible-checksums.patch
new file mode 100644
index 0000000..8eaeaac
--- /dev/null
+++ b/etc/patches/gcc-13/reproducibility/0004-compute-reproducible-checksums.patch
@@ -0,0 +1,75 @@
+From 6ca5ec25d5dc33d3c54072619601e980af976050 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Mon, 21 Aug 2023 18:03:56 +0200
+Subject: [PATCH 4/5] Compute reproducible checksums
+
+... for variable toolchain paths:
+* remove linker path from gcc's checksum-options
+* disable thin archives (for stripping libbackend.a)
+* strip debug info before computing checksums
+For removing the linker path, the user needs to set
+"BUILD_ROOT_DIR" before building.
+---
+ gcc/Makefile.in | 3 ++-
+ gcc/c/Make-lang.in | 6 +++++-
+ gcc/cp/Make-lang.in | 6 +++++-
+ 3 files changed, 12 insertions(+), 3 deletions(-)
+
+diff --git a/gcc/Makefile.in b/gcc/Makefile.in
+index ad9a5d94c..45ea14ffa 100644
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -293,7 +293,7 @@ USE_THIN_ARCHIVES = no
+ ifeq ($(THIN_ARCHIVE_SUPPORT),yes)
+ ifeq ($(AR_FLAGS),rc)
+ ifeq ($(RANLIB_FLAGS),)
+-USE_THIN_ARCHIVES = yes
++#USE_THIN_ARCHIVES = yes
+ endif
+ endif
+ endif
+@@ -2188,6 +2188,7 @@ gcc-cross$(exeext): xgcc$(exeext)
+
+ checksum-options:
+ echo "$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS)" > checksum-options.tmp \
++ && sed -i 's|'$${BUILD_ROOT_DIR:-/nonexistent}'|/build|g' checksum-options.tmp \
+ && $(srcdir)/../move-if-change checksum-options.tmp checksum-options
+
+ #
+diff --git a/gcc/c/Make-lang.in b/gcc/c/Make-lang.in
+index b3b12dcff..1733b40a7 100644
+--- a/gcc/c/Make-lang.in
++++ b/gcc/c/Make-lang.in
+@@ -77,7 +77,11 @@ cc1-checksum.cc : build/genchecksum$(build_exeext) checksum-options \
+ && cmp -s ../stage_current ../stage_final; then \
+ cp ../prev-gcc/cc1-checksum.cc cc1-checksum.cc; \
+ else \
+- build/genchecksum$(build_exeext) $(C_OBJS) $(BACKEND) $(LIBDEPS) \
++ rm -rf stripped_c_checksum_inputs; \
++ mkdir stripped_c_checksum_inputs; \
++ cp $(C_OBJS) $(BACKEND) $(LIBDEPS) stripped_c_checksum_inputs/; \
++ strip -g stripped_c_checksum_inputs/*; \
++ build/genchecksum$(build_exeext) $$(ls stripped_c_checksum_inputs/* | LC_ALL=C sort) \
+ checksum-options > cc1-checksum.cc.tmp && \
+ $(srcdir)/../move-if-change cc1-checksum.cc.tmp cc1-checksum.cc; \
+ fi
+diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in
+index 4ee26fad9..30fe695ec 100644
+--- a/gcc/cp/Make-lang.in
++++ b/gcc/cp/Make-lang.in
+@@ -135,7 +135,11 @@ cc1plus-checksum.cc : build/genchecksum$(build_exeext) checksum-options \
+ && cmp -s ../stage_current ../stage_final; then \
+ cp ../prev-gcc/cc1plus-checksum.cc cc1plus-checksum.cc; \
+ else \
+- build/genchecksum$(build_exeext) $(CXX_OBJS) $(BACKEND) $(CODYLIB) $(LIBDEPS) \
++ rm -rf stripped_cp_checksum_inputs; \
++ mkdir stripped_cp_checksum_inputs; \
++ cp $(CXX_OBJS) $(BACKEND) $(CODYLIB) $(LIBDEPS) stripped_cp_checksum_inputs; \
++ strip -g stripped_cp_checksum_inputs/*; \
++ build/genchecksum$(build_exeext) $$(ls stripped_cp_checksum_inputs/* | LC_ALL=C sort) \
+ checksum-options > cc1plus-checksum.cc.tmp && \
+ $(srcdir)/../move-if-change cc1plus-checksum.cc.tmp cc1plus-checksum.cc; \
+ fi
+--
+2.30.2
+
diff --git a/etc/patches/gcc-13/reproducibility/0005-do-not-hardcode-rpath-into-cc1-libs.patch b/etc/patches/gcc-13/reproducibility/0005-do-not-hardcode-rpath-into-cc1-libs.patch
new file mode 100644
index 0000000..8c40fa9
--- /dev/null
+++ b/etc/patches/gcc-13/reproducibility/0005-do-not-hardcode-rpath-into-cc1-libs.patch
@@ -0,0 +1,26 @@
+From e091349f7ab0316cbe4b000783b5dd8f79a04424 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Fri, 8 Sep 2023 14:59:34 +0200
+Subject: [PATCH 5/5] Do not hardcode rpath into cc1 libs
+
+... which is a temporary path anyway.
+---
+ libcc1/configure | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libcc1/configure b/libcc1/configure
+index a9fb5f7..f39f76b 100755
+--- a/libcc1/configure
++++ b/libcc1/configure
+@@ -17313,7 +17313,7 @@ finish_cmds=$lt_finish_cmds
+ finish_eval=$lt_finish_eval
+
+ # Whether we should hardcode library paths into libraries.
+-hardcode_into_libs=$hardcode_into_libs
++hardcode_into_libs=no #$hardcode_into_libs
+
+ # Compile-time system search path for libraries.
+ sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+--
+2.30.2
+
diff --git a/etc/patches/gcc-13/reproducibility/series b/etc/patches/gcc-13/reproducibility/series
new file mode 100644
index 0000000..996d939
--- /dev/null
+++ b/etc/patches/gcc-13/reproducibility/series
@@ -0,0 +1,5 @@
+0001-strip-build-directory-from-config-arguments.patch
+0002-strip-build-directory-from-fixinclues.patch
+0003-strip-build-directory-from-mkheaders.conf.patch
+0004-compute-reproducible-checksums.patch
+0005-do-not-hardcode-rpath-into-cc1-libs.patch
diff --git a/etc/patches/gcc-4.7.4/musl-support/0001-config.sub-add-musl-support-for-gmp-mpc-mpfr.patch b/etc/patches/gcc-4.7.4/musl-support/0001-config.sub-add-musl-support-for-gmp-mpc-mpfr.patch
new file mode 100644
index 0000000..0dd1b0d
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/musl-support/0001-config.sub-add-musl-support-for-gmp-mpc-mpfr.patch
@@ -0,0 +1,80 @@
+From 491a585201160692ac8683aeb16e884e2537a685 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Thu, 29 Jun 2023 18:20:38 +0200
+Subject: [PATCH 1/7] config.sub: Add musl support for gmp/mpc/mpfr
+
+---
+ gmp/configfsf.sub | 4 ++--
+ mpc/config.sub | 4 ++--
+ mpfr/config.sub | 4 ++--
+ 3 files changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/gmp/configfsf.sub b/gmp/configfsf.sub
+index a649350a6..b08476d3f 100755
+--- a/gmp/configfsf.sub
++++ b/gmp/configfsf.sub
+@@ -120,7 +120,7 @@ esac
+ # Here we must recognize all the valid KERNEL-OS combinations.
+ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+ case $maybe_os in
+- nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
++ nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-musl* | linux-uclibc* | \
+ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+ storm-chaos* | os2-emx* | rtmk-nova*)
+ os=-$maybe_os
+@@ -1262,7 +1262,7 @@ case $os in
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -chorusos* | -chorusrdb* | -cegcc* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+- | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
++ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-musl* | -linux-uclibc* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+diff --git a/mpc/config.sub b/mpc/config.sub
+index 6759825a5..0057add97 100755
+--- a/mpc/config.sub
++++ b/mpc/config.sub
+@@ -120,7 +120,7 @@ esac
+ # Here we must recognize all the valid KERNEL-OS combinations.
+ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+ case $maybe_os in
+- nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
++ nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-musl* | linux-uclibc* | \
+ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+ storm-chaos* | os2-emx* | rtmk-nova*)
+ os=-$maybe_os
+@@ -1250,7 +1250,7 @@ case $os in
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -chorusos* | -chorusrdb* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+- | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
++ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-musl* | -linux-uclibc* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+diff --git a/mpfr/config.sub b/mpfr/config.sub
+index 1761d8bdf..aeb4ba340 100755
+--- a/mpfr/config.sub
++++ b/mpfr/config.sub
+@@ -120,7 +120,7 @@ esac
+ # Here we must recognize all the valid KERNEL-OS combinations.
+ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+ case $maybe_os in
+- nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
++ nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-musl* | linux-uclibc* | \
+ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+ storm-chaos* | os2-emx* | rtmk-nova*)
+ os=-$maybe_os
+@@ -1218,7 +1218,7 @@ case $os in
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -chorusos* | -chorusrdb* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+- | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
++ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-musl* | -linux-uclibc* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/musl-support/0002-config.sub-add-musl-support-for-gcc.patch b/etc/patches/gcc-4.7.4/musl-support/0002-config.sub-add-musl-support-for-gcc.patch
new file mode 100644
index 0000000..0c1682c
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/musl-support/0002-config.sub-add-musl-support-for-gcc.patch
@@ -0,0 +1,39 @@
+From c3922f0d82ab03e4702eba4c3359d25fd2139bcf Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Thu, 29 Jun 2023 18:04:32 +0200
+Subject: [PATCH 2/7] config.sub: Add musl support for gcc
+
+Backport from GCC 4.8.0
+ Git commit: f08bdd699385e0c8cc3c841da3f4f72d9141f68c
+ Subversion revision: r194449
+
+Co-authored-by: Jan-Benedict Glaw <jbglaw@lug-owl.de>
+---
+ config.sub | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/config.sub b/config.sub
+index 78176a440..deebfcee7 100755
+--- a/config.sub
++++ b/config.sub
+@@ -125,7 +125,7 @@ esac
+ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+ case $maybe_os in
+ nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
+- linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
++ linux-musl | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
+ knetbsd*-gnu* | netbsd*-gnu* | \
+ kopensolaris*-gnu* | \
+ storm-chaos* | os2-emx* | rtmk-nova*)
+@@ -1345,7 +1345,7 @@ case $os in
+ | -chorusos* | -chorusrdb* | -cegcc* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -linux-android* \
+- | -linux-newlib* | -linux-uclibc* \
++ | -linux-newlib* | -linux-musl* | -linux-uclibc* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/musl-support/0003-musl-libc-config.patch b/etc/patches/gcc-4.7.4/musl-support/0003-musl-libc-config.patch
new file mode 100644
index 0000000..fc3d5b0
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/musl-support/0003-musl-libc-config.patch
@@ -0,0 +1,330 @@
+From 2568562d330c29bf2b487a85677cd319d78630bf Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Thu, 29 Jun 2023 16:52:26 +0200
+Subject: [PATCH 3/7] musl libc config
+
+Backport from GCC 6.1.0
+ Git commit: 755658a56b57beca14b5fb70afdf1e588a058f7f
+ Subversion revision: r222904
+
+Original description:
+ * config.gcc (LIBC_MUSL): New tm_defines macro.
+ * config/linux.h (OPTION_MUSL): Define.
+ (MUSL_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER32,)
+ (MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERX32,)
+ (INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
+ (INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
+ (INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.
+ * config/linux.opt (mmusl): New option.
+ * doc/invoke.texi (GNU/Linux Options): Document -mmusl.
+ * configure.ac (gcc_cv_libc_provides_ssp): Add *-*-musl*.
+ (gcc_cv_target_dl_iterate_phdr): Add *-linux-musl*.
+ * configure: Regenerate.
+
+Co-authored-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
+Co-authored-by: Gregor Richards <gregor.richards@uwaterloo.ca>
+---
+ gcc/config.gcc | 5 +-
+ gcc/config/linux.h | 110 +++++++++++++++++++++++++++++++++++++------
+ gcc/config/linux.opt | 6 ++-
+ gcc/configure | 7 +++
+ gcc/configure.ac | 7 +++
+ gcc/doc/invoke.texi | 10 +++-
+ 6 files changed, 127 insertions(+), 18 deletions(-)
+
+diff --git a/gcc/config.gcc b/gcc/config.gcc
+index 9503b96cf..96ddb1a92 100644
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -522,7 +522,7 @@ case ${target} in
+ esac
+
+ # Common C libraries.
+-tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
++tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4"
+
+ # Common parts for widely ported systems.
+ case ${target} in
+@@ -625,6 +625,9 @@ case ${target} in
+ *-*-*uclibc*)
+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
+ ;;
++ *-*-*musl*)
++ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL"
++ ;;
+ *)
+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
+ ;;
+diff --git a/gcc/config/linux.h b/gcc/config/linux.h
+index fb459e680..064c6067d 100644
+--- a/gcc/config/linux.h
++++ b/gcc/config/linux.h
+@@ -33,10 +33,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
+ #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
+ #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
++#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
+ #else
+ #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
+ #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
+ #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
++#define OPTION_MUSL (linux_libc == LIBC_MUSL)
+ #endif
+
+ #define GNU_USER_TARGET_OS_CPP_BUILTINS() \
+@@ -51,21 +53,25 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ } while (0)
+
+ /* Determine which dynamic linker to use depending on whether GLIBC or
+- uClibc or Bionic is the default C library and whether
+- -muclibc or -mglibc or -mbionic has been passed to change the default. */
++ uClibc or Bionic or musl is the default C library and whether
++ -muclibc or -mglibc or -mbionic or -mmusl has been passed to change
++ the default. */
+
+-#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
+- "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
++#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \
++ "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}"
+
+ #if DEFAULT_LIBC == LIBC_GLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M)
+ #elif DEFAULT_LIBC == LIBC_UCLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M)
+ #elif DEFAULT_LIBC == LIBC_BIONIC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M)
++#elif DEFAULT_LIBC == LIBC_MUSL
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B)
+ #else
+ #error "Unsupported DEFAULT_LIBC"
+ #endif /* DEFAULT_LIBC */
+@@ -82,19 +88,24 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker"
+ #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64"
+ #define BIONIC_DYNAMIC_LINKERX32 "/system/bin/linkerx32"
++/* Should be redefined for each target that supports musl. */
++#define MUSL_DYNAMIC_LINKER "/dev/null"
++#define MUSL_DYNAMIC_LINKER32 "/dev/null"
++#define MUSL_DYNAMIC_LINKER64 "/dev/null"
++#define MUSL_DYNAMIC_LINKERX32 "/dev/null"
+
+ #define GNU_USER_DYNAMIC_LINKER \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
+- BIONIC_DYNAMIC_LINKER)
++ BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
+ #define GNU_USER_DYNAMIC_LINKER32 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
+- BIONIC_DYNAMIC_LINKER32)
++ BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
+ #define GNU_USER_DYNAMIC_LINKER64 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
+- BIONIC_DYNAMIC_LINKER64)
++ BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
+ #define GNU_USER_DYNAMIC_LINKERX32 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \
+- BIONIC_DYNAMIC_LINKERX32)
++ BIONIC_DYNAMIC_LINKERX32, MUSL_DYNAMIC_LINKERX32)
+
+ /* Determine whether the entire c99 runtime
+ is present in the runtime library. */
+@@ -108,3 +119,74 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ /* Whether we have Bionic libc runtime */
+ #undef TARGET_HAS_BIONIC
+ #define TARGET_HAS_BIONIC (OPTION_BIONIC)
++
++/* musl avoids problematic includes by rearranging the include directories.
++ * Unfortunately, this is mostly duplicated from cppdefault.c */
++#if DEFAULT_LIBC == LIBC_MUSL
++#define INCLUDE_DEFAULTS_MUSL_GPP \
++ { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \
++ { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \
++ { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
++
++#ifdef LOCAL_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_LOCAL \
++ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \
++ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
++#else
++#define INCLUDE_DEFAULTS_MUSL_LOCAL
++#endif
++
++#ifdef PREFIX_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_PREFIX \
++ { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_PREFIX
++#endif
++
++#ifdef CROSS_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_CROSS \
++ { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_CROSS
++#endif
++
++#ifdef TOOL_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_TOOL \
++ { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_TOOL
++#endif
++
++#ifdef NATIVE_SYSTEM_HEADER_DIR
++#define INCLUDE_DEFAULTS_MUSL_NATIVE \
++ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \
++ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 },
++#else
++#define INCLUDE_DEFAULTS_MUSL_NATIVE
++#endif
++
++#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
++# undef INCLUDE_DEFAULTS_MUSL_LOCAL
++# define INCLUDE_DEFAULTS_MUSL_LOCAL
++# undef INCLUDE_DEFAULTS_MUSL_NATIVE
++# define INCLUDE_DEFAULTS_MUSL_NATIVE
++#else
++# undef INCLUDE_DEFAULTS_MUSL_CROSS
++# define INCLUDE_DEFAULTS_MUSL_CROSS
++#endif
++
++#undef INCLUDE_DEFAULTS
++#define INCLUDE_DEFAULTS \
++ { \
++ INCLUDE_DEFAULTS_MUSL_GPP \
++ INCLUDE_DEFAULTS_MUSL_PREFIX \
++ INCLUDE_DEFAULTS_MUSL_CROSS \
++ INCLUDE_DEFAULTS_MUSL_TOOL \
++ INCLUDE_DEFAULTS_MUSL_NATIVE \
++ { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
++ { 0, 0, 0, 0, 0, 0 } \
++ }
++#endif
+diff --git a/gcc/config/linux.opt b/gcc/config/linux.opt
+index ba6b9f83e..f5e94a9b1 100644
+--- a/gcc/config/linux.opt
++++ b/gcc/config/linux.opt
+@@ -28,5 +28,9 @@ Target Report RejectNegative Var(linux_libc,LIBC_GLIBC) Negative(muclibc)
+ Use GNU C library
+
+ muclibc
+-Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic)
++Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mmusl)
+ Use uClibc C library
++
++mmusl
++Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mbionic)
++Use musl C library
+diff --git a/gcc/configure b/gcc/configure
+index 0d8c5e71d..695e7c415 100755
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -26791,6 +26791,9 @@ if test "${gcc_cv_libc_provides_ssp+set}" = set; then :
+ else
+ gcc_cv_libc_provides_ssp=no
+ case "$target" in
++ *-*-musl*)
++ # All versions of musl provide stack protector
++ gcc_cv_libc_provides_ssp=yes;;
+ *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
+ # glibc 2.4 and later provides __stack_chk_fail and
+ # either __stack_chk_guard, or TLS access to stack guard canary.
+@@ -26824,6 +26827,7 @@ else
+ # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
+ # simply assert that glibc does provide this, which is true for all
+ # realistically usable GNU/Hurd configurations.
++ # All supported versions of musl provide it as well
+ gcc_cv_libc_provides_ssp=yes;;
+ *-*-darwin* | *-*-freebsd*)
+ ac_fn_c_check_func "$LINENO" "__stack_chk_fail" "ac_cv_func___stack_chk_fail"
+@@ -26906,6 +26910,9 @@ case "$target" in
+ gcc_cv_target_dl_iterate_phdr=no
+ fi
+ ;;
++ *-linux-musl*)
++ gcc_cv_target_dl_iterate_phdr=yes
++ ;;
+ esac
+
+ if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
+diff --git a/gcc/configure.ac b/gcc/configure.ac
+index a78a1d76d..b6425efb4 100644
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -4669,6 +4669,9 @@ AC_CACHE_CHECK(__stack_chk_fail in target C library,
+ gcc_cv_libc_provides_ssp,
+ [gcc_cv_libc_provides_ssp=no
+ case "$target" in
++ *-*-musl*)
++ # All versions of musl provide stack protector
++ gcc_cv_libc_provides_ssp=yes;;
+ *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
+ [# glibc 2.4 and later provides __stack_chk_fail and
+ # either __stack_chk_guard, or TLS access to stack guard canary.
+@@ -4702,6 +4705,7 @@ AC_CACHE_CHECK(__stack_chk_fail in target C library,
+ # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
+ # simply assert that glibc does provide this, which is true for all
+ # realistically usable GNU/Hurd configurations.
++ # All supported versions of musl provide it as well
+ gcc_cv_libc_provides_ssp=yes;;
+ *-*-darwin* | *-*-freebsd*)
+ AC_CHECK_FUNC(__stack_chk_fail,[gcc_cv_libc_provides_ssp=yes],
+@@ -4767,6 +4771,9 @@ case "$target" in
+ gcc_cv_target_dl_iterate_phdr=no
+ fi
+ ;;
++ *-linux-musl*)
++ gcc_cv_target_dl_iterate_phdr=yes
++ ;;
+ esac
+ GCC_TARGET_TEMPLATE([TARGET_DL_ITERATE_PHDR])
+ if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
+diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
+index 625fef25a..159615fe4 100644
+--- a/gcc/doc/invoke.texi
++++ b/gcc/doc/invoke.texi
+@@ -595,7 +595,7 @@ Objective-C and Objective-C++ Dialects}.
+ -mcpu=@var{cpu}}
+
+ @emph{GNU/Linux Options}
+-@gccoptlist{-mglibc -muclibc -mbionic -mandroid @gol
++@gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid @gol
+ -tno-android-cc -tno-android-ld}
+
+ @emph{H8/300 Options}
+@@ -12879,13 +12879,19 @@ These @samp{-m} options are defined for GNU/Linux targets:
+ @item -mglibc
+ @opindex mglibc
+ Use the GNU C library. This is the default except
+-on @samp{*-*-linux-*uclibc*} and @samp{*-*-linux-*android*} targets.
++on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and
++@samp{*-*-linux-*android*} targets.
+
+ @item -muclibc
+ @opindex muclibc
+ Use uClibc C library. This is the default on
+ @samp{*-*-linux-*uclibc*} targets.
+
++@item -mmusl
++@opindex mmusl
++Use the musl C library. This is the default on
++@samp{*-*-linux-*musl*} targets.
++
+ @item -mbionic
+ @opindex mbionic
+ Use Bionic C library. This is the default on
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/musl-support/0004-x86-musl-support.patch b/etc/patches/gcc-4.7.4/musl-support/0004-x86-musl-support.patch
new file mode 100644
index 0000000..012abea
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/musl-support/0004-x86-musl-support.patch
@@ -0,0 +1,50 @@
+From dd5e082250ca7b45ed22f713e10f0ba78b10b798 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Thu, 29 Jun 2023 16:53:50 +0200
+Subject: [PATCH 4/7] x86 musl support
+
+Backport from GCC 6.1.0
+ Git commit: cf57e99350d0b44876979c71986d8ca29c361f83
+ Subversion revision: r223218
+
+Original description:
+ * config/i386/linux.h (MUSL_DYNAMIC_LINKER): Define.
+ * config/i386/linux64.h (MUSL_DYNAMIC_LINKER32): Define.
+ (MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERX32): Define.
+
+Co-authored-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
+Co-authored-by: Gregor Richards <gregor.richards@uwaterloo.ca>
+---
+ gcc/config/i386/linux.h | 3 +++
+ gcc/config/i386/linux64.h | 7 +++++++
+ 2 files changed, 10 insertions(+)
+
+diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
+index 73681fe82..f907adfb1 100644
+--- a/gcc/config/i386/linux.h
++++ b/gcc/config/i386/linux.h
+@@ -22,3 +22,6 @@ along with GCC; see the file COPYING3. If not see
+
+ #define GNU_USER_LINK_EMULATION "elf_i386"
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++
++#undef MUSL_DYNAMIC_LINKER
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
+diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h
+index 5b0a212ce..cf361b264 100644
+--- a/gcc/config/i386/linux64.h
++++ b/gcc/config/i386/linux64.h
+@@ -31,3 +31,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
+ #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
+ #define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2"
++
++#undef MUSL_DYNAMIC_LINKER32
++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
++#undef MUSL_DYNAMIC_LINKER64
++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
++#undef MUSL_DYNAMIC_LINKERX32
++#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-x32.so.1"
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/musl-support/0005-libstdc-workaround-for-musl.patch b/etc/patches/gcc-4.7.4/musl-support/0005-libstdc-workaround-for-musl.patch
new file mode 100644
index 0000000..0b862e0
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/musl-support/0005-libstdc-workaround-for-musl.patch
@@ -0,0 +1,50 @@
+From 6f30aa9b58c145331da46adad18dc38926252547 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Thu, 29 Jun 2023 17:02:18 +0200
+Subject: [PATCH 5/7] libstdc++ workaround for musl
+
+Backport from GCC 6.1.0
+ Git commit: 85da5c3024f731e719c4093314da8edcd1056527
+ Subversion revision: r222329
+
+Original description:
+ * config/os/generic/os_defines.h (_GLIBCXX_GTHREAD_USE_WEAK): Define.
+ * configure.host (os_include_dir): Set to "os/generic" for linux-musl*.
+
+Co-authored-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
+---
+ libstdc++-v3/config/os/generic/os_defines.h | 5 +++++
+ libstdc++-v3/configure.host | 3 +++
+ 2 files changed, 8 insertions(+)
+
+diff --git a/libstdc++-v3/config/os/generic/os_defines.h b/libstdc++-v3/config/os/generic/os_defines.h
+index 3199bf30b..b8d7c1636 100644
+--- a/libstdc++-v3/config/os/generic/os_defines.h
++++ b/libstdc++-v3/config/os/generic/os_defines.h
+@@ -33,4 +33,9 @@
+ // System-specific #define, typedefs, corrections, etc, go here. This
+ // file will come before all others.
+
++// Disable the weak reference logic in gthr.h for os/generic because it
++// is broken on every platform unless there is implementation specific
++// workaround in gthr-posix.h and at link-time for static linking.
++#define _GLIBCXX_GTHREAD_USE_WEAK 0
++
+ #endif
+diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host
+index b0e2cd9ea..df7977151 100644
+--- a/libstdc++-v3/configure.host
++++ b/libstdc++-v3/configure.host
+@@ -242,6 +242,9 @@ case "${host_os}" in
+ freebsd*)
+ os_include_dir="os/bsd/freebsd"
+ ;;
++ linux-musl*)
++ os_include_dir="os/generic"
++ ;;
+ gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
+ if [ "$uclibc" = "yes" ]; then
+ os_include_dir="os/uclibc"
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/musl-support/0006-config.guess-add-musl-support.patch b/etc/patches/gcc-4.7.4/musl-support/0006-config.guess-add-musl-support.patch
new file mode 100644
index 0000000..675ec49
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/musl-support/0006-config.guess-add-musl-support.patch
@@ -0,0 +1,196 @@
+From 3c7b2147778b44abe947fb645074fed0545905ac Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Thu, 29 Jun 2023 16:43:25 +0200
+Subject: [PATCH 6/7] config.guess: Add musl support
+
+Backport from GCC 9.1.0
+ Git commit: 29305f6018483963fa79b072cf8e95128f3e2cd8
+ Subversion revision: r261675
+
+Co-authored-by: Ben Elliston <bje@gnu.org>
+---
+ config.guess | 92 ++++++++++++++++++++++++++++++++--------------------
+ 1 file changed, 56 insertions(+), 36 deletions(-)
+
+diff --git a/config.guess b/config.guess
+index b02565c7b..081f4c8b7 100755
+--- a/config.guess
++++ b/config.guess
+@@ -142,6 +142,34 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+ # Note: order is significant - the case branches are not exclusive.
+
++case "$UNAME_SYSTEM" in
++Linux|GNU|GNU/*)
++ # If the system lacks a compiler, then just pick glibc.
++ # We could probably try harder.
++ LIBC=gnu
++
++ eval $set_cc_for_build
++ cat <<-EOF > "$dummy.c"
++ #include <features.h>
++ #if defined(__UCLIBC__)
++ LIBC=uclibc
++ #elif defined(__dietlibc__)
++ LIBC=dietlibc
++ #else
++ LIBC=gnu
++ #endif
++ EOF
++ eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`"
++
++ # If ldd exists, use it to detect musl libc.
++ if command -v ldd >/dev/null && \
++ ldd --version 2>&1 | grep -q ^musl
++ then
++ LIBC=musl
++ fi
++ ;;
++esac
++
+ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+ *:NetBSD:*:*)
+ # NetBSD (nbsd) targets should (where applicable) match one or
+@@ -872,56 +900,48 @@ EOF
+ EV68*) UNAME_MACHINE=alphaev68 ;;
+ esac
+ objdump --private-headers /bin/sh | grep -q ld.so.1
+- if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+- echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
++ if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ arm*:Linux:*:*)
+ eval $set_cc_for_build
+ if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ARM_EABI__
+ then
+- echo ${UNAME_MACHINE}-unknown-linux-gnu
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ else
+ if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ARM_PCS_VFP
+ then
+- echo ${UNAME_MACHINE}-unknown-linux-gnueabi
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
+ else
+- echo ${UNAME_MACHINE}-unknown-linux-gnueabihf
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
+ fi
+ fi
+ exit ;;
+ avr32*:Linux:*:*)
+- echo ${UNAME_MACHINE}-unknown-linux-gnu
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ cris:Linux:*:*)
+- echo cris-axis-linux-gnu
++ echo cris-axis-linux-${LIBC}
+ exit ;;
+ crisv32:Linux:*:*)
+- echo crisv32-axis-linux-gnu
++ echo crisv32-axis-linux-${LIBC}
+ exit ;;
+ frv:Linux:*:*)
+- echo frv-unknown-linux-gnu
++ echo frv-unknown-linux-${LIBC}
+ exit ;;
+ i*86:Linux:*:*)
+- LIBC=gnu
+- eval $set_cc_for_build
+- sed 's/^ //' << EOF >$dummy.c
+- #ifdef __dietlibc__
+- LIBC=dietlibc
+- #endif
+-EOF
+- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
+ echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+ exit ;;
+ ia64:Linux:*:*)
+- echo ${UNAME_MACHINE}-unknown-linux-gnu
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ m32r*:Linux:*:*)
+- echo ${UNAME_MACHINE}-unknown-linux-gnu
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ m68*:Linux:*:*)
+- echo ${UNAME_MACHINE}-unknown-linux-gnu
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ mips:Linux:*:* | mips64:Linux:*:*)
+ eval $set_cc_for_build
+@@ -940,54 +960,54 @@ EOF
+ #endif
+ EOF
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
+- test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
++ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
+ ;;
+ or32:Linux:*:*)
+- echo or32-unknown-linux-gnu
++ echo or32-unknown-linux-${LIBC}
+ exit ;;
+ padre:Linux:*:*)
+- echo sparc-unknown-linux-gnu
++ echo sparc-unknown-linux-${LIBC}
+ exit ;;
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
+- echo hppa64-unknown-linux-gnu
++ echo hppa64-unknown-linux-${LIBC}
+ exit ;;
+ parisc:Linux:*:* | hppa:Linux:*:*)
+ # Look for CPU level
+ case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+- PA7*) echo hppa1.1-unknown-linux-gnu ;;
+- PA8*) echo hppa2.0-unknown-linux-gnu ;;
+- *) echo hppa-unknown-linux-gnu ;;
++ PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;
++ PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
++ *) echo hppa-unknown-linux-${LIBC} ;;
+ esac
+ exit ;;
+ ppc64:Linux:*:*)
+- echo powerpc64-unknown-linux-gnu
++ echo powerpc64-unknown-linux-${LIBC}
+ exit ;;
+ ppc:Linux:*:*)
+- echo powerpc-unknown-linux-gnu
++ echo powerpc-unknown-linux-${LIBC}
+ exit ;;
+ s390:Linux:*:* | s390x:Linux:*:*)
+ echo ${UNAME_MACHINE}-ibm-linux
+ exit ;;
+ sh64*:Linux:*:*)
+- echo ${UNAME_MACHINE}-unknown-linux-gnu
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ sh*:Linux:*:*)
+- echo ${UNAME_MACHINE}-unknown-linux-gnu
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ sparc:Linux:*:* | sparc64:Linux:*:*)
+- echo ${UNAME_MACHINE}-unknown-linux-gnu
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ tile*:Linux:*:*)
+- echo ${UNAME_MACHINE}-unknown-linux-gnu
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ vax:Linux:*:*)
+- echo ${UNAME_MACHINE}-dec-linux-gnu
++ echo ${UNAME_MACHINE}-dec-linux-${LIBC}
+ exit ;;
+ x86_64:Linux:*:*)
+- echo x86_64-unknown-linux-gnu
++ echo x86_64-unknown-linux-${LIBC}
+ exit ;;
+ xtensa*:Linux:*:*)
+- echo ${UNAME_MACHINE}-unknown-linux-gnu
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ i*86:DYNIX/ptx:4*:*)
+ # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/musl-support/0007-config.guess-detect-glibc-via-__GLIBC__.patch b/etc/patches/gcc-4.7.4/musl-support/0007-config.guess-detect-glibc-via-__GLIBC__.patch
new file mode 100644
index 0000000..ea62d6b
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/musl-support/0007-config.guess-detect-glibc-via-__GLIBC__.patch
@@ -0,0 +1,70 @@
+From 32088af3619e49aecec44260d594fdcf590bfe00 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Wed, 19 Jul 2023 11:55:37 +0200
+Subject: [PATCH] config.guess: Detect glibc via __GLIBC__
+
+Backport from GCC 11.1.0
+ Git commit: 53a90650663e59948f86505660604b5769cf808c and
+ 74af13c174714dd3b9f1ded4b39955f003c16361
+
+Co-authored-by: Iain Sandoe <iain@sandoe.co.uk>
+Co-authored-by: Kito Cheng <kito.cheng@sifive.com>
+---
+ config.guess | 30 ++++++++++++++++++++----------
+ 1 file changed, 20 insertions(+), 10 deletions(-)
+
+diff --git a/config.guess b/config.guess
+index 081f4c8b7..3d378a144 100755
+--- a/config.guess
++++ b/config.guess
+@@ -144,9 +144,7 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+ case "$UNAME_SYSTEM" in
+ Linux|GNU|GNU/*)
+- # If the system lacks a compiler, then just pick glibc.
+- # We could probably try harder.
+- LIBC=gnu
++ LIBC=unknown
+
+ eval $set_cc_for_build
+ cat <<-EOF > "$dummy.c"
+@@ -155,17 +153,29 @@ Linux|GNU|GNU/*)
+ LIBC=uclibc
+ #elif defined(__dietlibc__)
+ LIBC=dietlibc
+- #else
++ #elif defined(__GLIBC__)
+ LIBC=gnu
++ #else
++ #include <stdarg.h>
++ /* First heuristic to detect musl libc. */
++ #ifdef __DEFINED_va_list
++ LIBC=musl
++ #endif
+ #endif
+ EOF
+- eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`"
++ eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`"
+
+- # If ldd exists, use it to detect musl libc.
+- if command -v ldd >/dev/null && \
+- ldd --version 2>&1 | grep -q ^musl
+- then
+- LIBC=musl
++ # Second heuristic to detect musl libc.
++ if [ "$LIBC" = unknown ] &&
++ command -v ldd >/dev/null &&
++ ldd --version 2>&1 | grep -q ^musl; then
++ LIBC=musl
++ fi
++
++ # If the system lacks a compiler, then just pick glibc.
++ # We could probably try harder.
++ if [ "$LIBC" = unknown ]; then
++ LIBC=gnu
+ fi
+ ;;
+ esac
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/musl-support/series b/etc/patches/gcc-4.7.4/musl-support/series
new file mode 100644
index 0000000..00daf30
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/musl-support/series
@@ -0,0 +1,7 @@
+0001-config.sub-add-musl-support-for-gmp-mpc-mpfr.patch
+0002-config.sub-add-musl-support-for-gcc.patch
+0003-musl-libc-config.patch
+0004-x86-musl-support.patch
+0005-libstdc-workaround-for-musl.patch
+0006-config.guess-add-musl-support.patch
+0007-config.guess-detect-glibc-via-__GLIBC__.patch
diff --git a/etc/patches/gcc-4.7.4/reproducibility/0001-strip-build-directory-from-fixinclues.patch b/etc/patches/gcc-4.7.4/reproducibility/0001-strip-build-directory-from-fixinclues.patch
new file mode 100644
index 0000000..885c7d0
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/reproducibility/0001-strip-build-directory-from-fixinclues.patch
@@ -0,0 +1,29 @@
+From 95563f6ef2366acb57557c11b8301d468a87e04f Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Fri, 18 Aug 2023 14:36:57 +0200
+Subject: [PATCH 1/2] Strip build directory from fixinclues
+
+... to achieve a reproducible binary, which contains the
+configure string. For this to work, the user needs to set
+"BUILD_ROOT_DIR" before building.
+---
+ fixincludes/configure | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/fixincludes/configure b/fixincludes/configure
+index 4a28cd1f3..45fdab2be 100755
+--- a/fixincludes/configure
++++ b/fixincludes/configure
+@@ -6236,6 +6236,9 @@ cat >"$tmp/defines.awk" <<\_ACAWK ||
+ BEGIN {
+ _ACEOF
+
++# Remove host machine's build path from confdefs.h
++sed -i 's|'${BUILD_ROOT_DIR:-/nonexistent}'|/build|g' confdefs.h
++
+ # Transform confdefs.h into an awk script `defines.awk', embedded as
+ # here-document in config.status, that substitutes the proper values into
+ # config.h.in to produce config.h.
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/reproducibility/0002-compute-reproducible-checksums.patch b/etc/patches/gcc-4.7.4/reproducibility/0002-compute-reproducible-checksums.patch
new file mode 100644
index 0000000..7db6c92
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/reproducibility/0002-compute-reproducible-checksums.patch
@@ -0,0 +1,58 @@
+From 617a9fc8ad3711fedea305881286bdc00b80a6e1 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Mon, 21 Aug 2023 18:03:56 +0200
+Subject: [PATCH 2/2] Compute reproducible checksums
+
+... for variable toolchain paths:
+* remove linker path from gcc's checksum-options
+* strip debug info before computing checksums
+For removing the linker path, the user needs to set
+"BUILD_ROOT_DIR" before building.
+---
+ gcc/Makefile.in | 7 ++++++-
+ gcc/cp/Make-lang.in | 6 +++++-
+ 2 files changed, 11 insertions(+), 2 deletions(-)
+
+diff --git a/gcc/Makefile.in b/gcc/Makefile.in
+index f3cc49fdb..7fb30a13f 100644
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -1804,12 +1804,17 @@ gcc-cross$(exeext): xgcc$(exeext)
+
+ checksum-options:
+ echo "$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS)" > checksum-options.tmp \
++ && sed -i 's|'$${BUILD_ROOT_DIR:-/nonexistent}'|/build|g' checksum-options.tmp \
+ && $(srcdir)/../move-if-change checksum-options.tmp checksum-options
+
+ # compute checksum over all object files and the options
+ cc1-checksum.c : build/genchecksum$(build_exeext) checksum-options \
+ $(C_OBJS) $(BACKEND) $(LIBDEPS)
+- build/genchecksum$(build_exeext) $(C_OBJS) $(BACKEND) $(LIBDEPS) \
++ rm -rf stripped_c_checksum_inputs; \
++ mkdir stripped_c_checksum_inputs; \
++ cp $(C_OBJS) $(BACKEND) $(LIBDEPS) stripped_c_checksum_inputs/; \
++ strip -g stripped_c_checksum_inputs/*; \
++ build/genchecksum$(build_exeext) $$(ls stripped_c_checksum_inputs/* | LC_ALL=C sort) \
+ checksum-options > cc1-checksum.c.tmp && \
+ $(srcdir)/../move-if-change cc1-checksum.c.tmp cc1-checksum.c
+
+diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in
+index 0ce01ac49..0fc43d305 100644
+--- a/gcc/cp/Make-lang.in
++++ b/gcc/cp/Make-lang.in
+@@ -95,7 +95,11 @@ cp-warn = $(STRICT_WARN)
+ # compute checksum over all object files and the options
+ cc1plus-checksum.c : build/genchecksum$(build_exeext) checksum-options \
+ $(CXX_OBJS) $(BACKEND) $(LIBDEPS)
+- build/genchecksum$(build_exeext) $(CXX_OBJS) $(BACKEND) $(LIBDEPS) \
++ rm -rf stripped_cp_checksum_inputs; \
++ mkdir stripped_cp_checksum_inputs; \
++ cp $(CXX_OBJS) $(BACKEND) $(CODYLIB) $(LIBDEPS) stripped_cp_checksum_inputs; \
++ strip -g stripped_cp_checksum_inputs/*; \
++ build/genchecksum$(build_exeext) $$(ls stripped_cp_checksum_inputs/* | LC_ALL=C sort) \
+ checksum-options > cc1plus-checksum.c.tmp && \
+ $(srcdir)/../move-if-change cc1plus-checksum.c.tmp cc1plus-checksum.c
+
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/reproducibility/series b/etc/patches/gcc-4.7.4/reproducibility/series
new file mode 100644
index 0000000..1ec9fe3
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/reproducibility/series
@@ -0,0 +1,2 @@
+0001-strip-build-directory-from-fixinclues.patch
+0002-compute-reproducible-checksums.patch
diff --git a/etc/patches/gcc-4.7.4/use-ucontext_t.patch b/etc/patches/gcc-4.7.4/use-ucontext_t.patch
new file mode 100644
index 0000000..51efb60
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/use-ucontext_t.patch
@@ -0,0 +1,153 @@
+From 321844cd2cd0676936c309669df058069c1a1db1 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Thu, 29 Jun 2023 15:53:01 +0200
+Subject: [PATCH] Use ucontext_t not struct ucontext in linux-unwind.h files.
+
+Backport from GCC 8.1.0
+ Git commit: 883312dc79806f513275b72502231c751c14ff72
+ Subversion revision: r249731
+
+Original description:
+ Current glibc no longer gives the ucontext_t type the tag struct
+ ucontext, to conform with POSIX namespace rules. This requires
+ various linux-unwind.h files in libgcc, that were previously using
+ struct ucontext, to be fixed to use ucontext_t instead. This is
+ similar to the removal of the struct siginfo tag from siginfo_t some
+ years ago.
+
+ This patch changes those files to use ucontext_t instead. As the
+ standard name that should be unconditionally safe, so this is not
+ restricted to architectures supported by glibc, or conditioned on the
+ glibc version.
+
+ Tested compilation together with current glibc with glibc's
+ build-many-glibcs.py.
+
+Co-authored-by: Joseph Myers <joseph@codesourcery.com>
+---
+ libgcc/config/alpha/linux-unwind.h | 2 +-
+ libgcc/config/bfin/linux-unwind.h | 2 +-
+ libgcc/config/i386/linux-unwind.h | 4 ++--
+ libgcc/config/m68k/linux-unwind.h | 2 +-
+ libgcc/config/pa/linux-unwind.h | 2 +-
+ libgcc/config/sh/linux-unwind.h | 2 +-
+ libgcc/config/tilepro/linux-unwind.h | 2 +-
+ libgcc/config/xtensa/linux-unwind.h | 2 +-
+ 8 files changed, 9 insertions(+), 9 deletions(-)
+
+diff --git a/libgcc/config/alpha/linux-unwind.h b/libgcc/config/alpha/linux-unwind.h
+index 6c2f02891..c1fc84486 100644
+--- a/libgcc/config/alpha/linux-unwind.h
++++ b/libgcc/config/alpha/linux-unwind.h
+@@ -51,7 +51,7 @@ alpha_fallback_frame_state (struct _Unwind_Context *context,
+ {
+ struct rt_sigframe {
+ siginfo_t info;
+- struct ucontext uc;
++ ucontext_t uc;
+ } *rt_ = context->cfa;
+ sc = &rt_->uc.uc_mcontext;
+ }
+diff --git a/libgcc/config/bfin/linux-unwind.h b/libgcc/config/bfin/linux-unwind.h
+index 15bb2f12b..28d9f4207 100644
+--- a/libgcc/config/bfin/linux-unwind.h
++++ b/libgcc/config/bfin/linux-unwind.h
+@@ -52,7 +52,7 @@ bfin_fallback_frame_state (struct _Unwind_Context *context,
+ void *puc;
+ char retcode[8];
+ siginfo_t info;
+- struct ucontext uc;
++ ucontext_t uc;
+ } *rt_ = context->cfa;
+
+ /* The void * cast is necessary to avoid an aliasing warning.
+diff --git a/libgcc/config/i386/linux-unwind.h b/libgcc/config/i386/linux-unwind.h
+index cd9a9a1e2..4518c1ff9 100644
+--- a/libgcc/config/i386/linux-unwind.h
++++ b/libgcc/config/i386/linux-unwind.h
+@@ -53,7 +53,7 @@ x86_64_fallback_frame_state (struct _Unwind_Context *context,
+ if (*(unsigned char *)(pc+0) == 0x48
+ && *(unsigned long long *)(pc+1) == RT_SIGRETURN_SYSCALL)
+ {
+- struct ucontext *uc_ = context->cfa;
++ ucontext_t *uc_ = context->cfa;
+ /* The void * cast is necessary to avoid an aliasing warning.
+ The aliasing warning is correct, but should not be a problem
+ because it does not alias anything. */
+@@ -142,7 +142,7 @@ x86_fallback_frame_state (struct _Unwind_Context *context,
+ siginfo_t *pinfo;
+ void *puc;
+ siginfo_t info;
+- struct ucontext uc;
++ ucontext_t uc;
+ } *rt_ = context->cfa;
+ /* The void * cast is necessary to avoid an aliasing warning.
+ The aliasing warning is correct, but should not be a problem
+diff --git a/libgcc/config/m68k/linux-unwind.h b/libgcc/config/m68k/linux-unwind.h
+index 053c15558..d7bc1f2c0 100644
+--- a/libgcc/config/m68k/linux-unwind.h
++++ b/libgcc/config/m68k/linux-unwind.h
+@@ -33,7 +33,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ /* <sys/ucontext.h> is unfortunately broken right now. */
+ struct uw_ucontext {
+ unsigned long uc_flags;
+- struct ucontext *uc_link;
++ ucontext_t *uc_link;
+ stack_t uc_stack;
+ mcontext_t uc_mcontext;
+ unsigned long uc_filler[80];
+diff --git a/libgcc/config/pa/linux-unwind.h b/libgcc/config/pa/linux-unwind.h
+index 38b4eda7a..45ea66cf3 100644
+--- a/libgcc/config/pa/linux-unwind.h
++++ b/libgcc/config/pa/linux-unwind.h
+@@ -64,7 +64,7 @@ pa32_fallback_frame_state (struct _Unwind_Context *context,
+ struct sigcontext *sc;
+ struct rt_sigframe {
+ siginfo_t info;
+- struct ucontext uc;
++ ucontext_t uc;
+ } *frame;
+
+ /* rt_sigreturn trampoline:
+diff --git a/libgcc/config/sh/linux-unwind.h b/libgcc/config/sh/linux-unwind.h
+index 5a78e3172..eefad5175 100644
+--- a/libgcc/config/sh/linux-unwind.h
++++ b/libgcc/config/sh/linux-unwind.h
+@@ -181,7 +181,7 @@ sh_fallback_frame_state (struct _Unwind_Context *context,
+ {
+ struct rt_sigframe {
+ siginfo_t info;
+- struct ucontext uc;
++ ucontext_t uc;
+ } *rt_ = context->cfa;
+ /* The void * cast is necessary to avoid an aliasing warning.
+ The aliasing warning is correct, but should not be a problem
+diff --git a/libgcc/config/tilepro/linux-unwind.h b/libgcc/config/tilepro/linux-unwind.h
+index 27a6c4351..d2a15bb9f 100644
+--- a/libgcc/config/tilepro/linux-unwind.h
++++ b/libgcc/config/tilepro/linux-unwind.h
+@@ -62,7 +62,7 @@ tile_fallback_frame_state (struct _Unwind_Context *context,
+ struct rt_sigframe {
+ unsigned char save_area[C_ABI_SAVE_AREA_SIZE];
+ siginfo_t info;
+- struct ucontext uc;
++ ucontext_t uc;
+ } *rt_;
+
+ /* Return if this is not a signal handler. */
+diff --git a/libgcc/config/xtensa/linux-unwind.h b/libgcc/config/xtensa/linux-unwind.h
+index 245649728..b7b128cf0 100644
+--- a/libgcc/config/xtensa/linux-unwind.h
++++ b/libgcc/config/xtensa/linux-unwind.h
+@@ -63,7 +63,7 @@ xtensa_fallback_frame_state (struct _Unwind_Context *context,
+
+ struct rt_sigframe {
+ siginfo_t info;
+- struct ucontext uc;
++ ucontext_t uc;
+ } *rt_;
+
+ /* movi a2, __NR_rt_sigreturn; syscall */
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/various-fixes/0001-non-behavioral-changing-fix-in-gcc-cp-rtti.c.patch b/etc/patches/gcc-4.7.4/various-fixes/0001-non-behavioral-changing-fix-in-gcc-cp-rtti.c.patch
new file mode 100644
index 0000000..9d32ef4
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/various-fixes/0001-non-behavioral-changing-fix-in-gcc-cp-rtti.c.patch
@@ -0,0 +1,46 @@
+From 8dfe03984e5c8060b5baabd19478db9f89bc43d0 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Thu, 29 Jun 2023 15:47:17 +0200
+Subject: [PATCH 1/4] Non-behavioral changing fix in gcc/cp/rtti.c
+
+... to fix an infinite loop that occurs in the "cc1plus"
+binary, if it was compiled with TinyCC version 0.9.27. Upon
+closer inspection, the loop was infinitely executing the
+lines 814, 820, and 823 of the following snippet:
+
+---
+812: function(...) {
+813: while (true) {
+814: if (...)
+...
+820: else if (...)
+...
+822: else
+823: return ...;
+824: }
+---
+
+Presumably, TinyCC somehow generates instructions that are
+not able to exit the function from the return-statement
+inside the while loop. The solution is a non-behavioral
+changing fix: insert a break-statement in line 823 and
+thereby move the return-statement outside the while loop.
+---
+ gcc/cp/rtti.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c
+index 30383ed18..faf639115 100644
+--- a/gcc/cp/rtti.c
++++ b/gcc/cp/rtti.c
+@@ -820,6 +820,7 @@ target_incomplete_p (tree type)
+ else if (TREE_CODE (type) == POINTER_TYPE)
+ type = TREE_TYPE (type);
+ else
++ break;
+ return !COMPLETE_OR_VOID_TYPE_P (type);
+ }
+
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/various-fixes/0002-comment-out-M4-m4-not-needed-in-gmp-configure.patch b/etc/patches/gcc-4.7.4/various-fixes/0002-comment-out-M4-m4-not-needed-in-gmp-configure.patch
new file mode 100644
index 0000000..eccb90a
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/various-fixes/0002-comment-out-M4-m4-not-needed-in-gmp-configure.patch
@@ -0,0 +1,35 @@
+From 220a31382c25e511b30ef675711d9bcd057c1083 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Thu, 29 Jun 2023 15:47:27 +0200
+Subject: [PATCH 2/4] Comment out M4=m4-not-needed in gmp/configure
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Backport from GMP 5.0.2
+ Mercurial changeset IDs: d32fa7b198d3 and 2b1c397a9463
+
+Co-authored-by: Niels Möller <nisse@lysator.liu.se>
+Co-authored-by: Torbjorn Granlund <tege@gmplib.org>
+---
+ gmp/configure | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/gmp/configure b/gmp/configure
+index c72990c07..c5f247948 100755
+--- a/gmp/configure
++++ b/gmp/configure
+@@ -28982,8 +28982,8 @@ echo "${ECHO_T}$gmp_cv_m4_m4wrap_spurious" >&6
+ echo "define(<M4WRAP_SPURIOUS>,<$gmp_cv_m4_m4wrap_spurious>)" >> $gmp_tmpconfigm4
+
+
+-else
+- M4=m4-not-needed
++#else
++# M4=m4-not-needed
+ fi
+
+ # Only do the GMP_ASM checks if there's a .S or .asm wanting them.
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/various-fixes/0003-cfns-fix-mismatch-in-gnu_inline-attributes.patch b/etc/patches/gcc-4.7.4/various-fixes/0003-cfns-fix-mismatch-in-gnu_inline-attributes.patch
new file mode 100644
index 0000000..217ff88
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/various-fixes/0003-cfns-fix-mismatch-in-gnu_inline-attributes.patch
@@ -0,0 +1,62 @@
+From 45decf6322dedb510df1886da5b8419aecef52c5 Mon Sep 17 00:00:00 2001
+From: Mike Frysinger <vapier at gentoo dot org>
+Date: Thu, 29 Jun 2023 16:02:23 +0200
+Subject: [PATCH 3/4] cfns: fix mismatch in gnu_inline attributes
+
+Since the 3.0.3 release of gperf (made in May 2007), the generated func
+has had the gnu_inline attribute applied to it. The gcc source however
+has not been updated to include that which has lead to a mismatch.
+
+In practice, this hasn't been an issue for two reasons:
+(1) Before gcc-5, the default standard was (gnu) C89, and gcc does not
+warn or throw an error in this mode.
+(2) Starting with gcc-4.8, the compiler driver used to build gcc was
+changed to C++, and g++ does not warn or throw an error in this mode.
+
+This error does show up though when using gcc-5 to build gcc-4.7 or
+older as then the default is (gnu) C11 and the C compiler driver is
+used. That failure looks like:
+In file included from .../gcc-4.7.4/gcc/cp/except.c:990:0:
+cfns.gperf: At top level:
+cfns.gperf:101:1: error: 'gnu_inline' attribute present on 'libc_name_p'
+cfns.gperf:26:14: error: but not here
+
+Whether the compiler should always emit this error regardless of the
+active standard or compiler driver is debatable (I think it should be
+consistent -- either always do it or never do it).
+---
+ gcc/cp/cfns.gperf | 3 +++
+ gcc/cp/cfns.h | 3 +++
+ 2 files changed, 6 insertions(+)
+
+diff --git a/gcc/cp/cfns.gperf b/gcc/cp/cfns.gperf
+index ef1ed083d..ba0c487a6 100644
+--- a/gcc/cp/cfns.gperf
++++ b/gcc/cp/cfns.gperf
+@@ -22,6 +22,9 @@ __inline
+ static unsigned int hash (const char *, unsigned int);
+ #ifdef __GNUC__
+ __inline
++#ifdef __GNUC_STDC_INLINE__
++__attribute__ ((__gnu_inline__))
++#endif
+ #endif
+ const char * libc_name_p (const char *, unsigned int);
+ %}
+diff --git a/gcc/cp/cfns.h b/gcc/cp/cfns.h
+index 62cdfab93..2fb9b4632 100644
+--- a/gcc/cp/cfns.h
++++ b/gcc/cp/cfns.h
+@@ -53,6 +53,9 @@ __inline
+ static unsigned int hash (const char *, unsigned int);
+ #ifdef __GNUC__
+ __inline
++#ifdef __GNUC_STDC_INLINE__
++__attribute__ ((__gnu_inline__))
++#endif
+ #endif
+ const char * libc_name_p (const char *, unsigned int);
+ /* maximum key range = 391, duplicates = 0 */
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/various-fixes/0004-fix-gmp-configure-to-comply-with-newer-c-standards.patch b/etc/patches/gcc-4.7.4/various-fixes/0004-fix-gmp-configure-to-comply-with-newer-c-standards.patch
new file mode 100644
index 0000000..1360b06
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/various-fixes/0004-fix-gmp-configure-to-comply-with-newer-c-standards.patch
@@ -0,0 +1,234 @@
+From 7a642773c924589eeee2ca1be4615b35c12c6f5e Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Tue, 17 Oct 2023 14:59:32 +0200
+Subject: [PATCH 4/4] Fix GMP configure to comply with newer C standards
+
+---
+ configure | 68 +++++++++++++++++++++++--------------------------------
+ 1 file changed, 28 insertions(+), 40 deletions(-)
+
+diff --git a/gmp/configure b/gmp/configure
+index c72990c..c13bea9 100755
+--- a/gmp/configure
++++ b/gmp/configure
+@@ -7752,7 +7752,7 @@ cat >conftest.c <<EOF
+ int
+ main ()
+ {
+- exit(0);
++ return 0;
+ }
+ EOF
+ gmp_compile="$CC_FOR_BUILD conftest.c"
+@@ -7786,7 +7786,7 @@ cat >conftest.c <<EOF
+ int
+ main ()
+ {
+- exit(0);
++ return 0;
+ }
+ EOF
+ gmp_compile="$HOST_CC conftest.c"
+@@ -7821,7 +7821,7 @@ cat >conftest.c <<EOF
+ int
+ main ()
+ {
+- exit(0);
++ return 0;
+ }
+ EOF
+ gmp_compile="$i conftest.c"
+@@ -7904,7 +7904,7 @@ else
+ int
+ main ()
+ {
+- exit (0);
++ return 0;
+ }
+ EOF
+ for i in .exe ,ff8 ""; do
+@@ -7941,9 +7941,9 @@ if test "${gmp_cv_c_for_build_ansi+set}" = set; then
+ else
+ cat >conftest.c <<EOF
+ int
+-main (int argc, char *argv)
++main (int argc, char **argv)
+ {
+- exit(0);
++ return 0;
+ }
+ EOF
+ gmp_compile="$CC_FOR_BUILD conftest.c"
+@@ -7978,7 +7978,7 @@ else
+ int
+ main ()
+ {
+- exit(0);
++ return 0;
+ }
+ double d;
+ double
+@@ -9243,7 +9243,7 @@ main ()
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ exit(2);
+- exit (0);
++ return 0;
+ }
+ _ACEOF
+ rm -f conftest$ac_exeext
+@@ -24628,7 +24628,7 @@ main ()
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ exit(2);
+- exit (0);
++ return 0;
+ }
+ _ACEOF
+ rm -f conftest$ac_exeext
+@@ -27932,11 +27932,11 @@ check (va_alist)
+ ret = vsnprintf (buf, 4, fmt, ap);
+
+ if (strcmp (buf, "hel") != 0)
+- exit (1);
++ return 1;
+
+ /* allowed return values */
+ if (ret != -1 && ret != 3 && ret != 11)
+- exit (2);
++ return 2;
+
+ return 0;
+ }
+@@ -27945,7 +27945,7 @@ int
+ main ()
+ {
+ $i
+- exit (0);
++ return 0;
+ }
+
+ _ACEOF
+@@ -30741,25 +30741,22 @@ main ()
+
+ FILE *f = fopen ("conftest.val", "w");
+ if (! f)
+- exit (1);
++ return 1;
+ if (((long) (sizeof (unsigned short))) < 0)
+ {
+ long i = longval ();
+ if (i != ((long) (sizeof (unsigned short))))
+- exit (1);
++ return 1;
+ fprintf (f, "%ld\n", i);
+ }
+ else
+ {
+ unsigned long i = ulongval ();
+ if (i != ((long) (sizeof (unsigned short))))
+- exit (1);
++ return 1;
+ fprintf (f, "%lu\n", i);
+ }
+- exit (ferror (f) || fclose (f) != 0);
+-
+- ;
+- return 0;
++ return (ferror (f) || fclose (f) != 0);
+ }
+ _ACEOF
+ rm -f conftest$ac_exeext
+@@ -31155,25 +31152,22 @@ main ()
+
+ FILE *f = fopen ("conftest.val", "w");
+ if (! f)
+- exit (1);
++ return 1;
+ if (((long) (sizeof (unsigned))) < 0)
+ {
+ long i = longval ();
+ if (i != ((long) (sizeof (unsigned))))
+- exit (1);
++ return 1;
+ fprintf (f, "%ld\n", i);
+ }
+ else
+ {
+ unsigned long i = ulongval ();
+ if (i != ((long) (sizeof (unsigned))))
+- exit (1);
++ return 1;
+ fprintf (f, "%lu\n", i);
+ }
+- exit (ferror (f) || fclose (f) != 0);
+-
+- ;
+- return 0;
++ return (ferror (f) || fclose (f) != 0);
+ }
+ _ACEOF
+ rm -f conftest$ac_exeext
+@@ -31569,25 +31563,22 @@ main ()
+
+ FILE *f = fopen ("conftest.val", "w");
+ if (! f)
+- exit (1);
++ return 1;
+ if (((long) (sizeof (unsigned long))) < 0)
+ {
+ long i = longval ();
+ if (i != ((long) (sizeof (unsigned long))))
+- exit (1);
++ return 1;
+ fprintf (f, "%ld\n", i);
+ }
+ else
+ {
+ unsigned long i = ulongval ();
+ if (i != ((long) (sizeof (unsigned long))))
+- exit (1);
++ return 1;
+ fprintf (f, "%lu\n", i);
+ }
+- exit (ferror (f) || fclose (f) != 0);
+-
+- ;
+- return 0;
++ return (ferror (f) || fclose (f) != 0);
+ }
+ _ACEOF
+ rm -f conftest$ac_exeext
+@@ -32032,25 +32023,22 @@ main ()
+
+ FILE *f = fopen ("conftest.val", "w");
+ if (! f)
+- exit (1);
++ return 1;
+ if (((long) (sizeof (mp_limb_t))) < 0)
+ {
+ long i = longval ();
+ if (i != ((long) (sizeof (mp_limb_t))))
+- exit (1);
++ return 1;
+ fprintf (f, "%ld\n", i);
+ }
+ else
+ {
+ unsigned long i = ulongval ();
+ if (i != ((long) (sizeof (mp_limb_t))))
+- exit (1);
++ return 1;
+ fprintf (f, "%lu\n", i);
+ }
+- exit (ferror (f) || fclose (f) != 0);
+-
+- ;
+- return 0;
++ return (ferror (f) || fclose (f) != 0);
+ }
+ _ACEOF
+ rm -f conftest$ac_exeext
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/various-fixes/series b/etc/patches/gcc-4.7.4/various-fixes/series
new file mode 100644
index 0000000..50e3f37
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/various-fixes/series
@@ -0,0 +1,4 @@
+0001-non-behavioral-changing-fix-in-gcc-cp-rtti.c.patch
+0002-comment-out-M4-m4-not-needed-in-gmp-configure.patch
+0003-cfns-fix-mismatch-in-gnu_inline-attributes.patch
+0004-fix-gmp-configure-to-comply-with-newer-c-standards.patch
diff --git a/etc/patches/musl-cross-make-fe915821/fix-asound-patch.patch b/etc/patches/musl-cross-make-fe915821/fix-asound-patch.patch
new file mode 100644
index 0000000..a3bf90b
--- /dev/null
+++ b/etc/patches/musl-cross-make-fe915821/fix-asound-patch.patch
@@ -0,0 +1,167 @@
+From bb19399b4d940cb9b09e9872983e226a11174aef Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Mon, 26 Jun 2023 16:53:35 +0200
+Subject: [PATCH] Fix asound patch
+
+---
+ .../0001-asound-time64.diff | 42 +++++++++----------
+ 1 file changed, 21 insertions(+), 21 deletions(-)
+
+diff --git a/patches/linux-headers-4.19.88-1/0001-asound-time64.diff b/patches/linux-headers-4.19.88-1/0001-asound-time64.diff
+index 1a23259..76520a2 100644
+--- a/patches/linux-headers-4.19.88-1/0001-asound-time64.diff
++++ b/patches/linux-headers-4.19.88-1/0001-asound-time64.diff
+@@ -1,16 +1,16 @@
+ diff -ur a/generic/include/sound/asound.h b/generic/include/sound/asound.h
+---- a/generic/include/sound/asound.h 2019-10-15 12:26:39.634141383 -0400
+-+++ b/generic/include/sound/asound.h 2020-01-30 21:43:56.477450321 -0500
+-@@ -35,6 +35,8 @@
+- #include <time.h>
+- #endif
++--- a/generic/include/sound/asound.h 2021-06-28 22:04:41.000000000 +0200
+++++ b/generic/include/sound/asound.h 2023-06-26 16:51:09.416627212 +0200
++@@ -32,6 +32,8 @@
++
++ #include <stdlib.h>
+
+ +#include <asm/byteorder.h>
+ +
+ /*
+ * protocol version
+ */
+-@@ -154,7 +156,7 @@
++@@ -151,7 +153,7 @@
+ * *
+ *****************************************************************************/
+
+@@ -19,7 +19,7 @@ diff -ur a/generic/include/sound/asound.h b/generic/include/sound/asound.h
+
+ typedef unsigned long snd_pcm_uframes_t;
+ typedef signed long snd_pcm_sframes_t;
+-@@ -301,7 +303,9 @@
++@@ -298,7 +300,9 @@
+ #define SNDRV_PCM_INFO_DRAIN_TRIGGER 0x40000000 /* internal kernel flag - trigger in drain */
+ #define SNDRV_PCM_INFO_FIFO_IN_FRAMES 0x80000000 /* internal kernel flag - FIFO size is in frames */
+
+@@ -29,8 +29,8 @@ diff -ur a/generic/include/sound/asound.h b/generic/include/sound/asound.h
+ +#endif
+
+ typedef int __bitwise snd_pcm_state_t;
+- #define SNDRV_PCM_STATE_OPEN ((__force snd_pcm_state_t) 0) /* stream is open */
+-@@ -317,8 +321,17 @@
++ #define SNDRV_PCM_STATE_OPEN ((snd_pcm_state_t) 0) /* stream is open */
++@@ -314,8 +318,17 @@
+
+ enum {
+ SNDRV_PCM_MMAP_OFFSET_DATA = 0x00000000,
+@@ -50,7 +50,7 @@ diff -ur a/generic/include/sound/asound.h b/generic/include/sound/asound.h
+ };
+
+ union snd_pcm_sync_id {
+-@@ -456,8 +469,13 @@
++@@ -453,8 +466,13 @@
+ SNDRV_PCM_AUDIO_TSTAMP_TYPE_LAST = SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_SYNCHRONIZED
+ };
+
+@@ -64,7 +64,7 @@ diff -ur a/generic/include/sound/asound.h b/generic/include/sound/asound.h
+ struct timespec trigger_tstamp; /* time when stream was started/stopped/paused */
+ struct timespec tstamp; /* reference timestamp */
+ snd_pcm_uframes_t appl_ptr; /* appl ptr */
+-@@ -473,17 +491,48 @@
++@@ -470,17 +488,48 @@
+ __u32 audio_tstamp_accuracy; /* in ns units, only valid if indicated in audio_tstamp_data */
+ unsigned char reserved[52-2*sizeof(struct timespec)]; /* must be filled with zero */
+ };
+@@ -117,7 +117,7 @@ diff -ur a/generic/include/sound/asound.h b/generic/include/sound/asound.h
+ snd_pcm_uframes_t appl_ptr; /* RW: appl ptr (0...boundary-1) */
+ snd_pcm_uframes_t avail_min; /* RW: min available frames for wakeup */
+ };
+-@@ -492,14 +541,59 @@
++@@ -489,14 +538,59 @@
+ #define SNDRV_PCM_SYNC_PTR_APPL (1<<1) /* get appl_ptr from driver (r/w op) */
+ #define SNDRV_PCM_SYNC_PTR_AVAIL_MIN (1<<2) /* get avail_min from driver */
+
+@@ -180,7 +180,7 @@ diff -ur a/generic/include/sound/asound.h b/generic/include/sound/asound.h
+ unsigned char reserved[64];
+ } c;
+ };
+-@@ -584,6 +678,8 @@
++@@ -581,6 +675,8 @@
+ #define SNDRV_PCM_IOCTL_STATUS _IOR('A', 0x20, struct snd_pcm_status)
+ #define SNDRV_PCM_IOCTL_DELAY _IOR('A', 0x21, snd_pcm_sframes_t)
+ #define SNDRV_PCM_IOCTL_HWSYNC _IO('A', 0x22)
+@@ -189,7 +189,7 @@ diff -ur a/generic/include/sound/asound.h b/generic/include/sound/asound.h
+ #define SNDRV_PCM_IOCTL_SYNC_PTR _IOWR('A', 0x23, struct snd_pcm_sync_ptr)
+ #define SNDRV_PCM_IOCTL_STATUS_EXT _IOWR('A', 0x24, struct snd_pcm_status)
+ #define SNDRV_PCM_IOCTL_CHANNEL_INFO _IOR('A', 0x32, struct snd_pcm_channel_info)
+-@@ -614,7 +710,7 @@
++@@ -611,7 +707,7 @@
+ * Raw MIDI section - /dev/snd/midi??
+ */
+
+@@ -198,7 +198,7 @@ diff -ur a/generic/include/sound/asound.h b/generic/include/sound/asound.h
+
+ enum {
+ SNDRV_RAWMIDI_STREAM_OUTPUT = 0,
+-@@ -648,13 +744,16 @@
++@@ -645,13 +741,16 @@
+ unsigned char reserved[16]; /* reserved for future use */
+ };
+
+@@ -215,7 +215,7 @@ diff -ur a/generic/include/sound/asound.h b/generic/include/sound/asound.h
+
+ #define SNDRV_RAWMIDI_IOCTL_PVERSION _IOR('W', 0x00, int)
+ #define SNDRV_RAWMIDI_IOCTL_INFO _IOR('W', 0x01, struct snd_rawmidi_info)
+-@@ -667,7 +766,7 @@
++@@ -664,7 +763,7 @@
+ * Timer section - /dev/snd/timer
+ */
+
+@@ -224,7 +224,7 @@ diff -ur a/generic/include/sound/asound.h b/generic/include/sound/asound.h
+
+ enum {
+ SNDRV_TIMER_CLASS_NONE = -1,
+-@@ -761,6 +860,7 @@
++@@ -758,6 +857,7 @@
+ unsigned char reserved[60]; /* reserved */
+ };
+
+@@ -232,7 +232,7 @@ diff -ur a/generic/include/sound/asound.h b/generic/include/sound/asound.h
+ struct snd_timer_status {
+ struct timespec tstamp; /* Timestamp - last update */
+ unsigned int resolution; /* current period resolution in ns */
+-@@ -769,10 +869,11 @@
++@@ -766,10 +866,11 @@
+ unsigned int queue; /* used queue size */
+ unsigned char reserved[64]; /* reserved */
+ };
+@@ -245,7 +245,7 @@ diff -ur a/generic/include/sound/asound.h b/generic/include/sound/asound.h
+ #define SNDRV_TIMER_IOCTL_GINFO _IOWR('T', 0x03, struct snd_timer_ginfo)
+ #define SNDRV_TIMER_IOCTL_GPARAMS _IOW('T', 0x04, struct snd_timer_gparams)
+ #define SNDRV_TIMER_IOCTL_GSTATUS _IOWR('T', 0x05, struct snd_timer_gstatus)
+-@@ -785,6 +886,15 @@
++@@ -782,6 +883,15 @@
+ #define SNDRV_TIMER_IOCTL_STOP _IO('T', 0xa1)
+ #define SNDRV_TIMER_IOCTL_CONTINUE _IO('T', 0xa2)
+ #define SNDRV_TIMER_IOCTL_PAUSE _IO('T', 0xa3)
+@@ -261,7 +261,7 @@ diff -ur a/generic/include/sound/asound.h b/generic/include/sound/asound.h
+
+ struct snd_timer_read {
+ unsigned int resolution;
+-@@ -810,11 +920,15 @@
++@@ -807,11 +917,15 @@
+ SNDRV_TIMER_EVENT_MRESUME = SNDRV_TIMER_EVENT_RESUME + 10,
+ };
+
+@@ -277,7 +277,7 @@ diff -ur a/generic/include/sound/asound.h b/generic/include/sound/asound.h
+
+ /****************************************************************************
+ * *
+-@@ -955,8 +1069,7 @@
++@@ -952,8 +1066,7 @@
+ } bytes;
+ struct snd_aes_iec958 iec958;
+ } value; /* RO */
+--
+2.30.2
+
diff --git a/etc/patches/musl-cross-make-fe915821/patches/binutils-latest/0001-j2.diff b/etc/patches/musl-cross-make-fe915821/patches/binutils-latest/0001-j2.diff
new file mode 100644
index 0000000..f4ff1f2
--- /dev/null
+++ b/etc/patches/musl-cross-make-fe915821/patches/binutils-latest/0001-j2.diff
@@ -0,0 +1,585 @@
+diff --git a/bfd/archures.c b/bfd/archures.c
+index ff1ee0f9..5dc5fcb1 100644
+--- a/bfd/archures.c
++++ b/bfd/archures.c
+@@ -287,6 +287,8 @@ DESCRIPTION
+ .#define bfd_mach_sh2a_nofpu_or_sh3_nommu 0x2a2
+ .#define bfd_mach_sh2a_or_sh4 0x2a3
+ .#define bfd_mach_sh2a_or_sh3e 0x2a4
++.#define bfd_mach_sh2a_nofpu_or_sh3_nommu_or_shj2_nofpu 0x2a5
++.#define bfd_mach_shj2 0x2c
+ .#define bfd_mach_sh2e 0x2e
+ .#define bfd_mach_sh3 0x30
+ .#define bfd_mach_sh3_nommu 0x31
+diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
+index eddfb31b..2088eca4 100644
+--- a/bfd/bfd-in2.h
++++ b/bfd/bfd-in2.h
+@@ -1589,6 +1589,8 @@ enum bfd_architecture
+ #define bfd_mach_sh2a_nofpu_or_sh3_nommu 0x2a2
+ #define bfd_mach_sh2a_or_sh4 0x2a3
+ #define bfd_mach_sh2a_or_sh3e 0x2a4
++#define bfd_mach_sh2a_nofpu_or_sh3_nommu_or_shj2_nofpu 0x2a5
++#define bfd_mach_shj2 0x2c
+ #define bfd_mach_sh2e 0x2e
+ #define bfd_mach_sh3 0x30
+ #define bfd_mach_sh3_nommu 0x31
+diff --git a/bfd/cpu-sh.c b/bfd/cpu-sh.c
+index afea21a8..2c2c8b87 100644
+--- a/bfd/cpu-sh.c
++++ b/bfd/cpu-sh.c
+@@ -99,6 +99,8 @@ static struct { unsigned long bfd_mach, arch, arch_up; } bfd_to_arch_table[] =
+ { bfd_mach_sh4_nofpu, arch_sh4_nofpu, arch_sh4_nofpu_up },
+ { bfd_mach_sh4_nommu_nofpu, arch_sh4_nommu_nofpu, arch_sh4_nommu_nofpu_up },
+ { bfd_mach_sh4a_nofpu, arch_sh4a_nofpu, arch_sh4a_nofpu_up },
++ { bfd_mach_shj2, arch_shj2, arch_shj2_up },
++ { bfd_mach_sh2a_nofpu_or_sh3_nommu_or_shj2_nofpu, arch_sh2a_nofpu_or_sh3_nommu_or_shj2_nofpu, arch_sh2a_nofpu_or_sh3_nommu_or_shj2_nofpu_up },
+ { 0, 0, 0 } /* Terminator. */
+ };
+
+diff --git a/binutils/readelf.c b/binutils/readelf.c
+index 3da3db15..94254a6d 100644
+--- a/binutils/readelf.c
++++ b/binutils/readelf.c
+@@ -4163,6 +4163,8 @@ get_machine_flags (Filedata * filedata, unsigned e_flags, unsigned e_machine)
+ case EF_SH2A_SH3_NOFPU: strcat (buf, ", sh2a-nofpu-or-sh3-nommu"); break;
+ case EF_SH2A_SH4: strcat (buf, ", sh2a-or-sh4"); break;
+ case EF_SH2A_SH3E: strcat (buf, ", sh2a-or-sh3e"); break;
++ case EF_SHJ2: strcat (buf, ", j2"); break;
++ case EF_SH2A_SH3_SHJ2: strcat (buf, ", sh2a-nofpu-or-sh3-nommu-or-shj2 -nofpu"); break;
+ default: strcat (buf, _(", unknown ISA")); break;
+ }
+
+diff --git a/gas/config/tc-sh.c b/gas/config/tc-sh.c
+index bc0380a4..7c1970af 100644
+--- a/gas/config/tc-sh.c
++++ b/gas/config/tc-sh.c
+@@ -1251,6 +1251,8 @@ get_operands (sh_opcode_info *info, char *args, sh_operand_info *operand)
+ ptr++;
+ }
+ get_operand (&ptr, operand + 2);
++ if (strcmp (info->name,"cas") == 0)
++ operand[2].type = A_IND_0;
+ }
+ else
+ {
+@@ -1790,7 +1792,10 @@ get_specific (sh_opcode_info *opcode, sh_operand_info *operands)
+ goto fail;
+ reg_m = 4;
+ break;
+-
++ case A_IND_0:
++ if (user->reg != 0)
++ goto fail;
++ break;
+ default:
+ printf (_("unhandled %d\n"), arg);
+ goto fail;
+diff --git a/gas/testsuite/gas/sh/arch/sh2a-nofpu-or-sh3-nommu.s b/gas/testsuite/gas/sh/arch/sh2a-nofpu-or-sh3-nommu.s
+index cc298891..a3e18b55 100644
+--- a/gas/testsuite/gas/sh/arch/sh2a-nofpu-or-sh3-nommu.s
++++ b/gas/testsuite/gas/sh/arch/sh2a-nofpu-or-sh3-nommu.s
+@@ -12,8 +12,6 @@
+ sh2a_nofpu_or_sh3_nommu:
+ ! Instructions introduced into sh2a-nofpu-or-sh3-nommu
+ pref @r4 ;!/* 0000nnnn10000011 pref @<REG_N> */{"pref",{A_IND_N},{HEX_0,REG_N,HEX_8,HEX_3}, arch_sh2a_nofpu_or_sh3_nommu_up}
+- shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_up}
+- shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_up}
+
+ ! Instructions inherited from ancestors: sh sh2
+ add #4,r4 ;!/* 0111nnnni8*1.... add #<imm>,<REG_N> */{"add",{A_IMM,A_REG_N},{HEX_7,REG_N,IMM0_8}, arch_sh_up}
+diff --git a/gas/testsuite/gas/sh/arch/sh2a-nofpu-or-sh4-nommu-nofpu.s b/gas/testsuite/gas/sh/arch/sh2a-nofpu-or-sh4-nommu-nofpu.s
+index c7028456..812aa76e 100644
+--- a/gas/testsuite/gas/sh/arch/sh2a-nofpu-or-sh4-nommu-nofpu.s
++++ b/gas/testsuite/gas/sh/arch/sh2a-nofpu-or-sh4-nommu-nofpu.s
+@@ -12,7 +12,7 @@
+ sh2a_nofpu_or_sh4_nommu_nofpu:
+ ! Instructions introduced into sh2a-nofpu-or-sh4-nommu-nofpu
+
+-! Instructions inherited from ancestors: sh sh2 sh2a-nofpu-or-sh3-nommu
++! Instructions inherited from ancestors: sh sh2 sh2a-nofpu-or-sh3-nommu sh2a-nofpu-or-sh3-nommu-or-sh2j-nofpu
+ add #4,r4 ;!/* 0111nnnni8*1.... add #<imm>,<REG_N> */{"add",{A_IMM,A_REG_N},{HEX_7,REG_N,IMM0_8}, arch_sh_up}
+ add r5,r4 ;!/* 0011nnnnmmmm1100 add <REG_M>,<REG_N> */{"add",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_C}, arch_sh_up}
+ addc r5,r4 ;!/* 0011nnnnmmmm1110 addc <REG_M>,<REG_N>*/{"addc",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_E}, arch_sh_up}
+@@ -119,8 +119,8 @@ sh2a_nofpu_or_sh4_nommu_nofpu:
+ rte ;!/* 0000000000101011 rte */{"rte",{0},{HEX_0,HEX_0,HEX_2,HEX_B}, arch_sh_up}
+ rts ;!/* 0000000000001011 rts */{"rts",{0},{HEX_0,HEX_0,HEX_0,HEX_B}, arch_sh_up}
+ sett ;!/* 0000000000011000 sett */{"sett",{0},{HEX_0,HEX_0,HEX_1,HEX_8}, arch_sh_up}
+- shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_up}
+- shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_up}
++ shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
++ shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
+ shal r4 ;!/* 0100nnnn00100000 shal <REG_N> */{"shal",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_0}, arch_sh_up}
+ shar r4 ;!/* 0100nnnn00100001 shar <REG_N> */{"shar",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_1}, arch_sh_up}
+ shll r4 ;!/* 0100nnnn00000000 shll <REG_N> */{"shll",{A_REG_N},{HEX_4,REG_N,HEX_0,HEX_0}, arch_sh_up}
+diff --git a/gas/testsuite/gas/sh/arch/sh2a-nofpu.s b/gas/testsuite/gas/sh/arch/sh2a-nofpu.s
+index 6f4a17e9..5b386431 100644
+--- a/gas/testsuite/gas/sh/arch/sh2a-nofpu.s
++++ b/gas/testsuite/gas/sh/arch/sh2a-nofpu.s
+@@ -64,7 +64,7 @@ sh2a_nofpu:
+ movu.b @(2048,r5),r4 ;!/* 0011nnnnmmmm0001 1000dddddddddddd movu.b @(<DISP12>,<REG_M>),<REG_N> */ {"movu.b",{A_DISP_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_1,HEX_8,DISP0_12}, arch_sh2a_nofpu_up | arch_op32}
+ movu.w @(2048,r5),r4 ;!/* 0011nnnnmmmm0001 1001dddddddddddd movu.w @(<DISP12>,<REG_M>),<REG_N> */ {"movu.w",{A_DISP_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_1,HEX_9,DISP0_12BY2}, arch_sh2a_nofpu_up | arch_op32}
+
+-! Instructions inherited from ancestors: sh sh2 sh2a-nofpu-or-sh3-nommu sh2a-nofpu-or-sh4-nommu-nofpu
++! Instructions inherited from ancestors: sh sh2 sh2a-nofpu-or-sh3-nommu sh2a-nofpu-or-sh3-nommu-or-sh2j-nofpu sh2a-nofpu-or-sh4-nommu-nofpu
+ add #4,r4 ;!/* 0111nnnni8*1.... add #<imm>,<REG_N> */{"add",{A_IMM,A_REG_N},{HEX_7,REG_N,IMM0_8}, arch_sh_up}
+ add r5,r4 ;!/* 0011nnnnmmmm1100 add <REG_M>,<REG_N> */{"add",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_C}, arch_sh_up}
+ addc r5,r4 ;!/* 0011nnnnmmmm1110 addc <REG_M>,<REG_N>*/{"addc",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_E}, arch_sh_up}
+@@ -171,8 +171,8 @@ sh2a_nofpu:
+ rte ;!/* 0000000000101011 rte */{"rte",{0},{HEX_0,HEX_0,HEX_2,HEX_B}, arch_sh_up}
+ rts ;!/* 0000000000001011 rts */{"rts",{0},{HEX_0,HEX_0,HEX_0,HEX_B}, arch_sh_up}
+ sett ;!/* 0000000000011000 sett */{"sett",{0},{HEX_0,HEX_0,HEX_1,HEX_8}, arch_sh_up}
+- shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_up}
+- shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_up}
++ shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
++ shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
+ shal r4 ;!/* 0100nnnn00100000 shal <REG_N> */{"shal",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_0}, arch_sh_up}
+ shar r4 ;!/* 0100nnnn00100001 shar <REG_N> */{"shar",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_1}, arch_sh_up}
+ shll r4 ;!/* 0100nnnn00000000 shll <REG_N> */{"shll",{A_REG_N},{HEX_4,REG_N,HEX_0,HEX_0}, arch_sh_up}
+diff --git a/gas/testsuite/gas/sh/arch/sh2a-or-sh3e.s b/gas/testsuite/gas/sh/arch/sh2a-or-sh3e.s
+index 25c8ae14..69d3536a 100644
+--- a/gas/testsuite/gas/sh/arch/sh2a-or-sh3e.s
++++ b/gas/testsuite/gas/sh/arch/sh2a-or-sh3e.s
+@@ -13,7 +13,7 @@ sh2a_or_sh3e:
+ ! Instructions introduced into sh2a-or-sh3e
+ fsqrt fr1 ;!/* 1111nnnn01101101 fsqrt <F_REG_N> */{"fsqrt",{F_REG_N},{HEX_F,REG_N,HEX_6,HEX_D}, arch_sh2a_or_sh3e_up}
+
+-! Instructions inherited from ancestors: sh sh2 sh2a-nofpu-or-sh3-nommu sh2e
++! Instructions inherited from ancestors: sh sh2 sh2a-nofpu-or-sh3-nommu sh2a-nofpu-or-sh3-nommu-or-sh2j-nofpu sh2e
+ add #4,r4 ;!/* 0111nnnni8*1.... add #<imm>,<REG_N> */{"add",{A_IMM,A_REG_N},{HEX_7,REG_N,IMM0_8}, arch_sh_up}
+ add r5,r4 ;!/* 0011nnnnmmmm1100 add <REG_M>,<REG_N> */{"add",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_C}, arch_sh_up}
+ addc r5,r4 ;!/* 0011nnnnmmmm1110 addc <REG_M>,<REG_N>*/{"addc",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_E}, arch_sh_up}
+@@ -124,8 +124,8 @@ sh2a_or_sh3e:
+ rte ;!/* 0000000000101011 rte */{"rte",{0},{HEX_0,HEX_0,HEX_2,HEX_B}, arch_sh_up}
+ rts ;!/* 0000000000001011 rts */{"rts",{0},{HEX_0,HEX_0,HEX_0,HEX_B}, arch_sh_up}
+ sett ;!/* 0000000000011000 sett */{"sett",{0},{HEX_0,HEX_0,HEX_1,HEX_8}, arch_sh_up}
+- shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_up}
+- shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_up}
++ shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
++ shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
+ shal r4 ;!/* 0100nnnn00100000 shal <REG_N> */{"shal",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_0}, arch_sh_up}
+ shar r4 ;!/* 0100nnnn00100001 shar <REG_N> */{"shar",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_1}, arch_sh_up}
+ shll r4 ;!/* 0100nnnn00000000 shll <REG_N> */{"shll",{A_REG_N},{HEX_4,REG_N,HEX_0,HEX_0}, arch_sh_up}
+diff --git a/gas/testsuite/gas/sh/arch/sh2a-or-sh4.s b/gas/testsuite/gas/sh/arch/sh2a-or-sh4.s
+index d3300ca7..c6972689 100644
+--- a/gas/testsuite/gas/sh/arch/sh2a-or-sh4.s
++++ b/gas/testsuite/gas/sh/arch/sh2a-or-sh4.s
+@@ -39,7 +39,7 @@ sh2a_or_sh4:
+ fsub dr4,dr2 ;!/* 1111nnn0mmm00001 fsub <D_REG_M>,<D_REG_N>*/{"fsub",{D_REG_M,D_REG_N},{HEX_F,REG_N,REG_M,HEX_1}, arch_sh2a_or_sh4_up}
+ ftrc dr2,FPUL ;!/* 1111nnnn00111101 ftrc <D_REG_N>,FPUL*/{"ftrc",{D_REG_N,FPUL_M},{HEX_F,REG_N,HEX_3,HEX_D}, arch_sh2a_or_sh4_up}
+
+-! Instructions inherited from ancestors: sh sh2 sh2a-nofpu-or-sh3-nommu sh2a-nofpu-or-sh4-nommu-nofpu sh2a-or-sh3e sh2e
++! Instructions inherited from ancestors: sh sh2 sh2a-nofpu-or-sh3-nommu sh2a-nofpu-or-sh3-nommu-or-sh2j-nofpu sh2a-nofpu-or-sh4-nommu-nofpu sh2a-or-sh3e sh2e
+ add #4,r4 ;!/* 0111nnnni8*1.... add #<imm>,<REG_N> */{"add",{A_IMM,A_REG_N},{HEX_7,REG_N,IMM0_8}, arch_sh_up}
+ add r5,r4 ;!/* 0011nnnnmmmm1100 add <REG_M>,<REG_N> */{"add",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_C}, arch_sh_up}
+ addc r5,r4 ;!/* 0011nnnnmmmm1110 addc <REG_M>,<REG_N>*/{"addc",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_E}, arch_sh_up}
+@@ -150,8 +150,8 @@ sh2a_or_sh4:
+ rte ;!/* 0000000000101011 rte */{"rte",{0},{HEX_0,HEX_0,HEX_2,HEX_B}, arch_sh_up}
+ rts ;!/* 0000000000001011 rts */{"rts",{0},{HEX_0,HEX_0,HEX_0,HEX_B}, arch_sh_up}
+ sett ;!/* 0000000000011000 sett */{"sett",{0},{HEX_0,HEX_0,HEX_1,HEX_8}, arch_sh_up}
+- shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_up}
+- shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_up}
++ shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
++ shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
+ shal r4 ;!/* 0100nnnn00100000 shal <REG_N> */{"shal",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_0}, arch_sh_up}
+ shar r4 ;!/* 0100nnnn00100001 shar <REG_N> */{"shar",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_1}, arch_sh_up}
+ shll r4 ;!/* 0100nnnn00000000 shll <REG_N> */{"shll",{A_REG_N},{HEX_4,REG_N,HEX_0,HEX_0}, arch_sh_up}
+diff --git a/gas/testsuite/gas/sh/arch/sh2a.s b/gas/testsuite/gas/sh/arch/sh2a.s
+index 370dbd47..0d9f3b0d 100644
+--- a/gas/testsuite/gas/sh/arch/sh2a.s
++++ b/gas/testsuite/gas/sh/arch/sh2a.s
+@@ -16,7 +16,7 @@ sh2a:
+ fmov.s fr2,@(2048,r4) ;!/* 0011nnnnmmmm0001 0011dddddddddddd fmov.s <F_REG_M>,@(<DISP12>,<REG_N>) */ {"fmov.s",{F_REG_M,A_DISP_REG_N},{HEX_3,REG_N,REG_M,HEX_1,HEX_3,DISP1_12BY4}, arch_sh2a_up | arch_op32}
+ fmov.s @(2048,r5),fr1 ;!/* 0011nnnnmmmm0001 0111dddddddddddd fmov.s @(<DISP12>,<REG_M>),<F_REG_N> */ {"fmov.s",{A_DISP_REG_M,F_REG_N},{HEX_3,REG_N,REG_M,HEX_1,HEX_7,DISP0_12BY4}, arch_sh2a_up | arch_op32}
+
+-! Instructions inherited from ancestors: sh sh2 sh2a-nofpu sh2a-nofpu-or-sh3-nommu sh2a-nofpu-or-sh4-nommu-nofpu sh2a-or-sh3e sh2a-or-sh4 sh2e
++! Instructions inherited from ancestors: sh sh2 sh2a-nofpu sh2a-nofpu-or-sh3-nommu sh2a-nofpu-or-sh3-nommu-or-sh2j-nofpu sh2a-nofpu-or-sh4-nommu-nofpu sh2a-or-sh3e sh2a-or-sh4 sh2e
+ add #4,r4 ;!/* 0111nnnni8*1.... add #<imm>,<REG_N> */{"add",{A_IMM,A_REG_N},{HEX_7,REG_N,IMM0_8}, arch_sh_up}
+ add r5,r4 ;!/* 0011nnnnmmmm1100 add <REG_M>,<REG_N> */{"add",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_C}, arch_sh_up}
+ addc r5,r4 ;!/* 0011nnnnmmmm1110 addc <REG_M>,<REG_N>*/{"addc",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_E}, arch_sh_up}
+@@ -140,8 +140,8 @@ sh2a:
+ rte ;!/* 0000000000101011 rte */{"rte",{0},{HEX_0,HEX_0,HEX_2,HEX_B}, arch_sh_up}
+ rts ;!/* 0000000000001011 rts */{"rts",{0},{HEX_0,HEX_0,HEX_0,HEX_B}, arch_sh_up}
+ sett ;!/* 0000000000011000 sett */{"sett",{0},{HEX_0,HEX_0,HEX_1,HEX_8}, arch_sh_up}
+- shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_up}
+- shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_up}
++ shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
++ shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
+ shal r4 ;!/* 0100nnnn00100000 shal <REG_N> */{"shal",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_0}, arch_sh_up}
+ shar r4 ;!/* 0100nnnn00100001 shar <REG_N> */{"shar",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_1}, arch_sh_up}
+ shll r4 ;!/* 0100nnnn00000000 shll <REG_N> */{"shll",{A_REG_N},{HEX_4,REG_N,HEX_0,HEX_0}, arch_sh_up}
+diff --git a/gas/testsuite/gas/sh/arch/sh3-dsp.s b/gas/testsuite/gas/sh/arch/sh3-dsp.s
+index acc26be3..cfd4dfee 100644
+--- a/gas/testsuite/gas/sh/arch/sh3-dsp.s
++++ b/gas/testsuite/gas/sh/arch/sh3-dsp.s
+@@ -12,7 +12,7 @@
+ sh3_dsp:
+ ! Instructions introduced into sh3-dsp
+
+-! Instructions inherited from ancestors: sh sh-dsp sh2 sh2a-nofpu-or-sh3-nommu sh3 sh3-nommu
++! Instructions inherited from ancestors: sh sh-dsp sh2 sh2a-nofpu-or-sh3-nommu sh2a-nofpu-or-sh3-nommu-or-sh2j-nofpu sh3 sh3-nommu
+ add #4,r4 ;!/* 0111nnnni8*1.... add #<imm>,<REG_N> */{"add",{A_IMM,A_REG_N},{HEX_7,REG_N,IMM0_8}, arch_sh_up}
+ add r5,r4 ;!/* 0011nnnnmmmm1100 add <REG_M>,<REG_N> */{"add",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_C}, arch_sh_up}
+ addc r5,r4 ;!/* 0011nnnnmmmm1110 addc <REG_M>,<REG_N>*/{"addc",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_E}, arch_sh_up}
+@@ -152,8 +152,8 @@ sh3_dsp:
+ setrc #4 ;!/* 10000010i8*1.... setrc #<imm> */{"setrc",{A_IMM},{HEX_8,HEX_2,IMM0_8}, arch_sh_dsp_up}
+ repeat 10 20 r4 ;!/* repeat start end <REG_N> */{"repeat",{A_DISP_PC,A_DISP_PC,A_REG_N},{REPEAT,REG_N,HEX_1,HEX_4}, arch_sh_dsp_up}
+ repeat 10 20 #4 ;!/* repeat start end #<imm> */{"repeat",{A_DISP_PC,A_DISP_PC,A_IMM},{REPEAT,HEX_2,IMM0_8,HEX_8}, arch_sh_dsp_up}
+- shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_up}
+- shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_up}
++ shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
++ shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
+ shal r4 ;!/* 0100nnnn00100000 shal <REG_N> */{"shal",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_0}, arch_sh_up}
+ shar r4 ;!/* 0100nnnn00100001 shar <REG_N> */{"shar",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_1}, arch_sh_up}
+ shll r4 ;!/* 0100nnnn00000000 shll <REG_N> */{"shll",{A_REG_N},{HEX_4,REG_N,HEX_0,HEX_0}, arch_sh_up}
+diff --git a/gas/testsuite/gas/sh/arch/sh3-nommu.s b/gas/testsuite/gas/sh/arch/sh3-nommu.s
+index 3e8ff027..dacaae13 100644
+--- a/gas/testsuite/gas/sh/arch/sh3-nommu.s
++++ b/gas/testsuite/gas/sh/arch/sh3-nommu.s
+@@ -26,7 +26,7 @@ sh3_nommu:
+ stc.l SPC,@-r4 ;!/* 0100nnnn01000011 stc.l SPC,@-<REG_N> */{"stc.l",{A_SPC,A_DEC_N},{HEX_4,REG_N,HEX_4,HEX_3}, arch_sh3_nommu_up}
+ stc.l r1_bank,@-r4 ;!/* 0100nnnn1xxx0011 stc.l Rn_BANK,@-<REG_N> */{"stc.l",{A_REG_B,A_DEC_N},{HEX_4,REG_N,REG_B,HEX_3}, arch_sh3_nommu_up}
+
+-! Instructions inherited from ancestors: sh sh2 sh2a-nofpu-or-sh3-nommu
++! Instructions inherited from ancestors: sh sh2 sh2a-nofpu-or-sh3-nommu sh2a-nofpu-or-sh3-nommu-or-sh2j-nofpu
+ add #4,r4 ;!/* 0111nnnni8*1.... add #<imm>,<REG_N> */{"add",{A_IMM,A_REG_N},{HEX_7,REG_N,IMM0_8}, arch_sh_up}
+ add r5,r4 ;!/* 0011nnnnmmmm1100 add <REG_M>,<REG_N> */{"add",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_C}, arch_sh_up}
+ addc r5,r4 ;!/* 0011nnnnmmmm1110 addc <REG_M>,<REG_N>*/{"addc",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_E}, arch_sh_up}
+@@ -133,8 +133,8 @@ sh3_nommu:
+ rte ;!/* 0000000000101011 rte */{"rte",{0},{HEX_0,HEX_0,HEX_2,HEX_B}, arch_sh_up}
+ rts ;!/* 0000000000001011 rts */{"rts",{0},{HEX_0,HEX_0,HEX_0,HEX_B}, arch_sh_up}
+ sett ;!/* 0000000000011000 sett */{"sett",{0},{HEX_0,HEX_0,HEX_1,HEX_8}, arch_sh_up}
+- shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_up}
+- shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_up}
++ shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
++ shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
+ shal r4 ;!/* 0100nnnn00100000 shal <REG_N> */{"shal",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_0}, arch_sh_up}
+ shar r4 ;!/* 0100nnnn00100001 shar <REG_N> */{"shar",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_1}, arch_sh_up}
+ shll r4 ;!/* 0100nnnn00000000 shll <REG_N> */{"shll",{A_REG_N},{HEX_4,REG_N,HEX_0,HEX_0}, arch_sh_up}
+diff --git a/gas/testsuite/gas/sh/arch/sh3.s b/gas/testsuite/gas/sh/arch/sh3.s
+index 97ab9390..aa70fc33 100644
+--- a/gas/testsuite/gas/sh/arch/sh3.s
++++ b/gas/testsuite/gas/sh/arch/sh3.s
+@@ -13,7 +13,7 @@ sh3:
+ ! Instructions introduced into sh3
+ ldtlb ;!/* 0000000000111000 ldtlb */{"ldtlb",{0},{HEX_0,HEX_0,HEX_3,HEX_8}, arch_sh3_up}
+
+-! Instructions inherited from ancestors: sh sh2 sh2a-nofpu-or-sh3-nommu sh3-nommu
++! Instructions inherited from ancestors: sh sh2 sh2a-nofpu-or-sh3-nommu sh2a-nofpu-or-sh3-nommu-or-sh2j-nofpu sh3-nommu
+ add #4,r4 ;!/* 0111nnnni8*1.... add #<imm>,<REG_N> */{"add",{A_IMM,A_REG_N},{HEX_7,REG_N,IMM0_8}, arch_sh_up}
+ add r5,r4 ;!/* 0011nnnnmmmm1100 add <REG_M>,<REG_N> */{"add",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_C}, arch_sh_up}
+ addc r5,r4 ;!/* 0011nnnnmmmm1110 addc <REG_M>,<REG_N>*/{"addc",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_E}, arch_sh_up}
+@@ -128,8 +128,8 @@ sh3:
+ rts ;!/* 0000000000001011 rts */{"rts",{0},{HEX_0,HEX_0,HEX_0,HEX_B}, arch_sh_up}
+ sets ;!/* 0000000001011000 sets */{"sets",{0},{HEX_0,HEX_0,HEX_5,HEX_8}, arch_sh3_nommu_up}
+ sett ;!/* 0000000000011000 sett */{"sett",{0},{HEX_0,HEX_0,HEX_1,HEX_8}, arch_sh_up}
+- shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_up}
+- shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_up}
++ shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
++ shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
+ shal r4 ;!/* 0100nnnn00100000 shal <REG_N> */{"shal",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_0}, arch_sh_up}
+ shar r4 ;!/* 0100nnnn00100001 shar <REG_N> */{"shar",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_1}, arch_sh_up}
+ shll r4 ;!/* 0100nnnn00000000 shll <REG_N> */{"shll",{A_REG_N},{HEX_4,REG_N,HEX_0,HEX_0}, arch_sh_up}
+diff --git a/gas/testsuite/gas/sh/arch/sh3e.s b/gas/testsuite/gas/sh/arch/sh3e.s
+index f5c8ab91..215e5eca 100644
+--- a/gas/testsuite/gas/sh/arch/sh3e.s
++++ b/gas/testsuite/gas/sh/arch/sh3e.s
+@@ -12,7 +12,7 @@
+ sh3e:
+ ! Instructions introduced into sh3e
+
+-! Instructions inherited from ancestors: sh sh2 sh2a-nofpu-or-sh3-nommu sh2a-or-sh3e sh2e sh3 sh3-nommu
++! Instructions inherited from ancestors: sh sh2 sh2a-nofpu-or-sh3-nommu sh2a-nofpu-or-sh3-nommu-or-sh2j-nofpu sh2a-or-sh3e sh2e sh3 sh3-nommu
+ add #4,r4 ;!/* 0111nnnni8*1.... add #<imm>,<REG_N> */{"add",{A_IMM,A_REG_N},{HEX_7,REG_N,IMM0_8}, arch_sh_up}
+ add r5,r4 ;!/* 0011nnnnmmmm1100 add <REG_M>,<REG_N> */{"add",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_C}, arch_sh_up}
+ addc r5,r4 ;!/* 0011nnnnmmmm1110 addc <REG_M>,<REG_N>*/{"addc",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_E}, arch_sh_up}
+@@ -132,8 +132,8 @@ sh3e:
+ rts ;!/* 0000000000001011 rts */{"rts",{0},{HEX_0,HEX_0,HEX_0,HEX_B}, arch_sh_up}
+ sets ;!/* 0000000001011000 sets */{"sets",{0},{HEX_0,HEX_0,HEX_5,HEX_8}, arch_sh3_nommu_up}
+ sett ;!/* 0000000000011000 sett */{"sett",{0},{HEX_0,HEX_0,HEX_1,HEX_8}, arch_sh_up}
+- shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_up}
+- shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_up}
++ shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
++ shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
+ shal r4 ;!/* 0100nnnn00100000 shal <REG_N> */{"shal",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_0}, arch_sh_up}
+ shar r4 ;!/* 0100nnnn00100001 shar <REG_N> */{"shar",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_1}, arch_sh_up}
+ shll r4 ;!/* 0100nnnn00000000 shll <REG_N> */{"shll",{A_REG_N},{HEX_4,REG_N,HEX_0,HEX_0}, arch_sh_up}
+diff --git a/gas/testsuite/gas/sh/arch/sh4-nofpu.s b/gas/testsuite/gas/sh/arch/sh4-nofpu.s
+index 32b58f9c..1fef0351 100644
+--- a/gas/testsuite/gas/sh/arch/sh4-nofpu.s
++++ b/gas/testsuite/gas/sh/arch/sh4-nofpu.s
+@@ -12,7 +12,7 @@
+ sh4_nofpu:
+ ! Instructions introduced into sh4-nofpu
+
+-! Instructions inherited from ancestors: sh sh2 sh2a-nofpu-or-sh3-nommu sh2a-nofpu-or-sh4-nommu-nofpu sh3 sh3-nommu sh4-nommu-nofpu
++! Instructions inherited from ancestors: sh sh2 sh2a-nofpu-or-sh3-nommu sh2a-nofpu-or-sh3-nommu-or-sh2j-nofpu sh2a-nofpu-or-sh4-nommu-nofpu sh3 sh3-nommu sh4-nommu-nofpu
+ add #4,r4 ;!/* 0111nnnni8*1.... add #<imm>,<REG_N> */{"add",{A_IMM,A_REG_N},{HEX_7,REG_N,IMM0_8}, arch_sh_up}
+ add r5,r4 ;!/* 0011nnnnmmmm1100 add <REG_M>,<REG_N> */{"add",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_C}, arch_sh_up}
+ addc r5,r4 ;!/* 0011nnnnmmmm1110 addc <REG_M>,<REG_N>*/{"addc",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_E}, arch_sh_up}
+@@ -136,8 +136,8 @@ sh4_nofpu:
+ rts ;!/* 0000000000001011 rts */{"rts",{0},{HEX_0,HEX_0,HEX_0,HEX_B}, arch_sh_up}
+ sets ;!/* 0000000001011000 sets */{"sets",{0},{HEX_0,HEX_0,HEX_5,HEX_8}, arch_sh3_nommu_up}
+ sett ;!/* 0000000000011000 sett */{"sett",{0},{HEX_0,HEX_0,HEX_1,HEX_8}, arch_sh_up}
+- shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_up}
+- shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_up}
++ shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
++ shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
+ shal r4 ;!/* 0100nnnn00100000 shal <REG_N> */{"shal",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_0}, arch_sh_up}
+ shar r4 ;!/* 0100nnnn00100001 shar <REG_N> */{"shar",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_1}, arch_sh_up}
+ shll r4 ;!/* 0100nnnn00000000 shll <REG_N> */{"shll",{A_REG_N},{HEX_4,REG_N,HEX_0,HEX_0}, arch_sh_up}
+diff --git a/gas/testsuite/gas/sh/arch/sh4-nommu-nofpu.s b/gas/testsuite/gas/sh/arch/sh4-nommu-nofpu.s
+index 61f0bc6c..65d11c57 100644
+--- a/gas/testsuite/gas/sh/arch/sh4-nommu-nofpu.s
++++ b/gas/testsuite/gas/sh/arch/sh4-nommu-nofpu.s
+@@ -24,7 +24,7 @@ sh4_nommu_nofpu:
+ stc.l SGR,@-r4 ;!/* 0100nnnn00110010 stc.l SGR,@-<REG_N> */{"stc.l",{A_SGR,A_DEC_N},{HEX_4,REG_N,HEX_3,HEX_2}, arch_sh4_nommu_nofpu_up}
+ stc.l DBR,@-r4 ;!/* 0100nnnn11110010 stc.l DBR,@-<REG_N> */{"stc.l",{A_DBR,A_DEC_N},{HEX_4,REG_N,HEX_F,HEX_2}, arch_sh4_nommu_nofpu_up}
+
+-! Instructions inherited from ancestors: sh sh2 sh2a-nofpu-or-sh3-nommu sh2a-nofpu-or-sh4-nommu-nofpu sh3-nommu
++! Instructions inherited from ancestors: sh sh2 sh2a-nofpu-or-sh3-nommu sh2a-nofpu-or-sh3-nommu-or-sh2j-nofpu sh2a-nofpu-or-sh4-nommu-nofpu sh3-nommu
+ add #4,r4 ;!/* 0111nnnni8*1.... add #<imm>,<REG_N> */{"add",{A_IMM,A_REG_N},{HEX_7,REG_N,IMM0_8}, arch_sh_up}
+ add r5,r4 ;!/* 0011nnnnmmmm1100 add <REG_M>,<REG_N> */{"add",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_C}, arch_sh_up}
+ addc r5,r4 ;!/* 0011nnnnmmmm1110 addc <REG_M>,<REG_N>*/{"addc",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_E}, arch_sh_up}
+@@ -139,8 +139,8 @@ sh4_nommu_nofpu:
+ rts ;!/* 0000000000001011 rts */{"rts",{0},{HEX_0,HEX_0,HEX_0,HEX_B}, arch_sh_up}
+ sets ;!/* 0000000001011000 sets */{"sets",{0},{HEX_0,HEX_0,HEX_5,HEX_8}, arch_sh3_nommu_up}
+ sett ;!/* 0000000000011000 sett */{"sett",{0},{HEX_0,HEX_0,HEX_1,HEX_8}, arch_sh_up}
+- shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_up}
+- shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_up}
++ shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
++ shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
+ shal r4 ;!/* 0100nnnn00100000 shal <REG_N> */{"shal",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_0}, arch_sh_up}
+ shar r4 ;!/* 0100nnnn00100001 shar <REG_N> */{"shar",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_1}, arch_sh_up}
+ shll r4 ;!/* 0100nnnn00000000 shll <REG_N> */{"shll",{A_REG_N},{HEX_4,REG_N,HEX_0,HEX_0}, arch_sh_up}
+diff --git a/gas/testsuite/gas/sh/arch/sh4.s b/gas/testsuite/gas/sh/arch/sh4.s
+index af135ce3..dc199cb4 100644
+--- a/gas/testsuite/gas/sh/arch/sh4.s
++++ b/gas/testsuite/gas/sh/arch/sh4.s
+@@ -17,7 +17,7 @@ sh4:
+ fsrra fr1 ;!/* 1111nnnn01111101 fsrra <F_REG_N> */{"fsrra",{F_REG_N},{HEX_F,REG_N,HEX_7,HEX_D}, arch_sh4_up}
+ ftrv xmtrx,fv0 ;!/* 1111nn0111111101 ftrv XMTRX_M4,<V_REG_n>*/{"ftrv",{XMTRX_M4,V_REG_N},{HEX_F,REG_N_B01,HEX_F,HEX_D}, arch_sh4_up}
+
+-! Instructions inherited from ancestors: sh sh2 sh2a-nofpu-or-sh3-nommu sh2a-nofpu-or-sh4-nommu-nofpu sh2a-or-sh3e sh2a-or-sh4 sh2e sh3 sh3-nommu sh3e sh4-nofpu sh4-nommu-nofpu
++! Instructions inherited from ancestors: sh sh2 sh2a-nofpu-or-sh3-nommu sh2a-nofpu-or-sh3-nommu-or-sh2j-nofpu sh2a-nofpu-or-sh4-nommu-nofpu sh2a-or-sh3e sh2a-or-sh4 sh2e sh3 sh3-nommu sh3e sh4-nofpu sh4-nommu-nofpu
+ add #4,r4 ;!/* 0111nnnni8*1.... add #<imm>,<REG_N> */{"add",{A_IMM,A_REG_N},{HEX_7,REG_N,IMM0_8}, arch_sh_up}
+ add r5,r4 ;!/* 0011nnnnmmmm1100 add <REG_M>,<REG_N> */{"add",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_C}, arch_sh_up}
+ addc r5,r4 ;!/* 0011nnnnmmmm1110 addc <REG_M>,<REG_N>*/{"addc",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_E}, arch_sh_up}
+@@ -145,8 +145,8 @@ sh4:
+ rts ;!/* 0000000000001011 rts */{"rts",{0},{HEX_0,HEX_0,HEX_0,HEX_B}, arch_sh_up}
+ sets ;!/* 0000000001011000 sets */{"sets",{0},{HEX_0,HEX_0,HEX_5,HEX_8}, arch_sh3_nommu_up}
+ sett ;!/* 0000000000011000 sett */{"sett",{0},{HEX_0,HEX_0,HEX_1,HEX_8}, arch_sh_up}
+- shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_up}
+- shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_up}
++ shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
++ shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
+ shal r4 ;!/* 0100nnnn00100000 shal <REG_N> */{"shal",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_0}, arch_sh_up}
+ shar r4 ;!/* 0100nnnn00100001 shar <REG_N> */{"shar",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_1}, arch_sh_up}
+ shll r4 ;!/* 0100nnnn00000000 shll <REG_N> */{"shll",{A_REG_N},{HEX_4,REG_N,HEX_0,HEX_0}, arch_sh_up}
+diff --git a/gas/testsuite/gas/sh/arch/sh4a-nofpu.s b/gas/testsuite/gas/sh/arch/sh4a-nofpu.s
+index 9522bb6b..7581f471 100644
+--- a/gas/testsuite/gas/sh/arch/sh4a-nofpu.s
++++ b/gas/testsuite/gas/sh/arch/sh4a-nofpu.s
+@@ -19,7 +19,7 @@ sh4a_nofpu:
+ prefi @r4 ;!/* 0000nnnn11010011 prefi @<REG_N> */{"prefi",{A_IND_N},{HEX_0,REG_N,HEX_D,HEX_3}, arch_sh4a_nofpu_up}
+ synco ;!/* 0000000010101011 synco */{"synco",{0},{HEX_0,HEX_0,HEX_A,HEX_B}, arch_sh4a_nofpu_up}
+
+-! Instructions inherited from ancestors: sh sh2 sh2a-nofpu-or-sh3-nommu sh2a-nofpu-or-sh4-nommu-nofpu sh3 sh3-nommu sh4-nofpu sh4-nommu-nofpu
++! Instructions inherited from ancestors: sh sh2 sh2a-nofpu-or-sh3-nommu sh2a-nofpu-or-sh3-nommu-or-sh2j-nofpu sh2a-nofpu-or-sh4-nommu-nofpu sh3 sh3-nommu sh4-nofpu sh4-nommu-nofpu
+ add #4,r4 ;!/* 0111nnnni8*1.... add #<imm>,<REG_N> */{"add",{A_IMM,A_REG_N},{HEX_7,REG_N,IMM0_8}, arch_sh_up}
+ add r5,r4 ;!/* 0011nnnnmmmm1100 add <REG_M>,<REG_N> */{"add",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_C}, arch_sh_up}
+ addc r5,r4 ;!/* 0011nnnnmmmm1110 addc <REG_M>,<REG_N>*/{"addc",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_E}, arch_sh_up}
+@@ -143,8 +143,8 @@ sh4a_nofpu:
+ rts ;!/* 0000000000001011 rts */{"rts",{0},{HEX_0,HEX_0,HEX_0,HEX_B}, arch_sh_up}
+ sets ;!/* 0000000001011000 sets */{"sets",{0},{HEX_0,HEX_0,HEX_5,HEX_8}, arch_sh3_nommu_up}
+ sett ;!/* 0000000000011000 sett */{"sett",{0},{HEX_0,HEX_0,HEX_1,HEX_8}, arch_sh_up}
+- shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_up}
+- shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_up}
++ shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
++ shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
+ shal r4 ;!/* 0100nnnn00100000 shal <REG_N> */{"shal",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_0}, arch_sh_up}
+ shar r4 ;!/* 0100nnnn00100001 shar <REG_N> */{"shar",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_1}, arch_sh_up}
+ shll r4 ;!/* 0100nnnn00000000 shll <REG_N> */{"shll",{A_REG_N},{HEX_4,REG_N,HEX_0,HEX_0}, arch_sh_up}
+diff --git a/gas/testsuite/gas/sh/arch/sh4a.s b/gas/testsuite/gas/sh/arch/sh4a.s
+index 950ed2dc..55e9611c 100644
+--- a/gas/testsuite/gas/sh/arch/sh4a.s
++++ b/gas/testsuite/gas/sh/arch/sh4a.s
+@@ -13,7 +13,7 @@ sh4a:
+ ! Instructions introduced into sh4a
+ fpchg ;!/* 1111011111111101 fpchg */{"fpchg",{0},{HEX_F,HEX_7,HEX_F,HEX_D}, arch_sh4a_up}
+
+-! Instructions inherited from ancestors: sh sh2 sh2a-nofpu-or-sh3-nommu sh2a-nofpu-or-sh4-nommu-nofpu sh2a-or-sh3e sh2a-or-sh4 sh2e sh3 sh3-nommu sh3e sh4 sh4-nofpu sh4-nommu-nofpu sh4a-nofpu
++! Instructions inherited from ancestors: sh sh2 sh2a-nofpu-or-sh3-nommu sh2a-nofpu-or-sh3-nommu-or-sh2j-nofpu sh2a-nofpu-or-sh4-nommu-nofpu sh2a-or-sh3e sh2a-or-sh4 sh2e sh3 sh3-nommu sh3e sh4 sh4-nofpu sh4-nommu-nofpu sh4a-nofpu
+ add #4,r4 ;!/* 0111nnnni8*1.... add #<imm>,<REG_N> */{"add",{A_IMM,A_REG_N},{HEX_7,REG_N,IMM0_8}, arch_sh_up}
+ add r5,r4 ;!/* 0011nnnnmmmm1100 add <REG_M>,<REG_N> */{"add",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_C}, arch_sh_up}
+ addc r5,r4 ;!/* 0011nnnnmmmm1110 addc <REG_M>,<REG_N>*/{"addc",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_E}, arch_sh_up}
+@@ -147,8 +147,8 @@ sh4a:
+ rts ;!/* 0000000000001011 rts */{"rts",{0},{HEX_0,HEX_0,HEX_0,HEX_B}, arch_sh_up}
+ sets ;!/* 0000000001011000 sets */{"sets",{0},{HEX_0,HEX_0,HEX_5,HEX_8}, arch_sh3_nommu_up}
+ sett ;!/* 0000000000011000 sett */{"sett",{0},{HEX_0,HEX_0,HEX_1,HEX_8}, arch_sh_up}
+- shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_up}
+- shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_up}
++ shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
++ shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
+ shal r4 ;!/* 0100nnnn00100000 shal <REG_N> */{"shal",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_0}, arch_sh_up}
+ shar r4 ;!/* 0100nnnn00100001 shar <REG_N> */{"shar",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_1}, arch_sh_up}
+ shll r4 ;!/* 0100nnnn00000000 shll <REG_N> */{"shll",{A_REG_N},{HEX_4,REG_N,HEX_0,HEX_0}, arch_sh_up}
+diff --git a/gas/testsuite/gas/sh/arch/sh4al-dsp.s b/gas/testsuite/gas/sh/arch/sh4al-dsp.s
+index 6caaf2ce..fde6c1ee 100644
+--- a/gas/testsuite/gas/sh/arch/sh4al-dsp.s
++++ b/gas/testsuite/gas/sh/arch/sh4al-dsp.s
+@@ -48,7 +48,7 @@ sh4al_dsp:
+ dct pswap x1,m0 ;!/* 10011101xx01zzzz pswap <DSP_REG_X>,<DSP_REG_N> */ {"pswap", {DSP_REG_X,DSP_REG_N},{PPI,PPIC,HEX_9,HEX_D,HEX_1}, arch_sh4al_dsp_up}
+ dct pswap y0,m0 ;!/* 1011110101yyzzzz pswap <DSP_REG_Y>,<DSP_REG_N> */ {"pswap", {DSP_REG_Y,DSP_REG_N},{PPI,PPIC,HEX_B,HEX_D,HEX_4}, arch_sh4al_dsp_up}
+
+-! Instructions inherited from ancestors: sh sh-dsp sh2 sh2a-nofpu-or-sh3-nommu sh2a-nofpu-or-sh4-nommu-nofpu sh3 sh3-dsp sh3-nommu sh4-nofpu sh4-nommu-nofpu sh4a-nofpu
++! Instructions inherited from ancestors: sh sh-dsp sh2 sh2a-nofpu-or-sh3-nommu sh2a-nofpu-or-sh3-nommu-or-sh2j-nofpu sh2a-nofpu-or-sh4-nommu-nofpu sh3 sh3-dsp sh3-nommu sh4-nofpu sh4-nommu-nofpu sh4a-nofpu
+ add #4,r4 ;!/* 0111nnnni8*1.... add #<imm>,<REG_N> */{"add",{A_IMM,A_REG_N},{HEX_7,REG_N,IMM0_8}, arch_sh_up}
+ add r5,r4 ;!/* 0011nnnnmmmm1100 add <REG_M>,<REG_N> */{"add",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_C}, arch_sh_up}
+ addc r5,r4 ;!/* 0011nnnnmmmm1110 addc <REG_M>,<REG_N>*/{"addc",{ A_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_E}, arch_sh_up}
+@@ -202,8 +202,8 @@ sh4al_dsp:
+ setrc #4 ;!/* 10000010i8*1.... setrc #<imm> */{"setrc",{A_IMM},{HEX_8,HEX_2,IMM0_8}, arch_sh_dsp_up}
+ repeat 10 20 r4 ;!/* repeat start end <REG_N> */{"repeat",{A_DISP_PC,A_DISP_PC,A_REG_N},{REPEAT,REG_N,HEX_1,HEX_4}, arch_sh_dsp_up}
+ repeat 10 20 #4 ;!/* repeat start end #<imm> */{"repeat",{A_DISP_PC,A_DISP_PC,A_IMM},{REPEAT,HEX_2,IMM0_8,HEX_8}, arch_sh_dsp_up}
+- shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_up}
+- shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_up}
++ shad r5,r4 ;!/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
++ shld r5,r4 ;!/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_or_sh2j_nofpu_up}
+ shal r4 ;!/* 0100nnnn00100000 shal <REG_N> */{"shal",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_0}, arch_sh_up}
+ shar r4 ;!/* 0100nnnn00100001 shar <REG_N> */{"shar",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_1}, arch_sh_up}
+ shll r4 ;!/* 0100nnnn00000000 shll <REG_N> */{"shll",{A_REG_N},{HEX_4,REG_N,HEX_0,HEX_0}, arch_sh_up}
+diff --git a/include/elf/sh.h b/include/elf/sh.h
+index 2bc5f461..d7fe12d0 100644
+--- a/include/elf/sh.h
++++ b/include/elf/sh.h
+@@ -39,6 +39,7 @@ extern "C" {
+ #define EF_SH2E 11
+ #define EF_SH4A 12
+ #define EF_SH2A 13
++#define EF_SHJ2 14
+
+ #define EF_SH4_NOFPU 16
+ #define EF_SH4A_NOFPU 17
+@@ -50,6 +51,7 @@ extern "C" {
+ #define EF_SH2A_SH3_NOFPU 22
+ #define EF_SH2A_SH4 23
+ #define EF_SH2A_SH3E 24
++#define EF_SH2A_SH3_SHJ2 25
+
+ /* This one can only mix in objects from other EF_SH5 objects. */
+ #define EF_SH5 10
+@@ -72,7 +74,8 @@ extern "C" {
+ /* EF_SH2E */ bfd_mach_sh2e , \
+ /* EF_SH4A */ bfd_mach_sh4a , \
+ /* EF_SH2A */ bfd_mach_sh2a , \
+-/* 14, 15 */ 0, 0, \
++/* EF_SHJ2 */ bfd_mach_shj2 , \
++/* 15 */ 0, \
+ /* EF_SH4_NOFPU */ bfd_mach_sh4_nofpu , \
+ /* EF_SH4A_NOFPU */ bfd_mach_sh4a_nofpu , \
+ /* EF_SH4_NOMMU_NOFPU */ bfd_mach_sh4_nommu_nofpu, \
+@@ -81,7 +84,8 @@ extern "C" {
+ /* EF_SH2A_SH4_NOFPU */ bfd_mach_sh2a_nofpu_or_sh4_nommu_nofpu, \
+ /* EF_SH2A_SH3_NOFPU */ bfd_mach_sh2a_nofpu_or_sh3_nommu, \
+ /* EF_SH2A_SH4 */ bfd_mach_sh2a_or_sh4 , \
+-/* EF_SH2A_SH3E */ bfd_mach_sh2a_or_sh3e
++/* EF_SH2A_SH3E */ bfd_mach_sh2a_or_sh3e, \
++/* EF_SH2A_SH3_SHJ2_NOFPU */ bfd_mach_sh2a_nofpu_or_sh3_nommu_or_shj2_nofpu
+
+ /* Convert arch_sh* into EF_SH*. */
+ int sh_find_elf_flags (unsigned int arch_set);
+diff --git a/opcodes/sh-dis.c b/opcodes/sh-dis.c
+index 6fd59a6f..3a9d1629 100644
+--- a/opcodes/sh-dis.c
++++ b/opcodes/sh-dis.c
+@@ -866,6 +866,9 @@ print_insn_sh (bfd_vma memaddr, struct disassemble_info *info)
+ case XMTRX_M4:
+ fprintf_fn (stream, "xmtrx");
+ break;
++ case A_IND_0:
++ fprintf_fn (stream, "@r0");
++ break;
+ default:
+ abort ();
+ }
+diff --git a/opcodes/sh-opc.h b/opcodes/sh-opc.h
+index 0a38764c..35d8f44d 100644
+--- a/opcodes/sh-opc.h
++++ b/opcodes/sh-opc.h
+@@ -192,7 +192,8 @@ typedef enum
+ FPUL_N,
+ FPUL_M,
+ FPSCR_N,
+- FPSCR_M
++ FPSCR_M,
++ A_IND_0
+ }
+ sh_arg_type;
+
+@@ -216,9 +217,11 @@ sh_dsp_reg_nums;
+ #define arch_sh4_base (1 << 5)
+ #define arch_sh4a_base (1 << 6)
+ #define arch_sh2a_base (1 << 7)
+-#define arch_sh_base_mask MASK (0, 7)
++#define arch_shj2_base (1 << 8)
++#define arch_sh2a_sh3_shj2_base (1 << 9)
++#define arch_sh_base_mask MASK (0, 9)
+
+-/* Bits 8 ... 24 are currently free. */
++/* Bits 10 ... 24 are currently free. */
+
+ /* This is an annotation on instruction types, but we
+ abuse the arch field in instructions to denote it. */
+@@ -256,6 +259,8 @@ sh_dsp_reg_nums;
+ #define arch_sh2a_nofpu_or_sh3_nommu (arch_sh2a_sh3_base|arch_sh_no_mmu |arch_sh_no_co)
+ #define arch_sh2a_or_sh3e (arch_sh2a_sh4_base|arch_sh_no_mmu |arch_sh_sp_fpu)
+ #define arch_sh2a_or_sh4 (arch_sh2a_sh4_base|arch_sh_no_mmu |arch_sh_dp_fpu)
++#define arch_shj2 (arch_shj2_base |arch_sh_no_mmu |arch_sh_no_co)
++#define arch_sh2a_nofpu_or_sh3_nommu_or_shj2_nofpu (arch_sh2a_sh3_shj2_base|arch_sh_no_mmu |arch_sh_no_co)
+
+ #define SH_MERGE_ARCH_SET(SET1, SET2) ((SET1) & (SET2))
+ #define SH_VALID_BASE_ARCH_SET(SET) (((SET) & arch_sh_base_mask) != 0)
+@@ -320,7 +325,8 @@ SH4AL-dsp SH4A
+ #define arch_sh2_up (arch_sh2 \
+ | arch_sh2e_up \
+ | arch_sh2a_nofpu_or_sh3_nommu_up \
+- | arch_sh_dsp_up)
++ | arch_sh_dsp_up \
++ | arch_shj2_up)
+ #define arch_sh2a_nofpu_or_sh3_nommu_up (arch_sh2a_nofpu_or_sh3_nommu \
+ | arch_sh2a_nofpu_or_sh4_nommu_nofpu_up \
+ | arch_sh2a_or_sh3e_up \
+@@ -346,6 +352,12 @@ SH4AL-dsp SH4A
+ #define arch_sh4a_nofpu_up (arch_sh4a_nofpu \
+ | arch_sh4a_up \
+ | arch_sh4al_dsp_up)
++#define arch_shj2_up ( arch_shj2)
++#define arch_sh2a_nofpu_or_sh3_nommu_or_shj2_nofpu_up (arch_sh2a_nofpu_or_sh3_nommu \
++ | arch_sh2a_nofpu_or_sh4_nommu_nofpu_up \
++ | arch_sh2a_or_sh3e_up \
++ | arch_sh3_nommu_up \
++ | arch_shj2_up)
+
+ /* Right branches. */
+ #define arch_sh2e_up (arch_sh2e \
+@@ -714,9 +726,9 @@ const sh_opcode_info sh_table[] =
+
+ /* repeat start end #<imm> */{"repeat",{A_DISP_PC,A_DISP_PC,A_IMM},{REPEAT,HEX_2,IMM0_8S,HEX_8}, arch_sh_dsp_up},
+
+-/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_up},
++/* 0100nnnnmmmm1100 shad <REG_M>,<REG_N>*/{"shad",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_C}, arch_sh2a_nofpu_or_sh3_nommu_or_shj2_nofpu_up},
+
+-/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_up},
++/* 0100nnnnmmmm1101 shld <REG_M>,<REG_N>*/{"shld",{ A_REG_M,A_REG_N},{HEX_4,REG_N,REG_M,HEX_D}, arch_sh2a_nofpu_or_sh3_nommu_or_shj2_nofpu_up},
+
+ /* 0100nnnn00100000 shal <REG_N> */{"shal",{A_REG_N},{HEX_4,REG_N,HEX_2,HEX_0}, arch_sh_up},
+
+@@ -1194,7 +1206,7 @@ const sh_opcode_info sh_table[] =
+ {"movu.b",{A_DISP_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_1,HEX_8,DISP0_12}, arch_sh2a_nofpu_up | arch_op32},
+ /* 0011nnnnmmmm0001 1001dddddddddddd movu.w @(<DISP12>,<REG_M>),<REG_N> */
+ {"movu.w",{A_DISP_REG_M,A_REG_N},{HEX_3,REG_N,REG_M,HEX_1,HEX_9,DISP0_12BY2}, arch_sh2a_nofpu_up | arch_op32},
+-
++ /* 0010nnnnmmmm0011 cas.l Rm,Rn,@R0 */ {"cas.l", { A_REG_M,A_REG_N,A_IND_0},{HEX_2,REG_N,REG_M,HEX_3}, arch_shj2_up},
+ { 0, {0}, {0}, 0 }
+ };
+
diff --git a/etc/patches/musl-cross-make-fe915821/patches/gcc-13/0001-ssp_nonshared.diff b/etc/patches/musl-cross-make-fe915821/patches/gcc-13/0001-ssp_nonshared.diff
new file mode 100644
index 0000000..59fd2e4
--- /dev/null
+++ b/etc/patches/musl-cross-make-fe915821/patches/gcc-13/0001-ssp_nonshared.diff
@@ -0,0 +1,14 @@
+diff --git a/gcc/gcc.cc b/gcc/gcc.cc
+index 7837553958b..3c81c5798d8 100644
+--- a/gcc/gcc.cc
++++ b/gcc/gcc.cc
+@@ -974,7 +974,8 @@ proper position among the other output files. */
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+- "|fstack-protector-strong|fstack-protector-explicit:}"
++ "|fstack-protector-strong|fstack-protector-explicit" \
++ ":-lssp_nonshared}"
+ #else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ "|fstack-protector-strong|fstack-protector-explicit" \
diff --git a/etc/patches/musl-cross-make-fe915821/patches/gcc-13/0002-posix_memalign.diff b/etc/patches/musl-cross-make-fe915821/patches/gcc-13/0002-posix_memalign.diff
new file mode 100644
index 0000000..1d80096
--- /dev/null
+++ b/etc/patches/musl-cross-make-fe915821/patches/gcc-13/0002-posix_memalign.diff
@@ -0,0 +1,30 @@
+diff --git a/gcc/config/i386/pmm_malloc.h b/gcc/config/i386/pmm_malloc.h
+index 1b0bfe37852..d7b2b19bb3c 100644
+--- a/gcc/config/i386/pmm_malloc.h
++++ b/gcc/config/i386/pmm_malloc.h
+@@ -27,12 +27,13 @@
+ #include <stdlib.h>
+
+ /* We can't depend on <stdlib.h> since the prototype of posix_memalign
+- may not be visible. */
++ may not be visible and we can't pollute the namespace either. */
+ #ifndef __cplusplus
+-extern int posix_memalign (void **, size_t, size_t);
++extern int _mm_posix_memalign (void **, size_t, size_t)
+ #else
+-extern "C" int posix_memalign (void **, size_t, size_t) throw ();
++extern "C" int _mm_posix_memalign (void **, size_t, size_t) throw ()
+ #endif
++__asm__("posix_memalign");
+
+ static __inline void *
+ _mm_malloc (size_t __size, size_t __alignment)
+@@ -42,7 +43,7 @@ _mm_malloc (size_t __size, size_t __alignment)
+ return malloc (__size);
+ if (__alignment == 2 || (sizeof (void *) == 8 && __alignment == 4))
+ __alignment = sizeof (void *);
+- if (posix_memalign (&__ptr, __alignment, __size) == 0)
++ if (_mm_posix_memalign (&__ptr, __alignment, __size) == 0)
+ return __ptr;
+ else
+ return NULL;
diff --git a/etc/patches/musl-cross-make-fe915821/patches/gcc-13/0003-j2.diff b/etc/patches/musl-cross-make-fe915821/patches/gcc-13/0003-j2.diff
new file mode 100644
index 0000000..c378645
--- /dev/null
+++ b/etc/patches/musl-cross-make-fe915821/patches/gcc-13/0003-j2.diff
@@ -0,0 +1,346 @@
+diff --git a/gcc/config.gcc b/gcc/config.gcc
+index 357b0bed067..528add999f2 100644
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -556,7 +556,7 @@ s390*-*-*)
+ extra_headers="s390intrin.h htmintrin.h htmxlintrin.h vecintrin.h"
+ ;;
+ # Note the 'l'; we need to be able to match e.g. "shle" or "shl".
+-sh[123456789lbe]*-*-* | sh-*-*)
++sh[123456789lbej]*-*-* | sh-*-*)
+ cpu_type=sh
+ extra_options="${extra_options} fused-madd.opt"
+ extra_objs="${extra_objs} sh_treg_combine.o sh-mem.o sh_optimize_sett_clrt.o"
+@@ -3202,18 +3202,18 @@ s390x-ibm-tpf*)
+ extra_options="${extra_options} s390/tpf.opt"
+ tmake_file="${tmake_file} s390/t-s390"
+ ;;
+-sh-*-elf* | sh[12346l]*-*-elf* | \
+- sh-*-linux* | sh[2346lbe]*-*-linux* | \
++sh-*-elf* | sh[12346lj]*-*-elf* | \
++ sh-*-linux* | sh[2346lbej]*-*-linux* | \
+ sh-*-netbsdelf* | shl*-*-netbsdelf*)
+ tmake_file="${tmake_file} sh/t-sh sh/t-elf"
+ if test x${with_endian} = x; then
+ case ${target} in
+- sh[1234]*be-*-* | sh[1234]*eb-*-*) with_endian=big ;;
++ sh[j1234]*be-*-* | sh[j1234]*eb-*-*) with_endian=big ;;
+ shbe-*-* | sheb-*-*) with_endian=big,little ;;
+ sh[1234]l* | sh[34]*-*-linux*) with_endian=little ;;
+ shl* | sh*-*-linux* | \
+ sh-superh-elf) with_endian=little,big ;;
+- sh[1234]*-*-*) with_endian=big ;;
++ sh[j1234]*-*-*) with_endian=big ;;
+ *) with_endian=big,little ;;
+ esac
+ fi
+@@ -3280,6 +3280,7 @@ sh-*-elf* | sh[12346l]*-*-elf* | \
+ sh2a_nofpu*) sh_cpu_target=sh2a-nofpu ;;
+ sh2a*) sh_cpu_target=sh2a ;;
+ sh2e*) sh_cpu_target=sh2e ;;
++ shj2*) sh_cpu_target=shj2;;
+ sh2*) sh_cpu_target=sh2 ;;
+ *) sh_cpu_target=sh1 ;;
+ esac
+@@ -3301,7 +3302,7 @@ sh-*-elf* | sh[12346l]*-*-elf* | \
+ sh2a-single-only | sh2a-single | sh2a-nofpu | sh2a | \
+ sh4a-single-only | sh4a-single | sh4a-nofpu | sh4a | sh4al | \
+ sh4-single-only | sh4-single | sh4-nofpu | sh4 | sh4-300 | \
+- sh3e | sh3 | sh2e | sh2 | sh1) ;;
++ sh3e | sh3 | sh2e | sh2 | sh1 | shj2) ;;
+ "") sh_cpu_default=${sh_cpu_target} ;;
+ *) echo "with_cpu=$with_cpu not supported"; exit 1 ;;
+ esac
+@@ -3310,9 +3311,9 @@ sh-*-elf* | sh[12346l]*-*-elf* | \
+ case ${target} in
+ sh[1234]*) sh_multilibs=${sh_cpu_target} ;;
+ sh-superh-*) sh_multilibs=m4,m4-single,m4-single-only,m4-nofpu ;;
+- sh*-*-linux*) sh_multilibs=m1,m2,m2a,m3e,m4 ;;
++ sh*-*-linux*) sh_multilibs=m1,m2,m2a,m3e,m4,mj2 ;;
+ sh*-*-netbsd*) sh_multilibs=m3,m3e,m4 ;;
+- *) sh_multilibs=m1,m2,m2e,m4,m4-single,m4-single-only,m2a,m2a-single ;;
++ *) sh_multilibs=m1,m2,m2e,m4,m4-single,m4-single-only,m2a,m2a-single,mj2 ;;
+ esac
+ if test x$with_fp = xno; then
+ sh_multilibs="`echo $sh_multilibs|sed -e s/m4/sh4-nofpu/ -e s/,m4-[^,]*//g -e s/,m[23]e// -e s/m2a,m2a-single/m2a-nofpu/ -e s/m5-..m....,//g`"
+@@ -3327,7 +3328,8 @@ sh-*-elf* | sh[12346l]*-*-elf* | \
+ m1 | m2 | m2e | m3 | m3e | \
+ m4 | m4-single | m4-single-only | m4-nofpu | m4-300 |\
+ m4a | m4a-single | m4a-single-only | m4a-nofpu | m4al | \
+- m2a | m2a-single | m2a-single-only | m2a-nofpu)
++ m2a | m2a-single | m2a-single-only | m2a-nofpu | \
++ mj2)
+ # TM_MULTILIB_CONFIG is used by t-sh for the non-endian multilib definition
+ # It is passed to MULTIILIB_OPTIONS verbatim.
+ TM_MULTILIB_CONFIG="${TM_MULTILIB_CONFIG}/${sh_multilib}"
+@@ -3344,7 +3346,7 @@ sh-*-elf* | sh[12346l]*-*-elf* | \
+ done
+ TM_MULTILIB_CONFIG=`echo $TM_MULTILIB_CONFIG | sed 's:^/::'`
+ if test x${enable_incomplete_targets} = xyes ; then
+- tm_defines="$tm_defines SUPPORT_SH1=1 SUPPORT_SH2E=1 SUPPORT_SH4=1 SUPPORT_SH4_SINGLE=1 SUPPORT_SH2A=1 SUPPORT_SH2A_SINGLE=1"
++ tm_defines="$tm_defines SUPPORT_SH1=1 SUPPORT_SH2E=1 SUPPORT_SH4=1 SUPPORT_SH4_SINGLE=1 SUPPORT_SH2A=1 SUPPORT_SH2A_SINGLE=1 SUPPORT_SHJ2=1"
+ fi
+ tm_file="$tm_file ./sysroot-suffix.h"
+ tmake_file="$tmake_file t-sysroot-suffix"
+@@ -5175,6 +5177,8 @@ case "${target}" in
+ ;;
+ m4a | m4a-single | m4a-single-only | m4a-nofpu | m4al)
+ ;;
++ mj2)
++ ;;
+ *)
+ echo "Unknown CPU used in --with-cpu=$with_cpu, known values:" 1>&2
+ echo "m1 m2 m2e m3 m3e m4 m4-single m4-single-only m4-nofpu" 1>&2
+@@ -5385,7 +5389,7 @@ case ${target} in
+ tmake_file="${cpu_type}/t-${cpu_type} ${tmake_file}"
+ ;;
+
+- sh[123456ble]*-*-* | sh-*-*)
++ sh[123456blej]*-*-* | sh-*-*)
+ c_target_objs="${c_target_objs} sh-c.o"
+ cxx_target_objs="${cxx_target_objs} sh-c.o"
+ ;;
+diff --git a/gcc/config/sh/sh.cc b/gcc/config/sh/sh.cc
+index 1564109c942..798c1c1c1a3 100644
+--- a/gcc/config/sh/sh.cc
++++ b/gcc/config/sh/sh.cc
+@@ -686,6 +686,7 @@ parse_validate_atomic_model_option (const char* str)
+ model_names[sh_atomic_model::hard_llcs] = "hard-llcs";
+ model_names[sh_atomic_model::soft_tcb] = "soft-tcb";
+ model_names[sh_atomic_model::soft_imask] = "soft-imask";
++ model_names[sh_atomic_model::hard_cas] = "hard-cas";
+
+ const char* model_cdef_names[sh_atomic_model::num_models];
+ model_cdef_names[sh_atomic_model::none] = "NONE";
+@@ -693,6 +694,7 @@ parse_validate_atomic_model_option (const char* str)
+ model_cdef_names[sh_atomic_model::hard_llcs] = "HARD_LLCS";
+ model_cdef_names[sh_atomic_model::soft_tcb] = "SOFT_TCB";
+ model_cdef_names[sh_atomic_model::soft_imask] = "SOFT_IMASK";
++ model_cdef_names[sh_atomic_model::hard_cas] = "HARD_CAS";
+
+ sh_atomic_model ret;
+ ret.type = sh_atomic_model::none;
+@@ -771,6 +773,9 @@ got_mode_name:;
+ if (ret.type == sh_atomic_model::soft_imask && TARGET_USERMODE)
+ err_ret ("cannot use atomic model %s in user mode", ret.name);
+
++ if (ret.type == sh_atomic_model::hard_cas && !TARGET_SHJ2)
++ err_ret ("atomic model %s is only available J2 targets", ret.name);
++
+ return ret;
+
+ #undef err_ret
+@@ -827,6 +832,8 @@ sh_option_override (void)
+ sh_cpu = PROCESSOR_SH2E;
+ if (TARGET_SH2A)
+ sh_cpu = PROCESSOR_SH2A;
++ if (TARGET_SHJ2)
++ sh_cpu = PROCESSOR_SHJ2;
+ if (TARGET_SH3)
+ sh_cpu = PROCESSOR_SH3;
+ if (TARGET_SH3E)
+diff --git a/gcc/config/sh/sh.h b/gcc/config/sh/sh.h
+index d2280e2ffe6..3a54a896721 100644
+--- a/gcc/config/sh/sh.h
++++ b/gcc/config/sh/sh.h
+@@ -85,6 +85,7 @@ extern int code_for_indirect_jump_scratch;
+ #define SUPPORT_SH4_SINGLE 1
+ #define SUPPORT_SH2A 1
+ #define SUPPORT_SH2A_SINGLE 1
++#define SUPPORT_SHJ2 1
+ #endif
+
+ #define TARGET_DIVIDE_CALL_DIV1 (sh_div_strategy == SH_DIV_CALL_DIV1)
+@@ -117,6 +118,7 @@ extern int code_for_indirect_jump_scratch;
+ #define SELECT_SH4A_SINGLE_ONLY (MASK_SH4A | SELECT_SH4_SINGLE_ONLY)
+ #define SELECT_SH4A (MASK_SH4A | SELECT_SH4)
+ #define SELECT_SH4A_SINGLE (MASK_SH4A | SELECT_SH4_SINGLE)
++#define SELECT_SHJ2 (MASK_SHJ2 | SELECT_SH2)
+
+ #if SUPPORT_SH1
+ #define SUPPORT_SH2 1
+@@ -124,6 +126,7 @@ extern int code_for_indirect_jump_scratch;
+ #if SUPPORT_SH2
+ #define SUPPORT_SH3 1
+ #define SUPPORT_SH2A_NOFPU 1
++#define SUPPORT_SHJ2 1
+ #endif
+ #if SUPPORT_SH3
+ #define SUPPORT_SH4_NOFPU 1
+@@ -156,7 +159,7 @@ extern int code_for_indirect_jump_scratch;
+ #define MASK_ARCH (MASK_SH1 | MASK_SH2 | MASK_SH3 | MASK_SH_E | MASK_SH4 \
+ | MASK_HARD_SH2A | MASK_HARD_SH2A_DOUBLE | MASK_SH4A \
+ | MASK_HARD_SH4 | MASK_FPU_SINGLE \
+- | MASK_FPU_SINGLE_ONLY)
++ | MASK_FPU_SINGLE_ONLY | MASK_SHJ2)
+
+ /* This defaults us to big-endian. */
+ #ifndef TARGET_ENDIAN_DEFAULT
+@@ -231,7 +234,8 @@ extern int code_for_indirect_jump_scratch;
+ %{m2a-single:--isa=sh2a} \
+ %{m2a-single-only:--isa=sh2a} \
+ %{m2a-nofpu:--isa=sh2a-nofpu} \
+-%{m4al:-dsp}"
++%{m4al:-dsp} \
++%{mj2:-isa=j2}"
+
+ #define ASM_SPEC SH_ASM_SPEC
+
+@@ -347,6 +351,7 @@ struct sh_atomic_model
+ hard_llcs,
+ soft_tcb,
+ soft_imask,
++ hard_cas,
+
+ num_models
+ };
+@@ -390,6 +395,9 @@ extern const sh_atomic_model& selected_atomic_model (void);
+ #define TARGET_ATOMIC_SOFT_IMASK \
+ (selected_atomic_model ().type == sh_atomic_model::soft_imask)
+
++#define TARGET_ATOMIC_HARD_CAS \
++ (selected_atomic_model ().type == sh_atomic_model::hard_cas)
++
+ #endif // __cplusplus
+
+ #define SUBTARGET_OVERRIDE_OPTIONS (void) 0
+@@ -1484,7 +1492,7 @@ extern bool current_function_interrupt;
+
+ /* Nonzero if the target supports dynamic shift instructions
+ like shad and shld. */
+-#define TARGET_DYNSHIFT (TARGET_SH3 || TARGET_SH2A)
++#define TARGET_DYNSHIFT (TARGET_SH3 || TARGET_SH2A || TARGET_SHJ2)
+
+ /* The cost of using the dynamic shift insns (shad, shld) are the same
+ if they are available. If they are not available a library function will
+@@ -1747,6 +1755,7 @@ enum processor_type {
+ PROCESSOR_SH2,
+ PROCESSOR_SH2E,
+ PROCESSOR_SH2A,
++ PROCESSOR_SHJ2,
+ PROCESSOR_SH3,
+ PROCESSOR_SH3E,
+ PROCESSOR_SH4,
+diff --git a/gcc/config/sh/sh.opt b/gcc/config/sh/sh.opt
+index b4755a812f3..0989a1c18da 100644
+--- a/gcc/config/sh/sh.opt
++++ b/gcc/config/sh/sh.opt
+@@ -65,6 +65,10 @@ m2e
+ Target RejectNegative Condition(SUPPORT_SH2E)
+ Generate SH2e code.
+
++mj2
++Target RejectNegative Mask(SHJ2) Condition(SUPPORT_SHJ2)
++Generate J2 code.
++
+ m3
+ Target RejectNegative Mask(SH3) Condition(SUPPORT_SH3)
+ Generate SH3 code.
+diff --git a/gcc/config/sh/sync.md b/gcc/config/sh/sync.md
+index 2b43f8edb86..118fc5d06db 100644
+--- a/gcc/config/sh/sync.md
++++ b/gcc/config/sh/sync.md
+@@ -240,6 +240,9 @@
+ || (TARGET_SH4A && <MODE>mode == SImode && !TARGET_ATOMIC_STRICT))
+ atomic_insn = gen_atomic_compare_and_swap<mode>_hard (old_val, mem,
+ exp_val, new_val);
++ else if (TARGET_ATOMIC_HARD_CAS && <MODE>mode == SImode)
++ atomic_insn = gen_atomic_compare_and_swap<mode>_cas (old_val, mem,
++ exp_val, new_val);
+ else if (TARGET_ATOMIC_SOFT_GUSA)
+ atomic_insn = gen_atomic_compare_and_swap<mode>_soft_gusa (old_val, mem,
+ exp_val, new_val);
+@@ -306,6 +309,57 @@
+ }
+ [(set_attr "length" "14")])
+
++(define_expand "atomic_compare_and_swapsi_cas"
++ [(set (match_operand:SI 0 "register_operand" "=r")
++ (unspec_volatile:SI
++ [(match_operand:SI 1 "atomic_mem_operand_0" "=Sra")
++ (match_operand:SI 2 "register_operand" "r")
++ (match_operand:SI 3 "register_operand" "r")]
++ UNSPECV_CMPXCHG_1))]
++ "TARGET_ATOMIC_HARD_CAS"
++{
++ rtx mem = gen_rtx_REG (SImode, 0);
++ emit_move_insn (mem, force_reg (SImode, XEXP (operands[1], 0)));
++ emit_insn (gen_shj2_cas (operands[0], mem, operands[2], operands[3]));
++ DONE;
++})
++
++(define_insn "shj2_cas"
++ [(set (match_operand:SI 0 "register_operand" "=&r")
++ (unspec_volatile:SI
++ [(match_operand:SI 1 "register_operand" "=r")
++ (match_operand:SI 2 "register_operand" "r")
++ (match_operand:SI 3 "register_operand" "0")]
++ UNSPECV_CMPXCHG_1))
++ (set (reg:SI T_REG)
++ (unspec_volatile:SI [(const_int 0)] UNSPECV_CMPXCHG_3))]
++ "TARGET_ATOMIC_HARD_CAS"
++ "cas.l %2,%0,@%1"
++ [(set_attr "length" "2")]
++)
++
++(define_expand "atomic_compare_and_swapqi_cas"
++ [(set (match_operand:SI 0 "arith_reg_dest" "=&r")
++ (unspec_volatile:SI
++ [(match_operand:SI 1 "atomic_mem_operand_0" "=Sra")
++ (match_operand:SI 2 "arith_operand" "rI08")
++ (match_operand:SI 3 "arith_operand" "rI08")]
++ UNSPECV_CMPXCHG_1))]
++ "TARGET_ATOMIC_HARD_CAS"
++{FAIL;}
++)
++
++(define_expand "atomic_compare_and_swaphi_cas"
++ [(set (match_operand:SI 0 "arith_reg_dest" "=&r")
++ (unspec_volatile:SI
++ [(match_operand:SI 1 "atomic_mem_operand_0" "=Sra")
++ (match_operand:SI 2 "arith_operand" "rI08")
++ (match_operand:SI 3 "arith_operand" "rI08")]
++ UNSPECV_CMPXCHG_1))]
++ "TARGET_ATOMIC_HARD_CAS"
++{FAIL;}
++)
++
+ ;; The QIHImode llcs patterns modify the address register of the memory
+ ;; operand. In order to express that, we have to open code the memory
+ ;; operand. Initially the insn is expanded like every other atomic insn
+diff --git a/gcc/config/sh/t-sh b/gcc/config/sh/t-sh
+index 888f8ff7f25..29fd6ae45fd 100644
+--- a/gcc/config/sh/t-sh
++++ b/gcc/config/sh/t-sh
+@@ -50,7 +50,8 @@ MULTILIB_MATCHES = $(shell \
+ m2e,m3e,m4-single-only,m4-100-single-only,m4-200-single-only,m4-300-single-only,m4a-single-only \
+ m2a-single,m2a-single-only \
+ m4-single,m4-100-single,m4-200-single,m4-300-single,m4a-single \
+- m4,m4-100,m4-200,m4-300,m4a; do \
++ m4,m4-100,m4-200,m4-300,m4a \
++ mj2; do \
+ subst= ; \
+ for lib in `echo $$abi|tr , ' '` ; do \
+ if test "`echo $$multilibs|sed s/$$lib//`" != "$$multilibs"; then \
+@@ -63,9 +64,9 @@ MULTILIB_MATCHES = $(shell \
+
+ # SH1 and SH2A support big endian only.
+ ifeq ($(DEFAULT_ENDIAN),ml)
+-MULTILIB_EXCEPTIONS = m1 ml/m1 m2a* ml/m2a* $(TM_MULTILIB_EXCEPTIONS_CONFIG)
++MULTILIB_EXCEPTIONS = m1 ml/m1 m2a* ml/m2a* ml/mj2 $(TM_MULTILIB_EXCEPTIONS_CONFIG)
+ else
+-MULTILIB_EXCEPTIONS = ml/m1 ml/m2a* $(TM_MULTILIB_EXCEPTIONS_CONFIG)
++MULTILIB_EXCEPTIONS = ml/m1 ml/m2a* ml/mj2 $(TM_MULTILIB_EXCEPTIONS_CONFIG)
+ endif
+
+ MULTILIB_OSDIRNAMES = \
+@@ -87,7 +88,8 @@ MULTILIB_OSDIRNAMES = \
+ m4a-single-only=!m4a-single-only $(OTHER_ENDIAN)/m4a-single-only=!$(OTHER_ENDIAN)/m4a-single-only \
+ m4a-single=!m4a-single $(OTHER_ENDIAN)/m4a-single=!$(OTHER_ENDIAN)/m4a-single \
+ m4a=!m4a $(OTHER_ENDIAN)/m4a=!$(OTHER_ENDIAN)/m4a \
+- m4al=!m4al $(OTHER_ENDIAN)/m4al=!$(OTHER_ENDIAN)/m4al
++ m4al=!m4al $(OTHER_ENDIAN)/m4al=!$(OTHER_ENDIAN)/m4al \
++ mj2=!j2
+
+ $(out_object_file): gt-sh.h
+ gt-sh.h : s-gtype ; @true
diff --git a/etc/patches/musl-cross-make-fe915821/patches/gcc-13/0004-static-pie.diff b/etc/patches/musl-cross-make-fe915821/patches/gcc-13/0004-static-pie.diff
new file mode 100644
index 0000000..58d6e3d
--- /dev/null
+++ b/etc/patches/musl-cross-make-fe915821/patches/gcc-13/0004-static-pie.diff
@@ -0,0 +1,92 @@
+diff --git a/gcc/common.opt b/gcc/common.opt
+index a75b44ee47e..7c564818b49 100644
+--- a/gcc/common.opt
++++ b/gcc/common.opt
+@@ -3473,11 +3473,11 @@ Driver
+
+ no-pie
+ Driver RejectNegative Negative(shared)
+-Don't create a dynamically linked position independent executable.
++Don't create a position independent executable.
+
+ pie
+ Driver RejectNegative Negative(no-pie)
+-Create a dynamically linked position independent executable.
++Create a position independent executable.
+
+ static-pie
+ Driver RejectNegative Negative(pie)
+diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
+index 5ebbf42a13d..bb907d8e89a 100644
+--- a/gcc/config/gnu-user.h
++++ b/gcc/config/gnu-user.h
+@@ -51,13 +51,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ #define GNU_USER_TARGET_STARTFILE_SPEC \
+ "%{shared:; \
+ pg|p|profile:%{static-pie:grcrt1.o%s;:gcrt1.o%s}; \
+- static:crt1.o%s; \
+- static-pie:rcrt1.o%s; \
++ static|static-pie:%{" PIE_SPEC ":rcrt1.o%s;:crt1.o%s}; \
+ " PIE_SPEC ":Scrt1.o%s; \
+ :crt1.o%s} " \
+ GNU_USER_TARGET_CRTI " \
+- %{static:crtbeginT.o%s; \
+- shared|static-pie|" PIE_SPEC ":crtbeginS.o%s; \
++ %{shared|" PIE_SPEC ":crtbeginS.o%s; \
++ static:crtbeginT.o%s; \
+ :crtbegin.o%s} \
+ %{fvtable-verify=none:%s; \
+ fvtable-verify=preinit:vtv_start_preinit.o%s; \
+@@ -73,11 +72,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ GNU userspace "finalizer" file, `crtn.o'. */
+
+ #define GNU_USER_TARGET_ENDFILE_SPEC \
+- "%{!static:%{fvtable-verify=none:%s; \
++ "%{static|static-pie:; \
++ fvtable-verify=none:%s; \
+ fvtable-verify=preinit:vtv_end_preinit.o%s; \
+- fvtable-verify=std:vtv_end.o%s}} \
+- %{static:crtend.o%s; \
+- shared|static-pie|" PIE_SPEC ":crtendS.o%s; \
++ fvtable-verify=std:vtv_end.o%s} \
++ %{shared|" PIE_SPEC ":crtendS.o%s; \
+ :crtend.o%s} " \
+ GNU_USER_TARGET_CRTN " " \
+ CRTOFFLOADEND
+@@ -106,7 +105,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ #define LIB_SPEC GNU_USER_TARGET_LIB_SPEC
+
+ #if defined(HAVE_LD_EH_FRAME_HDR)
+-#define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} "
++#define LINK_EH_SPEC "%{!static|" PIE_SPEC ":--eh-frame-hdr} "
+ #endif
+
+ #define GNU_USER_TARGET_LINK_GCC_C_SEQUENCE_SPEC \
+diff --git a/gcc/gcc.cc b/gcc/gcc.cc
+index 3c81c5798d8..cd96eac5d12 100644
+--- a/gcc/gcc.cc
++++ b/gcc/gcc.cc
+@@ -1003,7 +1003,7 @@ proper position among the other output files. */
+ #define NO_FPIE_AND_FPIC_SPEC NO_FPIE_SPEC "|" NO_FPIC_SPEC
+ #define FPIE_OR_FPIC_SPEC NO_FPIE_AND_FPIC_SPEC ":;"
+ #else
+-#define PIE_SPEC "pie"
++#define PIE_SPEC "pie|static-pie"
+ #define FPIE1_SPEC "fpie"
+ #define NO_FPIE1_SPEC FPIE1_SPEC ":;"
+ #define FPIE2_SPEC "fPIE"
+@@ -1027,12 +1027,12 @@ proper position among the other output files. */
+ #ifndef LINK_PIE_SPEC
+ #ifdef HAVE_LD_PIE
+ #ifndef LD_PIE_SPEC
+-#define LD_PIE_SPEC "-pie"
++#define LD_PIE_SPEC "-pie %{static|static-pie:--no-dynamic-linker -z text -Bsymbolic}"
+ #endif
+ #else
+ #define LD_PIE_SPEC ""
+ #endif
+-#define LINK_PIE_SPEC "%{static|shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} "
++#define LINK_PIE_SPEC "%{shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} "
+ #endif
+
+ #ifndef LINK_BUILDID_SPEC
diff --git a/etc/patches/musl-cross-make-fe915821/patches/gcc-13/0005-m68k-sqrt.diff b/etc/patches/musl-cross-make-fe915821/patches/gcc-13/0005-m68k-sqrt.diff
new file mode 100644
index 0000000..652efb1
--- /dev/null
+++ b/etc/patches/musl-cross-make-fe915821/patches/gcc-13/0005-m68k-sqrt.diff
@@ -0,0 +1,20 @@
+diff --git a/gcc/config/m68k/m68k.md b/gcc/config/m68k/m68k.md
+index 59a456cd496..dbfddea41bd 100644
+--- a/gcc/config/m68k/m68k.md
++++ b/gcc/config/m68k/m68k.md
+@@ -4174,13 +4174,13 @@
+ (define_expand "sqrt<mode>2"
+ [(set (match_operand:FP 0 "nonimmediate_operand" "")
+ (sqrt:FP (match_operand:FP 1 "general_operand" "")))]
+- "TARGET_HARD_FLOAT"
++ "(TARGET_68881 && TARGET_68040) || TARGET_COLDFIRE_FPU"
+ "")
+
+ (define_insn "sqrt<mode>2_68881"
+ [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
+ (sqrt:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m")))]
+- "TARGET_68881"
++ "TARGET_68881 && TARGET_68040"
+ {
+ if (FP_REG_P (operands[1]))
+ return "f<FP:round>sqrt%.x %1,%0";
diff --git a/etc/repos.json b/etc/repos.json
new file mode 100644
index 0000000..8704fa9
--- /dev/null
+++ b/etc/repos.json
@@ -0,0 +1,651 @@
+{ "main": "gcc-latest-musl+tools"
+, "repositories":
+ { "patches": {"repository": {"type": "file", "path": "etc/patches"}}
+ , "scripts": {"repository": {"type": "file", "path": "etc/scripts"}}
+ , "imports": {"repository": {"type": "file", "path": "etc/imports"}}
+ , "defaults": {"repository": {"type": "file", "path": "etc/defaults"}}
+ , "bootstrap": {"repository": {"type": "file", "path": "src/bootstrap"}}
+ , "compilers": {"repository": {"type": "file", "path": "src/compilers"}}
+ , "tools": {"repository": {"type": "file", "path": "src/tools"}}
+ , "toolchains": {"repository": {"type": "file", "path": "toolchains"}}
+ , "rules":
+ { "repository":
+ { "type": "git"
+ , "branch": "master"
+ , "commit": "90185a3c608f1428b4ce3c32bc2451f31041acc2"
+ , "repository": "https://github.com/just-buildsystem/rules-cc"
+ , "subdir": "rules"
+ }
+ }
+ , "rules/stage-0":
+ { "repository": "rules"
+ , "target_root": "defaults"
+ , "target_file_name": "stage-0.TARGETS"
+ , "rule_root": "rules"
+ }
+ , "rules/stage-1":
+ { "repository": "rules"
+ , "target_root": "defaults"
+ , "target_file_name": "stage-1.TARGETS"
+ , "rule_root": "rules"
+ , "bindings":
+ { "make": "stage-0/make"
+ , "busybox": "stage-0/busybox"
+ , "gcc": "stage-0/gcc"
+ }
+ }
+ , "rules/gcc":
+ { "repository": "rules"
+ , "target_root": "defaults"
+ , "target_file_name": "gcc.TARGETS"
+ , "rule_root": "rules"
+ , "bindings":
+ { "make": "stage-0/make"
+ , "busybox": "stage-0/busybox"
+ , "gcc": "stage-1/gcc"
+ }
+ }
+ , "rules/clang":
+ { "repository": "rules"
+ , "target_root": "defaults"
+ , "target_file_name": "clang.TARGETS"
+ , "rule_root": "rules"
+ , "bindings":
+ { "make": "stage-0/make"
+ , "busybox": "stage-0/busybox"
+ , "gcc": "compilers/gcc-13.2.0-native"
+ , "cmake": "cmake-3.27.1"
+ , "python": "python-3.12.0"
+ }
+ }
+ , "rules/static-build":
+ { "repository": "rules"
+ , "target_root": "defaults"
+ , "target_file_name": "static-build.TARGETS"
+ , "rule_root": "rules"
+ , "bindings":
+ { "make": "stage-0/make"
+ , "busybox": "stage-0/busybox"
+ , "gcc-musl": "compilers/gcc-13.2.0-musl"
+ }
+ }
+ , "imports/stage-0/gmp-4.2.4":
+ { "repository":
+ { "type": "archive"
+ , "content": "c3b7c9fa7ff0f6634dfde7ba8bf4a9afa0b3b509"
+ , "fetch": "https://ftp.gnu.org/gnu/gmp/gmp-4.2.4.tar.gz"
+ , "sha256": "09652b51e348ea459f121c01b4b7189821e06bf457fbd85382aa6f0b741b4e78"
+ , "subdir": "gmp-4.2.4"
+ }
+ , "target_root": "imports"
+ , "target_file_name": "files.TARGETS"
+ }
+ , "imports/stage-0/mpc-0.8.1":
+ { "repository":
+ { "type": "archive"
+ , "content": "4828dd699fe92fc23456a7abe58fae1aa45c9e84"
+ , "fetch": "https://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz"
+ , "sha256": "e664603757251fd8a352848276497a4c79b7f8b21fd8aedd5cc0598a38fee3e4"
+ , "subdir": "mpc-0.8.1"
+ }
+ , "target_root": "imports"
+ , "target_file_name": "files.TARGETS"
+ }
+ , "imports/stage-0/mpfr-2.3.1":
+ { "repository":
+ { "type": "archive"
+ , "content": "34118d1fdb9a271925d769458ededef8c595876f"
+ , "fetch": "https://www.mpfr.org/mpfr-2.3.1/mpfr-2.3.1.tar.gz"
+ , "sha256": "504e34cace2fe0ba2824abb66928b623965d6f5f9bc931316e6785db7ef2e790"
+ , "subdir": "mpfr-2.3.1"
+ }
+ , "target_root": "imports"
+ , "target_file_name": "files.TARGETS"
+ }
+ , "imports/stage-1/gmp-5.1.3":
+ { "repository":
+ { "type": "archive"
+ , "content": "ba6992490775f21d0926ab17b51a7b8b6ed5e586"
+ , "fetch": "https://ftp.gnu.org/gnu/gmp/gmp-5.1.3.tar.gz"
+ , "sha256": "71f37fe18b7eaffd0700c0d3c5062268c3933c7100c29f944b81d2b6e9f78527"
+ , "subdir": "gmp-5.1.3"
+ }
+ , "target_root": "imports"
+ , "target_file_name": "files.TARGETS"
+ }
+ , "imports/binutils-latest":
+ { "repository":
+ { "type": "archive"
+ , "content": "17cfb0cec609e1771ed867b2d005492329759e39"
+ , "fetch": "https://ftp.gnu.org/gnu/binutils/binutils-2.41.tar.xz"
+ , "sha256": "ae9a5789e23459e59606e6714723f2d3ffc31c03174191ef0d015bdf06007450"
+ , "subdir": "binutils-2.41"
+ }
+ , "target_root": "imports"
+ , "target_file_name": "binutils.TARGETS"
+ , "bindings": {"rules": "rules/gcc"}
+ }
+ , "imports/gmp-6.3.0":
+ { "repository":
+ { "type": "archive"
+ , "content": "eed1334cca024677702c3a4de194758cb1b15c36"
+ , "fetch": "https://gmplib.org/download/gmp/gmp-6.3.0.tar.xz"
+ , "sha256": "a3c2b80201b89e68616f4ad30bc66aee4927c3ce50e33929ca819d5c43538898"
+ , "subdir": "gmp-6.3.0"
+ }
+ , "target_root": "imports"
+ , "target_file_name": "files.TARGETS"
+ }
+ , "imports/mpc-1.3.1":
+ { "repository":
+ { "type": "archive"
+ , "content": "afd933ab8b5246004dc0767bcd3d51333d5ca720"
+ , "fetch": "https://ftp.gnu.org/gnu/mpc/mpc-1.3.1.tar.gz"
+ , "sha256": "ab642492f5cf882b74aa0cb730cd410a81edcdbec895183ce930e706c1c759b8"
+ , "subdir": "mpc-1.3.1"
+ }
+ , "target_root": "imports"
+ , "target_file_name": "files.TARGETS"
+ }
+ , "imports/mpfr-4.2.1":
+ { "repository":
+ { "type": "archive"
+ , "content": "62fb991131420c31d94e7e992c9ba798e8de866f"
+ , "fetch": "https://www.mpfr.org/mpfr-current/mpfr-4.2.1.tar.xz"
+ , "sha256": "277807353a6726978996945af13e52829e3abd7a9a5b7fb2793894e18f1fcbb2"
+ , "subdir": "mpfr-4.2.1"
+ }
+ , "target_root": "imports"
+ , "target_file_name": "files.TARGETS"
+ }
+ , "imports/linux-headers-4.19.88-1":
+ { "repository":
+ { "type": "archive"
+ , "content": "d67e9625ed2750a32eadc8abdd4a356f429e1e61"
+ , "fetch": "https://github.com/sabotage-linux/kernel-headers/releases/download/v4.19.88-1/linux-headers-4.19.88-1.tar.xz"
+ , "sha256": "995bc76ccf0c40d752b5ea67c022232a17eef6c9ec80ea74ea742e3c19992813"
+ , "subdir": "linux-headers-4.19.88-1"
+ , "pragma": {"special": "resolve-partially"}
+ }
+ , "target_root": "imports"
+ , "target_file_name": "files.TARGETS"
+ }
+ , "imports/config-3d5db9e":
+ { "repository":
+ { "type": "archive"
+ , "content": "3a01a6bdf61b589ad70e35e1abf15758f6c2aa39"
+ , "fetch": "https://git.savannah.gnu.org/gitweb/?p=config.git;a=snapshot;h=3d5db9ebe8607382d17d60faf8853c944fc5f353;sf=tgz"
+ , "sha256": "b9974284ff6f9e285c8c57f57a9b0726f48576c61edc2e94a71815198fda0827"
+ , "subdir": "config-3d5db9e"
+ }
+ , "target_root": "imports"
+ , "target_file_name": "files.TARGETS"
+ }
+ , "imports/musl-cross-make-fe915821":
+ { "repository":
+ { "type": "archive"
+ , "content": "99cdef1bbcaf683b9801453fc78aa0c59636f9a2"
+ , "fetch": "https://github.com/richfelker/musl-cross-make/archive/fe915821b652a7fa37b34a596f47d8e20bc72338.tar.gz"
+ , "sha256": "c5df9afd5efd41c97fc7f3866664ef0c91af0ff65116e27cd9cba078c7ab33ae"
+ , "subdir": "musl-cross-make-fe915821b652a7fa37b34a596f47d8e20bc72338"
+ }
+ , "target_root": "imports"
+ , "target_file_name": "musl-cross-make-fe915821.TARGETS"
+ , "bindings":
+ { "rules": "rules/gcc"
+ , "linux-headers": "imports/linux-headers-4.19.88-1"
+ , "config": "imports/config-3d5db9e"
+ , "patches": "patches"
+ }
+ }
+ , "imports/musl-1.2.4":
+ { "repository":
+ { "type": "archive"
+ , "content": "3ae819b834bf1ca20cff02cb67b7526372d58bfd"
+ , "fetch": "https://musl.libc.org/releases/musl-1.2.4.tar.gz"
+ , "sha256": "7a35eae33d5372a7c0da1188de798726f68825513b7ae3ebe97aaaa52114f039"
+ , "subdir": "musl-1.2.4"
+ }
+ , "target_root": "imports"
+ , "target_file_name": "files.TARGETS"
+ }
+ , "imports/boringssl":
+ { "repository":
+ { "type": "archive"
+ , "content": "19cdde8ba529848172c09e84e3deb2c92dc670c3"
+ , "fetch": "https://github.com/google/boringssl/archive/6195bf8242156c9a2fa75702eee058f91b86a88b.tar.gz"
+ , "sha256": "ad0b806b6c5cbd6cae121c608945d5fed468748e330632e8d53315089ad52c67"
+ , "subdir": "boringssl-6195bf8242156c9a2fa75702eee058f91b86a88b"
+ }
+ , "target_root": "imports"
+ , "target_file_name": "boringssl.TARGETS"
+ , "bindings": {"rules": "rules/static-build"}
+ }
+ , "imports/zlib":
+ { "repository":
+ { "type": "archive"
+ , "content": "d115fc690fa59d3be51b3442158876536140b6c2"
+ , "fetch": "https://github.com/madler/zlib/releases/download/v1.2.13/zlib-1.2.13.tar.gz"
+ , "sha256": "b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30"
+ , "subdir": "zlib-1.2.13"
+ }
+ , "target_root": "imports"
+ , "target_file_name": "zlib.TARGETS"
+ , "bindings": {"rules": "rules/static-build"}
+ }
+ , "stage-0/busybox":
+ { "repository":
+ { "type": "archive"
+ , "content": "529defd1de4d1e362458e6561017ae74b2b3f28e"
+ , "fetch": "https://busybox.net/downloads/busybox-1.36.1.tar.bz2"
+ , "sha256": "b8cc24c9574d809e7279c3be349795c5d5ceb6fdf19ca709f80cde50e47de314"
+ , "subdir": "busybox-1.36.1"
+ }
+ , "target_root": "bootstrap"
+ , "target_file_name": "stage-0-busybox.TARGETS"
+ , "bindings":
+ { "rules": "rules/stage-0"
+ , "scripts": "scripts"
+ , "gcc": "stage-0/gcc"
+ , "make": "stage-0/make"
+ }
+ }
+ , "stage-0/make":
+ { "repository":
+ { "type": "archive"
+ , "content": "4adc00a78258ae2eb53d103ef2c1ecf291a86fbf"
+ , "fetch": "https://ftp.gnu.org/gnu/make/make-4.4.1.tar.gz"
+ , "sha256": "dd16fb1d67bfab79a72f5e8390735c49e3e8e70b4945a15ab1f81ddb78658fb3"
+ , "subdir": "make-4.4.1"
+ }
+ , "target_root": "bootstrap"
+ , "target_file_name": "stage-0-make.TARGETS"
+ , "bindings":
+ { "rules": "rules/stage-0"
+ , "busybox": "stage-0/busybox"
+ , "gcc": "stage-0/gcc"
+ }
+ }
+ , "stage-0/binutils":
+ { "repository": "imports/binutils-latest"
+ , "target_root": "bootstrap"
+ , "target_file_name": "stage-0-binutils.TARGETS"
+ , "bindings":
+ { "rules": "rules/stage-0"
+ , "busybox": "stage-0/busybox"
+ , "make": "stage-0/make"
+ , "scripts": "scripts"
+ }
+ }
+ , "stage-0/gcc":
+ { "repository":
+ { "type": "archive"
+ , "content": "4819a9afa95dae6ac8d5abec15049a66e3e725a0"
+ , "fetch": "https://ftp.gnu.org/gnu/gcc/gcc-4.7.4/gcc-4.7.4.tar.gz"
+ , "sha256": "ddbaa583c5d4e4f0928bf15d9f6b6c283349e16eedc47bde71e1b813f6f37819"
+ , "subdir": "gcc-4.7.4"
+ }
+ , "target_root": "bootstrap"
+ , "target_file_name": "stage-0-gcc.TARGETS"
+ , "bindings":
+ { "rules": "rules/stage-0"
+ , "busybox": "stage-0/busybox"
+ , "make": "stage-0/make"
+ , "binutils": "stage-0/binutils"
+ , "gmp": "imports/stage-0/gmp-4.2.4"
+ , "mpc": "imports/stage-0/mpc-0.8.1"
+ , "mpfr": "imports/stage-0/mpfr-2.3.1"
+ , "patches": "patches"
+ }
+ }
+ , "stage-1/gcc":
+ { "repository":
+ { "type": "archive"
+ , "content": "25e1bc0b9c97916a3e6c3f4c100bf170ddf06eaa"
+ , "fetch": "https://ftp.gnu.org/gnu/gcc/gcc-10.2.0/gcc-10.2.0.tar.gz"
+ , "sha256": "27e879dccc639cd7b0cc08ed575c1669492579529b53c9ff27b0b96265fa867d"
+ , "subdir": "gcc-10.2.0"
+ }
+ , "target_root": "bootstrap"
+ , "target_file_name": "stage-1-gcc.TARGETS"
+ , "bindings":
+ { "rules": "rules/stage-1"
+ , "gmp": "imports/stage-1/gmp-5.1.3"
+ , "mpc": "imports/mpc-1.3.1"
+ , "mpfr": "imports/mpfr-4.2.1"
+ , "binutils": "imports/binutils-latest"
+ , "patches": "patches"
+ }
+ }
+ , "compilers/gcc-13.2.0-native":
+ { "repository":
+ { "type": "archive"
+ , "content": "c88c4e3f76d499c613970283fde3c1da3d11e809"
+ , "fetch": "https://ftp.gnu.org/gnu/gcc/gcc-13.2.0/gcc-13.2.0.tar.gz"
+ , "sha256": "8cb4be3796651976f94b9356fa08d833524f62420d6292c5033a9a26af315078"
+ , "subdir": "gcc-13.2.0"
+ }
+ , "target_root": "compilers"
+ , "target_file_name": "gcc-13-native.TARGETS"
+ , "bindings":
+ { "rules": "rules/gcc"
+ , "binutils": "imports/binutils-latest"
+ , "gmp": "imports/gmp-6.3.0"
+ , "mpc": "imports/mpc-1.3.1"
+ , "mpfr": "imports/mpfr-4.2.1"
+ , "patches": "patches"
+ }
+ }
+ , "compilers/gcc-13.2.0-musl":
+ { "repository": "compilers"
+ , "target_file_name": "gcc-13-musl.TARGETS"
+ , "bindings":
+ { "rules": "rules/gcc"
+ , "musl-cross-make": "imports/musl-cross-make-fe915821"
+ , "binutils": "imports/binutils-latest"
+ , "musl": "imports/musl-1.2.4"
+ , "gmp": "imports/gmp-6.3.0"
+ , "mpc": "imports/mpc-1.3.1"
+ , "mpfr": "imports/mpfr-4.2.1"
+ , "gcc": "compilers/gcc-13.2.0-native"
+ }
+ }
+ , "compilers/gcc-13.2.0-musl-static":
+ { "repository": "compilers"
+ , "target_file_name": "gcc-13-musl-static.TARGETS"
+ , "bindings":
+ {"rules": "rules/static-build", "gcc-musl": "compilers/gcc-13.2.0-musl"}
+ }
+ , "compilers/clang-16.0.6-native":
+ { "repository":
+ { "type": "archive"
+ , "content": "e288cee0a32034107fabd6aad63d4b7a045b6b25"
+ , "fetch": "https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-16.0.6.tar.gz"
+ , "sha256": "56b2f75fdaa95ad5e477a246d3f0d164964ab066b4619a01836ef08e475ec9d5"
+ , "subdir": "llvm-project-llvmorg-16.0.6"
+ , "pragma": {"special": "resolve-partially"}
+ }
+ , "target_root": "compilers"
+ , "target_file_name": "clang-16-native.TARGETS"
+ , "bindings":
+ { "rules": "rules/clang"
+ , "binutils": "imports/binutils-latest"
+ , "patches": "patches"
+ }
+ }
+ , "compilers/clang-17.0.1-native":
+ { "repository":
+ { "type": "archive"
+ , "content": "8ac42d74d5689f28a8eae1f9d46330d196f84c2a"
+ , "fetch": "https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-17.0.1.tar.gz"
+ , "sha256": "d51b10be66c10a6a81f4c594b554ffbf1063ffbadcb810af37d1f88d6e0b49dd"
+ , "subdir": "llvm-project-llvmorg-17.0.1"
+ , "pragma": {"special": "resolve-partially"}
+ }
+ , "target_root": "compilers"
+ , "target_file_name": "clang-17-native.TARGETS"
+ , "bindings":
+ { "rules": "rules/clang"
+ , "binutils": "imports/binutils-latest"
+ , "patches": "patches"
+ }
+ }
+ , "tools/busybox-1.36.1":
+ { "repository":
+ { "type": "archive"
+ , "content": "529defd1de4d1e362458e6561017ae74b2b3f28e"
+ , "fetch": "https://busybox.net/downloads/busybox-1.36.1.tar.bz2"
+ , "sha256": "b8cc24c9574d809e7279c3be349795c5d5ceb6fdf19ca709f80cde50e47de314"
+ , "subdir": "busybox-1.36.1"
+ }
+ , "target_root": "tools"
+ , "target_file_name": "busybox-1.36.TARGETS"
+ , "bindings": {"rules": "rules/static-build"}
+ }
+ , "tools/make-4.4.1":
+ { "repository":
+ { "type": "archive"
+ , "content": "4adc00a78258ae2eb53d103ef2c1ecf291a86fbf"
+ , "fetch": "https://ftp.gnu.org/gnu/make/make-4.4.1.tar.gz"
+ , "sha256": "dd16fb1d67bfab79a72f5e8390735c49e3e8e70b4945a15ab1f81ddb78658fb3"
+ , "subdir": "make-4.4.1"
+ }
+ , "target_root": "tools"
+ , "target_file_name": "make-4.4.TARGETS"
+ , "bindings": {"rules": "rules/static-build"}
+ }
+ , "tools/cmake-3.27.1":
+ { "repository":
+ { "type": "archive"
+ , "content": "45586697d7bb7d4f3cae4c86bba5bde710a367a9"
+ , "fetch": "https://github.com/Kitware/CMake/releases/download/v3.27.1/cmake-3.27.1.tar.gz"
+ , "sha256": "b1a6b0135fa11b94476e90f5b32c4c8fad480bf91cf22d0ded98ce22c5132004"
+ , "subdir": "cmake-3.27.1"
+ }
+ , "target_root": "tools"
+ , "target_file_name": "cmake-3.27.TARGETS"
+ , "bindings": {"rules": "rules/static-build", "ssl": "imports/boringssl"}
+ }
+ , "tools/python-3.12.0":
+ { "repository":
+ { "type": "archive"
+ , "content": "0b9a01c1b77e8b75a977e7e8e447d6764215eb1b"
+ , "fetch": "https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tar.xz"
+ , "sha256": "795c34f44df45a0e9b9710c8c71c15c671871524cd412ca14def212e8ccb155d"
+ , "subdir": "Python-3.12.0"
+ }
+ , "target_root": "tools"
+ , "target_file_name": "python-3.12.TARGETS"
+ , "bindings": {"rules": "rules/static-build", "zlib": "imports/zlib"}
+ }
+ , "gcc-latest-native":
+ { "repository": "toolchains"
+ , "target_file_name": "gcc.TARGETS"
+ , "bindings": {"rules": "rules", "gcc": "compilers/gcc-13.2.0-native"}
+ }
+ , "gcc-13.2.0-native":
+ { "repository": "toolchains"
+ , "target_file_name": "gcc.TARGETS"
+ , "bindings": {"rules": "rules", "gcc": "compilers/gcc-13.2.0-native"}
+ }
+ , "gcc-latest-musl":
+ { "repository": "toolchains"
+ , "target_file_name": "gcc.TARGETS"
+ , "bindings": {"rules": "rules", "gcc": "compilers/gcc-13.2.0-musl"}
+ }
+ , "gcc-13.2.0-musl":
+ { "repository": "toolchains"
+ , "target_file_name": "gcc.TARGETS"
+ , "bindings": {"rules": "rules", "gcc": "compilers/gcc-13.2.0-musl"}
+ }
+ , "gcc-latest-musl-static":
+ { "repository": "toolchains"
+ , "target_file_name": "gcc.TARGETS"
+ , "bindings": {"rules": "rules", "gcc": "compilers/gcc-13.2.0-musl-static"}
+ }
+ , "gcc-13.2.0-musl-static":
+ { "repository": "toolchains"
+ , "target_file_name": "gcc.TARGETS"
+ , "bindings": {"rules": "rules", "gcc": "compilers/gcc-13.2.0-musl-static"}
+ }
+ , "clang-latest-native":
+ { "repository": "toolchains"
+ , "target_file_name": "clang.TARGETS"
+ , "bindings": {"rules": "rules", "clang": "compilers/clang-17.0.1-native"}
+ }
+ , "clang-17.0.1-native":
+ { "repository": "toolchains"
+ , "target_file_name": "clang.TARGETS"
+ , "bindings": {"rules": "rules", "clang": "compilers/clang-17.0.1-native"}
+ }
+ , "clang-16.0.6-native":
+ { "repository": "toolchains"
+ , "target_file_name": "clang.TARGETS"
+ , "bindings": {"rules": "rules", "clang": "compilers/clang-16.0.6-native"}
+ }
+ , "busybox-latest":
+ { "repository": "toolchains"
+ , "target_file_name": "busybox.TARGETS"
+ , "bindings": {"rules": "rules", "busybox": "tools/busybox-1.36.1"}
+ }
+ , "busybox-1.36.1":
+ { "repository": "toolchains"
+ , "target_file_name": "busybox.TARGETS"
+ , "bindings": {"rules": "rules", "busybox": "tools/busybox-1.36.1"}
+ }
+ , "make-latest":
+ { "repository": "toolchains"
+ , "target_file_name": "make.TARGETS"
+ , "bindings": {"rules": "rules", "make": "tools/make-4.4.1"}
+ }
+ , "make-4.4.1":
+ { "repository": "toolchains"
+ , "target_file_name": "make.TARGETS"
+ , "bindings": {"rules": "rules", "make": "tools/make-4.4.1"}
+ }
+ , "cmake-latest":
+ { "repository": "toolchains"
+ , "target_file_name": "cmake.TARGETS"
+ , "bindings": {"rules": "rules", "cmake": "tools/cmake-3.27.1"}
+ }
+ , "cmake-3.27.1":
+ { "repository": "toolchains"
+ , "target_file_name": "cmake.TARGETS"
+ , "bindings": {"rules": "rules", "cmake": "tools/cmake-3.27.1"}
+ }
+ , "python-latest":
+ { "repository": "toolchains"
+ , "target_file_name": "python.TARGETS"
+ , "bindings": {"rules": "rules", "python": "tools/python-3.12.0"}
+ }
+ , "python-3.12.0":
+ { "repository": "toolchains"
+ , "target_file_name": "python.TARGETS"
+ , "bindings": {"rules": "rules", "python": "tools/python-3.12.0"}
+ }
+ , "tools-all":
+ { "repository": "toolchains"
+ , "target_file_name": "tools-all.TARGETS"
+ , "bindings":
+ { "rules": "rules"
+ , "busybox": "busybox-latest"
+ , "make": "make-latest"
+ , "cmake": "cmake-latest"
+ , "python": "python-latest"
+ }
+ }
+ , "gcc-latest-native+tools":
+ { "repository": "toolchains"
+ , "target_file_name": "compiler+tools.TARGETS"
+ , "bindings":
+ {"rules": "rules", "tools": "tools-all", "compiler": "gcc-latest-native"}
+ }
+ , "gcc-13.2.0-native+tools":
+ { "repository": "toolchains"
+ , "target_file_name": "compiler+tools.TARGETS"
+ , "bindings":
+ {"rules": "rules", "tools": "tools-all", "compiler": "gcc-13.2.0-native"}
+ }
+ , "gcc-latest-musl+tools":
+ { "repository": "toolchains"
+ , "target_file_name": "compiler+tools.TARGETS"
+ , "bindings":
+ {"rules": "rules", "tools": "tools-all", "compiler": "gcc-latest-musl"}
+ }
+ , "gcc-13.2.0-musl+tools":
+ { "repository": "toolchains"
+ , "target_file_name": "compiler+tools.TARGETS"
+ , "bindings":
+ {"rules": "rules", "tools": "tools-all", "compiler": "gcc-13.2.0-musl"}
+ }
+ , "gcc-latest-musl-static+tools":
+ { "repository": "toolchains"
+ , "target_file_name": "compiler+tools.TARGETS"
+ , "bindings":
+ { "rules": "rules"
+ , "tools": "tools-all"
+ , "compiler": "gcc-latest-musl-static"
+ }
+ }
+ , "gcc-13.2.0-musl-static+tools":
+ { "repository": "toolchains"
+ , "target_file_name": "compiler+tools.TARGETS"
+ , "bindings":
+ { "rules": "rules"
+ , "tools": "tools-all"
+ , "compiler": "gcc-13.2.0-musl-static"
+ }
+ }
+ , "clang-latest-native+tools":
+ { "repository": "toolchains"
+ , "target_file_name": "compiler+tools.TARGETS"
+ , "bindings":
+ { "rules": "rules"
+ , "tools": "tools-all"
+ , "compiler": "clang-latest-native"
+ }
+ }
+ , "clang-17.0.1-native+tools":
+ { "repository": "toolchains"
+ , "target_file_name": "compiler+tools.TARGETS"
+ , "bindings":
+ { "rules": "rules"
+ , "tools": "tools-all"
+ , "compiler": "clang-17.0.1-native"
+ }
+ }
+ , "clang-16.0.6-native+tools":
+ { "repository": "toolchains"
+ , "target_file_name": "compiler+tools.TARGETS"
+ , "bindings":
+ { "rules": "rules"
+ , "tools": "tools-all"
+ , "compiler": "clang-16.0.6-native"
+ }
+ }
+ , "test/rules-gcc-native":
+ { "repository": "rules"
+ , "target_root": "defaults"
+ , "target_file_name": "test.TARGETS"
+ , "rule_root": "rules"
+ , "bindings": {"rules": "rules", "toolchain": "gcc-latest-native"}
+ }
+ , "test/rules-gcc-musl":
+ { "repository": "rules"
+ , "target_root": "defaults"
+ , "target_file_name": "test.TARGETS"
+ , "rule_root": "rules"
+ , "bindings": {"rules": "rules", "toolchain": "gcc-latest-musl"}
+ }
+ , "test/rules-gcc-musl-static":
+ { "repository": "rules"
+ , "target_root": "defaults"
+ , "target_file_name": "test.TARGETS"
+ , "rule_root": "rules"
+ , "bindings": {"rules": "rules", "toolchain": "gcc-latest-musl-static"}
+ }
+ , "test/rules-clang-native":
+ { "repository": "rules"
+ , "target_root": "defaults"
+ , "target_file_name": "test.TARGETS"
+ , "rule_root": "rules"
+ , "bindings": {"rules": "rules", "toolchain": "clang-latest-native"}
+ }
+ , "test/gcc-native":
+ { "repository": {"type": "file", "path": "test"}
+ , "bindings": {"rules": "test/rules-gcc-native"}
+ }
+ , "test/gcc-musl":
+ { "repository": {"type": "file", "path": "test"}
+ , "bindings": {"rules": "test/rules-gcc-musl"}
+ }
+ , "test/gcc-musl-static":
+ { "repository": {"type": "file", "path": "test"}
+ , "bindings": {"rules": "test/rules-gcc-musl-static"}
+ }
+ , "test/clang-native":
+ { "repository": {"type": "file", "path": "test"}
+ , "bindings": {"rules": "test/rules-clang-native"}
+ }
+ }
+}
diff --git a/etc/scripts/TARGETS b/etc/scripts/TARGETS
new file mode 100644
index 0000000..1fb0454
--- /dev/null
+++ b/etc/scripts/TARGETS
@@ -0,0 +1,5 @@
+{ "bootstrap-busybox":
+ {"type": "install", "deps": [["TREE", null, "bootstrap-busybox"]]}
+, "bootstrap-ar": {"type": "install", "deps": ["bootstrap-ar.sh"]}
+, "bootstrap-make": {"type": "install", "deps": ["bootstrap-make.sh"]}
+}
diff --git a/etc/scripts/bootstrap-ar.sh b/etc/scripts/bootstrap-ar.sh
new file mode 100755
index 0000000..12cead4
--- /dev/null
+++ b/etc/scripts/bootstrap-ar.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+set -eu
+
+SRCDIR=$1
+
+( cd ${SRCDIR}
+
+ export CC=${CC:-cc}
+ export LD=${LD:-${CC}}
+ export AR=true
+ export RANLIB=true
+ export MAKE=${MAKE:-make}
+ export CFLAGS="${CFLAGS:-} -I."
+
+ AR_SRCS="
+ binutils/ar.c
+ binutils/arparse.c
+ binutils/arlex.c
+ binutils/arsup.c
+ binutils/not-ranlib.c
+ binutils/rename.c
+ binutils/binemul.c
+ binutils/emul_vanilla.c
+ binutils/bucomm.c
+ binutils/version.c
+ binutils/filemode.c
+ "
+
+ # fake dlfcn.h in order to disable dynamic loads during configure
+ echo '#error fail here' > dlfcn.h
+
+ # configure and build object files for bfd, libiberty, zlib, and libsframe
+ ./configure --prefix=/ --disable-nls --enable-gprofng=no --disable-werror --enable-deterministic-archives
+ ${MAKE} MAKEINFO=true all-binutils || true
+
+ export CFLAGS="${CFLAGS} -DDEFAULT_AR_DETERMINISTIC=1 -Dbin_dummy_emulation="bin_vanilla_emulation" -Iinclude -Ibfd "
+
+ # build archiver object files
+ NUM=0
+ for SRC in ${AR_SRCS}; do
+ # use short object file name to keep final command line short
+ ${CC} ${CFLAGS} -c ${SRC} -o ${NUM}.o
+ NUM=$((${NUM}+1))
+ done
+
+ ${CC} ${CFLAGS} -o ar $(ls *.o bfd/*.o libiberty/*.o zlib/*.o libsframe/*.o | LC_ALL=C sort) -ldl
+)
+
+mv ${SRCDIR}/ar .
diff --git a/etc/scripts/bootstrap-busybox/appletlib.c b/etc/scripts/bootstrap-busybox/appletlib.c
new file mode 100644
index 0000000..aa63360
--- /dev/null
+++ b/etc/scripts/bootstrap-busybox/appletlib.c
@@ -0,0 +1,37 @@
+/*
+ * Minimalistic implementation of appletlib.c that does not require any header
+ * generation.
+ */
+#define stringify_impl(x) #x
+#define stringify(x) stringify_impl(x)
+#define concat(x,y) x##y
+#define applet_main(name) concat(name, _main)
+
+/* Define this accessor before we #define "errno" our way */
+#include <errno.h>
+static inline int *get_perrno(void) { return &errno; }
+
+#include stringify(APPLET_GROUP/APPLET_NAME.c)
+
+int main(int argc, char **argv) {
+#ifdef bb_cached_errno_ptr
+ ASSIGN_CONST_PTR(&bb_errno, get_perrno());
+#endif
+ return applet_main(APPLET_NAME)(argc, argv);
+}
+
+/* missing definitions from appletlib.c */
+const char *applet_name = stringify(APPLET_NAME);
+void bb_show_usage() { xfunc_die(); }
+unsigned string_array_len(char **argv) {
+ char **start = argv;
+ while (*argv)
+ argv++;
+ return argv - start;
+}
+
+/* missing definitions for tar.c (despite 'to_command' being disabled) */
+#include "bb_archive.h"
+void FAST_FUNC data_extract_to_command(archive_handle_t *archive_handle) {
+ /* unused */
+}
diff --git a/etc/scripts/bootstrap-busybox/bootstrap.sh b/etc/scripts/bootstrap-busybox/bootstrap.sh
new file mode 100755
index 0000000..cb9b2fb
--- /dev/null
+++ b/etc/scripts/bootstrap-busybox/bootstrap.sh
@@ -0,0 +1,92 @@
+#!/bin/sh
+
+set -eu
+
+SRCDIR=$1
+APPLET_GROUP=$2
+APPLET_NAME=$3
+
+export CC=${CC:-cc}
+export CFLAGS="-D_GNU_SOURCE -Iinclude -I${SRCDIR} -I${SRCDIR}/include"
+
+DEP_SRCS="
+ libbb/bb_pwd.c
+ libbb/bb_strtonum.c
+ libbb/concat_path_file.c
+ libbb/concat_subpath_file.c
+ libbb/common_bufsiz.c
+ libbb/compare_string_array.c
+ libbb/copyfd.c
+ libbb/crc32.c
+ libbb/default_error_retval.c
+ libbb/endofname.c
+ libbb/fclose_nonstdin.c
+ libbb/fflush_stdout_and_exit.c
+ libbb/full_write.c
+ libbb/get_last_path_component.c
+ libbb/get_line_from_file.c
+ libbb/getopt32.c
+ libbb/isqrt.c
+ libbb/last_char_is.c
+ libbb/llist.c
+ libbb/makedev.c
+ libbb/make_directory.c
+ libbb/messages.c
+ libbb/mode_string.c
+ libbb/perror_msg.c
+ libbb/process_escape_sequence.c
+ libbb/procps.c
+ libbb/ptr_to_globals.c
+ libbb/read.c
+ libbb/read_printf.c
+ libbb/recursive_action.c
+ libbb/safe_poll.c
+ libbb/safe_strncpy.c
+ libbb/safe_write.c
+ libbb/signals.c
+ libbb/skip_whitespace.c
+ libbb/time.c
+ libbb/verror_msg.c
+ libbb/wfopen.c
+ libbb/wfopen_input.c
+ libbb/xatonum.c
+ libbb/xfunc_die.c
+ libbb/xfuncs.c
+ libbb/xfuncs_printf.c
+ libbb/xgetcwd.c
+ libbb/xreadlink.c
+ libbb/xrealloc_vector.c
+ libbb/xregcomp.c
+ archival/bbunzip.c
+ archival/chksum_and_xwrite_tar_header.c
+ archival/libarchive/data_align.c
+ archival/libarchive/data_extract_all.c
+ archival/libarchive/data_extract_to_stdout.c
+ archival/libarchive/data_skip.c
+ archival/libarchive/filter_accept_all.c
+ archival/libarchive/filter_accept_reject_list.c
+ archival/libarchive/find_list_entry.c
+ archival/libarchive/get_header_tar.c
+ archival/libarchive/header_list.c
+ archival/libarchive/header_skip.c
+ archival/libarchive/header_verbose_list.c
+ archival/libarchive/init_handle.c
+ archival/libarchive/open_transformer.c
+ archival/libarchive/seek_by_jump.c
+ archival/libarchive/seek_by_read.c
+ archival/libarchive/unsafe_prefix.c
+ archival/libarchive/unsafe_symlink_target.c
+"
+
+if [ ! -f dep.objs ]; then
+ NUM=0
+ for SRC in ${DEP_SRCS}; do
+ # use short object file name to keep final command line short
+ ${CC} ${CFLAGS} -c ${SRCDIR}/${SRC} -o ${NUM}.o
+ NUM=$((${NUM}+1))
+ done
+ ls *.o | LC_ALL=C sort > dep.objs
+fi
+
+${CC} ${CFLAGS} -DAPPLET_GROUP=${APPLET_GROUP} -DAPPLET_NAME=${APPLET_NAME} \
+ -o ${APPLET_NAME} appletlib.c $(cat dep.objs)
diff --git a/etc/scripts/bootstrap-busybox/include/common_bufsiz.h b/etc/scripts/bootstrap-busybox/include/common_bufsiz.h
new file mode 100644
index 0000000..91e452a
--- /dev/null
+++ b/etc/scripts/bootstrap-busybox/include/common_bufsiz.h
@@ -0,0 +1,3 @@
+enum { COMMON_BUFSIZE = 1024 };
+extern char bb_common_bufsiz1[];
+#define setup_common_bufsiz() ((void)0)
diff --git a/etc/scripts/bootstrap-busybox/include/libbb.h b/etc/scripts/bootstrap-busybox/include/libbb.h
new file mode 100644
index 0000000..33405c1
--- /dev/null
+++ b/etc/scripts/bootstrap-busybox/include/libbb.h
@@ -0,0 +1,162 @@
+/* configuration */
+#define BB_VER "1.36.1"
+#define BB_EXTRA_VERSION ""
+#define BB_GLOBAL_CONST
+
+#define CONFIG_BUSYBOX_EXEC_PATH "/proc/self/exe"
+#define CONFIG_FEATURE_COPYBUF_KB 4
+#define CONFIG_SHA3_SMALL 0
+#define CONFIG_PASSWORD_MINLEN 6
+#define CONFIG_PID_FILE_PATH ""
+
+#define ENABLE_DESKTOP 0
+#define ENABLE_TAR 1
+#define ENABLE_ZCAT 0
+#define ENABLE_SELINUX 0
+#define ENABLE_KILLALL 0
+#define ENABLE_PGREP 0
+#define ENABLE_FGREP 0
+#define ENABLE_EGREP 0
+#define ENABLE_PKILL 0
+#define ENABLE_PIDOF 0
+#define ENABLE_SESTATUS 0
+#define ENABLE_SHA512SUM 0
+#define ENABLE_LOCALE_SUPPORT 0
+#define ENABLE_LONG_OPTS 0
+#define ENABLE_USE_BB_CRYPT_SHA 0
+#define ENABLE_FEATURE_VERBOSE 0
+#define ENABLE_FEATURE_SYSLOG 0
+#define ENABLE_FEATURE_CROND_D 0
+#define ENABLE_FEATURE_TOPMEM 0
+#define ENABLE_FEATURE_TOP_SMP_PROCESS 0
+#define ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS 0
+#define ENABLE_FEATURE_SHOW_THREADS 0
+#define ENABLE_FEATURE_CLEAN_UP 0
+#define ENABLE_FEATURE_PRESERVE_HARDLINKS 0
+#define ENABLE_FEATURE_NON_POSIX_CP 0
+#define ENABLE_FEATURE_USE_SENDFILE 0
+#define ENABLE_FEATURE_SKIP_ROOTFS 0
+#define ENABLE_FEATURE_MOUNT_LOOP_CREATE 0
+#define ENABLE_FEATURE_AWK_LIBM 0
+#define ENABLE_FEATURE_ALLOW_EXEC 0
+#define ENABLE_FEATURE_SEAMLESS_XZ 0
+#define ENABLE_FEATURE_SEAMLESS_LZMA 0
+#define ENABLE_FEATURE_SEAMLESS_BZ2 0
+#define ENABLE_FEATURE_SEAMLESS_GZ 0
+#define ENABLE_FEATURE_SEAMLESS_Z 0
+#define ENABLE_FEATURE_TAR_CREATE 1
+#define ENABLE_FEATURE_TAR_FROM 0
+#define ENABLE_FEATURE_TAR_NOPRESERVE_TIME 0
+#define ENABLE_FEATURE_TAR_LONG_OPTIONS 0
+#define ENABLE_FEATURE_TAR_TO_COMMAND 0
+#define ENABLE_FEATURE_TAR_GNU_EXTENSIONS 0
+#define ENABLE_FEATURE_TAR_AUTODETECT 0
+#define ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY 0
+#define ENABLE_FEATURE_TAR_OLDSUN_COMPATIBILITY 0
+#define ENABLE_FEATURE_FIND_PATH 0
+#define ENABLE_FEATURE_FIND_REGEX 0
+#define ENABLE_FEATURE_FIND_PRINT0 0
+#define ENABLE_FEATURE_FIND_TYPE 1
+#define ENABLE_FEATURE_FIND_EXECUTABLE 0
+#define ENABLE_FEATURE_FIND_PERM 0
+#define ENABLE_FEATURE_FIND_MTIME 0
+#define ENABLE_FEATURE_FIND_CTIME 0
+#define ENABLE_FEATURE_FIND_ATIME 0
+#define ENABLE_FEATURE_FIND_MMIN 0
+#define ENABLE_FEATURE_FIND_CMIN 0
+#define ENABLE_FEATURE_FIND_AMIN 0
+#define ENABLE_FEATURE_FIND_NEWER 0
+#define ENABLE_FEATURE_FIND_INUM 0
+#define ENABLE_FEATURE_FIND_SAMEFILE 0
+#define ENABLE_FEATURE_FIND_USER 0
+#define ENABLE_FEATURE_FIND_SIZE 0
+#define ENABLE_FEATURE_FIND_CONTEXT 0
+#define ENABLE_FEATURE_FIND_PAREN 1
+#define ENABLE_FEATURE_FIND_PRUNE 1
+#define ENABLE_FEATURE_FIND_QUIT 0
+#define ENABLE_FEATURE_FIND_DELETE 0
+#define ENABLE_FEATURE_FIND_EMPTY 0
+#define ENABLE_FEATURE_FIND_EXEC 0
+#define ENABLE_FEATURE_FIND_EXEC_PLUS 0
+#define ENABLE_FEATURE_FIND_GROUP 0
+#define ENABLE_FEATURE_FIND_LINKS 0
+#define ENABLE_FEATURE_FIND_NOT 1
+#define ENABLE_FEATURE_FIND_DEPTH 0
+#define ENABLE_FEATURE_FIND_MAXDEPTH 0
+#define ENABLE_FEATURE_FIND_XDEV 0
+#define ENABLE_FEATURE_BZIP2_DECOMPRESS 0
+
+#define IF_DESKTOP(...)
+#define IF_NOT_DESKTOP(...) __VA_ARGS__
+#define IF_SHELL_ASH(...)
+#define IF_SHELL_HUSH(...)
+#define IF_ECHO(...)
+#define IF_SLEEP(...)
+#define IF_PRINTF(...)
+#define IF_CHOWN(...)
+#define IF_LS(...)
+#define IF_SELINUX(...)
+#define IF_EXTRA_COMPAT(...)
+#define IF_FEATURE_SHOW_THREADS(...)
+#define IF_FEATURE_CP_REFLINK(...)
+#define IF_FEATURE_SHADOWPASSWDS(...)
+#define IF_FEATURE_MTAB_SUPPORT(...)
+#define IF_FEATURE_SKIP_ROOTFS(...)
+#define IF_FEATURE_MOUNT_LOOP_CREATE(...)
+#define IF_FEATURE_TIMEZONE(...)
+#define IF_FEATURE_AWK_GNU_EXTENSIONS(...)
+#define IF_FEATURE_GREP_CONTEXT(...)
+#define IF_FEATURE_SEAMLESS_XZ(...)
+#define IF_FEATURE_SEAMLESS_LZMA(...)
+#define IF_FEATURE_SEAMLESS_BZ2(...)
+#define IF_FEATURE_SEAMLESS_GZ(...)
+#define IF_FEATURE_SEAMLESS_Z(...)
+#define IF_FEATURE_TAR_CREATE(...) __VA_ARGS__
+#define IF_FEATURE_TAR_FROM(...)
+#define IF_FEATURE_TAR_NOPRESERVE_TIME(...)
+#define IF_FEATURE_TAR_LONG_OPTIONS(...)
+#define IF_FEATURE_TAR_TO_COMMAND(...)
+#define IF_NOT_FEATURE_TAR_CREATE(...)
+#define IF_FEATURE_TAR_OLDGNU_COMPATIBILITY(...)
+#define IF_FEATURE_TAR_OLDSUN_COMPATIBILITY(...)
+#define IF_FEATURE_FIND_PATH(...)
+#define IF_FEATURE_FIND_REGEX(...)
+#define IF_FEATURE_FIND_PRINT0(...)
+#define IF_FEATURE_FIND_TYPE(...) __VA_ARGS__
+#define IF_FEATURE_FIND_EXECUTABLE(...)
+#define IF_FEATURE_FIND_PERM(...)
+#define IF_FEATURE_FIND_MTIME(...)
+#define IF_FEATURE_FIND_CTIME(...)
+#define IF_FEATURE_FIND_ATIME(...)
+#define IF_FEATURE_FIND_MMIN(...)
+#define IF_FEATURE_FIND_CMIN(...)
+#define IF_FEATURE_FIND_AMIN(...)
+#define IF_FEATURE_FIND_NEWER(...)
+#define IF_FEATURE_FIND_INUM(...)
+#define IF_FEATURE_FIND_SAMEFILE(...)
+#define IF_FEATURE_FIND_USER(...)
+#define IF_FEATURE_FIND_SIZE(...)
+#define IF_FEATURE_FIND_CONTEXT(...)
+#define IF_FEATURE_FIND_PAREN(...) __VA_ARGS__
+#define IF_FEATURE_FIND_PRUNE(...) __VA_ARGS__
+#define IF_FEATURE_FIND_QUIT(...)
+#define IF_FEATURE_FIND_DELETE(...)
+#define IF_FEATURE_FIND_EMPTY(...)
+#define IF_FEATURE_FIND_EXEC(...)
+#define IF_FEATURE_FIND_EXEC_PLUS(...)
+#define IF_FEATURE_FIND_GROUP(...)
+#define IF_FEATURE_FIND_LINKS(...)
+#define IF_FEATURE_FIND_NOT(...) __VA_ARGS__
+#define IF_FEATURE_FIND_DEPTH(...)
+#define IF_FEATURE_FIND_MAXDEPTH(...)
+#define IF_NOT_FEATURE_FIND_MAXDEPTH(...) __VA_ARGS__
+#define IF_FEATURE_FIND_XDEV(...)
+#define IF_FEATURE_BZIP2_DECOMPRESS(...)
+
+
+/* missing declarations */
+char *strchrnul(const char *s, int c);
+
+
+/* include real libbb.h */
+#include "include/libbb.h"
diff --git a/src/bootstrap/stage-0-binutils.TARGETS b/src/bootstrap/stage-0-binutils.TARGETS
new file mode 100644
index 0000000..3a42b4a
--- /dev/null
+++ b/src/bootstrap/stage-0-binutils.TARGETS
@@ -0,0 +1,74 @@
+{ "bootstrap":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "bootstrap-ar"
+ }
+, "toolchain":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "binutils"
+ }
+, "files": {"type": "install", "deps": [["TREE", null, "."]]}
+, "flag_files":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "cmds":
+ [ "echo 'int main() {int i=1; return *((char*)&i) == 1;}' > endian_test.c"
+ , "${CC} -o endian_test endian_test.c"
+ , "CFLAGS=\"-D__$(./endian_test && echo BIG || echo LITTLE)_ENDIAN__=1\""
+ , "echo \"${CFLAGS}\" > ${DESTDIR}/cflags"
+ ]
+ , "outs": ["cflags"]
+ }
+, "staged_bootstrap_sources_and_flags":
+ { "type": "install"
+ , "dirs":
+ [ ["files", "src"]
+ , ["flag_files", "flags"]
+ , [["@", "scripts", "", "bootstrap-ar"], "."]
+ ]
+ }
+, "bootstrap-ar":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": ["staged_bootstrap_sources_and_flags"]
+ , "localbase":
+ [["@", "busybox", "", "bootstrap"], ["@", "make", "", "bootstrap"]]
+ , "cmds":
+ [ "export LD=${CC}"
+ , "export MAKE=${LOCALBASE}/bin/make"
+ , "export PATH=${LOCALBASE}/bin:$PATH"
+ , "export CFLAGS=\"$(cat flags/cflags)\""
+ , "./bootstrap-ar.sh src >build.log 2>&1 || (cat build.log && exit 1)"
+ , "mv ar ${DESTDIR}/bin/"
+ ]
+ , "outs": ["bin/ar"]
+ }
+, "binutils":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": ["staged_bootstrap_sources_and_flags"]
+ , "localbase":
+ [ ["@", "busybox", "", "bootstrap"]
+ , ["@", "make", "", "bootstrap"]
+ , "bootstrap"
+ ]
+ , "cmds":
+ [ "export LD=${CC}"
+ , "export RANLIB=true"
+ , "export AR=${LOCALBASE}/bin/ar"
+ , "export MAKE=${LOCALBASE}/bin/make"
+ , "export PATH=${LOCALBASE}/bin:$PATH"
+ , "export CFLAGS=\"$(cat flags/cflags)\""
+ , "unset LDFLAGS"
+ , "if [ -f /lib/ld-musl-$(uname -m).so.1 ]; then"
+ , " ln -s /lib/ld-musl-$(uname -m).so.1 ${TMPDIR}/ldd"
+ , " export PATH=$PATH:${TMPDIR}"
+ , "fi"
+ , "mkdir build"
+ , "cd build"
+ , "../src/configure --prefix=/ --disable-nls --enable-gprofng=no --disable-werror --enable-deterministic-archives >configure.log 2>&1 || (cat configure.log && exit 1)"
+ , "${MAKE} -j1 MAKEINFO=true >build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "${MAKE} -j1 MAKEINFO=true DESTDIR=${DESTDIR} install-strip >>build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "for f in $(find ${DESTDIR} -type f -name '*.la'); do sed -i 's|'$(pwd)'|/build|g' $f; done"
+ ]
+ , "out_dirs": ["."]
+ }
+}
diff --git a/src/bootstrap/stage-0-busybox.TARGETS b/src/bootstrap/stage-0-busybox.TARGETS
new file mode 100644
index 0000000..3d0c315
--- /dev/null
+++ b/src/bootstrap/stage-0-busybox.TARGETS
@@ -0,0 +1,63 @@
+{ "bootstrap":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "bootstrap-essentials"
+ }
+, "toolchain":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "busybox"
+ }
+, "files": {"type": "install", "deps": [["TREE", null, "."]]}
+, "staged_bootstrap_sources":
+ { "type": "install"
+ , "dirs":
+ [["files", "src"], [["@", "scripts", "", "bootstrap-busybox"], "."]]
+ }
+, "bootstrap-essentials":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": ["staged_bootstrap_sources"]
+ , "cmds":
+ [ "cd bootstrap-busybox"
+ , "./bootstrap.sh ../src editors awk >>build.log 2>&1 || (cat build.log && exit 1)"
+ , "./bootstrap.sh ../src editors cmp >>build.log 2>&1 || (cat build.log && exit 1)"
+ , "./bootstrap.sh ../src editors sed >>build.log 2>&1 || (cat build.log && exit 1)"
+ , "./bootstrap.sh ../src editors diff >>build.log 2>&1 || (cat build.log && exit 1)"
+ , "./bootstrap.sh ../src editors patch >>build.log 2>&1 || (cat build.log && exit 1)"
+ , "./bootstrap.sh ../src archival tar >>build.log 2>&1 || (cat build.log && exit 1)"
+ , "./bootstrap.sh ../src archival bzip2 >>build.log 2>&1 || (cat build.log && exit 1)"
+ , "./bootstrap.sh ../src findutils grep >>build.log 2>&1 || (cat build.log && exit 1)"
+ , "./bootstrap.sh ../src findutils find >>build.log 2>&1 || (cat build.log && exit 1)"
+ , "mv awk cmp sed diff patch tar bzip2 grep find ${DESTDIR}/bin/"
+ ]
+ , "outs":
+ [ "bin/awk"
+ , "bin/cmp"
+ , "bin/sed"
+ , "bin/diff"
+ , "bin/patch"
+ , "bin/tar"
+ , "bin/bzip2"
+ , "bin/grep"
+ , "bin/find"
+ ]
+ }
+, "staged-gcc":
+ {"type": "install", "dirs": [[["@", "gcc", "", "toolchain"], "gcc"]]}
+, "busybox":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": ["files"]
+ , "localbase": ["bootstrap", ["@", "make", "", "bootstrap"], "staged-gcc"]
+ , "cmds":
+ [ "export NJOBS=$(nproc --all 2>/dev/null || echo 1)"
+ , "export PATH=${LOCALBASE}/bin:${LOCALBASE}/gcc/bin:$PATH"
+ , "export MAKE=${LOCALBASE}/bin/make"
+ , "export CC=${LOCALBASE}/gcc/bin/gcc"
+ , "export CXX=${LOCALBASE}/gcc/bin/g++"
+ , "${MAKE} HOSTCC=${CC} HOSTCXX=${CXX} CONFIG_EXTRA_LDLIBS=\"m resolv\" defconfig >configure.log 2>&1 || (cat configure.log && exit 1)"
+ , "${MAKE} -j${NJOBS} HOSTCC=${CC} HOSTCXX=${CXX} CONFIG_EXTRA_LDLIBS=\"m resolv\" >build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "${MAKE} -j${NJOBS} HOSTCC=${CC} HOSTCXX=${CXX} CONFIG_EXTRA_LDLIBS=\"m resolv\" CONFIG_PREFIX=${DESTDIR} install >>build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ ]
+ , "out_dirs": ["."]
+ }
+}
diff --git a/src/bootstrap/stage-0-gcc.TARGETS b/src/bootstrap/stage-0-gcc.TARGETS
new file mode 100644
index 0000000..8a86620
--- /dev/null
+++ b/src/bootstrap/stage-0-gcc.TARGETS
@@ -0,0 +1,150 @@
+{ "toolchain":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "gcc-4.7.4"
+ }
+, "files": {"type": "install", "deps": [["TREE", null, "."]]}
+, "separate_sources_and_patches":
+ { "type": "install"
+ , "dirs":
+ [ ["files", "gcc"]
+ , [["@", "gmp", "", "files"], "gmp"]
+ , [["@", "mpc", "", "files"], "mpc"]
+ , [["@", "mpfr", "", "files"], "mpfr"]
+ , [["@", "patches", "", "gcc-4.7.4"], "patches"]
+ ]
+ }
+, "combined_patched_sources":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": ["separate_sources_and_patches"]
+ , "localbase": [["@", "busybox", "", "bootstrap"]]
+ , "cmds":
+ [ "export PATCH=${LOCALBASE}/bin/patch"
+ , "mv gmp mpc mpfr gcc/."
+ , "cp -r gcc/. ${DESTDIR}/. && chmod -R +w ${DESTDIR}/*"
+ , "cd ${DESTDIR}"
+ , "echo '#include <sys/ucontext.h>\nucontext_t foo;' > ${TMPDIR}/test.c"
+ , "if \"${CC}\" -c ${TMPDIR}/test.c -o ${TMPDIR}/test.o >/dev/null 2>&1; then"
+ , " ${PATCH} -p1 < ${WORKDIR}/patches/gcc-4.7.4/use-ucontext_t.patch >/dev/null"
+ , "fi"
+ , "for p in $(cat ${WORKDIR}/patches/gcc-4.7.4/various-fixes/series); do"
+ , " ${PATCH} -p1 < ${WORKDIR}/patches/gcc-4.7.4/various-fixes/$p >/dev/null"
+ , "done"
+ , "for p in $(cat ${WORKDIR}/patches/gcc-4.7.4/musl-support/series); do"
+ , " ${PATCH} -p1 < ${WORKDIR}/patches/gcc-4.7.4/musl-support/$p >/dev/null"
+ , "done"
+ , "for p in $(cat ${WORKDIR}/patches/gcc-4.7.4/reproducibility/series); do"
+ , " ${PATCH} -p1 < ${WORKDIR}/patches/gcc-4.7.4/reproducibility/$p >/dev/null"
+ , "done"
+ ]
+ , "out_dirs": ["."]
+ }
+, "staged_sources_and_binutils":
+ { "type": "install"
+ , "dirs":
+ [ ["combined_patched_sources", "src"]
+ , [["@", "binutils", "", "toolchain"], "binutils"]
+ ]
+ }
+, "gcc-4.7.4":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "arguments_config": ["TOOLCHAIN_CONFIG"]
+ , "project": ["staged_sources_and_binutils"]
+ , "localbase":
+ [["@", "busybox", "", "bootstrap"], ["@", "make", "", "bootstrap"]]
+ , "cmds":
+ [ { "type": "join"
+ , "$1":
+ [ "HOST_SYSTEM_HDR_DIR='"
+ , { "type": "lookup"
+ , "key": "HOST_SYSTEM_HDR_DIR"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ , "default": ""
+ }
+ , "'"
+ ]
+ }
+ , { "type": "join"
+ , "$1":
+ [ "HOST_SYSTEM_LIB_DIR='"
+ , { "type": "lookup"
+ , "key": "HOST_SYSTEM_LIB_DIR"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ , "default": ""
+ }
+ , "'"
+ ]
+ }
+ , { "type": "join"
+ , "$1":
+ [ "HOST_DYNAMIC_LINKER='"
+ , { "type": "lookup"
+ , "key": "HOST_DYNAMIC_LINKER"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ , "default": ""
+ }
+ , "'"
+ ]
+ }
+ , "export NJOBS=$(nproc --all 2>/dev/null || echo 1)"
+ , "export MAKEINFO=missing"
+ , "export MAKE=${LOCALBASE}/bin/make"
+ , "export PATH=$(pwd)/binutils/bin:${LOCALBASE}/bin:$PATH"
+ , "export BUILD_ROOT_DIR=${ACTION_DIR}"
+ , "unset CFLAGS LDFLAGS"
+ , "CONF_ARGS="
+ , "if [ -n \"$HOST_SYSTEM_HDR_DIR\" ]; then"
+ , " CONF_ARGS=\"$CONF_ARGS --with-sysroot=/ --with-native-system-header-dir=$HOST_SYSTEM_HDR_DIR\""
+ , "fi"
+ , "LINK_ARGS="
+ , "if [ -n \"$HOST_SYSTEM_LIB_DIR\" ]; then"
+ , " export LIBRARY_PATH=\"$HOST_SYSTEM_LIB_DIR\""
+ , " LINK_ARGS=\"$LINK_ARGS -B$HOST_SYSTEM_LIB_DIR -L$HOST_SYSTEM_LIB_DIR\""
+ , " LINK_ARGS=\"$LINK_ARGS -Xlinker -rpath -Xlinker $HOST_SYSTEM_LIB_DIR\""
+ , "fi"
+ , "if [ -n \"$HOST_DYNAMIC_LINKER\" ]; then"
+ , " mv src/gcc/config src/gcc/config.orig"
+ , " cp -r src/gcc/config.orig src/gcc/config"
+ , " chmod -R +w src/gcc/config"
+ , " for h in src/gcc/config/*/*.h; do"
+ , " grep -q _DYNAMIC_LINKER \"$h\" || continue"
+ , " sed -i 's|\\(^#define [A-Z]*_DYNAMIC_LINKER[A-Z0-9]* *\"\\).*\"|\\1'$HOST_DYNAMIC_LINKER'\"|g' \"$h\""
+ , " done"
+ , "fi"
+ , "export LDFLAGS_FOR_TARGET=\"${LINK_ARGS}\""
+ , "if [ -f /lib/ld-musl-$(uname -m).so.1 ]; then"
+ , " ln -s /lib/ld-musl-$(uname -m).so.1 ${TMPDIR}/ldd"
+ , " export PATH=$PATH:${TMPDIR}"
+ , "fi"
+ , "cp -r binutils/. ${DESTDIR}/."
+ , "chmod -R +w ${DESTDIR}/*"
+ , "cd src"
+ , "export check_msgfmt=no # do not use system's msgfmt, if available"
+ , "./configure --prefix=/ --enable-languages=c,c++ --disable-multilib --disable-shared --disable-lto --disable-gcov --disable-libmudflap --disable-libgomp --disable-libssp --disable-nls --disable-libitm ${CONF_ARGS} >configure.log 2>&1 || (cat configure.log && exit 1)"
+ , "${MAKE} -j${NJOBS} >build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "${MAKE} -j${NJOBS} DESTDIR=${DESTDIR} install-strip >>build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "cd ${DESTDIR}"
+ , "for f in $(find . -type f | grep '\\.o$'); do strip -g $f; done"
+ , "for f in $(find . -type f | grep '\\.a$'); do strip -g $f; done"
+ , "cd ${DESTDIR}/bin"
+ , "mv gcc gcc.real"
+ , "mv g++ g++.real"
+ , "printf '#!/bin/sh\\nexport PATH=\"$(dirname $0):$PATH\"\\nexec gcc.real %s \"$@\"' \"${LINK_ARGS}\" >gcc"
+ , "printf '#!/bin/sh\\nexport PATH=\"$(dirname $0):$PATH\"\\nexec g++.real %s \"$@\"' \"${LINK_ARGS}\" >g++"
+ , "chmod +x gcc g++"
+ ]
+ , "out_dirs": ["."]
+ }
+}
diff --git a/src/bootstrap/stage-0-make.TARGETS b/src/bootstrap/stage-0-make.TARGETS
new file mode 100644
index 0000000..3a38240
--- /dev/null
+++ b/src/bootstrap/stage-0-make.TARGETS
@@ -0,0 +1,54 @@
+{ "bootstrap":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "bootstrap-make"
+ }
+, "toolchain":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "make"
+ }
+, "files": {"type": "install", "deps": [["TREE", null, "."]]}
+, "bootstrap-make":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": ["files"]
+ , "localbase": [["@", "busybox", "", "bootstrap"]]
+ , "cmds":
+ [ "export PATH=${LOCALBASE}/bin:$PATH"
+ , "export LD=${CC}"
+ , "export AR=true"
+ , "export RANLIB=true"
+ , "cd ${TMPDIR}"
+ , "${WORKDIR}/configure --prefix=/ --disable-nls --disable-rpath --disable-load --disable-dependency-tracking >configure.log 2>&1 || (cat configure.log && exit 1)"
+ , "./build.sh >build.log 2>&1 || true"
+ , "${CC} -o make $(ls src/*.o lib/*.o | LC_ALL=C sort) >build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "mv make ${DESTDIR}/bin/"
+ ]
+ , "outs": ["bin/make"]
+ }
+, "staged-localbase":
+ { "type": "install"
+ , "dirs":
+ [ [["@", "busybox", "", "toolchain"], "busybox"]
+ , ["bootstrap", "make"]
+ , [["@", "gcc", "", "toolchain"], "gcc"]
+ ]
+ }
+, "make":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": ["files"]
+ , "localbase": ["staged-localbase"]
+ , "cmds":
+ [ "export NJOBS=$(nproc --all 2>/dev/null || echo 1)"
+ , "unset CFLAGS LDFLAGS"
+ , "export PATH=${LOCALBASE}/busybox/bin:${LOCALBASE}/busybox/usr/bin:${LOCALBASE}/make/bin:${LOCALBASE}/gcc/bin:$PATH"
+ , "export MAKE=${LOCALBASE}/make/bin/make"
+ , "export CC=${LOCALBASE}/gcc/bin/gcc"
+ , "export CXX=unused"
+ , "./configure --prefix=/ --disable-rpath --disable-load >configure.log 2>&1 || (cat configure.log && exit 1)"
+ , "${MAKE} -j${NJOBS} MAKEINFO=missing >build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "${MAKE} -j${NJOBS} MAKEINFO=missing DESTDIR=${DESTDIR} install-strip >>build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ ]
+ , "out_dirs": ["."]
+ }
+}
diff --git a/src/bootstrap/stage-1-gcc.TARGETS b/src/bootstrap/stage-1-gcc.TARGETS
new file mode 100644
index 0000000..42282ca
--- /dev/null
+++ b/src/bootstrap/stage-1-gcc.TARGETS
@@ -0,0 +1,156 @@
+{ "toolchain":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "gcc-10.2.0"
+ }
+, "original_sources_and_patches":
+ { "type": "install"
+ , "dirs":
+ [[["TREE", null, "."], "src"], [["@", "patches", "", "gcc-10"], "patches"]]
+ }
+, "patched_sources":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": ["original_sources_and_patches"]
+ , "cmds":
+ [ "cp -r src/. ${DESTDIR}/."
+ , "cd ${DESTDIR}"
+ , "chmod -R +w *"
+ , "patch -p1 < ${WORKDIR}/patches/gcc-10/detect-glibc-via-__GLIBC__.patch >/dev/null"
+ , "for p in $(cat ${WORKDIR}/patches/gcc-10/reproducibility/series); do"
+ , " patch -p1 < ${WORKDIR}/patches/gcc-10/reproducibility/$p >/dev/null"
+ , "done"
+ ]
+ , "out_dirs": ["."]
+ }
+, "patched_separate_sources":
+ { "type": "install"
+ , "dirs":
+ [ ["patched_sources", "src"]
+ , [["@", "gmp", "", "files"], "gmp"]
+ , [["@", "mpc", "", "files"], "mpc"]
+ , [["@", "mpfr", "", "files"], "mpfr"]
+ ]
+ }
+, "binutils":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": [["@", "binutils", "", "files"]]
+ , "cmds":
+ [ "export NJOBS=$(nproc --all 2>/dev/null || echo 1)"
+ , "unset LDFLAGS"
+ , "if [ -f /lib/ld-musl-$(uname -m).so.1 ]; then"
+ , " ln -s /lib/ld-musl-$(uname -m).so.1 ${TMPDIR}/ldd"
+ , " export PATH=$PATH:${TMPDIR}"
+ , "fi"
+ , "mkdir build"
+ , "cd build"
+ , "../configure --prefix=/ --disable-nls --enable-gprofng=no --disable-werror --enable-deterministic-archives >configure.log 2>&1 || (cat configure.log && exit 1)"
+ , "${MAKE} -j${NJOBS} MAKEINFO=true >build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "${MAKE} -j${NJOBS} MAKEINFO=true DESTDIR=${DESTDIR} install-strip >>build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "find ${DESTDIR} -type f -name '*.la' -exec sed -i 's|'$(pwd)'|/build|g' {} \\;"
+ ]
+ , "out_dirs": ["."]
+ }
+, "gcc-10.2.0":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "arguments_config": ["TOOLCHAIN_CONFIG"]
+ , "project": ["patched_separate_sources"]
+ , "localbase": ["binutils"]
+ , "cmds":
+ [ { "type": "join"
+ , "$1":
+ [ "HOST_SYSTEM_HDR_DIR='"
+ , { "type": "lookup"
+ , "key": "HOST_SYSTEM_HDR_DIR"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ , "default": ""
+ }
+ , "'"
+ ]
+ }
+ , { "type": "join"
+ , "$1":
+ [ "HOST_SYSTEM_LIB_DIR='"
+ , { "type": "lookup"
+ , "key": "HOST_SYSTEM_LIB_DIR"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ , "default": ""
+ }
+ , "'"
+ ]
+ }
+ , { "type": "join"
+ , "$1":
+ [ "HOST_DYNAMIC_LINKER='"
+ , { "type": "lookup"
+ , "key": "HOST_DYNAMIC_LINKER"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ , "default": ""
+ }
+ , "'"
+ ]
+ }
+ , "export NJOBS=$(nproc --all 2>/dev/null || echo 1)"
+ , "export PATH=${LOCALBASE}/bin:$PATH"
+ , "export BUILD_ROOT_DIR=${ACTION_DIR}"
+ , "unset CFLAGS LDFLAGS"
+ , "CONF_ARGS="
+ , "if [ -n \"$HOST_SYSTEM_HDR_DIR\" ]; then"
+ , " CONF_ARGS=\"$CONF_ARGS --with-sysroot=/ --with-native-system-header-dir=$HOST_SYSTEM_HDR_DIR\""
+ , "fi"
+ , "LINK_ARGS="
+ , "if [ -n \"$HOST_SYSTEM_LIB_DIR\" ]; then"
+ , " export LIBRARY_PATH=\"$HOST_SYSTEM_LIB_DIR\""
+ , " LINK_ARGS=\"$LINK_ARGS -B$HOST_SYSTEM_LIB_DIR -L$HOST_SYSTEM_LIB_DIR\""
+ , " LINK_ARGS=\"$LINK_ARGS -Xlinker -rpath -Xlinker $HOST_SYSTEM_LIB_DIR\""
+ , "fi"
+ , "if [ -n \"$HOST_DYNAMIC_LINKER\" ]; then"
+ , " mv src/gcc/config src/gcc/config.orig"
+ , " cp -r src/gcc/config.orig src/gcc/config"
+ , " chmod -R +w src/gcc/config"
+ , " for h in src/gcc/config/*/*.h; do"
+ , " grep -q _DYNAMIC_LINKER \"$h\" || continue"
+ , " sed -i 's|\\(^#define [A-Z]*_DYNAMIC_LINKER[A-Z0-9]* *\"\\).*\"|\\1'$HOST_DYNAMIC_LINKER'\"|g' \"$h\""
+ , " done"
+ , "fi"
+ , "export LDFLAGS_FOR_TARGET=\"${LINK_ARGS}\""
+ , "if [ -f /lib/ld-musl-$(uname -m).so.1 ]; then"
+ , " ln -s /lib/ld-musl-$(uname -m).so.1 ${TMPDIR}/ldd"
+ , " export PATH=$PATH:${TMPDIR}"
+ , "fi"
+ , "cp -r ${LOCALBASE}/. ${DESTDIR}/."
+ , "chmod -R +w ${DESTDIR}/*"
+ , "mv gmp mpc mpfr src/."
+ , "cd src"
+ , "export check_msgfmt=no # do not use system's msgfmt, if available"
+ , "./configure --prefix=/ --enable-checking=release --enable-languages=c,c++ --disable-multilib --disable-libsanitizer ${CONF_ARGS} >configure.log 2>&1 || (cat configure.log && exit 1)"
+ , "${MAKE} -j${NJOBS} >build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "${MAKE} -j${NJOBS} DESTDIR=${DESTDIR} install-strip >>build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "cd ${DESTDIR}"
+ , "strip ./bin/*"
+ , "find . -type f -name '*.so*' -exec sh -c \"strip {} 2>/dev/null\" \\;"
+ , "find . -type f -name '*.a' -exec sh -c \"strip -g {}\" \\;"
+ , "find . -type f -name '*.o' -exec sh -c \"strip -g {}\" \\;"
+ , "if [ -n \"${LINK_ARGS}\" ]; then"
+ , " cd ${DESTDIR}/bin"
+ , " mv gcc gcc.real"
+ , " mv g++ g++.real"
+ , " printf '#!/bin/sh\\nexec $(dirname $0)/gcc.real %s \"$@\"' \"${LINK_ARGS}\" >gcc"
+ , " printf '#!/bin/sh\\nexec $(dirname $0)/g++.real %s \"$@\"' \"${LINK_ARGS}\" >g++"
+ , " chmod +x gcc g++"
+ , "fi"
+ ]
+ , "out_dirs": ["."]
+ }
+}
diff --git a/src/compilers/clang-16-native.TARGETS b/src/compilers/clang-16-native.TARGETS
new file mode 100644
index 0000000..1b256fc
--- /dev/null
+++ b/src/compilers/clang-16-native.TARGETS
@@ -0,0 +1,226 @@
+{ "toolchain":
+ { "type": "configure"
+ , "arguments_config": ["ARCH", "TARGET_ARCH", "BUILD_ARCH"]
+ , "config":
+ { "type": "if"
+ , "cond":
+ { "type": "=="
+ , "$1":
+ { "type": "var"
+ , "name": "TARGET_ARCH"
+ , "default": {"type": "var", "name": "ARCH"}
+ }
+ , "$2":
+ { "type": "var"
+ , "name": "BUILD_ARCH"
+ , "default": {"type": "var", "name": "ARCH"}
+ }
+ }
+ , "then": {"type": "empty_map"}
+ , "else":
+ { "type": "fail"
+ , "msg": "clang-native does not support cross-compilation."
+ }
+ }
+ , "target": "toolchain_native"
+ }
+, "toolchain_native":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "clang-native"
+ }
+, "runlibs":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "libstdc++"
+ }
+, "runlibs_libcxx":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "libc++"
+ }
+, "original_sources_and_patches":
+ { "type": "install"
+ , "dirs":
+ [ [["TREE", null, "."], "src"]
+ , [["@", "patches", "", "clang-16"], "patches"]
+ ]
+ }
+, "patched_sources":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": ["original_sources_and_patches"]
+ , "cmds":
+ [ "cp -r src/. ${DESTDIR}/."
+ , "cd ${DESTDIR}"
+ , "chmod -R +w *"
+ , "patch -p1 < ${WORKDIR}/patches/clang-16/libcxx-musl-support.patch >/dev/null"
+ ]
+ , "out_dirs": ["."]
+ }
+, "clang-native":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "arguments_config": ["TOOLCHAIN_CONFIG"]
+ , "project": ["patched_sources"]
+ , "localbase": [["@", "binutils", "", "binutils"]]
+ , "cmds":
+ [ { "type": "join"
+ , "$1":
+ [ "HOST_SYSTEM_HDR_DIR='"
+ , { "type": "lookup"
+ , "key": "HOST_SYSTEM_HDR_DIR"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ , "default": ""
+ }
+ , "'"
+ ]
+ }
+ , { "type": "join"
+ , "$1":
+ [ "HOST_SYSTEM_LIB_DIR='"
+ , { "type": "lookup"
+ , "key": "HOST_SYSTEM_LIB_DIR"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ , "default": ""
+ }
+ , "'"
+ ]
+ }
+ , { "type": "join"
+ , "$1":
+ [ "HOST_DYNAMIC_LINKER='"
+ , { "type": "lookup"
+ , "key": "HOST_DYNAMIC_LINKER"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ , "default": ""
+ }
+ , "'"
+ ]
+ }
+ , "NJOBS=$(nproc --all 2>/dev/null || echo 1)"
+ , "HOST_TRIPLE=$(${CC} -dumpmachine)"
+ , "GCC_TOOLCHAIN=$(dirname ${CC})/.."
+ , "export PATH=${LOCALBASE}/bin:$PATH"
+ , "export PKG_CONFIG=false"
+ , "export LD_LIBRARY_PATH=\"${GCC_TOOLCHAIN}/lib:${GCC_TOOLCHAIN}/lib32:${GCC_TOOLCHAIN}/lib64\""
+ , "unset LDFLAGS"
+ , "CONF_ARGS="
+ , "INCL_ARGS="
+ , "if [ -n \"$HOST_SYSTEM_HDR_DIR\" ]; then"
+ , " CONF_ARGS=\"-DC_INCLUDE_DIRS=$HOST_SYSTEM_HDR_DIR\""
+ , " INCL_ARGS=\"-I$HOST_SYSTEM_HDR_DIR\""
+ , "fi"
+ , "LINK_ARGS="
+ , "if [ -n \"$HOST_SYSTEM_LIB_DIR\" ]; then"
+ , " export LIBRARY_PATH=\"$HOST_SYSTEM_LIB_DIR\""
+ , " LINK_ARGS=\"$LINK_ARGS -B$HOST_SYSTEM_LIB_DIR -L$HOST_SYSTEM_LIB_DIR\""
+ , " LINK_ARGS=\"$LINK_ARGS -Xlinker -rpath -Xlinker $HOST_SYSTEM_LIB_DIR\""
+ , "fi"
+ , "if [ -n \"$HOST_DYNAMIC_LINKER\" ]; then"
+ , " LINK_ARGS=\"$LINK_ARGS -Xlinker --dynamic-linker -Xlinker $HOST_DYNAMIC_LINKER\""
+ , "fi"
+ , "cp -r ${LOCALBASE}/. ${DESTDIR}/."
+ , "chmod -R +w ${DESTDIR}/*"
+ , "mkdir build"
+ , "cmake -B build -S llvm ${CONF_ARGS} -DLLVM_USE_FOLDERS=OFF -DLLVM_INCLUDE_DOCS=OFF -DLLVM_INCLUDE_TESTS=OFF -DLLVM_INSTALL_TOOLCHAIN_ONLY=ON -DLLVM_ENABLE_PROJECTS=clang -DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi;libunwind' -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_PARALLEL_LINK_JOBS=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX= -DLLVM_HOST_TRIPLE=${HOST_TRIPLE} -DLLVM_NATIVE_TARGET=ON -DLIBCXXABI_ENABLE_ASSERTIONS=OFF -DLIBUNWIND_ENABLE_ASSERTIONS=OFF >configure.log 2>&1 || (cat configure.log && exit 1)"
+ , "cmake --build build --target clang -j${NJOBS} >build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "export LDFLAGS=\"--gcc-toolchain=${GCC_TOOLCHAIN} ${LINK_ARGS}\""
+ , "cmake --build build --target all -j${NJOBS} >>build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "cmake --build build --target install -j${NJOBS} >>build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "cd ${DESTDIR}"
+ , "strip ./bin/* 2>/dev/null || true"
+ , "find . -type f -name '*.so*' -exec sh -c \"strip {} 2>/dev/null\" \\;"
+ , "find . -type f -name '*.a' -exec sh -c \"strip -g {}\" \\;"
+ , "find . -type f -name '*.o' -exec sh -c \"strip -g {}\" \\;"
+ , "cp -r ${GCC_TOOLCHAIN}/include ${GCC_TOOLCHAIN}/lib* ${DESTDIR}/."
+ , "cp -rl ${DESTDIR}/lib[0-9]*/* ${DESTDIR}/lib/."
+ , "if [ -n \"${INCL_ARGS}${LINK_ARGS}\" ]; then"
+ , " cd ${DESTDIR}/bin"
+ , " mv clang clang.real"
+ , " mv clang++ clang++.real"
+ , " printf '#!/bin/sh\\nexec $(dirname $0)/clang.real %s \"$@\"' \"${INCL_ARGS} ${LINK_ARGS}\" >clang"
+ , " printf '#!/bin/sh\\nexec $(dirname $0)/clang++.real %s \"$@\"' \"${INCL_ARGS} ${LINK_ARGS}\" >clang++"
+ , " chmod +x clang clang++"
+ , "fi"
+ ]
+ , "out_dirs": ["."]
+ }
+, "libstdc++":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["libstdc++"]
+ , "lib": ["libstdc++_files"]
+ , "deps": ["libgcc_s"]
+ }
+, "libc++":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["libc++"]
+ , "lib": ["libc++_files"]
+ , "deps": ["libgcc_s", "libatomic", "libc++abi"]
+ }
+, "libc++abi":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["libc++abi"]
+ , "lib": ["libc++abi_files"]
+ }
+, "libgcc_s":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["libgcc_s"]
+ , "lib": ["libgcc_s_files"]
+ }
+, "libatomic":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["libatomic"]
+ , "lib": ["libatomic_files"]
+ }
+, "libstdc++_files":
+ { "type": "generic"
+ , "arguments_config": ["ENV"]
+ , "deps": ["toolchain"]
+ , "cmds": [":"]
+ , "outs": ["lib64/libstdc++.so.6"]
+ , "env": {"type": "var", "name": "ENV", "default": {"type": "empty_map"}}
+ }
+, "libc++_files":
+ { "type": "generic"
+ , "arguments_config": ["ENV"]
+ , "deps": ["toolchain"]
+ , "cmds": ["cp lib/$(uname -m)-*/libc++.so.1 ."]
+ , "outs": ["libc++.so.1"]
+ , "env": {"type": "var", "name": "ENV", "default": {"type": "empty_map"}}
+ }
+, "libc++abi_files":
+ { "type": "generic"
+ , "arguments_config": ["ENV"]
+ , "deps": ["toolchain"]
+ , "cmds": ["cp lib/$(uname -m)-*/libc++abi.so.1 ."]
+ , "outs": ["libc++abi.so.1"]
+ , "env": {"type": "var", "name": "ENV", "default": {"type": "empty_map"}}
+ }
+, "libgcc_s_files":
+ { "type": "generic"
+ , "arguments_config": ["ENV"]
+ , "deps": ["toolchain"]
+ , "cmds": [":"]
+ , "outs": ["lib64/libgcc_s.so.1"]
+ , "env": {"type": "var", "name": "ENV", "default": {"type": "empty_map"}}
+ }
+, "libatomic_files":
+ { "type": "generic"
+ , "arguments_config": ["ENV"]
+ , "deps": ["toolchain"]
+ , "cmds": [":"]
+ , "outs": ["lib64/libatomic.so.1"]
+ , "env": {"type": "var", "name": "ENV", "default": {"type": "empty_map"}}
+ }
+}
diff --git a/src/compilers/clang-17-native.TARGETS b/src/compilers/clang-17-native.TARGETS
new file mode 100644
index 0000000..64ff374
--- /dev/null
+++ b/src/compilers/clang-17-native.TARGETS
@@ -0,0 +1,226 @@
+{ "toolchain":
+ { "type": "configure"
+ , "arguments_config": ["ARCH", "TARGET_ARCH", "BUILD_ARCH"]
+ , "config":
+ { "type": "if"
+ , "cond":
+ { "type": "=="
+ , "$1":
+ { "type": "var"
+ , "name": "TARGET_ARCH"
+ , "default": {"type": "var", "name": "ARCH"}
+ }
+ , "$2":
+ { "type": "var"
+ , "name": "BUILD_ARCH"
+ , "default": {"type": "var", "name": "ARCH"}
+ }
+ }
+ , "then": {"type": "empty_map"}
+ , "else":
+ { "type": "fail"
+ , "msg": "clang-native does not support cross-compilation."
+ }
+ }
+ , "target": "toolchain_native"
+ }
+, "toolchain_native":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "clang-native"
+ }
+, "runlibs":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "libstdc++"
+ }
+, "runlibs_libcxx":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "libc++"
+ }
+, "original_sources_and_patches":
+ { "type": "install"
+ , "dirs":
+ [ [["TREE", null, "."], "src"]
+ , [["@", "patches", "", "clang-17"], "patches"]
+ ]
+ }
+, "patched_sources":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": ["original_sources_and_patches"]
+ , "cmds":
+ [ "cp -r src/. ${DESTDIR}/."
+ , "cd ${DESTDIR}"
+ , "chmod -R +w *"
+ , "patch -p1 < ${WORKDIR}/patches/clang-17/libcxx-musl-support.patch >/dev/null"
+ ]
+ , "out_dirs": ["."]
+ }
+, "clang-native":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "arguments_config": ["TOOLCHAIN_CONFIG"]
+ , "project": ["patched_sources"]
+ , "localbase": [["@", "binutils", "", "binutils"]]
+ , "cmds":
+ [ { "type": "join"
+ , "$1":
+ [ "HOST_SYSTEM_HDR_DIR='"
+ , { "type": "lookup"
+ , "key": "HOST_SYSTEM_HDR_DIR"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ , "default": ""
+ }
+ , "'"
+ ]
+ }
+ , { "type": "join"
+ , "$1":
+ [ "HOST_SYSTEM_LIB_DIR='"
+ , { "type": "lookup"
+ , "key": "HOST_SYSTEM_LIB_DIR"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ , "default": ""
+ }
+ , "'"
+ ]
+ }
+ , { "type": "join"
+ , "$1":
+ [ "HOST_DYNAMIC_LINKER='"
+ , { "type": "lookup"
+ , "key": "HOST_DYNAMIC_LINKER"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ , "default": ""
+ }
+ , "'"
+ ]
+ }
+ , "NJOBS=$(nproc --all 2>/dev/null || echo 1)"
+ , "HOST_TRIPLE=$(${CC} -dumpmachine)"
+ , "GCC_TOOLCHAIN=$(dirname ${CC})/.."
+ , "export PATH=${LOCALBASE}/bin:$PATH"
+ , "export PKG_CONFIG=false"
+ , "export LD_LIBRARY_PATH=\"${GCC_TOOLCHAIN}/lib:${GCC_TOOLCHAIN}/lib32:${GCC_TOOLCHAIN}/lib64\""
+ , "unset LDFLAGS"
+ , "CONF_ARGS="
+ , "INCL_ARGS="
+ , "if [ -n \"$HOST_SYSTEM_HDR_DIR\" ]; then"
+ , " CONF_ARGS=\"-DC_INCLUDE_DIRS=$HOST_SYSTEM_HDR_DIR\""
+ , " INCL_ARGS=\"-I$HOST_SYSTEM_HDR_DIR\""
+ , "fi"
+ , "LINK_ARGS="
+ , "if [ -n \"$HOST_SYSTEM_LIB_DIR\" ]; then"
+ , " export LIBRARY_PATH=\"$HOST_SYSTEM_LIB_DIR\""
+ , " LINK_ARGS=\"$LINK_ARGS -B$HOST_SYSTEM_LIB_DIR -L$HOST_SYSTEM_LIB_DIR\""
+ , " LINK_ARGS=\"$LINK_ARGS -Xlinker -rpath -Xlinker $HOST_SYSTEM_LIB_DIR\""
+ , "fi"
+ , "if [ -n \"$HOST_DYNAMIC_LINKER\" ]; then"
+ , " LINK_ARGS=\"$LINK_ARGS -Xlinker --dynamic-linker -Xlinker $HOST_DYNAMIC_LINKER\""
+ , "fi"
+ , "cp -r ${LOCALBASE}/. ${DESTDIR}/."
+ , "chmod -R +w ${DESTDIR}/*"
+ , "mkdir build"
+ , "cmake -B build -S llvm ${CONF_ARGS} -DLLVM_USE_FOLDERS=OFF -DLLVM_INCLUDE_DOCS=OFF -DLLVM_INCLUDE_TESTS=OFF -DLLVM_INSTALL_TOOLCHAIN_ONLY=ON -DLLVM_ENABLE_PROJECTS=clang -DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi;libunwind' -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_PARALLEL_LINK_JOBS=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX= -DLLVM_HOST_TRIPLE=${HOST_TRIPLE} -DLLVM_NATIVE_TARGET=ON -DLIBCXXABI_ENABLE_ASSERTIONS=OFF -DLIBUNWIND_ENABLE_ASSERTIONS=OFF >configure.log 2>&1 || (cat configure.log && exit 1)"
+ , "cmake --build build --target clang -j${NJOBS} >build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "export LDFLAGS=\"--gcc-toolchain=${GCC_TOOLCHAIN} ${LINK_ARGS}\""
+ , "cmake --build build --target all -j${NJOBS} >>build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "cmake --build build --target install -j${NJOBS} >>build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "cd ${DESTDIR}"
+ , "strip ./bin/* 2>/dev/null || true"
+ , "find . -type f -name '*.so*' -exec sh -c \"strip {} 2>/dev/null\" \\;"
+ , "find . -type f -name '*.a' -exec sh -c \"strip -g {}\" \\;"
+ , "find . -type f -name '*.o' -exec sh -c \"strip -g {}\" \\;"
+ , "cp -r ${GCC_TOOLCHAIN}/include ${GCC_TOOLCHAIN}/lib* ${DESTDIR}/."
+ , "cp -rl ${DESTDIR}/lib[0-9]*/* ${DESTDIR}/lib/."
+ , "if [ -n \"${INCL_ARGS}${LINK_ARGS}\" ]; then"
+ , " cd ${DESTDIR}/bin"
+ , " mv clang clang.real"
+ , " mv clang++ clang++.real"
+ , " printf '#!/bin/sh\\nexec $(dirname $0)/clang.real %s \"$@\"' \"${INCL_ARGS} ${LINK_ARGS}\" >clang"
+ , " printf '#!/bin/sh\\nexec $(dirname $0)/clang++.real %s \"$@\"' \"${INCL_ARGS} ${LINK_ARGS}\" >clang++"
+ , " chmod +x clang clang++"
+ , "fi"
+ ]
+ , "out_dirs": ["."]
+ }
+, "libstdc++":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["libstdc++"]
+ , "lib": ["libstdc++_files"]
+ , "deps": ["libgcc_s"]
+ }
+, "libc++":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["libc++"]
+ , "lib": ["libc++_files"]
+ , "deps": ["libgcc_s", "libatomic", "libc++abi"]
+ }
+, "libc++abi":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["libc++abi"]
+ , "lib": ["libc++abi_files"]
+ }
+, "libgcc_s":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["libgcc_s"]
+ , "lib": ["libgcc_s_files"]
+ }
+, "libatomic":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["libatomic"]
+ , "lib": ["libatomic_files"]
+ }
+, "libstdc++_files":
+ { "type": "generic"
+ , "arguments_config": ["ENV"]
+ , "deps": ["toolchain"]
+ , "cmds": [":"]
+ , "outs": ["lib64/libstdc++.so.6"]
+ , "env": {"type": "var", "name": "ENV", "default": {"type": "empty_map"}}
+ }
+, "libc++_files":
+ { "type": "generic"
+ , "arguments_config": ["ENV"]
+ , "deps": ["toolchain"]
+ , "cmds": ["cp lib/$(uname -m)-*/libc++.so.1 ."]
+ , "outs": ["libc++.so.1"]
+ , "env": {"type": "var", "name": "ENV", "default": {"type": "empty_map"}}
+ }
+, "libc++abi_files":
+ { "type": "generic"
+ , "arguments_config": ["ENV"]
+ , "deps": ["toolchain"]
+ , "cmds": ["cp lib/$(uname -m)-*/libc++abi.so.1 ."]
+ , "outs": ["libc++abi.so.1"]
+ , "env": {"type": "var", "name": "ENV", "default": {"type": "empty_map"}}
+ }
+, "libgcc_s_files":
+ { "type": "generic"
+ , "arguments_config": ["ENV"]
+ , "deps": ["toolchain"]
+ , "cmds": [":"]
+ , "outs": ["lib64/libgcc_s.so.1"]
+ , "env": {"type": "var", "name": "ENV", "default": {"type": "empty_map"}}
+ }
+, "libatomic_files":
+ { "type": "generic"
+ , "arguments_config": ["ENV"]
+ , "deps": ["toolchain"]
+ , "cmds": [":"]
+ , "outs": ["lib64/libatomic.so.1"]
+ , "env": {"type": "var", "name": "ENV", "default": {"type": "empty_map"}}
+ }
+}
diff --git a/src/compilers/gcc-13-musl-static.TARGETS b/src/compilers/gcc-13-musl-static.TARGETS
new file mode 100644
index 0000000..d7cefea
--- /dev/null
+++ b/src/compilers/gcc-13-musl-static.TARGETS
@@ -0,0 +1,121 @@
+{ "toolchain":
+ { "type": "configure"
+ , "arguments_config": ["ARCH", "BUILD_ARCH"]
+ , "config":
+ { "type": "singleton_map"
+ , "key": "BUILD_ARCH"
+ , "value":
+ { "type": "var"
+ , "name": "BUILD_ARCH"
+ , "default":
+ { "type": "var"
+ , "name": "ARCH"
+ , "default":
+ {"type": "fail", "msg": "ARCH is required for cross-compiler."}
+ }
+ }
+ }
+ , "target": "toolchain_cross"
+ }
+, "toolchain_cross":
+ { "type": "export"
+ , "flexible_config":
+ ["ARCH", "TARGET_ARCH", "BUILD_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "gcc-musl-static"
+ }
+, "runlibs":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "libgcc_s"
+ }
+, "gcc-musl-static":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": [["@", "gcc-musl", "", "combined_patched_sources"]]
+ , "arguments_config": ["BUILD_ARCH"]
+ , "cmds":
+ { "type": "let*"
+ , "bindings":
+ [ [ "TARGET"
+ , { "type": "case"
+ , "expr":
+ { "type": "var"
+ , "name": "BUILD_ARCH"
+ , "default": {"type": "fail", "msg": "BUILD_ARCH is missing."}
+ }
+ , "case":
+ { "x86": "i686"
+ , "x86_64": "x86_64"
+ , "arm": "arm"
+ , "arm64": "aarch64"
+ }
+ , "default":
+ { "type": "fail"
+ , "msg":
+ ["Unsupported BUILD_ARCH", {"type": "var", "name": "BUILD_ARCH"}]
+ }
+ }
+ ]
+ ]
+ , "body":
+ [ { "type": "join"
+ , "$1": ["TARGET=", {"type": "var", "name": "TARGET"}, "-linux-musl"]
+ }
+ , "export NJOBS=$(nproc --all 2>/dev/null || echo 1)"
+ , "export MAKEINFO=missing"
+ , "unset CFLAGS CXXFLAGS LDFLAGS"
+ , "printf '#!/bin/sh\\nexec \"%s\" -static \"$@\"' \"${CC}\" >${TMPDIR}/cc"
+ , "printf '#!/bin/sh\\nexec \"%s\" -static \"$@\"' \"${CXX}\" >${TMPDIR}/c++"
+ , "chmod +x ${TMPDIR}/cc ${TMPDIR}/c++"
+ , "mv musl-latest.orig musl.readonly"
+ , "cp -r musl.readonly musl-latest.orig && chmod -R +w musl-latest.orig"
+ , "export check_msgfmt=no # do not use system's msgfmt, if available"
+ , "${MAKE} -j${NJOBS} TARGET=${TARGET} CC=${TMPDIR}/cc CXX=${TMPDIR}/c++ LDFLAGS='-static' LDFLAGS_FOR_TARGET='-static' >build.log 2>&1 || (cat build.log && exit 1)"
+ , "${MAKE} -j${NJOBS} TARGET=${TARGET} CC=${TMPDIR}/cc CXX=${TMPDIR}/c++ LDFLAGS='-static' LDFLAGS_FOR_TARGET='-static' OUTPUT= DESTDIR=${DESTDIR} install >>build.log 2>&1 || (cat build.log && exit 1)"
+ , "cd ${DESTDIR}"
+ , "TARGET_STRIP=./bin/${TARGET}-strip"
+ , "find ./bin/ ./${TARGET}/bin/ ./libexec/gcc/ -type f -exec sh -c \"strip {} 2>/dev/null\" \\;"
+ , "find . -type f -name '*.so*' -exec sh -c \"${TARGET_STRIP} {} 2>/dev/null\" \\;"
+ , "find . -type f -name '*.a' -exec sh -c \"${TARGET_STRIP} -g {}\" \\;"
+ , "find . -type f -name '*.o' -exec sh -c \"${TARGET_STRIP} -g {}\" \\;"
+ , "for f in $(ls ./bin/${TARGET}-*); do"
+ , " cp -l $f $(echo $f | sed 's|/'${TARGET}-'|/|g')"
+ , "done"
+ , "cp -rl ./${TARGET}/lib/. ./lib/."
+ , "find . -type l ! -exec test -e {} \\; -delete"
+ ]
+ }
+ , "out_dirs": ["."]
+ }
+, "toolchain_for_target":
+ { "type": "configure"
+ , "arguments_config": ["ARCH", "TARGET_ARCH"]
+ , "config":
+ { "type": "singleton_map"
+ , "key": "BUILD_ARCH"
+ , "value":
+ { "type": "var"
+ , "name": "TARGET_ARCH"
+ , "default":
+ { "type": "var"
+ , "name": "ARCH"
+ , "default":
+ {"type": "fail", "msg": "ARCH is required for cross-compiler."}
+ }
+ }
+ }
+ , "target": "toolchain_cross"
+ }
+, "libgcc_s":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["libgcc"]
+ , "lib": ["libgcc_s_files"]
+ }
+, "libgcc_s_files":
+ { "type": "generic"
+ , "arguments_config": ["ENV"]
+ , "deps": ["toolchain_for_target"]
+ , "cmds": [":"]
+ , "outs": ["lib/libgcc_s.so.1"]
+ , "env": {"type": "var", "name": "ENV", "default": {"type": "empty_map"}}
+ }
+}
diff --git a/src/compilers/gcc-13-musl.TARGETS b/src/compilers/gcc-13-musl.TARGETS
new file mode 100644
index 0000000..90d7987
--- /dev/null
+++ b/src/compilers/gcc-13-musl.TARGETS
@@ -0,0 +1,161 @@
+{ "toolchain":
+ { "type": "configure"
+ , "arguments_config": ["ARCH", "BUILD_ARCH"]
+ , "config":
+ { "type": "singleton_map"
+ , "key": "BUILD_ARCH"
+ , "value":
+ { "type": "var"
+ , "name": "BUILD_ARCH"
+ , "default":
+ { "type": "var"
+ , "name": "ARCH"
+ , "default":
+ {"type": "fail", "msg": "ARCH is required for cross-compiler."}
+ }
+ }
+ }
+ , "target": "toolchain_cross"
+ }
+, "toolchain_cross":
+ { "type": "export"
+ , "flexible_config":
+ ["ARCH", "TARGET_ARCH", "BUILD_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "gcc-musl"
+ }
+, "runlibs":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "libstdc++"
+ }
+, "separate_patched_sources":
+ { "type": "install"
+ , "dirs":
+ [ [["@", "musl-cross-make", "", "combined_sources_and_patches"], "src"]
+ , [["@", "binutils", "", "files"], "binutils"]
+ , [["@", "musl", "", "files"], "musl"]
+ , [["@", "gmp", "", "files"], "gmp"]
+ , [["@", "mpc", "", "files"], "mpc"]
+ , [["@", "mpfr", "", "files"], "mpfr"]
+ , [["@", "gcc", "", "patched_sources"], "gcc"]
+ ]
+ }
+, "combined_patched_sources":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": ["separate_patched_sources"]
+ , "cmds":
+ [ "cp -r src/. ${DESTDIR}"
+ , "mv binutils ${DESTDIR}/binutils-latest.orig"
+ , "mv musl ${DESTDIR}/musl-latest.orig"
+ , "mv gmp ${DESTDIR}/gmp-latest.orig"
+ , "mv mpc ${DESTDIR}/mpc-latest.orig"
+ , "mv mpfr ${DESTDIR}/mpfr-latest.orig"
+ , "mv gcc ${DESTDIR}/gcc-13.orig"
+ , "chmod +w ${DESTDIR}/config.mak"
+ , "printf 'GCC_VER = 13\n' >> ${DESTDIR}/config.mak"
+ ]
+ , "out_dirs": ["."]
+ }
+, "gcc-musl":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": ["combined_patched_sources"]
+ , "arguments_config": ["BUILD_ARCH"]
+ , "cmds":
+ { "type": "let*"
+ , "bindings":
+ [ [ "TARGET"
+ , { "type": "case"
+ , "expr":
+ { "type": "var"
+ , "name": "BUILD_ARCH"
+ , "default": {"type": "fail", "msg": "BUILD_ARCH is missing."}
+ }
+ , "case":
+ { "x86": "i686"
+ , "x86_64": "x86_64"
+ , "arm": "arm"
+ , "arm64": "aarch64"
+ }
+ , "default":
+ { "type": "fail"
+ , "msg":
+ ["Unsupported BUILD_ARCH", {"type": "var", "name": "BUILD_ARCH"}]
+ }
+ }
+ ]
+ ]
+ , "body":
+ [ { "type": "join"
+ , "$1": ["TARGET=", {"type": "var", "name": "TARGET"}, "-linux-musl"]
+ }
+ , "export NJOBS=$(nproc --all 2>/dev/null || echo 1)"
+ , "export MAKEINFO=missing"
+ , "export BUILD_ROOT_DIR=${ACTION_DIR}"
+ , "unset CFLAGS CXXFLAGS LDFLAGS"
+ , "mv musl-latest.orig musl.readonly"
+ , "cp -r musl.readonly musl-latest.orig && chmod -R +w musl-latest.orig"
+ , "export check_msgfmt=no # do not use system's msgfmt, if available"
+ , "${MAKE} -j${NJOBS} TARGET=${TARGET} >build.log 2>&1 || (cat build.log && exit 1)"
+ , "${MAKE} -j${NJOBS} TARGET=${TARGET} OUTPUT= DESTDIR=${DESTDIR} install >>build.log 2>&1 || (cat build.log && exit 1)"
+ , "cd ${DESTDIR}"
+ , "TARGET_STRIP=./bin/${TARGET}-strip"
+ , "find ./bin/ ./${TARGET}/bin/ ./libexec/gcc/ -type f -exec sh -c \"strip {} 2>/dev/null\" \\;"
+ , "find . -type f -name '*.so*' -exec sh -c \"${TARGET_STRIP} {} 2>/dev/null\" \\;"
+ , "find . -type f -name '*.a' -exec sh -c \"${TARGET_STRIP} -g {}\" \\;"
+ , "find . -type f -name '*.o' -exec sh -c \"${TARGET_STRIP} -g {}\" \\;"
+ , "for f in $(ls ./bin/${TARGET}-*); do"
+ , " cp -l $f $(echo $f | sed 's|/'${TARGET}-'|/|g')"
+ , "done"
+ , "cp -rl ./${TARGET}/lib/. ./lib/."
+ , "find . -type l ! -exec test -e {} \\; -delete"
+ ]
+ }
+ , "out_dirs": ["."]
+ }
+, "toolchain_for_target":
+ { "type": "configure"
+ , "arguments_config": ["ARCH", "TARGET_ARCH"]
+ , "config":
+ { "type": "singleton_map"
+ , "key": "BUILD_ARCH"
+ , "value":
+ { "type": "var"
+ , "name": "TARGET_ARCH"
+ , "default":
+ { "type": "var"
+ , "name": "ARCH"
+ , "default":
+ {"type": "fail", "msg": "ARCH is required for cross-compiler."}
+ }
+ }
+ }
+ , "target": "toolchain_cross"
+ }
+, "libstdc++":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["libstdc++"]
+ , "lib": ["libstdc++_files"]
+ , "deps": ["libgcc_s"]
+ }
+, "libgcc_s":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["libgcc_s"]
+ , "lib": ["libgcc_s_files"]
+ }
+, "libstdc++_files":
+ { "type": "generic"
+ , "arguments_config": ["ENV"]
+ , "deps": ["toolchain_for_target"]
+ , "cmds": [":"]
+ , "outs": ["lib/libstdc++.so.6"]
+ , "env": {"type": "var", "name": "ENV", "default": {"type": "empty_map"}}
+ }
+, "libgcc_s_files":
+ { "type": "generic"
+ , "arguments_config": ["ENV"]
+ , "deps": ["toolchain_for_target"]
+ , "cmds": [":"]
+ , "outs": ["lib/libgcc_s.so.1"]
+ , "env": {"type": "var", "name": "ENV", "default": {"type": "empty_map"}}
+ }
+}
diff --git a/src/compilers/gcc-13-native.TARGETS b/src/compilers/gcc-13-native.TARGETS
new file mode 100644
index 0000000..3b79d36
--- /dev/null
+++ b/src/compilers/gcc-13-native.TARGETS
@@ -0,0 +1,193 @@
+{ "toolchain":
+ { "type": "configure"
+ , "arguments_config": ["ARCH", "TARGET_ARCH", "BUILD_ARCH"]
+ , "config":
+ { "type": "if"
+ , "cond":
+ { "type": "=="
+ , "$1":
+ { "type": "var"
+ , "name": "TARGET_ARCH"
+ , "default": {"type": "var", "name": "ARCH"}
+ }
+ , "$2":
+ { "type": "var"
+ , "name": "BUILD_ARCH"
+ , "default": {"type": "var", "name": "ARCH"}
+ }
+ }
+ , "then": {"type": "empty_map"}
+ , "else":
+ {"type": "fail", "msg": "gcc-native does not support cross-compilation."}
+ }
+ , "target": "toolchain_native"
+ }
+, "toolchain_native":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "gcc-native"
+ }
+, "runlibs":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "libstdc++"
+ }
+, "original_sources_and_patches":
+ { "type": "install"
+ , "dirs":
+ [[["TREE", null, "."], "src"], [["@", "patches", "", "gcc-13"], "patches"]]
+ }
+, "patched_sources":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": ["original_sources_and_patches"]
+ , "cmds":
+ [ "cp -r src/. ${DESTDIR}/."
+ , "cd ${DESTDIR}"
+ , "chmod -R +w *"
+ , "for p in $(cat ${WORKDIR}/patches/gcc-13/reproducibility/series); do"
+ , " patch -p1 < ${WORKDIR}/patches/gcc-13/reproducibility/$p >/dev/null"
+ , "done"
+ ]
+ , "out_dirs": ["."]
+ }
+, "patched_separate_sources":
+ { "type": "install"
+ , "dirs":
+ [ ["patched_sources", "src"]
+ , [["@", "gmp", "", "files"], "gmp"]
+ , [["@", "mpc", "", "files"], "mpc"]
+ , [["@", "mpfr", "", "files"], "mpfr"]
+ ]
+ }
+, "gcc-native":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "arguments_config": ["TOOLCHAIN_CONFIG"]
+ , "project": ["patched_separate_sources"]
+ , "localbase": [["@", "binutils", "", "binutils"]]
+ , "cmds":
+ [ { "type": "join"
+ , "$1":
+ [ "HOST_SYSTEM_HDR_DIR='"
+ , { "type": "lookup"
+ , "key": "HOST_SYSTEM_HDR_DIR"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ , "default": ""
+ }
+ , "'"
+ ]
+ }
+ , { "type": "join"
+ , "$1":
+ [ "HOST_SYSTEM_LIB_DIR='"
+ , { "type": "lookup"
+ , "key": "HOST_SYSTEM_LIB_DIR"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ , "default": ""
+ }
+ , "'"
+ ]
+ }
+ , { "type": "join"
+ , "$1":
+ [ "HOST_DYNAMIC_LINKER='"
+ , { "type": "lookup"
+ , "key": "HOST_DYNAMIC_LINKER"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ , "default": ""
+ }
+ , "'"
+ ]
+ }
+ , "export NJOBS=$(nproc --all 2>/dev/null || echo 1)"
+ , "export PATH=${LOCALBASE}/bin:$PATH"
+ , "export MAKEINFO=missing"
+ , "export BUILD_ROOT_DIR=${ACTION_DIR}"
+ , "unset CFLAGS CXXFLAGS LDFLAGS"
+ , "CONF_ARGS="
+ , "if [ -n \"$HOST_SYSTEM_HDR_DIR\" ]; then"
+ , " CONF_ARGS=\"$CONF_ARGS --with-sysroot=/ --with-native-system-header-dir=$HOST_SYSTEM_HDR_DIR\""
+ , "fi"
+ , "LINK_ARGS="
+ , "if [ -n \"$HOST_SYSTEM_LIB_DIR\" ]; then"
+ , " export LIBRARY_PATH=\"$HOST_SYSTEM_LIB_DIR\""
+ , " LINK_ARGS=\"$LINK_ARGS -B$HOST_SYSTEM_LIB_DIR -L$HOST_SYSTEM_LIB_DIR\""
+ , " LINK_ARGS=\"$LINK_ARGS -Xlinker -rpath -Xlinker $HOST_SYSTEM_LIB_DIR\""
+ , "fi"
+ , "if [ -n \"$HOST_DYNAMIC_LINKER\" ]; then"
+ , " mv src/gcc/config src/gcc/config.orig"
+ , " cp -r src/gcc/config.orig src/gcc/config"
+ , " chmod -R +w src/gcc/config"
+ , " for h in src/gcc/config/*/*.h; do"
+ , " grep -q _DYNAMIC_LINKER \"$h\" || continue"
+ , " sed -i 's|\\(^#define [A-Z]*_DYNAMIC_LINKER[A-Z0-9]* *\"\\).*\"|\\1'$HOST_DYNAMIC_LINKER'\"|g' \"$h\""
+ , " done"
+ , "fi"
+ , "export LDFLAGS_FOR_TARGET=\"${LINK_ARGS}\""
+ , "if [ -f /lib/ld-musl-$(uname -m).so.1 ]; then"
+ , " ln -s /lib/ld-musl-$(uname -m).so.1 ${TMPDIR}/ldd"
+ , " export PATH=$PATH:${TMPDIR}"
+ , "fi"
+ , "cp -r ${LOCALBASE}/. ${DESTDIR}/."
+ , "chmod -R +w ${DESTDIR}/*"
+ , "mv gmp mpc mpfr src/."
+ , "cd src"
+ , "export check_msgfmt=no # do not use system's msgfmt, if available"
+ , "./configure ${CONF_ARGS} --prefix=/ --enable-checking=release --enable-languages=c,c++ --disable-multilib --disable-libsanitizer >configure.log 2>&1 || (cat configure.log && exit 1)"
+ , "${MAKE} -j${NJOBS} >build.log 2>&1 || (cat build.log && exit 1)"
+ , "${MAKE} -j${NJOBS} DESTDIR=${DESTDIR} install-strip >>build.log 2>&1 || (cat build.log && exit 1)"
+ , "cd ${DESTDIR}"
+ , "strip ./bin/*"
+ , "find . -type f -name '*.so*' -exec sh -c \"strip {} 2>/dev/null\" \\;"
+ , "find . -type f -name '*.a' -exec sh -c \"strip -g {}\" \\;"
+ , "find . -type f -name '*.o' -exec sh -c \"strip -g {}\" \\;"
+ , "if [ -n \"${LINK_ARGS}\" ]; then"
+ , " cd ${DESTDIR}/bin"
+ , " mv gcc gcc.real"
+ , " mv g++ g++.real"
+ , " printf '#!/bin/sh\\nexec $(dirname $0)/gcc.real %s \"$@\"' \"${LINK_ARGS}\" >gcc"
+ , " printf '#!/bin/sh\\nexec $(dirname $0)/g++.real %s \"$@\"' \"${LINK_ARGS}\" >g++"
+ , " chmod +x gcc g++"
+ , "fi"
+ ]
+ , "out_dirs": ["."]
+ }
+, "libstdc++":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["libstdc++"]
+ , "lib": ["libstdc++_files"]
+ , "deps": ["libgcc_s"]
+ }
+, "libgcc_s":
+ { "type": ["@", "rules", "CC/prebuilt", "library"]
+ , "name": ["libgcc_s"]
+ , "lib": ["libgcc_s_files"]
+ }
+, "libstdc++_files":
+ { "type": "generic"
+ , "arguments_config": ["ENV"]
+ , "deps": ["toolchain"]
+ , "cmds": [":"]
+ , "outs": ["lib64/libstdc++.so.6"]
+ , "env": {"type": "var", "name": "ENV", "default": {"type": "empty_map"}}
+ }
+, "libgcc_s_files":
+ { "type": "generic"
+ , "arguments_config": ["ENV"]
+ , "deps": ["toolchain"]
+ , "cmds": [":"]
+ , "outs": ["lib64/libgcc_s.so.1"]
+ , "env": {"type": "var", "name": "ENV", "default": {"type": "empty_map"}}
+ }
+}
diff --git a/src/tools/busybox-1.36.TARGETS b/src/tools/busybox-1.36.TARGETS
new file mode 100644
index 0000000..ab5d90b
--- /dev/null
+++ b/src/tools/busybox-1.36.TARGETS
@@ -0,0 +1,21 @@
+{ "toolchain":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "busybox"
+ }
+, "busybox":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": [["TREE", null, "."]]
+ , "cmds":
+ [ "NJOBS=$(nproc --all 2>/dev/null || echo 1)"
+ , "GCC_TOOLCHAIN=$(dirname ${CC})/.."
+ , "unset CFLAGS CXXFLAGS"
+ , "export LDFLAGS=\"-static\""
+ , "export SOURCE_DATE_EPOCH=0"
+ , "${MAKE} HOSTCC=\"${CC} -static\" HOSTCXX=\"${CXX} -static\" defconfig >configure.log 2>&1 || (cat configure.log && exit 1)"
+ , "${MAKE} -j${NJOBS} HOSTCC=\"${CC} -static\" HOSTCXX=\"${CXX} -static\" >build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "${MAKE} -j${NJOBS} HOSTCC=\"${CC} -static\" HOSTCXX=\"${CXX} -static\" CONFIG_PREFIX=${DESTDIR} install >>build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ ]
+ , "out_dirs": ["."]
+ }
+}
diff --git a/src/tools/cmake-3.27.TARGETS b/src/tools/cmake-3.27.TARGETS
new file mode 100644
index 0000000..69ef77a
--- /dev/null
+++ b/src/tools/cmake-3.27.TARGETS
@@ -0,0 +1,43 @@
+{ "toolchain":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "cmake"
+ }
+, "patched_sources":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": [["TREE", null, "."]]
+ , "cmds":
+ [ "cp -r . ${DESTDIR}/."
+ , "cd ${DESTDIR}"
+ , "mv Utilities/cmcurl/curltest.c Utilities/cmcurl/curltest.cpp"
+ , "sed -i 's/curltest\\.c)/curltest\\.cpp)/' Utilities/cmcurl/CMakeLists.txt"
+ ]
+ , "out_dirs": ["."]
+ }
+, "libssl":
+ { "type": "configure"
+ , "config":
+ { "type": "let*"
+ , "bindings": [["ADD_CFLAGS", ["-fPIE"]], ["ADD_CXXFLAGS", ["-fPIE"]]]
+ , "body": {"type": "env", "vars": ["ADD_CFLAGS", "ADD_CXXFLAGS"]}
+ }
+ , "target": ["@", "ssl", "", "ssl"]
+ }
+, "cmake":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": ["patched_sources"]
+ , "deps": ["libssl"]
+ , "cmds":
+ [ "export NJOBS=$(nproc --all 2>/dev/null || echo 1)"
+ , "export PKG_CONFIG=false"
+ , "mkdir ${TMPDIR}/build"
+ , "cd ${TMPDIR}/build"
+ , "export LDFLAGS='-static'"
+ , "export CFLAGS='-D__FILE__=__FILE_NAME__ -Wno-builtin-macro-redefined'"
+ , "export CXXFLAGS='-D__FILE__=__FILE_NAME__ -Wno-builtin-macro-redefined'"
+ , "${WORKDIR}/bootstrap --parallel=${NJOBS} -- -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${LOCALBASE} -DCMAKE_INSTALL_PREFIX=/ >bootstrap.log 2>&1 || (cat bootstrap.log && exit 1)"
+ , "${MAKE} -j${NJOBS} install >build.log 2>&1 || (cat bootstrap.log && cat build.log && exit 1)"
+ ]
+ , "out_dirs": ["."]
+ }
+}
diff --git a/src/tools/make-4.4.TARGETS b/src/tools/make-4.4.TARGETS
new file mode 100644
index 0000000..e35fb08
--- /dev/null
+++ b/src/tools/make-4.4.TARGETS
@@ -0,0 +1,20 @@
+{ "toolchain":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "make"
+ }
+, "make":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": [["TREE", null, "."]]
+ , "cmds":
+ [ "export NJOBS=$(nproc --all 2>/dev/null || echo 1)"
+ , "unset CFLAGS"
+ , "export CXX=unused"
+ , "export LDFLAGS='-static'"
+ , "./configure --prefix=/ --disable-rpath --disable-load >configure.log 2>&1 || (cat configure.log && exit 1)"
+ , "${MAKE} -j${NJOBS} MAKEINFO=missing >build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "${MAKE} -j${NJOBS} MAKEINFO=missing DESTDIR=${DESTDIR} install-strip >>build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ ]
+ , "outs": ["bin/make"]
+ }
+}
diff --git a/src/tools/python-3.12.TARGETS b/src/tools/python-3.12.TARGETS
new file mode 100644
index 0000000..625bac4
--- /dev/null
+++ b/src/tools/python-3.12.TARGETS
@@ -0,0 +1,36 @@
+{ "toolchain":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "target": "python"
+ }
+, "python":
+ { "type": ["@", "rules", "CC/foreign/shell", "data"]
+ , "project": [["TREE", null, "."]]
+ , "localbase": [["@", "zlib", "", "zlib"]]
+ , "cmds":
+ [ "export NJOBS=$(nproc --all 2>/dev/null || echo 1)"
+ , "export CFLAGS=\"-I${LOCALBASE}/include\""
+ , "export LDFLAGS=\"-static -L${LOCALBASE}/lib\""
+ , "export SOURCE_DATE_EPOCH=0"
+ , "./configure --disable-shared --disable-test-modules --prefix=/usr --with-pkg-config=no >configure.log 2>&1 || (cat configure.log && exit 1)"
+ , "rm Modules/Setup.local"
+ , "cp Modules/Setup.stdlib Modules/Setup.local"
+ , "sed -i 's/^\\*shared\\*/\\*static\\*/' Modules/Setup.local"
+ , "sed -i 's/^nis /#nis /' Modules/Setup.local"
+ , "sed -i 's/^_lzma /#_lzma /' Modules/Setup.local"
+ , "sed -i 's/^_uuid /#_uuid /' Modules/Setup.local"
+ , "${MAKE} -j${NJOBS} LINKFORSHARED=' ' >build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "${MAKE} -j${NJOBS} LINKFORSHARED=' ' install >>build.log 2>&1 || (cat configure.log build.log && exit 1)"
+ , "cd ${DESTDIR}/usr"
+ , "find ./bin -type f -exec sh -c \"strip {} 2>/dev/null\" \\;"
+ , "find ./lib -type f -name '*.a' -exec strip -g {} \\;"
+ , "find ./lib -type f -name '*.o' -exec strip -g {} \\;"
+ , "find ./lib -depth -type d -name '__pycache__' -exec rm -rf {} \\;"
+ , "find ./bin -type f -name '*-config' -exec sh -c \"sed -i 's|${ACTION_DIR}|/build|g' {}\" \\;"
+ , "find ./lib -type f -name 'Makefile' -exec sh -c \"sed -i 's|${ACTION_DIR}|/build|g' {}\" \\;"
+ , "find ./lib -type f -name '_sysconfigdata_*' -exec sh -c \"sed -i 's|${ACTION_DIR}|/build|g' {}\" \\;"
+ , "cp -l bin/python3 bin/python"
+ ]
+ , "out_dirs": ["."]
+ }
+}
diff --git a/test/TARGETS b/test/TARGETS
new file mode 100644
index 0000000..d9da126
--- /dev/null
+++ b/test/TARGETS
@@ -0,0 +1,260 @@
+{ "helloworld-c":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "pure C": ["yes"]
+ , "name": ["helloworld"]
+ , "srcs": ["main.c"]
+ , "private-cflags": ["-Wno-unused-command-line-argument"]
+ }
+, "helloworld-cpp":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "name": ["helloworld"]
+ , "srcs": ["main.cpp"]
+ , "private-cflags": ["-Wno-unused-command-line-argument"]
+ }
+, "installed helloworld-c":
+ { "type": ["@", "rules", "CC", "install-with-deps"]
+ , "targets": ["helloworld-c"]
+ }
+, "installed helloworld-cpp":
+ { "type": ["@", "rules", "CC", "install-with-deps"]
+ , "targets": ["helloworld-cpp"]
+ }
+, "test-c":
+ { "type": ["@", "rules", "shell/test", "script"]
+ , "arguments_config": ["TEST_NAME_SUFFIX"]
+ , "name":
+ { "type": "++"
+ , "$1": [["test-c"], {"type": "var", "name": "TEST_NAME_SUFFIX"}]
+ }
+ , "test": ["test.sh"]
+ , "deps": ["installed helloworld-c"]
+ }
+, "test-cpp":
+ { "type": ["@", "rules", "shell/test", "script"]
+ , "arguments_config": ["TEST_NAME_SUFFIX"]
+ , "name":
+ { "type": "++"
+ , "$1": [["test-cpp"], {"type": "var", "name": "TEST_NAME_SUFFIX"}]
+ }
+ , "test": ["test.sh"]
+ , "deps": ["installed helloworld-cpp"]
+ }
+, "config":
+ { "type": "configure"
+ , "arguments_config":
+ [ "CONFIG_TARGET"
+ , "ARCH"
+ , "TOOLCHAIN_CONFIG"
+ , "STATIC_FULL"
+ , "STATIC_RUNLIBS"
+ , "USE_LIBCXX"
+ , "ENV"
+ ]
+ , "tainted": ["test"]
+ , "target": {"type": "var", "name": "CONFIG_TARGET"}
+ , "config":
+ { "type": "let*"
+ , "bindings":
+ [ ["ARCH", {"type": "var", "name": "ARCH", "default": "x86_64"}]
+ , [ "STATIC_RUNLIBS"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "STATIC_FULL"}
+ , "then": true
+ , "else": {"type": "var", "name": "STATIC_RUNLIBS"}
+ }
+ ]
+ , [ "TOOLCHAIN_CONFIG"
+ , { "type": "map_union"
+ , "$1":
+ [ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ , {"type": "env", "vars": ["STATIC_RUNLIBS", "USE_LIBCXX"]}
+ ]
+ }
+ ]
+ , [ "ADD_LDFLAGS"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "STATIC_FULL"}
+ , "then": ["-static", "-s"]
+ }
+ ]
+ , [ "TEST_NAME_SUFFIX"
+ , { "type": "++"
+ , "$1":
+ [ { "type": "if"
+ , "cond": {"type": "var", "name": "STATIC_FULL"}
+ , "then": ["_static"]
+ , "else":
+ { "type": "if"
+ , "cond": {"type": "var", "name": "STATIC_RUNLIBS"}
+ , "then": ["_mixed"]
+ , "else": ["_shared"]
+ }
+ }
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "USE_LIBCXX"}
+ , "then": ["-llvmlibs"]
+ , "else": ["-gnulibs"]
+ }
+ ]
+ }
+ ]
+ , ["TEST_ENV", {"type": "var", "name": "ENV"}]
+ ]
+ , "body":
+ { "type": "env"
+ , "vars":
+ [ "ARCH"
+ , "TOOLCHAIN_CONFIG"
+ , "ADD_LDFLAGS"
+ , "TEST_NAME_SUFFIX"
+ , "TEST_ENV"
+ ]
+ }
+ }
+ }
+, "test-c_shared-gnulibs":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "fixed_config":
+ { "STATIC_FULL": false
+ , "STATIC_RUNLIBS": false
+ , "USE_LIBCXX": false
+ , "CONFIG_TARGET": "test-c"
+ }
+ , "target": "config"
+ }
+, "test-cpp_shared-gnulibs":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "fixed_config":
+ { "STATIC_FULL": false
+ , "STATIC_RUNLIBS": false
+ , "USE_LIBCXX": false
+ , "CONFIG_TARGET": "test-cpp"
+ }
+ , "target": "config"
+ }
+, "test-cpp_shared-llvmlibs":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "fixed_config":
+ { "STATIC_FULL": false
+ , "STATIC_RUNLIBS": false
+ , "USE_LIBCXX": true
+ , "CONFIG_TARGET": "test-cpp"
+ }
+ , "target": "config"
+ }
+, "test-c_mixed-gnulibs":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "fixed_config":
+ { "STATIC_FULL": false
+ , "STATIC_RUNLIBS": true
+ , "USE_LIBCXX": false
+ , "CONFIG_TARGET": "test-c"
+ }
+ , "target": "config"
+ }
+, "test-cpp_mixed-gnulibs":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "fixed_config":
+ { "STATIC_FULL": false
+ , "STATIC_RUNLIBS": true
+ , "USE_LIBCXX": false
+ , "CONFIG_TARGET": "test-cpp"
+ }
+ , "target": "config"
+ }
+, "test-cpp_mixed-llvmlibs":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "fixed_config":
+ { "STATIC_FULL": false
+ , "STATIC_RUNLIBS": true
+ , "USE_LIBCXX": true
+ , "CONFIG_TARGET": "test-cpp"
+ }
+ , "target": "config"
+ }
+, "test-c_static-gnulibs":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "fixed_config":
+ { "STATIC_FULL": true
+ , "STATIC_RUNLIBS": true
+ , "USE_LIBCXX": false
+ , "CONFIG_TARGET": "test-c"
+ }
+ , "target": "config"
+ }
+, "test-cpp_static-gnulibs":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "fixed_config":
+ { "STATIC_FULL": true
+ , "STATIC_RUNLIBS": true
+ , "USE_LIBCXX": false
+ , "CONFIG_TARGET": "test-cpp"
+ }
+ , "target": "config"
+ }
+, "test-cpp_static-llvmlibs":
+ { "type": "export"
+ , "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
+ , "fixed_config":
+ { "STATIC_FULL": true
+ , "STATIC_RUNLIBS": true
+ , "USE_LIBCXX": true
+ , "CONFIG_TARGET": "test-cpp"
+ }
+ , "target": "config"
+ }
+, "ALL":
+ { "type": "install"
+ , "arguments_config": ["SKIP_STATIC", "SKIP_SHARED", "HAVE_LIBCXX"]
+ , "tainted": ["test"]
+ , "deps":
+ { "type": "++"
+ , "$1":
+ [ { "type": "if"
+ , "cond": {"type": "var", "name": "SKIP_SHARED"}
+ , "then": []
+ , "else":
+ [ "test-c_shared-gnulibs"
+ , "test-cpp_shared-gnulibs"
+ , "test-c_mixed-gnulibs"
+ , "test-cpp_mixed-gnulibs"
+ ]
+ }
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "SKIP_STATIC"}
+ , "then": []
+ , "else": ["test-c_static-gnulibs", "test-cpp_static-gnulibs"]
+ }
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "HAVE_LIBCXX"}
+ , "then":
+ { "type": "if"
+ , "cond": {"type": "var", "name": "SKIP_SHARED"}
+ , "then": []
+ , "else": ["test-cpp_shared-llvmlibs", "test-cpp_mixed-llvmlibs"]
+ }
+ }
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "HAVE_LIBCXX"}
+ , "then":
+ { "type": "if"
+ , "cond": {"type": "var", "name": "SKIP_STATIC"}
+ , "then": []
+ , "else": ["test-cpp_static-llvmlibs"]
+ }
+ }
+ ]
+ }
+ }
+}
diff --git a/test/main.c b/test/main.c
new file mode 100644
index 0000000..e4074b7
--- /dev/null
+++ b/test/main.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(int argc, const char *argv[]) {
+ printf("Hello world!\n");
+ return 0;
+}
diff --git a/test/main.cpp b/test/main.cpp
new file mode 100644
index 0000000..88484d6
--- /dev/null
+++ b/test/main.cpp
@@ -0,0 +1,6 @@
+#include <iostream>
+
+int main(int argc, const char *argv[]) {
+ std::cout << "Hello world!\n";
+ return 0;
+}
diff --git a/test/test.sh b/test/test.sh
new file mode 100644
index 0000000..1039343
--- /dev/null
+++ b/test/test.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+set -e
+
+[ "$(./bin/helloworld)" = "Hello world!" ]
diff --git a/toolchains/CC/clang.TARGETS b/toolchains/CC/clang.TARGETS
new file mode 100644
index 0000000..bcea8e4
--- /dev/null
+++ b/toolchains/CC/clang.TARGETS
@@ -0,0 +1,89 @@
+{ "defaults":
+ { "type": ["@", "rules", "CC", "defaults"]
+ , "arguments_config": ["TOOLCHAIN_CONFIG"]
+ , "CC": ["clang/bin/clang"]
+ , "CXX": ["clang/bin/clang++"]
+ , "AR": ["clang/bin/ar"]
+ , "CXXFLAGS":
+ { "type": "if"
+ , "cond":
+ { "type": "lookup"
+ , "key": "USE_LIBCXX"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ }
+ , "then": ["-nostdlib++", "-stdlib=libc++"]
+ }
+ , "LDFLAGS":
+ { "type": "if"
+ , "cond":
+ { "type": "lookup"
+ , "key": "STATIC_RUNLIBS"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ }
+ , "then":
+ { "type": "++"
+ , "$1":
+ [ ["-static-libgcc"]
+ , { "type": "if"
+ , "cond":
+ { "type": "lookup"
+ , "key": "USE_LIBCXX"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ }
+ , "then":
+ [ "-Wl,--push-state"
+ , "-Wl,-Bstatic"
+ , "-lc++"
+ , "-lc++abi"
+ , "-Wl,--pop-state"
+ , "-lpthread"
+ ]
+ , "else": ["-static-libstdc++", "-l:libstdc++.a"]
+ }
+ ]
+ }
+ }
+ , "deps":
+ { "type": "if"
+ , "cond":
+ { "type": "lookup"
+ , "key": "STATIC_RUNLIBS"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ }
+ , "then": []
+ , "else":
+ { "type": "if"
+ , "cond":
+ { "type": "lookup"
+ , "key": "USE_LIBCXX"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ }
+ , "then": [["@", "clang", "", "runlibs_libcxx"]]
+ , "else": [["@", "clang", "", "runlibs"]]
+ }
+ }
+ , "toolchain": ["staged-clang"]
+ , "PATH": ["$(TOOLCHAIN)/clang/bin", "/bin"]
+ }
+, "staged-clang": {"type": "install", "dirs": [[["", "toolchain"], "clang"]]}
+}
diff --git a/toolchains/CC/compiler+tools.TARGETS b/toolchains/CC/compiler+tools.TARGETS
new file mode 100644
index 0000000..c72120b
--- /dev/null
+++ b/toolchains/CC/compiler+tools.TARGETS
@@ -0,0 +1,5 @@
+{ "defaults":
+ { "type": ["@", "rules", "CC", "defaults"]
+ , "base": [["@", "compiler", "CC", "defaults"]]
+ }
+}
diff --git a/toolchains/CC/foreign/busybox.TARGETS b/toolchains/CC/foreign/busybox.TARGETS
new file mode 100644
index 0000000..d051ad1
--- /dev/null
+++ b/toolchains/CC/foreign/busybox.TARGETS
@@ -0,0 +1,13 @@
+{ "defaults":
+ { "type": ["@", "rules", "CC/foreign", "defaults"]
+ , "toolchain": ["staged-busybox"]
+ , "PATH":
+ [ "$(TOOLCHAIN)/busybox/bin"
+ , "$(TOOLCHAIN)/busybox/sbin"
+ , "$(TOOLCHAIN)/busybox/usr/bin"
+ , "$(TOOLCHAIN)/busybox/usr/sbin"
+ ]
+ }
+, "staged-busybox":
+ {"type": "install", "dirs": [[["", "toolchain"], "busybox"]]}
+}
diff --git a/toolchains/CC/foreign/cmake.TARGETS b/toolchains/CC/foreign/cmake.TARGETS
new file mode 100644
index 0000000..facb83d
--- /dev/null
+++ b/toolchains/CC/foreign/cmake.TARGETS
@@ -0,0 +1,8 @@
+{ "defaults":
+ { "type": ["@", "rules", "CC/foreign", "defaults"]
+ , "CMAKE": ["cmake/bin/cmake"]
+ , "toolchain": ["staged-cmake"]
+ , "PATH": ["$(TOOLCHAIN)/cmake/bin"]
+ }
+, "staged-cmake": {"type": "install", "dirs": [[["", "toolchain"], "cmake"]]}
+}
diff --git a/toolchains/CC/foreign/compiler+tools.TARGETS b/toolchains/CC/foreign/compiler+tools.TARGETS
new file mode 100644
index 0000000..bc75880
--- /dev/null
+++ b/toolchains/CC/foreign/compiler+tools.TARGETS
@@ -0,0 +1,5 @@
+{ "defaults":
+ { "type": ["@", "rules", "CC/foreign", "defaults"]
+ , "base": [["@", "tools", "CC/foreign", "defaults"]]
+ }
+}
diff --git a/toolchains/CC/foreign/make.TARGETS b/toolchains/CC/foreign/make.TARGETS
new file mode 100644
index 0000000..ca679db
--- /dev/null
+++ b/toolchains/CC/foreign/make.TARGETS
@@ -0,0 +1,8 @@
+{ "defaults":
+ { "type": ["@", "rules", "CC/foreign", "defaults"]
+ , "MAKE": ["make/bin/make"]
+ , "PATH": ["$(TOOLCHAIN)/make/bin"]
+ , "toolchain": ["staged-make"]
+ }
+, "staged-make": {"type": "install", "dirs": [[["", "toolchain"], "make"]]}
+}
diff --git a/toolchains/CC/foreign/python.TARGETS b/toolchains/CC/foreign/python.TARGETS
new file mode 100644
index 0000000..2824c77
--- /dev/null
+++ b/toolchains/CC/foreign/python.TARGETS
@@ -0,0 +1,7 @@
+{ "defaults":
+ { "type": ["@", "rules", "CC/foreign", "defaults"]
+ , "toolchain": ["staged-python"]
+ , "PATH": ["$(TOOLCHAIN)/python/usr/bin"]
+ }
+, "staged-python": {"type": "install", "dirs": [[["", "toolchain"], "python"]]}
+}
diff --git a/toolchains/CC/foreign/tools-all.TARGETS b/toolchains/CC/foreign/tools-all.TARGETS
new file mode 100644
index 0000000..260bc43
--- /dev/null
+++ b/toolchains/CC/foreign/tools-all.TARGETS
@@ -0,0 +1,10 @@
+{ "defaults":
+ { "type": ["@", "rules", "CC/foreign", "defaults"]
+ , "base":
+ [ ["@", "busybox", "CC/foreign", "defaults"]
+ , ["@", "make", "CC/foreign", "defaults"]
+ , ["@", "cmake", "CC/foreign", "defaults"]
+ , ["@", "python", "CC/foreign", "defaults"]
+ ]
+ }
+}
diff --git a/toolchains/CC/gcc.TARGETS b/toolchains/CC/gcc.TARGETS
new file mode 100644
index 0000000..c0b6fbe
--- /dev/null
+++ b/toolchains/CC/gcc.TARGETS
@@ -0,0 +1,38 @@
+{ "defaults":
+ { "type": ["@", "rules", "CC", "defaults"]
+ , "arguments_config": ["TOOLCHAIN_CONFIG"]
+ , "CC": ["gcc/bin/gcc"]
+ , "CXX": ["gcc/bin/g++"]
+ , "AR": ["gcc/bin/ar"]
+ , "LDFLAGS":
+ { "type": "if"
+ , "cond":
+ { "type": "lookup"
+ , "key": "STATIC_RUNLIBS"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ }
+ , "then": ["-static-libgcc", "-static-libstdc++"]
+ }
+ , "deps":
+ { "type": "if"
+ , "cond":
+ { "type": "lookup"
+ , "key": "STATIC_RUNLIBS"
+ , "map":
+ { "type": "var"
+ , "name": "TOOLCHAIN_CONFIG"
+ , "default": {"type": "empty_map"}
+ }
+ }
+ , "then": []
+ , "else": [["@", "gcc", "", "runlibs"]]
+ }
+ , "toolchain": ["staged-gcc"]
+ , "PATH": ["$(TOOLCHAIN)/gcc/bin", "/bin"]
+ }
+, "staged-gcc": {"type": "install", "dirs": [[["", "toolchain"], "gcc"]]}
+}
diff --git a/toolchains/busybox.TARGETS b/toolchains/busybox.TARGETS
new file mode 100644
index 0000000..53e5b24
--- /dev/null
+++ b/toolchains/busybox.TARGETS
@@ -0,0 +1,3 @@
+{ "toolchain":
+ {"type": "install", "dirs": [[["@", "busybox", "", "toolchain"], "."]]}
+}
diff --git a/toolchains/clang.TARGETS b/toolchains/clang.TARGETS
new file mode 100644
index 0000000..8cdc4a3
--- /dev/null
+++ b/toolchains/clang.TARGETS
@@ -0,0 +1,3 @@
+{ "toolchain":
+ {"type": "install", "dirs": [[["@", "clang", "", "toolchain"], "."]]}
+}
diff --git a/toolchains/cmake.TARGETS b/toolchains/cmake.TARGETS
new file mode 100644
index 0000000..bb16198
--- /dev/null
+++ b/toolchains/cmake.TARGETS
@@ -0,0 +1,3 @@
+{ "toolchain":
+ {"type": "install", "dirs": [[["@", "cmake", "", "toolchain"], "."]]}
+}
diff --git a/toolchains/compiler+tools.TARGETS b/toolchains/compiler+tools.TARGETS
new file mode 100644
index 0000000..0f21c76
--- /dev/null
+++ b/toolchains/compiler+tools.TARGETS
@@ -0,0 +1,8 @@
+{ "toolchain":
+ { "type": "install"
+ , "dirs":
+ [ [["@", "tools", "", "toolchain"], "."]
+ , [["@", "compiler", "", "toolchain"], "compiler"]
+ ]
+ }
+}
diff --git a/toolchains/gcc.TARGETS b/toolchains/gcc.TARGETS
new file mode 100644
index 0000000..4c129eb
--- /dev/null
+++ b/toolchains/gcc.TARGETS
@@ -0,0 +1,3 @@
+{ "toolchain":
+ {"type": "install", "dirs": [[["@", "gcc", "", "toolchain"], "."]]}
+}
diff --git a/toolchains/make.TARGETS b/toolchains/make.TARGETS
new file mode 100644
index 0000000..2d2bed2
--- /dev/null
+++ b/toolchains/make.TARGETS
@@ -0,0 +1,3 @@
+{ "toolchain":
+ {"type": "install", "dirs": [[["@", "make", "", "toolchain"], "."]]}
+}
diff --git a/toolchains/patch/busybox.TARGETS b/toolchains/patch/busybox.TARGETS
new file mode 100644
index 0000000..5581cb7
--- /dev/null
+++ b/toolchains/patch/busybox.TARGETS
@@ -0,0 +1,9 @@
+{ "defaults":
+ { "type": ["@", "rules", "patch", "defaults"]
+ , "PATCH": ["busybox/usr/bin/patch"]
+ , "toolchain": ["staged-busybox"]
+ , "PATH": ["/bin"]
+ }
+, "staged-busybox":
+ {"type": "install", "dirs": [[["", "toolchain"], "busybox"]]}
+}
diff --git a/toolchains/patch/compiler+tools.TARGETS b/toolchains/patch/compiler+tools.TARGETS
new file mode 100644
index 0000000..86297fe
--- /dev/null
+++ b/toolchains/patch/compiler+tools.TARGETS
@@ -0,0 +1,5 @@
+{ "defaults":
+ { "type": ["@", "rules", "patch", "defaults"]
+ , "base": [["@", "tools", "patch", "defaults"]]
+ }
+}
diff --git a/toolchains/patch/tools-all.TARGETS b/toolchains/patch/tools-all.TARGETS
new file mode 100644
index 0000000..0dd1455
--- /dev/null
+++ b/toolchains/patch/tools-all.TARGETS
@@ -0,0 +1,5 @@
+{ "defaults":
+ { "type": ["@", "rules", "patch", "defaults"]
+ , "base": [["@", "busybox", "patch", "defaults"]]
+ }
+}
diff --git a/toolchains/python.TARGETS b/toolchains/python.TARGETS
new file mode 100644
index 0000000..14e16c0
--- /dev/null
+++ b/toolchains/python.TARGETS
@@ -0,0 +1,3 @@
+{ "toolchain":
+ {"type": "install", "dirs": [[["@", "python", "", "toolchain"], "."]]}
+}
diff --git a/toolchains/tools-all.TARGETS b/toolchains/tools-all.TARGETS
new file mode 100644
index 0000000..2330537
--- /dev/null
+++ b/toolchains/tools-all.TARGETS
@@ -0,0 +1,10 @@
+{ "toolchain":
+ { "type": "install"
+ , "dirs":
+ [ [["@", "busybox", "", "toolchain"], "busybox"]
+ , [["@", "make", "", "toolchain"], "make"]
+ , [["@", "cmake", "", "toolchain"], "cmake"]
+ , [["@", "python", "", "toolchain"], "python"]
+ ]
+ }
+}