From fab89c5d8645c8bb33dc7e4edd62363f6cc8ca11 Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Fri, 20 Nov 2026 20:20:40 -0700 Subject: [PATCH 1/9] Ship cross toolchains as separate PyPI packages Each cross toolchain is now its own PyPI project rather than being bundled into the base ppbt wheel. The base wheel stays lean (native toolchain only, ~40 MiB); cross users opt in via extras: pip install ppbt[cross-aarch64-linux-gnu] pip install ppbt[cross-x86_64-linux-gnu] pip install ppbt[cross-all] The base ppbt package exposes new API for picking a toolchain by triplet -- archive_for(triplet), toolchain_for(triplet), available_triplets() -- and extract() / environ() take a triplet= kwarg. Cross packages register themselves via a ppbt.toolchains entry point so base ppbt discovers them at import time without having to know their names. Sibling packages: - packages/cross-aarch64-linux-gnu/ (aarch64 target, x86_64 host) - packages/cross-x86_64-linux-gnu/ (x86_64 target, aarch64 host) Each ships its own crosstool-ng config + build backend, produces a wheel tagged for its *host* arch (an aarch64 cross toolchain runs on an x86_64 host, so the wheel is manylinux_2_17_x86_64), and has its own RECORD-merging on extract. CI matrix now has 4 cells (base x 2 host arches + 2 cross siblings each on its one host), and both source + wheel upload patterns use glob dispatch so new sibling packages fall out without wiring every artifact name individually. Editable installs across all three packages skip the heavy crosstool-ng build via a PEP 660 build_editable hook, so dev installs take seconds rather than hours. --- .github/workflows/deploy-package-action.yml | 18 +- .github/workflows/github-release.yml | 64 +- .github/workflows/package-action.yml | 43 +- .pre-commit-hooks/copyright_headers.py | 2 +- CHANGELOG.md | 21 + packages/cross-aarch64-linux-gnu/LICENSE.md | 184 ++++ packages/cross-aarch64-linux-gnu/README.md | 20 + .../cross-aarch64-linux-gnu/pyproject.toml | 13 + packages/cross-aarch64-linux-gnu/setup.cfg | 34 + packages/cross-aarch64-linux-gnu/setup.py | 26 + .../ppbt_cross_aarch64_linux_gnu/__init__.py | 23 + .../_config/aarch64-linux-gnu-ct-ng.config | 799 +++++++++++++++++ .../src/ppbt_cross_aarch64_linux_gnu/build.py | 229 +++++ packages/cross-x86_64-linux-gnu/LICENSE.md | 184 ++++ packages/cross-x86_64-linux-gnu/README.md | 20 + .../cross-x86_64-linux-gnu/pyproject.toml | 13 + packages/cross-x86_64-linux-gnu/setup.cfg | 34 + packages/cross-x86_64-linux-gnu/setup.py | 26 + .../ppbt_cross_x86_64_linux_gnu/__init__.py | 23 + .../_config/x86_64-linux-gnu-ct-ng.config | 800 ++++++++++++++++++ .../src/ppbt_cross_x86_64_linux_gnu/build.py | 229 +++++ pyproject.toml | 3 + setup.cfg | 7 + src/ppbt/__init__.py | 17 +- src/ppbt/build.py | 8 + src/ppbt/common.py | 251 +++++- tests/test_common.py | 154 ++++ 27 files changed, 3136 insertions(+), 109 deletions(-) create mode 100644 packages/cross-aarch64-linux-gnu/LICENSE.md create mode 100644 packages/cross-aarch64-linux-gnu/README.md create mode 100644 packages/cross-aarch64-linux-gnu/pyproject.toml create mode 100644 packages/cross-aarch64-linux-gnu/setup.cfg create mode 100644 packages/cross-aarch64-linux-gnu/setup.py create mode 100644 packages/cross-aarch64-linux-gnu/src/ppbt_cross_aarch64_linux_gnu/__init__.py create mode 100644 packages/cross-aarch64-linux-gnu/src/ppbt_cross_aarch64_linux_gnu/_config/aarch64-linux-gnu-ct-ng.config create mode 100644 packages/cross-aarch64-linux-gnu/src/ppbt_cross_aarch64_linux_gnu/build.py create mode 100644 packages/cross-x86_64-linux-gnu/LICENSE.md create mode 100644 packages/cross-x86_64-linux-gnu/README.md create mode 100644 packages/cross-x86_64-linux-gnu/pyproject.toml create mode 100644 packages/cross-x86_64-linux-gnu/setup.cfg create mode 100644 packages/cross-x86_64-linux-gnu/setup.py create mode 100644 packages/cross-x86_64-linux-gnu/src/ppbt_cross_x86_64_linux_gnu/__init__.py create mode 100644 packages/cross-x86_64-linux-gnu/src/ppbt_cross_x86_64_linux_gnu/_config/x86_64-linux-gnu-ct-ng.config create mode 100644 packages/cross-x86_64-linux-gnu/src/ppbt_cross_x86_64_linux_gnu/build.py create mode 100644 tests/test_common.py diff --git a/.github/workflows/deploy-package-action.yml b/.github/workflows/deploy-package-action.yml index 8ba569a..4b487bc 100644 --- a/.github/workflows/deploy-package-action.yml +++ b/.github/workflows/deploy-package-action.yml @@ -4,27 +4,23 @@ on: workflow_call jobs: release: - name: Publish Python Wheel + name: Publish Python Wheels runs-on: ubuntu-latest environment: release steps: - - name: Download Source Tarball + - name: Download Source Tarballs uses: actions/download-artifact@v4 with: - name: Source Tarball + pattern: Source Tarball * path: dist + merge-multiple: true - - name: Download x86 Python Package Artifacts + - name: Download Python Wheels uses: actions/download-artifact@v4 with: - name: Python Wheel x86_64 - path: dist - - - name: Download arm64 Python Package Artifacts - uses: actions/download-artifact@v4 - with: - name: Python Wheel aarch64 + pattern: Python Wheel * path: dist + merge-multiple: true - name: List dist directory run: ls -la dist/ diff --git a/.github/workflows/github-release.yml b/.github/workflows/github-release.yml index 5dcfa9e..1594fa9 100644 --- a/.github/workflows/github-release.yml +++ b/.github/workflows/github-release.yml @@ -11,67 +11,33 @@ jobs: release: name: Create Github Release runs-on: ubuntu-latest + permissions: + contents: write steps: - - name: Download Source Tarball + - name: Download Source Tarballs uses: actions/download-artifact@v4 with: - name: Source Tarball + pattern: Source Tarball * path: dist + merge-multiple: true - - name: Download x86 Python Package Artifacts + - name: Download Python Wheels uses: actions/download-artifact@v4 with: - name: Python Wheel x86_64 + pattern: Python Wheel * path: dist + merge-multiple: true - - name: Download arm64 Python Package Artifacts - uses: actions/download-artifact@v4 - with: - name: Python Wheel aarch64 - path: dist + - name: List dist directory + run: ls -la dist/ - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + uses: softprops/action-gh-release@v2 with: tag_name: "v${{ inputs.version }}" - release_name: "Release v${{ inputs.version }}" - body: | - Release ${{ needs.build-python-package.outputs.version }} + name: "Release v${{ inputs.version }}" + body: "Release ${{ inputs.version }}" draft: false prerelease: false - - - name: Upload Source Tarball - id: upload-release-asset-source - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: dist/ppbt-${{ inputs.version }}.tar.gz - asset_name: ppbt-${{ inputs.version }}.tar.gz - asset_content_type: application/tar+gzip - - - name: Upload x86-64 Wheel - id: upload-release-asset-x86_64 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: dist/ppbt-${{ inputs.version }}-py3-none-manylinux_2_17_x86_64.whl - asset_name: ppbt-${{ inputs.version }}-py3-none-manylinux_2_17_x86_64.whl - asset_content_type: application/zip - - - name: Upload arm64 Wheel - id: upload-release-asset-aarch64 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: dist/ppbt-${{ inputs.version }}-py3-none-manylinux_2_17_aarch64.whl - asset_name: ppbt-${{ inputs.version }}-py3-none-manylinux_2_17_aarch64.whl - asset_content_type: application/zip + files: | + dist/* diff --git a/.github/workflows/package-action.yml b/.github/workflows/package-action.yml index b3652a9..03c3853 100644 --- a/.github/workflows/package-action.yml +++ b/.github/workflows/package-action.yml @@ -24,8 +24,18 @@ on: jobs: build-source: - name: Build Python Source Tarball + name: Build Source Tarballs runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - pkg: ppbt + pkg_dir: "." + - pkg: ppbt-cross-aarch64-linux-gnu + pkg_dir: packages/cross-aarch64-linux-gnu + - pkg: ppbt-cross-x86_64-linux-gnu + pkg_dir: packages/cross-x86_64-linux-gnu steps: - uses: actions/checkout@master - name: Install build @@ -33,23 +43,38 @@ jobs: python -m pip install --upgrade pip python -m pip install build - name: Build Source Tarball + working-directory: ${{ matrix.pkg_dir }} run: | python3 -m build -s - name: Python Build Artifact uses: actions/upload-artifact@v4 with: - name: Source Tarball - path: dist/* + name: Source Tarball ${{ matrix.pkg }} + path: ${{ matrix.pkg_dir }}/dist/* retention-days: 5 build: name: Build Python Wheel strategy: + fail-fast: false matrix: - host: - - x86_64 - - aarch64 + # Each cell = one wheel. The base ``ppbt`` wheel builds on both + # arches (native toolchain). Cross wheels build on their *host* + # arch only (an aarch64-linux-gnu cross toolchain runs on x86_64). + include: + - host: x86_64 + pkg: ppbt + pkg_dir: "." + - host: aarch64 + pkg: ppbt + pkg_dir: "." + - host: x86_64 + pkg: ppbt-cross-aarch64-linux-gnu + pkg_dir: packages/cross-aarch64-linux-gnu + - host: aarch64 + pkg: ppbt-cross-x86_64-linux-gnu + pkg_dir: packages/cross-x86_64-linux-gnu runs-on: - self-hosted - linux @@ -91,6 +116,7 @@ jobs: pip install build wheel setuptools pkginfo - name: Build Wheel + working-directory: ${{ matrix.pkg_dir }} run: | ${{ inputs.cmd }} @@ -98,11 +124,12 @@ jobs: uses: actions/upload-artifact@v4 if: always() with: - name: Python Wheel ${{ matrix.host }} - path: dist/*.whl + name: Python Wheel ${{ matrix.pkg }} ${{ matrix.host }} + path: ${{ matrix.pkg_dir }}/dist/*.whl retention-days: 5 - name: Read Version + working-directory: ${{ matrix.pkg_dir }} run: >- python3 -c diff --git a/.pre-commit-hooks/copyright_headers.py b/.pre-commit-hooks/copyright_headers.py index c497f62..598a8f6 100644 --- a/.pre-commit-hooks/copyright_headers.py +++ b/.pre-commit-hooks/copyright_headers.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Copyright 2021-2024 Broadcom Corporation +# Copyright 2021-2026 Broadcom Corporation # SPDX-License-Identifier: Apache-2.0 # # pylint: disable=invalid-name,missing-module-docstring,missing-function-docstring diff --git a/CHANGELOG.md b/CHANGELOG.md index f713019..168ca02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,24 @@ +0.2.0 +===== +- Cross toolchains are now shipped as separate PyPI packages: + ``ppbt-cross-aarch64-linux-gnu`` (aarch64 target, runs on x86_64 host) + and ``ppbt-cross-x86_64-linux-gnu`` (x86_64 target, runs on aarch64). + The base ``ppbt`` wheel stays lean (native toolchain only), and + cross-compile users opt in via extras: + ``pip install ppbt[cross-aarch64-linux-gnu]`` / + ``pip install ppbt[cross-x86_64-linux-gnu]`` / + ``pip install ppbt[cross-all]``. Cross packages register themselves + via the ``ppbt.toolchains`` entry point so base ``ppbt`` discovers + them at import time. +- New public API: ``ppbt.archive_for(triplet)``, + ``ppbt.toolchain_for(triplet)``, ``ppbt.available_triplets()``. + ``ppbt.extract()`` and ``ppbt.environ()`` grow a ``triplet=`` kwarg + defaulting to the host triplet for backward compatibility. +- Editable installs (``pip install -e``) now skip the full + crosstool-ng build, so developers can iterate on ppbt without + spending an hour per install. + + 0.1.8 ===== - Refactor to support early import of ppbt.common at relenv runtime. diff --git a/packages/cross-aarch64-linux-gnu/LICENSE.md b/packages/cross-aarch64-linux-gnu/LICENSE.md new file mode 100644 index 0000000..6c3b205 --- /dev/null +++ b/packages/cross-aarch64-linux-gnu/LICENSE.md @@ -0,0 +1,184 @@ +Apache License +============== + +_Version 2.0, January 2004_ +_<>_ + +### 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_ + +Copyright (c) 2011-2022 VMware, Inc. All rights reserved. + +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/packages/cross-aarch64-linux-gnu/README.md b/packages/cross-aarch64-linux-gnu/README.md new file mode 100644 index 0000000..95a8a8d --- /dev/null +++ b/packages/cross-aarch64-linux-gnu/README.md @@ -0,0 +1,20 @@ +# ppbt-cross-aarch64-linux-gnu + +Cross-toolchain plugin for [ppbt](https://github.com/saltstack/ppbt). + +Ships a crosstool-ng-built GCC targeting `aarch64-linux-gnu` whose +driver binaries run on an `x86_64` host. Installed as an optional +extra of the base `ppbt` package: + +``` +pip install ppbt[cross-aarch64-linux-gnu] +``` + +Discovered at runtime by base `ppbt` via the `ppbt.toolchains` entry +point: + +```python +import ppbt +print(ppbt.available_triplets()) +env = ppbt.environ(triplet="aarch64-linux-gnu", auto_extract=True) +``` diff --git a/packages/cross-aarch64-linux-gnu/pyproject.toml b/packages/cross-aarch64-linux-gnu/pyproject.toml new file mode 100644 index 0000000..260d7ba --- /dev/null +++ b/packages/cross-aarch64-linux-gnu/pyproject.toml @@ -0,0 +1,13 @@ +[build-system] +requires = [ + "setuptools>=38.6.0", + "wheel>=0.31.0", + "twine>=1.11.0" +] +build-backend = "ppbt_cross_aarch64_linux_gnu.build" +backend-path = ["src"] + +[tool.pytest.ini_options] +pythonpath = [ + "src" +] diff --git a/packages/cross-aarch64-linux-gnu/setup.cfg b/packages/cross-aarch64-linux-gnu/setup.cfg new file mode 100644 index 0000000..61ea07d --- /dev/null +++ b/packages/cross-aarch64-linux-gnu/setup.cfg @@ -0,0 +1,34 @@ +[metadata] +name = ppbt-cross-aarch64-linux-gnu +version = attr: ppbt_cross_aarch64_linux_gnu.__version__ +author = Daniel A. Wozniak +author_email = +long-description-content-type = text/markdown +long_description = file: README.md +description = Portable Python Build Toolchain - aarch64-linux-gnu cross toolchain +license = Apache License 2.0 +license_file = LICENSE.md +url = https://github.com/saltstack/ppbt +bug_tracker = https://github.com/saltstack/ppbt/issues +classifiers = + Programming Language :: Python :: 3 + License :: OSI Approved :: Apache Software License + Development Status :: 2 - Pre-Alpha + Operating System :: POSIX :: Linux + +[options] +package_dir= + =src +packages = find: +python_requires = >=3 +include_package_data = True + +[options.packages.find] +where=src + +[options.package_data] +*=_config/**, _toolchain/** + +[options.entry_points] +ppbt.toolchains = + aarch64-linux-gnu = ppbt_cross_aarch64_linux_gnu diff --git a/packages/cross-aarch64-linux-gnu/setup.py b/packages/cross-aarch64-linux-gnu/setup.py new file mode 100644 index 0000000..3d9e58b --- /dev/null +++ b/packages/cross-aarch64-linux-gnu/setup.py @@ -0,0 +1,26 @@ +# Copyright 2024-2026 Broadcom Corporation +# SPDX-License-Identifier: Apache-2.0 +# +import platform + +from setuptools import setup + +# Keep in sync with ppbt's base crosstool-ng config. +GLIBC_VERSION = "2.17" + + +def plat_name(): + # The cross wheel ships binaries that *run on* the build host and + # emit code for a different target. The wheel's platform tag is the + # host's, not the target's. + return f"manylinux_{GLIBC_VERSION.replace('.', '_')}_{platform.machine()}" + + +setup( + options={ + "bdist_wheel": { + "plat_name": f"{plat_name()}", + "python_tag": "py3", + } + } +) diff --git a/packages/cross-aarch64-linux-gnu/src/ppbt_cross_aarch64_linux_gnu/__init__.py b/packages/cross-aarch64-linux-gnu/src/ppbt_cross_aarch64_linux_gnu/__init__.py new file mode 100644 index 0000000..55124d9 --- /dev/null +++ b/packages/cross-aarch64-linux-gnu/src/ppbt_cross_aarch64_linux_gnu/__init__.py @@ -0,0 +1,23 @@ +# Copyright 2024-2026 Broadcom Corporation +# SPDX-License-Identifier: Apache-2.0 +""" +Cross toolchain plugin: aarch64-linux-gnu target. + +This package ships a crosstool-ng-built GCC targeting +``aarch64-linux-gnu`` whose driver binaries run on the wheel's host +arch (x86_64). Discovered by the base ``ppbt`` package at runtime via +the ``ppbt.toolchains`` entry point. +""" +import pathlib + +__version__ = "0.2.0" + +TRIPLET = "aarch64-linux-gnu" +TOOLCHAIN_ROOT = pathlib.Path(__file__).parent / "_toolchain" +ARCHIVE = TOOLCHAIN_ROOT / f"{TRIPLET}.tar.xz" +TOOLCHAIN = TOOLCHAIN_ROOT / TRIPLET + +DISTINFO = ( + pathlib.Path(__file__).resolve().parent.parent + / f"ppbt_cross_aarch64_linux_gnu-{__version__}.dist-info" +) diff --git a/packages/cross-aarch64-linux-gnu/src/ppbt_cross_aarch64_linux_gnu/_config/aarch64-linux-gnu-ct-ng.config b/packages/cross-aarch64-linux-gnu/src/ppbt_cross_aarch64_linux_gnu/_config/aarch64-linux-gnu-ct-ng.config new file mode 100644 index 0000000..39aad53 --- /dev/null +++ b/packages/cross-aarch64-linux-gnu/src/ppbt_cross_aarch64_linux_gnu/_config/aarch64-linux-gnu-ct-ng.config @@ -0,0 +1,799 @@ +# +# Automatically generated file; DO NOT EDIT. +# crosstool-NG 1.25.0 Configuration +# +CT_CONFIGURE_has_static_link=y +CT_CONFIGURE_has_cxx11=y +CT_CONFIGURE_has_lzip=y +CT_CONFIGURE_has_wget=y +CT_CONFIGURE_has_curl=y +CT_CONFIGURE_has_rsync=y +CT_CONFIGURE_has_make_3_81_or_newer=y +CT_CONFIGURE_has_make_4_0_or_newer=y +CT_CONFIGURE_has_libtool_2_4_or_newer=y +CT_CONFIGURE_has_libtoolize_2_4_or_newer=y +CT_CONFIGURE_has_autoconf_2_65_or_newer=y +CT_CONFIGURE_has_autoreconf_2_65_or_newer=y +CT_CONFIGURE_has_automake_1_15_or_newer=y +CT_CONFIGURE_has_gnu_m4_1_4_12_or_newer=y +CT_CONFIGURE_has_python_3_4_or_newer=y +CT_CONFIGURE_has_bison_2_7_or_newer=y +CT_CONFIGURE_has_python=y +CT_CONFIGURE_has_svn=y +CT_CONFIGURE_has_git=y +CT_CONFIGURE_has_md5sum=y +CT_CONFIGURE_has_sha1sum=y +CT_CONFIGURE_has_sha256sum=y +CT_CONFIGURE_has_sha512sum=y +CT_CONFIGURE_has_install_with_strip_program=y +CT_VERSION="1.25.0" +CT_VCHECK="" +CT_CONFIG_VERSION_ENV="4" +CT_CONFIG_VERSION_CURRENT="4" +CT_CONFIG_VERSION="4" +CT_MODULES=y + +# +# Paths and misc options +# + +# +# crosstool-NG behavior +# +# CT_OBSOLETE is not set +# CT_EXPERIMENTAL is not set +# CT_DEBUG_CT is not set + +# +# Paths +# +CT_LOCAL_TARBALLS_DIR="${HOME}/src" +CT_SAVE_TARBALLS=y +# CT_TARBALLS_BUILDROOT_LAYOUT is not set +CT_WORK_DIR="${CT_TOP_DIR}/.build" +CT_BUILD_TOP_DIR="${CT_WORK_DIR:-${CT_TOP_DIR}/.build}/${CT_HOST:+HOST-${CT_HOST}/}${CT_TARGET}" +CT_BUILD_DIR="${CT_BUILD_TOP_DIR}/build" +CT_PREFIX_DIR="${CT_PREFIX:-${HOME}/x-tools}/${CT_HOST:+HOST-${CT_HOST}/}${CT_TARGET}" +CT_RM_RF_PREFIX_DIR=y +CT_REMOVE_DOCS=y +CT_INSTALL_LICENSES=y +# CT_PREFIX_DIR_RO is not set +CT_STRIP_HOST_TOOLCHAIN_EXECUTABLES=y +# CT_STRIP_TARGET_TOOLCHAIN_EXECUTABLES is not set + +# +# Downloading +# +CT_DOWNLOAD_AGENT_WGET=y +# CT_DOWNLOAD_AGENT_CURL is not set +# CT_DOWNLOAD_AGENT_NONE is not set +# CT_FORBID_DOWNLOAD is not set +# CT_FORCE_DOWNLOAD is not set +CT_CONNECT_TIMEOUT=10 +CT_DOWNLOAD_WGET_OPTIONS="--passive-ftp --tries=3 -nc --progress=dot:binary" +# CT_ONLY_DOWNLOAD is not set +# CT_USE_MIRROR is not set +CT_VERIFY_DOWNLOAD_DIGEST=y +CT_VERIFY_DOWNLOAD_DIGEST_SHA512=y +# CT_VERIFY_DOWNLOAD_DIGEST_SHA256 is not set +# CT_VERIFY_DOWNLOAD_DIGEST_SHA1 is not set +# CT_VERIFY_DOWNLOAD_DIGEST_MD5 is not set +CT_VERIFY_DOWNLOAD_DIGEST_ALG="sha512" +# CT_VERIFY_DOWNLOAD_SIGNATURE is not set + +# +# Extracting +# +# CT_FORCE_EXTRACT is not set +CT_OVERRIDE_CONFIG_GUESS_SUB=y +# CT_ONLY_EXTRACT is not set +CT_PATCH_BUNDLED=y +# CT_PATCH_BUNDLED_LOCAL is not set +CT_PATCH_ORDER="bundled" + +# +# Build behavior +# +CT_PARALLEL_JOBS=0 +CT_LOAD="" +CT_USE_PIPES=y +CT_EXTRA_CFLAGS_FOR_BUILD="" +CT_EXTRA_CXXFLAGS_FOR_BUILD="" +CT_EXTRA_LDFLAGS_FOR_BUILD="" +CT_EXTRA_CFLAGS_FOR_HOST="" +CT_EXTRA_LDFLAGS_FOR_HOST="" +# CT_CONFIG_SHELL_SH is not set +# CT_CONFIG_SHELL_ASH is not set +CT_CONFIG_SHELL_BASH=y +# CT_CONFIG_SHELL_CUSTOM is not set +CT_CONFIG_SHELL="${bash}" + +# +# Logging +# +# CT_LOG_ERROR is not set +# CT_LOG_WARN is not set +# CT_LOG_INFO is not set +CT_LOG_EXTRA=y +# CT_LOG_ALL is not set +# CT_LOG_DEBUG is not set +CT_LOG_LEVEL_MAX="EXTRA" +# CT_LOG_SEE_TOOLS_WARN is not set +CT_LOG_PROGRESS_BAR=n +CT_LOG_TO_FILE=y +CT_LOG_FILE_COMPRESS=y +# end of Paths and misc options + +# +# Target options +# +# CT_ARCH_ALPHA is not set +# CT_ARCH_ARC is not set +CT_ARCH_ARM=y +# CT_ARCH_AVR is not set +# CT_ARCH_M68K is not set +# CT_ARCH_MIPS is not set +# CT_ARCH_NIOS2 is not set +# CT_ARCH_POWERPC is not set +# CT_ARCH_PRU is not set +# CT_ARCH_S390 is not set +# CT_ARCH_SH is not set +# CT_ARCH_SPARC is not set +# CT_ARCH_X86 is not set +# CT_ARCH_XTENSA is not set +CT_ARCH="arm" +CT_ARCH_CHOICE_KSYM="ARM" +CT_ARCH_CPU="" +CT_ARCH_TUNE="" +CT_ARCH_ARM_SHOW=y + +# +# Options for arm +# +CT_ARCH_ARM_PKG_KSYM="" +CT_ALL_ARCH_CHOICES="ALPHA ARC ARM AVR C6X M68K MICROBLAZE MIPS MOXIE MSP430 NIOS2 POWERPC PRU RISCV S390 SH SPARC X86 XTENSA" +CT_ARCH_SUFFIX="" +CT_OMIT_TARGET_VENDOR=y + +# +# Generic target options +# +# CT_MULTILIB is not set +CT_DEMULTILIB=y +CT_ARCH_SUPPORTS_BOTH_MMU=y +CT_ARCH_DEFAULT_HAS_MMU=y +CT_ARCH_USE_MMU=y +CT_ARCH_SUPPORTS_FLAT_FORMAT=y +CT_ARCH_SUPPORTS_EITHER_ENDIAN=y +CT_ARCH_DEFAULT_LE=y +# CT_ARCH_BE is not set +CT_ARCH_LE=y +CT_ARCH_ENDIAN="little" +CT_ARCH_SUPPORTS_32=y +CT_ARCH_SUPPORTS_64=y +CT_ARCH_DEFAULT_32=y +CT_ARCH_BITNESS=64 +# CT_ARCH_32 is not set +CT_ARCH_64=y + +# +# Target optimisations +# +CT_ARCH_SUPPORTS_WITH_ARCH=y +CT_ARCH_SUPPORTS_WITH_CPU=y +CT_ARCH_SUPPORTS_WITH_TUNE=y +CT_ARCH_EXCLUSIVE_WITH_CPU=y +CT_ARCH_ARCH="" +CT_TARGET_CFLAGS="" +CT_TARGET_LDFLAGS="" +# end of Target options + +# +# Toolchain options +# + +# +# General toolchain options +# +CT_FORCE_SYSROOT=y +CT_USE_SYSROOT=y +CT_SYSROOT_NAME="sysroot" +CT_SYSROOT_DIR_PREFIX="" +CT_WANTS_STATIC_LINK=y +CT_WANTS_STATIC_LINK_CXX=y +CT_STATIC_TOOLCHAIN=y +CT_SHOW_CT_VERSION=y +CT_TOOLCHAIN_PKGVERSION="" +CT_TOOLCHAIN_BUGURL="" + +# +# Tuple completion and aliasing +# +CT_TARGET_ALIAS_SED_EXPR="" +CT_TARGET_ALIAS="" + +# +# Toolchain type +# +CT_CROSS=y +# CT_CANADIAN is not set +CT_TOOLCHAIN_TYPE="cross" + +# +# Build system +# +CT_BUILD="" +CT_BUILD_PREFIX="" +CT_BUILD_SUFFIX="" + +# +# Misc options +# +# CT_TOOLCHAIN_ENABLE_NLS is not set +# end of Toolchain options + +# +# Operating System +# +CT_KERNEL_SUPPORTS_SHARED_LIBS=y +# CT_KERNEL_BARE_METAL is not set +CT_KERNEL_LINUX=y +CT_KERNEL="linux" +CT_KERNEL_CHOICE_KSYM="LINUX" +CT_KERNEL_LINUX_SHOW=y + +# +# Options for linux +# +CT_KERNEL_LINUX_PKG_KSYM="LINUX" +CT_LINUX_DIR_NAME="linux" +CT_LINUX_USE_WWW_KERNEL_ORG=y +# CT_LINUX_USE_ORACLE is not set +CT_LINUX_USE="LINUX" +CT_LINUX_PKG_NAME="linux" +CT_LINUX_SRC_RELEASE=y +# CT_LINUX_SRC_DEVEL is not set +CT_LINUX_PATCH_ORDER="global" +CT_LINUX_V_5_16=y +# CT_LINUX_V_5_15 is not set +# CT_LINUX_V_5_14 is not set +# CT_LINUX_V_5_13 is not set +# CT_LINUX_V_5_12 is not set +# CT_LINUX_V_5_11 is not set +# CT_LINUX_V_5_10 is not set +# CT_LINUX_V_5_9 is not set +# CT_LINUX_V_5_8 is not set +# CT_LINUX_V_5_7 is not set +# CT_LINUX_V_5_4 is not set +# CT_LINUX_V_5_3 is not set +# CT_LINUX_V_5_2 is not set +# CT_LINUX_V_5_1 is not set +# CT_LINUX_V_5_0 is not set +# CT_LINUX_V_4_20 is not set +# CT_LINUX_V_4_19 is not set +# CT_LINUX_V_4_18 is not set +# CT_LINUX_V_4_17 is not set +# CT_LINUX_V_4_16 is not set +# CT_LINUX_V_4_15 is not set +# CT_LINUX_V_4_14 is not set +# CT_LINUX_V_4_13 is not set +# CT_LINUX_V_4_12 is not set +# CT_LINUX_V_4_11 is not set +# CT_LINUX_V_4_10 is not set +# CT_LINUX_V_4_9 is not set +# CT_LINUX_V_4_4 is not set +# CT_LINUX_V_4_1 is not set +# CT_LINUX_V_3_16 is not set +# CT_LINUX_V_3_13 is not set +# CT_LINUX_V_3_12 is not set +# CT_LINUX_V_3_10 is not set +CT_LINUX_VERSION="5.16.9" +CT_LINUX_MIRRORS="$(CT_Mirrors kernel.org linux ${CT_LINUX_VERSION})" +CT_LINUX_ARCHIVE_FILENAME="@{pkg_name}-@{version}" +CT_LINUX_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" +CT_LINUX_ARCHIVE_FORMATS=".tar.xz .tar.gz" +CT_LINUX_SIGNATURE_FORMAT="unpacked/.sign" +CT_LINUX_later_than_5_12=y +CT_LINUX_5_12_or_later=y +CT_LINUX_later_than_5_3=y +CT_LINUX_5_3_or_later=y +CT_LINUX_later_than_4_8=y +CT_LINUX_4_8_or_later=y +CT_LINUX_later_than_3_7=y +CT_LINUX_3_7_or_later=y +CT_LINUX_REQUIRE_3_7_or_later=y +CT_LINUX_later_than_3_2=y +CT_LINUX_3_2_or_later=y +CT_KERNEL_DEP_RSYNC=y +CT_KERNEL_LINUX_VERBOSITY_0=y +# CT_KERNEL_LINUX_VERBOSITY_1 is not set +# CT_KERNEL_LINUX_VERBOSITY_2 is not set +CT_KERNEL_LINUX_VERBOSE_LEVEL=0 +CT_KERNEL_LINUX_INSTALL_CHECK=y +CT_ALL_KERNEL_CHOICES="BARE_METAL LINUX WINDOWS" + +# +# Common kernel options +# +CT_SHARED_LIBS=y +# end of Operating System + +# +# Binary utilities +# +CT_ARCH_BINFMT_ELF=y +CT_BINUTILS_BINUTILS=y +CT_BINUTILS="binutils" +CT_BINUTILS_CHOICE_KSYM="BINUTILS" +CT_BINUTILS_BINUTILS_SHOW=y + +# +# Options for binutils +# +CT_BINUTILS_BINUTILS_PKG_KSYM="BINUTILS" +CT_BINUTILS_DIR_NAME="binutils" +CT_BINUTILS_USE_GNU=y +# CT_BINUTILS_USE_ORACLE is not set +CT_BINUTILS_USE="BINUTILS" +CT_BINUTILS_PKG_NAME="binutils" +CT_BINUTILS_SRC_RELEASE=y +# CT_BINUTILS_SRC_DEVEL is not set +CT_BINUTILS_PATCH_ORDER="global" +CT_BINUTILS_V_2_29=y +# CT_BINUTILS_V_2_28 is not set +# CT_BINUTILS_V_2_27 is not set +# CT_BINUTILS_V_2_26 is not set +CT_BINUTILS_VERSION="2.29.1" +CT_BINUTILS_MIRRORS="$(CT_Mirrors GNU binutils) $(CT_Mirrors sourceware binutils/releases)" +CT_BINUTILS_ARCHIVE_FILENAME="@{pkg_name}-@{version}" +CT_BINUTILS_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" +CT_BINUTILS_ARCHIVE_FORMATS=".tar.xz .tar.bz2 .tar.gz" +CT_BINUTILS_SIGNATURE_FORMAT="packed/.sig" +CT_BINUTILS_2_30_or_older=y +CT_BINUTILS_older_than_2_30=y +CT_BINUTILS_REQUIRE_older_than_2_30=y +CT_BINUTILS_later_than_2_27=y +CT_BINUTILS_2_27_or_later=y +CT_BINUTILS_later_than_2_26=y +CT_BINUTILS_2_26_or_later=y + +# +# GNU binutils +# +CT_BINUTILS_GOLD_SUPPORTS_ARCH=y +CT_BINUTILS_FORCE_LD_BFD_DEFAULT=y +CT_BINUTILS_LINKER_LD=y +CT_BINUTILS_LINKERS_LIST="ld" +CT_BINUTILS_LINKER_DEFAULT="bfd" +CT_BINUTILS_RELRO=m +CT_BINUTILS_DETERMINISTIC_ARCHIVES=y +CT_BINUTILS_EXTRA_CONFIG_ARRAY="" +# CT_BINUTILS_FOR_TARGET is not set +CT_ALL_BINUTILS_CHOICES="BINUTILS" +# end of Binary utilities + +# +# C-library +# +CT_LIBC_GLIBC=y +# CT_LIBC_UCLIBC_NG is not set +CT_LIBC="glibc" +CT_LIBC_CHOICE_KSYM="GLIBC" +CT_THREADS="nptl" +CT_LIBC_GLIBC_SHOW=y + +# +# Options for glibc +# +CT_LIBC_GLIBC_PKG_KSYM="GLIBC" +CT_GLIBC_DIR_NAME="glibc" +CT_GLIBC_USE_GNU=y +# CT_GLIBC_USE_ORACLE is not set +CT_GLIBC_USE="GLIBC" +CT_GLIBC_PKG_NAME="glibc" +CT_GLIBC_SRC_RELEASE=y +# CT_GLIBC_SRC_DEVEL is not set +CT_GLIBC_PATCH_ORDER="global" +# CT_GLIBC_V_2_35 is not set +# CT_GLIBC_V_2_34 is not set +# CT_GLIBC_V_2_33 is not set +# CT_GLIBC_V_2_32 is not set +# CT_GLIBC_V_2_31 is not set +# CT_GLIBC_V_2_30 is not set +# CT_GLIBC_V_2_29 is not set +# CT_GLIBC_V_2_28 is not set +# CT_GLIBC_V_2_27 is not set +# CT_GLIBC_V_2_26 is not set +# CT_GLIBC_V_2_25 is not set +# CT_GLIBC_V_2_24 is not set +# CT_GLIBC_V_2_23 is not set +# CT_GLIBC_V_2_19 is not set +CT_GLIBC_V_2_17=y +CT_GLIBC_VERSION="2.17" +CT_GLIBC_MIRRORS="$(CT_Mirrors GNU glibc)" +CT_GLIBC_ARCHIVE_FILENAME="@{pkg_name}-@{version}" +CT_GLIBC_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" +CT_GLIBC_ARCHIVE_FORMATS=".tar.xz .tar.bz2 .tar.gz" +CT_GLIBC_SIGNATURE_FORMAT="packed/.sig" +CT_GLIBC_2_34_or_older=y +CT_GLIBC_older_than_2_34=y +CT_GLIBC_2_32_or_older=y +CT_GLIBC_older_than_2_32=y +CT_GLIBC_2_31_or_older=y +CT_GLIBC_older_than_2_31=y +CT_GLIBC_2_30_or_older=y +CT_GLIBC_older_than_2_30=y +CT_GLIBC_2_29_or_older=y +CT_GLIBC_older_than_2_29=y +CT_GLIBC_2_28_or_older=y +CT_GLIBC_older_than_2_28=y +CT_GLIBC_2_27_or_older=y +CT_GLIBC_older_than_2_27=y +CT_GLIBC_2_26_or_older=y +CT_GLIBC_older_than_2_26=y +CT_GLIBC_2_25_or_older=y +CT_GLIBC_older_than_2_25=y +CT_GLIBC_2_24_or_older=y +CT_GLIBC_older_than_2_24=y +CT_GLIBC_2_23_or_older=y +CT_GLIBC_older_than_2_23=y +CT_GLIBC_2_20_or_older=y +CT_GLIBC_older_than_2_20=y +CT_GLIBC_2_17_or_later=y +CT_GLIBC_2_17_or_older=y +CT_GLIBC_later_than_2_14=y +CT_GLIBC_2_14_or_later=y +CT_GLIBC_DEP_KERNEL_HEADERS_VERSION=y +CT_GLIBC_DEP_BINUTILS=y +CT_GLIBC_DEP_GCC=y +CT_GLIBC_DEP_PYTHON=y +CT_GLIBC_SPARC_ALLOW_V7=y +CT_GLIBC_HAS_NPTL_ADDON=y +CT_GLIBC_HAS_PORTS_ADDON=y +CT_GLIBC_HAS_LIBIDN_ADDON=y +CT_GLIBC_USE_PORTS_ADDON=y +CT_GLIBC_USE_NPTL_ADDON=y +# CT_GLIBC_USE_LIBIDN_ADDON is not set +CT_GLIBC_HAS_OBSOLETE_RPC=y +CT_GLIBC_EXTRA_CONFIG_ARRAY="" +CT_GLIBC_CONFIGPARMS="" +CT_GLIBC_EXTRA_CFLAGS="-Wno-missing-attributes -Wno-array-bounds -Wno-array-parameter -Wno-stringop-overflow -Wno-maybe-uninitialized" +CT_GLIBC_ENABLE_OBSOLETE_RPC=y +# CT_GLIBC_DISABLE_VERSIONING is not set +CT_GLIBC_OLDEST_ABI="2.17" +CT_GLIBC_FORCE_UNWIND=y +# CT_GLIBC_LOCALES is not set +# CT_GLIBC_KERNEL_VERSION_NONE is not set +CT_GLIBC_KERNEL_VERSION_AS_HEADERS=y +# CT_GLIBC_KERNEL_VERSION_CHOSEN is not set +CT_GLIBC_MIN_KERNEL="5.16.9" +CT_GLIBC_ENABLE_COMMON_FLAG=y +CT_ALL_LIBC_CHOICES="AVR_LIBC BIONIC GLIBC MINGW_W64 MOXIEBOX MUSL NEWLIB NONE UCLIBC_NG" +CT_LIBC_SUPPORT_THREADS_ANY=y +CT_LIBC_SUPPORT_THREADS_NATIVE=y + +# +# Common C library options +# +CT_THREADS_NATIVE=y +# CT_CREATE_LDSO_CONF is not set +CT_LIBC_XLDD=y +# end of C-library + +# +# C compiler +# +CT_CC_CORE_NEEDED=y +CT_CC_SUPPORT_CXX=y +CT_CC_SUPPORT_FORTRAN=y +CT_CC_SUPPORT_ADA=y +CT_CC_SUPPORT_OBJC=y +CT_CC_SUPPORT_OBJCXX=y +CT_CC_SUPPORT_GOLANG=y +CT_CC_GCC=y +CT_CC="gcc" +CT_CC_CHOICE_KSYM="GCC" +CT_CC_GCC_SHOW=y + +# +# Options for gcc +# +CT_CC_GCC_PKG_KSYM="GCC" +CT_GCC_DIR_NAME="gcc" +CT_GCC_USE_GNU=y +CT_GCC_USE="GCC" +CT_GCC_PKG_NAME="gcc" +CT_GCC_SRC_RELEASE=y +# CT_GCC_SRC_DEVEL is not set +CT_GCC_PATCH_ORDER="global" +CT_GCC_V_11=y +# CT_GCC_V_10 is not set +# CT_GCC_V_9 is not set +# CT_GCC_V_8 is not set +# CT_GCC_V_7 is not set +# CT_GCC_V_6 is not set +# CT_GCC_V_5 is not set +# CT_GCC_V_4_9 is not set +CT_GCC_VERSION="11.2.0" +CT_GCC_MIRRORS="$(CT_Mirrors GNU gcc/gcc-${CT_GCC_VERSION}) $(CT_Mirrors sourceware gcc/releases/gcc-${CT_GCC_VERSION})" +CT_GCC_ARCHIVE_FILENAME="@{pkg_name}-@{version}" +CT_GCC_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" +CT_GCC_ARCHIVE_FORMATS=".tar.xz .tar.gz" +CT_GCC_SIGNATURE_FORMAT="" +CT_GCC_later_than_11=y +CT_GCC_11_or_later=y +CT_GCC_later_than_10=y +CT_GCC_10_or_later=y +CT_GCC_later_than_9=y +CT_GCC_9_or_later=y +CT_GCC_later_than_8=y +CT_GCC_8_or_later=y +CT_GCC_later_than_7=y +CT_GCC_7_or_later=y +CT_GCC_later_than_6=y +CT_GCC_6_or_later=y +CT_GCC_later_than_5=y +CT_GCC_5_or_later=y +CT_GCC_later_than_4_9=y +CT_GCC_4_9_or_later=y +CT_CC_GCC_HAS_LIBMPX=y +CT_CC_GCC_ENABLE_CXX_FLAGS="" +CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY="" +CT_CC_GCC_EXTRA_CONFIG_ARRAY="" +CT_CC_GCC_STATIC_LIBSTDCXX=y +# CT_CC_GCC_SYSTEM_ZLIB is not set +CT_CC_GCC_CONFIG_TLS=m + +# +# Optimisation features +# +CT_CC_GCC_USE_GRAPHITE=y + +# +# Settings for libraries running on target +# +CT_CC_GCC_ENABLE_TARGET_OPTSPACE=y +# CT_CC_GCC_LIBMUDFLAP is not set +# CT_CC_GCC_LIBGOMP is not set +# CT_CC_GCC_LIBSSP is not set +# CT_CC_GCC_LIBQUADMATH is not set +# CT_CC_GCC_LIBSANITIZER is not set + +# +# Misc. obscure options. +# +CT_CC_CXA_ATEXIT=y +CT_CC_GCC_TM_CLONE_REGISTRY=m +# CT_CC_GCC_DISABLE_PCH is not set +CT_CC_GCC_SJLJ_EXCEPTIONS=m +CT_CC_GCC_LDBL_128=m +# CT_CC_GCC_BUILD_ID is not set +CT_CC_GCC_LNK_HASH_STYLE_DEFAULT=y +# CT_CC_GCC_LNK_HASH_STYLE_SYSV is not set +# CT_CC_GCC_LNK_HASH_STYLE_GNU is not set +# CT_CC_GCC_LNK_HASH_STYLE_BOTH is not set +CT_CC_GCC_LNK_HASH_STYLE="" +CT_CC_GCC_DEC_FLOATS_AUTO=y +# CT_CC_GCC_DEC_FLOATS_BID is not set +# CT_CC_GCC_DEC_FLOATS_DPD is not set +# CT_CC_GCC_DEC_FLOATS_NO is not set +CT_CC_GCC_DEC_FLOATS="" +CT_ALL_CC_CHOICES="GCC" + +# +# Additional supported languages: +# +CT_CC_LANG_CXX=y +# CT_CC_LANG_FORTRAN is not set +# end of C compiler + +# +# Debug facilities +# +# CT_DEBUG_DUMA is not set +# CT_DEBUG_GDB is not set +# CT_DEBUG_LTRACE is not set +# CT_DEBUG_STRACE is not set +CT_ALL_DEBUG_CHOICES="DUMA GDB LTRACE STRACE" +# end of Debug facilities + +# +# Companion libraries +# +# CT_COMPLIBS_CHECK is not set +# CT_COMP_LIBS_CLOOG is not set +# CT_COMP_LIBS_EXPAT is not set +CT_COMP_LIBS_GETTEXT=y +CT_COMP_LIBS_GETTEXT_PKG_KSYM="GETTEXT" +CT_GETTEXT_DIR_NAME="gettext" +CT_GETTEXT_PKG_NAME="gettext" +CT_GETTEXT_SRC_RELEASE=y +# CT_GETTEXT_SRC_DEVEL is not set +CT_GETTEXT_PATCH_ORDER="global" +CT_GETTEXT_V_0_21=y +# CT_GETTEXT_V_0_20_1 is not set +# CT_GETTEXT_V_0_19_8_1 is not set +CT_GETTEXT_VERSION="0.21" +CT_GETTEXT_MIRRORS="$(CT_Mirrors GNU gettext)" +CT_GETTEXT_ARCHIVE_FILENAME="@{pkg_name}-@{version}" +CT_GETTEXT_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" +CT_GETTEXT_ARCHIVE_FORMATS=".tar.xz .tar.gz" +CT_GETTEXT_SIGNATURE_FORMAT="packed/.sig" +CT_GETTEXT_0_21_or_later=y +CT_GETTEXT_0_21_or_older=y +CT_GETTEXT_INCOMPATIBLE_WITH_UCLIBC_NG=y + +# +# This version of gettext is not compatible with uClibc-NG. Select +# + +# +# a different version if uClibc-NG is used on the target or (in a +# + +# +# Canadian cross build) on the host. +# +CT_COMP_LIBS_GMP=y +CT_COMP_LIBS_GMP_PKG_KSYM="GMP" +CT_GMP_DIR_NAME="gmp" +CT_GMP_PKG_NAME="gmp" +CT_GMP_SRC_RELEASE=y +# CT_GMP_SRC_DEVEL is not set +CT_GMP_PATCH_ORDER="global" +CT_GMP_V_6_2=y +# CT_GMP_V_6_1 is not set +CT_GMP_VERSION="6.2.1" +CT_GMP_MIRRORS="https://gmplib.org/download/gmp https://gmplib.org/download/gmp/archive $(CT_Mirrors GNU gmp)" +CT_GMP_ARCHIVE_FILENAME="@{pkg_name}-@{version}" +CT_GMP_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" +CT_GMP_ARCHIVE_FORMATS=".tar.xz .tar.lz .tar.bz2" +CT_GMP_SIGNATURE_FORMAT="packed/.sig" +CT_COMP_LIBS_ISL=y +CT_COMP_LIBS_ISL_PKG_KSYM="ISL" +CT_ISL_DIR_NAME="isl" +CT_ISL_PKG_NAME="isl" +CT_ISL_SRC_RELEASE=y +# CT_ISL_SRC_DEVEL is not set +CT_ISL_PATCH_ORDER="global" +CT_ISL_V_0_24=y +# CT_ISL_V_0_23 is not set +# CT_ISL_V_0_22 is not set +# CT_ISL_V_0_21 is not set +# CT_ISL_V_0_20 is not set +# CT_ISL_V_0_19 is not set +# CT_ISL_V_0_18 is not set +# CT_ISL_V_0_17 is not set +# CT_ISL_V_0_16 is not set +# CT_ISL_V_0_15 is not set +CT_ISL_VERSION="0.24" +CT_ISL_MIRRORS="https://libisl.sourceforge.io" +CT_ISL_ARCHIVE_FILENAME="@{pkg_name}-@{version}" +CT_ISL_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" +CT_ISL_ARCHIVE_FORMATS=".tar.xz .tar.bz2 .tar.gz" +CT_ISL_SIGNATURE_FORMAT="" +CT_ISL_later_than_0_18=y +CT_ISL_0_18_or_later=y +CT_ISL_later_than_0_15=y +CT_ISL_0_15_or_later=y +# CT_COMP_LIBS_LIBELF is not set +CT_COMP_LIBS_LIBICONV=y +CT_COMP_LIBS_LIBICONV_PKG_KSYM="LIBICONV" +CT_LIBICONV_DIR_NAME="libiconv" +CT_LIBICONV_PKG_NAME="libiconv" +CT_LIBICONV_SRC_RELEASE=y +# CT_LIBICONV_SRC_DEVEL is not set +CT_LIBICONV_PATCH_ORDER="global" +CT_LIBICONV_V_1_16=y +# CT_LIBICONV_V_1_15 is not set +CT_LIBICONV_VERSION="1.16" +CT_LIBICONV_MIRRORS="$(CT_Mirrors GNU libiconv)" +CT_LIBICONV_ARCHIVE_FILENAME="@{pkg_name}-@{version}" +CT_LIBICONV_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" +CT_LIBICONV_ARCHIVE_FORMATS=".tar.gz" +CT_LIBICONV_SIGNATURE_FORMAT="packed/.sig" +CT_COMP_LIBS_MPC=y +CT_COMP_LIBS_MPC_PKG_KSYM="MPC" +CT_MPC_DIR_NAME="mpc" +CT_MPC_PKG_NAME="mpc" +CT_MPC_SRC_RELEASE=y +# CT_MPC_SRC_DEVEL is not set +CT_MPC_PATCH_ORDER="global" +CT_MPC_V_1_2=y +# CT_MPC_V_1_1 is not set +# CT_MPC_V_1_0 is not set +CT_MPC_VERSION="1.2.1" +CT_MPC_MIRRORS="http://www.multiprecision.org/downloads $(CT_Mirrors GNU mpc)" +CT_MPC_ARCHIVE_FILENAME="@{pkg_name}-@{version}" +CT_MPC_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" +CT_MPC_ARCHIVE_FORMATS=".tar.gz" +CT_MPC_SIGNATURE_FORMAT="packed/.sig" +CT_MPC_later_than_1_1_0=y +CT_MPC_1_1_0_or_later=y +CT_COMP_LIBS_MPFR=y +CT_COMP_LIBS_MPFR_PKG_KSYM="MPFR" +CT_MPFR_DIR_NAME="mpfr" +CT_MPFR_PKG_NAME="mpfr" +CT_MPFR_SRC_RELEASE=y +# CT_MPFR_SRC_DEVEL is not set +CT_MPFR_PATCH_ORDER="global" +CT_MPFR_V_4_1=y +# CT_MPFR_V_4_0 is not set +# CT_MPFR_V_3_1 is not set +CT_MPFR_VERSION="4.1.0" +CT_MPFR_MIRRORS="http://www.mpfr.org/mpfr-${CT_MPFR_VERSION} $(CT_Mirrors GNU mpfr)" +CT_MPFR_ARCHIVE_FILENAME="@{pkg_name}-@{version}" +CT_MPFR_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" +CT_MPFR_ARCHIVE_FORMATS=".tar.xz .tar.bz2 .tar.gz .zip" +CT_MPFR_SIGNATURE_FORMAT="packed/.asc" +CT_MPFR_later_than_4_0_0=y +CT_MPFR_4_0_0_or_later=y +CT_COMP_LIBS_NCURSES=y +CT_COMP_LIBS_NCURSES_PKG_KSYM="NCURSES" +CT_NCURSES_DIR_NAME="ncurses" +CT_NCURSES_PKG_NAME="ncurses" +CT_NCURSES_SRC_RELEASE=y +# CT_NCURSES_SRC_DEVEL is not set +CT_NCURSES_PATCH_ORDER="global" +CT_NCURSES_V_6_2=y +# CT_NCURSES_V_6_1 is not set +# CT_NCURSES_V_6_0 is not set +CT_NCURSES_VERSION="6.2" +CT_NCURSES_MIRRORS="https://invisible-mirror.net/archives/ncurses $(CT_Mirrors GNU ncurses)" +CT_NCURSES_ARCHIVE_FILENAME="@{pkg_name}-@{version}" +CT_NCURSES_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" +CT_NCURSES_ARCHIVE_FORMATS=".tar.gz" +CT_NCURSES_SIGNATURE_FORMAT="packed/.sig" +CT_NCURSES_NEW_ABI=y +CT_NCURSES_HOST_CONFIG_ARGS="" +CT_NCURSES_HOST_DISABLE_DB=y +CT_NCURSES_HOST_FALLBACKS="linux,xterm,xterm-color,xterm-256color,vt100" +CT_NCURSES_TARGET_CONFIG_ARGS="" +# CT_NCURSES_TARGET_DISABLE_DB is not set +CT_NCURSES_TARGET_FALLBACKS="" +CT_COMP_LIBS_ZLIB=y +CT_COMP_LIBS_ZLIB_PKG_KSYM="ZLIB" +CT_ZLIB_DIR_NAME="zlib" +CT_ZLIB_PKG_NAME="zlib" +CT_ZLIB_SRC_RELEASE=y +# CT_ZLIB_SRC_DEVEL is not set +CT_ZLIB_PATCH_ORDER="global" +CT_ZLIB_V_1_2_12=y +CT_ZLIB_VERSION="1.2.13" +CT_ZLIB_MIRRORS="http://downloads.sourceforge.net/project/libpng/zlib/${CT_ZLIB_VERSION} https://www.zlib.net/fossils/" +CT_ZLIB_ARCHIVE_FILENAME="@{pkg_name}-@{version}" +CT_ZLIB_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" +CT_ZLIB_ARCHIVE_FORMATS=".tar.xz .tar.gz" +CT_ZLIB_SIGNATURE_FORMAT="packed/.asc" +CT_ALL_COMP_LIBS_CHOICES="CLOOG EXPAT GETTEXT GMP GNUPRUMCU ISL LIBELF LIBICONV MPC MPFR NCURSES NEWLIB_NANO PICOLIBC ZLIB" +CT_LIBICONV_NEEDED=y +CT_GETTEXT_NEEDED=y +CT_GMP_NEEDED=y +CT_MPFR_NEEDED=y +CT_ISL_NEEDED=y +CT_MPC_NEEDED=y +CT_NCURSES_NEEDED=y +CT_ZLIB_NEEDED=y +CT_LIBICONV=y +CT_GETTEXT=y +CT_GMP=y +CT_MPFR=y +CT_ISL=y +CT_MPC=y +CT_NCURSES=y +CT_ZLIB=y +# end of Companion libraries + +# +# Companion tools +# +# CT_COMP_TOOLS_FOR_HOST is not set +# CT_COMP_TOOLS_AUTOCONF is not set +# CT_COMP_TOOLS_AUTOMAKE is not set +# CT_COMP_TOOLS_BISON is not set +# CT_COMP_TOOLS_DTC is not set +# CT_COMP_TOOLS_LIBTOOL is not set +# CT_COMP_TOOLS_M4 is not set +# CT_COMP_TOOLS_MAKE is not set +CT_ALL_COMP_TOOLS_CHOICES="AUTOCONF AUTOMAKE BISON DTC LIBTOOL M4 MAKE" +# end of Companion tools diff --git a/packages/cross-aarch64-linux-gnu/src/ppbt_cross_aarch64_linux_gnu/build.py b/packages/cross-aarch64-linux-gnu/src/ppbt_cross_aarch64_linux_gnu/build.py new file mode 100644 index 0000000..dec65e3 --- /dev/null +++ b/packages/cross-aarch64-linux-gnu/src/ppbt_cross_aarch64_linux_gnu/build.py @@ -0,0 +1,229 @@ +# Copyright 2024-2026 Broadcom Corporation +# SPDX-License-Identifier: Apache-2.0 +# +""" +Build a ``ppbt-cross-aarch64-linux-gnu`` wheel. + +Produces a crosstool-ng toolchain that runs on the wheel's host arch +(x86_64) and targets ``aarch64-linux-gnu``. The tarball is stashed +inside this package's ``_toolchain/`` dir so the base ``ppbt`` package +can discover it via the ``ppbt.toolchains`` entry point. +""" +import base64 +import csv +import hashlib +import http.client +import os +import pathlib +import shutil +import subprocess +import sys +import tarfile +import time +import urllib.error +import urllib.request + +from setuptools.build_meta import ( + build_editable as _build_editable_passthrough, + build_sdist, + build_wheel, + get_requires_for_build_sdist, + get_requires_for_build_wheel, + prepare_metadata_for_build_wheel, +) + + +def build_editable(wheel_directory, config_settings=None, metadata_directory=None): + """PEP 660 editable hook: skip the toolchain build.""" + return _build_editable_passthrough( + wheel_directory, config_settings, metadata_directory + ) + + +__all__ = ( + "build_sdist", + "build_wheel", + "build_editable", + "get_requires_for_build_sdist", + "get_requires_for_build_wheel", + "prepare_metadata_for_build_wheel", +) + +TRIPLET = "aarch64-linux-gnu" +PKG_MODULE = "ppbt_cross_aarch64_linux_gnu" +CT_NG_VER = "1.26.0" +CT_URL = "http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-{version}.tar.bz2" +CT_GIT_REPO = "https://github.com/crosstool-ng/crosstool-ng.git" +CICD = "CI" in os.environ +PATCHELF_VERSION = "0.18.0" +PATCHELF_SOURCE = ( + f"https://github.com/NixOS/patchelf/releases/download/" + f"{PATCHELF_VERSION}/patchelf-{PATCHELF_VERSION}.tar.gz" +) + +_build_wheel = build_wheel +_build_sdist = build_sdist + + +class BuildError(RuntimeError): + """Generic build error.""" + + +def _fetch(url, fp, backoff=3, timeout=30): + if backoff < 1: + backoff = 1 + n = 0 + while n < backoff: + n += 1 + try: + fin = urllib.request.urlopen(url, timeout=timeout) + break + except ( + urllib.error.HTTPError, + urllib.error.URLError, + http.client.RemoteDisconnected, + ): + if n >= backoff: + raise + time.sleep(n * 10) + try: + block = fin.read(1024 * 300) + while block: + fp.write(block) + block = fin.read(10240) + finally: + fin.close() + + +def download_url(url, dest): + """Download ``url`` to ``dest`` dir.""" + local = os.path.join(dest, os.path.basename(url)) + print(f"Downloading {url} -> {local}") + with open(local, "wb") as fout: + try: + _fetch(url, fout) + except Exception as exc: + print(f"Unable to download: {url} {exc}", file=sys.stderr, flush=True) + try: + os.unlink(local) + except OSError: + pass + raise + return local + + +def extract_archive(to_dir, archive): + """Extract ``archive`` (tar.gz / tar.xz / tar.bz2) into ``to_dir``.""" + if archive.endswith("tgz") or archive.endswith("gz"): + mode = "r:gz" + elif archive.endswith("xz"): + mode = "r:xz" + elif archive.endswith("bz2"): + mode = "r:bz2" + else: + mode = "r" + with tarfile.open(archive, mode) as t: + t.extractall(to_dir) + + +def runcmd(cmd, **kwargs): + """Run ``cmd``, raising :class:`BuildError` on non-zero exit.""" + proc = subprocess.run(cmd, **kwargs) + if proc.returncode != 0: + raise BuildError(f"Build cmd '{' '.join(str(c) for c in cmd)}' failed") + return proc + + +def _prepare_crosstool_ng(build): + ctngdir = build / f"crosstool-ng-{CT_NG_VER}" + if not ctngdir.exists(): + archive = download_url(CT_URL.format(version=CT_NG_VER), build) + extract_archive(build, archive) + ctng = ctngdir / "ct-ng" + if not ctng.exists(): + print("Compiling ct-ng") + os.chdir(ctngdir) + runcmd(["./configure", "--enable-local"]) + runcmd(["make"]) + return ctngdir, ctng + + +def _prepare_patchelf(build): + source = build / f"patchelf-{PATCHELF_VERSION}" + patchelf = source / "src" / "patchelf" + if not source.exists(): + archive = download_url(PATCHELF_SOURCE, build) + extract_archive(build, archive) + if not patchelf.exists(): + os.chdir(source) + runcmd(["./configure"]) + runcmd(["make"]) + return patchelf + + +def build_toolchain(): + """Build the cross toolchain and stage it inside this package.""" + cwd = pathlib.Path(os.getcwd()) + root = pathlib.Path(os.environ.get("PWD", os.getcwd())) + build = root / "build" + build.mkdir(exist_ok=True) + pkg_src = cwd / "src" / PKG_MODULE + toolchain_dir = pkg_src / "_toolchain" + toolchain_dir.mkdir(exist_ok=True) + config = pkg_src / "_config" / f"{TRIPLET}-ct-ng.config" + if not config.exists(): + print(f"Cross config missing: {config}", file=sys.stderr) + sys.exit(1) + try: + ctngdir, ctng = _prepare_crosstool_ng(build) + patchelf = _prepare_patchelf(build) + + archdir = build / TRIPLET + if not archdir.exists(): + with open(config, "r") as rfp, open(ctngdir / ".config", "w") as wfp: + wfp.write(rfp.read()) + os.chdir(ctngdir) + env = os.environ.copy() + env["CT_PREFIX"] = str(build) + if os.getuid() == 0: + env["CT_ALLOW_BUILD_AS_ROOT"] = "y" + env["CT_ALLOW_BUILD_AS_ROOT_SURE"] = "y" + if CICD: + env["CT_LOG_PROGRESS"] = "n" + runcmd([str(ctng), "source"], env=env) + runcmd([str(ctng), "build"], env=env) + + shutil.copy(patchelf, archdir / "bin" / "patchelf") + os.chdir(build) + archive = f"{TRIPLET}.tar.xz" + record = f"{TRIPLET}.tar.xz.record" + subprocess.run( + ["tar", "-C", str(build), "-cJf", archive, TRIPLET], check=True + ) + with open(record, "w") as rfp: + rwriter = csv.writer(rfp) + for walk_root, _dirs, files in os.walk(archdir): + relroot = pathlib.Path(walk_root).relative_to(build) + for f in files: + relpath = relroot / f + with open(relpath, "rb") as fp: + data = fp.read() + hsh = ( + base64.urlsafe_b64encode(hashlib.sha256(data).digest()) + .rstrip(b"=") + .decode() + ) + hashpath = str(pathlib.Path(PKG_MODULE) / "_toolchain" / relpath) + rwriter.writerow([hashpath, f"sha256={hsh}", len(data)]) + print(f"Copying {archive} to {toolchain_dir}") + shutil.copy(archive, toolchain_dir) + print(f"Copying {record} to {toolchain_dir}") + shutil.copy(record, toolchain_dir) + finally: + os.chdir(cwd) + + +def build_wheel(wheel_directory, metadata_directory=None, config_settings=None): + """PEP 517 wheel creation hook.""" + build_toolchain() + return _build_wheel(wheel_directory, metadata_directory, config_settings) diff --git a/packages/cross-x86_64-linux-gnu/LICENSE.md b/packages/cross-x86_64-linux-gnu/LICENSE.md new file mode 100644 index 0000000..6c3b205 --- /dev/null +++ b/packages/cross-x86_64-linux-gnu/LICENSE.md @@ -0,0 +1,184 @@ +Apache License +============== + +_Version 2.0, January 2004_ +_<>_ + +### 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_ + +Copyright (c) 2011-2022 VMware, Inc. All rights reserved. + +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/packages/cross-x86_64-linux-gnu/README.md b/packages/cross-x86_64-linux-gnu/README.md new file mode 100644 index 0000000..095fccb --- /dev/null +++ b/packages/cross-x86_64-linux-gnu/README.md @@ -0,0 +1,20 @@ +# ppbt-cross-x86_64-linux-gnu + +Cross-toolchain plugin for [ppbt](https://github.com/saltstack/ppbt). + +Ships a crosstool-ng-built GCC targeting `x86_64-linux-gnu` whose +driver binaries run on an `aarch64` host. Installed as an optional +extra of the base `ppbt` package: + +``` +pip install ppbt[cross-x86_64-linux-gnu] +``` + +Discovered at runtime by base `ppbt` via the `ppbt.toolchains` entry +point: + +```python +import ppbt +print(ppbt.available_triplets()) +env = ppbt.environ(triplet="x86_64-linux-gnu", auto_extract=True) +``` diff --git a/packages/cross-x86_64-linux-gnu/pyproject.toml b/packages/cross-x86_64-linux-gnu/pyproject.toml new file mode 100644 index 0000000..36899d6 --- /dev/null +++ b/packages/cross-x86_64-linux-gnu/pyproject.toml @@ -0,0 +1,13 @@ +[build-system] +requires = [ + "setuptools>=38.6.0", + "wheel>=0.31.0", + "twine>=1.11.0" +] +build-backend = "ppbt_cross_x86_64_linux_gnu.build" +backend-path = ["src"] + +[tool.pytest.ini_options] +pythonpath = [ + "src" +] diff --git a/packages/cross-x86_64-linux-gnu/setup.cfg b/packages/cross-x86_64-linux-gnu/setup.cfg new file mode 100644 index 0000000..6c19476 --- /dev/null +++ b/packages/cross-x86_64-linux-gnu/setup.cfg @@ -0,0 +1,34 @@ +[metadata] +name = ppbt-cross-x86_64-linux-gnu +version = attr: ppbt_cross_x86_64_linux_gnu.__version__ +author = Daniel A. Wozniak +author_email = +long-description-content-type = text/markdown +long_description = file: README.md +description = Portable Python Build Toolchain - x86_64-linux-gnu cross toolchain +license = Apache License 2.0 +license_file = LICENSE.md +url = https://github.com/saltstack/ppbt +bug_tracker = https://github.com/saltstack/ppbt/issues +classifiers = + Programming Language :: Python :: 3 + License :: OSI Approved :: Apache Software License + Development Status :: 2 - Pre-Alpha + Operating System :: POSIX :: Linux + +[options] +package_dir= + =src +packages = find: +python_requires = >=3 +include_package_data = True + +[options.packages.find] +where=src + +[options.package_data] +*=_config/**, _toolchain/** + +[options.entry_points] +ppbt.toolchains = + x86_64-linux-gnu = ppbt_cross_x86_64_linux_gnu diff --git a/packages/cross-x86_64-linux-gnu/setup.py b/packages/cross-x86_64-linux-gnu/setup.py new file mode 100644 index 0000000..3d9e58b --- /dev/null +++ b/packages/cross-x86_64-linux-gnu/setup.py @@ -0,0 +1,26 @@ +# Copyright 2024-2026 Broadcom Corporation +# SPDX-License-Identifier: Apache-2.0 +# +import platform + +from setuptools import setup + +# Keep in sync with ppbt's base crosstool-ng config. +GLIBC_VERSION = "2.17" + + +def plat_name(): + # The cross wheel ships binaries that *run on* the build host and + # emit code for a different target. The wheel's platform tag is the + # host's, not the target's. + return f"manylinux_{GLIBC_VERSION.replace('.', '_')}_{platform.machine()}" + + +setup( + options={ + "bdist_wheel": { + "plat_name": f"{plat_name()}", + "python_tag": "py3", + } + } +) diff --git a/packages/cross-x86_64-linux-gnu/src/ppbt_cross_x86_64_linux_gnu/__init__.py b/packages/cross-x86_64-linux-gnu/src/ppbt_cross_x86_64_linux_gnu/__init__.py new file mode 100644 index 0000000..2ace1cf --- /dev/null +++ b/packages/cross-x86_64-linux-gnu/src/ppbt_cross_x86_64_linux_gnu/__init__.py @@ -0,0 +1,23 @@ +# Copyright 2024-2026 Broadcom Corporation +# SPDX-License-Identifier: Apache-2.0 +""" +Cross toolchain plugin: x86_64-linux-gnu target. + +This package ships a crosstool-ng-built GCC targeting +``x86_64-linux-gnu`` whose driver binaries run on the wheel's host arch +(aarch64). Discovered by the base ``ppbt`` package at runtime via the +``ppbt.toolchains`` entry point. +""" +import pathlib + +__version__ = "0.2.0" + +TRIPLET = "x86_64-linux-gnu" +TOOLCHAIN_ROOT = pathlib.Path(__file__).parent / "_toolchain" +ARCHIVE = TOOLCHAIN_ROOT / f"{TRIPLET}.tar.xz" +TOOLCHAIN = TOOLCHAIN_ROOT / TRIPLET + +DISTINFO = ( + pathlib.Path(__file__).resolve().parent.parent + / f"ppbt_cross_x86_64_linux_gnu-{__version__}.dist-info" +) diff --git a/packages/cross-x86_64-linux-gnu/src/ppbt_cross_x86_64_linux_gnu/_config/x86_64-linux-gnu-ct-ng.config b/packages/cross-x86_64-linux-gnu/src/ppbt_cross_x86_64_linux_gnu/_config/x86_64-linux-gnu-ct-ng.config new file mode 100644 index 0000000..e3ef31e --- /dev/null +++ b/packages/cross-x86_64-linux-gnu/src/ppbt_cross_x86_64_linux_gnu/_config/x86_64-linux-gnu-ct-ng.config @@ -0,0 +1,800 @@ +# +# Automatically generated file; DO NOT EDIT. +# crosstool-NG 1.25.0 Configuration +# +CT_CONFIGURE_has_static_link=y +CT_CONFIGURE_has_cxx11=y +CT_CONFIGURE_has_wget=y +CT_CONFIGURE_has_curl=y +CT_CONFIGURE_has_rsync=y +CT_CONFIGURE_has_make_3_81_or_newer=y +CT_CONFIGURE_has_make_4_0_or_newer=y +CT_CONFIGURE_has_libtool_2_4_or_newer=y +CT_CONFIGURE_has_libtoolize_2_4_or_newer=y +CT_CONFIGURE_has_autoconf_2_65_or_newer=y +CT_CONFIGURE_has_autoreconf_2_65_or_newer=y +CT_CONFIGURE_has_automake_1_15_or_newer=y +CT_CONFIGURE_has_gnu_m4_1_4_12_or_newer=y +CT_CONFIGURE_has_python_3_4_or_newer=y +CT_CONFIGURE_has_bison_2_7_or_newer=y +CT_CONFIGURE_has_python=y +CT_CONFIGURE_has_dtc=y +CT_CONFIGURE_has_git=y +CT_CONFIGURE_has_md5sum=y +CT_CONFIGURE_has_sha1sum=y +CT_CONFIGURE_has_sha256sum=y +CT_CONFIGURE_has_sha512sum=y +CT_CONFIGURE_has_install_with_strip_program=y +CT_VERSION="1.25.0" +CT_VCHECK="" +CT_CONFIG_VERSION_ENV="4" +CT_CONFIG_VERSION_CURRENT="4" +CT_CONFIG_VERSION="4" +CT_MODULES=y + +# +# Paths and misc options +# + +# +# crosstool-NG behavior +# +# CT_OBSOLETE is not set +# CT_EXPERIMENTAL is not set +# CT_DEBUG_CT is not set + +# +# Paths +# +CT_LOCAL_TARBALLS_DIR="${HOME}/src" +CT_SAVE_TARBALLS=y +# CT_TARBALLS_BUILDROOT_LAYOUT is not set +CT_WORK_DIR="${CT_TOP_DIR}/.build" +CT_BUILD_TOP_DIR="${CT_WORK_DIR:-${CT_TOP_DIR}/.build}/${CT_HOST:+HOST-${CT_HOST}/}${CT_TARGET}" +CT_BUILD_DIR="${CT_BUILD_TOP_DIR}/build" +CT_PREFIX_DIR="${CT_PREFIX:-${HOME}/x-tools}/${CT_HOST:+HOST-${CT_HOST}/}${CT_TARGET}" +CT_RM_RF_PREFIX_DIR=y +CT_REMOVE_DOCS=y +CT_INSTALL_LICENSES=y +# CT_PREFIX_DIR_RO is not set +CT_STRIP_HOST_TOOLCHAIN_EXECUTABLES=y +# CT_STRIP_TARGET_TOOLCHAIN_EXECUTABLES is not set + +# +# Downloading +# +CT_DOWNLOAD_AGENT_WGET=y +# CT_DOWNLOAD_AGENT_CURL is not set +# CT_DOWNLOAD_AGENT_NONE is not set +# CT_FORBID_DOWNLOAD is not set +# CT_FORCE_DOWNLOAD is not set +CT_CONNECT_TIMEOUT=10 +CT_DOWNLOAD_WGET_OPTIONS="--passive-ftp --tries=3 -nc --progress=dot:binary" +# CT_ONLY_DOWNLOAD is not set +# CT_USE_MIRROR is not set +CT_VERIFY_DOWNLOAD_DIGEST=y +CT_VERIFY_DOWNLOAD_DIGEST_SHA512=y +# CT_VERIFY_DOWNLOAD_DIGEST_SHA256 is not set +# CT_VERIFY_DOWNLOAD_DIGEST_SHA1 is not set +# CT_VERIFY_DOWNLOAD_DIGEST_MD5 is not set +CT_VERIFY_DOWNLOAD_DIGEST_ALG="sha512" +# CT_VERIFY_DOWNLOAD_SIGNATURE is not set + +# +# Extracting +# +# CT_FORCE_EXTRACT is not set +CT_OVERRIDE_CONFIG_GUESS_SUB=y +# CT_ONLY_EXTRACT is not set +CT_PATCH_BUNDLED=y +# CT_PATCH_BUNDLED_LOCAL is not set +CT_PATCH_ORDER="bundled" + +# +# Build behavior +# +CT_PARALLEL_JOBS=0 +CT_LOAD="" +CT_USE_PIPES=y +CT_EXTRA_CFLAGS_FOR_BUILD="" +CT_EXTRA_CXXFLAGS_FOR_BUILD="" +CT_EXTRA_LDFLAGS_FOR_BUILD="" +CT_EXTRA_CFLAGS_FOR_HOST="" +CT_EXTRA_LDFLAGS_FOR_HOST="" +# CT_CONFIG_SHELL_SH is not set +# CT_CONFIG_SHELL_ASH is not set +CT_CONFIG_SHELL_BASH=y +# CT_CONFIG_SHELL_CUSTOM is not set +CT_CONFIG_SHELL="${bash}" + +# +# Logging +# +# CT_LOG_ERROR is not set +# CT_LOG_WARN is not set +# CT_LOG_INFO is not set +CT_LOG_EXTRA=y +# CT_LOG_ALL is not set +# CT_LOG_DEBUG is not set +CT_LOG_LEVEL_MAX="EXTRA" +# CT_LOG_SEE_TOOLS_WARN is not set +CT_LOG_PROGRESS_BAR=n +CT_LOG_TO_FILE=y +CT_LOG_FILE_COMPRESS=y +# end of Paths and misc options + +# +# Target options +# +# CT_ARCH_ALPHA is not set +# CT_ARCH_ARC is not set +# CT_ARCH_ARM is not set +# CT_ARCH_AVR is not set +# CT_ARCH_M68K is not set +# CT_ARCH_MIPS is not set +# CT_ARCH_NIOS2 is not set +# CT_ARCH_POWERPC is not set +# CT_ARCH_PRU is not set +# CT_ARCH_S390 is not set +# CT_ARCH_SH is not set +# CT_ARCH_SPARC is not set +CT_ARCH_X86=y +# CT_ARCH_XTENSA is not set +CT_ARCH="x86" +CT_ARCH_CHOICE_KSYM="X86" +CT_ARCH_CPU="" +CT_ARCH_TUNE="" +CT_ARCH_X86_SHOW=y + +# +# Options for x86 +# +CT_ARCH_X86_PKG_KSYM="" +CT_ALL_ARCH_CHOICES="ALPHA ARC ARM AVR C6X M68K MICROBLAZE MIPS MOXIE MSP430 NIOS2 POWERPC PRU RISCV S390 SH SPARC X86 XTENSA" +CT_ARCH_SUFFIX="" +CT_OMIT_TARGET_VENDOR=y + +# +# Generic target options +# +# CT_MULTILIB is not set +CT_DEMULTILIB=y +CT_ARCH_USE_MMU=y +CT_ARCH_SUPPORTS_32=y +CT_ARCH_SUPPORTS_64=y +CT_ARCH_DEFAULT_32=y +CT_ARCH_BITNESS=64 +# CT_ARCH_32 is not set +CT_ARCH_64=y +CT_ARCH_SUPPORTS_WITH_32_64=y + +# +# Target optimisations +# +CT_ARCH_SUPPORTS_WITH_ARCH=y +CT_ARCH_SUPPORTS_WITH_CPU=y +CT_ARCH_SUPPORTS_WITH_TUNE=y +CT_ARCH_ARCH="" +CT_TARGET_CFLAGS="" +CT_TARGET_LDFLAGS="" +# end of Target options + +# +# Toolchain options +# + +# +# General toolchain options +# +CT_FORCE_SYSROOT=y +CT_USE_SYSROOT=y +CT_SYSROOT_NAME="sysroot" +CT_SYSROOT_DIR_PREFIX="" +CT_WANTS_STATIC_LINK=y +CT_WANTS_STATIC_LINK_CXX=y +CT_STATIC_TOOLCHAIN=y +CT_SHOW_CT_VERSION=y +CT_TOOLCHAIN_PKGVERSION="" +CT_TOOLCHAIN_BUGURL="" + +# +# Tuple completion and aliasing +# +CT_TARGET_ALIAS_SED_EXPR="" +CT_TARGET_ALIAS="" + +# +# Toolchain type +# +CT_CROSS=y +# CT_CANADIAN is not set +CT_TOOLCHAIN_TYPE="cross" + +# +# Build system +# +CT_BUILD="" +CT_BUILD_PREFIX="" +CT_BUILD_SUFFIX="" + +# +# Misc options +# +# CT_TOOLCHAIN_ENABLE_NLS is not set +# end of Toolchain options + +# +# Operating System +# +CT_KERNEL_SUPPORTS_SHARED_LIBS=y +# CT_KERNEL_BARE_METAL is not set +CT_KERNEL_LINUX=y +CT_KERNEL="linux" +CT_KERNEL_CHOICE_KSYM="LINUX" +CT_KERNEL_LINUX_SHOW=y + +# +# Options for linux +# +CT_KERNEL_LINUX_PKG_KSYM="LINUX" +CT_LINUX_DIR_NAME="linux" +CT_LINUX_USE_WWW_KERNEL_ORG=y +# CT_LINUX_USE_ORACLE is not set +CT_LINUX_USE="LINUX" +CT_LINUX_PKG_NAME="linux" +CT_LINUX_SRC_RELEASE=y +# CT_LINUX_SRC_DEVEL is not set +CT_LINUX_PATCH_ORDER="global" +CT_LINUX_V_5_16=y +# CT_LINUX_V_5_15 is not set +# CT_LINUX_V_5_14 is not set +# CT_LINUX_V_5_13 is not set +# CT_LINUX_V_5_12 is not set +# CT_LINUX_V_5_11 is not set +# CT_LINUX_V_5_10 is not set +# CT_LINUX_V_5_9 is not set +# CT_LINUX_V_5_8 is not set +# CT_LINUX_V_5_7 is not set +# CT_LINUX_V_5_4 is not set +# CT_LINUX_V_5_3 is not set +# CT_LINUX_V_5_2 is not set +# CT_LINUX_V_5_1 is not set +# CT_LINUX_V_5_0 is not set +# CT_LINUX_V_4_20 is not set +# CT_LINUX_V_4_19 is not set +# CT_LINUX_V_4_18 is not set +# CT_LINUX_V_4_17 is not set +# CT_LINUX_V_4_16 is not set +# CT_LINUX_V_4_15 is not set +# CT_LINUX_V_4_14 is not set +# CT_LINUX_V_4_13 is not set +# CT_LINUX_V_4_12 is not set +# CT_LINUX_V_4_11 is not set +# CT_LINUX_V_4_10 is not set +# CT_LINUX_V_4_9 is not set +# CT_LINUX_V_4_4 is not set +# CT_LINUX_V_4_1 is not set +# CT_LINUX_V_3_16 is not set +# CT_LINUX_V_3_13 is not set +# CT_LINUX_V_3_12 is not set +# CT_LINUX_V_3_10 is not set +# CT_LINUX_V_3_4 is not set +# CT_LINUX_V_3_2 is not set +# CT_LINUX_V_2_6_32 is not set +CT_LINUX_VERSION="5.16.9" +CT_LINUX_MIRRORS="$(CT_Mirrors kernel.org linux ${CT_LINUX_VERSION})" +CT_LINUX_ARCHIVE_FILENAME="@{pkg_name}-@{version}" +CT_LINUX_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" +CT_LINUX_ARCHIVE_FORMATS=".tar.xz .tar.gz" +CT_LINUX_SIGNATURE_FORMAT="unpacked/.sign" +CT_LINUX_later_than_5_12=y +CT_LINUX_5_12_or_later=y +CT_LINUX_later_than_5_3=y +CT_LINUX_5_3_or_later=y +CT_LINUX_later_than_4_8=y +CT_LINUX_4_8_or_later=y +CT_LINUX_later_than_3_7=y +CT_LINUX_3_7_or_later=y +CT_LINUX_later_than_3_2=y +CT_LINUX_3_2_or_later=y +CT_KERNEL_DEP_RSYNC=y +CT_KERNEL_LINUX_VERBOSITY_0=y +# CT_KERNEL_LINUX_VERBOSITY_1 is not set +# CT_KERNEL_LINUX_VERBOSITY_2 is not set +CT_KERNEL_LINUX_VERBOSE_LEVEL=0 +CT_KERNEL_LINUX_INSTALL_CHECK=y +CT_ALL_KERNEL_CHOICES="BARE_METAL LINUX WINDOWS" + +# +# Common kernel options +# +CT_SHARED_LIBS=y +# end of Operating System + +# +# Binary utilities +# +CT_ARCH_BINFMT_ELF=y +CT_BINUTILS_BINUTILS=y +CT_BINUTILS="binutils" +CT_BINUTILS_CHOICE_KSYM="BINUTILS" +CT_BINUTILS_BINUTILS_SHOW=y + +# +# Options for binutils +# +CT_BINUTILS_BINUTILS_PKG_KSYM="BINUTILS" +CT_BINUTILS_DIR_NAME="binutils" +CT_BINUTILS_USE_GNU=y +# CT_BINUTILS_USE_ORACLE is not set +CT_BINUTILS_USE="BINUTILS" +CT_BINUTILS_PKG_NAME="binutils" +CT_BINUTILS_SRC_RELEASE=y +# CT_BINUTILS_SRC_DEVEL is not set +CT_BINUTILS_PATCH_ORDER="global" +# CT_BINUTILS_V_2_38 is not set +# CT_BINUTILS_V_2_37 is not set +# CT_BINUTILS_V_2_36 is not set +# CT_BINUTILS_V_2_35 is not set +# CT_BINUTILS_V_2_34 is not set +# CT_BINUTILS_V_2_33 is not set +# CT_BINUTILS_V_2_32 is not set +# CT_BINUTILS_V_2_31 is not set +# CT_BINUTILS_V_2_30 is not set +CT_BINUTILS_V_2_29=y +# CT_BINUTILS_V_2_28 is not set +# CT_BINUTILS_V_2_27 is not set +# CT_BINUTILS_V_2_26 is not set +CT_BINUTILS_VERSION="2.29.1" +CT_BINUTILS_MIRRORS="$(CT_Mirrors GNU binutils) $(CT_Mirrors sourceware binutils/releases)" +CT_BINUTILS_ARCHIVE_FILENAME="@{pkg_name}-@{version}" +CT_BINUTILS_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" +CT_BINUTILS_ARCHIVE_FORMATS=".tar.xz .tar.bz2 .tar.gz" +CT_BINUTILS_SIGNATURE_FORMAT="packed/.sig" +CT_BINUTILS_2_30_or_older=y +CT_BINUTILS_older_than_2_30=y +CT_BINUTILS_later_than_2_27=y +CT_BINUTILS_2_27_or_later=y +CT_BINUTILS_later_than_2_26=y +CT_BINUTILS_2_26_or_later=y + +# +# GNU binutils +# +CT_BINUTILS_GOLD_SUPPORTS_ARCH=y +CT_BINUTILS_FORCE_LD_BFD_DEFAULT=y +CT_BINUTILS_LINKER_LD=y +CT_BINUTILS_LINKERS_LIST="ld" +CT_BINUTILS_LINKER_DEFAULT="bfd" +CT_BINUTILS_RELRO=m +CT_BINUTILS_DETERMINISTIC_ARCHIVES=y +CT_BINUTILS_EXTRA_CONFIG_ARRAY="" +# CT_BINUTILS_FOR_TARGET is not set +CT_ALL_BINUTILS_CHOICES="BINUTILS" +# end of Binary utilities + +# +# C-library +# +CT_LIBC_GLIBC=y +# CT_LIBC_UCLIBC_NG is not set +CT_LIBC="glibc" +CT_LIBC_CHOICE_KSYM="GLIBC" +CT_THREADS="nptl" +CT_LIBC_GLIBC_SHOW=y + +# +# Options for glibc +# +CT_LIBC_GLIBC_PKG_KSYM="GLIBC" +CT_GLIBC_DIR_NAME="glibc" +CT_GLIBC_USE_GNU=y +# CT_GLIBC_USE_ORACLE is not set +CT_GLIBC_USE="GLIBC" +CT_GLIBC_PKG_NAME="glibc" +CT_GLIBC_SRC_RELEASE=y +# CT_GLIBC_SRC_DEVEL is not set +CT_GLIBC_PATCH_ORDER="global" +# CT_GLIBC_V_2_35 is not set +# CT_GLIBC_V_2_34 is not set +# CT_GLIBC_V_2_33 is not set +# CT_GLIBC_V_2_32 is not set +# CT_GLIBC_V_2_31 is not set +# CT_GLIBC_V_2_30 is not set +# CT_GLIBC_V_2_29 is not set +# CT_GLIBC_V_2_28 is not set +# CT_GLIBC_V_2_27 is not set +# CT_GLIBC_V_2_26 is not set +# CT_GLIBC_V_2_25 is not set +# CT_GLIBC_V_2_24 is not set +# CT_GLIBC_V_2_23 is not set +# CT_GLIBC_V_2_19 is not set +CT_GLIBC_V_2_17=y +CT_GLIBC_VERSION="2.17" +CT_GLIBC_MIRRORS="$(CT_Mirrors GNU glibc)" +CT_GLIBC_ARCHIVE_FILENAME="@{pkg_name}-@{version}" +CT_GLIBC_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" +CT_GLIBC_ARCHIVE_FORMATS=".tar.xz .tar.bz2 .tar.gz" +CT_GLIBC_SIGNATURE_FORMAT="packed/.sig" +CT_GLIBC_2_34_or_older=y +CT_GLIBC_older_than_2_34=y +CT_GLIBC_2_32_or_older=y +CT_GLIBC_older_than_2_32=y +CT_GLIBC_2_31_or_older=y +CT_GLIBC_older_than_2_31=y +CT_GLIBC_2_30_or_older=y +CT_GLIBC_older_than_2_30=y +CT_GLIBC_2_29_or_older=y +CT_GLIBC_older_than_2_29=y +CT_GLIBC_2_28_or_older=y +CT_GLIBC_older_than_2_28=y +CT_GLIBC_2_27_or_older=y +CT_GLIBC_older_than_2_27=y +CT_GLIBC_2_26_or_older=y +CT_GLIBC_older_than_2_26=y +CT_GLIBC_2_25_or_older=y +CT_GLIBC_older_than_2_25=y +CT_GLIBC_2_24_or_older=y +CT_GLIBC_older_than_2_24=y +CT_GLIBC_2_23_or_older=y +CT_GLIBC_older_than_2_23=y +CT_GLIBC_2_20_or_older=y +CT_GLIBC_older_than_2_20=y +CT_GLIBC_2_17_or_later=y +CT_GLIBC_2_17_or_older=y +CT_GLIBC_later_than_2_14=y +CT_GLIBC_2_14_or_later=y +CT_GLIBC_DEP_KERNEL_HEADERS_VERSION=y +CT_GLIBC_DEP_BINUTILS=y +CT_GLIBC_DEP_GCC=y +CT_GLIBC_DEP_PYTHON=y +CT_GLIBC_SPARC_ALLOW_V7=y +CT_GLIBC_HAS_NPTL_ADDON=y +CT_GLIBC_HAS_PORTS_ADDON=y +CT_GLIBC_HAS_LIBIDN_ADDON=y +CT_GLIBC_USE_NPTL_ADDON=y +# CT_GLIBC_USE_LIBIDN_ADDON is not set +CT_GLIBC_HAS_OBSOLETE_RPC=y +CT_GLIBC_EXTRA_CONFIG_ARRAY="" +CT_GLIBC_CONFIGPARMS="" +CT_GLIBC_EXTRA_CFLAGS="-Wno-missing-attributes -Wno-array-bounds -Wno-array-parameter -Wno-stringop-overflow -Wno-maybe-uninitialized" +CT_GLIBC_ENABLE_OBSOLETE_RPC=y +# CT_GLIBC_DISABLE_VERSIONING is not set +CT_GLIBC_OLDEST_ABI="glibc-2.17" +CT_GLIBC_FORCE_UNWIND=y +# CT_GLIBC_LOCALES is not set +# CT_GLIBC_KERNEL_VERSION_NONE is not set +CT_GLIBC_KERNEL_VERSION_AS_HEADERS=y +# CT_GLIBC_KERNEL_VERSION_CHOSEN is not set +CT_GLIBC_MIN_KERNEL="5.16.9" +CT_GLIBC_ENABLE_COMMON_FLAG=y +CT_ALL_LIBC_CHOICES="AVR_LIBC BIONIC GLIBC MINGW_W64 MOXIEBOX MUSL NEWLIB NONE UCLIBC_NG" +CT_LIBC_SUPPORT_THREADS_ANY=y +CT_LIBC_SUPPORT_THREADS_NATIVE=y + +# +# Common C library options +# +CT_THREADS_NATIVE=y +# CT_CREATE_LDSO_CONF is not set +# CT_LIBC_XLDD is not set +# end of C-library + +# +# C compiler +# +CT_CC_CORE_NEEDED=y +CT_CC_SUPPORT_CXX=y +CT_CC_SUPPORT_FORTRAN=y +CT_CC_SUPPORT_ADA=y +CT_CC_SUPPORT_OBJC=y +CT_CC_SUPPORT_OBJCXX=y +CT_CC_SUPPORT_GOLANG=y +CT_CC_GCC=y +CT_CC="gcc" +CT_CC_CHOICE_KSYM="GCC" +CT_CC_GCC_SHOW=y + +# +# Options for gcc +# +CT_CC_GCC_PKG_KSYM="GCC" +CT_GCC_DIR_NAME="gcc" +CT_GCC_USE_GNU=y +CT_GCC_USE="GCC" +CT_GCC_PKG_NAME="gcc" +CT_GCC_SRC_RELEASE=y +# CT_GCC_SRC_DEVEL is not set +CT_GCC_PATCH_ORDER="global" +CT_GCC_V_11=y +# CT_GCC_V_10 is not set +# CT_GCC_V_9 is not set +# CT_GCC_V_8 is not set +# CT_GCC_V_7 is not set +# CT_GCC_V_6 is not set +# CT_GCC_V_5 is not set +# CT_GCC_V_4_9 is not set +CT_GCC_VERSION="11.2.0" +CT_GCC_MIRRORS="$(CT_Mirrors GNU gcc/gcc-${CT_GCC_VERSION}) $(CT_Mirrors sourceware gcc/releases/gcc-${CT_GCC_VERSION})" +CT_GCC_ARCHIVE_FILENAME="@{pkg_name}-@{version}" +CT_GCC_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" +CT_GCC_ARCHIVE_FORMATS=".tar.xz .tar.gz" +CT_GCC_SIGNATURE_FORMAT="" +CT_GCC_later_than_11=y +CT_GCC_11_or_later=y +CT_GCC_later_than_10=y +CT_GCC_10_or_later=y +CT_GCC_later_than_9=y +CT_GCC_9_or_later=y +CT_GCC_later_than_8=y +CT_GCC_8_or_later=y +CT_GCC_later_than_7=y +CT_GCC_7_or_later=y +CT_GCC_later_than_6=y +CT_GCC_6_or_later=y +CT_GCC_later_than_5=y +CT_GCC_5_or_later=y +CT_GCC_later_than_4_9=y +CT_GCC_4_9_or_later=y +CT_CC_GCC_HAS_LIBMPX=y +CT_CC_GCC_ENABLE_CXX_FLAGS="" +CT_CC_GCC_CORE_EXTRA_CONFIG_ARRAY="" +CT_CC_GCC_EXTRA_CONFIG_ARRAY="" +CT_CC_GCC_STATIC_LIBSTDCXX=y +# CT_CC_GCC_SYSTEM_ZLIB is not set +CT_CC_GCC_CONFIG_TLS=m + +# +# Optimisation features +# +CT_CC_GCC_USE_GRAPHITE=y + +# +# Settings for libraries running on target +# +CT_CC_GCC_ENABLE_TARGET_OPTSPACE=y +# CT_CC_GCC_LIBMUDFLAP is not set +# CT_CC_GCC_LIBGOMP is not set +# CT_CC_GCC_LIBSSP is not set +# CT_CC_GCC_LIBQUADMATH is not set +# CT_CC_GCC_LIBSANITIZER is not set +# CT_CC_GCC_LIBMPX is not set + +# +# Misc. obscure options. +# +CT_CC_CXA_ATEXIT=y +CT_CC_GCC_TM_CLONE_REGISTRY=m +# CT_CC_GCC_DISABLE_PCH is not set +CT_CC_GCC_SJLJ_EXCEPTIONS=m +CT_CC_GCC_LDBL_128=m +# CT_CC_GCC_BUILD_ID is not set +CT_CC_GCC_LNK_HASH_STYLE_DEFAULT=y +# CT_CC_GCC_LNK_HASH_STYLE_SYSV is not set +# CT_CC_GCC_LNK_HASH_STYLE_GNU is not set +# CT_CC_GCC_LNK_HASH_STYLE_BOTH is not set +CT_CC_GCC_LNK_HASH_STYLE="" +CT_CC_GCC_DEC_FLOATS_AUTO=y +# CT_CC_GCC_DEC_FLOATS_BID is not set +# CT_CC_GCC_DEC_FLOATS_DPD is not set +# CT_CC_GCC_DEC_FLOATS_NO is not set +CT_CC_GCC_DEC_FLOATS="" +CT_ALL_CC_CHOICES="GCC" + +# +# Additional supported languages: +# +CT_CC_LANG_CXX=y +# CT_CC_LANG_FORTRAN is not set +# end of C compiler + +# +# Debug facilities +# +# CT_DEBUG_DUMA is not set +# CT_DEBUG_GDB is not set +# CT_DEBUG_LTRACE is not set +# CT_DEBUG_STRACE is not set +CT_ALL_DEBUG_CHOICES="DUMA GDB LTRACE STRACE" +# end of Debug facilities + +# +# Companion libraries +# +# CT_COMPLIBS_CHECK is not set +# CT_COMP_LIBS_CLOOG is not set +# CT_COMP_LIBS_EXPAT is not set +CT_COMP_LIBS_GETTEXT=y +CT_COMP_LIBS_GETTEXT_PKG_KSYM="GETTEXT" +CT_GETTEXT_DIR_NAME="gettext" +CT_GETTEXT_PKG_NAME="gettext" +CT_GETTEXT_SRC_RELEASE=y +# CT_GETTEXT_SRC_DEVEL is not set +CT_GETTEXT_PATCH_ORDER="global" +CT_GETTEXT_V_0_21=y +# CT_GETTEXT_V_0_20_1 is not set +# CT_GETTEXT_V_0_19_8_1 is not set +CT_GETTEXT_VERSION="0.21" +CT_GETTEXT_MIRRORS="$(CT_Mirrors GNU gettext)" +CT_GETTEXT_ARCHIVE_FILENAME="@{pkg_name}-@{version}" +CT_GETTEXT_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" +CT_GETTEXT_ARCHIVE_FORMATS=".tar.xz .tar.gz" +CT_GETTEXT_SIGNATURE_FORMAT="packed/.sig" +CT_GETTEXT_0_21_or_later=y +CT_GETTEXT_0_21_or_older=y +CT_GETTEXT_INCOMPATIBLE_WITH_UCLIBC_NG=y + +# +# This version of gettext is not compatible with uClibc-NG. Select +# + +# +# a different version if uClibc-NG is used on the target or (in a +# + +# +# Canadian cross build) on the host. +# +CT_COMP_LIBS_GMP=y +CT_COMP_LIBS_GMP_PKG_KSYM="GMP" +CT_GMP_DIR_NAME="gmp" +CT_GMP_PKG_NAME="gmp" +CT_GMP_SRC_RELEASE=y +# CT_GMP_SRC_DEVEL is not set +CT_GMP_PATCH_ORDER="global" +CT_GMP_V_6_2=y +# CT_GMP_V_6_1 is not set +CT_GMP_VERSION="6.2.1" +CT_GMP_MIRRORS="https://gmplib.org/download/gmp https://gmplib.org/download/gmp/archive $(CT_Mirrors GNU gmp)" +CT_GMP_ARCHIVE_FILENAME="@{pkg_name}-@{version}" +CT_GMP_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" +CT_GMP_ARCHIVE_FORMATS=".tar.xz .tar.lz .tar.bz2" +CT_GMP_SIGNATURE_FORMAT="packed/.sig" +CT_COMP_LIBS_ISL=y +CT_COMP_LIBS_ISL_PKG_KSYM="ISL" +CT_ISL_DIR_NAME="isl" +CT_ISL_PKG_NAME="isl" +CT_ISL_SRC_RELEASE=y +# CT_ISL_SRC_DEVEL is not set +CT_ISL_PATCH_ORDER="global" +CT_ISL_V_0_24=y +# CT_ISL_V_0_23 is not set +# CT_ISL_V_0_22 is not set +# CT_ISL_V_0_21 is not set +# CT_ISL_V_0_20 is not set +# CT_ISL_V_0_19 is not set +# CT_ISL_V_0_18 is not set +# CT_ISL_V_0_17 is not set +# CT_ISL_V_0_16 is not set +# CT_ISL_V_0_15 is not set +CT_ISL_VERSION="0.24" +CT_ISL_MIRRORS="https://libisl.sourceforge.io" +CT_ISL_ARCHIVE_FILENAME="@{pkg_name}-@{version}" +CT_ISL_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" +CT_ISL_ARCHIVE_FORMATS=".tar.xz .tar.bz2 .tar.gz" +CT_ISL_SIGNATURE_FORMAT="" +CT_ISL_later_than_0_18=y +CT_ISL_0_18_or_later=y +CT_ISL_later_than_0_15=y +CT_ISL_0_15_or_later=y +# CT_COMP_LIBS_LIBELF is not set +CT_COMP_LIBS_LIBICONV=y +CT_COMP_LIBS_LIBICONV_PKG_KSYM="LIBICONV" +CT_LIBICONV_DIR_NAME="libiconv" +CT_LIBICONV_PKG_NAME="libiconv" +CT_LIBICONV_SRC_RELEASE=y +# CT_LIBICONV_SRC_DEVEL is not set +CT_LIBICONV_PATCH_ORDER="global" +CT_LIBICONV_V_1_16=y +# CT_LIBICONV_V_1_15 is not set +CT_LIBICONV_VERSION="1.16" +CT_LIBICONV_MIRRORS="$(CT_Mirrors GNU libiconv)" +CT_LIBICONV_ARCHIVE_FILENAME="@{pkg_name}-@{version}" +CT_LIBICONV_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" +CT_LIBICONV_ARCHIVE_FORMATS=".tar.gz" +CT_LIBICONV_SIGNATURE_FORMAT="packed/.sig" +CT_COMP_LIBS_MPC=y +CT_COMP_LIBS_MPC_PKG_KSYM="MPC" +CT_MPC_DIR_NAME="mpc" +CT_MPC_PKG_NAME="mpc" +CT_MPC_SRC_RELEASE=y +# CT_MPC_SRC_DEVEL is not set +CT_MPC_PATCH_ORDER="global" +CT_MPC_V_1_2=y +# CT_MPC_V_1_1 is not set +# CT_MPC_V_1_0 is not set +CT_MPC_VERSION="1.2.1" +CT_MPC_MIRRORS="http://www.multiprecision.org/downloads $(CT_Mirrors GNU mpc)" +CT_MPC_ARCHIVE_FILENAME="@{pkg_name}-@{version}" +CT_MPC_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" +CT_MPC_ARCHIVE_FORMATS=".tar.gz" +CT_MPC_SIGNATURE_FORMAT="packed/.sig" +CT_MPC_later_than_1_1_0=y +CT_MPC_1_1_0_or_later=y +CT_COMP_LIBS_MPFR=y +CT_COMP_LIBS_MPFR_PKG_KSYM="MPFR" +CT_MPFR_DIR_NAME="mpfr" +CT_MPFR_PKG_NAME="mpfr" +CT_MPFR_SRC_RELEASE=y +# CT_MPFR_SRC_DEVEL is not set +CT_MPFR_PATCH_ORDER="global" +CT_MPFR_V_4_1=y +# CT_MPFR_V_4_0 is not set +# CT_MPFR_V_3_1 is not set +CT_MPFR_VERSION="4.1.0" +CT_MPFR_MIRRORS="http://www.mpfr.org/mpfr-${CT_MPFR_VERSION} $(CT_Mirrors GNU mpfr)" +CT_MPFR_ARCHIVE_FILENAME="@{pkg_name}-@{version}" +CT_MPFR_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" +CT_MPFR_ARCHIVE_FORMATS=".tar.xz .tar.bz2 .tar.gz .zip" +CT_MPFR_SIGNATURE_FORMAT="packed/.asc" +CT_MPFR_later_than_4_0_0=y +CT_MPFR_4_0_0_or_later=y +CT_COMP_LIBS_NCURSES=y +CT_COMP_LIBS_NCURSES_PKG_KSYM="NCURSES" +CT_NCURSES_DIR_NAME="ncurses" +CT_NCURSES_PKG_NAME="ncurses" +CT_NCURSES_SRC_RELEASE=y +# CT_NCURSES_SRC_DEVEL is not set +CT_NCURSES_PATCH_ORDER="global" +CT_NCURSES_V_6_2=y +# CT_NCURSES_V_6_1 is not set +# CT_NCURSES_V_6_0 is not set +CT_NCURSES_VERSION="6.2" +CT_NCURSES_MIRRORS="https://invisible-mirror.net/archives/ncurses $(CT_Mirrors GNU ncurses)" +CT_NCURSES_ARCHIVE_FILENAME="@{pkg_name}-@{version}" +CT_NCURSES_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" +CT_NCURSES_ARCHIVE_FORMATS=".tar.gz" +CT_NCURSES_SIGNATURE_FORMAT="packed/.sig" +CT_NCURSES_NEW_ABI=y +CT_NCURSES_HOST_CONFIG_ARGS="" +CT_NCURSES_HOST_DISABLE_DB=y +CT_NCURSES_HOST_FALLBACKS="linux,xterm,xterm-color,xterm-256color,vt100" +CT_NCURSES_TARGET_CONFIG_ARGS="" +# CT_NCURSES_TARGET_DISABLE_DB is not set +CT_NCURSES_TARGET_FALLBACKS="" +CT_COMP_LIBS_ZLIB=y +CT_COMP_LIBS_ZLIB_PKG_KSYM="ZLIB" +CT_ZLIB_DIR_NAME="zlib" +CT_ZLIB_PKG_NAME="zlib" +CT_ZLIB_SRC_RELEASE=y +# CT_ZLIB_SRC_DEVEL is not set +CT_ZLIB_PATCH_ORDER="global" +CT_ZLIB_V_1_2_12=y +CT_ZLIB_VERSION="1.2.13" +CT_ZLIB_MIRRORS="http://downloads.sourceforge.net/project/libpng/zlib/${CT_ZLIB_VERSION} https://www.zlib.net/fossils/" +CT_ZLIB_ARCHIVE_FILENAME="@{pkg_name}-@{version}" +CT_ZLIB_ARCHIVE_DIRNAME="@{pkg_name}-@{version}" +CT_ZLIB_ARCHIVE_FORMATS=".tar.xz .tar.gz" +CT_ZLIB_SIGNATURE_FORMAT="packed/.asc" +CT_ALL_COMP_LIBS_CHOICES="CLOOG EXPAT GETTEXT GMP GNUPRUMCU ISL LIBELF LIBICONV MPC MPFR NCURSES NEWLIB_NANO PICOLIBC ZLIB" +CT_LIBICONV_NEEDED=y +CT_GETTEXT_NEEDED=y +CT_GMP_NEEDED=y +CT_MPFR_NEEDED=y +CT_ISL_NEEDED=y +CT_MPC_NEEDED=y +CT_NCURSES_NEEDED=y +CT_ZLIB_NEEDED=y +CT_LIBICONV=y +CT_GETTEXT=y +CT_GMP=y +CT_MPFR=y +CT_ISL=y +CT_MPC=y +CT_NCURSES=y +CT_ZLIB=y +# end of Companion libraries + +# +# Companion tools +# +# CT_COMP_TOOLS_FOR_HOST is not set +# CT_COMP_TOOLS_AUTOCONF is not set +# CT_COMP_TOOLS_AUTOMAKE is not set +# CT_COMP_TOOLS_BISON is not set +# CT_COMP_TOOLS_DTC is not set +# CT_COMP_TOOLS_LIBTOOL is not set +# CT_COMP_TOOLS_M4 is not set +# CT_COMP_TOOLS_MAKE is not set +CT_ALL_COMP_TOOLS_CHOICES="AUTOCONF AUTOMAKE BISON DTC LIBTOOL M4 MAKE" +# end of Companion tools diff --git a/packages/cross-x86_64-linux-gnu/src/ppbt_cross_x86_64_linux_gnu/build.py b/packages/cross-x86_64-linux-gnu/src/ppbt_cross_x86_64_linux_gnu/build.py new file mode 100644 index 0000000..e62c818 --- /dev/null +++ b/packages/cross-x86_64-linux-gnu/src/ppbt_cross_x86_64_linux_gnu/build.py @@ -0,0 +1,229 @@ +# Copyright 2024-2026 Broadcom Corporation +# SPDX-License-Identifier: Apache-2.0 +# +""" +Build a ``ppbt-cross-x86_64-linux-gnu`` wheel. + +Produces a crosstool-ng toolchain that runs on the wheel's host arch +(aarch64) and targets ``x86_64-linux-gnu``. The tarball is stashed +inside this package's ``_toolchain/`` dir so the base ``ppbt`` package +can discover it via the ``ppbt.toolchains`` entry point. +""" +import base64 +import csv +import hashlib +import http.client +import os +import pathlib +import shutil +import subprocess +import sys +import tarfile +import time +import urllib.error +import urllib.request + +from setuptools.build_meta import ( + build_editable as _build_editable_passthrough, + build_sdist, + build_wheel, + get_requires_for_build_sdist, + get_requires_for_build_wheel, + prepare_metadata_for_build_wheel, +) + + +def build_editable(wheel_directory, config_settings=None, metadata_directory=None): + """PEP 660 editable hook: skip the toolchain build.""" + return _build_editable_passthrough( + wheel_directory, config_settings, metadata_directory + ) + + +__all__ = ( + "build_sdist", + "build_wheel", + "build_editable", + "get_requires_for_build_sdist", + "get_requires_for_build_wheel", + "prepare_metadata_for_build_wheel", +) + +TRIPLET = "x86_64-linux-gnu" +PKG_MODULE = "ppbt_cross_x86_64_linux_gnu" +CT_NG_VER = "1.26.0" +CT_URL = "http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-{version}.tar.bz2" +CT_GIT_REPO = "https://github.com/crosstool-ng/crosstool-ng.git" +CICD = "CI" in os.environ +PATCHELF_VERSION = "0.18.0" +PATCHELF_SOURCE = ( + f"https://github.com/NixOS/patchelf/releases/download/" + f"{PATCHELF_VERSION}/patchelf-{PATCHELF_VERSION}.tar.gz" +) + +_build_wheel = build_wheel +_build_sdist = build_sdist + + +class BuildError(RuntimeError): + """Generic build error.""" + + +def _fetch(url, fp, backoff=3, timeout=30): + if backoff < 1: + backoff = 1 + n = 0 + while n < backoff: + n += 1 + try: + fin = urllib.request.urlopen(url, timeout=timeout) + break + except ( + urllib.error.HTTPError, + urllib.error.URLError, + http.client.RemoteDisconnected, + ): + if n >= backoff: + raise + time.sleep(n * 10) + try: + block = fin.read(1024 * 300) + while block: + fp.write(block) + block = fin.read(10240) + finally: + fin.close() + + +def download_url(url, dest): + """Download ``url`` to ``dest`` dir.""" + local = os.path.join(dest, os.path.basename(url)) + print(f"Downloading {url} -> {local}") + with open(local, "wb") as fout: + try: + _fetch(url, fout) + except Exception as exc: + print(f"Unable to download: {url} {exc}", file=sys.stderr, flush=True) + try: + os.unlink(local) + except OSError: + pass + raise + return local + + +def extract_archive(to_dir, archive): + """Extract ``archive`` (tar.gz / tar.xz / tar.bz2) into ``to_dir``.""" + if archive.endswith("tgz") or archive.endswith("gz"): + mode = "r:gz" + elif archive.endswith("xz"): + mode = "r:xz" + elif archive.endswith("bz2"): + mode = "r:bz2" + else: + mode = "r" + with tarfile.open(archive, mode) as t: + t.extractall(to_dir) + + +def runcmd(cmd, **kwargs): + """Run ``cmd``, raising :class:`BuildError` on non-zero exit.""" + proc = subprocess.run(cmd, **kwargs) + if proc.returncode != 0: + raise BuildError(f"Build cmd '{' '.join(str(c) for c in cmd)}' failed") + return proc + + +def _prepare_crosstool_ng(build): + ctngdir = build / f"crosstool-ng-{CT_NG_VER}" + if not ctngdir.exists(): + archive = download_url(CT_URL.format(version=CT_NG_VER), build) + extract_archive(build, archive) + ctng = ctngdir / "ct-ng" + if not ctng.exists(): + print("Compiling ct-ng") + os.chdir(ctngdir) + runcmd(["./configure", "--enable-local"]) + runcmd(["make"]) + return ctngdir, ctng + + +def _prepare_patchelf(build): + source = build / f"patchelf-{PATCHELF_VERSION}" + patchelf = source / "src" / "patchelf" + if not source.exists(): + archive = download_url(PATCHELF_SOURCE, build) + extract_archive(build, archive) + if not patchelf.exists(): + os.chdir(source) + runcmd(["./configure"]) + runcmd(["make"]) + return patchelf + + +def build_toolchain(): + """Build the cross toolchain and stage it inside this package.""" + cwd = pathlib.Path(os.getcwd()) + root = pathlib.Path(os.environ.get("PWD", os.getcwd())) + build = root / "build" + build.mkdir(exist_ok=True) + pkg_src = cwd / "src" / PKG_MODULE + toolchain_dir = pkg_src / "_toolchain" + toolchain_dir.mkdir(exist_ok=True) + config = pkg_src / "_config" / f"{TRIPLET}-ct-ng.config" + if not config.exists(): + print(f"Cross config missing: {config}", file=sys.stderr) + sys.exit(1) + try: + ctngdir, ctng = _prepare_crosstool_ng(build) + patchelf = _prepare_patchelf(build) + + archdir = build / TRIPLET + if not archdir.exists(): + with open(config, "r") as rfp, open(ctngdir / ".config", "w") as wfp: + wfp.write(rfp.read()) + os.chdir(ctngdir) + env = os.environ.copy() + env["CT_PREFIX"] = str(build) + if os.getuid() == 0: + env["CT_ALLOW_BUILD_AS_ROOT"] = "y" + env["CT_ALLOW_BUILD_AS_ROOT_SURE"] = "y" + if CICD: + env["CT_LOG_PROGRESS"] = "n" + runcmd([str(ctng), "source"], env=env) + runcmd([str(ctng), "build"], env=env) + + shutil.copy(patchelf, archdir / "bin" / "patchelf") + os.chdir(build) + archive = f"{TRIPLET}.tar.xz" + record = f"{TRIPLET}.tar.xz.record" + subprocess.run( + ["tar", "-C", str(build), "-cJf", archive, TRIPLET], check=True + ) + with open(record, "w") as rfp: + rwriter = csv.writer(rfp) + for walk_root, _dirs, files in os.walk(archdir): + relroot = pathlib.Path(walk_root).relative_to(build) + for f in files: + relpath = relroot / f + with open(relpath, "rb") as fp: + data = fp.read() + hsh = ( + base64.urlsafe_b64encode(hashlib.sha256(data).digest()) + .rstrip(b"=") + .decode() + ) + hashpath = str(pathlib.Path(PKG_MODULE) / "_toolchain" / relpath) + rwriter.writerow([hashpath, f"sha256={hsh}", len(data)]) + print(f"Copying {archive} to {toolchain_dir}") + shutil.copy(archive, toolchain_dir) + print(f"Copying {record} to {toolchain_dir}") + shutil.copy(record, toolchain_dir) + finally: + os.chdir(cwd) + + +def build_wheel(wheel_directory, metadata_directory=None, config_settings=None): + """PEP 517 wheel creation hook.""" + build_toolchain() + return _build_wheel(wheel_directory, metadata_directory, config_settings) diff --git a/pyproject.toml b/pyproject.toml index a79534e..d1fb5d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,3 +11,6 @@ backend-path = ["src"] pythonpath = [ "src" ] + +[tool.isort] +profile = "black" diff --git a/setup.cfg b/setup.cfg index f21ad07..5c703df 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,6 +37,13 @@ exclude = [options.package_data] *=_config/**, _toolchain/** +[options.extras_require] +cross-aarch64-linux-gnu = ppbt-cross-aarch64-linux-gnu +cross-x86_64-linux-gnu = ppbt-cross-x86_64-linux-gnu +cross-all = + ppbt-cross-aarch64-linux-gnu + ppbt-cross-x86_64-linux-gnu + [flake8] max-line-length = 120 exclude = diff --git a/src/ppbt/__init__.py b/src/ppbt/__init__.py index e134309..8a52db5 100644 --- a/src/ppbt/__init__.py +++ b/src/ppbt/__init__.py @@ -3,6 +3,19 @@ """ Portable Python Build Toolchains. """ -from .common import __version__, environ, extract +from .common import ( + __version__, + archive_for, + available_triplets, + environ, + extract, + toolchain_for, +) -ALL = ("environ", "extract") +__all__ = ( + "environ", + "extract", + "archive_for", + "toolchain_for", + "available_triplets", +) diff --git a/src/ppbt/build.py b/src/ppbt/build.py index 8e05098..93afb51 100644 --- a/src/ppbt/build.py +++ b/src/ppbt/build.py @@ -18,6 +18,7 @@ import urllib.error import urllib.request +from setuptools.build_meta import build_editable as _build_editable_passthrough from setuptools.build_meta import build_sdist, build_wheel import ppbt.common @@ -286,3 +287,10 @@ def build_wheel(wheel_directory, metadata_directory=None, config_settings=None): """PEP 517 wheel creation hook.""" build_ppbt() return _build_wheel(wheel_directory, metadata_directory, config_settings) + + +def build_editable(wheel_directory, config_settings=None, metadata_directory=None): + """PEP 660 editable hook: skip the toolchain build for dev installs.""" + return _build_editable_passthrough( + wheel_directory, config_settings, metadata_directory + ) diff --git a/src/ppbt/common.py b/src/ppbt/common.py index 661d5d4..952f993 100644 --- a/src/ppbt/common.py +++ b/src/ppbt/common.py @@ -3,6 +3,11 @@ # """ Toolchain build environment. + +The base ``ppbt`` wheel ships only the host native toolchain. Cross +toolchains live in sibling packages (``ppbt-cross-``) and are +discovered at runtime via the ``ppbt.toolchains`` entry point so the +base wheel stays small. """ import csv @@ -11,8 +16,9 @@ import platform import sys import tarfile +from importlib import metadata -__version__ = "0.1.8" +__version__ = "0.2.0" log = logging.getLogger(__name__) @@ -35,7 +41,7 @@ def get_triplet(machine=None, plat=None): :param plat: The platform for the triplet :type plat: str - :raises BuildError: If the platform is unknown + :raises PPBTException: If the platform is unknown :return: The target triplet :rtype: str @@ -63,8 +69,8 @@ def build_arch(): TRIPLET = get_triplet(build_arch()) -ARCHIVE = pathlib.Path(__file__).parent / "_toolchain" / f"{TRIPLET}.tar.xz" TOOLCHAIN_ROOT = pathlib.Path(__file__).parent / "_toolchain" +ARCHIVE = TOOLCHAIN_ROOT / f"{TRIPLET}.tar.xz" TOOLCHAIN = TOOLCHAIN_ROOT / TRIPLET # This is not reliable, the version can be modified by setuptools at build time. @@ -72,6 +78,8 @@ def build_arch(): pathlib.Path(__file__).resolve().parent.parent / f"ppbt-{__version__}.dist-info" ) +TOOLCHAINS_ENTRY_POINT = "ppbt.toolchains" + def extract_archive(to_dir, archive): """ @@ -94,48 +102,215 @@ def extract_archive(to_dir, archive): t.extractall(to_dir) -def extract(overwrite=False): +def _toolchain_module(triplet): + """ + Return the Python module that ships the toolchain for ``triplet``. + + The base ``ppbt`` package supplies the host native triplet. Sibling + cross packages register additional triplets via the + ``ppbt.toolchains`` entry point whose name is the triplet string and + whose target is a module exposing ``TRIPLET``, ``TOOLCHAIN_ROOT``, + ``ARCHIVE``, ``TOOLCHAIN`` and ``DISTINFO`` at module scope. + + :param triplet: Target triplet. + :type triplet: str + :return: The module providing the toolchain, or ``None`` if the + triplet is not registered. + """ + if triplet == TRIPLET: + return sys.modules[__name__] + try: + eps = metadata.entry_points(group=TOOLCHAINS_ENTRY_POINT) + except TypeError: + # importlib.metadata < 3.10 doesn't take the group kwarg. + eps = metadata.entry_points().get(TOOLCHAINS_ENTRY_POINT, []) + for ep in eps: + if ep.name != triplet: + continue + try: + return ep.load() + except Exception as exc: # noqa: BLE001 + log.warning( + "Failed to load %s entry point %r: %r", + TOOLCHAINS_ENTRY_POINT, + triplet, + exc, + ) + return None + return None + + +def archive_for(triplet): + """ + Return the path to the toolchain archive for ``triplet``. + + Base ``ppbt`` supplies the host archive; sibling ``ppbt-cross-*`` + packages supply cross archives. The return value is just a path -- + callers should check existence or use :func:`available_triplets`. + + :param triplet: Target triplet, as produced by :func:`get_triplet`. + :type triplet: str + :return: Path to ``.tar.xz`` inside the providing package. + :rtype: pathlib.Path + """ + mod = _toolchain_module(triplet) + if mod is None: + return TOOLCHAIN_ROOT / f"{triplet}.tar.xz" + return pathlib.Path(mod.ARCHIVE) + + +def toolchain_for(triplet): + """ + Return the path where the toolchain for ``triplet`` extracts to. + + :param triplet: Target triplet. + :type triplet: str + :return: Path to the extracted toolchain directory inside the + providing package. + :rtype: pathlib.Path + """ + mod = _toolchain_module(triplet) + if mod is None: + return TOOLCHAIN_ROOT / triplet + return pathlib.Path(mod.TOOLCHAIN) + + +def available_triplets(): """ - Extract the toolchain tarball. + Return the triplets reachable from this Python install. + + Includes the host triplet (when the base wheel's archive is + present) and every triplet registered via a ``ppbt.toolchains`` + entry point whose provider package has its archive present. + + :return: Triplets with an archive available. + :rtype: list[str] + """ + triplets = set() + if ARCHIVE.exists(): + triplets.add(TRIPLET) + try: + eps = metadata.entry_points(group=TOOLCHAINS_ENTRY_POINT) + except TypeError: + eps = metadata.entry_points().get(TOOLCHAINS_ENTRY_POINT, []) + for ep in eps: + if ep.name in triplets: + continue + try: + mod = ep.load() + except Exception as exc: # noqa: BLE001 + log.warning( + "Failed to load %s entry point %r: %r", + TOOLCHAINS_ENTRY_POINT, + ep.name, + exc, + ) + continue + if pathlib.Path(mod.ARCHIVE).exists(): + triplets.add(ep.name) + return sorted(triplets) + + +def _extract_toolchain(toolchain_dir, archive, distinfo, overwrite=False): """ - if TOOLCHAIN.exists() and not overwrite: + Extract ``archive`` into ``toolchain_dir`` and merge its RECORD. + + Shared between the base host toolchain and sibling cross packages + so RECORD-merging behaviour is defined in one place. + + :param toolchain_dir: Final extracted toolchain directory. + :type toolchain_dir: pathlib.Path + :param archive: Path to the ``.tar.xz`` archive. + :type archive: pathlib.Path + :param distinfo: Path to the providing wheel's ``*.dist-info`` + directory (which contains ``RECORD``). + :type distinfo: pathlib.Path + :param overwrite: Re-extract even if ``toolchain_dir`` exists. + :type overwrite: bool + """ + toolchain_dir = pathlib.Path(toolchain_dir) + archive = pathlib.Path(archive) + distinfo = pathlib.Path(distinfo) + if toolchain_dir.exists() and not overwrite: log.debug("Toolchain directory exists") - else: - log.info("Extract archive") - extract_archive(TOOLCHAIN_ROOT, str(ARCHIVE)) - record = DISTINFO / "RECORD" - if record.exists(): - records = [] - log.info("Update pkg metadata") - with open(record, "r") as fp: - for row in csv.reader(fp): - records.append(row) - with open(str(ARCHIVE) + ".record", "r") as fp: - for row in csv.reader(fp): - records.append(row) - records = sorted(records, key=lambda _: _[0]) - with open(record, "w") as fp: - writer = csv.writer(fp) - for row in records: - writer.writerow(row) - - -def environ(auto_extract=False): - """ - Toolchain build environment. - """ - if not TOOLCHAIN.exists(): + return + log.info("Extract archive %s", archive) + extract_archive(toolchain_dir.parent, str(archive)) + record = distinfo / "RECORD" + archive_record = pathlib.Path(str(archive) + ".record") + if record.exists() and archive_record.exists(): + log.info("Update pkg metadata") + records = [] + with open(record, "r") as fp: + records.extend(list(csv.reader(fp))) + with open(archive_record, "r") as fp: + records.extend(list(csv.reader(fp))) + records = sorted(records, key=lambda row: row[0]) + with open(record, "w") as fp: + writer = csv.writer(fp) + for row in records: + writer.writerow(row) + + +def extract(overwrite=False, triplet=None): + """ + Extract the toolchain tarball for ``triplet`` (default: host). + + :param overwrite: Re-extract even if the toolchain directory + already exists. + :type overwrite: bool + :param triplet: Target triplet. Defaults to the host triplet. + :type triplet: str or None + :raises PPBTException: If no provider is registered for ``triplet``. + """ + if triplet is None: + triplet = TRIPLET + mod = _toolchain_module(triplet) + if mod is None: + raise PPBTException( + f"No toolchain registered for {triplet}; " f"install ppbt-cross-{triplet}?" + ) + _extract_toolchain( + pathlib.Path(mod.TOOLCHAIN), + pathlib.Path(mod.ARCHIVE), + pathlib.Path(mod.DISTINFO), + overwrite=overwrite, + ) + + +def environ(auto_extract=False, triplet=None): + """ + Toolchain build environment for ``triplet`` (default: host). + + :param auto_extract: If True and the toolchain is not yet + extracted, extract it. Otherwise raise. + :type auto_extract: bool + :param triplet: Target triplet. Defaults to the host triplet. + :type triplet: str or None + :raises PPBTException: If no provider is registered for ``triplet``. + :raises RuntimeError: If the toolchain is not extracted and + ``auto_extract`` is False. + """ + if triplet is None: + triplet = TRIPLET + mod = _toolchain_module(triplet) + if mod is None: + raise PPBTException( + f"No toolchain registered for {triplet}; " f"install ppbt-cross-{triplet}?" + ) + toolchain_dir = pathlib.Path(mod.TOOLCHAIN) + if not toolchain_dir.exists(): if auto_extract: - extract() + extract(triplet=triplet) else: raise RuntimeError("Toolchain not extracted") - basebin = TOOLCHAIN / "bin" / TRIPLET + basebin = toolchain_dir / "bin" / triplet return { - "TOOLCHAIN_PATH": f"{TOOLCHAIN}", + "TOOLCHAIN_PATH": f"{toolchain_dir}", "CC": f"{basebin}-gcc", "CXX": f"{basebin}-g++", - "CFLAGS": f"-I{TOOLCHAIN}/{TRIPLET}/sysroot/usr/include", - "CPPFLAGS": f"-I{TOOLCHAIN}/{TRIPLET}/sysroot/usr/include", - "CMAKE_FLAGS": f"-I{TOOLCHAIN}/{TRIPLET}/sysroot/usr/include", - "LDFLAGS": f"-L{TOOLCHAIN}/{TRIPLET}/sysroot/lib", + "CFLAGS": f"-I{toolchain_dir}/{triplet}/sysroot/usr/include", + "CPPFLAGS": f"-I{toolchain_dir}/{triplet}/sysroot/usr/include", + "CMAKE_FLAGS": f"-I{toolchain_dir}/{triplet}/sysroot/usr/include", + "LDFLAGS": f"-L{toolchain_dir}/{triplet}/sysroot/lib", } diff --git a/tests/test_common.py b/tests/test_common.py new file mode 100644 index 0000000..c47e366 --- /dev/null +++ b/tests/test_common.py @@ -0,0 +1,154 @@ +# Copyright 2024 Broadcom Corporation +# SPDX-License-Identifier: Apache-2.0 +# +""" +Tests for the public ``ppbt.common`` helpers. + +Cover the three things downstream tools (relenv) rely on: + +* native host toolchain lookup via :data:`ppbt.common.ARCHIVE` / :data:`TOOLCHAIN`. +* cross toolchain discovery via the ``ppbt.toolchains`` entry point. +* clear errors when a triplet has no provider installed. + +No actual toolchain archive is extracted; the fixtures stand in fake +provider modules via ``monkeypatch``. +""" +import pathlib +import sys +import types + +import pytest + +import ppbt +import ppbt.common + + +def test_archive_for_host_matches_module_constant(): + """The archive for the host triplet is :data:`ARCHIVE`.""" + assert ppbt.common.archive_for(ppbt.common.TRIPLET) == ppbt.common.ARCHIVE + + +def test_toolchain_for_host_matches_module_constant(): + """The toolchain dir for the host triplet is :data:`TOOLCHAIN`.""" + assert ppbt.common.toolchain_for(ppbt.common.TRIPLET) == ppbt.common.TOOLCHAIN + + +def test_public_api_reexports(): + """New helpers are reachable via the top-level ``ppbt`` namespace.""" + assert ppbt.archive_for is ppbt.common.archive_for + assert ppbt.toolchain_for is ppbt.common.toolchain_for + assert ppbt.available_triplets is ppbt.common.available_triplets + + +def _make_fake_provider(tmp_path, triplet, module_name): + """Build a fake sibling-package module with ARCHIVE etc.""" + root = tmp_path / module_name / "_toolchain" + root.mkdir(parents=True) + archive = root / f"{triplet}.tar.xz" + toolchain = root / triplet + distinfo = tmp_path / f"{module_name}-0.2.0.dist-info" + distinfo.mkdir() + + mod = types.ModuleType(module_name) + mod.TRIPLET = triplet + mod.TOOLCHAIN_ROOT = root + mod.ARCHIVE = archive + mod.TOOLCHAIN = toolchain + mod.DISTINFO = distinfo + sys.modules[module_name] = mod + return mod + + +class _FakeEntryPoint: + def __init__(self, name, module): + self.name = name + self._module = module + + def load(self): + return self._module + + +@pytest.fixture +def fake_cross(tmp_path, monkeypatch): + """Register a fake cross provider via the entry-point group.""" + triplet = "cross-test-linux-gnu" + module_name = "_ppbt_fake_cross_provider" + mod = _make_fake_provider(tmp_path, triplet, module_name) + eps = [_FakeEntryPoint(triplet, mod)] + monkeypatch.setattr( + ppbt.common.metadata, "entry_points", lambda group=None: eps + ) + yield triplet, mod + sys.modules.pop(module_name, None) + + +def test_archive_for_resolves_cross_provider_entry_point(fake_cross): + """``archive_for(triplet)`` returns the sibling package's archive.""" + triplet, mod = fake_cross + assert ppbt.common.archive_for(triplet) == mod.ARCHIVE + + +def test_toolchain_for_resolves_cross_provider_entry_point(fake_cross): + """``toolchain_for(triplet)`` returns the sibling package's toolchain dir.""" + triplet, mod = fake_cross + assert ppbt.common.toolchain_for(triplet) == mod.TOOLCHAIN + + +def test_available_triplets_includes_cross_when_archive_present(fake_cross): + """Cross triplet shows up in ``available_triplets`` once its archive exists.""" + triplet, mod = fake_cross + assert triplet not in ppbt.common.available_triplets() + mod.ARCHIVE.touch() + assert triplet in ppbt.common.available_triplets() + + +def test_archive_for_unknown_triplet_falls_back_to_base_path(monkeypatch): + """Unknown triplet falls back to a predictable base-package path.""" + monkeypatch.setattr( + ppbt.common.metadata, "entry_points", lambda group=None: [] + ) + path = ppbt.common.archive_for("mips64-linux-gnu") + assert path.parent == ppbt.common.TOOLCHAIN_ROOT + assert path.name == "mips64-linux-gnu.tar.xz" + + +def test_extract_without_provider_raises(monkeypatch): + """``extract`` on an unregistered triplet gives a helpful error.""" + monkeypatch.setattr( + ppbt.common.metadata, "entry_points", lambda group=None: [] + ) + with pytest.raises(ppbt.common.PPBTException) as exc: + ppbt.common.extract(triplet="mips64-linux-gnu") + assert "mips64-linux-gnu" in str(exc.value) + assert "ppbt-cross-mips64-linux-gnu" in str(exc.value) + + +def test_environ_without_provider_raises(monkeypatch): + """``environ`` on an unregistered triplet gives a helpful error.""" + monkeypatch.setattr( + ppbt.common.metadata, "entry_points", lambda group=None: [] + ) + with pytest.raises(ppbt.common.PPBTException): + ppbt.common.environ(triplet="mips64-linux-gnu") + + +def test_environ_defaults_to_host(tmp_path, monkeypatch): + """``environ()`` without a triplet returns env for the host toolchain.""" + fake_root = tmp_path / "_toolchain" + fake_root.mkdir() + fake_toolchain = fake_root / ppbt.common.TRIPLET + (fake_toolchain / "bin").mkdir(parents=True) + monkeypatch.setattr(ppbt.common, "TOOLCHAIN_ROOT", fake_root) + monkeypatch.setattr(ppbt.common, "TOOLCHAIN", fake_toolchain) + env = ppbt.common.environ() + assert pathlib.Path(env["TOOLCHAIN_PATH"]) == fake_toolchain + assert env["CC"].endswith(f"bin/{ppbt.common.TRIPLET}-gcc") + + +def test_environ_accepts_triplet(fake_cross): + """``environ(triplet=...)`` returns env for the provider's toolchain.""" + triplet, mod = fake_cross + (mod.TOOLCHAIN / "bin").mkdir(parents=True) + env = ppbt.common.environ(triplet=triplet) + assert pathlib.Path(env["TOOLCHAIN_PATH"]) == mod.TOOLCHAIN + assert env["CC"].endswith(f"bin/{triplet}-gcc") From 6e4ed3b93d15878c8539496be541bd4e11fef100 Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Fri, 20 Nov 2026 20:48:33 -0700 Subject: [PATCH 2/9] Fix CI: libxml2 on ubuntu-26.04, Windows path separators - Pre-commit's ``Install System Deps`` step installed ``libxml2`` as a bare package, which ubuntu-26.04 ("resolute") dropped from main. ``libxml2-dev`` alone pulls the runtime transitively, which was the fix already used elsewhere. - ``test_environ_defaults_to_host`` and ``test_environ_accepts_triplet`` asserted ``env["CC"].endswith("bin/-gcc")``, but on Windows ``pathlib`` builds ``bin\-gcc`` (backslashes), so both failed on the Windows CI matrix. Use ``pathlib.PurePath(cc).name`` instead of a hard-coded separator substring. Also picks up the black/isort reformats on the sibling build.py files that had multi-line ``from ... import`` blocks collapsed by newer black. --- .github/workflows/pre-commit-action.yml | 2 +- .../src/ppbt_cross_aarch64_linux_gnu/build.py | 6 ++---- .../src/ppbt_cross_x86_64_linux_gnu/build.py | 6 ++---- tests/test_common.py | 20 ++++++------------- 4 files changed, 11 insertions(+), 23 deletions(-) diff --git a/.github/workflows/pre-commit-action.yml b/.github/workflows/pre-commit-action.yml index 1464765..e1daeb8 100644 --- a/.github/workflows/pre-commit-action.yml +++ b/.github/workflows/pre-commit-action.yml @@ -19,7 +19,7 @@ jobs: - name: Install System Deps run: | sudo apt-get update - sudo apt-get install -y git gcc make zlib1g-dev libc-dev libffi-dev g++ libxml2 libxml2-dev libxslt-dev libcurl4-openssl-dev libssl-dev libgnutls28-dev + sudo apt-get install -y git gcc make zlib1g-dev libc-dev libffi-dev g++ libxml2-dev libxslt-dev libcurl4-openssl-dev libssl-dev libgnutls28-dev - uses: actions/checkout@v4 with: diff --git a/packages/cross-aarch64-linux-gnu/src/ppbt_cross_aarch64_linux_gnu/build.py b/packages/cross-aarch64-linux-gnu/src/ppbt_cross_aarch64_linux_gnu/build.py index dec65e3..972fb4c 100644 --- a/packages/cross-aarch64-linux-gnu/src/ppbt_cross_aarch64_linux_gnu/build.py +++ b/packages/cross-aarch64-linux-gnu/src/ppbt_cross_aarch64_linux_gnu/build.py @@ -23,8 +23,8 @@ import urllib.error import urllib.request +from setuptools.build_meta import build_editable as _build_editable_passthrough from setuptools.build_meta import ( - build_editable as _build_editable_passthrough, build_sdist, build_wheel, get_requires_for_build_sdist, @@ -197,9 +197,7 @@ def build_toolchain(): os.chdir(build) archive = f"{TRIPLET}.tar.xz" record = f"{TRIPLET}.tar.xz.record" - subprocess.run( - ["tar", "-C", str(build), "-cJf", archive, TRIPLET], check=True - ) + subprocess.run(["tar", "-C", str(build), "-cJf", archive, TRIPLET], check=True) with open(record, "w") as rfp: rwriter = csv.writer(rfp) for walk_root, _dirs, files in os.walk(archdir): diff --git a/packages/cross-x86_64-linux-gnu/src/ppbt_cross_x86_64_linux_gnu/build.py b/packages/cross-x86_64-linux-gnu/src/ppbt_cross_x86_64_linux_gnu/build.py index e62c818..19dde7c 100644 --- a/packages/cross-x86_64-linux-gnu/src/ppbt_cross_x86_64_linux_gnu/build.py +++ b/packages/cross-x86_64-linux-gnu/src/ppbt_cross_x86_64_linux_gnu/build.py @@ -23,8 +23,8 @@ import urllib.error import urllib.request +from setuptools.build_meta import build_editable as _build_editable_passthrough from setuptools.build_meta import ( - build_editable as _build_editable_passthrough, build_sdist, build_wheel, get_requires_for_build_sdist, @@ -197,9 +197,7 @@ def build_toolchain(): os.chdir(build) archive = f"{TRIPLET}.tar.xz" record = f"{TRIPLET}.tar.xz.record" - subprocess.run( - ["tar", "-C", str(build), "-cJf", archive, TRIPLET], check=True - ) + subprocess.run(["tar", "-C", str(build), "-cJf", archive, TRIPLET], check=True) with open(record, "w") as rfp: rwriter = csv.writer(rfp) for walk_root, _dirs, files in os.walk(archdir): diff --git a/tests/test_common.py b/tests/test_common.py index c47e366..61f60f3 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -75,9 +75,7 @@ def fake_cross(tmp_path, monkeypatch): module_name = "_ppbt_fake_cross_provider" mod = _make_fake_provider(tmp_path, triplet, module_name) eps = [_FakeEntryPoint(triplet, mod)] - monkeypatch.setattr( - ppbt.common.metadata, "entry_points", lambda group=None: eps - ) + monkeypatch.setattr(ppbt.common.metadata, "entry_points", lambda group=None: eps) yield triplet, mod sys.modules.pop(module_name, None) @@ -104,9 +102,7 @@ def test_available_triplets_includes_cross_when_archive_present(fake_cross): def test_archive_for_unknown_triplet_falls_back_to_base_path(monkeypatch): """Unknown triplet falls back to a predictable base-package path.""" - monkeypatch.setattr( - ppbt.common.metadata, "entry_points", lambda group=None: [] - ) + monkeypatch.setattr(ppbt.common.metadata, "entry_points", lambda group=None: []) path = ppbt.common.archive_for("mips64-linux-gnu") assert path.parent == ppbt.common.TOOLCHAIN_ROOT assert path.name == "mips64-linux-gnu.tar.xz" @@ -114,9 +110,7 @@ def test_archive_for_unknown_triplet_falls_back_to_base_path(monkeypatch): def test_extract_without_provider_raises(monkeypatch): """``extract`` on an unregistered triplet gives a helpful error.""" - monkeypatch.setattr( - ppbt.common.metadata, "entry_points", lambda group=None: [] - ) + monkeypatch.setattr(ppbt.common.metadata, "entry_points", lambda group=None: []) with pytest.raises(ppbt.common.PPBTException) as exc: ppbt.common.extract(triplet="mips64-linux-gnu") assert "mips64-linux-gnu" in str(exc.value) @@ -125,9 +119,7 @@ def test_extract_without_provider_raises(monkeypatch): def test_environ_without_provider_raises(monkeypatch): """``environ`` on an unregistered triplet gives a helpful error.""" - monkeypatch.setattr( - ppbt.common.metadata, "entry_points", lambda group=None: [] - ) + monkeypatch.setattr(ppbt.common.metadata, "entry_points", lambda group=None: []) with pytest.raises(ppbt.common.PPBTException): ppbt.common.environ(triplet="mips64-linux-gnu") @@ -142,7 +134,7 @@ def test_environ_defaults_to_host(tmp_path, monkeypatch): monkeypatch.setattr(ppbt.common, "TOOLCHAIN", fake_toolchain) env = ppbt.common.environ() assert pathlib.Path(env["TOOLCHAIN_PATH"]) == fake_toolchain - assert env["CC"].endswith(f"bin/{ppbt.common.TRIPLET}-gcc") + assert pathlib.PurePath(env["CC"]).name == f"{ppbt.common.TRIPLET}-gcc" def test_environ_accepts_triplet(fake_cross): @@ -151,4 +143,4 @@ def test_environ_accepts_triplet(fake_cross): (mod.TOOLCHAIN / "bin").mkdir(parents=True) env = ppbt.common.environ(triplet=triplet) assert pathlib.Path(env["TOOLCHAIN_PATH"]) == mod.TOOLCHAIN - assert env["CC"].endswith(f"bin/{triplet}-gcc") + assert pathlib.PurePath(env["CC"]).name == f"{triplet}-gcc" From 438676ff5dfbb8a4ebb84a7d3f71ac72f2a671d3 Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Fri, 20 Nov 2026 20:59:45 -0700 Subject: [PATCH 3/9] Fix pre-commit: pin Python 3.11, bump copyright years Black 22.6.0 calls asyncio.get_event_loop() which 3.12 removed; the pyflakes bundled with flake8-mypy-fork references ast.Str, also removed in 3.12. ubuntu-26.04's default python is 3.12, so pin 3.11 with actions/setup-python before running pre-commit. The copyright hook also wanted the 2024 headers bumped to 2024-2026 on the files touched in this PR. --- .github/workflows/pre-commit-action.yml | 5 +++++ src/ppbt/__init__.py | 2 +- src/ppbt/build.py | 2 +- src/ppbt/common.py | 2 +- tests/test_common.py | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pre-commit-action.yml b/.github/workflows/pre-commit-action.yml index e1daeb8..a09fb05 100644 --- a/.github/workflows/pre-commit-action.yml +++ b/.github/workflows/pre-commit-action.yml @@ -25,6 +25,11 @@ jobs: with: fetch-depth: 0 + - name: Set up Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: "3.11" + - name: Install Pre-Commit run: | python -m pip install --upgrade pip diff --git a/src/ppbt/__init__.py b/src/ppbt/__init__.py index 8a52db5..cb991ac 100644 --- a/src/ppbt/__init__.py +++ b/src/ppbt/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2024 Broadcom Corporation +# Copyright 2024-2026 Broadcom Corporation # SPDX-License-Identifier: Apache-2.0 """ Portable Python Build Toolchains. diff --git a/src/ppbt/build.py b/src/ppbt/build.py index 93afb51..0576efa 100644 --- a/src/ppbt/build.py +++ b/src/ppbt/build.py @@ -1,4 +1,4 @@ -# Copyright 2024 Broadcom Corporation +# Copyright 2024-2026 Broadcom Corporation # SPDX-License-Identifier: Apache-2.0 # """ diff --git a/src/ppbt/common.py b/src/ppbt/common.py index 952f993..7961318 100644 --- a/src/ppbt/common.py +++ b/src/ppbt/common.py @@ -1,4 +1,4 @@ -# Copyright 2024 Broadcom Corporation +# Copyright 2024-2026 Broadcom Corporation # SPDX-License-Identifier: Apache-2.0 # """ diff --git a/tests/test_common.py b/tests/test_common.py index 61f60f3..ab0fb0c 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -1,4 +1,4 @@ -# Copyright 2024 Broadcom Corporation +# Copyright 2024-2026 Broadcom Corporation # SPDX-License-Identifier: Apache-2.0 # """ From 8fb3e596d8e3a982b26bba418fb5a422d37c89e8 Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Fri, 20 Nov 2026 21:10:44 -0700 Subject: [PATCH 4/9] Replace retired macos-12 runner labels with macos-13/14 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GitHub retired macos-12 in late 2024 and macos-13-xlarge requires paid Apple-Silicon runners that aren't enabled on this repo, so both cells queued indefinitely on every PR run. Use macos-13 (x86) and macos-14 (Apple Silicon, generic label) instead — same coverage, no paid tier required. --- .github/workflows/test-action.yml | 4 ++-- .github/workflows/test-package-action.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml index 5606e63..644408d 100644 --- a/.github/workflows/test-action.yml +++ b/.github/workflows/test-action.yml @@ -15,8 +15,8 @@ jobs: matrix: runs-on: - ubuntu-latest - - macos-12 - - macos-13-xlarge + - macos-13 + - macos-14 - windows-latest name: Unit Test ${{ matrix.runs-on }} diff --git a/.github/workflows/test-package-action.yml b/.github/workflows/test-package-action.yml index b4d529f..e61f702 100644 --- a/.github/workflows/test-package-action.yml +++ b/.github/workflows/test-package-action.yml @@ -15,8 +15,8 @@ jobs: matrix: runs-on: - ubuntu-latest - - macos-12 - - macos-13-xlarge + - macos-13 + - macos-14 - windows-latest name: Package Test ${{ matrix.runs-on }} From 568543ef792d1d5b1e5bf1486e3137dfc2e2f19b Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Fri, 20 Nov 2026 21:27:34 -0700 Subject: [PATCH 5/9] Drop macOS from test matrix ppbt ships only Linux manylinux wheels (crosstool-ng gcc toolchain targeting glibc 2.17); there's no macOS wheel to validate. The macOS cells had been queued-but-never-run for a while (macos-12 retired, macos-13-xlarge needs paid Apple Silicon runners), and macos-13 / macos-14 jobs get scheduler-cancelled on this org. Removing them rather than babysit a configuration that adds no coverage. --- .github/workflows/test-action.yml | 2 -- .github/workflows/test-package-action.yml | 2 -- 2 files changed, 4 deletions(-) diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml index 644408d..653fd99 100644 --- a/.github/workflows/test-action.yml +++ b/.github/workflows/test-action.yml @@ -15,8 +15,6 @@ jobs: matrix: runs-on: - ubuntu-latest - - macos-13 - - macos-14 - windows-latest name: Unit Test ${{ matrix.runs-on }} diff --git a/.github/workflows/test-package-action.yml b/.github/workflows/test-package-action.yml index e61f702..f3152d4 100644 --- a/.github/workflows/test-package-action.yml +++ b/.github/workflows/test-package-action.yml @@ -15,8 +15,6 @@ jobs: matrix: runs-on: - ubuntu-latest - - macos-13 - - macos-14 - windows-latest name: Package Test ${{ matrix.runs-on }} From 5f7c30ae30c04f860b8dd92210bea9cc963d01f7 Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Fri, 20 Nov 2026 22:54:32 -0700 Subject: [PATCH 6/9] Use GitHub's free runners for wheel builds Self-hosted `src-build` runners weren't picking up these jobs (queued indefinitely with no runner assignment). Use ubuntu-latest for x86_64 cells and ubuntu-24.04-arm for aarch64 cells; both are free for public repos and compatible with the debian:11 container the wheel build runs inside. --- .github/workflows/package-action.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/package-action.yml b/.github/workflows/package-action.yml index 03c3853..b713f2c 100644 --- a/.github/workflows/package-action.yml +++ b/.github/workflows/package-action.yml @@ -64,22 +64,22 @@ jobs: # arch only (an aarch64-linux-gnu cross toolchain runs on x86_64). include: - host: x86_64 + runs_on: ubuntu-latest pkg: ppbt pkg_dir: "." - host: aarch64 + runs_on: ubuntu-24.04-arm pkg: ppbt pkg_dir: "." - host: x86_64 + runs_on: ubuntu-latest pkg: ppbt-cross-aarch64-linux-gnu pkg_dir: packages/cross-aarch64-linux-gnu - host: aarch64 + runs_on: ubuntu-24.04-arm pkg: ppbt-cross-x86_64-linux-gnu pkg_dir: packages/cross-x86_64-linux-gnu - runs-on: - - self-hosted - - linux - - src-build - - ${{ matrix.host }} + runs-on: ${{ matrix.runs_on }} container: image: debian:11 outputs: From 0cd979dc22b56128e2dd5096b788938ba285f8d1 Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Fri, 20 Nov 2026 22:56:56 -0700 Subject: [PATCH 7/9] Use debian:12 build container Debian 11 (bullseye) is no longer served from debian-security; the pool returned 404 for every pinned security update so apt-get install failed. The target glibc (2.17) is produced by crosstool-ng inside the container, not by the container itself, so moving the host image up to bookworm doesn't change what ends up in the shipped toolchain. --- .github/workflows/package-action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package-action.yml b/.github/workflows/package-action.yml index b713f2c..5f57684 100644 --- a/.github/workflows/package-action.yml +++ b/.github/workflows/package-action.yml @@ -81,7 +81,7 @@ jobs: pkg_dir: packages/cross-x86_64-linux-gnu runs-on: ${{ matrix.runs_on }} container: - image: debian:11 + image: debian:12 outputs: version: ${{ steps.version.outputs.version }} steps: From 08fe87430151ae4347cda4d967135e5dd8d1c98d Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Fri, 20 Nov 2026 23:04:10 -0700 Subject: [PATCH 8/9] Move build backend out of the installed package Previously `src/ppbt/build.py` was both the PEP 517 build backend and part of the installed wheel. That meant anything consuming `ppbt` at runtime (notably relenv) could trip over setuptools / subprocess / tarfile machinery that only belongs at wheel-build time. Commit 09d32eb already moved setuptools imports out of ppbt.common for the same reason; this finishes the job by relocating the backend module outside `src/` entirely. - Base ppbt: `_build.py` at repo root. - Each cross sibling: `packages/cross-/_build.py`. - All three pyprojects now set `build-backend = "_build"` and `backend-path = ["."]`. - `src/ppbt/build.py` deleted; backend duplicates the small subset of ppbt.common helpers it needs (build_arch, get_triplet, extract_archive) so it is standalone and not circular. - tests/test_build.py now loads `_build.py` by path and asserts the PEP 517 hooks are exposed. --- _build.py | 264 ++++++++++++++++ .../build.py => _build.py} | 0 .../cross-aarch64-linux-gnu/pyproject.toml | 4 +- .../build.py => _build.py} | 0 .../cross-x86_64-linux-gnu/pyproject.toml | 4 +- pyproject.toml | 4 +- src/ppbt/build.py | 296 ------------------ tests/test_build.py | 29 +- 8 files changed, 295 insertions(+), 306 deletions(-) create mode 100644 _build.py rename packages/cross-aarch64-linux-gnu/{src/ppbt_cross_aarch64_linux_gnu/build.py => _build.py} (100%) rename packages/cross-x86_64-linux-gnu/{src/ppbt_cross_x86_64_linux_gnu/build.py => _build.py} (100%) delete mode 100644 src/ppbt/build.py diff --git a/_build.py b/_build.py new file mode 100644 index 0000000..6488f4a --- /dev/null +++ b/_build.py @@ -0,0 +1,264 @@ +# Copyright 2024-2026 Broadcom Corporation +# SPDX-License-Identifier: Apache-2.0 +# +""" +Build backend for the base ``ppbt`` wheel. + +Lives at the repo root (outside ``src/``) so it is NOT shipped in the +installed wheel. That keeps the runtime ``ppbt`` package free of +build-time machinery (setuptools, tarfile boilerplate, subprocess +helpers) which ``relenv`` otherwise ends up importing when it only +wants ``ppbt.common``. + +Helpers it needs from ``ppbt.common`` (``build_arch``, ``get_triplet``, +``extract_archive``, ``PPBTException``) are inlined so this file does +not depend on the package it is building. +""" +import base64 +import csv +import hashlib +import http.client +import os +import pathlib +import platform +import shutil +import subprocess +import sys +import tarfile +import time +import urllib.error +import urllib.request + +from setuptools.build_meta import ( + build_editable as _build_editable_passthrough, + build_sdist, + build_wheel, + get_requires_for_build_sdist, + get_requires_for_build_wheel, + prepare_metadata_for_build_wheel, +) + +CT_NG_VER = "1.26.0" +CT_URL = "http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-{version}.tar.bz2" +CT_GIT_REPO = "https://github.com/crosstool-ng/crosstool-ng.git" +CICD = "CI" in os.environ +PATCHELF_VERSION = "0.18.0" +PATCHELF_SOURCE = ( + f"https://github.com/NixOS/patchelf/releases/download/" + f"{PATCHELF_VERSION}/patchelf-{PATCHELF_VERSION}.tar.gz" +) + +_build_wheel = build_wheel +_build_sdist = build_sdist + + +class BuildError(RuntimeError): + """Generic build error.""" + + +def build_arch(): + """Return the lowercased host machine name.""" + return platform.machine().lower() + + +def get_triplet(machine=None, plat=None): + """Build a GNU triplet for ``machine`` + ``plat`` (host defaults).""" + if not plat: + plat = sys.platform + if not machine: + machine = build_arch() + if plat == "darwin": + return f"{machine}-macos" + if plat == "win32": + return f"{machine}-win" + if plat == "linux": + return f"{machine}-linux-gnu" + raise BuildError(f"Unknown platform {plat}") + + +def extract_archive(to_dir, archive): + """Extract ``archive`` (tar.gz / tar.xz / tar.bz2) into ``to_dir``.""" + if archive.endswith("tgz") or archive.endswith("gz"): + mode = "r:gz" + elif archive.endswith("xz"): + mode = "r:xz" + elif archive.endswith("bz2"): + mode = "r:bz2" + else: + mode = "r" + with tarfile.open(archive, mode) as t: + t.extractall(to_dir) + + +def _fetch(url, fp, backoff=3, timeout=30): + if backoff < 1: + backoff = 1 + n = 0 + while n < backoff: + n += 1 + try: + fin = urllib.request.urlopen(url, timeout=timeout) + break + except ( + urllib.error.HTTPError, + urllib.error.URLError, + http.client.RemoteDisconnected, + ): + if n >= backoff: + raise + time.sleep(n * 10) + try: + block = fin.read(1024 * 300) + while block: + fp.write(block) + block = fin.read(10240) + finally: + fin.close() + + +def download_url(url, dest): + """Download ``url`` to ``dest`` dir.""" + local = os.path.join(dest, os.path.basename(url)) + print(f"Downloading {url} -> {local}") + with open(local, "wb") as fout: + try: + _fetch(url, fout) + except Exception as exc: + print(f"Unable to download: {url} {exc}", file=sys.stderr, flush=True) + try: + os.unlink(local) + except OSError: + pass + raise + return local + + +def runcmd(cmd, **kwargs): + """Run ``cmd``, raising :class:`BuildError` on non-zero exit.""" + proc = subprocess.run(cmd, **kwargs) + if proc.returncode != 0: + raise BuildError(f"Build cmd '{' '.join(str(c) for c in cmd)}' failed") + return proc + + +def build_ppbt(branch=None): + """Build the host native toolchain and stage it inside the package. + + Downloads+compiles crosstool-ng, runs the host native config, adds + patchelf, tars up the result, and drops the archive + record file + into ``src/ppbt/_toolchain/``. + """ + cwd = pathlib.Path(os.getcwd()) + root = pathlib.Path(os.environ.get("PWD", os.getcwd())) + build = root / "build" + archdir = None + try: + print(f" ** Build dir is: {build}") + build.mkdir(exist_ok=True) + if branch: + ctngdir = build / "crosstool-ng" + if not ctngdir.exists(): + os.chdir(build) + subprocess.run(["git", "clone", "-b", branch, CT_GIT_REPO]) + else: + ctngdir = build / f"crosstool-ng-{CT_NG_VER}" + if not ctngdir.exists(): + url = CT_URL.format(version=CT_NG_VER) + archive = download_url(url, build) + extract_archive(build, archive) + + os.chdir(ctngdir) + ctng = ctngdir / "ct-ng" + if ctng.exists(): + print(f"Using existing ct-ng: {ctng}") + else: + print("Compiling ct-ng") + runcmd(["./configure", "--enable-local"]) + runcmd(["make"]) + + machine = platform.machine() + toolchain = cwd / "src" / "ppbt" / "_toolchain" + toolchain.mkdir(exist_ok=True) + + triplet = get_triplet(build_arch()) + archdir = build / triplet + if archdir.exists(): + print(f"Toolchain directory exists: {archdir}") + else: + config = ( + root / "src" / "ppbt" / "_config" / machine / f"{triplet}-ct-ng.config" + ) + if not config.exists(): + print(f"Toolchain config missing: {config}", file=sys.stderr) + sys.exit(1) + with open(config, "r") as rfp, open(ctngdir / ".config", "w") as wfp: + wfp.write(rfp.read()) + os.chdir(ctngdir) + env = os.environ.copy() + env["CT_PREFIX"] = str(build) + if os.getuid() == 0: + env["CT_ALLOW_BUILD_AS_ROOT"] = "y" + env["CT_ALLOW_BUILD_AS_ROOT_SURE"] = "y" + if CICD: + env["CT_LOG_PROGRESS"] = "n" + runcmd([str(ctng), "source"], env=env) + runcmd([str(ctng), "build"], env=env) + + source = build / f"patchelf-{PATCHELF_VERSION}" + patchelf = source / "src" / "patchelf" + if not source.exists(): + archive = download_url(PATCHELF_SOURCE, build) + extract_archive(build, archive) + if not patchelf.exists(): + os.chdir(source) + subprocess.run(["./configure"]) + subprocess.run(["make"]) + + shutil.copy(source / "src" / "patchelf", build / triplet / "bin" / "patchelf") + os.chdir(build) + archive = f"{triplet}.tar.xz" + record = f"{triplet}.tar.xz.record" + subprocess.run(["tar", "-C", str(build), "-cJf", archive, triplet], check=True) + + with open(record, "w") as rfp: + rwriter = csv.writer(rfp) + for walk_root, _dirs, files in os.walk(archdir): + relroot = pathlib.Path(walk_root).relative_to(build) + for f in files: + relpath = relroot / f + with open(relpath, "rb") as fp: + data = fp.read() + hsh = ( + base64.urlsafe_b64encode(hashlib.sha256(data).digest()) + .rstrip(b"=") + .decode() + ) + hashpath = str(pathlib.Path("ppbt") / "_toolchain" / relpath) + rwriter.writerow([hashpath, f"sha256={hsh}", len(data)]) + shutil.copy(archive, toolchain) + shutil.copy(record, toolchain) + finally: + os.chdir(cwd) + + +def build_wheel(wheel_directory, metadata_directory=None, config_settings=None): + """PEP 517 wheel creation hook.""" + build_ppbt() + return _build_wheel(wheel_directory, metadata_directory, config_settings) + + +def build_editable(wheel_directory, config_settings=None, metadata_directory=None): + """PEP 660 editable hook: skip the toolchain build for dev installs.""" + return _build_editable_passthrough( + wheel_directory, config_settings, metadata_directory + ) + + +__all__ = ( + "build_sdist", + "build_wheel", + "build_editable", + "get_requires_for_build_sdist", + "get_requires_for_build_wheel", + "prepare_metadata_for_build_wheel", +) diff --git a/packages/cross-aarch64-linux-gnu/src/ppbt_cross_aarch64_linux_gnu/build.py b/packages/cross-aarch64-linux-gnu/_build.py similarity index 100% rename from packages/cross-aarch64-linux-gnu/src/ppbt_cross_aarch64_linux_gnu/build.py rename to packages/cross-aarch64-linux-gnu/_build.py diff --git a/packages/cross-aarch64-linux-gnu/pyproject.toml b/packages/cross-aarch64-linux-gnu/pyproject.toml index 260d7ba..4b28d30 100644 --- a/packages/cross-aarch64-linux-gnu/pyproject.toml +++ b/packages/cross-aarch64-linux-gnu/pyproject.toml @@ -4,8 +4,8 @@ requires = [ "wheel>=0.31.0", "twine>=1.11.0" ] -build-backend = "ppbt_cross_aarch64_linux_gnu.build" -backend-path = ["src"] +build-backend = "_build" +backend-path = ["."] [tool.pytest.ini_options] pythonpath = [ diff --git a/packages/cross-x86_64-linux-gnu/src/ppbt_cross_x86_64_linux_gnu/build.py b/packages/cross-x86_64-linux-gnu/_build.py similarity index 100% rename from packages/cross-x86_64-linux-gnu/src/ppbt_cross_x86_64_linux_gnu/build.py rename to packages/cross-x86_64-linux-gnu/_build.py diff --git a/packages/cross-x86_64-linux-gnu/pyproject.toml b/packages/cross-x86_64-linux-gnu/pyproject.toml index 36899d6..4b28d30 100644 --- a/packages/cross-x86_64-linux-gnu/pyproject.toml +++ b/packages/cross-x86_64-linux-gnu/pyproject.toml @@ -4,8 +4,8 @@ requires = [ "wheel>=0.31.0", "twine>=1.11.0" ] -build-backend = "ppbt_cross_x86_64_linux_gnu.build" -backend-path = ["src"] +build-backend = "_build" +backend-path = ["."] [tool.pytest.ini_options] pythonpath = [ diff --git a/pyproject.toml b/pyproject.toml index d1fb5d7..7a7a225 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,8 +4,8 @@ requires = [ "wheel>=0.31.0", "twine>=1.11.0" ] -build-backend = "ppbt.build" -backend-path = ["src"] +build-backend = "_build" +backend-path = ["."] [tool.pytest.ini_options] pythonpath = [ diff --git a/src/ppbt/build.py b/src/ppbt/build.py deleted file mode 100644 index 0576efa..0000000 --- a/src/ppbt/build.py +++ /dev/null @@ -1,296 +0,0 @@ -# Copyright 2024-2026 Broadcom Corporation -# SPDX-License-Identifier: Apache-2.0 -# -""" -Build a ppbt wheel which includes a toolchain archive. -""" -import base64 -import csv -import hashlib -import http.client -import os -import pathlib -import platform -import shutil -import subprocess -import sys -import time -import urllib.error -import urllib.request - -from setuptools.build_meta import build_editable as _build_editable_passthrough -from setuptools.build_meta import build_sdist, build_wheel - -import ppbt.common - -CT_NG_VER = "1.26.0" -CT_URL = "http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-{version}.tar.bz2" -CT_GIT_REPO = "https://github.com/crosstool-ng/crosstool-ng.git" -CICD = "CI" in os.environ -PATCHELF_VERSION = "0.18.0" -PATCHELF_SOURCE = ( - f"https://github.com/NixOS/patchelf/releases/download/" - f"{PATCHELF_VERSION}/patchelf-{PATCHELF_VERSION}.tar.gz" -) - -_build_wheel = build_wheel -_build_sdist = build_sdist - - -class BuildError(ppbt.common.PPBTException, RuntimeError): - """Generic build error.""" - - -def get_download_location(url, dest): - """ - Get the full path to where the url will be downloaded to. - - :param url: The url to donwload - :type url: str - :param dest: Where to download the url to - :type dest: str - - :return: The path to where the url will be downloaded to - :rtype: str - """ - return os.path.join(dest, os.path.basename(url)) - - -def fetch_url(url, fp, backoff=3, timeout=30): - """ - Fetch the contents of a url. - - This method will store the contents in the given file like object. - """ - if backoff < 1: - backoff = 1 - n = 0 - while n < backoff: - n += 1 - try: - fin = urllib.request.urlopen(url, timeout=timeout) - except ( - urllib.error.HTTPError, - urllib.error.URLError, - http.client.RemoteDisconnected, - ): - if n >= backoff: - raise - time.sleep(n * 10) - try: - size = 1024 * 300 - block = fin.read(size) - while block: - fp.write(block) - block = fin.read(10240) - finally: - fin.close() - - -def download_url(url, dest, verbose=True, backoff=3, timeout=60): - """ - Download the url to the provided destination. - - This method assumes the last part of the url is a filename. (https://foo.com/bar/myfile.tar.xz) - - :param url: The url to download - :type url: str - :param dest: Where to download the url to - :type dest: str - :param verbose: Print download url and destination to stdout - :type verbose: bool - - :raises urllib.error.HTTPError: If the url was unable to be downloaded - - :return: The path to the downloaded content - :rtype: str - """ - local = get_download_location(url, dest) - if verbose: - print(f"Downloading {url} -> {local}") - fout = open(local, "wb") - try: - fetch_url(url, fout, backoff, timeout) - except Exception as exc: - if verbose: - print(f"Unable to download: {url} {exc}", file=sys.stderr, flush=True) - try: - os.unlink(local) - except OSError: - pass - raise - return local - - -def runcmd(*args, **kwargs): - """ - Run a command. - - Run the provided command, raising an Exception when the command finishes - with a non zero exit code. Arguments are passed through to ``subprocess.run`` - - :return: The process result - :rtype: ``subprocess.CompletedProcess`` - - :raises BuildError: If the command finishes with a non zero exit code - """ - proc = subprocess.run(*args, **kwargs) - if proc.returncode != 0: - raise BuildError("Build cmd '{}' failed".format(" ".join(args[0]))) - return proc - - -def build_ppbt(branch=None, use_tempdir=True): - """Build a toolchain and include it in the wheel. - - - Downloads and installs crosstool-ng for building a toolchain. - - Compile a toolchain - - Add patchelf to the toolchain's binaries - - Create a tarball to be included in the wheel - """ - cwd = pathlib.Path(os.getcwd()) - root = pathlib.Path(os.environ.get("PWD", os.getcwd())) - build = root / "build" - archdir = None - try: - # root = pathlib.Path(__file__).resolve().parent.parent.parent - # build = root / "build" - print(f" ** Build dir is: {build}") - build.mkdir(exist_ok=True) - if branch: - ctngdir = build / "crosstool-ng" - if not ctngdir.exists(): - os.chdir(build) - subprocess.run(["git", "clone", "-b", branch, CT_GIT_REPO]) - else: - ctngdir = build / f"crosstool-ng-{CT_NG_VER}" - if not ctngdir.exists(): - url = CT_URL.format(version=CT_NG_VER) - archive = download_url(url, build) - ppbt.common.extract_archive(build, archive) - - os.chdir(ctngdir) - ctng = ctngdir / "ct-ng" - - if ctng.exists(): - print(f"Using existing ct-ng: {ctng}") - else: - print("Compiling ct-ng") - runcmd(["./configure", "--enable-local"]) - runcmd(["make"]) - print(f"Using compiled ct-ng: {ctng}") - - arch = ppbt.common.build_arch() - machine = platform.machine() - toolchain = cwd / "src" / "ppbt" / "_toolchain" - - print(f"toolchain: {toolchain}") - - toolchain.mkdir(exist_ok=True) - - triplet = ppbt.common.get_triplet(arch) - archdir = build / triplet - print(f"Arch dir is {archdir}") - if archdir.exists(): - print("Toolchain directory exists: {}".format(archdir)) - else: - config = ( - root - / "src" - / "ppbt" - / "_config" - / machine - / "{}-ct-ng.config".format(triplet) - ) - if not config.exists(): - print("Toolchain config missing: {}".format(config)) - sys.exit(1) - with open(config, "r") as rfp: - print("Writing crosstool-ng .config") - with open(ctngdir / ".config", "w") as wfp: - wfp.write(rfp.read()) - os.chdir(ctngdir) - env = os.environ.copy() - env["CT_PREFIX"] = build - if os.getuid() == 0: - env["CT_ALLOW_BUILD_AS_ROOT"] = "y" - env["CT_ALLOW_BUILD_AS_ROOT_SURE"] = "y" - if CICD: - env["CT_LOG_PROGRESS"] = "n" - runcmd( - [ - str(ctng), - "source", - ], - env=env, - ) - runcmd( - [ - str(ctng), - "build", - ], - env=env, - ) - - source = build / f"patchelf-{PATCHELF_VERSION}" - patchelf = source / "src" / "patchelf" - if source.exists(): - print(f"Using existing patchelf source: {source}") - else: - print(f"Fetchin patchelf source: {PATCHELF_SOURCE}") - archive = download_url(PATCHELF_SOURCE, build) - ppbt.common.extract_archive(build, archive) - os.chdir(source) - - if patchelf.exists(): - print(f"Using existing patchelf binary: {source}") - else: - print("Build patchelf") - subprocess.run(["./configure"]) - subprocess.run(["make"]) - - shutil.copy(source / "src" / "patchelf", build / triplet / "bin" / "patchelf") - os.chdir(build) - archive = f"{ triplet }.tar.xz" - record = f"{ triplet }.tar.xz.record" - cmd = ["tar", "-C", f"{ build }", "-cJf", f"{ archive }", f"{ triplet }"] - subprocess.run(cmd) - - # XXX: Figure out why things break when using the tarfile module. - with open(record, "w") as rfp: - rwriter = csv.writer(rfp) - for root, _dirs, files in os.walk(archdir): - relroot = pathlib.Path(root).relative_to(build) - for f in files: - print(f"Archive {relroot} / {f}") - relpath = relroot / f - with open(relpath, "rb") as fp: - data = fp.read() - hsh = ( - base64.urlsafe_b64encode(hashlib.sha256(data).digest()) - .rstrip(b"=") - .decode() - ) - hashpath = str(pathlib.Path("ppbt") / "_toolchain" / relpath) - rwriter.writerow([hashpath, f"sha256={hsh}", len(data)]) - print(f"Copying {archive} to {toolchain}") - shutil.copy(archive, toolchain) - print(f"Copying {record} to {toolchain}") - shutil.copy(record, toolchain) - finally: - # if archdir and archdir.exists(): - # shutil.rmtree(archdir) - os.chdir(cwd) - - -def build_wheel(wheel_directory, metadata_directory=None, config_settings=None): - """PEP 517 wheel creation hook.""" - build_ppbt() - return _build_wheel(wheel_directory, metadata_directory, config_settings) - - -def build_editable(wheel_directory, config_settings=None, metadata_directory=None): - """PEP 660 editable hook: skip the toolchain build for dev installs.""" - return _build_editable_passthrough( - wheel_directory, config_settings, metadata_directory - ) diff --git a/tests/test_build.py b/tests/test_build.py index b989898..b72a866 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -1,8 +1,29 @@ -# Copyright 2024 Broadcom Corporation +# Copyright 2024-2026 Broadcom Corporation # SPDX-License-Identifier: Apache-2.0 # -import ppbt.build +""" +Smoke-test the build backend module loads. +The build backend lives at the repo root (``_build.py``) rather than +inside the installed ``ppbt`` package, so the installed wheel stays +free of setuptools/subprocess machinery. Reach it via its +``backend-path`` so the test works both in-tree and from an sdist. +""" +import importlib.util +import pathlib -def test_noop(): - assert ppbt.build +BACKEND = pathlib.Path(__file__).resolve().parent.parent / "_build.py" + + +def test_build_backend_imports(): + """``_build.py`` loads and exposes the PEP 517 hooks.""" + spec = importlib.util.spec_from_file_location("_build_under_test", BACKEND) + mod = importlib.util.module_from_spec(spec) + spec.loader.exec_module(mod) + for hook in ( + "build_sdist", + "build_wheel", + "build_editable", + "prepare_metadata_for_build_wheel", + ): + assert callable(getattr(mod, hook)), f"backend missing {hook}" From 0a95c2b0891a3d41bf51953bf85e46d05e3ae978 Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Fri, 20 Nov 2026 23:11:43 -0700 Subject: [PATCH 9/9] Dodge isort 5.12 renamed-import split in _build.py Isort 5.12 (pre-commit-pinned) splits `from X import Y as _Y` onto its own line, which disagrees with my local isort's black profile and ping-pongs the file. Import the submodule once and dereference each PEP 517 hook off it instead; no `as` imports, no disagreement. --- _build.py | 17 ++++++++--------- packages/cross-aarch64-linux-gnu/_build.py | 17 ++++++++--------- packages/cross-x86_64-linux-gnu/_build.py | 17 ++++++++--------- 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/_build.py b/_build.py index 6488f4a..c22e348 100644 --- a/_build.py +++ b/_build.py @@ -29,14 +29,13 @@ import urllib.error import urllib.request -from setuptools.build_meta import ( - build_editable as _build_editable_passthrough, - build_sdist, - build_wheel, - get_requires_for_build_sdist, - get_requires_for_build_wheel, - prepare_metadata_for_build_wheel, -) +from setuptools import build_meta as _st_build_meta + +build_sdist = _st_build_meta.build_sdist +build_wheel = _st_build_meta.build_wheel +get_requires_for_build_sdist = _st_build_meta.get_requires_for_build_sdist +get_requires_for_build_wheel = _st_build_meta.get_requires_for_build_wheel +prepare_metadata_for_build_wheel = _st_build_meta.prepare_metadata_for_build_wheel CT_NG_VER = "1.26.0" CT_URL = "http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-{version}.tar.bz2" @@ -249,7 +248,7 @@ def build_wheel(wheel_directory, metadata_directory=None, config_settings=None): def build_editable(wheel_directory, config_settings=None, metadata_directory=None): """PEP 660 editable hook: skip the toolchain build for dev installs.""" - return _build_editable_passthrough( + return _st_build_meta.build_editable( wheel_directory, config_settings, metadata_directory ) diff --git a/packages/cross-aarch64-linux-gnu/_build.py b/packages/cross-aarch64-linux-gnu/_build.py index 972fb4c..2d11b58 100644 --- a/packages/cross-aarch64-linux-gnu/_build.py +++ b/packages/cross-aarch64-linux-gnu/_build.py @@ -23,19 +23,18 @@ import urllib.error import urllib.request -from setuptools.build_meta import build_editable as _build_editable_passthrough -from setuptools.build_meta import ( - build_sdist, - build_wheel, - get_requires_for_build_sdist, - get_requires_for_build_wheel, - prepare_metadata_for_build_wheel, -) +from setuptools import build_meta as _st_build_meta + +build_sdist = _st_build_meta.build_sdist +build_wheel = _st_build_meta.build_wheel +get_requires_for_build_sdist = _st_build_meta.get_requires_for_build_sdist +get_requires_for_build_wheel = _st_build_meta.get_requires_for_build_wheel +prepare_metadata_for_build_wheel = _st_build_meta.prepare_metadata_for_build_wheel def build_editable(wheel_directory, config_settings=None, metadata_directory=None): """PEP 660 editable hook: skip the toolchain build.""" - return _build_editable_passthrough( + return _st_build_meta.build_editable( wheel_directory, config_settings, metadata_directory ) diff --git a/packages/cross-x86_64-linux-gnu/_build.py b/packages/cross-x86_64-linux-gnu/_build.py index 19dde7c..373e1c6 100644 --- a/packages/cross-x86_64-linux-gnu/_build.py +++ b/packages/cross-x86_64-linux-gnu/_build.py @@ -23,19 +23,18 @@ import urllib.error import urllib.request -from setuptools.build_meta import build_editable as _build_editable_passthrough -from setuptools.build_meta import ( - build_sdist, - build_wheel, - get_requires_for_build_sdist, - get_requires_for_build_wheel, - prepare_metadata_for_build_wheel, -) +from setuptools import build_meta as _st_build_meta + +build_sdist = _st_build_meta.build_sdist +build_wheel = _st_build_meta.build_wheel +get_requires_for_build_sdist = _st_build_meta.get_requires_for_build_sdist +get_requires_for_build_wheel = _st_build_meta.get_requires_for_build_wheel +prepare_metadata_for_build_wheel = _st_build_meta.prepare_metadata_for_build_wheel def build_editable(wheel_directory, config_settings=None, metadata_directory=None): """PEP 660 editable hook: skip the toolchain build.""" - return _build_editable_passthrough( + return _st_build_meta.build_editable( wheel_directory, config_settings, metadata_directory )