From f2888ae0a10451a7b023625373a3f65d5a494b9d Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Wed, 28 Oct 2026 18:07:44 +0100 Subject: [PATCH 01/51] ci: add Cargo license policy Co-Authored-By: Claude Sonnet 5.5 --- deny.toml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 deny.toml diff --git a/deny.toml b/deny.toml new file mode 100644 index 0000000..2629bec --- /dev/null +++ b/deny.toml @@ -0,0 +1,13 @@ +[licenses] +confidence-threshold = 0.8 +allow = [ + "Apache-2.0", + "Apache-2.0 WITH LLVM-exception", + "BSD-2-Clause", + "BSD-3-Clause", + "BSL-1.0", + "ISC", + "MIT", + "Unicode-3.0", + "Zlib", +] From 0ff3b5ef9afab8eddcfb3bbda2c7d7dcf4821e67 Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Wed, 28 Oct 2026 18:08:14 +0100 Subject: [PATCH 02/51] ci: inspect npm and platform package licenses Co-Authored-By: Claude Sonnet 5.5 --- scripts/check-npm-licenses.mjs | 75 ++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 scripts/check-npm-licenses.mjs diff --git a/scripts/check-npm-licenses.mjs b/scripts/check-npm-licenses.mjs new file mode 100644 index 0000000..7ef84f8 --- /dev/null +++ b/scripts/check-npm-licenses.mjs @@ -0,0 +1,75 @@ +import { readFile } from 'node:fs/promises'; +import { resolve } from 'node:path'; +import { pathToFileURL } from 'node:url'; + +const allowed = new Set(['MIT', 'Apache-2.0', 'BSD-2-Clause', 'BSD-3-Clause', 'ISC', '0BSD', 'MIT OR Apache-2.0', 'Apache-2.0 OR MIT']); +const platformPrefix = '@ktav-lang/js-'; +const versionPattern = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/; +const dependencyFields = ['dependencies', 'optionalDependencies', 'peerDependencies', 'bundledDependencies', 'bundleDependencies']; + +export function checkLock(lock, root) { + if (lock?.lockfileVersion !== 3 || !lock.packages || typeof lock.packages !== 'object' || Array.isArray(lock.packages) || !lock.packages['']) { + throw new Error('Invalid npm lockfile'); + } + const failures = []; + const platforms = []; + for (const [path, pkg] of Object.entries(lock.packages)) { + if (path === '') continue; + if (allowed.has(pkg?.license)) continue; + if (path === 'node_modules/argparse' && pkg?.version === '2.0.1' && pkg?.dev === true && pkg?.license === 'Python-2.0') continue; + const name = path.startsWith('node_modules/') ? path.slice('node_modules/'.length) : ''; + const suffix = name.startsWith(platformPrefix) ? name.slice(platformPrefix.length) : ''; + const version = root?.optionalDependencies?.[name]; + if (!pkg?.license && pkg?.optional === true && /^[a-z0-9-]+$/.test(suffix) && versionPattern.test(version || '')) { + platforms.push({ name, version, suffix }); + } else { + failures.push(`${path}: unapproved or missing license ${JSON.stringify(pkg?.license)}`); + } + } + for (const [name, version] of Object.entries(root?.optionalDependencies || {})) { + if (name.startsWith(platformPrefix) && !lock.packages[`node_modules/${name}`]) { + failures.push(`${name}@${version}: missing lockfile entry`); + } + } + return { failures, platforms }; +} + +export function checkPlatform(expected, local, published) { + const failures = []; + for (const [label, pkg] of [['local', local], ['registry', published]]) { + if (pkg?.name !== expected.name || pkg?.version !== expected.version || !allowed.has(pkg?.license)) { + failures.push(`${expected.name}@${expected.version}: invalid ${label} identity or license`); + } + for (const field of dependencyFields) { + if (pkg?.[field] != null && (typeof pkg[field] !== 'object' || Object.keys(pkg[field]).length > 0)) { + failures.push(`${expected.name}@${expected.version}: unreviewed ${label} ${field}`); + } + } + } + if (local?.license !== published?.license) failures.push(`${expected.name}@${expected.version}: license metadata differs`); + return failures; +} + +async function main() { + const lock = JSON.parse(await readFile('package-lock.json', 'utf8')); + const root = JSON.parse(await readFile('package.json', 'utf8')); + const { failures, platforms } = checkLock(lock, root); + for (const expected of platforms) { + try { + const local = JSON.parse(await readFile(`npm/${expected.suffix}/package.json`, 'utf8')); + const response = await fetch(`https://registry.npmjs.org/${encodeURIComponent(expected.name)}/${encodeURIComponent(expected.version)}`); + if (!response.ok) throw new Error(`registry HTTP ${response.status}`); + failures.push(...checkPlatform(expected, local, await response.json())); + } catch (error) { + failures.push(`${expected.name}@${expected.version}: ${error.message}`); + } + } + if (failures.length) { + for (const failure of failures) console.error(failure); + process.exitCode = 1; + } else { + console.log(`Checked ${Object.keys(lock.packages).length - 1} npm lockfile entries`); + } +} + +if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) await main(); From ee244bc8c51dd98f4e2a6f23f4eb8b9a48c3b606 Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Wed, 28 Oct 2026 18:08:27 +0100 Subject: [PATCH 03/51] test: cover npm license and platform policy Co-Authored-By: Claude Sonnet 5.5 --- tests/npm-license-policy.test.mjs | 47 +++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 tests/npm-license-policy.test.mjs diff --git a/tests/npm-license-policy.test.mjs b/tests/npm-license-policy.test.mjs new file mode 100644 index 0000000..3a3f347 --- /dev/null +++ b/tests/npm-license-policy.test.mjs @@ -0,0 +1,47 @@ +import assert from 'node:assert/strict'; +import test from 'node:test'; +import { checkLock, checkPlatform } from '../scripts/check-npm-licenses.mjs'; + +const name = '@ktav-lang/js-linux-x64-gnu'; +const root = { optionalDependencies: { [name]: '0.8.1' } }; +const entry = `node_modules/${name}`; +const lock = (packages) => ({ lockfileVersion: 3, packages: { '': {}, ...packages } }); + +test('checks every lockfile entry and rejects unapproved compounds', () => { + const result = checkLock(lock({ + 'node_modules/a': { license: 'MIT AND GPL-3.0-only' }, + 'node_modules/b': {}, + 'node_modules/c': { license: 'MIT' }, + }), {}); + assert.equal(result.failures.length, 2); + assert.equal(result.platforms.length, 0); +}); + +test('limits Python-2.0 exception to the reviewed development package', () => { + const result = checkLock(lock({ + 'node_modules/argparse': { version: '2.0.1', dev: true, license: 'Python-2.0' }, + 'node_modules/a': { version: '2.0.1', dev: true, license: 'Python-2.0' }, + }), {}); + assert.equal(result.failures.length, 1); + assert.match(result.failures[0], /node_modules\/a/); + assert.equal(checkLock(lock({ 'node_modules/argparse': { version: '2.0.1', license: 'Python-2.0' } }), {}).failures.length, 1); +}); + +test('requires reviewed optional packages to match registry and local metadata', () => { + const result = checkLock(lock({ [entry]: { optional: true } }), root); + assert.deepEqual(result.failures, []); + assert.equal(result.platforms.length, 1); + const expected = result.platforms[0]; + const pkg = { name, version: '0.8.1', license: 'MIT OR Apache-2.0' }; + assert.deepEqual(checkPlatform(expected, pkg, pkg), []); + assert.notEqual(checkPlatform(expected, pkg, { ...pkg, license: 'UNKNOWN' }).length, 0); + assert.notEqual(checkPlatform(expected, pkg, { ...pkg, dependencies: { unreviewed: '1' } }).length, 0); + assert.notEqual(checkPlatform(expected, pkg, { ...pkg, version: '0.8.2' }).length, 0); + assert.notEqual(checkLock(lock({}), root).failures.length, 0); + assert.notEqual(checkLock(lock({ [entry]: { optional: true } }), { optionalDependencies: { [name]: '^0.8.1' } }).failures.length, 0); +}); + +test('rejects malformed lockfiles', () => { + assert.throws(() => checkLock({ lockfileVersion: 2, packages: {} }, {})); + assert.throws(() => checkLock({ lockfileVersion: 3 }, {})); +}); From d8451f0cc0e10f44a91dc4676fb1030d3cca8f6d Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Wed, 28 Oct 2026 18:08:40 +0100 Subject: [PATCH 04/51] ci: check Cargo and npm licenses Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/licenses.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/licenses.yml diff --git a/.github/workflows/licenses.yml b/.github/workflows/licenses.yml new file mode 100644 index 0000000..a262ed3 --- /dev/null +++ b/.github/workflows/licenses.yml @@ -0,0 +1,31 @@ +name: License checks + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +jobs: + cargo-licenses: + name: Cargo dependency licenses + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: EmbarkStudios/cargo-deny-action@b66acf5e9fe20f8aba065be86778a8a4c846f902 + with: + command: check licenses + + npm-licenses: + name: npm dependency licenses + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '24' + - run: npm ci --ignore-scripts + - run: node --test tests/npm-license-policy.test.mjs + - run: node scripts/check-npm-licenses.mjs From 27bf5984f5d48c26c922a0ade959f4e004b1c3ac Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Wed, 28 Oct 2026 18:38:27 +0100 Subject: [PATCH 05/51] ci: check committed and resolved npm graphs Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/licenses.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/licenses.yml b/.github/workflows/licenses.yml index a262ed3..51e7651 100644 --- a/.github/workflows/licenses.yml +++ b/.github/workflows/licenses.yml @@ -26,6 +26,10 @@ jobs: - uses: actions/setup-node@v4 with: node-version: '24' - - run: npm ci --ignore-scripts - run: node --test tests/npm-license-policy.test.mjs - - run: node scripts/check-npm-licenses.mjs + - name: Check committed npm lockfile + run: node scripts/check-npm-licenses.mjs + - name: Resolve npm graph without lifecycle scripts + run: npm install --ignore-scripts + - name: Check resolved npm graph + run: node scripts/check-npm-licenses.mjs From a635b429d5ee7896987f6abe17b1688ddf8ad42d Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Wed, 28 Oct 2026 19:59:55 +0100 Subject: [PATCH 06/51] ci: audit Vite example dependencies Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/licenses.yml | 4 ++++ scripts/check-npm-licenses.mjs | 9 +++++---- tests/npm-license-policy.test.mjs | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/.github/workflows/licenses.yml b/.github/workflows/licenses.yml index 51e7651..9357dca 100644 --- a/.github/workflows/licenses.yml +++ b/.github/workflows/licenses.yml @@ -33,3 +33,7 @@ jobs: run: npm install --ignore-scripts - name: Check resolved npm graph run: node scripts/check-npm-licenses.mjs + - name: Resolve Vite example dependencies without lifecycle scripts + run: npm --prefix examples/bundler-vite install --package-lock-only --ignore-scripts --no-audit --no-fund + - name: Check Vite example licenses + run: node scripts/check-npm-licenses.mjs examples/bundler-vite diff --git a/scripts/check-npm-licenses.mjs b/scripts/check-npm-licenses.mjs index 7ef84f8..8bec36a 100644 --- a/scripts/check-npm-licenses.mjs +++ b/scripts/check-npm-licenses.mjs @@ -1,5 +1,5 @@ import { readFile } from 'node:fs/promises'; -import { resolve } from 'node:path'; +import { join, resolve } from 'node:path'; import { pathToFileURL } from 'node:url'; const allowed = new Set(['MIT', 'Apache-2.0', 'BSD-2-Clause', 'BSD-3-Clause', 'ISC', '0BSD', 'MIT OR Apache-2.0', 'Apache-2.0 OR MIT']); @@ -51,12 +51,13 @@ export function checkPlatform(expected, local, published) { } async function main() { - const lock = JSON.parse(await readFile('package-lock.json', 'utf8')); - const root = JSON.parse(await readFile('package.json', 'utf8')); + const base = process.argv[2] || '.'; + const lock = JSON.parse(await readFile(join(base, 'package-lock.json'), 'utf8')); + const root = JSON.parse(await readFile(join(base, 'package.json'), 'utf8')); const { failures, platforms } = checkLock(lock, root); for (const expected of platforms) { try { - const local = JSON.parse(await readFile(`npm/${expected.suffix}/package.json`, 'utf8')); + const local = JSON.parse(await readFile(join(base, 'npm', expected.suffix, 'package.json'), 'utf8')); const response = await fetch(`https://registry.npmjs.org/${encodeURIComponent(expected.name)}/${encodeURIComponent(expected.version)}`); if (!response.ok) throw new Error(`registry HTTP ${response.status}`); failures.push(...checkPlatform(expected, local, await response.json())); diff --git a/tests/npm-license-policy.test.mjs b/tests/npm-license-policy.test.mjs index 3a3f347..fdedefd 100644 --- a/tests/npm-license-policy.test.mjs +++ b/tests/npm-license-policy.test.mjs @@ -1,4 +1,8 @@ import assert from 'node:assert/strict'; +import { spawnSync } from 'node:child_process'; +import { mkdtempSync, writeFileSync } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { join, resolve } from 'node:path'; import test from 'node:test'; import { checkLock, checkPlatform } from '../scripts/check-npm-licenses.mjs'; @@ -41,6 +45,16 @@ test('requires reviewed optional packages to match registry and local metadata', assert.notEqual(checkLock(lock({ [entry]: { optional: true } }), { optionalDependencies: { [name]: '^0.8.1' } }).failures.length, 0); }); +test('checks an independent npm project from a specified directory', () => { + const dir = mkdtempSync(join(tmpdir(), 'ktav-license-test-')); + writeFileSync(join(dir, 'package.json'), '{}'); + writeFileSync(join(dir, 'package-lock.json'), JSON.stringify(lock({ 'node_modules/x': { license: 'MIT' } }))); + const script = resolve('scripts/check-npm-licenses.mjs'); + assert.equal(spawnSync(process.execPath, [script, dir]).status, 0); + writeFileSync(join(dir, 'package-lock.json'), JSON.stringify(lock({ 'node_modules/x': { license: 'UNKNOWN' } }))); + assert.equal(spawnSync(process.execPath, [script, dir]).status, 1); +}); + test('rejects malformed lockfiles', () => { assert.throws(() => checkLock({ lockfileVersion: 2, packages: {} }, {})); assert.throws(() => checkLock({ lockfileVersion: 3 }, {})); From e2a3633ce155faaeaf9195b3112247d010cc104e Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Thu, 29 Oct 2026 07:33:48 +0100 Subject: [PATCH 07/51] fix: build genuine musl Node addons Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/musl-ci.yml | 74 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 23 ++++------- scripts/build-musl-addon.sh | 30 ++++++++++++++ 3 files changed, 111 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/musl-ci.yml create mode 100644 scripts/build-musl-addon.sh diff --git a/.github/workflows/musl-ci.yml b/.github/workflows/musl-ci.yml new file mode 100644 index 0000000..4c5b29f --- /dev/null +++ b/.github/workflows/musl-ci.yml @@ -0,0 +1,74 @@ +name: Musl native compatibility + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +jobs: + musl-addon: + name: Musl addon and corpus (${{ matrix.target }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + max-parallel: 1 + matrix: + include: + - target: x86_64-unknown-linux-musl + addon: ktav.linux-x64-musl.node + platform: linux/amd64 + - target: aarch64-unknown-linux-musl + addon: ktav.linux-arm64-musl.node + platform: linux/arm64 + steps: + - uses: actions/checkout@v6 + with: + submodules: recursive + persist-credentials: false + - uses: actions/setup-node@v6 + with: + node-version: '22' + - uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + - uses: mlugg/setup-zig@v2 + with: + version: 0.14.0 + - uses: taiki-e/install-action@v2 + with: + tool: cargo-zigbuild + - run: npm install + - run: npm run build:ts + - name: Build and verify release-path addon + env: + MUSL_TARGET: ${{ matrix.target }} + run: bash scripts/build-musl-addon.sh "$MUSL_TARGET" + - uses: docker/setup-qemu-action@v3 + if: matrix.platform == 'linux/arm64' + with: + platforms: arm64 + - name: Run native corpus in Alpine + shell: bash + env: + ADDON: ${{ matrix.addon }} + PLATFORM: ${{ matrix.platform }} + run: | + set -euo pipefail + stage="$(mktemp -d)" + mkdir -p "$stage/dist/native" "$stage/dist/ts" "$stage/spec" + cp "$ADDON" "$stage/dist/native/$ADDON" + cp -R dist/ts/. "$stage/dist/ts/" + cp -R tests "$stage/tests" + cp -R spec/versions "$stage/spec/versions" + cp package.json "$stage/package.json" + docker pull --platform "$PLATFORM" node:22-alpine + docker run --rm --platform "$PLATFORM" --network none \ + --mount "type=bind,source=$stage,target=/work,readonly" \ + --workdir /work node:22-alpine /bin/sh -ec ' + node tests/node/run-node-napi.mjs + node tests/node/run-edit-napi.mjs + node tests/node/run-spec09-napi.mjs + ' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7e62a5c..2cb8ef8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -79,19 +79,13 @@ jobs: target: aarch64-unknown-linux-gnu build: npx napi build --release -p ktav-napi --target aarch64-unknown-linux-gnu --platform --js false --output-dir . --use-napi-cross - # Linux musl — Zig is the only reliable static-MUSL linker - # on hosted runners; cargo-zigbuild is what napi-rs ships for. + # Both musl targets use Zig and verify their ELF dependencies. - os: ubuntu-latest target: x86_64-unknown-linux-musl - build: npx napi build --release -p ktav-napi --target x86_64-unknown-linux-musl --platform --js false --output-dir . --use-napi-cross - # aarch64-unknown-linux-musl uses cargo-zigbuild via - # `--cross-compile` — @napi-rs/cross-toolchain doesn't ship - # an x64→aarch64-musl linker pair, but zig's bundled musl - # sysroot handles it cleanly. The `setup-zig` step below is - # gated on the target name so it only runs here. + build: bash scripts/build-musl-addon.sh x86_64-unknown-linux-musl - os: ubuntu-latest target: aarch64-unknown-linux-musl - build: npx napi build --release -p ktav-napi --target aarch64-unknown-linux-musl --platform --js false --output-dir . --cross-compile + build: bash scripts/build-musl-addon.sh aarch64-unknown-linux-musl steps: - uses: actions/checkout@v6 @@ -108,16 +102,13 @@ jobs: with: key: ${{ matrix.settings.target }} - # Zig is only required by the `--cross-compile` build path — we - # use it for aarch64-unknown-linux-musl (see matrix comment). - # Skipping on every other target avoids a 150MB download × 7. - - name: Install zig (for --cross-compile targets only) - if: matrix.settings.target == 'aarch64-unknown-linux-musl' + - name: Install zig (musl targets) + if: endsWith(matrix.settings.target, '-unknown-linux-musl') uses: mlugg/setup-zig@v2 with: version: 0.14.0 - - name: Install cargo-zigbuild (for --cross-compile targets only) - if: matrix.settings.target == 'aarch64-unknown-linux-musl' + - name: Install cargo-zigbuild (musl targets) + if: endsWith(matrix.settings.target, '-unknown-linux-musl') uses: taiki-e/install-action@v2 with: tool: cargo-zigbuild diff --git a/scripts/build-musl-addon.sh b/scripts/build-musl-addon.sh new file mode 100644 index 0000000..8582484 --- /dev/null +++ b/scripts/build-musl-addon.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +set -euo pipefail + +case "${1:-}" in + x86_64-unknown-linux-musl) addon=ktav.linux-x64-musl.node; machine='Advanced Micro Devices X86-64' ;; + aarch64-unknown-linux-musl) addon=ktav.linux-arm64-musl.node; machine='AArch64' ;; + *) printf 'Unsupported musl target: %s\n' "${1:-}" >&2; exit 1 ;; +esac + +npx --no-install napi build --release -p ktav-napi --target "$1" --platform --js false --output-dir . --cross-compile +test -s "$addon" +python3 - "$addon" "$machine" <<'PY' +import re +import subprocess +import sys + +path, expected_machine = sys.argv[1:] +header = subprocess.check_output(['readelf', '-h', path], text=True) +machine = re.search(r'^\s*Machine:\s*(.+)$', header, re.MULTILINE) +if not machine or machine.group(1).strip() != expected_machine: + raise SystemExit(f'{path}: unexpected ELF machine') +dynamic = subprocess.check_output(['readelf', '-d', path], text=True) +needed = re.findall(r'Shared library: \[([^]]+)\]', dynamic) +if any(name != 'libc.so' for name in needed): + raise SystemExit(f'{path}: unexpected shared libraries: {needed!r}') +versions = subprocess.check_output(['readelf', '--version-info', path], text=True) +if re.search(r'\bGLIBC_[0-9]', versions): + raise SystemExit(f'{path}: glibc symbol version in musl addon') +print(f'{path}: ELF machine and musl dynamic dependencies verified: {needed!r}') +PY From d53d7fac008c7c257ef68de26c8d5cfcc0c9d345 Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Thu, 29 Oct 2026 07:44:14 +0100 Subject: [PATCH 08/51] test: require dynamic musl libc in addons Co-Authored-By: Claude Sonnet 5.5 --- scripts/build-musl-addon.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build-musl-addon.sh b/scripts/build-musl-addon.sh index 8582484..5eb1284 100644 --- a/scripts/build-musl-addon.sh +++ b/scripts/build-musl-addon.sh @@ -21,7 +21,7 @@ if not machine or machine.group(1).strip() != expected_machine: raise SystemExit(f'{path}: unexpected ELF machine') dynamic = subprocess.check_output(['readelf', '-d', path], text=True) needed = re.findall(r'Shared library: \[([^]]+)\]', dynamic) -if any(name != 'libc.so' for name in needed): +if needed != ['libc.so']: raise SystemExit(f'{path}: unexpected shared libraries: {needed!r}') versions = subprocess.check_output(['readelf', '--version-info', path], text=True) if re.search(r'\bGLIBC_[0-9]', versions): From 318e3b238d2fed6a6a54646946e9c692431b84bc Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Thu, 29 Oct 2026 08:21:50 +0100 Subject: [PATCH 09/51] docs: clarify musl build comment Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2cb8ef8..a120aca 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -79,7 +79,7 @@ jobs: target: aarch64-unknown-linux-gnu build: npx napi build --release -p ktav-napi --target aarch64-unknown-linux-gnu --platform --js false --output-dir . --use-napi-cross - # Both musl targets use Zig and verify their ELF dependencies. + # Оба musl target используют Zig и проверяют ELF. - os: ubuntu-latest target: x86_64-unknown-linux-musl build: bash scripts/build-musl-addon.sh x86_64-unknown-linux-musl From f3e2c16df660718f3db8d959f2d47f5985ec75ac Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Fri, 30 Oct 2026 01:45:20 +0100 Subject: [PATCH 10/51] ci: audit WASM notices in actual npm packages Prepare source-backed Cargo and standard-library notices for source0.8.1 and retain them after wasm-pack optimization and inline generation. Inspect actual npm tarball payloads and exact inline/standalone identity. Keep this prototype separate from publishing and production release jobs. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/wasm-notice-check.yml | 114 ++++++++++++++++++++++++ ci/about.toml | 11 +++ scripts/cargo_notice_bundle.py | 113 +++++++++++++++++++++++ scripts/check_embedded_notices.py | 72 +++++++++++++++ scripts/check_wasm_npm.py | 50 +++++++++++ scripts/collect_cargo_notices.py | 108 ++++++++++++++++++++++ scripts/prepare_js_notices.py | 64 +++++++++++++ scripts/wasm-notice-resource.mjs | 79 ++++++++++++++++ tests/test_wasm_npm.py | 94 +++++++++++++++++++ tests/wasm-notice-resource.test.mjs | 56 ++++++++++++ 10 files changed, 761 insertions(+) create mode 100644 .github/workflows/wasm-notice-check.yml create mode 100644 ci/about.toml create mode 100644 scripts/cargo_notice_bundle.py create mode 100644 scripts/check_embedded_notices.py create mode 100644 scripts/check_wasm_npm.py create mode 100644 scripts/collect_cargo_notices.py create mode 100644 scripts/prepare_js_notices.py create mode 100644 scripts/wasm-notice-resource.mjs create mode 100644 tests/test_wasm_npm.py create mode 100644 tests/wasm-notice-resource.test.mjs diff --git a/.github/workflows/wasm-notice-check.yml b/.github/workflows/wasm-notice-check.yml new file mode 100644 index 0000000..f2bb36d --- /dev/null +++ b/.github/workflows/wasm-notice-check.yml @@ -0,0 +1,114 @@ +name: WASM notice evidence + +on: + pull_request: + +permissions: + contents: read + +env: + SOURCE_REF: 562deb3fde092d63a78f359be095e5079929d0d1 + +jobs: + wasm-notices: + name: WASM notice / actual npm package + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Preserve notice tools + shell: python + run: | + import os + import shutil + from pathlib import Path + stage = Path(os.environ['RUNNER_TEMP']) / 'wasm-notice-tools' + stage.mkdir() + for name in ['scripts/wasm-notice-resource.mjs', 'tests/wasm-notice-resource.test.mjs', 'tests/test_wasm_npm.py', 'scripts/prepare_js_notices.py', 'scripts/check_wasm_npm.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/check_embedded_notices.py', 'ci/about.toml']: + target = stage / name + target.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(name, target) + - uses: actions/checkout@v4 + with: + ref: ${{ env.SOURCE_REF }} + submodules: recursive + persist-credentials: false + - name: Apply notice-only build overlay + shell: python + run: | + import hashlib + import json + import os + import shutil + import subprocess + from pathlib import Path + if subprocess.check_output(['git', 'rev-parse', 'HEAD'], text=True).strip() != os.environ['SOURCE_REF']: + raise SystemExit('unexpected WASM source revision') + stage = Path(os.environ['RUNNER_TEMP']) / 'wasm-notice-tools' + for path in stage.rglob('*'): + if path.is_file(): + target = Path(path.relative_to(stage)) + target.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(path, target) + script = Path('scripts/build-wasm.mjs') + original = script.read_bytes() + anchor = b'buildWebInline();' + if original.count(anchor) != 1: + raise SystemExit('WASM inline boundary changed') + hook = b'for (const subdir of ["web", "bundler"]) addNoticeFile(resolve(outRoot, subdir, "ktav_bg.wasm"), process.env.KTAV_NATIVE_NOTICES);' + packaged = b'import { addNoticeFile } from "./wasm-notice-resource.mjs";' + bytes([10]) + original.replace(anchor, hook + bytes([10, 10]) + anchor) + script.write_bytes(packaged) + record = {'source_ref': os.environ['SOURCE_REF'], 'tooling_ref': os.environ['GITHUB_SHA'], 'original_build_script_sha256': hashlib.sha256(original).hexdigest(), 'packaged_build_script_sha256': hashlib.sha256(packaged).hexdigest(), 'coverage': 'Audit-only Cargo/std prototype, not historical npm or non-Cargo runtime compliance.'} + (Path(os.environ['RUNNER_TEMP']) / 'wasm-source-provenance.json').write_text(json.dumps(record, sort_keys=True, indent=2)) + subprocess.run(['git', 'diff', '--exit-code', '--', 'Cargo.toml', 'crates', 'tests/node', 'root-docs', 'package.json', 'package-lock.json'], check=True) + - uses: actions/setup-node@v4 + with: + node-version: '24' + - uses: dtolnay/rust-toolchain@1.99.1 + with: + targets: wasm32-unknown-unknown + components: rust-docs + - uses: taiki-e/install-action@v2 + with: + tool: cargo-about@0.9.3,wasm-pack + - name: Verify notice section and tarball guards + run: | + node --test tests/wasm-notice-resource.test.mjs + python3 -I -m unittest discover -s tests -p test_wasm_npm.py -v + - name: Prepare source-backed locked notices + shell: bash + run: | + set -euo pipefail + python3 scripts/prepare_js_notices.py "$RUNNER_TEMP/wasm-notices" + cp "$RUNNER_TEMP/wasm-source-provenance.json" "$RUNNER_TEMP/wasm-notices/source-provenance.json" + printf 'KTAV_NATIVE_NOTICES=%s\n' "$RUNNER_TEMP/wasm-notices/NOTICE.json.gz" >> "$GITHUB_ENV" + wasm-pack --version > "$RUNNER_TEMP/wasm-notices/wasm-pack-version.txt" + - run: npm ci --ignore-scripts + - name: Build final WASM before inline generation + env: + CARGO_NET_OFFLINE: 'true' + run: node scripts/build-wasm.mjs + - name: Verify final WASM resources + shell: bash + run: | + set -euo pipefail + cmp Cargo.lock "$RUNNER_TEMP/wasm-notices/Cargo.lock" + for target in web bundler; do + node --input-type=module -e 'import {readFileSync} from "node:fs"; import {verifyNotice} from "./scripts/wasm-notice-resource.mjs"; verifyNotice(readFileSync(process.argv[1]),readFileSync(process.env.KTAV_NATIVE_NOTICES));' "dist/wasm/$target/ktav_bg.wasm" + python3 -I scripts/check_embedded_notices.py "dist/wasm/$target/ktav_bg.wasm" "$RUNNER_TEMP/wasm-notices/NOTICE.json" > "$RUNNER_TEMP/wasm-notices/resource-$target.json" + done + cp "$RUNNER_TEMP/wasm-notices/NOTICE.json" dist/wasm/NOTICE.json + - run: npm run build:ts + - name: Verify host WASM consumer + run: npm run test:node-wasm + - name: Inspect actual packed main package + shell: bash + run: | + set -euo pipefail + npm pack --ignore-scripts --json --pack-destination "$RUNNER_TEMP" > "$RUNNER_TEMP/wasm-notices/npm-pack.json" + python3 -c 'import json,os,subprocess,sys; from pathlib import Path; e=Path(os.environ["RUNNER_TEMP"])/"wasm-notices"; p=json.loads((e/"npm-pack.json").read_text()); assert len(p)==1; name=p[0]["filename"]; assert Path(name).name==name; output=subprocess.check_output([sys.executable,"scripts/check_wasm_npm.py",str(e.parent/name),str(e),"."]); (e/"npm-verification.json").write_bytes(output)' + - uses: actions/upload-artifact@v4 + if: always() + with: + name: wasm-license-evidence + path: ${{ runner.temp }}/wasm-notices/ + if-no-files-found: warn diff --git a/ci/about.toml b/ci/about.toml new file mode 100644 index 0000000..9ef5947 --- /dev/null +++ b/ci/about.toml @@ -0,0 +1,11 @@ +accepted = [ + "MIT", + "ISC", + "BSD-2-Clause", + "BSD-3-Clause", + "Zlib", + "BSL-1.0", + "Apache-2.0 WITH LLVM-exception", + "Apache-2.0", + "Unicode-3.0", +] diff --git a/scripts/cargo_notice_bundle.py b/scripts/cargo_notice_bundle.py new file mode 100644 index 0000000..7196de5 --- /dev/null +++ b/scripts/cargo_notice_bundle.py @@ -0,0 +1,113 @@ +"""Собрать notices без локальных путей и проверить их в wheel.""" + +from __future__ import annotations + +import base64 +import csv +import hashlib +import io +import json +import sys +import zipfile +from pathlib import Path, PurePosixPath + +from collect_cargo_notices import _collect, _packages + +MEMBER = "ktav/_third_party/NOTICE.json" +MAX_BUNDLE_BYTES = 64 * 1024 * 1024 + + +def _text(data: bytes) -> dict: + return {"sha256": hashlib.sha256(data).hexdigest(), "text": data.decode("utf-8")} + + +def _package(package: dict) -> dict: + return {key: package.get(key) for key in ("name", "version", "source")} + + +def _build(evidence: Path) -> bytes: + metadata = json.loads((evidence / "metadata.json").read_text(encoding="utf-8")) + report = json.loads((evidence / "licenses.json").read_text(encoding="utf-8")) + packages = _packages(metadata, report) + identities = {package["id"]: _package(package) for package in packages} + licenses = [] + for entry in report["licenses"]: + used_by = [identities[item["crate"]["id"]] for item in entry["used_by"]] + licenses.append( + { + **_text(entry["text"].encode("utf-8")), + "used_by": sorted(used_by, key=lambda item: json.dumps(item, sort_keys=True)), + } + ) + notices = _collect(metadata, report) + for entry in notices["notices"]: + path = PurePosixPath(entry["path"]) + if path.is_absolute() or ".." in path.parts or "\\" in entry["path"]: + raise ValueError("unsafe notice path") + rustc = (evidence / "rustc.txt").read_bytes() + if not rustc.startswith(b"rustc ") or b"\ncommit-hash: " not in rustc: + raise ValueError("missing verbose rustc provenance") + stdlib = (evidence / "COPYRIGHT-library.html").read_bytes() + if not stdlib.strip(): + raise ValueError("empty Rust standard library report") + lock = (evidence / "Cargo.lock").read_bytes() + if not lock.strip(): + raise ValueError("empty Cargo.lock") + result = { + "schema_version": 1, + "coverage": "Resolved Cargo graph and Rust standard library; not a linked-code inventory. " + "Non-Cargo runtimes require separate evidence.", + "cargo_lock_sha256": hashlib.sha256(lock).hexdigest(), + "packages": sorted(identities.values(), key=lambda item: json.dumps(item, sort_keys=True)), + "licenses": sorted(licenses, key=lambda item: json.dumps(item, sort_keys=True)), + "notices": notices["notices"], + "rustc": rustc.decode("utf-8"), + "rust_standard_library": _text(stdlib), + } + data = (json.dumps(result, ensure_ascii=False, sort_keys=True, indent=2) + "\n").encode() + if len(data) > MAX_BUNDLE_BYTES: + raise ValueError("notice bundle size limit exceeded") + return data + + +def _verify(wheel_path: Path, expected: bytes) -> None: + if not expected or len(expected) > MAX_BUNDLE_BYTES: + raise ValueError("invalid expected bundle size") + with zipfile.ZipFile(wheel_path) as wheel: + members = [item for item in wheel.infolist() if item.filename == MEMBER] + if len(members) != 1 or members[0].file_size != len(expected): + raise ValueError("missing, duplicate or wrong-sized wheel notice bundle") + if wheel.read(members[0]) != expected: + raise ValueError("wheel notice bundle differs from build evidence") + records = [item for item in wheel.infolist() if item.filename.endswith(".dist-info/RECORD")] + if len(records) != 1 or records[0].filename.count("/") != 1: + raise ValueError("unexpected wheel RECORD") + rows = csv.reader(io.StringIO(wheel.read(records[0]).decode("utf-8"))) + matching = [row for row in rows if row and row[0] == MEMBER] + digest = base64.urlsafe_b64encode(hashlib.sha256(expected).digest()).rstrip(b"=").decode() + if matching != [[MEMBER, f"sha256={digest}", str(len(expected))]]: + raise ValueError("notice bundle does not match wheel RECORD") + + +def main() -> None: + """Собрать bundle или сверить точные байты упакованного файла.""" + if len(sys.argv) != 4 or sys.argv[1] not in {"build", "verify"}: + raise SystemExit( + "usage: cargo_notice_bundle.py build EVIDENCE OUTPUT | verify WHEEL BUNDLE" + ) + try: + if sys.argv[1] == "build": + data = _build(Path(sys.argv[2])) + output = Path(sys.argv[3]) + output.parent.mkdir(parents=True, exist_ok=True) + with output.open("xb") as destination: + destination.write(data) + else: + _verify(Path(sys.argv[2]), Path(sys.argv[3]).read_bytes()) + except (OSError, ValueError, KeyError, TypeError, zipfile.BadZipFile) as exc: + raise SystemExit(str(exc)) from exc + print(f"notice bundle {sys.argv[1]} verified") + + +if __name__ == "__main__": + main() diff --git a/scripts/check_embedded_notices.py b/scripts/check_embedded_notices.py new file mode 100644 index 0000000..e70868f --- /dev/null +++ b/scripts/check_embedded_notices.py @@ -0,0 +1,72 @@ +"""Проверить license resource без исполнения native binary.""" + +from __future__ import annotations + +import gzip +import hashlib +import io +import json +import sys +from pathlib import Path + +MARKER = b"KTAV-NOTICES-GZIP-v1\0" +MAX_GZIP = 4 * 1024 * 1024 +MAX_JSON = 64 * 1024 * 1024 +MAX_BINARY = 128 * 1024 * 1024 + + +def _read(path: Path, limit: int) -> bytes: + with path.open("rb") as source: + data = source.read(limit + 1) + if len(data) > limit: + raise ValueError(f"file exceeds notice verification limit: {path.name}") + return data + + +def _extract(binary: bytes) -> tuple[bytes, int]: + offset = binary.find(MARKER) + if offset < 0 or binary.find(MARKER, offset + 1) >= 0: + raise ValueError("missing or duplicate embedded notice resource") + start = offset + len(MARKER) + if start + 8 > len(binary): + raise ValueError("truncated embedded notice length") + size = int.from_bytes(binary[start : start + 8], "little") + start += 8 + if not 0 < size <= MAX_GZIP or start + size > len(binary): + raise ValueError("invalid embedded notice size") + with gzip.GzipFile(fileobj=io.BytesIO(binary[start : start + size])) as source: + data = source.read(MAX_JSON + 1) + if len(data) > MAX_JSON: + raise ValueError("embedded notice JSON exceeds size limit") + return data, size + + +def main() -> None: + """Сверить embedded resource с ожидаемым source-backed bundle.""" + if len(sys.argv) != 3: + raise SystemExit("usage: check_embedded_notices.py BINARY EXPECTED_NOTICE_JSON") + try: + binary = _read(Path(sys.argv[1]), MAX_BINARY) + expected = _read(Path(sys.argv[2]), MAX_JSON) + actual, compressed_size = _extract(binary) + if actual != expected: + raise ValueError("embedded notices differ from the locked build evidence") + bundle = json.loads(actual) + if bundle.get("schema_version") != 1: + raise ValueError("unexpected embedded notice schema") + report = { + "schema_version": 1, + "binary": Path(sys.argv[1]).name, + "binary_sha256": hashlib.sha256(binary).hexdigest(), + "notice_sha256": hashlib.sha256(actual).hexdigest(), + "cargo_lock_sha256": bundle["cargo_lock_sha256"], + "notice_bytes": len(actual), + "compressed_bytes": compressed_size, + } + except (OSError, EOFError, ValueError, KeyError, TypeError) as exc: + raise SystemExit(str(exc)) from exc + print(json.dumps(report, sort_keys=True, indent=2)) + + +if __name__ == "__main__": + main() diff --git a/scripts/check_wasm_npm.py b/scripts/check_wasm_npm.py new file mode 100644 index 0000000..3e2b3ff --- /dev/null +++ b/scripts/check_wasm_npm.py @@ -0,0 +1,50 @@ +"""Сверить actual npm tarball без исполнения его payload.""" + +import base64 +import hashlib +import json +from pathlib import Path, PurePosixPath +import re +import sys +import tarfile + +from check_embedded_notices import _extract + + +def verify(archive_path, evidence, root): + expected = (evidence / 'NOTICE.json').read_bytes() + with tarfile.open(archive_path, 'r:gz') as archive: + files = {} + for member in archive.getmembers(): + path = PurePosixPath(member.name) + if path.is_absolute() or '..' in path.parts or '\\' in member.name or member.name in files or not member.isfile() or member.size > 64 * 1024 * 1024: + raise ValueError('unsafe npm tar member') + files[member.name] = archive.extractfile(member).read() + wasm_names = {'package/dist/wasm/web/ktav_bg.wasm', 'package/dist/wasm/bundler/ktav_bg.wasm'} + if {name for name in files if name.endswith('.wasm')} != wasm_names: + raise ValueError('unexpected WASM payload inventory') + for name, data in files.items(): + if name in wasm_names: + if not data.startswith(b'\0asm') or _extract(data)[0] != expected or data != (root / name.removeprefix('package/')).read_bytes(): + raise ValueError('packed WASM differs from built bytes or notice evidence') + elif data.startswith((b'\x7fELF', b'MZ', b'\0asm', b'!\n', b'\xcf\xfa\xed\xfe', b'\xfe\xed\xfa\xcf')) or name.endswith(('.node', '.dll', '.so', '.dylib')): + raise ValueError('unexpected native payload in main npm package') + if files['package/dist/wasm/NOTICE.json'] != expected: + raise ValueError('packed notice sidecar differs') + inline = files['package/dist/wasm/web/ktav.inline.js'] + matches = re.findall(rb'const __KTAV_INLINE_WASM_BASE64 = ("[A-Za-z0-9+/=]*");', inline) + if len(matches) != 1 or base64.b64decode(json.loads(matches[0]), validate=True) != files['package/dist/wasm/web/ktav_bg.wasm']: + raise ValueError('inline WASM differs from standalone packed payload') + for name in ('LICENSE-MIT', 'LICENSE-APACHE'): + if files['package/' + name] != (root / name).read_bytes(): + raise ValueError('packed own license differs from source') + package = json.loads(files['package/package.json']) + if package['name'] != '@ktav-lang/ktav' or package['version'] != '0.8.1': + raise ValueError('unexpected npm package identity') + return {'package_sha256': hashlib.sha256(archive_path.read_bytes()).hexdigest(), 'notice_sha256': hashlib.sha256(expected).hexdigest(), 'wasm': {name: hashlib.sha256(files[name]).hexdigest() for name in sorted(wasm_names)}, 'inline_matches_web': True, 'coverage': 'Cargo/std notice prototype; non-Cargo runtime and historical packages not covered.'} + + +if __name__ == '__main__': + if len(sys.argv) != 4: + raise SystemExit('usage: check_wasm_npm.py TARBALL EVIDENCE SOURCE_ROOT') + print(json.dumps(verify(*map(Path, sys.argv[1:])), indent=2, sort_keys=True)) diff --git a/scripts/collect_cargo_notices.py b/scripts/collect_cargo_notices.py new file mode 100644 index 0000000..79da382 --- /dev/null +++ b/scripts/collect_cargo_notices.py @@ -0,0 +1,108 @@ +"""Собрать лицензионные уведомления разрешённого Cargo-графа.""" + +from __future__ import annotations + +import hashlib +import json +import re +import sys +from pathlib import Path + +NOTICE_NAME = re.compile( + r"^(?:notice|notices|copyright|copying|patents|authors|credits|acknowledg(?:e)?ments|" + r"third[-_ ]?party[-_ ]?(?:notices?|licen[cs]es?))" + r"(?:[-_].+|\.(?:txt|md|rst|html|lesser))?$", + re.IGNORECASE, +) +MAX_NOTICE_BYTES = 4 * 1024 * 1024 +MAX_TOTAL_BYTES = 32 * 1024 * 1024 + + +def _packages(metadata: dict, report: dict) -> list[dict]: + packages = metadata.get("packages") + crates = report.get("crates") + licenses = report.get("licenses") + if not isinstance(packages, list) or not packages: + raise ValueError("Cargo metadata has no packages") + if not isinstance(crates, list) or not isinstance(licenses, list) or not licenses: + raise ValueError("license report is incomplete") + package_ids = {p["id"] for p in packages} + reported_ids = {c["package"]["id"] for c in crates} + licensed_ids = {u["crate"]["id"] for lic in licenses for u in lic["used_by"]} + if ( + len(package_ids) != len(packages) + or package_ids != reported_ids + or package_ids != licensed_ids + ): + raise ValueError("Cargo graph and license report coverage differ") + if any(not lic.get("source_path") or not lic.get("text") for lic in licenses): + raise ValueError("license report contains an unverified fallback") + return sorted(packages, key=lambda p: p["id"]) + + +def _notice_files(root: Path) -> list[Path]: + if root.is_symlink() or not root.is_dir(): + raise ValueError(f"invalid package source directory: {root}") + pending = [root] + found = [] + while pending: + directory = pending.pop() + for path in sorted(directory.iterdir()): + if path.name in {".git", "target"}: + continue + if path.is_symlink(): + if NOTICE_NAME.fullmatch(path.name) or path.is_dir(): + raise ValueError(f"unverified symlink in package source: {path}") + continue + if path.is_dir(): + pending.append(path) + elif path.is_file() and NOTICE_NAME.fullmatch(path.name): + found.append(path) + return sorted(found) + + +def _collect(metadata: dict, report: dict) -> dict: + packages = _packages(metadata, report) + notices = [] + total = 0 + for package in packages: + root = Path(package["manifest_path"]).parent + for path in _notice_files(root): + size = path.stat().st_size + if size > MAX_NOTICE_BYTES or total + size > MAX_TOTAL_BYTES: + raise ValueError(f"notice size limit exceeded: {path}") + data = path.read_bytes() + if len(data) != size: + raise ValueError(f"notice changed while reading: {path}") + total += len(data) + notices.append( + { + "package": package["name"], + "version": package["version"], + "source": package.get("source"), + "path": path.relative_to(root).as_posix(), + "sha256": hashlib.sha256(data).hexdigest(), + "text": data.decode("utf-8"), + } + ) + return {"schema_version": 1, "package_count": len(packages), "notices": notices} + + +def main() -> None: + """Проверить покрытие, сохранить уведомления и хеши.""" + if len(sys.argv) != 4: + raise SystemExit("usage: collect_cargo_notices.py METADATA LICENSES OUTPUT") + try: + metadata = json.loads(Path(sys.argv[1]).read_text(encoding="utf-8")) + report = json.loads(Path(sys.argv[2]).read_text(encoding="utf-8")) + result = _collect(metadata, report) + Path(sys.argv[3]).write_text( + json.dumps(result, ensure_ascii=False, indent=2) + "\n", encoding="utf-8" + ) + except (OSError, ValueError, KeyError, TypeError) as exc: + raise SystemExit(str(exc)) from exc + print(f"Collected {len(result['notices'])} notices from {result['package_count']} packages") + + +if __name__ == "__main__": + main() diff --git a/scripts/prepare_js_notices.py b/scripts/prepare_js_notices.py new file mode 100644 index 0000000..e67a737 --- /dev/null +++ b/scripts/prepare_js_notices.py @@ -0,0 +1,64 @@ +"""Подготовить notices свежего CI lock, не выдавая его за historical graph.""" + +import gzip +import json +from pathlib import Path +import shutil +import subprocess +import sys +import tomllib + +from cargo_notice_bundle import _build + + +def prepare(evidence): + root = Path.cwd().resolve() + evidence = evidence.resolve() + if evidence.is_relative_to(root) or evidence.exists(): + raise ValueError('JS evidence must be new and outside source') + lock = root / 'Cargo.lock' + if lock.exists(): + raise ValueError('published JS source unexpectedly has Cargo.lock') + subprocess.run(['cargo', 'generate-lockfile'], check=True) + subprocess.run(['cargo', 'update', '-p', 'ktav', '--precise', '0.8.1'], check=True) + original = lock.read_bytes() + core = [item for item in tomllib.loads(original.decode())['package'] if item['name'] == 'ktav'] + if len(core) != 1 or core[0]['version'] != '0.8.1' or core[0].get('checksum') != '7140dfe2fa6c320e74768cd6a637828c2d26f81746254f4fcd805f3993bd3fd5' or core[0].get('source') != 'registry+https://github.com/rust-lang/crates.io-index': + raise ValueError('unexpected JS registry core source') + raw = subprocess.check_output(['cargo', 'metadata', '--locked', '--all-features', '--format-version', '1']) + metadata = json.loads(raw) + own = [item for item in metadata['packages'] if item.get('source') is None] + if {item['name'] for item in own} != {'ktav-cabi', 'ktav-napi', 'ktav-wasm'}: + raise ValueError('unexpected JS workspace packages') + for package in own: + package_root = Path(package['manifest_path']).resolve().parent + if not package_root.is_relative_to(root) or package.get('license') != 'MIT OR Apache-2.0': + raise ValueError('unexpected own JS source license') + for name in ('LICENSE-MIT', 'LICENSE-APACHE'): + source, target = root / name, package_root / name + if target.is_symlink() or (target.exists() and target.read_bytes() != source.read_bytes()): + raise ValueError('own JS crate license differs') + if not target.exists(): + shutil.copyfile(source, target) + evidence.mkdir() + (evidence / 'metadata.json').write_bytes(raw) + (evidence / 'Cargo.lock').write_bytes(original) + (evidence / 'rustc.txt').write_bytes(subprocess.check_output(['rustc', '--version', '--verbose'])) + sysroot = subprocess.check_output(['rustc', '--print', 'sysroot'], text=True).strip() + shutil.copyfile(Path(sysroot) / 'share/doc/rust/COPYRIGHT-library.html', evidence / 'COPYRIGHT-library.html') + report = subprocess.check_output(['cargo', 'about', 'generate', '--locked', '--all-features', '--fail', '--config', 'ci/about.toml', '--format', 'json']) + (evidence / 'licenses.json').write_bytes(report) + bundle = json.loads(_build(evidence)) + bundle['resolution_origin'] = 'Fresh CI resolution for published JS source 0.8.1; not historical published dependency evidence.' + data = (json.dumps(bundle, ensure_ascii=False, sort_keys=True, indent=2) + '\n').encode() + payload = gzip.compress(data, mtime=0) + if len(data) > 64 * 1024 * 1024 or len(payload) > 4 * 1024 * 1024 or lock.read_bytes() != original: + raise ValueError('JS notice bounds exceeded or lock changed') + (evidence / 'NOTICE.json').write_bytes(data) + (evidence / 'NOTICE.json.gz').write_bytes(payload) + + +if __name__ == '__main__': + if len(sys.argv) != 2: + raise SystemExit('usage: prepare_js_notices.py NEW_EVIDENCE_DIRECTORY') + prepare(Path(sys.argv[1])) diff --git a/scripts/wasm-notice-resource.mjs b/scripts/wasm-notice-resource.mjs new file mode 100644 index 0000000..4adbd6d --- /dev/null +++ b/scripts/wasm-notice-resource.mjs @@ -0,0 +1,79 @@ +import { readFileSync, writeFileSync } from "node:fs"; +import { gunzipSync } from "node:zlib"; + +const MAGIC = Buffer.from("KTAV-NOTICES-GZIP-v1\0"); +const SECTION = "ktav.third-party-notices.v1"; +const MAX_WASM = 64 * 1024 * 1024; +const MAX_GZIP = 4 * 1024 * 1024; + +function readLength(bytes, cursor) { + let value = 0; + for (let index = 0; index < 5; index++) { + if (cursor.offset >= bytes.length) throw new Error("truncated WASM length"); + const byte = bytes[cursor.offset++]; + if (index === 4 && byte > 15) throw new Error("WASM length overflow"); + value += (byte & 127) * 2 ** (index * 7); + if ((byte & 128) === 0) return value; + } + throw new Error("invalid WASM length"); +} + +function lengthBytes(value) { + const result = []; + do { + const byte = value % 128; + value = Math.floor(value / 128); + result.push(byte | (value === 0 ? 0 : 128)); + } while (value !== 0); + return Buffer.from(result); +} + +function sections(bytes) { + if (bytes.length > MAX_WASM || !WebAssembly.validate(bytes)) throw new Error("invalid bounded WASM module"); + const found = []; + const cursor = { offset: 8 }; + while (cursor.offset < bytes.length) { + const kind = bytes[cursor.offset++]; + const size = readLength(bytes, cursor); + const end = cursor.offset + size; + if (end > bytes.length) throw new Error("truncated WASM section"); + if (kind === 0) { + const nameLength = readLength(bytes, cursor); + const nameEnd = cursor.offset + nameLength; + if (nameEnd > end) throw new Error("truncated WASM custom name"); + if (bytes.subarray(cursor.offset, nameEnd).equals(Buffer.from(SECTION))) found.push(bytes.subarray(nameEnd, end)); + } + cursor.offset = end; + } + return found; +} + +function resource(payload) { + if (payload.length > MAX_GZIP || payload.length < 2 || payload[0] !== 31 || payload[1] !== 139) throw new Error("invalid bounded notice gzip"); + const decoded = gunzipSync(payload, { maxOutputLength: MAX_WASM }); + const notice = JSON.parse(decoded.toString("utf8")); + if (notice.schema_version !== 1 || !Array.isArray(notice.packages) || !notice.packages.length) throw new Error("incomplete notice JSON"); + const size = Buffer.alloc(8); + size.writeBigUInt64LE(BigInt(payload.length)); + return Buffer.concat([MAGIC, size, payload]); +} + +export function addNotice(bytes, payload) { + bytes = Buffer.from(bytes); + if (sections(bytes).length !== 0) throw new Error("WASM notice section already exists"); + const name = Buffer.from(SECTION); + const body = Buffer.concat([lengthBytes(name.length), name, resource(payload)]); + const result = Buffer.concat([bytes, Buffer.from([0]), lengthBytes(body.length), body]); + verifyNotice(result, payload); + return result; +} + +export function verifyNotice(bytes, payload) { + const found = sections(Buffer.from(bytes)); + if (found.length !== 1 || !found[0].equals(resource(payload))) throw new Error("WASM notice section differs from evidence"); +} + +export function addNoticeFile(path, payloadPath) { + const result = addNotice(readFileSync(path), readFileSync(payloadPath)); + writeFileSync(path, result); +} diff --git a/tests/test_wasm_npm.py b/tests/test_wasm_npm.py new file mode 100644 index 0000000..8fad494 --- /dev/null +++ b/tests/test_wasm_npm.py @@ -0,0 +1,94 @@ +"""Проверить actual tarball guard на подмене notice и WASM payload.""" + +import base64 +import gzip +import importlib.util +import io +import json +from pathlib import Path +import sys +import tarfile +import tempfile +import unittest + +SCRIPTS = Path(__file__).resolve().parents[1] / 'scripts' +for name in ('check_embedded_notices', 'check_wasm_npm'): + spec = importlib.util.spec_from_file_location(name, SCRIPTS / (name + '.py')) + module = importlib.util.module_from_spec(spec) + sys.modules[name] = module + spec.loader.exec_module(module) +CHECK = sys.modules['check_wasm_npm'] + + +class PackageTests(unittest.TestCase): + def setUp(self): + self.temp = tempfile.TemporaryDirectory() + self.addCleanup(self.temp.cleanup) + self.root = Path(self.temp.name) + self.evidence = self.root / 'evidence' + self.evidence.mkdir() + self.notice = b'{"schema_version":1,"packages":[{"name":"fixture"}]}' + (self.evidence / 'NOTICE.json').write_bytes(self.notice) + payload = gzip.compress(self.notice, mtime=0) + self.wasm = b'\0asm' + b'KTAV-NOTICES-GZIP-v1\0' + len(payload).to_bytes(8, 'little') + payload + self.files = {'package/package.json': b'{"name":"@ktav-lang/ktav","version":"0.8.1"}', 'package/dist/wasm/NOTICE.json': self.notice} + for target in ('web', 'bundler'): + path = 'dist/wasm/' + target + '/ktav_bg.wasm' + (self.root / path).parent.mkdir(parents=True, exist_ok=True) + (self.root / path).write_bytes(self.wasm) + self.files['package/' + path] = self.wasm + self.files['package/dist/wasm/web/ktav.inline.js'] = b'const __KTAV_INLINE_WASM_BASE64 = ' + json.dumps(base64.b64encode(self.wasm).decode()).encode() + b';' + for name in ('LICENSE-MIT', 'LICENSE-APACHE'): + (self.root / name).write_text(name) + self.files['package/' + name] = name.encode() + + def verify(self): + path = self.root / 'package.tgz' + with tarfile.open(path, 'w:gz') as archive: + for name, data in self.files.items(): + member = tarfile.TarInfo(name) + member.size = len(data) + archive.addfile(member, io.BytesIO(data)) + return CHECK.verify(path, self.evidence, self.root) + + def test_matching_container(self): + self.assertTrue(self.verify()['inline_matches_web']) + + def test_changed_sidecar_rejected(self): + self.files['package/dist/wasm/NOTICE.json'] = b'{}' + with self.assertRaisesRegex(ValueError, 'sidecar'): + self.verify() + + def test_foreign_wasm_with_same_notice_rejected(self): + self.files['package/dist/wasm/bundler/ktav_bg.wasm'] += b'changed' + with self.assertRaisesRegex(ValueError, 'built bytes'): + self.verify() + + def test_changed_inline_rejected(self): + self.files['package/dist/wasm/web/ktav.inline.js'] = b'const __KTAV_INLINE_WASM_BASE64 = "AA==";' + with self.assertRaisesRegex(ValueError, 'inline WASM'): + self.verify() + + def test_hidden_native_rejected(self): + self.files['package/hidden.bin'] = b'\x7fELF' + with self.assertRaisesRegex(ValueError, 'native payload'): + self.verify() + + def test_unexpected_wasm_rejected(self): + self.files['package/other.wasm'] = self.wasm + with self.assertRaisesRegex(ValueError, 'inventory'): + self.verify() + + def test_changed_own_license_rejected(self): + self.files['package/LICENSE-MIT'] = b'changed' + with self.assertRaisesRegex(ValueError, 'own license'): + self.verify() + + def test_traversal_rejected(self): + self.files['package/../escape'] = b'data' + with self.assertRaisesRegex(ValueError, 'unsafe'): + self.verify() + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/wasm-notice-resource.test.mjs b/tests/wasm-notice-resource.test.mjs new file mode 100644 index 0000000..247d067 --- /dev/null +++ b/tests/wasm-notice-resource.test.mjs @@ -0,0 +1,56 @@ +import assert from "node:assert/strict"; +import { test } from "node:test"; +import { gzipSync } from "node:zlib"; +import { addNotice, verifyNotice } from "../scripts/wasm-notice-resource.mjs"; + +const moduleBytes = Buffer.from([0, 97, 115, 109, 1, 0, 0, 0]); +const payload = gzipSync(JSON.stringify({ schema_version: 1, packages: [{ name: "fixture", version: "1" }] })); + +test("retains exact payload in a valid non-executed WASM module", () => { + const result = addNotice(moduleBytes, payload); + assert.ok(WebAssembly.validate(result)); + assert.ok(result.subarray(0, moduleBytes.length).equals(moduleBytes)); + verifyNotice(result, payload); + assert.ok(moduleBytes.equals(Buffer.from([0, 97, 115, 109, 1, 0, 0, 0]))); +}); + +test("rejects a duplicate notice section", () => { + assert.throws(() => addNotice(addNotice(moduleBytes, payload), payload), /already exists/); +}); + +test("rejects missing notice section", () => { + assert.throws(() => verifyNotice(moduleBytes, payload), /differs/); +}); + +test("rejects changed expected compressed bytes", () => { + const other = gzipSync(JSON.stringify({ schema_version: 1, packages: [{ name: "other" }] })); + assert.throws(() => verifyNotice(addNotice(moduleBytes, payload), other), /differs/); +}); + +test("rejects truncated module", () => { + const result = addNotice(moduleBytes, payload); + assert.throws(() => verifyNotice(result.subarray(0, result.length - 1), payload), /invalid bounded WASM/); +}); + +test("rejects non-WASM data", () => { + assert.throws(() => addNotice(Buffer.from("not wasm"), payload), /invalid bounded WASM/); +}); + +test("rejects invalid gzip", () => { + assert.throws(() => addNotice(moduleBytes, Buffer.from("not gzip")), /notice gzip/); +}); + +test("rejects non-JSON payload", () => { + assert.throws(() => addNotice(moduleBytes, gzipSync("not JSON"))); +}); + +test("rejects incomplete notice JSON", () => { + assert.throws(() => addNotice(moduleBytes, gzipSync('{"schema_version":1,"packages":[]}')), /incomplete/); +}); + +test("preserves unrelated custom sections", () => { + const withOther = Buffer.concat([moduleBytes, Buffer.from([0, 3, 1, 120, 42])]); + const result = addNotice(withOther, payload); + assert.ok(result.subarray(0, withOther.length).equals(withOther)); + verifyNotice(result, payload); +}); From 58ae382404c0e8157188e7025d8bf4063e4aba39 Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Fri, 30 Oct 2026 01:58:49 +0100 Subject: [PATCH 11/51] ci: retain exact NAPI upstream license notices Replace six generated MIT fallbacks with reviewed source terms, bound to locked package checksums and original VCS revisions. Preserve both NAPI MIT copyright blocks and Microsoft's original text without alteration. Keep original cargo-about bytes and embed explicit supplement provenance. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/wasm-notice-check.yml | 3 +- ci/licenses/js-source-supplements.json | 113 ++++++++++++++++++++++++ ci/test_js_source_supplements.py | 73 +++++++++++++++ scripts/prepare_js_notices.py | 8 +- scripts/source_license_supplements.py | 50 +++++++++++ 5 files changed, 245 insertions(+), 2 deletions(-) create mode 100644 ci/licenses/js-source-supplements.json create mode 100644 ci/test_js_source_supplements.py create mode 100644 scripts/source_license_supplements.py diff --git a/.github/workflows/wasm-notice-check.yml b/.github/workflows/wasm-notice-check.yml index f2bb36d..ae4f4dd 100644 --- a/.github/workflows/wasm-notice-check.yml +++ b/.github/workflows/wasm-notice-check.yml @@ -23,7 +23,7 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'wasm-notice-tools' stage.mkdir() - for name in ['scripts/wasm-notice-resource.mjs', 'tests/wasm-notice-resource.test.mjs', 'tests/test_wasm_npm.py', 'scripts/prepare_js_notices.py', 'scripts/check_wasm_npm.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/check_embedded_notices.py', 'ci/about.toml']: + for name in ['scripts/wasm-notice-resource.mjs', 'tests/wasm-notice-resource.test.mjs', 'tests/test_wasm_npm.py', 'scripts/prepare_js_notices.py', 'scripts/check_wasm_npm.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/check_embedded_notices.py', 'ci/about.toml', 'scripts/source_license_supplements.py', 'ci/test_js_source_supplements.py', 'ci/licenses/js-source-supplements.json']: target = stage / name target.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(name, target) @@ -74,6 +74,7 @@ jobs: run: | node --test tests/wasm-notice-resource.test.mjs python3 -I -m unittest discover -s tests -p test_wasm_npm.py -v + python3 -I -m unittest discover -s ci -p test_js_source_supplements.py -v - name: Prepare source-backed locked notices shell: bash run: | diff --git a/ci/licenses/js-source-supplements.json b/ci/licenses/js-source-supplements.json new file mode 100644 index 0000000..b1a8859 --- /dev/null +++ b/ci/licenses/js-source-supplements.json @@ -0,0 +1,113 @@ +{ + "packages": [ + { + "crate_checksum": "6a746ad50efbfb632ade1de4025519a477decbbd798cea1a6ac41d7c44f80083", + "crate_license_path": null, + "declared_license": "MIT", + "license": "MIT", + "license_sha256": "3f1ce66533302df3a32edbfdfc0b78f0dd34659e4c1f5817162e5ea3c2297215", + "license_source": "https://raw.githubusercontent.com/napi-rs/napi-rs/d9cb526c15e63ba30e06b4d169068c9854180595/LICENSE", + "license_text": "MIT License\n\nCopyright (c) 2020-present LongYinan\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\nMIT License\n\nCopyright (c) 2018 GitHub\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n", + "name": "napi", + "reason": "Original exact source terms replace generated cargo-about fallback; original tool report retained.", + "vcs": { + "git": { + "sha1": "d9cb526c15e63ba30e06b4d169068c9854180595" + }, + "path_in_vcs": "crates/napi" + }, + "version": "3.15.0" + }, + { + "crate_checksum": "b899b545d3aa6dca985939059f258c5488d34e4ecf39c274e20009748f4b846d", + "crate_license_path": null, + "declared_license": "MIT", + "license": "MIT", + "license_sha256": "3f1ce66533302df3a32edbfdfc0b78f0dd34659e4c1f5817162e5ea3c2297215", + "license_source": "https://raw.githubusercontent.com/napi-rs/napi-rs/a94cef33f62e74682963dd085e283f52dcec2600/LICENSE", + "license_text": "MIT License\n\nCopyright (c) 2020-present LongYinan\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\nMIT License\n\nCopyright (c) 2018 GitHub\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n", + "name": "napi-build", + "reason": "Original exact source terms replace generated cargo-about fallback; original tool report retained.", + "vcs": { + "git": { + "sha1": "a94cef33f62e74682963dd085e283f52dcec2600" + }, + "path_in_vcs": "crates/build" + }, + "version": "2.6.0" + }, + { + "crate_checksum": "3ff48271a0f61abb83f3e2d1989fa71169143db95f6f948c3a8903961f2855dc", + "crate_license_path": null, + "declared_license": "MIT", + "license": "MIT", + "license_sha256": "3f1ce66533302df3a32edbfdfc0b78f0dd34659e4c1f5817162e5ea3c2297215", + "license_source": "https://raw.githubusercontent.com/napi-rs/napi-rs/d9cb526c15e63ba30e06b4d169068c9854180595/LICENSE", + "license_text": "MIT License\n\nCopyright (c) 2020-present LongYinan\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\nMIT License\n\nCopyright (c) 2018 GitHub\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n", + "name": "napi-derive", + "reason": "Original exact source terms replace generated cargo-about fallback; original tool report retained.", + "vcs": { + "git": { + "sha1": "d9cb526c15e63ba30e06b4d169068c9854180595" + }, + "path_in_vcs": "crates/macro" + }, + "version": "3.6.13" + }, + { + "crate_checksum": "f2639052c5aff9956a21d7b6202fc61d5e89c5f19c72d289b7a0641ea94e8159", + "crate_license_path": null, + "declared_license": "MIT", + "license": "MIT", + "license_sha256": "3f1ce66533302df3a32edbfdfc0b78f0dd34659e4c1f5817162e5ea3c2297215", + "license_source": "https://raw.githubusercontent.com/napi-rs/napi-rs/d9cb526c15e63ba30e06b4d169068c9854180595/LICENSE", + "license_text": "MIT License\n\nCopyright (c) 2020-present LongYinan\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\nMIT License\n\nCopyright (c) 2018 GitHub\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n", + "name": "napi-derive-backend", + "reason": "Original exact source terms replace generated cargo-about fallback; original tool report retained.", + "vcs": { + "git": { + "sha1": "d9cb526c15e63ba30e06b4d169068c9854180595" + }, + "path_in_vcs": "crates/backend" + }, + "version": "6.1.6" + }, + { + "crate_checksum": "d153beb7d5c973f4b9395be8a83054a28968b61188f1dd1a2cc2321af22daea2", + "crate_license_path": null, + "declared_license": "MIT", + "license": "MIT", + "license_sha256": "3f1ce66533302df3a32edbfdfc0b78f0dd34659e4c1f5817162e5ea3c2297215", + "license_source": "https://raw.githubusercontent.com/napi-rs/napi-rs/d9cb526c15e63ba30e06b4d169068c9854180595/LICENSE", + "license_text": "MIT License\n\nCopyright (c) 2020-present LongYinan\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\nMIT License\n\nCopyright (c) 2018 GitHub\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n", + "name": "napi-sys", + "reason": "Original exact source terms replace generated cargo-about fallback; original tool report retained.", + "vcs": { + "git": { + "sha1": "d9cb526c15e63ba30e06b4d169068c9854180595" + }, + "path_in_vcs": "crates/sys" + }, + "version": "3.4.1" + }, + { + "crate_checksum": "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5", + "crate_license_path": "license-mit", + "declared_license": "MIT OR Apache-2.0", + "license": "MIT", + "license_sha256": "c2cfccb812fe482101a8f04597dfc5a9991a6b2748266c47ac91b6a5aae15383", + "license_source": "https://static.crates.io/crates/windows-link/windows-link-0.2.1.crate", + "license_text": " MIT License\n\n Copyright (c) Microsoft Corporation.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE\n", + "name": "windows-link", + "reason": "Original exact source terms replace generated cargo-about fallback; original tool report retained.", + "vcs": { + "git": { + "sha1": "d468916ac27a36fb8a12bafc1bf5c0ec2fe92238" + }, + "path_in_vcs": "crates/libs/link" + }, + "version": "0.2.1" + } + ], + "schema_version": 1 +} \ No newline at end of file diff --git a/ci/test_js_source_supplements.py b/ci/test_js_source_supplements.py new file mode 100644 index 0000000..d7752b4 --- /dev/null +++ b/ci/test_js_source_supplements.py @@ -0,0 +1,73 @@ +import copy +import importlib.util +import json +from pathlib import Path +import tempfile +import unittest + +SPEC = importlib.util.spec_from_file_location('supplement', Path(__file__).resolve().parents[1] / 'scripts/source_license_supplements.py') +SUPPLEMENT = importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(SUPPLEMENT) + + +class FallbackTests(unittest.TestCase): + def setUp(self): + self.temp = tempfile.TemporaryDirectory() + self.addCleanup(self.temp.cleanup) + self.root = Path(self.temp.name) + self.catalog_path = self.root / 'catalog.json' + catalog = json.loads((Path(__file__).resolve().parent / 'licenses/js-source-supplements.json').read_text()) + self.review = next(item for item in catalog['packages'] if item['name'] == 'windows-link') + self.catalog = {'packages': [self.review]} + (self.root / '.cargo_vcs_info.json').write_text(json.dumps(self.review['vcs'])) + (self.root / 'license-mit').write_bytes(self.review['license_text'].encode()) + self.package = {'id': 'windows-link', 'name': 'windows-link', 'version': self.review['version'], 'license': self.review['declared_license'], 'source': 'registry+https://github.com/rust-lang/crates.io-index', 'manifest_path': str(self.root / 'Cargo.toml')} + self.metadata = {'packages': [self.package]} + self.report = {'licenses': [{'id': 'MIT', 'source_path': None, 'text': 'generated fallback', 'used_by': [{'crate': self.package}]}]} + self.lock = ('[[package]]\nname="windows-link"\nversion="' + self.review['version'] + '"\nchecksum="' + self.review['crate_checksum'] + '"\n').encode() + + def apply(self): + self.catalog_path.write_text(json.dumps(self.catalog)) + return SUPPLEMENT.supplement_fallbacks(self.metadata, self.report, self.lock, self.catalog_path) + + def test_original_report_preserved_and_real_source_used(self): + before = copy.deepcopy(self.report) + result, provenance = self.apply() + self.assertEqual(self.report, before) + self.assertEqual(result['licenses'][0]['text'], self.review['license_text']) + self.assertEqual(provenance[0]['crate_checksum'], self.review['crate_checksum']) + self.assertNotIn('license_text', provenance[0]) + + def test_unknown_package_rejected(self): + self.package['version'] = '999' + with self.assertRaisesRegex(ValueError, 'identity'): + self.apply() + + def test_wrong_checksum_rejected(self): + self.lock = self.lock.replace(self.review['crate_checksum'].encode(), b'0' * 64) + with self.assertRaisesRegex(ValueError, 'checksum'): + self.apply() + + def test_wrong_vcs_rejected(self): + (self.root / '.cargo_vcs_info.json').write_text('{}') + with self.assertRaisesRegex(ValueError, 'VCS'): + self.apply() + + def test_changed_published_license_rejected(self): + (self.root / 'license-mit').write_text('changed') + with self.assertRaisesRegex(ValueError, 'differs'): + self.apply() + + def test_changed_catalog_text_rejected(self): + self.review['license_text'] = 'MIT' + with self.assertRaisesRegex(ValueError, 'license changed'): + self.apply() + + def test_non_mit_fallback_rejected(self): + self.report['licenses'][0]['id'] = 'Apache-2.0' + with self.assertRaisesRegex(ValueError, 'unreviewed license'): + self.apply() + + +if __name__ == '__main__': + unittest.main() diff --git a/scripts/prepare_js_notices.py b/scripts/prepare_js_notices.py index e67a737..1077c33 100644 --- a/scripts/prepare_js_notices.py +++ b/scripts/prepare_js_notices.py @@ -9,6 +9,7 @@ import tomllib from cargo_notice_bundle import _build +from source_license_supplements import supplement_fallbacks def prepare(evidence): @@ -47,8 +48,13 @@ def prepare(evidence): sysroot = subprocess.check_output(['rustc', '--print', 'sysroot'], text=True).strip() shutil.copyfile(Path(sysroot) / 'share/doc/rust/COPYRIGHT-library.html', evidence / 'COPYRIGHT-library.html') report = subprocess.check_output(['cargo', 'about', 'generate', '--locked', '--all-features', '--fail', '--config', 'ci/about.toml', '--format', 'json']) - (evidence / 'licenses.json').write_bytes(report) + (evidence / 'licenses-cargo-about.json').write_bytes(report) + combined, provenance = supplement_fallbacks(metadata, json.loads(report), original, + root / 'ci/licenses/js-source-supplements.json') + combined['source_license_supplements'] = provenance + (evidence / 'licenses.json').write_text(json.dumps(combined, ensure_ascii=False, indent=2) + '\n', encoding='utf-8') bundle = json.loads(_build(evidence)) + bundle['source_license_supplements'] = provenance bundle['resolution_origin'] = 'Fresh CI resolution for published JS source 0.8.1; not historical published dependency evidence.' data = (json.dumps(bundle, ensure_ascii=False, sort_keys=True, indent=2) + '\n').encode() payload = gzip.compress(data, mtime=0) diff --git a/scripts/source_license_supplements.py b/scripts/source_license_supplements.py new file mode 100644 index 0000000..cdfc75f --- /dev/null +++ b/scripts/source_license_supplements.py @@ -0,0 +1,50 @@ +"""Проверить explicit source-backed license supplements.""" + +import copy +import hashlib +import json +from pathlib import Path +import tomllib + + +def supplement_fallbacks(metadata, report, lock_bytes, catalog_path): + catalog = json.loads(catalog_path.read_text(encoding='utf-8')) + reviewed = {item['name']: item for item in catalog['packages']} + if len(reviewed) != len(catalog['packages']): + raise ValueError('duplicate source supplement review') + packages = {item['id']: item for item in metadata['packages']} + locks = tomllib.loads(lock_bytes.decode('utf-8'))['package'] + combined = copy.deepcopy(report) + verified = [] + licenses = [] + for entry in combined['licenses']: + if entry.get('source_path'): + licenses.append(entry) + continue + if entry.get('id') != 'MIT' or not entry.get('used_by'): + raise ValueError('unreviewed license fallback') + for use in entry['used_by']: + package = packages[use['crate']['id']] + review = reviewed.get(package['name']) + if review is None or package['version'] != review['version'] or package.get('license') != review['declared_license'] or package.get('source') != 'registry+https://github.com/rust-lang/crates.io-index': + raise ValueError('unreviewed fallback package identity') + locked = [item for item in locks if item['name'] == review['name'] and item['version'] == review['version']] + if len(locked) != 1 or locked[0].get('checksum') != review['crate_checksum']: + raise ValueError('fallback source checksum changed') + root = Path(package['manifest_path']).parent + vcs = json.loads((root / '.cargo_vcs_info.json').read_text(encoding='utf-8')) + if vcs != review['vcs']: + raise ValueError('fallback source VCS changed') + text = review['license_text'] + if hashlib.sha256(text.encode('utf-8')).hexdigest() != review['license_sha256']: + raise ValueError('fallback source license changed') + if review.get('crate_license_path'): + source = root / review['crate_license_path'] + if source.is_symlink() or not source.resolve().is_relative_to(root.resolve()) or source.read_bytes() != text.encode('utf-8'): + raise ValueError('published fallback license differs from review') + licenses.append({'name': 'MIT', 'id': 'MIT', 'first_of_kind': False, 'text': text, + 'source_path': str(catalog_path), 'used_by': [use], + 'origin': 'reviewed-source-supplement'}) + verified.append({key: value for key, value in review.items() if key != 'license_text'}) + combined['licenses'] = licenses + return combined, verified From 701369b1b2d57f7998cbfdbb8bc3282db0ad6dbe Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Fri, 30 Oct 2026 02:08:12 +0100 Subject: [PATCH 12/51] ci: preserve original npm release resolution evidence Use the published source's npm install path without lifecycle scripts instead of npm ci on its inconsistent platform-package lock entries. Retain original and resolved locks, reject manifest changes and validate the resolved graph with the existing npm license policy. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/wasm-notice-check.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wasm-notice-check.yml b/.github/workflows/wasm-notice-check.yml index ae4f4dd..b65f31a 100644 --- a/.github/workflows/wasm-notice-check.yml +++ b/.github/workflows/wasm-notice-check.yml @@ -23,7 +23,7 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'wasm-notice-tools' stage.mkdir() - for name in ['scripts/wasm-notice-resource.mjs', 'tests/wasm-notice-resource.test.mjs', 'tests/test_wasm_npm.py', 'scripts/prepare_js_notices.py', 'scripts/check_wasm_npm.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/check_embedded_notices.py', 'ci/about.toml', 'scripts/source_license_supplements.py', 'ci/test_js_source_supplements.py', 'ci/licenses/js-source-supplements.json']: + for name in ['scripts/wasm-notice-resource.mjs', 'tests/wasm-notice-resource.test.mjs', 'tests/test_wasm_npm.py', 'scripts/prepare_js_notices.py', 'scripts/check_wasm_npm.py', 'scripts/check-npm-licenses.mjs', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/check_embedded_notices.py', 'ci/about.toml', 'scripts/source_license_supplements.py', 'ci/test_js_source_supplements.py', 'ci/licenses/js-source-supplements.json']: target = stage / name target.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(name, target) @@ -83,7 +83,15 @@ jobs: cp "$RUNNER_TEMP/wasm-source-provenance.json" "$RUNNER_TEMP/wasm-notices/source-provenance.json" printf 'KTAV_NATIVE_NOTICES=%s\n' "$RUNNER_TEMP/wasm-notices/NOTICE.json.gz" >> "$GITHUB_ENV" wasm-pack --version > "$RUNNER_TEMP/wasm-notices/wasm-pack-version.txt" - - run: npm ci --ignore-scripts + - name: Resolve original npm release graph without lifecycle scripts + shell: bash + run: | + set -euo pipefail + cp package-lock.json "$RUNNER_TEMP/wasm-notices/npm-lock-source.json" + npm install --ignore-scripts --no-audit --no-fund + git diff --exit-code -- package.json + cp package-lock.json "$RUNNER_TEMP/wasm-notices/npm-lock-resolved.json" + node scripts/check-npm-licenses.mjs - name: Build final WASM before inline generation env: CARGO_NET_OFFLINE: 'true' From beabea159e1fedf906604c8ee9c8a814bfd7f2ca Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Fri, 30 Oct 2026 02:18:13 +0100 Subject: [PATCH 13/51] ci: preserve WASM build script hashbang in overlay Insert the notice helper import after the original interpreter line instead of making the hashbang an invalid second-line token. Check the overlaid script syntax before tool installation and builds. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/wasm-notice-check.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/wasm-notice-check.yml b/.github/workflows/wasm-notice-check.yml index b65f31a..3e403eb 100644 --- a/.github/workflows/wasm-notice-check.yml +++ b/.github/workflows/wasm-notice-check.yml @@ -55,7 +55,10 @@ jobs: if original.count(anchor) != 1: raise SystemExit('WASM inline boundary changed') hook = b'for (const subdir of ["web", "bundler"]) addNoticeFile(resolve(outRoot, subdir, "ktav_bg.wasm"), process.env.KTAV_NATIVE_NOTICES);' - packaged = b'import { addNoticeFile } from "./wasm-notice-resource.mjs";' + bytes([10]) + original.replace(anchor, hook + bytes([10, 10]) + anchor) + shebang, body = original.split(bytes([10]), 1) + if shebang != b'#!/usr/bin/env node': + raise SystemExit('WASM build script interpreter changed') + packaged = shebang + bytes([10]) + b'import { addNoticeFile } from "./wasm-notice-resource.mjs";' + bytes([10]) + body.replace(anchor, hook + bytes([10, 10]) + anchor) script.write_bytes(packaged) record = {'source_ref': os.environ['SOURCE_REF'], 'tooling_ref': os.environ['GITHUB_SHA'], 'original_build_script_sha256': hashlib.sha256(original).hexdigest(), 'packaged_build_script_sha256': hashlib.sha256(packaged).hexdigest(), 'coverage': 'Audit-only Cargo/std prototype, not historical npm or non-Cargo runtime compliance.'} (Path(os.environ['RUNNER_TEMP']) / 'wasm-source-provenance.json').write_text(json.dumps(record, sort_keys=True, indent=2)) @@ -63,6 +66,8 @@ jobs: - uses: actions/setup-node@v4 with: node-version: '24' + - name: Verify notice-only build overlay syntax + run: node --check scripts/build-wasm.mjs - uses: dtolnay/rust-toolchain@1.99.1 with: targets: wasm32-unknown-unknown From 334c354cbd563d65c0f953945f269c3570e75fea Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Fri, 30 Oct 2026 03:36:17 +0100 Subject: [PATCH 14/51] ci: capture exact GNU NAPI runtime link inputs Keep published-source NAPI build code and GNU cross toolchain unchanged. Capture the actual shared-library link with transparent compiler forwarding and bind the final addon bytes to the map, compiler and SDK notices. Verify the matching-CPU consumer loads the newly built addon, not an installed optional package. Do not equate SDK package MIT metadata with a licensing conclusion for GNU runtime code. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/napi-notice-check.yml | 130 ++++++++++++++++++++++++ ci/test_napi_cross_link.py | 64 ++++++++++++ scripts/capture_napi_cross_link.py | 45 ++++++++ scripts/collect_napi_link_evidence.py | 84 +++++++++++++++ 4 files changed, 323 insertions(+) create mode 100644 .github/workflows/napi-notice-check.yml create mode 100644 ci/test_napi_cross_link.py create mode 100644 scripts/capture_napi_cross_link.py create mode 100644 scripts/collect_napi_link_evidence.py diff --git a/.github/workflows/napi-notice-check.yml b/.github/workflows/napi-notice-check.yml new file mode 100644 index 0000000..241d032 --- /dev/null +++ b/.github/workflows/napi-notice-check.yml @@ -0,0 +1,130 @@ +name: NAPI GNU runtime evidence + +on: + pull_request: + +permissions: + contents: read + +env: + SOURCE_REF: 562deb3fde092d63a78f359be095e5079929d0d1 + +jobs: + napi-link-inputs: + name: NAPI GNU inputs / ${{ matrix.target }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - target: x86_64-unknown-linux-gnu + addon: ktav.linux-x64-gnu.node + - target: aarch64-unknown-linux-gnu + addon: ktav.linux-arm64-gnu.node + steps: + - uses: actions/checkout@v4 + - name: Preserve source-backed audit tools + shell: python + run: | + import os + import shutil + from pathlib import Path + stage = Path(os.environ['RUNNER_TEMP']) / 'napi-notice-tools' + stage.mkdir() + for name in ['scripts/capture_napi_cross_link.py', 'scripts/collect_napi_link_evidence.py', 'ci/test_napi_cross_link.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json']: + target = stage / name + target.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(name, target) + - uses: actions/checkout@v4 + with: + ref: ${{ env.SOURCE_REF }} + submodules: recursive + persist-credentials: false + - name: Restore audit tools without modifying NAPI source or build hook + shell: python + run: | + import hashlib + import json + import os + import shutil + import subprocess + from pathlib import Path + if subprocess.check_output(['git', 'rev-parse', 'HEAD'], text=True).strip() != os.environ['SOURCE_REF']: + raise SystemExit('unexpected NAPI source revision') + stage = Path(os.environ['RUNNER_TEMP']) / 'napi-notice-tools' + for path in stage.rglob('*'): + if path.is_file(): + target = Path(path.relative_to(stage)) + target.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(path, target) + subprocess.run(['git', 'diff', '--exit-code', '--', 'Cargo.toml', 'crates', 'tests/node', 'root-docs', 'package.json', 'package-lock.json'], check=True) + record = {'source_ref': os.environ['SOURCE_REF'], 'tooling_ref': os.environ['GITHUB_SHA'], 'napi_build_rs_sha256': hashlib.sha256(Path('crates/napi/build.rs').read_bytes()).hexdigest(), 'coverage': 'Audit-only GNU linker provenance, not completed non-Cargo runtime licensing or historical package evidence.'} + (Path(os.environ['RUNNER_TEMP']) / 'napi-source-provenance.json').write_text(json.dumps(record, sort_keys=True, indent=2)) + - uses: actions/setup-node@v4 + with: + node-version: '24' + - uses: dtolnay/rust-toolchain@1.99.1 + with: + targets: ${{ matrix.target }} + components: rust-docs + - uses: taiki-e/install-action@v2 + with: + tool: cargo-about@0.9.3 + - name: Verify transparent linker capture guards + run: python3 -I -m unittest discover -s ci -p test_napi_cross_link.py -v + - name: Prepare locked Cargo/std notices and linker evidence directory + shell: python + env: + NAPI_TARGET: ${{ matrix.target }} + run: | + import os + import shutil + import subprocess + import sys + from pathlib import Path + evidence = Path(os.environ['RUNNER_TEMP']) / 'napi-notices' + subprocess.run([sys.executable, 'scripts/prepare_js_notices.py', str(evidence)], check=True) + shutil.copyfile(Path(os.environ['RUNNER_TEMP']) / 'napi-source-provenance.json', evidence / 'source-provenance.json') + maps = evidence / 'link-maps' + maps.mkdir() + key = 'CARGO_TARGET_' + os.environ['NAPI_TARGET'].upper().replace('-', '_') + '_LINKER' + capture = Path('scripts/napi-link-capture') / (os.environ['NAPI_TARGET'] + '-gcc') + capture.parent.mkdir() + shutil.copyfile('scripts/capture_napi_cross_link.py', capture) + capture.chmod(0o755) + with Path(os.environ['GITHUB_ENV']).open('a', encoding='utf-8') as output: + for name, value in [(key, str(capture.resolve())), ('KTAV_NAPI_TARGET', os.environ['NAPI_TARGET']), ('KTAV_NAPI_LINK_EVIDENCE', str(maps))]: + output.write(name + '=' + value + chr(10)) + - name: Resolve the original npm release graph and check licenses + shell: bash + run: | + set -euo pipefail + cp package-lock.json "$RUNNER_TEMP/napi-notices/npm-lock-source.json" + npm install --ignore-scripts --no-audit --no-fund + git diff --exit-code -- package.json + cp package-lock.json "$RUNNER_TEMP/napi-notices/npm-lock-resolved.json" + node scripts/check-npm-licenses.mjs + node -e 'const c=require("@napi-rs/cli/package.json");const t=require("@napi-rs/cross-toolchain/package.json");if(c.version!=="3.6.2"||t.version!=="1.0.3")throw new Error("NAPI build tool versions require source review");' + - name: Build with the unchanged GNU NAPI cross path and capture actual map + shell: bash + run: | + set -euo pipefail + chmod +x scripts/napi-link-capture/${{ matrix.target }}-gcc + npx --no-install napi build --release -p ktav-napi --target ${{ matrix.target }} --platform --js false --output-dir . --use-napi-cross + cmp Cargo.lock "$RUNNER_TEMP/napi-notices/Cargo.lock" + python3 scripts/collect_napi_link_evidence.py ${{ matrix.addon }} "$RUNNER_TEMP/napi-notices" ${{ matrix.target }} + - name: Verify actual matching-CPU Node consumer + if: matrix.target == 'x86_64-unknown-linux-gnu' + shell: bash + run: | + set -euo pipefail + npm run build:ts + mkdir -p dist/native + cp ${{ matrix.addon }} dist/native/${{ matrix.addon }} + node --input-type=module -e 'import assert from "node:assert/strict";import {createRequire} from "node:module";import {readFileSync,realpathSync,writeFileSync} from "node:fs";import {createHash} from "node:crypto";await import("./dist/ts/node.js");const require=createRequire(import.meta.url);const expected=realpathSync("dist/native/ktav.linux-x64-gnu.node");assert.deepEqual(Object.keys(require.cache).filter(p=>p.endsWith(".node")),[expected]);writeFileSync(process.env.RUNNER_TEMP+"/napi-notices/consumer.json",JSON.stringify({loaded_built_addon:true,binary_sha256:createHash("sha256").update(readFileSync(expected)).digest("hex")}));await import("./tests/node/run-node-napi.mjs");' + - uses: actions/upload-artifact@v4 + if: always() + with: + name: napi-license-prototype-${{ matrix.target }} + path: ${{ runner.temp }}/napi-notices/ + if-no-files-found: warn diff --git a/ci/test_napi_cross_link.py b/ci/test_napi_cross_link.py new file mode 100644 index 0000000..127134d --- /dev/null +++ b/ci/test_napi_cross_link.py @@ -0,0 +1,64 @@ +"""Проверить прозрачность и границы NAPI GNU map capture.""" + +import importlib.util +import json +import os +from pathlib import Path +import subprocess +import sys +import tempfile +import unittest + +SCRIPT = Path(__file__).resolve().parents[1] / 'scripts/capture_napi_cross_link.py' +SPEC = importlib.util.spec_from_file_location('capture', SCRIPT) +CAPTURE = importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(CAPTURE) + + +class CaptureTests(unittest.TestCase): + def setUp(self): + self.temp = tempfile.TemporaryDirectory() + self.addCleanup(self.temp.cleanup) + self.root = Path(self.temp.name) + self.workspace = self.root / 'workspace' + self.workspace.mkdir() + self.evidence = self.root / 'evidence' + self.evidence.mkdir() + self.environment = {'KTAV_NAPI_TARGET': 'x86_64-unknown-linux-gnu', 'GITHUB_WORKSPACE': str(self.workspace), 'KTAV_NAPI_LINK_EVIDENCE': str(self.evidence)} + + def test_probe_arguments_are_unchanged(self): + compiler, args, record = CAPTURE.command(['--version', 'with space'], self.environment, self.root) + self.assertEqual(args, [str(compiler), '--version', 'with space']) + self.assertIsNone(record) + self.assertEqual(list(self.evidence.iterdir()), []) + + def test_shared_link_preserves_arguments_and_adds_map(self): + original = ['-shared', '-o', str(self.workspace / 'libktav_napi.so'), 'with space'] + compiler, args, record = CAPTURE.command(original, self.environment, self.root) + self.assertEqual(args[:-1], [str(compiler), *original]) + self.assertTrue(args[-1].startswith('-Wl,-Map=')) + self.assertEqual(record['arguments'], original) + files = list(self.evidence.glob('*.json')) + self.assertEqual(len(files), 1) + self.assertEqual(json.loads(files[0].read_text()), record) + + def test_foreign_output_rejected(self): + with self.assertRaisesRegex(ValueError, 'belong to this build'): + CAPTURE.command(['-shared', '-o', str(self.root / 'foreign.so')], self.environment, self.root) + + def test_unknown_target_rejected(self): + self.environment['KTAV_NAPI_TARGET'] = 'unknown' + with self.assertRaisesRegex(ValueError, 'unreviewed'): + CAPTURE.command(['--version'], self.environment, self.root) + + def test_compiler_failure_status_is_not_masked(self): + compiler = self.root / '.napi-rs/cross-toolchain/1.0.3/x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu-gcc' + compiler.parent.mkdir(parents=True) + compiler.write_text('#!/bin/sh\nexit 23\n') + compiler.chmod(0o755) + result = subprocess.run([sys.executable, str(SCRIPT), '--version'], env={**os.environ, **self.environment, 'HOME': str(self.root)}, capture_output=True) + self.assertEqual(result.returncode, 23) + + +if __name__ == '__main__': + unittest.main() diff --git a/scripts/capture_napi_cross_link.py b/scripts/capture_napi_cross_link.py new file mode 100644 index 0000000..3c9664d --- /dev/null +++ b/scripts/capture_napi_cross_link.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 +"""Прозрачно захватить GNU linker map выбранного NAPI cross toolchain.""" + +import json +import os +from pathlib import Path +import sys +import uuid + +TARGETS = {'x86_64-unknown-linux-gnu', 'aarch64-unknown-linux-gnu'} + + +def command(arguments, environment, home): + target = environment['KTAV_NAPI_TARGET'] + if target not in TARGETS: + raise ValueError('unreviewed NAPI cross target') + toolchain = home / '.napi-rs/cross-toolchain/1.0.3' / target + compiler = toolchain / 'bin' / (target + '-gcc') + args = list(arguments) + record = None + if '-shared' in args and '-o' in args: + position = args.index('-o') + if position + 1 >= len(args): + raise ValueError('missing NAPI linker output') + output = Path(args[position + 1]).resolve() + workspace = Path(environment['GITHUB_WORKSPACE']).resolve() + if not output.is_relative_to(workspace) or output.suffix != '.so': + raise ValueError('NAPI shared output must belong to this build') + evidence = Path(environment['KTAV_NAPI_LINK_EVIDENCE']) + if not evidence.is_dir() or evidence.is_symlink(): + raise ValueError('NAPI linker evidence must already exist') + name = uuid.uuid4().hex + link_map = evidence / (name + '.map') + record = {'target': target, 'compiler': str(compiler), 'output': str(output), 'map': link_map.name, 'arguments': args} + with (evidence / (name + '.json')).open('x', encoding='utf-8') as destination: + json.dump(record, destination, sort_keys=True, indent=2) + args.append('-Wl,-Map=' + str(link_map)) + return compiler, [str(compiler), *args], record + + +if __name__ == '__main__': + compiler, arguments, _ = command(sys.argv[1:], os.environ, Path.home()) + if not compiler.is_file(): + raise SystemExit('exact NAPI cross compiler was not installed; fallback forbidden') + os.execv(str(compiler), arguments) diff --git a/scripts/collect_napi_link_evidence.py b/scripts/collect_napi_link_evidence.py new file mode 100644 index 0000000..4c50480 --- /dev/null +++ b/scripts/collect_napi_link_evidence.py @@ -0,0 +1,84 @@ +"""Связать actual addon с GNU map и compiler/sysroot evidence.""" + +import hashlib +import json +from pathlib import Path, PurePosixPath +import re +import shutil +import struct +import subprocess +import sys + +TARGETS = {'x86_64-unknown-linux-gnu': 62, 'aarch64-unknown-linux-gnu': 183} +LEGAL = re.compile(r'^(?:license|licence|copying|copyright|notice)(?:[._-].*)?$', re.I) + + +def sha(path): + checksum = hashlib.sha256() + with path.open('rb') as source: + for chunk in iter(lambda: source.read(1024 * 1024), b''): + checksum.update(chunk) + return checksum.hexdigest() + + +def collect(binary, evidence, target): + if target not in TARGETS or not binary.is_file() or binary.stat().st_size > 128 * 1024 * 1024: + raise ValueError('invalid NAPI target or binary') + with binary.open('rb') as source: + header = source.read(64) + if len(header) != 64 or header[:6] != b'\x7fELF\x02\x01' or struct.unpack_from(' 4 * 1024 * 1024 or total + size > 32 * 1024 * 1024: + raise ValueError('SDK notice size limit exceeded') + data = path.read_bytes() + total += len(data) + notices.append({'path': path.relative_to(sdk).as_posix(), 'sha256': hashlib.sha256(data).hexdigest(), 'text': data.decode('utf-8')}) + (evidence / 'sdk-notice-files.json').write_text(json.dumps(notices, ensure_ascii=False, indent=2), encoding='utf-8') + members = sorted({(PurePosixPath(archive).name, PurePosixPath(member).name) for archive, member in re.findall(r'([^\s()]+[.]a)\(([^()\n]+)\)', text)}) + objects = sorted({PurePosixPath(path).name for path in re.findall(r'^LOAD\s+([^\n]+[.]o)\s*$', text, re.M)}) + result = {'target': target, 'binary_sha256': binary_sha, 'compiler_sha256': sha(compiler), 'cross_toolchain_version': '1.0.3', 'archive_members': members, 'loaded_objects': objects, 'sdk_notice_files': len(notices), 'coverage': 'Observed GNU link inputs only; package MIT metadata is not a license conclusion for GNU runtime objects.'} + (evidence / 'native-link-inputs.json').write_text(json.dumps(result, sort_keys=True, indent=2), encoding='utf-8') + print(json.dumps(result, sort_keys=True)) + + +if __name__ == '__main__': + if len(sys.argv) != 4: + raise SystemExit('usage: collect_napi_link_evidence.py BINARY EVIDENCE TARGET') + collect(Path(sys.argv[1]), Path(sys.argv[2]), sys.argv[3]) From eef16fe40bf24ca336291251d4a6f619267be1b4 Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Fri, 30 Oct 2026 03:48:15 +0100 Subject: [PATCH 15/51] ci: snapshot original NAPI linker arguments Do not alias the mutable command list when recording original arguments. Appending the map option must not mutate the returned capture metadata. Retain the regression assertion for unchanged arguments and compiler status. Co-Authored-By: Claude Opus 5.5 --- scripts/capture_napi_cross_link.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/capture_napi_cross_link.py b/scripts/capture_napi_cross_link.py index 3c9664d..03eefc6 100644 --- a/scripts/capture_napi_cross_link.py +++ b/scripts/capture_napi_cross_link.py @@ -31,7 +31,7 @@ def command(arguments, environment, home): raise ValueError('NAPI linker evidence must already exist') name = uuid.uuid4().hex link_map = evidence / (name + '.map') - record = {'target': target, 'compiler': str(compiler), 'output': str(output), 'map': link_map.name, 'arguments': args} + record = {'target': target, 'compiler': str(compiler), 'output': str(output), 'map': link_map.name, 'arguments': list(args)} with (evidence / (name + '.json')).open('x', encoding='utf-8') as destination: json.dump(record, destination, sort_keys=True, indent=2) args.append('-Wl,-Map=' + str(link_map)) From 550b4917653dbfeadfc4a57daa64aec7ae3152ea Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Fri, 30 Oct 2026 03:59:38 +0100 Subject: [PATCH 16/51] ci: preserve exact non-UTF8 SDK notice bytes Do not assume every original GNU SDK legal file is UTF-8. Retain raw bytes and hashes for every file, provide UTF-8 text only when valid, and explicitly flag unclassified encodings for review. Do not replace characters, discard terms or infer a license from the encoding. Add regression coverage for UTF-8, non-UTF8 and binary source notices. Co-Authored-By: Claude Opus 5.5 --- ci/test_napi_cross_link.py | 30 +++++++++++++++++++++++++++ scripts/collect_napi_link_evidence.py | 15 ++++++++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/ci/test_napi_cross_link.py b/ci/test_napi_cross_link.py index 127134d..92ee338 100644 --- a/ci/test_napi_cross_link.py +++ b/ci/test_napi_cross_link.py @@ -1,5 +1,7 @@ """Проверить прозрачность и границы NAPI GNU map capture.""" +import base64 +import hashlib import importlib.util import json import os @@ -60,5 +62,33 @@ def test_compiler_failure_status_is_not_masked(self): self.assertEqual(result.returncode, 23) +COLLECT_SPEC = importlib.util.spec_from_file_location('collector', SCRIPT.with_name('collect_napi_link_evidence.py')) +COLLECT = importlib.util.module_from_spec(COLLECT_SPEC) +COLLECT_SPEC.loader.exec_module(COLLECT) + + +class NoticeByteTests(unittest.TestCase): + def test_utf8_notice_is_preserved_exactly(self): + data = 'Copyright © fixture'.encode('utf-8') + record = COLLECT.notice_record('LICENSE', data) + self.assertEqual(record['utf8_text'].encode('utf-8'), data) + self.assertEqual(base64.b64decode(record['raw_bytes_base64']), data) + self.assertFalse(record['requires_encoding_review']) + + def test_non_utf8_notice_is_not_lossily_decoded(self): + data = b'Copyright \xa9 fixture' + record = COLLECT.notice_record('COPYING', data) + self.assertIsNone(record['utf8_text']) + self.assertTrue(record['requires_encoding_review']) + self.assertEqual(base64.b64decode(record['raw_bytes_base64']), data) + self.assertEqual(record['sha256'], hashlib.sha256(data).hexdigest()) + + def test_binary_notice_bytes_remain_uninterpreted(self): + data = bytes([31, 139, 255, 0]) + record = COLLECT.notice_record('COPYING.gz', data) + self.assertEqual(base64.b64decode(record['raw_bytes_base64']), data) + self.assertTrue(record['requires_encoding_review']) + + if __name__ == '__main__': unittest.main() diff --git a/scripts/collect_napi_link_evidence.py b/scripts/collect_napi_link_evidence.py index 4c50480..13bf68e 100644 --- a/scripts/collect_napi_link_evidence.py +++ b/scripts/collect_napi_link_evidence.py @@ -1,5 +1,6 @@ """Связать actual addon с GNU map и compiler/sysroot evidence.""" +import base64 import hashlib import json from pathlib import Path, PurePosixPath @@ -21,6 +22,16 @@ def sha(path): return checksum.hexdigest() +def notice_record(name, data): + try: + text = data.decode('utf-8') + except UnicodeDecodeError: + text = None + return {'path': name, 'sha256': hashlib.sha256(data).hexdigest(), + 'raw_bytes_base64': base64.b64encode(data).decode('ascii'), + 'utf8_text': text, 'requires_encoding_review': text is None} + + def collect(binary, evidence, target): if target not in TARGETS or not binary.is_file() or binary.stat().st_size > 128 * 1024 * 1024: raise ValueError('invalid NAPI target or binary') @@ -69,11 +80,11 @@ def collect(binary, evidence, target): raise ValueError('SDK notice size limit exceeded') data = path.read_bytes() total += len(data) - notices.append({'path': path.relative_to(sdk).as_posix(), 'sha256': hashlib.sha256(data).hexdigest(), 'text': data.decode('utf-8')}) + notices.append(notice_record(path.relative_to(sdk).as_posix(), data)) (evidence / 'sdk-notice-files.json').write_text(json.dumps(notices, ensure_ascii=False, indent=2), encoding='utf-8') members = sorted({(PurePosixPath(archive).name, PurePosixPath(member).name) for archive, member in re.findall(r'([^\s()]+[.]a)\(([^()\n]+)\)', text)}) objects = sorted({PurePosixPath(path).name for path in re.findall(r'^LOAD\s+([^\n]+[.]o)\s*$', text, re.M)}) - result = {'target': target, 'binary_sha256': binary_sha, 'compiler_sha256': sha(compiler), 'cross_toolchain_version': '1.0.3', 'archive_members': members, 'loaded_objects': objects, 'sdk_notice_files': len(notices), 'coverage': 'Observed GNU link inputs only; package MIT metadata is not a license conclusion for GNU runtime objects.'} + result = {'target': target, 'binary_sha256': binary_sha, 'compiler_sha256': sha(compiler), 'cross_toolchain_version': '1.0.3', 'archive_members': members, 'loaded_objects': objects, 'sdk_notice_files': len(notices), 'notice_files_requiring_encoding_review': [item['path'] for item in notices if item['requires_encoding_review']], 'coverage': 'Observed GNU link inputs only; package MIT metadata is not a license conclusion for GNU runtime objects.'} (evidence / 'native-link-inputs.json').write_text(json.dumps(result, sort_keys=True, indent=2), encoding='utf-8') print(json.dumps(result, sort_keys=True)) From 188d7b4918734112182e02c63eb4fe209233c38f Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Fri, 30 Oct 2026 12:41:10 +0100 Subject: [PATCH 17/51] ci: bind GNU NAPI inputs to pinned SDK bytes Check actual loaded SDK objects and archives against reviewed byte fingerprints from the published SDK repository revision. Bind compiler and configuration bytes as well, preserving the catalogue digest in the exact-addon evidence. Reject unknown static inputs and SDK escapes. Add nine regressions for changed bytes, missing and additional inputs, trusted aliases and escaping paths. Preserve the source overlay and existing GNU cross-build path. This is provenance evidence, not blanket runtime license clearance or a reproducible source-build claim. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/napi-notice-check.yml | 3 +- ci/napi-gnu-sdk-inputs.json | 128 ++++++++++++++++++++++++ ci/test_napi_cross_link.py | 78 +++++++++++++++ scripts/collect_napi_link_evidence.py | 42 +++++++- 4 files changed, 249 insertions(+), 2 deletions(-) create mode 100644 ci/napi-gnu-sdk-inputs.json diff --git a/.github/workflows/napi-notice-check.yml b/.github/workflows/napi-notice-check.yml index 241d032..192b8b3 100644 --- a/.github/workflows/napi-notice-check.yml +++ b/.github/workflows/napi-notice-check.yml @@ -31,7 +31,7 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'napi-notice-tools' stage.mkdir() - for name in ['scripts/capture_napi_cross_link.py', 'scripts/collect_napi_link_evidence.py', 'ci/test_napi_cross_link.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json']: + for name in ['scripts/capture_napi_cross_link.py', 'scripts/collect_napi_link_evidence.py', 'ci/test_napi_cross_link.py', 'ci/napi-gnu-sdk-inputs.json', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json']: target = stage / name target.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(name, target) @@ -85,6 +85,7 @@ jobs: evidence = Path(os.environ['RUNNER_TEMP']) / 'napi-notices' subprocess.run([sys.executable, 'scripts/prepare_js_notices.py', str(evidence)], check=True) shutil.copyfile(Path(os.environ['RUNNER_TEMP']) / 'napi-source-provenance.json', evidence / 'source-provenance.json') + shutil.copyfile('ci/napi-gnu-sdk-inputs.json', evidence / 'napi-gnu-sdk-inputs.json') maps = evidence / 'link-maps' maps.mkdir() key = 'CARGO_TARGET_' + os.environ['NAPI_TARGET'].upper().replace('-', '_') + '_LINKER' diff --git a/ci/napi-gnu-sdk-inputs.json b/ci/napi-gnu-sdk-inputs.json new file mode 100644 index 0000000..a93a11f --- /dev/null +++ b/ci/napi-gnu-sdk-inputs.json @@ -0,0 +1,128 @@ +{ + "coverage": "Pinned SDK input bytes; source-name and declared-version correspondence are not a reproducible source-build claim.", + "repository_revision": "9cd8dda8e1798b7ce74bbba900cd8c6767afa37f", + "schema_version": 1, + "sdk_version": "1.0.3", + "targets": { + "aarch64-unknown-linux-gnu": { + "compiler": { + "bytes": 828528, + "git_blob_sha": "36a02f6c2d9fabbb57adfc9a918a2a0e8788002b", + "path": "bin/aarch64-unknown-linux-gnu-gcc", + "repository_path": "x64/aarch64-unknown-linux-gnu/bin/aarch64-unknown-linux-gnu-gcc", + "sha256": "3cdc81cf0998bfa9a39377af5722764b13a5d6dcf1aecc1f144722b455d0b045" + }, + "configuration": { + "bytes": 4920, + "git_blob_sha": "1a45d7aff02accda4847e3ea6a0690402b9641e8", + "path": "bin/aarch64-unknown-linux-gnu-ct-ng.config", + "repository_path": "x64/aarch64-unknown-linux-gnu/bin/aarch64-unknown-linux-gnu-ct-ng.config", + "sha256": "0dea140e772babd916f1df202fc926d9f437d79b40abbaf4fb02bcb620c9a8ee" + }, + "runtime_inputs": [ + { + "bytes": 1440, + "git_blob_sha": "5edbe0a2d3dda3d28e25a8e626f98d785cf1c340", + "path": "aarch64-unknown-linux-gnu/sysroot/usr/lib/crti.o", + "repository_path": "x64/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot/usr/lib/crti.o", + "sha256": "0b0250606c8c3305631c8e26dd58a26df1297dc0c2d501442625bf6748365e8c" + }, + { + "bytes": 1016, + "git_blob_sha": "9a77f62d19f4df3bc97bde4dc45fc6f4dd92d5ab", + "path": "aarch64-unknown-linux-gnu/sysroot/usr/lib/crtn.o", + "repository_path": "x64/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot/usr/lib/crtn.o", + "sha256": "50ea930e73f339140017b9faf4124313fda4f1c3946b59a6af5f31988336b91b" + }, + { + "bytes": 75816, + "git_blob_sha": "85094597a2e77da57df6745a66f825ae964c81e8", + "path": "aarch64-unknown-linux-gnu/sysroot/usr/lib/libc_nonshared.a", + "repository_path": "x64/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot/usr/lib/libc_nonshared.a", + "sha256": "24e31e0ced364852e667877fc4da8ad3d111bb2544a744b1a25538a4b4c2395f" + }, + { + "bytes": 4724, + "git_blob_sha": "f37718a9c8649fb1d6da7043ab2c7f647ae2b504", + "path": "aarch64-unknown-linux-gnu/sysroot/usr/lib/libpthread_nonshared.a", + "repository_path": "x64/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot/usr/lib/libpthread_nonshared.a", + "sha256": "6681ebf6a60ab0819587b0c1888218c7e1a7846f03df171ff6fe505e6265ef58" + }, + { + "bytes": 3408, + "git_blob_sha": "1990db7f27139ad2dda5705b2912e8eef29d7ca6", + "path": "lib/gcc/aarch64-unknown-linux-gnu/4.8.5/crtbeginS.o", + "repository_path": "x64/aarch64-unknown-linux-gnu/lib/gcc/aarch64-unknown-linux-gnu/4.8.5/crtbeginS.o", + "sha256": "4c7955ace6928b8602bef526d171bc6ed6a968927d0222b76476e55878cf8d1e" + }, + { + "bytes": 1392, + "git_blob_sha": "d4cf4503e88a0c9e65062e14ee33eee4ed642651", + "path": "lib/gcc/aarch64-unknown-linux-gnu/4.8.5/crtendS.o", + "repository_path": "x64/aarch64-unknown-linux-gnu/lib/gcc/aarch64-unknown-linux-gnu/4.8.5/crtendS.o", + "sha256": "f50ebe3bcb8896e74beb060ee4883cc71eded13ce62b2a5d4478166633e84947" + } + ] + }, + "x86_64-unknown-linux-gnu": { + "compiler": { + "bytes": 869488, + "git_blob_sha": "f8568accd69d728c68e73ed124404c6af66d8c3a", + "path": "bin/x86_64-unknown-linux-gnu-gcc", + "repository_path": "x64/x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu-gcc", + "sha256": "172152675d84539fec54571b2007095d55b33b6da8aecaa8904e5f5795488e51" + }, + "configuration": { + "bytes": 4905, + "git_blob_sha": "eb99b96dccaa94e689c042f4e9cbc41b3b6699f8", + "path": "bin/x86_64-unknown-linux-gnu-ct-ng.config", + "repository_path": "x64/x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu-ct-ng.config", + "sha256": "978d0dff8d6ecc38a2dd8f9dd56a56d7083df6189fc05adb818b7d6f2109449e" + }, + "runtime_inputs": [ + { + "bytes": 2824, + "git_blob_sha": "ede7f02a24d6cc7a90e78873cfadbb8c6d8fc27b", + "path": "x86_64-unknown-linux-gnu/sysroot/usr/lib/crti.o", + "repository_path": "x64/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/sysroot/usr/lib/crti.o", + "sha256": "f6b62f52bba9c208fa65188e670e01fa0634d6aac08f4ea70d4054b91837c72a" + }, + { + "bytes": 2544, + "git_blob_sha": "a07d5c1dd50dd216291481722a7063f97af5428c", + "path": "x86_64-unknown-linux-gnu/sysroot/usr/lib/crtn.o", + "repository_path": "x64/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/sysroot/usr/lib/crtn.o", + "sha256": "aa96c36b491d6835d75cae1774584f8e2fb299b784fe11b4d70bc2dc40fd250d" + }, + { + "bytes": 65182, + "git_blob_sha": "b3f7bf33633ee98393d19700527b327ae26967c6", + "path": "x86_64-unknown-linux-gnu/sysroot/usr/lib/libc_nonshared.a", + "repository_path": "x64/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/sysroot/usr/lib/libc_nonshared.a", + "sha256": "a07403f9e6fa62130b96deb0d2aa84b517b67cc2a13138264d7a527634c7c399" + }, + { + "bytes": 4332, + "git_blob_sha": "3a973f182e868ae5405b822a198b57828f91c027", + "path": "x86_64-unknown-linux-gnu/sysroot/usr/lib/libpthread_nonshared.a", + "repository_path": "x64/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu/sysroot/usr/lib/libpthread_nonshared.a", + "sha256": "f8488896e8a81316cfc03cea79f34428bb279696bb3940c82edfb9349962f83c" + }, + { + "bytes": 3368, + "git_blob_sha": "b56a5577016f8de0a9b8a0037ad620784216bd1b", + "path": "lib/gcc/x86_64-unknown-linux-gnu/4.8.5/crtbeginS.o", + "repository_path": "x64/x86_64-unknown-linux-gnu/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/crtbeginS.o", + "sha256": "a4206eded529ecbc814556370eeb0edb286be49749d2d65f54f83e438ef6ea4d" + }, + { + "bytes": 1936, + "git_blob_sha": "3a2fd8270ffe7b225ac3a8de2474c499248d5bdf", + "path": "lib/gcc/x86_64-unknown-linux-gnu/4.8.5/crtendS.o", + "repository_path": "x64/x86_64-unknown-linux-gnu/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/crtendS.o", + "sha256": "0eaf7f3c0c919b188499c3a7f33fb84395ecb4be1072c7e19c2702f9d48319e5" + } + ] + } + } +} diff --git a/ci/test_napi_cross_link.py b/ci/test_napi_cross_link.py index 92ee338..40a6bbc 100644 --- a/ci/test_napi_cross_link.py +++ b/ci/test_napi_cross_link.py @@ -90,5 +90,83 @@ def test_binary_notice_bytes_remain_uninterpreted(self): self.assertTrue(record['requires_encoding_review']) +class SdkInputTests(unittest.TestCase): + def fixture(self): + temporary = tempfile.TemporaryDirectory() + self.addCleanup(temporary.cleanup) + root = Path(temporary.name) + sdk = root / 'sdk' + entries = {} + for name, data in [('bin/compiler', b'compiler'), ('bin/config', b'config'), ('lib/runtime.o', b'runtime')]: + path = sdk / name + path.parent.mkdir(parents=True, exist_ok=True) + path.write_bytes(data) + entries[name] = {'path': name, 'bytes': len(data), 'sha256': hashlib.sha256(data).hexdigest()} + catalog = {'repository_revision': 'a' * 40, 'targets': {'x86_64-unknown-linux-gnu': {'compiler': entries['bin/compiler'], 'configuration': entries['bin/config'], 'runtime_inputs': [entries['lib/runtime.o']]}}} + return sdk, catalog, 'LOAD ' + (sdk / 'lib/runtime.o').as_posix() + '\n' + + def test_exact_compiler_config_and_loaded_runtime_are_bound(self): + sdk, catalog, link_map = self.fixture() + report = COLLECT.sdk_inputs(sdk, link_map, 'x86_64-unknown-linux-gnu', catalog) + self.assertEqual(len(report['inputs']), 3) + self.assertEqual([item['path'] for item in report['inputs'] if item['role'] == 'runtime'], ['lib/runtime.o']) + + def test_changed_runtime_bytes_are_rejected(self): + sdk, catalog, link_map = self.fixture() + (sdk / 'lib/runtime.o').write_bytes(b'changed') + with self.assertRaisesRegex(ValueError, 'pinned repository bytes'): + COLLECT.sdk_inputs(sdk, link_map, 'x86_64-unknown-linux-gnu', catalog) + + def test_changed_compiler_bytes_are_rejected(self): + sdk, catalog, link_map = self.fixture() + (sdk / 'bin/compiler').write_bytes(b'altered!') + with self.assertRaisesRegex(ValueError, 'pinned repository bytes'): + COLLECT.sdk_inputs(sdk, link_map, 'x86_64-unknown-linux-gnu', catalog) + + def test_missing_loaded_runtime_is_rejected(self): + sdk, catalog, _ = self.fixture() + with self.assertRaisesRegex(ValueError, 'static input inventory'): + COLLECT.sdk_inputs(sdk, '', 'x86_64-unknown-linux-gnu', catalog) + + def test_unknown_loaded_sdk_archive_is_rejected(self): + sdk, catalog, link_map = self.fixture() + (sdk / 'lib/unknown.a').write_bytes(b'archive') + link_map += 'LOAD ' + (sdk / 'lib/unknown.a').as_posix() + '\n' + with self.assertRaisesRegex(ValueError, 'static input inventory'): + COLLECT.sdk_inputs(sdk, link_map, 'x86_64-unknown-linux-gnu', catalog) + + def test_inside_sdk_alias_is_normalized(self): + sdk, catalog, _ = self.fixture() + alias = sdk / 'lib/alias.o' + alias.symlink_to(sdk / 'lib/runtime.o') + report = COLLECT.sdk_inputs(sdk, 'LOAD ' + alias.as_posix() + '\n', 'x86_64-unknown-linux-gnu', catalog) + self.assertEqual(report['inputs'][-1]['path'], 'lib/runtime.o') + + def test_sdk_symlink_escape_is_rejected(self): + sdk, catalog, link_map = self.fixture() + outside = sdk.parent / 'outside.o' + outside.write_bytes(b'runtime') + path = sdk / 'lib/runtime.o' + path.unlink() + path.symlink_to(outside) + with self.assertRaisesRegex(ValueError, 'escapes selected SDK'): + COLLECT.sdk_inputs(sdk, link_map, 'x86_64-unknown-linux-gnu', catalog) + + def test_extra_mapped_sdk_symlink_escape_is_not_ignored(self): + sdk, catalog, link_map = self.fixture() + outside = sdk.parent / 'outside.a' + outside.write_bytes(b'archive') + alias = sdk / 'lib/escape.a' + alias.symlink_to(outside) + with self.assertRaisesRegex(ValueError, 'mapped SDK static input escapes'): + COLLECT.sdk_inputs(sdk, link_map + 'LOAD ' + alias.as_posix() + '\n', 'x86_64-unknown-linux-gnu', catalog) + + def test_catalog_path_traversal_is_rejected(self): + sdk, catalog, link_map = self.fixture() + catalog['targets']['x86_64-unknown-linux-gnu']['runtime_inputs'][0]['path'] = '../outside.o' + with self.assertRaisesRegex(ValueError, 'unsafe reviewed SDK input path'): + COLLECT.sdk_inputs(sdk, link_map, 'x86_64-unknown-linux-gnu', catalog) + + if __name__ == '__main__': unittest.main() diff --git a/scripts/collect_napi_link_evidence.py b/scripts/collect_napi_link_evidence.py index 13bf68e..500bd52 100644 --- a/scripts/collect_napi_link_evidence.py +++ b/scripts/collect_napi_link_evidence.py @@ -32,6 +32,37 @@ def notice_record(name, data): 'utf8_text': text, 'requires_encoding_review': text is None} +def sdk_inputs(sdk, link_map, target, catalog): + boundary = sdk.resolve() + selected = catalog['targets'][target] + records = [] + for role, entries in [('compiler', [selected['compiler']]), ('configuration', [selected['configuration']]), ('runtime', selected['runtime_inputs'])]: + for entry in entries: + relative = PurePosixPath(entry['path']) + if relative.is_absolute() or '..' in relative.parts or '\\' in entry['path']: + raise ValueError('unsafe reviewed SDK input path') + path = sdk / entry['path'] + if not path.resolve().is_relative_to(boundary) or not path.is_file(): + raise ValueError('SDK input escapes selected SDK or is missing') + with path.open('rb') as source: + data = source.read(4 * 1024 * 1024 + 1) + if len(data) > 4 * 1024 * 1024 or len(data) != entry['bytes'] or hashlib.sha256(data).hexdigest() != entry['sha256']: + raise ValueError('SDK input differs from pinned repository bytes') + records.append({'role': role, 'path': path.resolve().relative_to(boundary).as_posix(), 'bytes': len(data), 'sha256': entry['sha256']}) + expected = {item['path'] for item in records if item['role'] == 'runtime'} + observed = set() + for value in re.findall(r'^LOAD\s+([^\n]+\.(?:o|a))\s*$', link_map, re.M): + public_path = Path(value) + path = public_path.resolve() + if public_path.is_relative_to(sdk.absolute()) and not path.is_relative_to(boundary): + raise ValueError('mapped SDK static input escapes selected SDK') + if path.is_relative_to(boundary): + observed.add(path.relative_to(boundary).as_posix()) + if observed != expected: + raise ValueError('actual SDK static input inventory differs from reviewed profile') + return {'repository_revision': catalog['repository_revision'], 'inputs': records, 'coverage': 'Exact SDK compiler/configuration and loaded static-input bytes; not a claim of reproducible GNU source compilation or complete runtime license clearance.'} + + def collect(binary, evidence, target): if target not in TARGETS or not binary.is_file() or binary.stat().st_size > 128 * 1024 * 1024: raise ValueError('invalid NAPI target or binary') @@ -63,6 +94,15 @@ def collect(binary, evidence, target): compiler = sdk / 'bin' / (target + '-gcc') if Path(record['compiler']) != compiler or not compiler.resolve().is_relative_to(sdk.resolve()): raise ValueError('captured compiler differs from selected SDK') + catalog_path = Path(__file__).resolve().parents[1] / 'ci/napi-gnu-sdk-inputs.json' + with catalog_path.open('rb') as source: + catalog_bytes = source.read(1024 * 1024 + 1) + if len(catalog_bytes) > 1024 * 1024: + raise ValueError('SDK input catalogue exceeds bound') + catalog = json.loads(catalog_bytes) + if catalog.get('schema_version') != 1 or catalog.get('sdk_version') != '1.0.3' or set(catalog['targets']) != set(TARGETS): + raise ValueError('unreviewed SDK input catalogue') + input_profile = sdk_inputs(sdk, text, target, catalog) for name, args in [('compiler-version.txt', [str(compiler), '--version']), ('elf-header.txt', ['readelf', '-h', str(binary)]), ('elf-dynamic.txt', ['readelf', '-d', str(binary)]), ('elf-versions.txt', ['readelf', '--version-info', str(binary)])]: (evidence / name).write_bytes(subprocess.check_output(args)) configuration = sdk / 'bin' / (target + '-ct-ng.config') @@ -84,7 +124,7 @@ def collect(binary, evidence, target): (evidence / 'sdk-notice-files.json').write_text(json.dumps(notices, ensure_ascii=False, indent=2), encoding='utf-8') members = sorted({(PurePosixPath(archive).name, PurePosixPath(member).name) for archive, member in re.findall(r'([^\s()]+[.]a)\(([^()\n]+)\)', text)}) objects = sorted({PurePosixPath(path).name for path in re.findall(r'^LOAD\s+([^\n]+[.]o)\s*$', text, re.M)}) - result = {'target': target, 'binary_sha256': binary_sha, 'compiler_sha256': sha(compiler), 'cross_toolchain_version': '1.0.3', 'archive_members': members, 'loaded_objects': objects, 'sdk_notice_files': len(notices), 'notice_files_requiring_encoding_review': [item['path'] for item in notices if item['requires_encoding_review']], 'coverage': 'Observed GNU link inputs only; package MIT metadata is not a license conclusion for GNU runtime objects.'} + result = {'target': target, 'binary_sha256': binary_sha, 'compiler_sha256': sha(compiler), 'cross_toolchain_version': '1.0.3', 'sdk_input_profile': input_profile, 'sdk_input_catalog_sha256': hashlib.sha256(catalog_bytes).hexdigest(), 'archive_members': members, 'loaded_objects': objects, 'sdk_notice_files': len(notices), 'notice_files_requiring_encoding_review': [item['path'] for item in notices if item['requires_encoding_review']], 'coverage': 'Observed GNU link inputs only; package MIT metadata is not a license conclusion for GNU runtime objects.'} (evidence / 'native-link-inputs.json').write_text(json.dumps(result, sort_keys=True, indent=2), encoding='utf-8') print(json.dumps(result, sort_keys=True)) From 3274d0b47282c950ec64e77c8143cb25aeed7be3 Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Fri, 30 Oct 2026 13:10:09 +0100 Subject: [PATCH 18/51] fix: retain the reviewed JS Cargo build graph Track the exact lock from successful CI run 40994854671 and bind it to explicit provenance. Keep per-crate locks ignored. Preserve the reviewed lock through both immutable-source notice overlays instead of silently resolving new crate releases on every run. Require exact lock bytes before generating notices and retain the non-historical resolution label. Add seven missing/changed/unbound-lock regressions. Keep source license fallback guards, MSRV, product versions, Rust sources and native cross-build flags unchanged. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/napi-notice-check.yml | 10 +- .github/workflows/wasm-notice-check.yml | 5 +- .gitignore | 3 +- Cargo.lock | 523 ++++++++++++++++++++++++ ci/js-build-lock.json | 13 + ci/test_js_build_lock.py | 82 ++++ scripts/prepare_js_notices.py | 29 +- 7 files changed, 651 insertions(+), 14 deletions(-) create mode 100644 Cargo.lock create mode 100644 ci/js-build-lock.json create mode 100644 ci/test_js_build_lock.py diff --git a/.github/workflows/napi-notice-check.yml b/.github/workflows/napi-notice-check.yml index 192b8b3..967f49b 100644 --- a/.github/workflows/napi-notice-check.yml +++ b/.github/workflows/napi-notice-check.yml @@ -31,7 +31,7 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'napi-notice-tools' stage.mkdir() - for name in ['scripts/capture_napi_cross_link.py', 'scripts/collect_napi_link_evidence.py', 'ci/test_napi_cross_link.py', 'ci/napi-gnu-sdk-inputs.json', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json']: + for name in ['Cargo.lock', 'ci/js-build-lock.json', 'ci/test_js_build_lock.py', 'scripts/capture_napi_cross_link.py', 'scripts/collect_napi_link_evidence.py', 'ci/test_napi_cross_link.py', 'ci/napi-gnu-sdk-inputs.json', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json']: target = stage / name target.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(name, target) @@ -58,7 +58,7 @@ jobs: target.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(path, target) subprocess.run(['git', 'diff', '--exit-code', '--', 'Cargo.toml', 'crates', 'tests/node', 'root-docs', 'package.json', 'package-lock.json'], check=True) - record = {'source_ref': os.environ['SOURCE_REF'], 'tooling_ref': os.environ['GITHUB_SHA'], 'napi_build_rs_sha256': hashlib.sha256(Path('crates/napi/build.rs').read_bytes()).hexdigest(), 'coverage': 'Audit-only GNU linker provenance, not completed non-Cargo runtime licensing or historical package evidence.'} + record = {'source_ref': os.environ['SOURCE_REF'], 'tooling_ref': os.environ['GITHUB_SHA'], 'napi_build_rs_sha256': hashlib.sha256(Path('crates/napi/build.rs').read_bytes()).hexdigest(), 'reviewed_lock_sha256': hashlib.sha256(Path('Cargo.lock').read_bytes()).hexdigest(), 'coverage': 'Audit-only GNU linker provenance, not completed non-Cargo runtime licensing or historical package evidence.'} (Path(os.environ['RUNNER_TEMP']) / 'napi-source-provenance.json').write_text(json.dumps(record, sort_keys=True, indent=2)) - uses: actions/setup-node@v4 with: @@ -70,8 +70,10 @@ jobs: - uses: taiki-e/install-action@v2 with: tool: cargo-about@0.9.3 - - name: Verify transparent linker capture guards - run: python3 -I -m unittest discover -s ci -p test_napi_cross_link.py -v + - name: Verify transparent linker capture and reviewed lock guards + run: | + python3 -I -m unittest discover -s ci -p test_napi_cross_link.py -v + python3 -I -m unittest discover -s ci -p test_js_build_lock.py -v - name: Prepare locked Cargo/std notices and linker evidence directory shell: python env: diff --git a/.github/workflows/wasm-notice-check.yml b/.github/workflows/wasm-notice-check.yml index 3e403eb..6b4dc64 100644 --- a/.github/workflows/wasm-notice-check.yml +++ b/.github/workflows/wasm-notice-check.yml @@ -23,7 +23,7 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'wasm-notice-tools' stage.mkdir() - for name in ['scripts/wasm-notice-resource.mjs', 'tests/wasm-notice-resource.test.mjs', 'tests/test_wasm_npm.py', 'scripts/prepare_js_notices.py', 'scripts/check_wasm_npm.py', 'scripts/check-npm-licenses.mjs', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/check_embedded_notices.py', 'ci/about.toml', 'scripts/source_license_supplements.py', 'ci/test_js_source_supplements.py', 'ci/licenses/js-source-supplements.json']: + for name in ['Cargo.lock', 'ci/js-build-lock.json', 'ci/test_js_build_lock.py', 'scripts/wasm-notice-resource.mjs', 'tests/wasm-notice-resource.test.mjs', 'tests/test_wasm_npm.py', 'scripts/prepare_js_notices.py', 'scripts/check_wasm_npm.py', 'scripts/check-npm-licenses.mjs', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/check_embedded_notices.py', 'ci/about.toml', 'scripts/source_license_supplements.py', 'ci/test_js_source_supplements.py', 'ci/licenses/js-source-supplements.json']: target = stage / name target.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(name, target) @@ -60,7 +60,7 @@ jobs: raise SystemExit('WASM build script interpreter changed') packaged = shebang + bytes([10]) + b'import { addNoticeFile } from "./wasm-notice-resource.mjs";' + bytes([10]) + body.replace(anchor, hook + bytes([10, 10]) + anchor) script.write_bytes(packaged) - record = {'source_ref': os.environ['SOURCE_REF'], 'tooling_ref': os.environ['GITHUB_SHA'], 'original_build_script_sha256': hashlib.sha256(original).hexdigest(), 'packaged_build_script_sha256': hashlib.sha256(packaged).hexdigest(), 'coverage': 'Audit-only Cargo/std prototype, not historical npm or non-Cargo runtime compliance.'} + record = {'source_ref': os.environ['SOURCE_REF'], 'tooling_ref': os.environ['GITHUB_SHA'], 'original_build_script_sha256': hashlib.sha256(original).hexdigest(), 'packaged_build_script_sha256': hashlib.sha256(packaged).hexdigest(), 'reviewed_lock_sha256': hashlib.sha256(Path('Cargo.lock').read_bytes()).hexdigest(), 'coverage': 'Audit-only Cargo/std prototype, not historical npm or non-Cargo runtime compliance.'} (Path(os.environ['RUNNER_TEMP']) / 'wasm-source-provenance.json').write_text(json.dumps(record, sort_keys=True, indent=2)) subprocess.run(['git', 'diff', '--exit-code', '--', 'Cargo.toml', 'crates', 'tests/node', 'root-docs', 'package.json', 'package-lock.json'], check=True) - uses: actions/setup-node@v4 @@ -80,6 +80,7 @@ jobs: node --test tests/wasm-notice-resource.test.mjs python3 -I -m unittest discover -s tests -p test_wasm_npm.py -v python3 -I -m unittest discover -s ci -p test_js_source_supplements.py -v + python3 -I -m unittest discover -s ci -p test_js_build_lock.py -v - name: Prepare source-backed locked notices shell: bash run: | diff --git a/.gitignore b/.gitignore index 6c6372f..490ed15 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,8 @@ docs_local/ # Rust build artifacts target/ -Cargo.lock +**/Cargo.lock +!/Cargo.lock # Node / JS node_modules/ diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..5389c6f --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,523 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "bumpalo" +version = "3.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" + +[[package]] +name = "castaway" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dec551ab6e7578819132c713a93c022a05d60159dc86e7a7050223577484c55a" +dependencies = [ + "rustversion", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "compact_str" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dfdd1c2274d9aa354115b09dc9a901d6c5576818cdf70d14cae2bdb47df00ab" +dependencies = [ + "castaway", + "cfg-if", + "itoa", + "rustversion", + "ryu", + "serde", + "static_assertions", +] + +[[package]] +name = "convert_case" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1af709f1f33454bf52eadfc8c78b3b9ef9cb26fb54d16dc9cd9a7299f899fd1b" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "ctor" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "914a755b7c2d4af2bdcff7ce1739e2db9a1b81a9b07123d8015786ae03c0980d" + +[[package]] +name = "equivalent" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "futures" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-executor" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" + +[[package]] +name = "futures-macro" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown", + "serde", + "serde_core", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "js-sys" +version = "0.3.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "ktav" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7140dfe2fa6c320e74768cd6a637828c2d26f81746254f4fcd805f3993bd3fd5" +dependencies = [ + "bumpalo", + "compact_str", + "indexmap", + "itoa", + "memchr", + "rustc-hash", + "ryu", + "serde", + "serde_json", +] + +[[package]] +name = "ktav-cabi" +version = "0.8.1" +dependencies = [ + "ktav", +] + +[[package]] +name = "ktav-napi" +version = "0.8.1" +dependencies = [ + "indexmap", + "itoa", + "ktav", + "napi", + "napi-build", + "napi-derive", + "rustc-hash", + "ryu", +] + +[[package]] +name = "ktav-wasm" +version = "0.8.1" +dependencies = [ + "indexmap", + "itoa", + "js-sys", + "ktav", + "rustc-hash", + "ryu", + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.191" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + +[[package]] +name = "libloading" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "754ca22de805bb5744484a5b151a9e1a8e837d5dc232c2d7d8c2e3492edc8b60" +dependencies = [ + "cfg-if", + "windows-link", +] + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "napi" +version = "3.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a746ad50efbfb632ade1de4025519a477decbbd798cea1a6ac41d7c44f80083" +dependencies = [ + "bitflags", + "ctor", + "futures", + "libc", + "napi-build", + "napi-sys", + "nohash-hasher", + "rustc-hash", +] + +[[package]] +name = "napi-build" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b899b545d3aa6dca985939059f258c5488d34e4ecf39c274e20009748f4b846d" + +[[package]] +name = "napi-derive" +version = "3.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ff48271a0f61abb83f3e2d1989fa71169143db95f6f948c3a8903961f2855dc" +dependencies = [ + "convert_case", + "ctor", + "napi-derive-backend", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "napi-derive-backend" +version = "6.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2639052c5aff9956a21d7b6202fc61d5e89c5f19c72d289b7a0641ea94e8159" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "semver", + "syn", +] + +[[package]] +name = "napi-sys" +version = "3.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d153beb7d5c973f4b9395be8a83054a28968b61188f1dd1a2cc2321af22daea2" +dependencies = [ + "libloading", +] + +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rustc-hash" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "foldhash", + "indexmap", + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "syn" +version = "3.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "unicode-segmentation" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" + +[[package]] +name = "wasm-bindgen" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/ci/js-build-lock.json b/ci/js-build-lock.json new file mode 100644 index 0000000..d9e61c5 --- /dev/null +++ b/ci/js-build-lock.json @@ -0,0 +1,13 @@ +{ + "schema_version": 1, + "cargo_lock_sha256": "c09c21c421fda8a5411f756f5df5718de41d4cf92ad237150592011f9f785932", + "reviewed_source_ref": "562deb3fde092d63a78f359be095e5079929d0d1", + "reviewed_ci": { + "repository": "ktav-lang/js", + "run": 40994854671, + "artifact": 12950643988, + "target": "x86_64-unknown-linux-gnu", + "rust_toolchain": "1.99.1" + }, + "coverage": "Previously successful, source-reviewed CI build graph for product 0.8.1. This is not evidence of the original historical published dependency graph. Updating this lock requires renewed source/license review." +} diff --git a/ci/test_js_build_lock.py b/ci/test_js_build_lock.py new file mode 100644 index 0000000..f34b1a8 --- /dev/null +++ b/ci/test_js_build_lock.py @@ -0,0 +1,82 @@ +"""Проверить reviewed lock без запуска Cargo и автоматического resolution.""" + +import hashlib +import importlib.util +import json +from pathlib import Path +import sys +import tempfile +import unittest + +SCRIPTS = Path(__file__).resolve().parents[1] / 'scripts' +sys.path.insert(0, str(SCRIPTS)) +spec = importlib.util.spec_from_file_location('js_notices', SCRIPTS / 'prepare_js_notices.py') +helper = importlib.util.module_from_spec(spec) +spec.loader.exec_module(helper) + + +class ReviewedBuildLockTests(unittest.TestCase): + def fixture(self): + temporary = tempfile.TemporaryDirectory() + self.addCleanup(temporary.cleanup) + root = Path(temporary.name) + data = b'version = 4\n' + (root / 'Cargo.lock').write_bytes(data) + (root / 'ci').mkdir() + provenance = {'schema_version': 1, 'cargo_lock_sha256': hashlib.sha256(data).hexdigest()} + (root / 'ci/js-build-lock.json').write_text(json.dumps(provenance), encoding='utf-8') + return root, data, provenance + + def test_existing_reviewed_lock_is_returned_without_rewriting(self): + root, data, provenance = self.fixture() + original, record = helper.reviewed_lock(root) + self.assertEqual(original, data) + self.assertEqual(record, provenance) + self.assertEqual((root / 'Cargo.lock').read_bytes(), data) + + def test_missing_lock_is_not_regenerated(self): + root, _, _ = self.fixture() + (root / 'Cargo.lock').unlink() + with self.assertRaisesRegex(ValueError, 'missing'): + helper.reviewed_lock(root) + self.assertFalse((root / 'Cargo.lock').exists()) + + def test_missing_provenance_is_rejected(self): + root, _, _ = self.fixture() + (root / 'ci/js-build-lock.json').unlink() + with self.assertRaisesRegex(ValueError, 'missing'): + helper.reviewed_lock(root) + + def test_changed_lock_is_not_silently_resolved(self): + root, _, _ = self.fixture() + (root / 'Cargo.lock').write_bytes(b'version = 3\n') + with self.assertRaisesRegex(ValueError, 'differs from reviewed graph'): + helper.reviewed_lock(root) + self.assertEqual((root / 'Cargo.lock').read_bytes(), b'version = 3\n') + + def test_unknown_review_record_schema_is_rejected(self): + root, _, provenance = self.fixture() + provenance['schema_version'] = 2 + (root / 'ci/js-build-lock.json').write_text(json.dumps(provenance), encoding='utf-8') + with self.assertRaisesRegex(ValueError, 'differs from reviewed graph'): + helper.reviewed_lock(root) + + def test_unbound_hash_is_rejected(self): + root, _, provenance = self.fixture() + provenance['cargo_lock_sha256'] = '0' * 64 + (root / 'ci/js-build-lock.json').write_text(json.dumps(provenance), encoding='utf-8') + with self.assertRaisesRegex(ValueError, 'differs from reviewed graph'): + helper.reviewed_lock(root) + + def test_symlinked_lock_is_rejected(self): + root, data, _ = self.fixture() + alternate = root / 'alternate.lock' + alternate.write_bytes(data) + (root / 'Cargo.lock').unlink() + (root / 'Cargo.lock').symlink_to(alternate) + with self.assertRaisesRegex(ValueError, 'missing'): + helper.reviewed_lock(root) + + +if __name__ == '__main__': + unittest.main() diff --git a/scripts/prepare_js_notices.py b/scripts/prepare_js_notices.py index 1077c33..6f8461a 100644 --- a/scripts/prepare_js_notices.py +++ b/scripts/prepare_js_notices.py @@ -1,6 +1,7 @@ -"""Подготовить notices свежего CI lock, не выдавая его за historical graph.""" +"""Подготовить notices проверенного CI lock, не выдавая его за historical graph.""" import gzip +import hashlib import json from pathlib import Path import shutil @@ -12,17 +13,30 @@ from source_license_supplements import supplement_fallbacks +def reviewed_lock(root): + lock = root / 'Cargo.lock' + provenance_path = root / 'ci/js-build-lock.json' + if lock.is_symlink() or not lock.is_file() or provenance_path.is_symlink() or not provenance_path.is_file(): + raise ValueError('reviewed JS build lock or provenance is missing') + with lock.open('rb') as source: + original = source.read(4 * 1024 * 1024 + 1) + with provenance_path.open('rb') as source: + provenance_bytes = source.read(1024 * 1024 + 1) + if len(original) > 4 * 1024 * 1024 or len(provenance_bytes) > 1024 * 1024: + raise ValueError('reviewed JS build lock exceeds bound') + provenance = json.loads(provenance_bytes) + if provenance.get('schema_version') != 1 or hashlib.sha256(original).hexdigest() != provenance.get('cargo_lock_sha256'): + raise ValueError('JS build lock differs from reviewed graph') + return original, provenance + + def prepare(evidence): root = Path.cwd().resolve() evidence = evidence.resolve() if evidence.is_relative_to(root) or evidence.exists(): raise ValueError('JS evidence must be new and outside source') lock = root / 'Cargo.lock' - if lock.exists(): - raise ValueError('published JS source unexpectedly has Cargo.lock') - subprocess.run(['cargo', 'generate-lockfile'], check=True) - subprocess.run(['cargo', 'update', '-p', 'ktav', '--precise', '0.8.1'], check=True) - original = lock.read_bytes() + original, lock_provenance = reviewed_lock(root) core = [item for item in tomllib.loads(original.decode())['package'] if item['name'] == 'ktav'] if len(core) != 1 or core[0]['version'] != '0.8.1' or core[0].get('checksum') != '7140dfe2fa6c320e74768cd6a637828c2d26f81746254f4fcd805f3993bd3fd5' or core[0].get('source') != 'registry+https://github.com/rust-lang/crates.io-index': raise ValueError('unexpected JS registry core source') @@ -55,7 +69,8 @@ def prepare(evidence): (evidence / 'licenses.json').write_text(json.dumps(combined, ensure_ascii=False, indent=2) + '\n', encoding='utf-8') bundle = json.loads(_build(evidence)) bundle['source_license_supplements'] = provenance - bundle['resolution_origin'] = 'Fresh CI resolution for published JS source 0.8.1; not historical published dependency evidence.' + bundle['resolution_origin'] = 'Pinned reviewed CI build graph for JS source 0.8.1; not historical published dependency evidence.' + bundle['reviewed_build_lock'] = lock_provenance data = (json.dumps(bundle, ensure_ascii=False, sort_keys=True, indent=2) + '\n').encode() payload = gzip.compress(data, mtime=0) if len(data) > 64 * 1024 * 1024 or len(payload) > 4 * 1024 * 1024 or lock.read_bytes() != original: From 8e6f5cef4db54ab8c43237d9b904f7238614695e Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sat, 31 Oct 2026 17:25:52 +0100 Subject: [PATCH 19/51] fix: retain numbered GNU copying documents Include COPYING3 and COPYING3.LIB in the SDK legal inventory without changing existing notice naming rules or runtime license conclusions. Add positive and negative filename regression cases. Co-Authored-By: Claude Opus 5.5 --- ci/test_napi_cross_link.py | 17 +++++++++++++++++ scripts/collect_napi_link_evidence.py | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ci/test_napi_cross_link.py b/ci/test_napi_cross_link.py index 40a6bbc..8fc3c94 100644 --- a/ci/test_napi_cross_link.py +++ b/ci/test_napi_cross_link.py @@ -67,6 +67,23 @@ def test_compiler_failure_status_is_not_masked(self): COLLECT_SPEC.loader.exec_module(COLLECT) +class NoticeFilenameTests(unittest.TestCase): + def test_numbered_copying_documents_are_included(self): + for name in ['COPYING2', 'COPYING3', 'COPYING3.LIB', 'copying3.lib', 'COPYING3.gz']: + with self.subTest(name=name): + self.assertIsNotNone(COLLECT.LEGAL.fullmatch(name)) + + def test_existing_notice_names_remain_included(self): + for name in ['LICENSE', 'LICENCE', 'COPYING', 'COPYING.LIB', 'COPYING.RUNTIME', 'COPYRIGHT', 'NOTICE', 'LICENSE-MIT', 'NOTICE_extra']: + with self.subTest(name=name): + self.assertIsNotNone(COLLECT.LEGAL.fullmatch(name)) + + def test_unrelated_names_remain_excluded(self): + for name in ['COPYING3helper', 'COPYINGcat', 'LICENSE3', 'README', 'libgcc.a', 'prefix-COPYING3']: + with self.subTest(name=name): + self.assertIsNone(COLLECT.LEGAL.fullmatch(name)) + + class NoticeByteTests(unittest.TestCase): def test_utf8_notice_is_preserved_exactly(self): data = 'Copyright © fixture'.encode('utf-8') diff --git a/scripts/collect_napi_link_evidence.py b/scripts/collect_napi_link_evidence.py index 500bd52..3cfc811 100644 --- a/scripts/collect_napi_link_evidence.py +++ b/scripts/collect_napi_link_evidence.py @@ -11,7 +11,7 @@ import sys TARGETS = {'x86_64-unknown-linux-gnu': 62, 'aarch64-unknown-linux-gnu': 183} -LEGAL = re.compile(r'^(?:license|licence|copying|copyright|notice)(?:[._-].*)?$', re.I) +LEGAL = re.compile(r'^(?:license|licence|copying[0-9]*|copyright|notice)(?:[._-].*)?$', re.I) def sha(path): From fd325b2f762dc98d650f3ac229f5530115b52027 Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sat, 31 Oct 2026 17:35:13 +0100 Subject: [PATCH 20/51] ci: bind GNU NAPI notices to reviewed inputs Preserve complete upstream runtime source grants and pinned SDK GPL, LGPL and GCC Runtime Library Exception documents in target-specific JSON, readable notices and the Cargo/std bundle. Verify actual compiler/configuration/runtime input bytes, selected archive members and the captured final Rust/LLVM plus GCC link path. Reject unknown targets, inputs, documents and compiler extensions. Embedding and npm delivery remain separate verification gates. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/napi-notice-check.yml | 5 +- ci/licenses/napi-gnu-runtime.json | 120 ++++++++++++++++++ ci/test_napi_gnu_runtime_notices.py | 135 ++++++++++++++++++++ scripts/collect_napi_link_evidence.py | 1 + scripts/napi_gnu_runtime_notices.py | 161 ++++++++++++++++++++++++ 5 files changed, 421 insertions(+), 1 deletion(-) create mode 100644 ci/licenses/napi-gnu-runtime.json create mode 100644 ci/test_napi_gnu_runtime_notices.py create mode 100644 scripts/napi_gnu_runtime_notices.py diff --git a/.github/workflows/napi-notice-check.yml b/.github/workflows/napi-notice-check.yml index 967f49b..d6a6868 100644 --- a/.github/workflows/napi-notice-check.yml +++ b/.github/workflows/napi-notice-check.yml @@ -31,7 +31,7 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'napi-notice-tools' stage.mkdir() - for name in ['Cargo.lock', 'ci/js-build-lock.json', 'ci/test_js_build_lock.py', 'scripts/capture_napi_cross_link.py', 'scripts/collect_napi_link_evidence.py', 'ci/test_napi_cross_link.py', 'ci/napi-gnu-sdk-inputs.json', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json']: + for name in ['Cargo.lock', 'ci/js-build-lock.json', 'ci/test_js_build_lock.py', 'scripts/capture_napi_cross_link.py', 'scripts/collect_napi_link_evidence.py', 'ci/test_napi_cross_link.py', 'ci/napi-gnu-sdk-inputs.json', 'ci/licenses/napi-gnu-runtime.json', 'ci/test_napi_gnu_runtime_notices.py', 'scripts/napi_gnu_runtime_notices.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json']: target = stage / name target.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(name, target) @@ -74,6 +74,7 @@ jobs: run: | python3 -I -m unittest discover -s ci -p test_napi_cross_link.py -v python3 -I -m unittest discover -s ci -p test_js_build_lock.py -v + python3 -I -m unittest discover -s ci -p test_napi_gnu_runtime_notices.py -v - name: Prepare locked Cargo/std notices and linker evidence directory shell: python env: @@ -86,6 +87,7 @@ jobs: from pathlib import Path evidence = Path(os.environ['RUNNER_TEMP']) / 'napi-notices' subprocess.run([sys.executable, 'scripts/prepare_js_notices.py', str(evidence)], check=True) + subprocess.run([sys.executable, '-I', 'scripts/napi_gnu_runtime_notices.py', 'prepare', str(evidence), os.environ['NAPI_TARGET']], check=True) shutil.copyfile(Path(os.environ['RUNNER_TEMP']) / 'napi-source-provenance.json', evidence / 'source-provenance.json') shutil.copyfile('ci/napi-gnu-sdk-inputs.json', evidence / 'napi-gnu-sdk-inputs.json') maps = evidence / 'link-maps' @@ -116,6 +118,7 @@ jobs: npx --no-install napi build --release -p ktav-napi --target ${{ matrix.target }} --platform --js false --output-dir . --use-napi-cross cmp Cargo.lock "$RUNNER_TEMP/napi-notices/Cargo.lock" python3 scripts/collect_napi_link_evidence.py ${{ matrix.addon }} "$RUNNER_TEMP/napi-notices" ${{ matrix.target }} + python3 -I scripts/napi_gnu_runtime_notices.py verify "$RUNNER_TEMP/napi-notices" ${{ matrix.target }} - name: Verify actual matching-CPU Node consumer if: matrix.target == 'x86_64-unknown-linux-gnu' shell: bash diff --git a/ci/licenses/napi-gnu-runtime.json b/ci/licenses/napi-gnu-runtime.json new file mode 100644 index 0000000..14d5dbd --- /dev/null +++ b/ci/licenses/napi-gnu-runtime.json @@ -0,0 +1,120 @@ +{ + "schema_version": 1, + "sdk_revision": "9cd8dda8e1798b7ce74bbba900cd8c6767afa37f", + "materials": [ + { + "id": "glibc/io/fstat64.c", + "kind": "source", + "repository": "https://github.com/bminor/glibc", + "revision": "c758a6861537815c759cba2018a3b1abb1943842", + "path": "io/fstat64.c", + "git_blob": "f859aa627b4b510638e42c8ff61b463992614a14", + "sha256": "d5710871e920a7c60f5d8c8a32e3933fb4c97fe97f1d61e3e4e623983c36dbf4", + "bytes": 2377, + "text": "/* Copyright (C) 1996, 1997, 2001, 2006 Free Software Foundation, Inc.\n This file is part of the GNU C Library.\n\n The GNU C Library is free software; you can redistribute it and/or\n modify it under the terms of the GNU Lesser General Public\n License as published by the Free Software Foundation; either\n version 2.1 of the License, or (at your option) any later version.\n\n In addition to the permissions in the GNU Lesser General Public\n License, the Free Software Foundation gives you unlimited\n permission to link the compiled version of this file with other\n programs, and to distribute those programs without any restriction\n coming from the use of this file. (The GNU Lesser General Public\n License restrictions do apply in other respects; for example, they\n cover modification of the file, and distribution when not linked\n into another program.)\n\n Note that people who make modified versions of this file are not\n obligated to grant this special exception for their modified\n versions; it is their choice whether to do so. The GNU Lesser\n General Public License gives permission to release a modified\n version without this exception; this exception also makes it\n possible to release a modified version which carries forward this\n exception.\n\n The GNU C Library is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public\n License along with the GNU C Library; if not, see\n . */\n\n#include \n\n/* This definition is only used if inlining fails for this function; see\n the last page of . The real work is done by the `x'\n function which is passed a version number argument. We arrange in the\n makefile that when not inlined this function is always statically\n linked; that way a dynamically-linked executable always encodes the\n version number corresponding to the data structures it uses, so the `x'\n functions in the shared library can adapt without needing to recompile\n all callers. */\n\n#undef fstat64\nint\nattribute_hidden\nfstat64 (int fd, struct stat64 *buf)\n{\n return __fxstat64 (_STAT_VER, fd, buf);\n}\n" + }, + { + "id": "glibc/io/stat64.c", + "kind": "source", + "repository": "https://github.com/bminor/glibc", + "revision": "c758a6861537815c759cba2018a3b1abb1943842", + "path": "io/stat64.c", + "git_blob": "e3eb413eff5c5bef2032f44459e99be62c9a9d46", + "sha256": "ab271a6691d873ff9f19022ca9d8b08d9f0782b78cfeaf836dae1773dcf893fb", + "bytes": 2386, + "text": "/* Copyright (C) 1996, 1997, 2001, 2006 Free Software Foundation, Inc.\n This file is part of the GNU C Library.\n\n The GNU C Library is free software; you can redistribute it and/or\n modify it under the terms of the GNU Lesser General Public\n License as published by the Free Software Foundation; either\n version 2.1 of the License, or (at your option) any later version.\n\n In addition to the permissions in the GNU Lesser General Public\n License, the Free Software Foundation gives you unlimited\n permission to link the compiled version of this file with other\n programs, and to distribute those programs without any restriction\n coming from the use of this file. (The GNU Lesser General Public\n License restrictions do apply in other respects; for example, they\n cover modification of the file, and distribution when not linked\n into another program.)\n\n Note that people who make modified versions of this file are not\n obligated to grant this special exception for their modified\n versions; it is their choice whether to do so. The GNU Lesser\n General Public License gives permission to release a modified\n version without this exception; this exception also makes it\n possible to release a modified version which carries forward this\n exception.\n\n The GNU C Library is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public\n License along with the GNU C Library; if not, see\n . */\n\n#include \n\n/* This definition is only used if inlining fails for this function; see\n the last page of . The real work is done by the `x'\n function which is passed a version number argument. We arrange in the\n makefile that when not inlined this function is always statically\n linked; that way a dynamically-linked executable always encodes the\n version number corresponding to the data structures it uses, so the `x'\n functions in the shared library can adapt without needing to recompile\n all callers. */\n\n#undef stat64\nint\nattribute_hidden\nstat64 (const char *file, struct stat64 *buf)\n{\n return __xstat64 (_STAT_VER, file, buf);\n}\n" + }, + { + "id": "glibc/ports/sysdeps/aarch64/crti.S", + "kind": "source", + "repository": "https://github.com/bminor/glibc", + "revision": "c758a6861537815c759cba2018a3b1abb1943842", + "path": "ports/sysdeps/aarch64/crti.S", + "git_blob": "0c89accd7c1377fab5a05e0a339892fcf63c74cd", + "sha256": "c6c1c4e20897e5f7edabfdce54a2e002c351d7eb66f4fdcfa54dbf7c806a8ee5", + "bytes": 2865, + "text": "/* Special .init and .fini section support for AArch64.\n Copyright (C) 1995-2012 Free Software Foundation, Inc.\n\n This file is part of the GNU C Library.\n\n The GNU C Library is free software; you can redistribute it and/or\n modify it under the terms of the GNU Lesser General Public\n License as published by the Free Software Foundation; either\n version 2.1 of the License, or (at your option) any later version.\n\n In addition to the permissions in the GNU Lesser General Public\n License, the Free Software Foundation gives you unlimited\n permission to link the compiled version of this file with other\n programs, and to distribute those programs without any restriction\n coming from the use of this file. (The GNU Lesser General Public\n License restrictions do apply in other respects; for example, they\n cover modification of the file, and distribution when not linked\n into another program.)\n\n Note that people who make modified versions of this file are not\n obligated to grant this special exception for their modified\n versions; it is their choice whether to do so. The GNU Lesser\n General Public License gives permission to release a modified\n version without this exception; this exception also makes it\n possible to release a modified version which carries forward this\n exception.\n\n The GNU C Library is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public\n License along with the GNU C Library; if not, see\n . */\n\n/* crti.S puts a function prologue at the beginning of the .init and\n .fini sections and defines global symbols for those addresses, so\n they can be called as functions. The symbols _init and _fini are\n magic and cause the linker to emit DT_INIT and DT_FINI. */\n\n#include \n\n#ifndef PREINIT_FUNCTION\n# define PREINIT_FUNCTION __gmon_start__\n#endif\n\n#ifndef PREINIT_FUNCTION_WEAK\n# define PREINIT_FUNCTION_WEAK 1\n#endif\n\n#if PREINIT_FUNCTION_WEAK\n\tweak_extern (PREINIT_FUNCTION)\n#else\n\t.hidden PREINIT_FUNCTION\n#endif\n\n#if PREINIT_FUNCTION_WEAK\n\t.align\t2\n\t.type\tcall_weak_fn, %function\ncall_weak_fn:\n\tadrp\tx0, :got:PREINIT_FUNCTION\n\tldr\tx0, [x0, #:got_lo12:PREINIT_FUNCTION]\n\tcbz\tx0, 1f\n\tb\tPREINIT_FUNCTION\n1:\n\tRET\n\t.size\tcall_weak_fn, .-call_weak_fn\n#endif\n\n\t.section .init,\"ax\",%progbits\n\t.align\t2\n\t.global\t_init\n\t.type\t_init, %function\n_init:\n\tstp\tx29, x30, [sp, -16]!\n\tmov\tx29, sp\n#if PREINIT_FUNCTION_WEAK\n\tbl\tcall_weak_fn\n#else\n\tbl\tPREINIT_FUNCTION\n#endif\n\n\t.section\t.fini,\"ax\",%progbits\n\t.align\t2\n\t.global\t_fini\n\t.type\t_fini, %function\n_fini:\n\tstp\tx29, x30, [sp, -16]!\n\tmov\tx29, sp\n" + }, + { + "id": "glibc/ports/sysdeps/aarch64/crtn.S", + "kind": "source", + "repository": "https://github.com/bminor/glibc", + "revision": "c758a6861537815c759cba2018a3b1abb1943842", + "path": "ports/sysdeps/aarch64/crtn.S", + "git_blob": "24456f9f5ac4e0adf0daa4af0c040656bdc5f998", + "sha256": "a3eef4861509305c628c0d4ee066c4079bf83052be0fd6e08412199be6c0eafc", + "bytes": 1990, + "text": "/* Special .init and .fini section support for AArch64.\n Copyright (C) 1995-2012 Free Software Foundation, Inc.\n\n This file is part of the GNU C Library.\n\n The GNU C Library is free software; you can redistribute it and/or\n modify it under the terms of the GNU Lesser General Public\n License as published by the Free Software Foundation; either\n version 2.1 of the License, or (at your option) any later version.\n\n In addition to the permissions in the GNU Lesser General Public\n License, the Free Software Foundation gives you unlimited\n permission to link the compiled version of this file with other\n programs, and to distribute those programs without any restriction\n coming from the use of this file. (The GNU Lesser General Public\n License restrictions do apply in other respects; for example, they\n cover modification of the file, and distribution when not linked\n into another program.)\n\n Note that people who make modified versions of this file are not\n obligated to grant this special exception for their modified\n versions; it is their choice whether to do so. The GNU Lesser\n General Public License gives permission to release a modified\n version without this exception; this exception also makes it\n possible to release a modified version which carries forward this\n exception.\n\n The GNU C Library is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public\n License along with the GNU C Library; if not, see\n . */\n\n/* crtn.S puts function epilogues in the .init and .fini sections\n corresponding to the prologues in crti.S. */\n\n\t.section .init,\"ax\",%progbits\n\tldp\tx29, x30, [sp], 16\n\tRET\n\n\t.section .fini,\"ax\",%progbits\n\tldp\tx29, x30, [sp], 16\n\tRET\n" + }, + { + "id": "glibc/sysdeps/x86_64/crti.S", + "kind": "source", + "repository": "https://github.com/bminor/glibc", + "revision": "c758a6861537815c759cba2018a3b1abb1943842", + "path": "sysdeps/x86_64/crti.S", + "git_blob": "30672194038f52dad052e027f253528797700b31", + "sha256": "bce8ff6c4b187ca1db7e9111f208f28ecd35466d182ccc9b8e1908096b35776a", + "bytes": 2760, + "text": "/* Special .init and .fini section support for x86-64.\n Copyright (C) 2012 Free Software Foundation, Inc.\n This file is part of the GNU C Library.\n\n The GNU C Library is free software; you can redistribute it and/or\n modify it under the terms of the GNU Lesser General Public\n License as published by the Free Software Foundation; either\n version 2.1 of the License, or (at your option) any later version.\n\n In addition to the permissions in the GNU Lesser General Public\n License, the Free Software Foundation gives you unlimited\n permission to link the compiled version of this file with other\n programs, and to distribute those programs without any restriction\n coming from the use of this file. (The GNU Lesser General Public\n License restrictions do apply in other respects; for example, they\n cover modification of the file, and distribution when not linked\n into another program.)\n\n Note that people who make modified versions of this file are not\n obligated to grant this special exception for their modified\n versions; it is their choice whether to do so. The GNU Lesser\n General Public License gives permission to release a modified\n version without this exception; this exception also makes it\n possible to release a modified version which carries forward this\n exception.\n\n The GNU C Library is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public\n License along with the GNU C Library; if not, see\n . */\n\n/* crti.S puts a function prologue at the beginning of the .init and\n .fini sections and defines global symbols for those addresses, so\n they can be called as functions. The symbols _init and _fini are\n magic and cause the linker to emit DT_INIT and DT_FINI. */\n\n#include \n#include \n\n#ifndef PREINIT_FUNCTION\n# define PREINIT_FUNCTION __gmon_start__\n#endif\n\n#ifndef PREINIT_FUNCTION_WEAK\n# define PREINIT_FUNCTION_WEAK 1\n#endif\n\n#if PREINIT_FUNCTION_WEAK\n\tweak_extern (PREINIT_FUNCTION)\n#else\n\t.hidden PREINIT_FUNCTION\n#endif\n\n\t.section .init,\"ax\",@progbits\n\t.p2align 2\n\t.globl _init\n\t.type _init, @function\n_init:\n\t/* Maintain 16-byte stack alignment for called functions. */\n\tsubq $8, %rsp\n#if PREINIT_FUNCTION_WEAK\n\tmovq PREINIT_FUNCTION@GOTPCREL(%rip), %rax\n\ttestq %rax, %rax\n\tje .Lno_weak_fn\n\tcall PREINIT_FUNCTION@PLT\n.Lno_weak_fn:\n#else\n\tcall PREINIT_FUNCTION\n#endif\n\n\t.section .fini,\"ax\",@progbits\n\t.p2align 2\n\t.globl _fini\n\t.type _fini, @function\n_fini:\n\tsubq $8, %rsp\n" + }, + { + "id": "glibc/sysdeps/x86_64/crtn.S", + "kind": "source", + "repository": "https://github.com/bminor/glibc", + "revision": "c758a6861537815c759cba2018a3b1abb1943842", + "path": "sysdeps/x86_64/crtn.S", + "git_blob": "e6f27245f121161ad4409e5288d584bfb081db64", + "sha256": "23431518a8f9fdaf863fcf11ce4d3b7a8d6292e415c14b61b04e6ea15cbe55b1", + "bytes": 1965, + "text": "/* Special .init and .fini section support for x86-64.\n Copyright (C) 2012 Free Software Foundation, Inc.\n This file is part of the GNU C Library.\n\n The GNU C Library is free software; you can redistribute it and/or\n modify it under the terms of the GNU Lesser General Public\n License as published by the Free Software Foundation; either\n version 2.1 of the License, or (at your option) any later version.\n\n In addition to the permissions in the GNU Lesser General Public\n License, the Free Software Foundation gives you unlimited\n permission to link the compiled version of this file with other\n programs, and to distribute those programs without any restriction\n coming from the use of this file. (The GNU Lesser General Public\n License restrictions do apply in other respects; for example, they\n cover modification of the file, and distribution when not linked\n into another program.)\n\n Note that people who make modified versions of this file are not\n obligated to grant this special exception for their modified\n versions; it is their choice whether to do so. The GNU Lesser\n General Public License gives permission to release a modified\n version without this exception; this exception also makes it\n possible to release a modified version which carries forward this\n exception.\n\n The GNU C Library is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public\n License along with the GNU C Library; if not, see\n . */\n\n/* crtn.S puts function epilogues in the .init and .fini sections\n corresponding to the prologues in crti.S. */\n\n\t.section .init,\"ax\",@progbits\n\taddq $8, %rsp\n\tret\n\n\t.section .fini,\"ax\",@progbits\n\taddq $8, %rsp\n\tret\n" + }, + { + "id": "gcc/libgcc/crtstuff.c", + "kind": "source", + "repository": "https://github.com/gcc-mirror/gcc", + "revision": "2da13f5a051c8a28a85311fea990355b4797c179", + "path": "libgcc/crtstuff.c", + "git_blob": "0beda5e571649d973dea8995641e7dca8a85e3b2", + "sha256": "00637abae856a12b0f68a7e1f6f24ee1089ce377e3939b84e21c2dc8ae052cfd", + "bytes": 25159, + "text": "/* Specialized bits of code needed to support construction and\n destruction of file-scope objects in C++ code.\n Copyright (C) 1991-2013 Free Software Foundation, Inc.\n Contributed by Ron Guilmette (rfg@monkeys.com).\n\nThis file is part of GCC.\n\nGCC is free software; you can redistribute it and/or modify it under\nthe terms of the GNU General Public License as published by the Free\nSoftware Foundation; either version 3, or (at your option) any later\nversion.\n\nGCC is distributed in the hope that it will be useful, but WITHOUT ANY\nWARRANTY; without even the implied warranty of MERCHANTABILITY or\nFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\nfor more details.\n\nUnder Section 7 of GPL version 3, you are granted additional\npermissions described in the GCC Runtime Library Exception, version\n3.1, as published by the Free Software Foundation.\n\nYou should have received a copy of the GNU General Public License and\na copy of the GCC Runtime Library Exception along with this program;\nsee the files COPYING3 and COPYING.RUNTIME respectively. If not, see\n. */\n\n/* This file is a bit like libgcc2.c in that it is compiled\n multiple times and yields multiple .o files.\n\n This file is useful on target machines where the object file format\n supports multiple \"user-defined\" sections (e.g. COFF, ELF, ROSE). On\n such systems, this file allows us to avoid running collect (or any\n other such slow and painful kludge). Additionally, if the target\n system supports a .init section, this file allows us to support the\n linking of C++ code with a non-C++ main program.\n\n Note that if INIT_SECTION_ASM_OP is defined in the tm.h file, then\n this file *will* make use of the .init section. If that symbol is\n not defined however, then the .init section will not be used.\n\n Currently, only ELF and COFF are supported. It is likely however that\n ROSE could also be supported, if someone was willing to do the work to\n make whatever (small?) adaptations are needed. (Some work may be\n needed on the ROSE assembler and linker also.)\n\n This file must be compiled with gcc. */\n\n/* Target machine header files require this define. */\n#define IN_LIBGCC2\n\n/* FIXME: Including auto-host is incorrect, but until we have\n identified the set of defines that need to go into auto-target.h,\n this will have to do. */\n#include \"auto-host.h\"\n#undef pid_t\n#undef rlim_t\n#undef ssize_t\n#undef vfork\n#include \"tconfig.h\"\n#include \"tsystem.h\"\n#include \"coretypes.h\"\n#include \"tm.h\"\n#include \"libgcc_tm.h\"\n#include \"unwind-dw2-fde.h\"\n\n#ifndef FORCE_CODE_SECTION_ALIGN\n# define FORCE_CODE_SECTION_ALIGN\n#endif\n\n#ifndef CRT_CALL_STATIC_FUNCTION\n# define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC)\t\\\nstatic void __attribute__((__used__))\t\t\t\\\ncall_ ## FUNC (void)\t\t\t\t\t\\\n{\t\t\t\t\t\t\t\\\n asm (SECTION_OP);\t\t\t\t\t\\\n FUNC ();\t\t\t\t\t\t\\\n FORCE_CODE_SECTION_ALIGN\t\t\t\t\\\n asm (TEXT_SECTION_ASM_OP);\t\t\t\t\\\n}\n#endif\n\n#if defined(OBJECT_FORMAT_ELF) \\\n && !defined(OBJECT_FORMAT_FLAT) \\\n && defined(HAVE_LD_EH_FRAME_HDR) \\\n && !defined(inhibit_libc) && !defined(CRTSTUFFT_O) \\\n && defined(__FreeBSD__) && __FreeBSD__ >= 7\n#include \n# define USE_PT_GNU_EH_FRAME\n#endif\n\n#if defined(OBJECT_FORMAT_ELF) \\\n && !defined(OBJECT_FORMAT_FLAT) \\\n && defined(HAVE_LD_EH_FRAME_HDR) && defined(TARGET_DL_ITERATE_PHDR) \\\n && !defined(inhibit_libc) && !defined(CRTSTUFFT_O) \\\n && defined(__sun__) && defined(__svr4__)\n#include \n# define USE_PT_GNU_EH_FRAME\n#endif\n\n#if defined(OBJECT_FORMAT_ELF) \\\n && !defined(OBJECT_FORMAT_FLAT) \\\n && defined(HAVE_LD_EH_FRAME_HDR) \\\n && !defined(inhibit_libc) && !defined(CRTSTUFFT_O) \\\n && defined(__GLIBC__) && __GLIBC__ >= 2\n#include \n/* uClibc pretends to be glibc 2.2 and DT_CONFIG is defined in its link.h.\n But it doesn't use PT_GNU_EH_FRAME ELF segment currently. */\n# if !defined(__UCLIBC__) \\\n && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \\\n || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG)))\n# define USE_PT_GNU_EH_FRAME\n# endif\n#endif\n\n#if defined(OBJECT_FORMAT_ELF) \\\n && !defined(OBJECT_FORMAT_FLAT) \\\n && defined(HAVE_LD_EH_FRAME_HDR) \\\n && !defined(CRTSTUFFT_O) \\\n && defined(inhibit_libc) \\\n && (defined(__GLIBC__) || defined(__gnu_linux__) || defined(__GNU__))\n/* On systems using glibc, an inhibit_libc build of libgcc is only\n part of a bootstrap process. Build the same crt*.o as would be\n built with headers present, so that it is not necessary to build\n glibc more than once for the bootstrap to converge. */\n# define USE_PT_GNU_EH_FRAME\n#endif\n\n#if defined(EH_FRAME_SECTION_NAME) && !defined(USE_PT_GNU_EH_FRAME)\n# define USE_EH_FRAME_REGISTRY\n#endif\n#if defined(EH_FRAME_SECTION_NAME) && EH_TABLES_CAN_BE_READ_ONLY\n# define EH_FRAME_SECTION_CONST const\n#else\n# define EH_FRAME_SECTION_CONST\n#endif\n\n#if !defined(DTOR_LIST_END) && defined(OBJECT_FORMAT_ELF) \\\n && defined(HAVE_GAS_HIDDEN) && !defined(FINI_ARRAY_SECTION_ASM_OP)\n# define HIDDEN_DTOR_LIST_END\n#endif\n\n#if !defined(USE_TM_CLONE_REGISTRY) && defined(OBJECT_FORMAT_ELF)\n# define USE_TM_CLONE_REGISTRY 1\n#endif\n\n/* We do not want to add the weak attribute to the declarations of these\n routines in unwind-dw2-fde.h because that will cause the definition of\n these symbols to be weak as well.\n\n This exposes a core issue, how to handle creating weak references vs\n how to create weak definitions. Either we have to have the definition\n of TARGET_WEAK_ATTRIBUTE be conditional in the shared header files or\n have a second declaration if we want a function's references to be weak,\n but not its definition.\n\n Making TARGET_WEAK_ATTRIBUTE conditional seems like a good solution until\n one thinks about scaling to larger problems -- i.e., the condition under\n which TARGET_WEAK_ATTRIBUTE is active will eventually get far too\n complicated.\n\n So, we take an approach similar to #pragma weak -- we have a second\n declaration for functions that we want to have weak references.\n\n Neither way is particularly good. */\n\n/* References to __register_frame_info and __deregister_frame_info should\n be weak in this file if at all possible. */\nextern void __register_frame_info (const void *, struct object *)\n\t\t\t\t TARGET_ATTRIBUTE_WEAK;\nextern void __register_frame_info_bases (const void *, struct object *,\n\t\t\t\t\t void *, void *)\n\t\t\t\t TARGET_ATTRIBUTE_WEAK;\nextern void *__deregister_frame_info (const void *)\n\t\t\t\t TARGET_ATTRIBUTE_WEAK;\nextern void *__deregister_frame_info_bases (const void *)\n\t\t\t\t TARGET_ATTRIBUTE_WEAK;\nextern void __do_global_ctors_1 (void);\n\n/* Likewise for _Jv_RegisterClasses. */\nextern void _Jv_RegisterClasses (void *) TARGET_ATTRIBUTE_WEAK;\n\n/* Likewise for transactional memory clone tables. */\nextern void _ITM_registerTMCloneTable (void *, size_t) TARGET_ATTRIBUTE_WEAK;\nextern void _ITM_deregisterTMCloneTable (void *) TARGET_ATTRIBUTE_WEAK;\n\n#ifdef OBJECT_FORMAT_ELF\n\n/* Declare a pointer to void function type. */\ntypedef void (*func_ptr) (void);\n#define STATIC static\n\n#else /* OBJECT_FORMAT_ELF */\n\n#include \"gbl-ctors.h\"\n\n#define STATIC\n\n#endif /* OBJECT_FORMAT_ELF */\n\n#ifdef CRT_BEGIN\n\n/* NOTE: In order to be able to support SVR4 shared libraries, we arrange\n to have one set of symbols { __CTOR_LIST__, __DTOR_LIST__, __CTOR_END__,\n __DTOR_END__ } per root executable and also one set of these symbols\n per shared library. So in any given whole process image, we may have\n multiple definitions of each of these symbols. In order to prevent\n these definitions from conflicting with one another, and in order to\n ensure that the proper lists are used for the initialization/finalization\n of each individual shared library (respectively), we give these symbols\n only internal (i.e. `static') linkage, and we also make it a point to\n refer to only the __CTOR_END__ symbol in crtend.o and the __DTOR_LIST__\n symbol in crtbegin.o, where they are defined. */\n\n/* No need for .ctors/.dtors section if linker can place them in\n .init_array/.fini_array section. */\n#ifndef USE_INITFINI_ARRAY\n/* The -1 is a flag to __do_global_[cd]tors indicating that this table\n does not start with a count of elements. */\n#ifdef CTOR_LIST_BEGIN\nCTOR_LIST_BEGIN;\n#elif defined(CTORS_SECTION_ASM_OP)\n/* Hack: force cc1 to switch to .data section early, so that assembling\n __CTOR_LIST__ does not undo our behind-the-back change to .ctors. */\nstatic func_ptr force_to_data[1] __attribute__ ((__used__)) = { };\nasm (CTORS_SECTION_ASM_OP);\nSTATIC func_ptr __CTOR_LIST__[1]\n __attribute__ ((__used__, aligned(sizeof(func_ptr))))\n = { (func_ptr) (-1) };\n#else\nSTATIC func_ptr __CTOR_LIST__[1]\n __attribute__ ((__used__, section(\".ctors\"), aligned(sizeof(func_ptr))))\n = { (func_ptr) (-1) };\n#endif /* __CTOR_LIST__ alternatives */\n\n#ifdef DTOR_LIST_BEGIN\nDTOR_LIST_BEGIN;\n#elif defined(DTORS_SECTION_ASM_OP)\nasm (DTORS_SECTION_ASM_OP);\nSTATIC func_ptr __DTOR_LIST__[1]\n __attribute__ ((aligned(sizeof(func_ptr))))\n = { (func_ptr) (-1) };\n#else\nSTATIC func_ptr __DTOR_LIST__[1]\n __attribute__((section(\".dtors\"), aligned(sizeof(func_ptr))))\n = { (func_ptr) (-1) };\n#endif /* __DTOR_LIST__ alternatives */\n#endif /* USE_INITFINI_ARRAY */\n\n#ifdef USE_EH_FRAME_REGISTRY\n/* Stick a label at the beginning of the frame unwind info so we can register\n and deregister it with the exception handling library code. */\nSTATIC EH_FRAME_SECTION_CONST char __EH_FRAME_BEGIN__[]\n __attribute__((section(EH_FRAME_SECTION_NAME), aligned(4)))\n = { };\n#endif /* USE_EH_FRAME_REGISTRY */\n\n#ifdef JCR_SECTION_NAME\n/* Stick a label at the beginning of the java class registration info\n so we can register them properly. */\nSTATIC void *__JCR_LIST__[]\n __attribute__ ((used, section(JCR_SECTION_NAME), aligned(sizeof(void*))))\n = { };\n#endif /* JCR_SECTION_NAME */\n\n#if USE_TM_CLONE_REGISTRY\nSTATIC func_ptr __TMC_LIST__[]\n __attribute__((used, section(\".tm_clone_table\"), aligned(sizeof(void*))))\n = { };\n# ifdef HAVE_GAS_HIDDEN\nextern func_ptr __TMC_END__[] __attribute__((__visibility__ (\"hidden\")));\n# endif\n\nstatic inline void\nderegister_tm_clones (void)\n{\n void (*fn) (void *);\n\n#ifdef HAVE_GAS_HIDDEN\n if (__TMC_END__ - __TMC_LIST__ == 0)\n return;\n#else\n if (__TMC_LIST__[0] == NULL)\n return;\n#endif\n\n fn = _ITM_deregisterTMCloneTable;\n __asm (\"\" : \"+r\" (fn));\n if (fn)\n fn (__TMC_LIST__);\n}\n\nstatic inline void\nregister_tm_clones (void)\n{\n void (*fn) (void *, size_t);\n size_t size;\n\n#ifdef HAVE_GAS_HIDDEN\n size = (__TMC_END__ - __TMC_LIST__) / 2;\n#else\n for (size = 0; __TMC_LIST__[size * 2] != NULL; size++)\n continue;\n#endif\n if (size == 0)\n return;\n\n fn = _ITM_registerTMCloneTable;\n __asm (\"\" : \"+r\" (fn));\n if (fn)\n fn (__TMC_LIST__, size);\n}\n#endif /* USE_TM_CLONE_REGISTRY */\n\n#if defined(INIT_SECTION_ASM_OP) || defined(INIT_ARRAY_SECTION_ASM_OP)\n\n#ifdef OBJECT_FORMAT_ELF\n\n/* Declare the __dso_handle variable. It should have a unique value\n in every shared-object; in a main program its value is zero. The\n object should in any case be protected. This means the instance\n in one DSO or the main program is not used in another object. The\n dynamic linker takes care of this. */\n\n#ifdef TARGET_LIBGCC_SDATA_SECTION\nextern void *__dso_handle __attribute__ ((__section__ (TARGET_LIBGCC_SDATA_SECTION)));\n#endif\n#ifdef HAVE_GAS_HIDDEN\nextern void *__dso_handle __attribute__ ((__visibility__ (\"hidden\")));\n#endif\n#ifdef CRTSTUFFS_O\nvoid *__dso_handle = &__dso_handle;\n#else\nvoid *__dso_handle = 0;\n#endif\n\n/* The __cxa_finalize function may not be available so we use only a\n weak declaration. */\nextern void __cxa_finalize (void *) TARGET_ATTRIBUTE_WEAK;\n\n/* Run all the global destructors on exit from the program. */\n\n/* Some systems place the number of pointers in the first word of the\n table. On SVR4 however, that word is -1. In all cases, the table is\n null-terminated. On SVR4, we start from the beginning of the list and\n invoke each per-compilation-unit destructor routine in order\n until we find that null.\n\n Note that this function MUST be static. There will be one of these\n functions in each root executable and one in each shared library, but\n although they all have the same code, each one is unique in that it\n refers to one particular associated `__DTOR_LIST__' which belongs to the\n same particular root executable or shared library file.\n\n On some systems, this routine is run more than once from the .fini,\n when exit is called recursively, so we arrange to remember where in\n the list we left off processing, and we resume at that point,\n should we be re-invoked. */\n\nstatic void __attribute__((used))\n__do_global_dtors_aux (void)\n{\n static _Bool completed;\n\n if (__builtin_expect (completed, 0))\n return;\n\n#ifdef CRTSTUFFS_O\n if (__cxa_finalize)\n __cxa_finalize (__dso_handle);\n#endif\n\n#ifdef FINI_ARRAY_SECTION_ASM_OP\n /* If we are using .fini_array then destructors will be run via that\n mechanism. */\n#elif defined(HIDDEN_DTOR_LIST_END)\n {\n /* Safer version that makes sure only .dtors function pointers are\n called even if the static variable is maliciously changed. */\n extern func_ptr __DTOR_END__[] __attribute__((visibility (\"hidden\")));\n static size_t dtor_idx;\n const size_t max_idx = __DTOR_END__ - __DTOR_LIST__ - 1;\n func_ptr f;\n\n while (dtor_idx < max_idx)\n {\n\tf = __DTOR_LIST__[++dtor_idx];\n\tf ();\n }\n }\n#else /* !defined (FINI_ARRAY_SECTION_ASM_OP) */\n {\n static func_ptr *p = __DTOR_LIST__ + 1;\n func_ptr f;\n\n while ((f = *p))\n {\n\tp++;\n\tf ();\n }\n }\n#endif /* !defined(FINI_ARRAY_SECTION_ASM_OP) */\n\n#if USE_TM_CLONE_REGISTRY\n deregister_tm_clones ();\n#endif /* USE_TM_CLONE_REGISTRY */\n\n#ifdef USE_EH_FRAME_REGISTRY\n#ifdef CRT_GET_RFIB_DATA\n /* If we used the new __register_frame_info_bases interface,\n make sure that we deregister from the same place. */\n if (__deregister_frame_info_bases)\n __deregister_frame_info_bases (__EH_FRAME_BEGIN__);\n#else\n if (__deregister_frame_info)\n __deregister_frame_info (__EH_FRAME_BEGIN__);\n#endif\n#endif\n\n completed = 1;\n}\n\n/* Stick a call to __do_global_dtors_aux into the .fini section. */\n#ifdef FINI_SECTION_ASM_OP\nCRT_CALL_STATIC_FUNCTION (FINI_SECTION_ASM_OP, __do_global_dtors_aux)\n#elif defined (FINI_ARRAY_SECTION_ASM_OP)\nstatic func_ptr __do_global_dtors_aux_fini_array_entry[]\n __attribute__ ((__used__, section(\".fini_array\"), aligned(sizeof(func_ptr))))\n = { __do_global_dtors_aux };\n#else /* !FINI_SECTION_ASM_OP && !FINI_ARRAY_SECTION_ASM_OP */\nstatic void __attribute__((used))\n__do_global_dtors_aux_1 (void)\n{\n atexit (__do_global_dtors_aux);\n}\nCRT_CALL_STATIC_FUNCTION (INIT_SECTION_ASM_OP, __do_global_dtors_aux_1)\n#endif\n\n#if defined(USE_EH_FRAME_REGISTRY) \\\n || defined(JCR_SECTION_NAME) \\\n || defined(USE_TM_CLONE_REGISTRY)\n/* Stick a call to __register_frame_info into the .init section. For some\n reason calls with no arguments work more reliably in .init, so stick the\n call in another function. */\n\nstatic void __attribute__((used))\nframe_dummy (void)\n{\n#ifdef USE_EH_FRAME_REGISTRY\n static struct object object;\n#ifdef CRT_GET_RFIB_DATA\n void *tbase, *dbase;\n tbase = 0;\n CRT_GET_RFIB_DATA (dbase);\n if (__register_frame_info_bases)\n __register_frame_info_bases (__EH_FRAME_BEGIN__, &object, tbase, dbase);\n#else\n if (__register_frame_info)\n __register_frame_info (__EH_FRAME_BEGIN__, &object);\n#endif /* CRT_GET_RFIB_DATA */\n#endif /* USE_EH_FRAME_REGISTRY */\n\n#ifdef JCR_SECTION_NAME\n if (__JCR_LIST__[0])\n {\n void (*register_classes) (void *) = _Jv_RegisterClasses;\n __asm (\"\" : \"+r\" (register_classes));\n if (register_classes)\n\tregister_classes (__JCR_LIST__);\n }\n#endif /* JCR_SECTION_NAME */\n\n#if USE_TM_CLONE_REGISTRY\n register_tm_clones ();\n#endif /* USE_TM_CLONE_REGISTRY */\n}\n\n#ifdef INIT_SECTION_ASM_OP\nCRT_CALL_STATIC_FUNCTION (INIT_SECTION_ASM_OP, frame_dummy)\n#else /* defined(INIT_SECTION_ASM_OP) */\nstatic func_ptr __frame_dummy_init_array_entry[]\n __attribute__ ((__used__, section(\".init_array\"), aligned(sizeof(func_ptr))))\n = { frame_dummy };\n#endif /* !defined(INIT_SECTION_ASM_OP) */\n#endif /* USE_EH_FRAME_REGISTRY || JCR_SECTION_NAME || USE_TM_CLONE_REGISTRY */\n\n#else /* OBJECT_FORMAT_ELF */\n\n/* The function __do_global_ctors_aux is compiled twice (once in crtbegin.o\n and once in crtend.o). It must be declared static to avoid a link\n error. Here, we define __do_global_ctors as an externally callable\n function. It is externally callable so that __main can invoke it when\n INVOKE__main is defined. This has the additional effect of forcing cc1\n to switch to the .text section. */\n\nstatic void __do_global_ctors_aux (void);\nvoid\n__do_global_ctors (void)\n{\n#ifdef INVOKE__main\n /* If __main won't actually call __do_global_ctors then it doesn't matter\n what's inside the function. The inside of __do_global_ctors_aux is\n called automatically in that case. And the Alliant fx2800 linker\n crashes on this reference. So prevent the crash. */\n __do_global_ctors_aux ();\n#endif\n}\n\nasm (INIT_SECTION_ASM_OP);\t/* cc1 doesn't know that we are switching! */\n\n/* A routine to invoke all of the global constructors upon entry to the\n program. We put this into the .init section (for systems that have\n such a thing) so that we can properly perform the construction of\n file-scope static-storage C++ objects within shared libraries. */\n\nstatic void __attribute__((used))\n__do_global_ctors_aux (void)\t/* prologue goes in .init section */\n{\n FORCE_CODE_SECTION_ALIGN\t/* explicit align before switch to .text */\n asm (TEXT_SECTION_ASM_OP);\t/* don't put epilogue and body in .init */\n DO_GLOBAL_CTORS_BODY;\n atexit (__do_global_dtors);\n}\n\n#endif /* OBJECT_FORMAT_ELF */\n\n#elif defined(HAS_INIT_SECTION) /* ! INIT_SECTION_ASM_OP */\n\nextern void __do_global_dtors (void);\n\n/* This case is used by the Irix 6 port, which supports named sections but\n not an SVR4-style .fini section. __do_global_dtors can be non-static\n in this case because we protect it with -hidden_symbol. */\n\nvoid\n__do_global_dtors (void)\n{\n func_ptr *p, f;\n for (p = __DTOR_LIST__ + 1; (f = *p); p++)\n f ();\n\n#if USE_TM_CLONE_REGISTRY\n deregister_tm_clones ();\n#endif /* USE_TM_CLONE_REGISTRY */\n\n#ifdef USE_EH_FRAME_REGISTRY\n if (__deregister_frame_info)\n __deregister_frame_info (__EH_FRAME_BEGIN__);\n#endif\n}\n\n#if defined(USE_EH_FRAME_REGISTRY) \\\n || defined(JCR_SECTION_NAME) \\\n || defined(USE_TM_CLONE_REGISTRY)\n/* A helper function for __do_global_ctors, which is in crtend.o. Here\n in crtbegin.o, we can reference a couple of symbols not visible there.\n Plus, since we're before libgcc.a, we have no problems referencing\n functions from there. */\nvoid\n__do_global_ctors_1(void)\n{\n#ifdef USE_EH_FRAME_REGISTRY\n static struct object object;\n if (__register_frame_info)\n __register_frame_info (__EH_FRAME_BEGIN__, &object);\n#endif\n\n#ifdef JCR_SECTION_NAME\n if (__JCR_LIST__[0])\n {\n void (*register_classes) (void *) = _Jv_RegisterClasses;\n __asm (\"\" : \"+r\" (register_classes));\n if (register_classes)\n\tregister_classes (__JCR_LIST__);\n }\n#endif\n\n#if USE_TM_CLONE_REGISTRY\n register_tm_clones ();\n#endif /* USE_TM_CLONE_REGISTRY */\n}\n#endif /* USE_EH_FRAME_REGISTRY || JCR_SECTION_NAME || USE_TM_CLONE_REGISTRY */\n\n#else /* ! INIT_SECTION_ASM_OP && ! HAS_INIT_SECTION */\n#error \"What are you doing with crtstuff.c, then?\"\n#endif\n\n#elif defined(CRT_END) /* ! CRT_BEGIN */\n\n/* No need for .ctors/.dtors section if linker can place them in\n .init_array/.fini_array section. */\n#ifndef USE_INITFINI_ARRAY\n/* Put a word containing zero at the end of each of our two lists of function\n addresses. Note that the words defined here go into the .ctors and .dtors\n sections of the crtend.o file, and since that file is always linked in\n last, these words naturally end up at the very ends of the two lists\n contained in these two sections. */\n\n#ifdef CTOR_LIST_END\nCTOR_LIST_END;\n#elif defined(CTORS_SECTION_ASM_OP)\n/* Hack: force cc1 to switch to .data section early, so that assembling\n __CTOR_LIST__ does not undo our behind-the-back change to .ctors. */\nstatic func_ptr force_to_data[1] __attribute__ ((__used__)) = { };\nasm (CTORS_SECTION_ASM_OP);\nSTATIC func_ptr __CTOR_END__[1]\n __attribute__((aligned(sizeof(func_ptr))))\n = { (func_ptr) 0 };\n#else\nSTATIC func_ptr __CTOR_END__[1]\n __attribute__((section(\".ctors\"), aligned(sizeof(func_ptr))))\n = { (func_ptr) 0 };\n#endif\n\n#ifdef DTOR_LIST_END\nDTOR_LIST_END;\n#elif defined(HIDDEN_DTOR_LIST_END)\n#ifdef DTORS_SECTION_ASM_OP\nasm (DTORS_SECTION_ASM_OP);\n#endif\nfunc_ptr __DTOR_END__[1]\n __attribute__ ((used,\n#ifndef DTORS_SECTION_ASM_OP\n\t\t section(\".dtors\"),\n#endif\n\t\t aligned(sizeof(func_ptr)), visibility (\"hidden\")))\n = { (func_ptr) 0 };\n#elif defined(DTORS_SECTION_ASM_OP)\nasm (DTORS_SECTION_ASM_OP);\nSTATIC func_ptr __DTOR_END__[1]\n __attribute__ ((used, aligned(sizeof(func_ptr))))\n = { (func_ptr) 0 };\n#else\nSTATIC func_ptr __DTOR_END__[1]\n __attribute__((used, section(\".dtors\"), aligned(sizeof(func_ptr))))\n = { (func_ptr) 0 };\n#endif\n#endif /* USE_INITFINI_ARRAY */\n\n#ifdef EH_FRAME_SECTION_NAME\n/* Terminate the frame unwind info section with a 4byte 0 as a sentinel;\n this would be the 'length' field in a real FDE. */\n# if __INT_MAX__ == 2147483647\ntypedef int int32;\n# elif __LONG_MAX__ == 2147483647\ntypedef long int32;\n# elif __SHRT_MAX__ == 2147483647\ntypedef short int32;\n# else\n# error \"Missing a 4 byte integer\"\n# endif\nSTATIC EH_FRAME_SECTION_CONST int32 __FRAME_END__[]\n __attribute__ ((used, section(EH_FRAME_SECTION_NAME),\n\t\t aligned(sizeof(int32))))\n = { 0 };\n#endif /* EH_FRAME_SECTION_NAME */\n\n#ifdef JCR_SECTION_NAME\n/* Null terminate the .jcr section array. */\nSTATIC void *__JCR_END__[1]\n __attribute__ ((used, section(JCR_SECTION_NAME),\n\t\t aligned(sizeof(void *))))\n = { 0 };\n#endif /* JCR_SECTION_NAME */\n\n#if USE_TM_CLONE_REGISTRY\n# ifndef HAVE_GAS_HIDDEN\nstatic\n# endif\nfunc_ptr __TMC_END__[]\n __attribute__((used, section(\".tm_clone_table\"), aligned(sizeof(void *))))\n# ifdef HAVE_GAS_HIDDEN\n __attribute__((__visibility__ (\"hidden\"))) = { };\n# else\n = { 0, 0 };\n# endif\n#endif /* USE_TM_CLONE_REGISTRY */\n\n#ifdef INIT_ARRAY_SECTION_ASM_OP\n\n/* If we are using .init_array, there is nothing to do. */\n\n#elif defined(INIT_SECTION_ASM_OP)\n\n#ifdef OBJECT_FORMAT_ELF\nstatic void __attribute__((used))\n__do_global_ctors_aux (void)\n{\n func_ptr *p;\n for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--)\n (*p) ();\n}\n\n/* Stick a call to __do_global_ctors_aux into the .init section. */\nCRT_CALL_STATIC_FUNCTION (INIT_SECTION_ASM_OP, __do_global_ctors_aux)\n#else /* OBJECT_FORMAT_ELF */\n\n/* Stick the real initialization code, followed by a normal sort of\n function epilogue at the very end of the .init section for this\n entire root executable file or for this entire shared library file.\n\n Note that we use some tricks here to get *just* the body and just\n a function epilogue (but no function prologue) into the .init\n section of the crtend.o file. Specifically, we switch to the .text\n section, start to define a function, and then we switch to the .init\n section just before the body code.\n\n Earlier on, we put the corresponding function prologue into the .init\n section of the crtbegin.o file (which will be linked in first).\n\n Note that we want to invoke all constructors for C++ file-scope static-\n storage objects AFTER any other possible initialization actions which\n may be performed by the code in the .init section contributions made by\n other libraries, etc. That's because those other initializations may\n include setup operations for very primitive things (e.g. initializing\n the state of the floating-point coprocessor, etc.) which should be done\n before we start to execute any of the user's code. */\n\nstatic void\n__do_global_ctors_aux (void)\t/* prologue goes in .text section */\n{\n asm (INIT_SECTION_ASM_OP);\n DO_GLOBAL_CTORS_BODY;\n atexit (__do_global_dtors);\n}\t\t\t\t/* epilogue and body go in .init section */\n\nFORCE_CODE_SECTION_ALIGN\nasm (TEXT_SECTION_ASM_OP);\n\n#endif /* OBJECT_FORMAT_ELF */\n\n#elif defined(HAS_INIT_SECTION) /* ! INIT_SECTION_ASM_OP */\n\nextern void __do_global_ctors (void);\n\n/* This case is used by the Irix 6 port, which supports named sections but\n not an SVR4-style .init section. __do_global_ctors can be non-static\n in this case because we protect it with -hidden_symbol. */\nvoid\n__do_global_ctors (void)\n{\n func_ptr *p;\n#if defined(USE_EH_FRAME_REGISTRY) \\\n || defined(JCR_SECTION_NAME) \\\n || defined(USE_TM_CLONE_REGISTRY)\n __do_global_ctors_1();\n#endif\n for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--)\n (*p) ();\n}\n\n#else /* ! INIT_SECTION_ASM_OP && ! HAS_INIT_SECTION */\n#error \"What are you doing with crtstuff.c, then?\"\n#endif\n\n#else /* ! CRT_BEGIN && ! CRT_END */\n#error \"One of CRT_BEGIN or CRT_END must be defined.\"\n#endif\n" + }, + { + "id": "share/licenses/gcc/COPYING3", + "kind": "license", + "repository": "https://github.com/napi-rs/cross-toolchain", + "revision": "9cd8dda8e1798b7ce74bbba900cd8c6767afa37f", + "git_blob": "94a9ed024d3859793618152ea559a168bbcbb5e2", + "sha256": "8ceb4b9ee5adedde47b31e975c1d90c73ad27b6b165a1dcd80c7c545eb65b903", + "bytes": 35147, + "path": "share/licenses/gcc/COPYING3", + "text": " GNU GENERAL PUBLIC LICENSE\n Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. \n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n Preamble\n\n The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works. By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users. We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors. You can apply it to\nyour programs, too.\n\n When we speak of free software, we are referring to freedom, not\nprice. Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights. Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received. You must make sure that they, too, receive\nor can get the source code. And you must show them these terms so they\nknow their rights.\n\n Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software. For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so. This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software. The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable. Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts. If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary. To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n The precise terms and conditions for copying, distribution and\nmodification follow.\n\n TERMS AND CONDITIONS\n\n 0. Definitions.\n\n \"This License\" refers to version 3 of the GNU General Public License.\n\n \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n \"The Program\" refers to any copyrightable work licensed under this\nLicense. Each licensee is addressed as \"you\". \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy. The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy. Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies. Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License. If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n 1. Source Code.\n\n The \"source code\" for a work means the preferred form of the work\nfor making modifications to it. \"Object code\" means any non-source\nform of a work.\n\n A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form. A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities. However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work. For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n The Corresponding Source for a work in source code form is that\nsame work.\n\n 2. Basic Permissions.\n\n All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met. This License explicitly affirms your unlimited\npermission to run the unmodified Program. The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work. This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force. You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright. Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n Conveying under any other circumstances is permitted solely under\nthe conditions stated below. Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n 3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n 4. Conveying Verbatim Copies.\n\n You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n 5. Conveying Modified Source Versions.\n\n You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n a) The work must carry prominent notices stating that you modified\n it, and giving a relevant date.\n\n b) The work must carry prominent notices stating that it is\n released under this License and any conditions added under section\n 7. This requirement modifies the requirement in section 4 to\n \"keep intact all notices\".\n\n c) You must license the entire work, as a whole, under this\n License to anyone who comes into possession of a copy. This\n License will therefore apply, along with any applicable section 7\n additional terms, to the whole of the work, and all its parts,\n regardless of how they are packaged. This License gives no\n permission to license the work in any other way, but it does not\n invalidate such permission if you have separately received it.\n\n d) If the work has interactive user interfaces, each must display\n Appropriate Legal Notices; however, if the Program has interactive\n interfaces that do not display Appropriate Legal Notices, your\n work need not make them do so.\n\n A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit. Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n 6. Conveying Non-Source Forms.\n\n You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n a) Convey the object code in, or embodied in, a physical product\n (including a physical distribution medium), accompanied by the\n Corresponding Source fixed on a durable physical medium\n customarily used for software interchange.\n\n b) Convey the object code in, or embodied in, a physical product\n (including a physical distribution medium), accompanied by a\n written offer, valid for at least three years and valid for as\n long as you offer spare parts or customer support for that product\n model, to give anyone who possesses the object code either (1) a\n copy of the Corresponding Source for all the software in the\n product that is covered by this License, on a durable physical\n medium customarily used for software interchange, for a price no\n more than your reasonable cost of physically performing this\n conveying of source, or (2) access to copy the\n Corresponding Source from a network server at no charge.\n\n c) Convey individual copies of the object code with a copy of the\n written offer to provide the Corresponding Source. This\n alternative is allowed only occasionally and noncommercially, and\n only if you received the object code with such an offer, in accord\n with subsection 6b.\n\n d) Convey the object code by offering access from a designated\n place (gratis or for a charge), and offer equivalent access to the\n Corresponding Source in the same way through the same place at no\n further charge. You need not require recipients to copy the\n Corresponding Source along with the object code. If the place to\n copy the object code is a network server, the Corresponding Source\n may be on a different server (operated by you or a third party)\n that supports equivalent copying facilities, provided you maintain\n clear directions next to the object code saying where to find the\n Corresponding Source. Regardless of what server hosts the\n Corresponding Source, you remain obligated to ensure that it is\n available for as long as needed to satisfy these requirements.\n\n e) Convey the object code using peer-to-peer transmission, provided\n you inform other peers where the object code and Corresponding\n Source of the work are being offered to the general public at no\n charge under subsection 6d.\n\n A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling. In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage. For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product. A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source. The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information. But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed. Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n 7. Additional Terms.\n\n \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law. If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit. (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.) You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n a) Disclaiming warranty or limiting liability differently from the\n terms of sections 15 and 16 of this License; or\n\n b) Requiring preservation of specified reasonable legal notices or\n author attributions in that material or in the Appropriate Legal\n Notices displayed by works containing it; or\n\n c) Prohibiting misrepresentation of the origin of that material, or\n requiring that modified versions of such material be marked in\n reasonable ways as different from the original version; or\n\n d) Limiting the use for publicity purposes of names of licensors or\n authors of the material; or\n\n e) Declining to grant rights under trademark law for use of some\n trade names, trademarks, or service marks; or\n\n f) Requiring indemnification of licensors and authors of that\n material by anyone who conveys the material (or modified versions of\n it) with contractual assumptions of liability to the recipient, for\n any liability that these contractual assumptions directly impose on\n those licensors and authors.\n\n All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10. If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term. If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n 8. Termination.\n\n You may not propagate or modify a covered work except as expressly\nprovided under this License. Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License. If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n 9. Acceptance Not Required for Having Copies.\n\n You are not required to accept this License in order to receive or\nrun a copy of the Program. Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance. However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work. These actions infringe copyright if you do\nnot accept this License. Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n 10. Automatic Licensing of Downstream Recipients.\n\n Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License. You are not responsible\nfor enforcing compliance by third parties with this License.\n\n An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations. If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License. For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n 11. Patents.\n\n A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based. The\nwork thus licensed is called the contributor's \"contributor version\".\n\n A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version. For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement). To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients. \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License. You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n 12. No Surrender of Others' Freedom.\n\n If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License. If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all. For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n 13. Use with the GNU Affero General Public License.\n\n Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work. The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n 14. Revised Versions of this License.\n\n The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time. Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n Each version is given a distinguishing version number. If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation. If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n Later license versions may give you additional or different\npermissions. However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n 15. Disclaimer of Warranty.\n\n THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n 16. Limitation of Liability.\n\n IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n 17. Interpretation of Sections 15 and 16.\n\n If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n END OF TERMS AND CONDITIONS\n\n How to Apply These Terms to Your New Programs\n\n If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n To do so, attach the following notices to the program. It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n \n Copyright (C) \n\n This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program. If not, see .\n\nAlso add information on how to contact you by electronic and paper mail.\n\n If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n Copyright (C) \n This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n This is free software, and you are welcome to redistribute it\n under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License. Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n.\n\n The GNU General Public License does not permit incorporating your program\ninto proprietary programs. If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library. If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License. But first, please read\n.\n" + }, + { + "id": "share/licenses/gcc/COPYING.RUNTIME", + "kind": "license", + "repository": "https://github.com/napi-rs/cross-toolchain", + "revision": "9cd8dda8e1798b7ce74bbba900cd8c6767afa37f", + "git_blob": "e1b3c69c179dfaff5744ea4bf853e6b0d90c9ef9", + "sha256": "9d6b43ce4d8de0c878bf16b54d8e7a10d9bd42b75178153e3af6a815bdc90f74", + "bytes": 3324, + "path": "share/licenses/gcc/COPYING.RUNTIME", + "text": "GCC RUNTIME LIBRARY EXCEPTION\n\nVersion 3.1, 31 March 2009\n\nCopyright (C) 2009 Free Software Foundation, Inc. \n\nEveryone is permitted to copy and distribute verbatim copies of this\nlicense document, but changing it is not allowed.\n\nThis GCC Runtime Library Exception (\"Exception\") is an additional\npermission under section 7 of the GNU General Public License, version\n3 (\"GPLv3\"). It applies to a given file (the \"Runtime Library\") that\nbears a notice placed by the copyright holder of the file stating that\nthe file is governed by GPLv3 along with this Exception.\n\nWhen you use GCC to compile a program, GCC may combine portions of\ncertain GCC header files and runtime libraries with the compiled\nprogram. The purpose of this Exception is to allow compilation of\nnon-GPL (including proprietary) programs to use, in this way, the\nheader files and runtime libraries covered by this Exception.\n\n0. Definitions.\n\nA file is an \"Independent Module\" if it either requires the Runtime\nLibrary for execution after a Compilation Process, or makes use of an\ninterface provided by the Runtime Library, but is not otherwise based\non the Runtime Library.\n\n\"GCC\" means a version of the GNU Compiler Collection, with or without\nmodifications, governed by version 3 (or a specified later version) of\nthe GNU General Public License (GPL) with the option of using any\nsubsequent versions published by the FSF.\n\n\"GPL-compatible Software\" is software whose conditions of propagation,\nmodification and use would permit combination with GCC in accord with\nthe license of GCC.\n\n\"Target Code\" refers to output from any compiler for a real or virtual\ntarget processor architecture, in executable form or suitable for\ninput to an assembler, loader, linker and/or execution\nphase. Notwithstanding that, Target Code does not include data in any\nformat that is used as a compiler intermediate representation, or used\nfor producing a compiler intermediate representation.\n\nThe \"Compilation Process\" transforms code entirely represented in\nnon-intermediate languages designed for human-written code, and/or in\nJava Virtual Machine byte code, into Target Code. Thus, for example,\nuse of source code generators and preprocessors need not be considered\npart of the Compilation Process, since the Compilation Process can be\nunderstood as starting with the output of the generators or\npreprocessors.\n\nA Compilation Process is \"Eligible\" if it is done using GCC, alone or\nwith other GPL-compatible software, or if it is done without using any\nwork based on GCC. For example, using non-GPL-compatible Software to\noptimize any GCC intermediate representations would not qualify as an\nEligible Compilation Process.\n\n1. Grant of Additional Permission.\n\nYou have permission to propagate a work of Target Code formed by\ncombining the Runtime Library with Independent Modules, even if such\npropagation would otherwise violate the terms of GPLv3, provided that\nall Target Code was generated by Eligible Compilation Processes. You\nmay then convey such a combination under terms of your choice,\nconsistent with the licensing of the Independent Modules.\n\n2. No Weakening of GCC Copyleft.\n\nThe availability of this Exception does not imply any general\npresumption that third-party software is unaffected by the copyleft\nrequirements of the license of GCC.\n\n" + }, + { + "id": "share/licenses/glibc/COPYING.LIB", + "kind": "license", + "repository": "https://github.com/napi-rs/cross-toolchain", + "revision": "9cd8dda8e1798b7ce74bbba900cd8c6767afa37f", + "git_blob": "cf9b6b997263b8a4e007aa1edd4b16437f4583ca", + "sha256": "ca0061fc1381a3ab242310e4b3f56389f28e3d460eb2fd822ed7a21c6f030532", + "bytes": 26536, + "path": "share/licenses/glibc/COPYING.LIB", + "text": "\n GNU LESSER GENERAL PUBLIC LICENSE\n Version 2.1, February 1999\n\n Copyright (C) 1991, 1999 Free Software Foundation, Inc.\n 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n[This is the first released version of the Lesser GPL. It also counts\n as the successor of the GNU Library Public License, version 2, hence\n the version number 2.1.]\n\n Preamble\n\n The licenses for most software are designed to take away your\nfreedom to share and change it. By contrast, the GNU General Public\nLicenses are intended to guarantee your freedom to share and change\nfree software--to make sure the software is free for all its users.\n\n This license, the Lesser General Public License, applies to some\nspecially designated software packages--typically libraries--of the\nFree Software Foundation and other authors who decide to use it. You\ncan use it too, but we suggest you first think carefully about whether\nthis license or the ordinary General Public License is the better\nstrategy to use in any particular case, based on the explanations\nbelow.\n\n When we speak of free software, we are referring to freedom of use,\nnot price. Our General Public Licenses are designed to make sure that\nyou have the freedom to distribute copies of free software (and charge\nfor this service if you wish); that you receive source code or can get\nit if you want it; that you can change the software and use pieces of\nit in new free programs; and that you are informed that you can do\nthese things.\n\n To protect your rights, we need to make restrictions that forbid\ndistributors to deny you these rights or to ask you to surrender these\nrights. These restrictions translate to certain responsibilities for\nyou if you distribute copies of the library or if you modify it.\n\n For example, if you distribute copies of the library, whether gratis\nor for a fee, you must give the recipients all the rights that we gave\nyou. You must make sure that they, too, receive or can get the source\ncode. If you link other code with the library, you must provide\ncomplete object files to the recipients, so that they can relink them\nwith the library after making changes to the library and recompiling\nit. And you must show them these terms so they know their rights.\n\n We protect your rights with a two-step method: (1) we copyright the\nlibrary, and (2) we offer you this license, which gives you legal\npermission to copy, distribute and/or modify the library.\n\n To protect each distributor, we want to make it very clear that\nthere is no warranty for the free library. Also, if the library is\nmodified by someone else and passed on, the recipients should know\nthat what they have is not the original version, so that the original\nauthor's reputation will not be affected by problems that might be\nintroduced by others.\n^L\n Finally, software patents pose a constant threat to the existence of\nany free program. We wish to make sure that a company cannot\neffectively restrict the users of a free program by obtaining a\nrestrictive license from a patent holder. Therefore, we insist that\nany patent license obtained for a version of the library must be\nconsistent with the full freedom of use specified in this license.\n\n Most GNU software, including some libraries, is covered by the\nordinary GNU General Public License. This license, the GNU Lesser\nGeneral Public License, applies to certain designated libraries, and\nis quite different from the ordinary General Public License. We use\nthis license for certain libraries in order to permit linking those\nlibraries into non-free programs.\n\n When a program is linked with a library, whether statically or using\na shared library, the combination of the two is legally speaking a\ncombined work, a derivative of the original library. The ordinary\nGeneral Public License therefore permits such linking only if the\nentire combination fits its criteria of freedom. The Lesser General\nPublic License permits more lax criteria for linking other code with\nthe library.\n\n We call this license the \"Lesser\" General Public License because it\ndoes Less to protect the user's freedom than the ordinary General\nPublic License. It also provides other free software developers Less\nof an advantage over competing non-free programs. These disadvantages\nare the reason we use the ordinary General Public License for many\nlibraries. However, the Lesser license provides advantages in certain\nspecial circumstances.\n\n For example, on rare occasions, there may be a special need to\nencourage the widest possible use of a certain library, so that it\nbecomes a de-facto standard. To achieve this, non-free programs must\nbe allowed to use the library. A more frequent case is that a free\nlibrary does the same job as widely used non-free libraries. In this\ncase, there is little to gain by limiting the free library to free\nsoftware only, so we use the Lesser General Public License.\n\n In other cases, permission to use a particular library in non-free\nprograms enables a greater number of people to use a large body of\nfree software. For example, permission to use the GNU C Library in\nnon-free programs enables many more people to use the whole GNU\noperating system, as well as its variant, the GNU/Linux operating\nsystem.\n\n Although the Lesser General Public License is Less protective of the\nusers' freedom, it does ensure that the user of a program that is\nlinked with the Library has the freedom and the wherewithal to run\nthat program using a modified version of the Library.\n\n The precise terms and conditions for copying, distribution and\nmodification follow. Pay close attention to the difference between a\n\"work based on the library\" and a \"work that uses the library\". The\nformer contains code derived from the library, whereas the latter must\nbe combined with the library in order to run.\n^L\n GNU LESSER GENERAL PUBLIC LICENSE\n TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\n 0. This License Agreement applies to any software library or other\nprogram which contains a notice placed by the copyright holder or\nother authorized party saying it may be distributed under the terms of\nthis Lesser General Public License (also called \"this License\").\nEach licensee is addressed as \"you\".\n\n A \"library\" means a collection of software functions and/or data\nprepared so as to be conveniently linked with application programs\n(which use some of those functions and data) to form executables.\n\n The \"Library\", below, refers to any such software library or work\nwhich has been distributed under these terms. A \"work based on the\nLibrary\" means either the Library or any derivative work under\ncopyright law: that is to say, a work containing the Library or a\nportion of it, either verbatim or with modifications and/or translated\nstraightforwardly into another language. (Hereinafter, translation is\nincluded without limitation in the term \"modification\".)\n\n \"Source code\" for a work means the preferred form of the work for\nmaking modifications to it. For a library, complete source code means\nall the source code for all modules it contains, plus any associated\ninterface definition files, plus the scripts used to control\ncompilation and installation of the library.\n\n Activities other than copying, distribution and modification are not\ncovered by this License; they are outside its scope. The act of\nrunning a program using the Library is not restricted, and output from\nsuch a program is covered only if its contents constitute a work based\non the Library (independent of the use of the Library in a tool for\nwriting it). Whether that is true depends on what the Library does\nand what the program that uses the Library does.\n\n 1. You may copy and distribute verbatim copies of the Library's\ncomplete source code as you receive it, in any medium, provided that\nyou conspicuously and appropriately publish on each copy an\nappropriate copyright notice and disclaimer of warranty; keep intact\nall the notices that refer to this License and to the absence of any\nwarranty; and distribute a copy of this License along with the\nLibrary.\n\n You may charge a fee for the physical act of transferring a copy,\nand you may at your option offer warranty protection in exchange for a\nfee.\n\f\n 2. You may modify your copy or copies of the Library or any portion\nof it, thus forming a work based on the Library, and copy and\ndistribute such modifications or work under the terms of Section 1\nabove, provided that you also meet all of these conditions:\n\n a) The modified work must itself be a software library.\n\n b) You must cause the files modified to carry prominent notices\n stating that you changed the files and the date of any change.\n\n c) You must cause the whole of the work to be licensed at no\n charge to all third parties under the terms of this License.\n\n d) If a facility in the modified Library refers to a function or a\n table of data to be supplied by an application program that uses\n the facility, other than as an argument passed when the facility\n is invoked, then you must make a good faith effort to ensure that,\n in the event an application does not supply such function or\n table, the facility still operates, and performs whatever part of\n its purpose remains meaningful.\n\n (For example, a function in a library to compute square roots has\n a purpose that is entirely well-defined independent of the\n application. Therefore, Subsection 2d requires that any\n application-supplied function or table used by this function must\n be optional: if the application does not supply it, the square\n root function must still compute square roots.)\n\nThese requirements apply to the modified work as a whole. If\nidentifiable sections of that work are not derived from the Library,\nand can be reasonably considered independent and separate works in\nthemselves, then this License, and its terms, do not apply to those\nsections when you distribute them as separate works. But when you\ndistribute the same sections as part of a whole which is a work based\non the Library, the distribution of the whole must be on the terms of\nthis License, whose permissions for other licensees extend to the\nentire whole, and thus to each and every part regardless of who wrote\nit.\n\nThus, it is not the intent of this section to claim rights or contest\nyour rights to work written entirely by you; rather, the intent is to\nexercise the right to control the distribution of derivative or\ncollective works based on the Library.\n\nIn addition, mere aggregation of another work not based on the Library\nwith the Library (or with a work based on the Library) on a volume of\na storage or distribution medium does not bring the other work under\nthe scope of this License.\n\n 3. You may opt to apply the terms of the ordinary GNU General Public\nLicense instead of this License to a given copy of the Library. To do\nthis, you must alter all the notices that refer to this License, so\nthat they refer to the ordinary GNU General Public License, version 2,\ninstead of to this License. (If a newer version than version 2 of the\nordinary GNU General Public License has appeared, then you can specify\nthat version instead if you wish.) Do not make any other change in\nthese notices.\n^L\n Once this change is made in a given copy, it is irreversible for\nthat copy, so the ordinary GNU General Public License applies to all\nsubsequent copies and derivative works made from that copy.\n\n This option is useful when you wish to copy part of the code of\nthe Library into a program that is not a library.\n\n 4. You may copy and distribute the Library (or a portion or\nderivative of it, under Section 2) in object code or executable form\nunder the terms of Sections 1 and 2 above provided that you accompany\nit with the complete corresponding machine-readable source code, which\nmust be distributed under the terms of Sections 1 and 2 above on a\nmedium customarily used for software interchange.\n\n If distribution of object code is made by offering access to copy\nfrom a designated place, then offering equivalent access to copy the\nsource code from the same place satisfies the requirement to\ndistribute the source code, even though third parties are not\ncompelled to copy the source along with the object code.\n\n 5. A program that contains no derivative of any portion of the\nLibrary, but is designed to work with the Library by being compiled or\nlinked with it, is called a \"work that uses the Library\". Such a\nwork, in isolation, is not a derivative work of the Library, and\ntherefore falls outside the scope of this License.\n\n However, linking a \"work that uses the Library\" with the Library\ncreates an executable that is a derivative of the Library (because it\ncontains portions of the Library), rather than a \"work that uses the\nlibrary\". The executable is therefore covered by this License.\nSection 6 states terms for distribution of such executables.\n\n When a \"work that uses the Library\" uses material from a header file\nthat is part of the Library, the object code for the work may be a\nderivative work of the Library even though the source code is not.\nWhether this is true is especially significant if the work can be\nlinked without the Library, or if the work is itself a library. The\nthreshold for this to be true is not precisely defined by law.\n\n If such an object file uses only numerical parameters, data\nstructure layouts and accessors, and small macros and small inline\nfunctions (ten lines or less in length), then the use of the object\nfile is unrestricted, regardless of whether it is legally a derivative\nwork. (Executables containing this object code plus portions of the\nLibrary will still fall under Section 6.)\n\n Otherwise, if the work is a derivative of the Library, you may\ndistribute the object code for the work under the terms of Section 6.\nAny executables containing that work also fall under Section 6,\nwhether or not they are linked directly with the Library itself.\n^L\n 6. As an exception to the Sections above, you may also combine or\nlink a \"work that uses the Library\" with the Library to produce a\nwork containing portions of the Library, and distribute that work\nunder terms of your choice, provided that the terms permit\nmodification of the work for the customer's own use and reverse\nengineering for debugging such modifications.\n\n You must give prominent notice with each copy of the work that the\nLibrary is used in it and that the Library and its use are covered by\nthis License. You must supply a copy of this License. If the work\nduring execution displays copyright notices, you must include the\ncopyright notice for the Library among them, as well as a reference\ndirecting the user to the copy of this License. Also, you must do one\nof these things:\n\n a) Accompany the work with the complete corresponding\n machine-readable source code for the Library including whatever\n changes were used in the work (which must be distributed under\n Sections 1 and 2 above); and, if the work is an executable linked\n with the Library, with the complete machine-readable \"work that\n uses the Library\", as object code and/or source code, so that the\n user can modify the Library and then relink to produce a modified\n executable containing the modified Library. (It is understood\n that the user who changes the contents of definitions files in the\n Library will not necessarily be able to recompile the application\n to use the modified definitions.)\n\n b) Use a suitable shared library mechanism for linking with the\n Library. A suitable mechanism is one that (1) uses at run time a\n copy of the library already present on the user's computer system,\n rather than copying library functions into the executable, and (2)\n will operate properly with a modified version of the library, if\n the user installs one, as long as the modified version is\n interface-compatible with the version that the work was made with.\n\n c) Accompany the work with a written offer, valid for at least\n three years, to give the same user the materials specified in\n Subsection 6a, above, for a charge no more than the cost of\n performing this distribution.\n\n d) If distribution of the work is made by offering access to copy\n from a designated place, offer equivalent access to copy the above\n specified materials from the same place.\n\n e) Verify that the user has already received a copy of these\n materials or that you have already sent this user a copy.\n\n For an executable, the required form of the \"work that uses the\nLibrary\" must include any data and utility programs needed for\nreproducing the executable from it. However, as a special exception,\nthe materials to be distributed need not include anything that is\nnormally distributed (in either source or binary form) with the major\ncomponents (compiler, kernel, and so on) of the operating system on\nwhich the executable runs, unless that component itself accompanies\nthe executable.\n\n It may happen that this requirement contradicts the license\nrestrictions of other proprietary libraries that do not normally\naccompany the operating system. Such a contradiction means you cannot\nuse both them and the Library together in an executable that you\ndistribute.\n^L\n 7. You may place library facilities that are a work based on the\nLibrary side-by-side in a single library together with other library\nfacilities not covered by this License, and distribute such a combined\nlibrary, provided that the separate distribution of the work based on\nthe Library and of the other library facilities is otherwise\npermitted, and provided that you do these two things:\n\n a) Accompany the combined library with a copy of the same work\n based on the Library, uncombined with any other library\n facilities. This must be distributed under the terms of the\n Sections above.\n\n b) Give prominent notice with the combined library of the fact\n that part of it is a work based on the Library, and explaining\n where to find the accompanying uncombined form of the same work.\n\n 8. You may not copy, modify, sublicense, link with, or distribute\nthe Library except as expressly provided under this License. Any\nattempt otherwise to copy, modify, sublicense, link with, or\ndistribute the Library is void, and will automatically terminate your\nrights under this License. However, parties who have received copies,\nor rights, from you under this License will not have their licenses\nterminated so long as such parties remain in full compliance.\n\n 9. You are not required to accept this License, since you have not\nsigned it. However, nothing else grants you permission to modify or\ndistribute the Library or its derivative works. These actions are\nprohibited by law if you do not accept this License. Therefore, by\nmodifying or distributing the Library (or any work based on the\nLibrary), you indicate your acceptance of this License to do so, and\nall its terms and conditions for copying, distributing or modifying\nthe Library or works based on it.\n\n 10. Each time you redistribute the Library (or any work based on the\nLibrary), the recipient automatically receives a license from the\noriginal licensor to copy, distribute, link with or modify the Library\nsubject to these terms and conditions. You may not impose any further\nrestrictions on the recipients' exercise of the rights granted herein.\nYou are not responsible for enforcing compliance by third parties with\nthis License.\n^L\n 11. If, as a consequence of a court judgment or allegation of patent\ninfringement or for any other reason (not limited to patent issues),\nconditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License. If you cannot\ndistribute so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you\nmay not distribute the Library at all. For example, if a patent\nlicense would not permit royalty-free redistribution of the Library by\nall those who receive copies directly or indirectly through you, then\nthe only way you could satisfy both it and this License would be to\nrefrain entirely from distribution of the Library.\n\nIf any portion of this section is held invalid or unenforceable under\nany particular circumstance, the balance of the section is intended to\napply, and the section as a whole is intended to apply in other\ncircumstances.\n\nIt is not the purpose of this section to induce you to infringe any\npatents or other property right claims or to contest validity of any\nsuch claims; this section has the sole purpose of protecting the\nintegrity of the free software distribution system which is\nimplemented by public license practices. Many people have made\ngenerous contributions to the wide range of software distributed\nthrough that system in reliance on consistent application of that\nsystem; it is up to the author/donor to decide if he or she is willing\nto distribute software through any other system and a licensee cannot\nimpose that choice.\n\nThis section is intended to make thoroughly clear what is believed to\nbe a consequence of the rest of this License.\n\n 12. If the distribution and/or use of the Library is restricted in\ncertain countries either by patents or by copyrighted interfaces, the\noriginal copyright holder who places the Library under this License\nmay add an explicit geographical distribution limitation excluding those\ncountries, so that distribution is permitted only in or among\ncountries not thus excluded. In such case, this License incorporates\nthe limitation as if written in the body of this License.\n\n 13. The Free Software Foundation may publish revised and/or new\nversions of the Lesser General Public License from time to time.\nSuch new versions will be similar in spirit to the present version,\nbut may differ in detail to address new problems or concerns.\n\nEach version is given a distinguishing version number. If the Library\nspecifies a version number of this License which applies to it and\n\"any later version\", you have the option of following the terms and\nconditions either of that version or of any later version published by\nthe Free Software Foundation. If the Library does not specify a\nlicense version number, you may choose any version ever published by\nthe Free Software Foundation.\n^L\n 14. If you wish to incorporate parts of the Library into other free\nprograms whose distribution conditions are incompatible with these,\nwrite to the author to ask for permission. For software which is\ncopyrighted by the Free Software Foundation, write to the Free\nSoftware Foundation; we sometimes make exceptions for this. Our\ndecision will be guided by the two goals of preserving the free status\nof all derivatives of our free software and of promoting the sharing\nand reuse of software generally.\n\n NO WARRANTY\n\n 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO\nWARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.\nEXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR\nOTHER PARTIES PROVIDE THE LIBRARY \"AS IS\" WITHOUT WARRANTY OF ANY\nKIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE\nLIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME\nTHE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN\nWRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY\nAND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU\nFOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR\nCONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE\nLIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING\nRENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A\nFAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF\nSUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\nDAMAGES.\n\n END OF TERMS AND CONDITIONS\n^L\n How to Apply These Terms to Your New Libraries\n\n If you develop a new library, and you want it to be of the greatest\npossible use to the public, we recommend making it free software that\neveryone can redistribute and change. You can do so by permitting\nredistribution under these terms (or, alternatively, under the terms\nof the ordinary General Public License).\n\n To apply these terms, attach the following notices to the library.\nIt is safest to attach them to the start of each source file to most\neffectively convey the exclusion of warranty; and each file should\nhave at least the \"copyright\" line and a pointer to where the full\nnotice is found.\n\n\n \n Copyright (C) \n\n This library is free software; you can redistribute it and/or\n modify it under the terms of the GNU Lesser General Public\n License as published by the Free Software Foundation; either\n version 2.1 of the License, or (at your option) any later version.\n\n This library is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public\n License along with this library; if not, write to the Free Software\n Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n\nAlso add information on how to contact you by electronic and paper mail.\n\nYou should also get your employer (if you work as a programmer) or\nyour school, if any, to sign a \"copyright disclaimer\" for the library,\nif necessary. Here is a sample; alter the names:\n\n Yoyodyne, Inc., hereby disclaims all copyright interest in the\n library `Frob' (a library for tweaking knobs) written by James\n Random Hacker.\n\n , 1 April 1990\n Ty Coon, President of Vice\n\nThat's all there is to it!\n\n\n" + } + ], + "scope": "Reviewed upstream source grants and exact SDK license documents for the observed GNU NAPI link profile. Not a claim of bit-reproducible SDK compilation, an ARM crosstool-NG recipe identity, or historical package clearance.", + "glibc_terms": "LGPL-2.1-or-later with the file-level unlimited permission to link and distribute the compiled file with other programs. This permission is stated in each selected source; it is not a blanket exception for glibc, and does not cover unlinked source distribution.", + "gcc_terms": "GPL-3.0-or-later WITH GCC-exception-3.1 for crtbeginS.o/crtendS.o from libgcc/crtstuff.c. The exception permits combining with Independent Modules only when all Target Code was generated by Eligible Compilation Processes.", + "compilation_process": "Ktav Rust sources and registry crates are compiled by the pinned rustc 1.99.1 LLVM toolchain, without GCC intermediate representation. The pinned SDK GCC 4.8.5 driver links the resulting native Rust object and libcompiler_builtins with GCC/glibc CRT inputs using its GNU linker. The captured final link has no external compiler plugins, specs replacement, response files or LTO plugin arguments. Rust/LLVM is a non-GCC compilation path; GCC/binutils are GPL-compatible tools. This assessment does not infer the build recipe of the prebuilt SDK or extend to unknown inputs or modified compilation tools." +} diff --git a/ci/test_napi_gnu_runtime_notices.py b/ci/test_napi_gnu_runtime_notices.py new file mode 100644 index 0000000..5934d3c --- /dev/null +++ b/ci/test_napi_gnu_runtime_notices.py @@ -0,0 +1,135 @@ +"""Проверить fail-closed GNU runtime profile без запуска toolchain.""" + +import base64 +import copy +import gzip +import importlib.util +import json +from pathlib import Path +import tempfile +import unittest + +ROOT = Path(__file__).resolve().parents[1] +SPEC = importlib.util.spec_from_file_location('gnu_runtime', ROOT / 'scripts/napi_gnu_runtime_notices.py') +RUNTIME = importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(RUNTIME) +TARGET = 'x86_64-unknown-linux-gnu' + + +class RuntimeNoticeTests(unittest.TestCase): + def fixture(self, target=TARGET): + notice = RUNTIME.runtime_notice(ROOT, target) + selected = notice['sdk_inputs'] + inputs = [] + for role, entries in [('compiler', [selected['compiler']]), ('configuration', [selected['configuration']]), ('runtime', selected['runtime_inputs'])]: + inputs.extend({'role': role, 'path': item['path'], 'bytes': item['bytes'], 'sha256': item['sha256']} for item in entries) + own = 'ktav_napi.ktav_napi.abcdef-cgu.0.rcgu.o' + report = {'target': target, 'sdk_input_profile': {'repository_revision': notice['sdk_revision'], 'inputs': inputs}, 'sdk_input_catalog_sha256': RUNTIME.CATALOG_SHA256, 'compiler_sha256': selected['compiler']['sha256'], 'cross_toolchain_version': '1.0.3', 'archive_members': copy.deepcopy(RUNTIME.MEMBERS), 'loaded_objects': sorted(RUNTIME.CRT | {own})} + documents = [{'path': item['id'], 'sha256': item['sha256'], 'raw_bytes_base64': base64.b64encode(item['text'].encode('utf-8')).decode('ascii')} for item in notice['materials'] if item['id'] in RUNTIME.DOCUMENTS] + command = {'target': target, 'compiler': '/sdk/' + target + '/bin/' + target + '-gcc', 'output': '/build/libktav_napi.so', 'arguments': ['/build/' + own, '-Wl,-Bstatic', '/rust/libcompiler_builtins-abcdef.rlib', '-Wl,-Bdynamic', '-lc', '-L', '/rust', '-o', '/build/libktav_napi.so', '-shared', '-nodefaultlibs']} + rustc = 'rustc 1.99.1 (fixture)\nrelease: 1.99.1\nLLVM version: 23.0.0\n' + compiler = target + '-gcc (GCC) 4.8.5\n' + if target == 'aarch64-unknown-linux-gnu': + command['arguments'].append('-Wl,--fix-cortex-a53-843419') + return notice, report, documents, command, rustc, compiler + + def test_both_exact_target_profiles_pass(self): + for target in RUNTIME.TARGETS: + with self.subTest(target=target): + RUNTIME.verify_link(*self.fixture(target)) + + def test_target_specific_sources_and_full_documents_are_present(self): + for target, architecture in RUNTIME.TARGETS.items(): + notice = RUNTIME.runtime_notice(ROOT, target) + ids = {item['id'] for item in notice['materials']} + self.assertEqual(len(ids), 8) + self.assertIn('glibc/' + architecture + '/crti.S', ids) + self.assertIn('glibc/' + architecture + '/crtn.S', ids) + self.assertTrue(set(RUNTIME.DOCUMENTS) <= ids) + data, plain = RUNTIME.notice_bytes(notice) + self.assertEqual(json.loads(data), notice) + for item in notice['materials']: + self.assertIn(item['text'].encode('utf-8'), plain) + + def test_unknown_target_is_rejected(self): + with self.assertRaisesRegex(ValueError, 'unreviewed GNU runtime target'): + RUNTIME.runtime_notice(ROOT, 'unknown') + + def test_target_mismatch_is_rejected(self): + args = list(self.fixture()) + args[1]['target'] = 'aarch64-unknown-linux-gnu' + with self.assertRaisesRegex(ValueError, 'target differs'): + RUNTIME.verify_link(*args) + + def test_changed_sdk_input_is_rejected(self): + args = list(self.fixture()) + args[1]['sdk_input_profile']['inputs'][-1]['sha256'] = '0' * 64 + with self.assertRaisesRegex(ValueError, 'actual SDK inputs differ'): + RUNTIME.verify_link(*args) + + def test_unreviewed_archive_member_is_rejected(self): + args = list(self.fixture()) + args[1]['archive_members'].append(['libpthread_nonshared.a', 'unknown.oS']) + with self.assertRaisesRegex(ValueError, 'archive members differ'): + RUNTIME.verify_link(*args) + + def test_missing_crt_is_rejected(self): + args = list(self.fixture()) + args[1]['loaded_objects'].remove('crti.o') + with self.assertRaisesRegex(ValueError, 'loaded objects differ'): + RUNTIME.verify_link(*args) + + def test_missing_gpl3_document_is_rejected(self): + args = list(self.fixture()) + args[2] = [item for item in args[2] if item['path'] != 'share/licenses/gcc/COPYING3'] + with self.assertRaisesRegex(ValueError, 'actual SDK legal document differs'): + RUNTIME.verify_link(*args) + + def test_changed_exception_document_is_rejected(self): + args = list(self.fixture()) + args[2][1]['raw_bytes_base64'] = base64.b64encode(b'changed').decode('ascii') + with self.assertRaisesRegex(ValueError, 'actual SDK legal document differs'): + RUNTIME.verify_link(*args) + + def test_external_compiler_extensions_are_rejected(self): + for argument in ['-fplugin=foreign.so', '-specs=/foreign', '@response', '-flto', '-Wl,-plugin,foreign.so', '-B/foreign']: + with self.subTest(argument=argument): + args = list(self.fixture()) + args[3]['arguments'].append(argument) + with self.assertRaisesRegex(ValueError, 'unreviewed final NAPI link argument'): + RUNTIME.verify_link(*args) + + def test_changed_rust_toolchain_is_rejected(self): + args = list(self.fixture()) + args[4] = args[4].replace('1.99.1', '1.99.2') + with self.assertRaisesRegex(ValueError, 'unreviewed Rust compilation process'): + RUNTIME.verify_link(*args) + + def test_prepare_preserves_cargo_bundle_and_compressed_bytes(self): + with tempfile.TemporaryDirectory() as temporary: + evidence = Path(temporary) + (evidence / 'NOTICE.json').write_text(json.dumps({'cargo_fixture': ['unchanged']}), encoding='utf-8') + RUNTIME.prepare(ROOT, evidence, TARGET) + raw = (evidence / 'NOTICE.json').read_bytes() + bundle = json.loads(raw) + self.assertEqual(bundle['cargo_fixture'], ['unchanged']) + self.assertEqual(bundle['napi_gnu_runtime'], RUNTIME.runtime_notice(ROOT, TARGET)) + self.assertEqual(gzip.decompress((evidence / 'NOTICE.json.gz').read_bytes()), raw) + with self.assertRaisesRegex(ValueError, 'already exists'): + RUNTIME.prepare(ROOT, evidence, TARGET) + + def test_modified_or_missing_material_profile_is_rejected(self): + with tempfile.TemporaryDirectory() as temporary: + root = Path(temporary) + (root / 'ci/licenses').mkdir(parents=True) + (root / 'ci/licenses/napi-gnu-runtime.json').write_text('{}', encoding='utf-8') + (root / 'ci/napi-gnu-sdk-inputs.json').write_bytes((ROOT / 'ci/napi-gnu-sdk-inputs.json').read_bytes()) + with self.assertRaisesRegex(ValueError, 'differs from review'): + RUNTIME.runtime_notice(root, TARGET) + (root / 'ci/licenses/napi-gnu-runtime.json').unlink() + with self.assertRaisesRegex(ValueError, 'missing or symlinked'): + RUNTIME.runtime_notice(root, TARGET) + + +if __name__ == '__main__': + unittest.main() diff --git a/scripts/collect_napi_link_evidence.py b/scripts/collect_napi_link_evidence.py index 3cfc811..1eb391f 100644 --- a/scripts/collect_napi_link_evidence.py +++ b/scripts/collect_napi_link_evidence.py @@ -83,6 +83,7 @@ def collect(binary, evidence, target): if len(records) != 1: raise ValueError('actual addon must match exactly one captured shared link') record = records[0] + (evidence / 'native-link-command.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') if PurePosixPath(record['map']).name != record['map']: raise ValueError('unsafe captured native map name') link_map = evidence / 'link-maps' / record['map'] diff --git a/scripts/napi_gnu_runtime_notices.py b/scripts/napi_gnu_runtime_notices.py new file mode 100644 index 0000000..1e8c4ed --- /dev/null +++ b/scripts/napi_gnu_runtime_notices.py @@ -0,0 +1,161 @@ +"""Связать полный GNU notice с reviewed target и actual link evidence.""" + +import base64 +import gzip +import hashlib +import json +from pathlib import Path, PurePosixPath +import re +import sys + +PROFILE_SHA256 = '6aac74157ae3d421c2238e73f4a7d47fca62452f8685a51f158cdc83ac18f07e' +CATALOG_SHA256 = '81946a881bab335453f935cd935c3255ce3eb623f636a26089f61099b94610db' +TARGETS = {'x86_64-unknown-linux-gnu': 'sysdeps/x86_64', 'aarch64-unknown-linux-gnu': 'ports/sysdeps/aarch64'} +DOCUMENTS = ['share/licenses/gcc/COPYING3', 'share/licenses/gcc/COPYING.RUNTIME', 'share/licenses/glibc/COPYING.LIB'] +CRT = {'crti.o', 'crtn.o', 'crtbeginS.o', 'crtendS.o'} +MEMBERS = [['libc_nonshared.a', 'fstat64.oS'], ['libc_nonshared.a', 'stat64.oS']] +FLAGS = {'-m64', '-Wl,--no-undefined-version', '-Wl,--as-needed', '-Wl,-Bstatic', '-Wl,-Bdynamic', '-Wl,--eh-frame-hdr', '-Wl,-z,noexecstack', '-Wl,--gc-sections', '-shared', '-Wl,-z,relro,-z,now', '-Wl,-O1', '-Wl,--strip-debug', '-nodefaultlibs', '-Wl,-z,nodelete', '-ldl', '-lgcc_s', '-lutil', '-lrt', '-lpthread', '-lm', '-lc'} + + +def read(path, limit): + if path.is_symlink() or not path.is_file(): + raise ValueError('missing or symlinked GNU notice input') + with path.open('rb') as source: + data = source.read(limit + 1) + if len(data) > limit: + raise ValueError('GNU notice input exceeds bound') + return data + + +def reviewed(root): + profile = read(root / 'ci/licenses/napi-gnu-runtime.json', 1024 * 1024) + catalog = read(root / 'ci/napi-gnu-sdk-inputs.json', 1024 * 1024) + if hashlib.sha256(profile).hexdigest() != PROFILE_SHA256 or hashlib.sha256(catalog).hexdigest() != CATALOG_SHA256: + raise ValueError('GNU runtime profile or SDK catalogue differs from review') + return json.loads(profile), json.loads(catalog) + + +def runtime_notice(root, target): + if target not in TARGETS: + raise ValueError('unreviewed GNU runtime target') + profile, catalog = reviewed(root) + selected = ['glibc/io/fstat64.c', 'glibc/io/stat64.c', 'glibc/' + TARGETS[target] + '/crti.S', 'glibc/' + TARGETS[target] + '/crtn.S', 'gcc/libgcc/crtstuff.c', *DOCUMENTS] + indexed = {item['id']: item for item in profile['materials']} + materials = [indexed[name] for name in selected] + for item in materials: + data = item['text'].encode('utf-8') + blob = hashlib.sha1(b'blob ' + str(len(data)).encode() + b'\0' + data).hexdigest() + if len(data) != item['bytes'] or hashlib.sha256(data).hexdigest() != item['sha256'] or blob != item['git_blob']: + raise ValueError('GNU source or license material identity mismatch') + return {'schema_version': 1, 'target': target, 'profile_sha256': PROFILE_SHA256, 'sdk_catalog_sha256': CATALOG_SHA256, 'sdk_revision': profile['sdk_revision'], 'sdk_inputs': catalog['targets'][target], 'archive_members': MEMBERS, 'loaded_crt_objects': sorted(CRT), 'materials': materials, 'glibc_terms': profile['glibc_terms'], 'gcc_terms': profile['gcc_terms'], 'compilation_process': profile['compilation_process'], 'scope': profile['scope'], 'unused_archive': 'libpthread_nonshared.a is loaded, but no members are retained by this reviewed link profile.', 'host_libraries': 'System shared libraries including glibc and libgcc_s are host-provided, not redistributed in this addon payload; their dynamic use is distinct from the selected compiled-in CRT members.'} + + +def notice_bytes(notice): + data = (json.dumps(notice, ensure_ascii=False, sort_keys=True, indent=2) + '\n').encode('utf-8') + sections = ['GNU NAPI runtime notices — ' + notice['target'], notice['scope'], notice['glibc_terms'], notice['gcc_terms'], notice['compilation_process'], notice['unused_archive'], notice['host_libraries']] + for item in notice['materials']: + sections.extend(['=' * 72, item['id'], item['repository'] + ' @ ' + item['revision'], 'Git blob: ' + item['git_blob'] + '; SHA256: ' + item['sha256'], item['text']]) + plain = ('\n\n'.join(sections) + '\n').encode('utf-8') + return data, plain + + +def prepare(root, evidence, target): + notice = runtime_notice(root, target) + data, plain = notice_bytes(notice) + paths = [evidence / 'GNU-RUNTIME-NOTICE.json', evidence / 'GNU-RUNTIME-NOTICE.txt'] + if any(path.exists() or path.is_symlink() for path in paths): + raise ValueError('GNU runtime notice output already exists') + bundle = json.loads(read(evidence / 'NOTICE.json', 64 * 1024 * 1024)) + if 'napi_gnu_runtime' in bundle: + raise ValueError('GNU runtime bundle already augmented') + bundle['napi_gnu_runtime'] = notice + augmented = (json.dumps(bundle, ensure_ascii=False, sort_keys=True, indent=2) + '\n').encode('utf-8') + compressed = gzip.compress(augmented, mtime=0) + if len(augmented) > 64 * 1024 * 1024 or len(compressed) > 4 * 1024 * 1024: + raise ValueError('augmented GNU notice exceeds resource bounds') + paths[0].write_bytes(data) + paths[1].write_bytes(plain) + (evidence / 'NOTICE.json').write_bytes(augmented) + (evidence / 'NOTICE.json.gz').write_bytes(compressed) + + +def verify_link(notice, report, notices, command, rustc, compiler): + target = notice['target'] + if report.get('target') != target or command.get('target') != target: + raise ValueError('GNU runtime target differs from actual link') + selected = notice['sdk_inputs'] + expected = [] + for role, entries in [('compiler', [selected['compiler']]), ('configuration', [selected['configuration']]), ('runtime', selected['runtime_inputs'])]: + expected.extend({'role': role, 'path': item['path'], 'bytes': item['bytes'], 'sha256': item['sha256']} for item in entries) + actual = report.get('sdk_input_profile', {}) + if actual.get('repository_revision') != notice['sdk_revision'] or actual.get('inputs') != expected or report.get('sdk_input_catalog_sha256') != CATALOG_SHA256: + raise ValueError('GNU actual SDK inputs differ from reviewed runtime') + if report.get('compiler_sha256') != selected['compiler']['sha256'] or report.get('cross_toolchain_version') != '1.0.3': + raise ValueError('GNU actual compiler differs from reviewed runtime') + if sorted(report.get('archive_members', [])) != MEMBERS: + raise ValueError('GNU retained archive members differ from reviewed runtime') + objects = report.get('loaded_objects', []) + own = [name for name in objects if re.fullmatch(r'ktav_napi\..+\.rcgu\.o', name)] + if len(own) != 1 or len(objects) != 5 or set(objects) != CRT | set(own): + raise ValueError('GNU loaded objects differ from reviewed runtime') + indexed = {} + for item in notices: + if item['path'] in indexed: + raise ValueError('duplicate SDK notice path') + indexed[item['path']] = item + for item in notice['materials']: + if item['id'] not in DOCUMENTS: + continue + actual_document = indexed.get(item['id']) + if actual_document is None or base64.b64decode(actual_document['raw_bytes_base64'], validate=True) != item['text'].encode('utf-8') or actual_document['sha256'] != item['sha256']: + raise ValueError('actual SDK legal document differs from reviewed notice') + if not rustc.startswith('rustc 1.99.1 ') or '\nrelease: 1.99.1\n' not in rustc or '\nLLVM version: ' not in rustc: + raise ValueError('unreviewed Rust compilation process') + if not compiler.splitlines() or not compiler.splitlines()[0].startswith(target + '-gcc ') or not compiler.splitlines()[0].endswith(' 4.8.5'): + raise ValueError('unreviewed GCC compilation process') + if not command.get('compiler', '').endswith('/' + target + '/bin/' + target + '-gcc') or PurePosixPath(command.get('output', '')).name != 'libktav_napi.so': + raise ValueError('unreviewed final NAPI link command') + arguments = command.get('arguments', []) + skip_path = False + native_inputs = [] + for argument in arguments: + if skip_path: + if not PurePosixPath(argument).is_absolute(): + raise ValueError('unreviewed final NAPI link path') + skip_path = False + elif argument in {'-L', '-o'}: + skip_path = True + elif argument in FLAGS or (target == 'aarch64-unknown-linux-gnu' and argument == '-Wl,--fix-cortex-a53-843419') or argument.startswith('-Wl,--version-script=/'): + continue + elif PurePosixPath(argument).is_absolute() and (PurePosixPath(argument).name in own or re.fullmatch(r'libcompiler_builtins-[0-9a-f]+\.rlib', PurePosixPath(argument).name)): + native_inputs.append(PurePosixPath(argument).name) + else: + raise ValueError('unreviewed final NAPI link argument') + if skip_path or len(native_inputs) != 2 or not all(name in native_inputs for name in own) or arguments.count('-shared') != 1 or arguments.count('-o') != 1: + raise ValueError('incomplete reviewed final NAPI compilation process') + + +def verify(root, evidence, target): + notice = runtime_notice(root, target) + data, plain = notice_bytes(notice) + if read(evidence / 'GNU-RUNTIME-NOTICE.json', 1024 * 1024) != data or read(evidence / 'GNU-RUNTIME-NOTICE.txt', 1024 * 1024) != plain: + raise ValueError('GNU runtime notice output differs from reviewed material') + bundle_bytes = read(evidence / 'NOTICE.json', 64 * 1024 * 1024) + bundle = json.loads(bundle_bytes) + if read(evidence / 'NOTICE.json.gz', 4 * 1024 * 1024) != gzip.compress(bundle_bytes, mtime=0): + raise ValueError('GNU compressed bundle differs from readable notice') + if bundle.get('napi_gnu_runtime') != notice: + raise ValueError('GNU runtime notice absent from augmented bundle') + report = json.loads(read(evidence / 'native-link-inputs.json', 1024 * 1024)) + verify_link(notice, report, json.loads(read(evidence / 'sdk-notice-files.json', 48 * 1024 * 1024)), json.loads(read(evidence / 'native-link-command.json', 1024 * 1024)), read(evidence / 'rustc.txt', 64 * 1024).decode('utf-8'), read(evidence / 'compiler-version.txt', 64 * 1024).decode('utf-8')) + result = {'target': target, 'binary_sha256': report['binary_sha256'], 'runtime_notice_sha256': hashlib.sha256(data).hexdigest(), 'plain_notice_sha256': hashlib.sha256(plain).hexdigest(), 'profile_sha256': PROFILE_SHA256, 'scope': 'Actual GNU SDK inputs, selected source/license notices and final link process verified; embedding and npm delivery are separate gates, not established by this report.'} + (evidence / 'gnu-runtime-verification.json').write_text(json.dumps(result, sort_keys=True, indent=2) + '\n', encoding='utf-8') + print(json.dumps(result, sort_keys=True)) + + +if __name__ == '__main__': + if len(sys.argv) != 4 or sys.argv[1] not in {'prepare', 'verify'}: + raise SystemExit('usage: napi_gnu_runtime_notices.py prepare|verify EVIDENCE TARGET') + root = Path(__file__).resolve().parents[1] + action = prepare if sys.argv[1] == 'prepare' else verify + action(root, Path(sys.argv[2]), sys.argv[3]) From 71a0fe2ca9522db97375bb8606811fd7b0b6c478 Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sat, 31 Oct 2026 17:52:27 +0100 Subject: [PATCH 21/51] feat: retain complete GNU notices in NAPI addons Keep napi-build setup and all public binding behavior unchanged. Generate a bounded private gzip resource and reference it from the existing exported parser without adding dependencies or public APIs. Build both GNU targets with the reviewed Cargo/std/runtime bundle, verify the exact resource in actual addon bytes and preserve those bytes in CI evidence. Exercise encoder boundaries with the real pinned napi-build dependency and retain the matching-CPU consumer. Record the two explicit source overlays against the original baseline. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/napi-notice-check.yml | 30 ++++++-- crates/napi/build.rs | 97 ++++++++++++++++++++++++- crates/napi/src/lib.rs | 4 + 3 files changed, 125 insertions(+), 6 deletions(-) diff --git a/.github/workflows/napi-notice-check.yml b/.github/workflows/napi-notice-check.yml index d6a6868..b6c1f39 100644 --- a/.github/workflows/napi-notice-check.yml +++ b/.github/workflows/napi-notice-check.yml @@ -31,7 +31,7 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'napi-notice-tools' stage.mkdir() - for name in ['Cargo.lock', 'ci/js-build-lock.json', 'ci/test_js_build_lock.py', 'scripts/capture_napi_cross_link.py', 'scripts/collect_napi_link_evidence.py', 'ci/test_napi_cross_link.py', 'ci/napi-gnu-sdk-inputs.json', 'ci/licenses/napi-gnu-runtime.json', 'ci/test_napi_gnu_runtime_notices.py', 'scripts/napi_gnu_runtime_notices.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json']: + for name in ['crates/napi/build.rs', 'crates/napi/src/lib.rs', 'scripts/check_embedded_notices.py', 'Cargo.lock', 'ci/js-build-lock.json', 'ci/test_js_build_lock.py', 'scripts/capture_napi_cross_link.py', 'scripts/collect_napi_link_evidence.py', 'ci/test_napi_cross_link.py', 'ci/napi-gnu-sdk-inputs.json', 'ci/licenses/napi-gnu-runtime.json', 'ci/test_napi_gnu_runtime_notices.py', 'scripts/napi_gnu_runtime_notices.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json']: target = stage / name target.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(name, target) @@ -40,7 +40,7 @@ jobs: ref: ${{ env.SOURCE_REF }} submodules: recursive persist-credentials: false - - name: Restore audit tools without modifying NAPI source or build hook + - name: Restore tools and the two reviewed private resource changes shell: python run: | import hashlib @@ -51,14 +51,19 @@ jobs: from pathlib import Path if subprocess.check_output(['git', 'rev-parse', 'HEAD'], text=True).strip() != os.environ['SOURCE_REF']: raise SystemExit('unexpected NAPI source revision') + overlay = ['crates/napi/build.rs', 'crates/napi/src/lib.rs'] + baseline = {name: hashlib.sha256(Path(name).read_bytes()).hexdigest() for name in overlay} stage = Path(os.environ['RUNNER_TEMP']) / 'napi-notice-tools' for path in stage.rglob('*'): if path.is_file(): target = Path(path.relative_to(stage)) target.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(path, target) - subprocess.run(['git', 'diff', '--exit-code', '--', 'Cargo.toml', 'crates', 'tests/node', 'root-docs', 'package.json', 'package-lock.json'], check=True) - record = {'source_ref': os.environ['SOURCE_REF'], 'tooling_ref': os.environ['GITHUB_SHA'], 'napi_build_rs_sha256': hashlib.sha256(Path('crates/napi/build.rs').read_bytes()).hexdigest(), 'reviewed_lock_sha256': hashlib.sha256(Path('Cargo.lock').read_bytes()).hexdigest(), 'coverage': 'Audit-only GNU linker provenance, not completed non-Cargo runtime licensing or historical package evidence.'} + changed = subprocess.check_output(['git', 'diff', '--name-only', '--', 'Cargo.toml', 'crates', 'tests/node', 'root-docs', 'package.json', 'package-lock.json'], text=True).splitlines() + if set(changed) != set(overlay): + raise SystemExit('binding overlay must contain exactly the two reviewed resource files') + binding_overlay = {name: {'baseline_sha256': baseline[name], 'compiled_sha256': hashlib.sha256(Path(name).read_bytes()).hexdigest()} for name in overlay} + record = {'source_ref': os.environ['SOURCE_REF'], 'tooling_ref': os.environ['GITHUB_SHA'], 'binding_overlay': binding_overlay, 'napi_build_rs_sha256': binding_overlay['crates/napi/build.rs']['compiled_sha256'], 'reviewed_lock_sha256': hashlib.sha256(Path('Cargo.lock').read_bytes()).hexdigest(), 'coverage': 'Original source with two explicit private resource changes; not historical package evidence or completed npm delivery.'} (Path(os.environ['RUNNER_TEMP']) / 'napi-source-provenance.json').write_text(json.dumps(record, sort_keys=True, indent=2)) - uses: actions/setup-node@v4 with: @@ -98,7 +103,7 @@ jobs: shutil.copyfile('scripts/capture_napi_cross_link.py', capture) capture.chmod(0o755) with Path(os.environ['GITHUB_ENV']).open('a', encoding='utf-8') as output: - for name, value in [(key, str(capture.resolve())), ('KTAV_NAPI_TARGET', os.environ['NAPI_TARGET']), ('KTAV_NAPI_LINK_EVIDENCE', str(maps))]: + for name, value in [(key, str(capture.resolve())), ('KTAV_NAPI_TARGET', os.environ['NAPI_TARGET']), ('KTAV_NAPI_LINK_EVIDENCE', str(maps)), ('KTAV_NAPI_NOTICES_GZIP', str((evidence / 'NOTICE.json.gz').resolve()))]: output.write(name + '=' + value + chr(10)) - name: Resolve the original npm release graph and check licenses shell: bash @@ -119,6 +124,21 @@ jobs: cmp Cargo.lock "$RUNNER_TEMP/napi-notices/Cargo.lock" python3 scripts/collect_napi_link_evidence.py ${{ matrix.addon }} "$RUNNER_TEMP/napi-notices" ${{ matrix.target }} python3 -I scripts/napi_gnu_runtime_notices.py verify "$RUNNER_TEMP/napi-notices" ${{ matrix.target }} + python3 -I scripts/check_embedded_notices.py ${{ matrix.addon }} "$RUNNER_TEMP/napi-notices/NOTICE.json" > "$RUNNER_TEMP/napi-notices/embedded-notice-verification.json" + cp ${{ matrix.addon }} "$RUNNER_TEMP/napi-notices/${{ matrix.addon }}" + - name: Verify bounded resource encoder with the real build dependency + shell: python + run: | + import os + import subprocess + from pathlib import Path + libraries = list(Path('target/release/deps').glob('libnapi_build-*.rlib')) + if len(libraries) != 1: + raise SystemExit('expected one pinned host napi-build library') + library = libraries[0].resolve() + test = Path(os.environ['RUNNER_TEMP']) / 'napi-build-hook-tests' + subprocess.run(['rustc', '--test', '--edition=2021', 'crates/napi/build.rs', '--extern', 'napi_build=' + str(library), '-L', 'dependency=' + str(library.parent), '-o', str(test)], check=True) + subprocess.run([str(test)], check=True) - name: Verify actual matching-CPU Node consumer if: matrix.target == 'x86_64-unknown-linux-gnu' shell: bash diff --git a/crates/napi/build.rs b/crates/napi/build.rs index c365ab3..e904702 100644 --- a/crates/napi/build.rs +++ b/crates/napi/build.rs @@ -1,6 +1,101 @@ +use std::io::{self, Read}; + +const MARKER: &[u8] = b"KTAV-NOTICES-GZIP-v1\0"; +const MAX_GZIP: usize = 4 * 1024 * 1024; + +fn notice_resource(source: impl Read) -> io::Result> { + let mut payload = Vec::new(); + source + .take((MAX_GZIP + 1) as u64) + .read_to_end(&mut payload)?; + if payload.len() > MAX_GZIP || !payload.starts_with(&[0x1f, 0x8b, 0x08]) { + return Err(io::Error::new( + io::ErrorKind::InvalidData, + "NAPI notices must be a gzip payload of at most 4 MiB", + )); + } + let mut resource = Vec::with_capacity(MARKER.len() + 8 + payload.len()); + resource.extend_from_slice(MARKER); + resource.extend_from_slice(&(payload.len() as u64).to_le_bytes()); + resource.extend_from_slice(&payload); + Ok(resource) +} + // napi-build injects the linker flags N-API needs on each platform — // on macOS, `-undefined dynamic_lookup`; on Windows, the import lib for // node.dll; on Linux, nothing extra. Required by `napi-rs`. -fn main() { +fn main() -> io::Result<()> { napi_build::setup(); + println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rerun-if-env-changed=KTAV_NAPI_NOTICES_GZIP"); + let resource = match std::env::var_os("KTAV_NAPI_NOTICES_GZIP") { + Some(path) => { + let path = std::path::PathBuf::from(path); + println!("cargo:rerun-if-changed={}", path.display()); + notice_resource(std::fs::File::open(path)?)? + } + None => Vec::new(), + }; + let output = std::env::var_os("OUT_DIR") + .ok_or_else(|| io::Error::new(io::ErrorKind::NotFound, "missing OUT_DIR"))?; + std::fs::write( + std::path::PathBuf::from(output).join("ktav-napi-notices.resource"), + resource, + ) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn resource_keeps_marker_length_and_payload() { + let payload = [0x1f, 0x8b, 0x08, 0, 0]; + let resource = notice_resource(payload.as_slice()).unwrap(); + assert_eq!(&resource[..MARKER.len()], MARKER); + assert_eq!( + &resource[MARKER.len()..MARKER.len() + 8], + &(payload.len() as u64).to_le_bytes() + ); + assert_eq!(&resource[MARKER.len() + 8..], payload); + } + + #[test] + fn empty_and_non_gzip_payloads_are_rejected() { + for payload in [&[][..], b"not gzip", &[0x1f, 0x8b]] { + assert_eq!( + notice_resource(payload).unwrap_err().kind(), + io::ErrorKind::InvalidData + ); + } + } + + #[test] + fn exact_bound_is_allowed_but_one_extra_byte_is_rejected() { + let mut payload = vec![0; MAX_GZIP]; + payload[..3].copy_from_slice(&[0x1f, 0x8b, 0x08]); + assert_eq!( + notice_resource(payload.as_slice()).unwrap().len(), + MARKER.len() + 8 + MAX_GZIP + ); + payload.push(0); + assert_eq!( + notice_resource(payload.as_slice()).unwrap_err().kind(), + io::ErrorKind::InvalidData + ); + } + + #[test] + fn read_errors_are_propagated() { + struct Failed; + impl Read for Failed { + fn read(&mut self, _: &mut [u8]) -> io::Result { + Err(io::Error::new(io::ErrorKind::PermissionDenied, "fixture")) + } + } + assert_eq!( + notice_resource(Failed).unwrap_err().kind(), + io::ErrorKind::PermissionDenied + ); + } } diff --git a/crates/napi/src/lib.rs b/crates/napi/src/lib.rs index fb685a0..ab3307c 100644 --- a/crates/napi/src/lib.rs +++ b/crates/napi/src/lib.rs @@ -18,6 +18,9 @@ use napi::{sys, ValueType}; use napi_derive::napi; use rustc_hash::FxBuildHasher; +static KTAV_NOTICES: &[u8] = + include_bytes!(concat!(env!("OUT_DIR"), "/ktav-napi-notices.resource")); + fn envelope_json(err: &ktav::Error, source: &str) -> String { let mut env = ktav::ErrorEnvelope::from_error(err, source); // Spec § 6: every source-content parse error carries a 1-based line. @@ -152,6 +155,7 @@ fn line_of_offset(bytes: &[u8], pos: usize) -> u32 { /// Parse a Ktav document and return the equivalent JavaScript value. #[napi] pub fn loads<'env>(env: &'env Env, s: String) -> Result> { + std::hint::black_box(KTAV_NOTICES); let value = ktav::parse(&s).map_err(|e| Error::from_reason(envelope_json(&e, &s)))?; value_to_js(env, &value) } From f6b74d472f7d0813913e57146cece67be11a2acc Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sat, 31 Oct 2026 18:03:20 +0100 Subject: [PATCH 22/51] fix: apply notice retention to the selected NAPI source Do not copy the current binding implementation over the original 0.8.1 audit source: its newer edit APIs require a different core. Apply only the two private notice insertions to the selected source and record their baseline and compiled identities as before. Keep current product APIs, the registry core, MSRV and reviewed lock unchanged. Add six source-preservation and fail-closed regressions. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/napi-notice-check.yml | 5 ++- ci/test_napi_notice_overlay.py | 50 +++++++++++++++++++++++++ scripts/patch_napi_notice_source.py | 27 +++++++++++++ 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 ci/test_napi_notice_overlay.py create mode 100644 scripts/patch_napi_notice_source.py diff --git a/.github/workflows/napi-notice-check.yml b/.github/workflows/napi-notice-check.yml index b6c1f39..5a54586 100644 --- a/.github/workflows/napi-notice-check.yml +++ b/.github/workflows/napi-notice-check.yml @@ -31,7 +31,7 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'napi-notice-tools' stage.mkdir() - for name in ['crates/napi/build.rs', 'crates/napi/src/lib.rs', 'scripts/check_embedded_notices.py', 'Cargo.lock', 'ci/js-build-lock.json', 'ci/test_js_build_lock.py', 'scripts/capture_napi_cross_link.py', 'scripts/collect_napi_link_evidence.py', 'ci/test_napi_cross_link.py', 'ci/napi-gnu-sdk-inputs.json', 'ci/licenses/napi-gnu-runtime.json', 'ci/test_napi_gnu_runtime_notices.py', 'scripts/napi_gnu_runtime_notices.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json']: + for name in ['crates/napi/build.rs', 'scripts/patch_napi_notice_source.py', 'ci/test_napi_notice_overlay.py', 'scripts/check_embedded_notices.py', 'Cargo.lock', 'ci/js-build-lock.json', 'ci/test_js_build_lock.py', 'scripts/capture_napi_cross_link.py', 'scripts/collect_napi_link_evidence.py', 'ci/test_napi_cross_link.py', 'ci/napi-gnu-sdk-inputs.json', 'ci/licenses/napi-gnu-runtime.json', 'ci/test_napi_gnu_runtime_notices.py', 'scripts/napi_gnu_runtime_notices.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json']: target = stage / name target.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(name, target) @@ -48,6 +48,7 @@ jobs: import os import shutil import subprocess + import sys from pathlib import Path if subprocess.check_output(['git', 'rev-parse', 'HEAD'], text=True).strip() != os.environ['SOURCE_REF']: raise SystemExit('unexpected NAPI source revision') @@ -59,6 +60,7 @@ jobs: target = Path(path.relative_to(stage)) target.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(path, target) + subprocess.run([sys.executable, '-I', 'scripts/patch_napi_notice_source.py', 'crates/napi/src/lib.rs'], check=True) changed = subprocess.check_output(['git', 'diff', '--name-only', '--', 'Cargo.toml', 'crates', 'tests/node', 'root-docs', 'package.json', 'package-lock.json'], text=True).splitlines() if set(changed) != set(overlay): raise SystemExit('binding overlay must contain exactly the two reviewed resource files') @@ -80,6 +82,7 @@ jobs: python3 -I -m unittest discover -s ci -p test_napi_cross_link.py -v python3 -I -m unittest discover -s ci -p test_js_build_lock.py -v python3 -I -m unittest discover -s ci -p test_napi_gnu_runtime_notices.py -v + python3 -I -m unittest discover -s ci -p test_napi_notice_overlay.py -v - name: Prepare locked Cargo/std notices and linker evidence directory shell: python env: diff --git a/ci/test_napi_notice_overlay.py b/ci/test_napi_notice_overlay.py new file mode 100644 index 0000000..2b21fe9 --- /dev/null +++ b/ci/test_napi_notice_overlay.py @@ -0,0 +1,50 @@ +"""Проверить перенос только retention без замены binding API.""" + +import importlib.util +from pathlib import Path +import unittest + +SCRIPT = Path(__file__).resolve().parents[1] / 'scripts/patch_napi_notice_source.py' +SPEC = importlib.util.spec_from_file_location('overlay', SCRIPT) +OVERLAY = importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(OVERLAY) + + +class NoticeOverlayTests(unittest.TestCase): + def source(self, extra=''): + return OVERLAY.IMPORT + '\n' + extra + OVERLAY.FUNCTION + ' original_body(env, s)\n}\n' + + def test_original_binding_body_is_preserved(self): + source = self.source() + patched = OVERLAY.patch_source(source) + self.assertEqual(patched.replace(OVERLAY.STATIC, '').replace(OVERLAY.CALL, ''), source) + self.assertEqual(patched.count('static KTAV_NOTICES:'), 1) + self.assertEqual(patched.count(OVERLAY.CALL), 1) + + def test_other_revision_api_is_not_copied_or_removed(self): + extra = 'fn revision_specific_api() { distinct_body(); }\n' + source = self.source(extra) + patched = OVERLAY.patch_source(source) + self.assertIn(extra, patched) + self.assertEqual(patched.replace(OVERLAY.STATIC, '').replace(OVERLAY.CALL, ''), source) + self.assertNotIn('revision_specific_api', OVERLAY.patch_source(self.source())) + + def test_missing_import_anchor_is_rejected(self): + with self.assertRaisesRegex(ValueError, 'unreviewed'): + OVERLAY.patch_source(self.source().replace(OVERLAY.IMPORT, '')) + + def test_duplicate_anchor_is_rejected(self): + with self.assertRaisesRegex(ValueError, 'unreviewed'): + OVERLAY.patch_source(self.source() + OVERLAY.FUNCTION) + + def test_missing_function_anchor_is_rejected(self): + with self.assertRaisesRegex(ValueError, 'unreviewed'): + OVERLAY.patch_source(self.source().replace(OVERLAY.FUNCTION, '')) + + def test_repeated_overlay_is_rejected(self): + with self.assertRaisesRegex(ValueError, 'already patched'): + OVERLAY.patch_source(OVERLAY.patch_source(self.source())) + + +if __name__ == '__main__': + unittest.main() diff --git a/scripts/patch_napi_notice_source.py b/scripts/patch_napi_notice_source.py new file mode 100644 index 0000000..71824b5 --- /dev/null +++ b/scripts/patch_napi_notice_source.py @@ -0,0 +1,27 @@ +"""Добавить только private retention к выбранному binding source.""" + +from pathlib import Path +import sys + + +IMPORT = 'use rustc_hash::FxBuildHasher;\n' +FUNCTION = "pub fn loads<'env>(env: &'env Env, s: String) -> Result> {\n" +STATIC = '\nstatic KTAV_NOTICES: &[u8] =\n include_bytes!(concat!(env!("OUT_DIR"), "/ktav-napi-notices.resource"));\n' +CALL = ' std::hint::black_box(KTAV_NOTICES);\n' + + +def patch_source(source): + if 'KTAV_NOTICES' in source or source.count(IMPORT) != 1 or source.count(FUNCTION) != 1: + raise ValueError('unreviewed or already patched NAPI source') + return source.replace(IMPORT, IMPORT + STATIC).replace(FUNCTION, FUNCTION + CALL) + + +if __name__ == '__main__': + if len(sys.argv) != 2: + raise SystemExit('usage: patch_napi_notice_source.py NAPI_LIB_RS') + path = Path(sys.argv[1]) + if path.is_symlink() or not path.is_file() or path.stat().st_size > 1024 * 1024: + raise SystemExit('expected bounded regular NAPI source file') + original = path.read_bytes() + patched = patch_source(original.decode('utf-8')).encode('utf-8') + path.write_bytes(patched) From de71212cccbc7c4543409c2aaa7444d46d61b9eb Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sat, 31 Oct 2026 18:44:57 +0100 Subject: [PATCH 23/51] ci: inspect actual macOS NAPI and C ABI inputs Build both roles for both Darwin targets from the original 0.8.1 source and reviewed Cargo lock, preserving only the private NAPI notice overlay. Capture final linker maps, exact staged/original bytes, bounded Mach-O metadata and system SDK object boundaries. Reuse the reviewed LSP SDK public-name and symlink rules. Record dynamic imports without inferring GNU licensing from libiconv names. Preserve matching-CPU NAPI consumer and Cargo/std resource evidence. Release assembly, C ABI source and publication gates are unchanged. Co-Authored-By: Claude Opus 5.5 --- .../workflows/macos-native-notice-check.yml | 168 ++++++++++++++++++ ci/test_macos_native_evidence.py | 120 +++++++++++++ scripts/macos_native_evidence.py | 164 +++++++++++++++++ 3 files changed, 452 insertions(+) create mode 100644 .github/workflows/macos-native-notice-check.yml create mode 100644 ci/test_macos_native_evidence.py create mode 100644 scripts/macos_native_evidence.py diff --git a/.github/workflows/macos-native-notice-check.yml b/.github/workflows/macos-native-notice-check.yml new file mode 100644 index 0000000..f6565d1 --- /dev/null +++ b/.github/workflows/macos-native-notice-check.yml @@ -0,0 +1,168 @@ +name: macOS native runtime evidence + +on: + pull_request: + +permissions: + contents: read + +env: + SOURCE_REF: 562deb3fde092d63a78f359be095e5079929d0d1 + +jobs: + macos-native: + name: macOS native inputs / ${{ matrix.target }} + runs-on: macos-latest + strategy: + fail-fast: false + matrix: + include: + - target: x86_64-apple-darwin + addon: ktav.darwin-x64.node + - target: aarch64-apple-darwin + addon: ktav.darwin-arm64.node + env: + MACOS_TARGET: ${{ matrix.target }} + NAPI_ADDON: ${{ matrix.addon }} + steps: + - uses: actions/checkout@v4 + - name: Preserve reviewed tools and private build hook + shell: python + run: | + import os + import shutil + from pathlib import Path + stage = Path(os.environ['RUNNER_TEMP']) / 'macos-native-tools' + stage.mkdir() + names = ['Cargo.lock', 'ci/js-build-lock.json', 'crates/napi/build.rs', 'scripts/patch_napi_notice_source.py', 'scripts/macos_native_evidence.py', 'ci/test_macos_native_evidence.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json'] + for name in names: + destination = stage / name + destination.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(name, destination) + - uses: actions/checkout@v4 + with: + ref: ${{ env.SOURCE_REF }} + submodules: recursive + persist-credentials: false + - name: Restore tools and graft only private NAPI metadata + shell: python + run: | + import hashlib + import json + import os + import shutil + import subprocess + import sys + from pathlib import Path + if subprocess.check_output(['git', 'rev-parse', 'HEAD'], text=True).strip() != os.environ['SOURCE_REF']: + raise SystemExit('unexpected macOS source revision') + overlay = ['crates/napi/build.rs', 'crates/napi/src/lib.rs'] + baseline = {name: hashlib.sha256(Path(name).read_bytes()).hexdigest() for name in overlay} + stage = Path(os.environ['RUNNER_TEMP']) / 'macos-native-tools' + for path in stage.rglob('*'): + if path.is_file(): + destination = Path(path.relative_to(stage)) + destination.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(path, destination) + subprocess.run([sys.executable, '-I', 'scripts/patch_napi_notice_source.py', 'crates/napi/src/lib.rs'], check=True) + changed = subprocess.check_output(['git', 'diff', '--name-only', '--', 'Cargo.toml', 'crates', 'tests/node', 'root-docs', 'package.json', 'package-lock.json'], text=True).splitlines() + if set(changed) != set(overlay): + raise SystemExit('macOS source overlay changed more than the two private resource files') + record = {'source_ref': os.environ['SOURCE_REF'], 'tooling_ref': os.environ['GITHUB_SHA'], 'binding_overlay': {name: {'baseline_sha256': baseline[name], 'compiled_sha256': hashlib.sha256(Path(name).read_bytes()).hexdigest()} for name in overlay}, 'scope': 'Original 0.8.1 source with private NAPI Cargo/std resource only; CABI source remains unchanged.'} + (Path(os.environ['RUNNER_TEMP']) / 'macos-native-source.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') + - uses: actions/setup-node@v4 + with: + node-version: '24' + - uses: dtolnay/rust-toolchain@1.99.1 + with: + targets: ${{ matrix.target }} + components: rust-docs + - uses: taiki-e/install-action@v2 + with: + tool: cargo-about@0.9.3 + - name: Verify Mach-O and SDK-boundary regressions + run: python3 -I -m unittest discover -s ci -p test_macos_native_evidence.py -v + - name: Prepare reviewed Cargo/std notices and source evidence + shell: python + run: | + import os + import shutil + import subprocess + import sys + from pathlib import Path + evidence = Path(os.environ['RUNNER_TEMP']) / 'macos-native-notices' + subprocess.run([sys.executable, 'scripts/prepare_js_notices.py', str(evidence)], check=True) + shutil.copyfile(Path(os.environ['RUNNER_TEMP']) / 'macos-native-source.json', evidence / 'source-provenance.json') + - name: Resolve unchanged npm manifest and verify tool licenses + shell: bash + run: | + set -euo pipefail + cp package-lock.json "$RUNNER_TEMP/macos-native-notices/npm-lock-source.json" + npm install --ignore-scripts --no-audit --no-fund + git diff --exit-code -- package.json + cp package-lock.json "$RUNNER_TEMP/macos-native-notices/npm-lock-resolved.json" + node scripts/check-npm-licenses.mjs + node -e 'if(require("@napi-rs/cli/package.json").version!=="3.6.2")throw new Error("NAPI CLI version requires review")' + - name: Build both native roles and preserve actual link evidence + shell: python + run: | + import hashlib + import json + import os + import shutil + import subprocess + import sys + from pathlib import Path + evidence = Path(os.environ['RUNNER_TEMP']) / 'macos-native-notices' + target = os.environ['MACOS_TARGET'] + if os.environ.get('RUSTFLAGS') or os.environ.get('CARGO_ENCODED_RUSTFLAGS'): + raise SystemExit('preexisting macOS flags require review') + commands = [('napi', ['npx', '--no-install', 'napi', 'build', '--release', '-p', 'ktav-napi', '--target', target, '--platform', '--js', 'false', '--output-dir', '.']), ('cabi', ['cargo', 'build', '--locked', '--release', '-p', 'ktav-cabi', '--target', target])] + for role, command in commands: + link_map = evidence / (role + '-native-link.map') + environment = {**os.environ, 'CARGO_ENCODED_RUSTFLAGS': '-C' + chr(31) + 'link-arg=-Wl,-map,' + str(link_map), 'KTAV_NAPI_NOTICES_GZIP': str(evidence / 'NOTICE.json.gz'), 'RUSTC_LOG': 'rustc_codegen_ssa::back::link=info'} + result = subprocess.run(command, env=environment, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + (evidence / (role + '-linker-trace.txt')).write_bytes(result.stderr) + sys.stdout.buffer.write(result.stdout) + sys.stderr.buffer.write(result.stderr) + if result.returncode: + raise SystemExit(result.returncode) + original = Path('target') / target / 'release' / ('libktav_' + role + '.dylib') + binary = Path(os.environ['NAPI_ADDON']) if role == 'napi' else original + staged = evidence / binary.name + shutil.copyfile(binary, staged) + subprocess.run([sys.executable, '-I', 'scripts/macos_native_evidence.py', str(staged), str(original), str(link_map), str(evidence), target, role], check=True) + if role == 'napi': + report = subprocess.check_output([sys.executable, '-I', 'scripts/check_embedded_notices.py', str(staged), str(evidence / 'NOTICE.json')]) + (evidence / 'napi-embedded-verification.json').write_bytes(report) + if Path('Cargo.lock').read_bytes() != (evidence / 'Cargo.lock').read_bytes(): + raise SystemExit('macOS build changed the reviewed Cargo lock') + for name, command in [('clang-version.txt', ['clang', '--version']), ('sdk-version.txt', ['xcrun', '--show-sdk-version']), ('xcode-version.txt', ['xcodebuild', '-version'])]: + (evidence / name).write_bytes(subprocess.check_output(command)) + - name: Run actual matching-CPU NAPI consumer + shell: python + run: | + import hashlib + import json + import os + import shutil + import subprocess + from pathlib import Path + evidence = Path(os.environ['RUNNER_TEMP']) / 'macos-native-notices' + host = subprocess.check_output(['node', '-p', 'process.arch'], text=True).strip() + target = 'arm64' if os.environ['MACOS_TARGET'].startswith('aarch64-') else 'x64' + native = host == target + if native: + subprocess.run(['npm', 'run', 'build:ts'], check=True) + Path('dist/native').mkdir(parents=True, exist_ok=True) + shutil.copyfile(evidence / os.environ['NAPI_ADDON'], Path('dist/native') / os.environ['NAPI_ADDON']) + script = 'import assert from "node:assert/strict";import {createRequire} from "node:module";import {realpathSync} from "node:fs";await import("./dist/ts/node.js");const require=createRequire(import.meta.url);const expected=realpathSync("dist/native/"+process.env.NAPI_ADDON);assert.deepEqual(Object.keys(require.cache).filter(p=>p.endsWith(".node")),[expected]);await import("./tests/node/run-node-napi.mjs");' + subprocess.run(['node', '--input-type=module', '-e', script], check=True) + report = {'target': os.environ['MACOS_TARGET'], 'host_node_arch': host, 'native_execution': native, 'napi_binary_sha256': hashlib.sha256((evidence / os.environ['NAPI_ADDON']).read_bytes()).hexdigest(), 'scope': 'Matching-CPU NAPI consumer only; CABI binary inspected as data, not executed by this step.'} + (evidence / 'execution-scope.json').write_text(json.dumps(report, sort_keys=True, indent=2) + '\n', encoding='utf-8') + - uses: actions/upload-artifact@v4 + if: always() + with: + name: macos-native-evidence-${{ matrix.target }} + path: ${{ runner.temp }}/macos-native-notices/ + if-no-files-found: warn diff --git a/ci/test_macos_native_evidence.py b/ci/test_macos_native_evidence.py new file mode 100644 index 0000000..f9bf3f8 --- /dev/null +++ b/ci/test_macos_native_evidence.py @@ -0,0 +1,120 @@ +"""Проверить bounded Mach-O parsing и прежнюю SDK map boundary.""" + +import importlib.util +from pathlib import Path +import struct +import tempfile +import unittest + +SCRIPT = Path(__file__).resolve().parents[1] / 'scripts/macos_native_evidence.py' +SPEC = importlib.util.spec_from_file_location('macos', SCRIPT) +MACOS = importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(MACOS) + + +def dylib_command(command, name): + payload = name.encode('utf-8') + b'\0' + payload += bytes((-len(payload)) % 8) + return struct.pack('<6I', command, 24 + len(payload), 24, 0, 0, 0) + payload + + +def library(symbol='_PyLong_FromLong', dependency='/usr/lib/libSystem.B.dylib'): + identity = dylib_command(0xD, '@rpath/ktav_napi.dylib') + load = dylib_command(0xC, dependency) + size = len(identity) + len(load) + 24 + offset = 32 + size + strings = b'\0' + symbol.encode('utf-8') + b'\0' + symtab = struct.pack('<6I', 2, 24, offset, 1, offset + 16, len(strings)) + header = struct.pack('<8I', 0xFEEDFACF, 0x0100000C, 0, 6, 3, size, 0, 0) + return header + identity + load + symtab + struct.pack(' bound: + raise ValueError('macOS evidence exceeds bound') + return data + + +def object_inputs(data, cargo_root, rustlib_root, sdk_root): + if data.count(b'# Object files:') != 1: + raise ValueError('missing or duplicate Darwin map object section') + section = data.split(b'# Object files:', 1)[1].split(b'# Sections:', 1) + if len(section) != 2: + raise ValueError('missing Darwin map sections boundary') + result = [] + ids = set() + for line in section[0].splitlines(): + if not line.strip(): + continue + match = re.fullmatch(rb'\[\s*(\d+)\]\s+(.+)', line) + if not match or int(match[1]) in ids: + raise ValueError('invalid Darwin map object row') + ids.add(int(match[1])) + name = match[2].decode('utf-8') + if name == 'linker synthesized': + result.append({'kind': 'linker-synthesized'}) + continue + if name.endswith('.tbd'): + path = Path(name) + boundary = (sdk_root / 'usr/lib').resolve() + public_path = path.parent.resolve() / path.name + resolved = path.resolve() + if not public_path.is_relative_to(boundary) or not resolved.is_relative_to(boundary): + raise ValueError('Darwin SDK stub escapes selected SDK') + relative = public_path.relative_to(boundary).as_posix() + if relative not in SYSTEM_STUBS: + raise ValueError('unreviewed Darwin SDK stub: ' + relative) + result.append({'kind': 'system-stub', 'path': relative, 'resolved_path': resolved.relative_to(boundary).as_posix()}) + continue + archive = name.split('.rlib(', 1)[0] + '.rlib' if '.rlib(' in name else None + if archive: + if not name.endswith('.rcgu.o)'): + raise ValueError('non-Rust native member in Darwin rlib input') + path = Path(archive).resolve() + else: + if not name.endswith('.rcgu.o'): + raise ValueError('external static object in Darwin native library') + path = Path(name).resolve() + boundary = next((item for item in [cargo_root.resolve(), rustlib_root.resolve()] if path.is_relative_to(item)), None) + if boundary is None: + raise ValueError('Darwin Rust object outside reviewed Cargo/sysroot roots') + result.append({'kind': 'rust-object', 'path': path.relative_to(boundary).as_posix(), 'origin': 'cargo' if boundary == cargo_root.resolve() else 'rust-sysroot'}) + if ids != set(range(len(result))) or sum(item['kind'] == 'linker-synthesized' for item in result) != 1 or not any(item['kind'] == 'rust-object' for item in result): + raise ValueError('incomplete Darwin map input inventory') + return result + + +def macho(data): + if len(data) < 32 or len(data) > 128 * 1024 * 1024 or data[:4] != b'\xcf\xfa\xed\xfe': + raise ValueError('expected bounded thin Mach-O64') + cpu, _, kind, count, size = struct.unpack_from('<5I', data, 4) + if cpu not in TARGETS.values() or kind not in {6, 8} or count > 65535 or size > 4 * 1024 * 1024 or 32 + size > len(data): + raise ValueError('unreviewed Mach-O library header') + position = 32 + libraries = [] + identities = [] + symbols = None + for _ in range(count): + if position + 8 > 32 + size: + raise ValueError('truncated Mach-O commands') + command, length = struct.unpack_from(' 32 + size: + raise ValueError('invalid Mach-O command bounds') + command &= 0x7fffffff + if command in {0xC, 0xD, 0x18, 0x1F, 0x20, 0x23}: + if length < 24: + raise ValueError('truncated Mach-O dylib command') + offset = struct.unpack_from(' 4096: + raise ValueError('invalid Mach-O dylib name') + name = raw.split(b'\0', 1)[0].decode('utf-8') + (identities if command == 0xD else libraries).append(name) + elif command == 2: + if length < 24 or symbols is not None: + raise ValueError('invalid Mach-O symbol command') + symbols = struct.unpack_from('<4I', data, position + 8) + position += length + if position != 32 + size or symbols is None or len(identities) != (1 if kind == 6 else 0): + raise ValueError('incomplete Mach-O load/symbol metadata') + offset, count, strings, string_size = symbols + if count > 1024 * 1024 or offset + count * 16 > len(data) or strings + string_size > len(data) or string_size > 64 * 1024 * 1024: + raise ValueError('invalid Mach-O symbol bounds') + imported = [] + for index in range(count): + name_offset, symbol_type, section, _, _ = struct.unpack_from('= string_size: + raise ValueError('Mach-O symbol escapes strings') + end = data.find(b'\0', strings + name_offset, strings + string_size) + if end < 0: + raise ValueError('unterminated Mach-O symbol') + name = data[strings + name_offset:end] + if b'iconv' in name.lower() or b'charset' in name.lower(): + imported.append(name.decode('utf-8')) + return {'cpu': cpu, 'mach_o_filetype': kind, 'install_name': identities[0] if identities else None, 'dynamic_libraries': libraries, 'iconv_charset_undefined_symbols': imported, 'symbol_table_present': True} + + +def collect(binary, original, link_map, evidence, target, role): + if target not in TARGETS or role not in {'napi', 'cabi'}: + raise ValueError('unreviewed macOS target or role') + data = read(binary, 128 * 1024 * 1024) + if data != read(original, 128 * 1024 * 1024): + raise ValueError('staged macOS library differs from mapped original') + machine = macho(data) + if machine['cpu'] != TARGETS[target]: + raise ValueError('macOS CPU differs from target') + if not machine['dynamic_libraries'] or set(machine['dynamic_libraries']) - {'/usr/lib/libSystem.B.dylib', '/usr/lib/libiconv.2.dylib'}: + raise ValueError('unreviewed macOS system dynamic dependency') + contents = read(link_map, 32 * 1024 * 1024) + paths = re.findall(rb'^# Path:\s*(.+)$', contents, re.M) + if len(paths) != 1: + raise ValueError('missing or duplicate macOS map output') + mapped = Path(paths[0].decode('utf-8')).resolve() + if mapped not in {original.resolve(), (original.parent / 'deps' / original.name).resolve()} or read(mapped, 128 * 1024 * 1024) != data: + raise ValueError('macOS map output differs from actual original library') + sysroot = Path(subprocess.check_output(['rustc', '--print', 'sysroot'], text=True).strip()) + sdk = Path(subprocess.check_output(['xcrun', '--show-sdk-path'], text=True).strip()) + inputs = object_inputs(contents, original.parent / 'deps', sysroot / 'lib/rustlib' / target / 'lib', sdk) + result = {'target': target, 'role': role, 'binary': binary.name, 'binary_sha256': hashlib.sha256(data).hexdigest(), 'map_sha256': hashlib.sha256(contents).hexdigest(), **machine, 'objects': inputs, 'scope': 'Actual Cargo/std versus system-SDK static-input boundary and dynamic imports; not blanket SDK terms or completed npm package clearance.'} + (evidence / (role + '-macos-verification.json')).write_text(json.dumps(result, sort_keys=True, indent=2) + '\n', encoding='utf-8') + print(json.dumps(result, sort_keys=True)) + + +if __name__ == '__main__': + if len(sys.argv) != 7: + raise SystemExit('usage: macos_native_evidence.py BINARY ORIGINAL MAP EVIDENCE TARGET ROLE') + collect(Path(sys.argv[1]), Path(sys.argv[2]), Path(sys.argv[3]), Path(sys.argv[4]), sys.argv[5], sys.argv[6]) From 51ec15d8969c6815a00fa4558545247b411bf4ba Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sat, 31 Oct 2026 18:56:59 +0100 Subject: [PATCH 24/51] fix: drop unused libiconv from macOS NAPI addons Actual artifacts for both Darwin targets load libiconv without importing iconv or charset symbols. Add dead_strip_dylibs only to the NAPI link path; the observed C ABI libraries already use only libSystem and keep their existing flags. Require only libSystem and no iconv/charset imports for both roles, with four additional fail-closed regressions. Keep actual linker maps, SDK boundaries, CPU guards, resource scans and the matching NAPI consumer mandatory. No binding API or version changes. Co-Authored-By: Claude Opus 5.5 --- .../workflows/macos-native-notice-check.yml | 5 ++++- ci/test_macos_native_evidence.py | 19 +++++++++++++++++++ scripts/macos_native_evidence.py | 8 ++++++-- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/.github/workflows/macos-native-notice-check.yml b/.github/workflows/macos-native-notice-check.yml index f6565d1..be2985f 100644 --- a/.github/workflows/macos-native-notice-check.yml +++ b/.github/workflows/macos-native-notice-check.yml @@ -120,7 +120,10 @@ jobs: commands = [('napi', ['npx', '--no-install', 'napi', 'build', '--release', '-p', 'ktav-napi', '--target', target, '--platform', '--js', 'false', '--output-dir', '.']), ('cabi', ['cargo', 'build', '--locked', '--release', '-p', 'ktav-cabi', '--target', target])] for role, command in commands: link_map = evidence / (role + '-native-link.map') - environment = {**os.environ, 'CARGO_ENCODED_RUSTFLAGS': '-C' + chr(31) + 'link-arg=-Wl,-map,' + str(link_map), 'KTAV_NAPI_NOTICES_GZIP': str(evidence / 'NOTICE.json.gz'), 'RUSTC_LOG': 'rustc_codegen_ssa::back::link=info'} + flags = '-C' + chr(31) + 'link-arg=-Wl,-map,' + str(link_map) + if role == 'napi': + flags += chr(31) + '-C' + chr(31) + 'link-arg=-Wl,-dead_strip_dylibs' + environment = {**os.environ, 'CARGO_ENCODED_RUSTFLAGS': flags, 'KTAV_NAPI_NOTICES_GZIP': str(evidence / 'NOTICE.json.gz'), 'RUSTC_LOG': 'rustc_codegen_ssa::back::link=info'} result = subprocess.run(command, env=environment, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (evidence / (role + '-linker-trace.txt')).write_bytes(result.stderr) sys.stdout.buffer.write(result.stdout) diff --git a/ci/test_macos_native_evidence.py b/ci/test_macos_native_evidence.py index f9bf3f8..3342de2 100644 --- a/ci/test_macos_native_evidence.py +++ b/ci/test_macos_native_evidence.py @@ -58,6 +58,25 @@ def test_invalid_load_command_length_is_rejected(self): MACOS.macho(data) +class RuntimeImportTests(unittest.TestCase): + def test_only_system_library_passes(self): + MACOS.verify_runtime_imports(MACOS.macho(library())) + + def test_unused_iconv_dependency_is_rejected(self): + with self.assertRaisesRegex(ValueError, 'unused or unreviewed'): + MACOS.verify_runtime_imports(MACOS.macho(library(dependency='/usr/lib/libiconv.2.dylib'))) + + def test_iconv_symbol_is_rejected_even_with_system_library(self): + with self.assertRaisesRegex(ValueError, 'unused or unreviewed'): + MACOS.verify_runtime_imports(MACOS.macho(library('_iconv_open'))) + + def test_duplicate_system_dependency_is_rejected(self): + machine = MACOS.macho(library()) + machine['dynamic_libraries'] *= 2 + with self.assertRaisesRegex(ValueError, 'unused or unreviewed'): + MACOS.verify_runtime_imports(machine) + + class MapTests(unittest.TestCase): def fixture(self): temporary = tempfile.TemporaryDirectory() diff --git a/scripts/macos_native_evidence.py b/scripts/macos_native_evidence.py index 9fdf5e9..30d6361 100644 --- a/scripts/macos_native_evidence.py +++ b/scripts/macos_native_evidence.py @@ -132,6 +132,11 @@ def macho(data): return {'cpu': cpu, 'mach_o_filetype': kind, 'install_name': identities[0] if identities else None, 'dynamic_libraries': libraries, 'iconv_charset_undefined_symbols': imported, 'symbol_table_present': True} +def verify_runtime_imports(machine): + if machine['dynamic_libraries'] != ['/usr/lib/libSystem.B.dylib'] or machine['iconv_charset_undefined_symbols']: + raise ValueError('unused or unreviewed macOS dynamic dependency') + + def collect(binary, original, link_map, evidence, target, role): if target not in TARGETS or role not in {'napi', 'cabi'}: raise ValueError('unreviewed macOS target or role') @@ -141,8 +146,7 @@ def collect(binary, original, link_map, evidence, target, role): machine = macho(data) if machine['cpu'] != TARGETS[target]: raise ValueError('macOS CPU differs from target') - if not machine['dynamic_libraries'] or set(machine['dynamic_libraries']) - {'/usr/lib/libSystem.B.dylib', '/usr/lib/libiconv.2.dylib'}: - raise ValueError('unreviewed macOS system dynamic dependency') + verify_runtime_imports(machine) contents = read(link_map, 32 * 1024 * 1024) paths = re.findall(rb'^# Path:\s*(.+)$', contents, re.M) if len(paths) != 1: From 4d4861cbd4ad43faa206ffd2fab1095f6f4657ed Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sat, 31 Oct 2026 19:35:50 +0100 Subject: [PATCH 25/51] ci: probe Windows GNU LLVM C ABI compatibility Build the unchanged original 0.8.1 C ABI crate for both Windows GNU LLVM targets with the exact SDK already reviewed for LSP. Preserve Cargo/std evidence, actual PE imports/exports and machine, link maps, input fingerprints and original SDK legal documents. Exercise an x64 loader/export probe with SDK paths removed; do not claim parser-corpus execution or ARM execution. Do not switch NAPI targets: reviewed napi-build 2.6.0 requires libnode.dll for its GNU setup, unlike the existing Node.exe path. Runtime member licensing, embedding and npm delivery remain separate. No dependency versions, binding sources or production targets change. Co-Authored-By: Claude Opus 5.5 --- .../workflows/windows-cabi-gnullvm-check.yml | 258 ++++++++++++++++++ 1 file changed, 258 insertions(+) create mode 100644 .github/workflows/windows-cabi-gnullvm-check.yml diff --git a/.github/workflows/windows-cabi-gnullvm-check.yml b/.github/workflows/windows-cabi-gnullvm-check.yml new file mode 100644 index 0000000..4c2814a --- /dev/null +++ b/.github/workflows/windows-cabi-gnullvm-check.yml @@ -0,0 +1,258 @@ +name: Windows C ABI GNU LLVM compatibility evidence + +on: + pull_request: + +permissions: + contents: read + +env: + SOURCE_REF: 562deb3fde092d63a78f359be095e5079929d0d1 + +jobs: + cabi-gnullvm: + name: C ABI GNU LLVM / ${{ matrix.target }} + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + include: + - target: x86_64-pc-windows-gnullvm + compiler: x86_64-w64-mingw32-clang.exe + machine: 34404 + - target: aarch64-pc-windows-gnullvm + compiler: aarch64-w64-mingw32-clang.exe + machine: 43620 + env: + CABI_TARGET: ${{ matrix.target }} + CABI_COMPILER: ${{ matrix.compiler }} + CABI_MACHINE: ${{ matrix.machine }} + steps: + - uses: actions/checkout@v4 + - name: Preserve reviewed lock and notice tooling + shell: python + run: | + import os + import shutil + from pathlib import Path + stage = Path(os.environ['RUNNER_TEMP']) / 'cabi-gnullvm-tools' + stage.mkdir() + for name in ['Cargo.lock', 'ci/js-build-lock.json', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'ci/about.toml', 'ci/licenses/js-source-supplements.json']: + path = stage / name + path.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(name, path) + - uses: actions/checkout@v4 + with: + ref: ${{ env.SOURCE_REF }} + persist-credentials: false + - name: Restore tools without changing any binding sources + shell: python + run: | + import os + import shutil + import subprocess + from pathlib import Path + if subprocess.check_output(['git', 'rev-parse', 'HEAD'], text=True).strip() != os.environ['SOURCE_REF']: + raise SystemExit('unexpected Windows C ABI source') + stage = Path(os.environ['RUNNER_TEMP']) / 'cabi-gnullvm-tools' + for path in stage.rglob('*'): + if path.is_file(): + destination = Path(path.relative_to(stage)) + destination.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(path, destination) + subprocess.run(['git', 'diff', '--exit-code', '--', 'Cargo.toml', 'crates', 'package.json', 'package-lock.json'], check=True) + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - uses: dtolnay/rust-toolchain@1.99.1 + with: + targets: ${{ matrix.target }} + components: rust-docs + - uses: taiki-e/install-action@v2 + with: + tool: cargo-about@0.9.3 + - name: Prepare reviewed Cargo/std evidence + shell: python + run: | + import os + import shutil + import subprocess + import sys + from pathlib import Path + evidence = Path(os.environ['RUNNER_TEMP']) / 'cabi-gnullvm-evidence' + subprocess.run([sys.executable, 'scripts/prepare_js_notices.py', str(evidence)], check=True) + for name in ['LICENSE-MIT', 'LICENSE-APACHE']: + shutil.copyfile(name, evidence / name) + - name: Install the exact previously reviewed LLVM MinGW SDK + shell: python + run: | + import hashlib + import json + import os + import stat + import subprocess + import urllib.request + import zipfile + from pathlib import Path, PurePosixPath + root = Path(os.environ['RUNNER_TEMP']) + sdk = root / 'cabi-gnullvm-sdk' + sdk.mkdir() + archive_path = sdk / 'sdk.zip' + url = 'https://github.com/mstorsjo/llvm-mingw/releases/download/20261020/llvm-mingw-20261020-ucrt-x86_64.zip' + checksum = hashlib.sha256() + total = 0 + with urllib.request.urlopen(url, timeout=120) as response, archive_path.open('xb') as output: + while chunk := response.read(1024 * 1024): + total += len(chunk) + if total > 256 * 1024 * 1024: + raise SystemExit('candidate SDK size bound exceeded') + checksum.update(chunk) + output.write(chunk) + if checksum.hexdigest() != 'fd5462b7f5d93b2ff981fcd3f9c7e427e47f3203c64ea91c27bcc444eebd74cd': + raise SystemExit('candidate SDK differs from reviewed archive') + with zipfile.ZipFile(archive_path) as archive: + seen = set() + for item in archive.infolist(): + path = PurePosixPath(item.filename) + if path.is_absolute() or '..' in path.parts or '\\' in item.filename or ':' in item.filename or item.filename.casefold() in seen or stat.S_IFMT(item.external_attr >> 16) == stat.S_IFLNK: + raise SystemExit('unsafe or duplicate candidate SDK path') + seen.add(item.filename.casefold()) + archive.extractall(sdk) + install = sdk / 'llvm-mingw-20261020-ucrt-x86_64' + compiler = install / 'bin' / os.environ['CABI_COMPILER'] + if not compiler.is_file(): + raise SystemExit('candidate compiler missing') + evidence = root / 'cabi-gnullvm-evidence' + (evidence / 'compiler-version.txt').write_bytes(subprocess.check_output([str(compiler), '--version'])) + record = {'source_ref': os.environ['SOURCE_REF'], 'tooling_ref': os.environ['GITHUB_SHA'], 'target': os.environ['CABI_TARGET'], 'sdk_archive_sha256': checksum.hexdigest(), 'sdk_source': url, 'coverage': 'Compatibility and input probe only; not completed runtime licensing, embedded CABI notices, npm delivery or NAPI compatibility.'} + (evidence / 'source-provenance.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') + key = 'CARGO_TARGET_' + os.environ['CABI_TARGET'].upper().replace('-', '_') + '_LINKER' + flags = ['-C', 'target-feature=+crt-static', '-C', 'link-arg=-Wl,-Map,' + (evidence / 'native-link.map').as_posix(), '-C', 'link-arg=-Wl,--reproduce=' + (root / 'cabi-gnullvm-link.tar').as_posix()] + with Path(os.environ['GITHUB_ENV']).open('a', encoding='utf-8') as output: + for name, value in [(key, str(compiler)), ('CARGO_ENCODED_RUSTFLAGS', chr(31).join(flags)), ('LLVM_MINGW_CANDIDATE', str(install))]: + output.write(name + '=' + value + '\n') + with Path(os.environ['GITHUB_PATH']).open('a', encoding='utf-8') as output: + output.write(str(install / 'bin') + '\n') + - name: Build the unchanged C ABI crate + run: cargo build --locked --release -p ktav-cabi --target ${{ matrix.target }} + - name: Capture exact PE, link inputs and original SDK legal documents + shell: python + run: | + import base64 + import hashlib + import json + import os + import re + import shutil + import struct + import subprocess + import tarfile + from pathlib import Path, PurePosixPath + root = Path(os.environ['RUNNER_TEMP']) + evidence = root / 'cabi-gnullvm-evidence' + original = Path('target') / os.environ['CABI_TARGET'] / 'release/ktav_cabi.dll' + binary = evidence / 'ktav_cabi.dll' + shutil.copyfile(original, binary) + data = binary.read_bytes() + if len(data) < 64 or len(data) > 128 * 1024 * 1024 or data[:2] != b'MZ': + raise SystemExit('expected bounded PE library') + offset = int.from_bytes(data[60:64], 'little') + if offset + 24 > len(data) or data[offset:offset + 4] != b'PE\0\0' or struct.unpack_from(' 512 * 1024 * 1024: + raise SystemExit('missing or oversized linker reproduction') + inputs = [] + seen = set() + total = 0 + with tarfile.open(reproduction, mode='r:') as archive: + for item in archive: + path = PurePosixPath(item.name) + if path.is_absolute() or '..' in path.parts or '\\' in item.name or item.name in seen or item.issym() or item.islnk(): + raise SystemExit('unsafe linker input record') + seen.add(item.name) + if item.isdir(): + continue + if not item.isfile() or item.size > 128 * 1024 * 1024: + raise SystemExit('invalid linker input type/size') + total += item.size + if total > 512 * 1024 * 1024 or len(seen) > 8192: + raise SystemExit('link input inventory exceeds bound') + source = archive.extractfile(item) + checksum = hashlib.sha256() + size = 0 + while chunk := source.read(1024 * 1024): + checksum.update(chunk) + size += len(chunk) + if size != item.size: + raise SystemExit('truncated linker input') + inputs.append({'path': item.name, 'bytes': size, 'sha256': checksum.hexdigest()}) + if not any(item['path'].endswith('/response.txt') for item in inputs): + raise SystemExit('missing actual linker command evidence') + (evidence / 'link-input-fingerprints.json').write_text(json.dumps(inputs, sort_keys=True, indent=2) + '\n', encoding='utf-8') + legal = [] + total = 0 + for path in sorted(sdk.rglob('*')): + if not path.is_file() or not re.match(r'(?i)^(?:license|copying|copyright|notice|authors|disclaimer)', path.name): + continue + if path.stat().st_size > 4 * 1024 * 1024: + raise SystemExit('SDK legal document exceeds bound') + data = path.read_bytes() + total += len(data) + if total > 32 * 1024 * 1024: + raise SystemExit('SDK legal inventory exceeds bound') + try: + text = data.decode('utf-8') + except UnicodeDecodeError: + text = None + legal.append({'path': path.relative_to(sdk).as_posix(), 'sha256': hashlib.sha256(data).hexdigest(), 'raw_bytes_base64': base64.b64encode(data).decode('ascii'), 'utf8_text': text}) + (evidence / 'sdk-legal.json').write_text(json.dumps(legal, ensure_ascii=False, indent=2) + '\n', encoding='utf-8') + if Path('Cargo.lock').read_bytes() != (evidence / 'Cargo.lock').read_bytes(): + raise SystemExit('candidate changed the reviewed Cargo lock') + result = {'target': os.environ['CABI_TARGET'], 'binary_sha256': hashlib.sha256(binary.read_bytes()).hexdigest(), 'map_sha256': hashlib.sha256(link_map.read_bytes()).hexdigest(), 'machine': int(os.environ['CABI_MACHINE']), 'imports': imports, 'exports': [name.decode('ascii') for name in exports], 'sdk_legal_files': len(legal), 'coverage': 'Actual PE and input fingerprints; runtime source/member licensing and distribution notices remain separate.'} + (evidence / 'native-verification.json').write_text(json.dumps(result, sort_keys=True, indent=2) + '\n', encoding='utf-8') + - name: Load the actual x64 C ABI with SDK paths removed + if: matrix.target == 'x86_64-pc-windows-gnullvm' + shell: python + run: | + import hashlib + import json + import os + import shutil + import subprocess + import sys + from pathlib import Path + evidence = Path(os.environ['RUNNER_TEMP']) / 'cabi-gnullvm-evidence' + probe = Path(os.environ['RUNNER_TEMP']) / 'cabi-gnullvm-clean-path' + probe.mkdir() + binary = probe / 'ktav_cabi.dll' + shutil.copyfile(evidence / binary.name, binary) + windows = Path(os.environ['SystemRoot']) + environment = {**os.environ, 'PATH': str(windows / 'System32') + os.pathsep + str(windows)} + script = 'import ctypes; library=ctypes.CDLL("./ktav_cabi.dll"); [getattr(library,name) for name in ["ktav_version","ktav_loads","ktav_free"]]; print("C ABI library loaded and exports resolved")' + result = subprocess.run([sys.executable, '-I', '-c', script], cwd=probe, env=environment, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=30) + (evidence / 'loader-stdout.txt').write_bytes(result.stdout) + (evidence / 'loader-stderr.txt').write_bytes(result.stderr) + if result.returncode != 0: + raise SystemExit('actual C ABI library failed to load with SDK paths removed') + record = {'sdk_path_removed': True, 'only_own_dll_staged': True, 'exit_code': result.returncode, 'binary_sha256': hashlib.sha256(binary.read_bytes()).hexdigest(), 'scope': 'Matching-x64 DLL loader/export probe only; no Bun/Deno or parser-corpus claim. ARM DLL not executed.'} + (evidence / 'loader-probe.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') + - uses: actions/upload-artifact@v4 + if: always() + with: + name: cabi-gnullvm-evidence-${{ matrix.target }} + path: ${{ runner.temp }}/cabi-gnullvm-evidence/ + if-no-files-found: warn From 6f5db3d5a3e29cf8499b92356d017c2a9e9220ec Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sat, 31 Oct 2026 19:51:54 +0100 Subject: [PATCH 26/51] fix: recognize the Windows ProcessPrng system module Both C ABI candidates build successfully, but their PE import gate incorrectly rejects BCryptPrimitives.dll. Microsoft documents it as the system DLL for ProcessPrng, not an external compiler runtime. Add only that exact name and retain the non-OS runtime rejection. Exercise the active import predicate with the new system-module case and negative compiler-runtime/foreign-DLL cases. Preserve all CPU, export, input fingerprint and clean-PATH loader checks. Reference: https://learn.microsoft.com/en-us/windows/win32/seccng/processprng Co-Authored-By: Claude Opus 5.5 --- .github/workflows/windows-cabi-gnullvm-check.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows-cabi-gnullvm-check.yml b/.github/workflows/windows-cabi-gnullvm-check.yml index 4c2814a..1d9bc0b 100644 --- a/.github/workflows/windows-cabi-gnullvm-check.yml +++ b/.github/workflows/windows-cabi-gnullvm-check.yml @@ -163,8 +163,14 @@ jobs: pe = subprocess.check_output([str(sdk / 'bin/llvm-readobj.exe'), '--file-headers', '--coff-imports', '--coff-exports', str(binary)]) (evidence / 'pe-inputs.txt').write_bytes(pe) imports = [name.decode('ascii').lower() for name in re.findall(rb'^\s*Name: ([^\r\n]+[.]dll)\s*$', pe, re.M | re.I)] - allowed = {'kernel32.dll', 'ntdll.dll', 'ucrtbase.dll', 'msvcrt.dll', 'advapi32.dll', 'bcrypt.dll', 'crypt32.dll', 'dbghelp.dll', 'ole32.dll', 'oleaut32.dll', 'rpcrt4.dll', 'secur32.dll', 'shell32.dll', 'shlwapi.dll', 'user32.dll', 'userenv.dll', 'version.dll', 'ws2_32.dll', 'psapi.dll'} - if not imports or any(name not in allowed and not name.startswith(('api-ms-win-', 'ext-ms-win-')) for name in imports): + # https://learn.microsoft.com/en-us/windows/win32/seccng/processprng + allowed = {'kernel32.dll', 'ntdll.dll', 'ucrtbase.dll', 'msvcrt.dll', 'advapi32.dll', 'bcrypt.dll', 'bcryptprimitives.dll', 'crypt32.dll', 'dbghelp.dll', 'ole32.dll', 'oleaut32.dll', 'rpcrt4.dll', 'secur32.dll', 'shell32.dll', 'shlwapi.dll', 'user32.dll', 'userenv.dll', 'version.dll', 'ws2_32.dll', 'psapi.dll'} + def os_import(name): + return name in allowed or name.startswith(('api-ms-win-', 'ext-ms-win-')) + assert os_import('bcryptprimitives.dll') + for name in ['libunwind.dll', 'libgcc_s_seh-1.dll', 'libstdc++-6.dll', 'vcruntime140.dll', 'foreign.dll']: + assert not os_import(name), name + if not imports or not all(os_import(name) for name in imports): raise SystemExit('C ABI candidate imports a non-OS runtime DLL: ' + repr(imports)) exports = re.findall(rb'^\s*Name: (ktav_[^\r\n]+)\s*$', pe, re.M) if not {b'ktav_version', b'ktav_loads', b'ktav_free'} <= set(exports): From 99d6edd252c1d2364df3e06d645bae05a2f1f15d Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sat, 31 Oct 2026 20:56:31 +0100 Subject: [PATCH 27/51] ci: capture actual MSVC NAPI runtime inputs Build both MSVC targets from original 0.8.1 source with the reviewed lock and private Cargo/std resource. Select existing VC and Windows SDK libraries explicitly without installing tools or accepting terms. Capture final-target LINKREPRO, verbose library selection and map, input fingerprints, PE metadata and available original legal files. Do not upload SDK libraries or objects, or approve redistribution rights merely from these observations. Keep normal Node.exe targets, preserve the matching-x64 consumer, verify exact embedded notices and exercise six bounded PE/input tests. Production assembly, dependency versions and public APIs are unchanged. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/napi-msvc-input-check.yml | 211 ++++++++++++++++++++ ci/test_msvc_napi_evidence.py | 58 ++++++ scripts/collect_msvc_napi_evidence.py | 133 ++++++++++++ 3 files changed, 402 insertions(+) create mode 100644 .github/workflows/napi-msvc-input-check.yml create mode 100644 ci/test_msvc_napi_evidence.py create mode 100644 scripts/collect_msvc_napi_evidence.py diff --git a/.github/workflows/napi-msvc-input-check.yml b/.github/workflows/napi-msvc-input-check.yml new file mode 100644 index 0000000..cc5a7da --- /dev/null +++ b/.github/workflows/napi-msvc-input-check.yml @@ -0,0 +1,211 @@ +name: NAPI MSVC runtime input evidence + +on: + pull_request: + +permissions: + contents: read + +env: + SOURCE_REF: 562deb3fde092d63a78f359be095e5079929d0d1 + +jobs: + napi-msvc: + name: NAPI MSVC inputs / ${{ matrix.target }} + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + include: + - target: x86_64-pc-windows-msvc + arch: x64 + addon: ktav.win32-x64-msvc.node + - target: aarch64-pc-windows-msvc + arch: arm64 + addon: ktav.win32-arm64-msvc.node + env: + MSVC_TARGET: ${{ matrix.target }} + MSVC_ARCH: ${{ matrix.arch }} + MSVC_ADDON: ${{ matrix.addon }} + steps: + - uses: actions/checkout@v4 + - name: Preserve reviewed source overlay and notice tools + shell: python + run: | + import os + import shutil + from pathlib import Path + stage = Path(os.environ['RUNNER_TEMP']) / 'napi-msvc-tools' + stage.mkdir() + names = ['Cargo.lock', 'ci/js-build-lock.json', 'crates/napi/build.rs', 'scripts/patch_napi_notice_source.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'scripts/collect_msvc_napi_evidence.py', 'ci/test_msvc_napi_evidence.py', 'ci/about.toml', 'ci/licenses/js-source-supplements.json'] + for name in names: + path = stage / name + path.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(name, path) + - uses: actions/checkout@v4 + with: + ref: ${{ env.SOURCE_REF }} + persist-credentials: false + - name: Restore tools and the two private resource changes only + shell: python + run: | + import hashlib + import json + import os + import shutil + import subprocess + import sys + from pathlib import Path + if subprocess.check_output(['git', 'rev-parse', 'HEAD'], text=True).strip() != os.environ['SOURCE_REF']: + raise SystemExit('unexpected MSVC NAPI source') + overlay = ['crates/napi/build.rs', 'crates/napi/src/lib.rs'] + baseline = {name: hashlib.sha256(Path(name).read_bytes()).hexdigest() for name in overlay} + stage = Path(os.environ['RUNNER_TEMP']) / 'napi-msvc-tools' + for path in stage.rglob('*'): + if path.is_file(): + destination = Path(path.relative_to(stage)) + destination.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(path, destination) + subprocess.run([sys.executable, '-I', 'scripts/patch_napi_notice_source.py', 'crates/napi/src/lib.rs'], check=True) + changed = subprocess.check_output(['git', 'diff', '--name-only', '--', 'Cargo.toml', 'crates', 'tests/node', 'root-docs', 'package.json', 'package-lock.json'], text=True).splitlines() + if set(changed) != set(overlay): + raise SystemExit('MSVC source overlay changed more than the private resource files') + record = {'source_ref': os.environ['SOURCE_REF'], 'tooling_ref': os.environ['GITHUB_SHA'], 'binding_overlay': {name: {'baseline_sha256': baseline[name], 'compiled_sha256': hashlib.sha256(Path(name).read_bytes()).hexdigest()} for name in overlay}, 'scope': 'Original 0.8.1 source with private NAPI Cargo/std resource only; not historical dependency evidence.'} + (Path(os.environ['RUNNER_TEMP']) / 'napi-msvc-source.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - uses: actions/setup-node@v4 + with: + node-version: '24' + - uses: dtolnay/rust-toolchain@1.99.1 + with: + targets: ${{ matrix.target }} + components: rust-docs, llvm-tools-preview + - uses: taiki-e/install-action@v2 + with: + tool: cargo-about@0.9.3 + - name: Verify PE and bounded input regression guards + run: python -I -m unittest discover -s ci -p test_msvc_napi_evidence.py -v + - name: Prepare exact reviewed Cargo/std notices + shell: python + run: | + import os + import shutil + import subprocess + import sys + from pathlib import Path + evidence = Path(os.environ['RUNNER_TEMP']) / 'napi-msvc-evidence' + subprocess.run([sys.executable, 'scripts/prepare_js_notices.py', str(evidence)], check=True) + shutil.copyfile(Path(os.environ['RUNNER_TEMP']) / 'napi-msvc-source.json', evidence / 'source-provenance.json') + for name in ['LICENSE-MIT', 'LICENSE-APACHE']: + shutil.copyfile(name, evidence / name) + - name: Resolve unchanged npm manifest and verify tool licenses + shell: bash + run: | + set -euo pipefail + cp package-lock.json "$RUNNER_TEMP/napi-msvc-evidence/npm-lock-source.json" + npm install --ignore-scripts --no-audit --no-fund + git diff --exit-code -- package.json + cp package-lock.json "$RUNNER_TEMP/napi-msvc-evidence/npm-lock-resolved.json" + node scripts/check-npm-licenses.mjs + node -e 'if(require("@napi-rs/cli/package.json").version!=="3.6.2")throw new Error("NAPI CLI version requires review")' + - name: Select existing VC and Windows SDK without installing components + shell: python + run: | + import hashlib + import json + import os + import subprocess + from pathlib import Path + base = Path(os.environ['ProgramFiles(x86)']) + vswhere = base / 'Microsoft Visual Studio/Installer/vswhere.exe' + installations = json.loads(subprocess.check_output([str(vswhere), '-all', '-products', '*', '-format', 'json'], encoding='utf-8-sig')) + arch = os.environ['MSVC_ARCH'] + selected = None + for installation in sorted(installations, key=lambda item: tuple(map(int, item['installationVersion'].split('.'))), reverse=True): + vs = Path(installation['installationPath']) + version_file = vs / 'VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt' + if not version_file.is_file(): + continue + version = version_file.read_text(encoding='utf-8-sig').strip() + tools = vs / 'VC/Tools/MSVC' / version + linker = tools / 'bin/Hostx64' / arch / 'link.exe' + if linker.is_file() and (tools / 'lib' / arch).is_dir(): + selected = (vs, tools, linker, version, installation['installationVersion']) + break + if selected is None: + raise SystemExit('requested existing MSVC cross-linker is missing') + vs, tools, linker, version, installation_version = selected + sdk = base / 'Windows Kits/10' + versions = [path for path in (sdk / 'Lib').iterdir() if path.is_dir() and all(part.isdigit() for part in path.name.split('.')) and (path / 'ucrt' / arch).is_dir() and (path / 'um' / arch).is_dir()] + if not versions: + raise SystemExit('matching existing Windows SDK library directories missing') + sdk_lib = max(versions, key=lambda path: tuple(map(int, path.name.split('.')))) + libraries = [tools / 'lib' / arch, sdk_lib / 'ucrt' / arch, sdk_lib / 'um' / arch] + evidence = Path(os.environ['RUNNER_TEMP']) / 'napi-msvc-evidence' + record = {'target': os.environ['MSVC_TARGET'], 'visual_studio_root': str(vs), 'visual_studio_version': installation_version, 'vctools_version': version, 'linker': str(linker), 'linker_sha256': hashlib.sha256(linker.read_bytes()).hexdigest(), 'windows_sdk_root': str(sdk), 'windows_sdk_version': sdk_lib.name, 'library_directories': list(map(str, libraries)), 'scope': 'Selected installed compiler/SDK identities; not agreement acceptance or distribution permission.'} + (evidence / 'selected-sdk.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') + - name: Build the actual addon with final-target MSVC link reproduction + shell: python + run: | + import json + import os + import shutil + import subprocess + import sys + from pathlib import Path + evidence = Path(os.environ['RUNNER_TEMP']) / 'napi-msvc-evidence' + sdk = json.loads((evidence / 'selected-sdk.json').read_text(encoding='utf-8')) + reproduction = Path(os.environ['RUNNER_TEMP']) / 'napi-msvc-link' + reproduction.mkdir() + if os.environ.get('RUSTFLAGS') or os.environ.get('CARGO_ENCODED_RUSTFLAGS'): + raise SystemExit('preexisting MSVC linker flags require review') + flags = ['-C', 'link-arg=/MAP:' + str(evidence / 'native-link.map'), '-C', 'link-arg=/VERBOSE:LIB', '-C', 'link-arg=/LINKREPRO:' + str(reproduction), '-C', 'link-arg=/LINKREPROTARGET:ktav_napi.dll'] + for library in sdk['library_directories']: + flags += ['-C', 'link-arg=/LIBPATH:' + library] + key = 'CARGO_TARGET_' + os.environ['MSVC_TARGET'].upper().replace('-', '_') + '_LINKER' + environment = {**os.environ, key: sdk['linker'], 'CARGO_ENCODED_RUSTFLAGS': chr(31).join(flags), 'KTAV_NAPI_NOTICES_GZIP': str(evidence / 'NOTICE.json.gz'), 'RUSTC_LOG': 'rustc_codegen_ssa::back::link=info'} + command = ['npx.cmd', '--no-install', 'napi', 'build', '--release', '-p', 'ktav-napi', '--target', os.environ['MSVC_TARGET'], '--platform', '--js', 'false', '--output-dir', '.'] + result = subprocess.run(command, env=environment, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + (evidence / 'linker-stdout.txt').write_bytes(result.stdout) + (evidence / 'linker-stderr.txt').write_bytes(result.stderr) + sys.stdout.buffer.write(result.stdout) + sys.stderr.buffer.write(result.stderr) + if result.returncode: + raise SystemExit(result.returncode) + binary = Path(os.environ['MSVC_ADDON']) + staged = evidence / binary.name + shutil.copyfile(binary, staged) + original = Path('target') / os.environ['MSVC_TARGET'] / 'release/ktav_napi.dll' + subprocess.run([sys.executable, '-I', 'scripts/collect_msvc_napi_evidence.py', str(evidence), str(staged), str(original), str(evidence / 'selected-sdk.json'), str(reproduction), os.environ['MSVC_TARGET']], check=True) + report = subprocess.check_output([sys.executable, '-I', 'scripts/check_embedded_notices.py', str(staged), str(evidence / 'NOTICE.json')]) + (evidence / 'embedded-notice-verification.json').write_bytes(report) + if Path('Cargo.lock').read_bytes() != (evidence / 'Cargo.lock').read_bytes(): + raise SystemExit('MSVC build changed the reviewed lock') + - name: Run actual matching-x64 Node consumer + if: matrix.target == 'x86_64-pc-windows-msvc' + shell: python + run: | + import hashlib + import json + import os + import shutil + import subprocess + from pathlib import Path + evidence = Path(os.environ['RUNNER_TEMP']) / 'napi-msvc-evidence' + if subprocess.check_output(['node', '-p', 'process.arch'], text=True).strip() != 'x64': + raise SystemExit('matching x64 Node consumer required') + subprocess.run(['npm.cmd', 'run', 'build:ts'], check=True) + Path('dist/native').mkdir(parents=True, exist_ok=True) + shutil.copyfile(evidence / os.environ['MSVC_ADDON'], Path('dist/native') / os.environ['MSVC_ADDON']) + script = 'import assert from "node:assert/strict";import {createRequire} from "node:module";import {realpathSync} from "node:fs";await import("./dist/ts/node.js");const require=createRequire(import.meta.url);const expected=realpathSync("dist/native/"+process.env.MSVC_ADDON);assert.deepEqual(Object.keys(require.cache).filter(p=>p.endsWith(".node")),[expected]);await import("./tests/node/run-node-napi.mjs");' + subprocess.run(['node', '--input-type=module', '-e', script], check=True) + record = {'loaded_built_addon': True, 'binary_sha256': hashlib.sha256((evidence / os.environ['MSVC_ADDON']).read_bytes()).hexdigest(), 'scope': 'Matching-x64 NAPI consumer only; ARM addon not executed.'} + (evidence / 'consumer.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') + - uses: actions/upload-artifact@v4 + if: always() + with: + name: napi-msvc-evidence-${{ matrix.target }} + path: ${{ runner.temp }}/napi-msvc-evidence/ + if-no-files-found: warn diff --git a/ci/test_msvc_napi_evidence.py b/ci/test_msvc_napi_evidence.py new file mode 100644 index 0000000..6bd97ec --- /dev/null +++ b/ci/test_msvc_napi_evidence.py @@ -0,0 +1,58 @@ +"""Проверить MSVC PE и bounded input guards без native исполнения.""" + +import importlib.util +from pathlib import Path +import struct +import tempfile +import unittest + +SCRIPT = Path(__file__).resolve().parents[1] / 'scripts/collect_msvc_napi_evidence.py' +SPEC = importlib.util.spec_from_file_location('msvc', SCRIPT) +MSVC = importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(MSVC) + + +def pe(machine=0x8664, characteristics=0x2000): + header = bytearray(64) + header[:2] = b'MZ' + struct.pack_into(' limit: + raise ValueError('MSVC input exceeds bound') + return data + + +def fingerprint(path, limit): + if path.is_symlink() or not path.is_file() or path.stat().st_size > limit: + raise ValueError('unreviewed MSVC fingerprint input') + checksum = hashlib.sha256() + total = 0 + with path.open('rb') as source: + while chunk := source.read(1024 * 1024): + total += len(chunk) + if total > limit: + raise ValueError('MSVC fingerprint exceeds bound') + checksum.update(chunk) + return {'bytes': total, 'sha256': checksum.hexdigest()} + + +def pe_machine(data): + if len(data) < 64 or data[:2] != b'MZ': + raise ValueError('expected MSVC PE library') + offset = int.from_bytes(data[60:64], 'little') + if offset + 24 > len(data) or data[offset:offset + 4] != b'PE\0\0' or not struct.unpack_from(' 512 * 1024 * 1024 or len(inputs) >= 8192: + raise ValueError('MSVC reproduction exceeds bounds') + relative = path.relative_to(reproduction).as_posix() + inputs.append({'path': relative, **record}) + if path.suffix.lower() == '.rsp' and 'environment' not in path.name.lower(): + raw = read(path, 4 * 1024 * 1024) + responses.append({'path': relative, 'raw_bytes_base64': base64.b64encode(raw).decode('ascii'), **record}) + if not inputs or not responses: + raise ValueError('actual final MSVC link reproduction/response missing') + (evidence / 'link-input-fingerprints.json').write_text(json.dumps(inputs, sort_keys=True, indent=2) + '\n', encoding='utf-8') + (evidence / 'link-responses.json').write_text(json.dumps(responses, sort_keys=True, indent=2) + '\n', encoding='utf-8') + roots = {'visual-studio': Path(info['visual_studio_root']), 'windows-sdk': Path(info['windows_sdk_root'])} + candidates = [] + for role, root in roots.items(): + candidates.extend((role, root, path) for path in root.iterdir() if path.is_file()) + folders = ['Licenses', 'License', 'license', 'Redist'] + if role == 'visual-studio': + folders += ['VC/Redist', 'VC/Auxiliary/Build'] + for folder in folders: + parent = root / folder + if not parent.is_dir(): + continue + for index, path in enumerate(parent.rglob('*')): + if index >= 32768: + raise ValueError('SDK legal path enumeration exceeds bound') + if path.is_file() and len(path.relative_to(parent).parts) <= 5: + candidates.append((role, root, path)) + legal = [] + seen = set() + total = 0 + for role, root, path in candidates: + if path.suffix.lower() not in {'.txt', '.html', '.htm', '.rtf', '.md'} or not re.search(r'license|licence|eula|notice|copyright|redist', path.name, re.I): + continue + key = role + '/' + path.relative_to(root).as_posix() + if key.casefold() in seen: + continue + seen.add(key.casefold()) + if not path.resolve().is_relative_to(root.resolve()): + raise ValueError('SDK legal document escapes selected installation') + raw = read(path, 4 * 1024 * 1024) + total += len(raw) + if total > 32 * 1024 * 1024 or len(legal) >= 1024: + raise ValueError('MSVC SDK legal inventory exceeds bound') + try: + text = raw.decode('utf-16') if raw.startswith((b'\xff\xfe', b'\xfe\xff')) else raw.decode('utf-8-sig') + except UnicodeDecodeError: + text = None + legal.append({'path': key, 'sha256': hashlib.sha256(raw).hexdigest(), 'bytes': len(raw), 'raw_bytes_base64': base64.b64encode(raw).decode('ascii'), 'decoded_text': text, 'requires_encoding_review': text is None}) + (evidence / 'sdk-legal.json').write_text(json.dumps(legal, ensure_ascii=False, indent=2) + '\n', encoding='utf-8') + imports = re.findall(rb'^\s*Name: ([^\r\n]+[.](?:dll|exe))\s*$', pe, re.M | re.I) + link_map = read(evidence / 'native-link.map', 32 * 1024 * 1024) + result = {'target': target, 'binary_sha256': hashlib.sha256(data).hexdigest(), 'map_sha256': hashlib.sha256(link_map).hexdigest(), 'machine': machines[target], 'imports': [name.decode('ascii') for name in imports], 'input_count': len(inputs), 'sdk_legal_files': len(legal), 'selected_sdk': info, 'scope': 'Actual selected MSVC NAPI build inputs and available original SDK documents only. Host imports are not included code; no redistribution-rights approval or historical build claim.'} + (evidence / 'native-msvc-verification.json').write_text(json.dumps(result, sort_keys=True, indent=2) + '\n', encoding='utf-8') + print(json.dumps(result, sort_keys=True)) + + +if __name__ == '__main__': + if len(sys.argv) != 7: + raise SystemExit('usage: collect_msvc_napi_evidence.py EVIDENCE BINARY ORIGINAL SDK_INFO REPRODUCTION TARGET') + collect(*map(Path, sys.argv[1:6]), sys.argv[6]) From 4c3992d317cc67ec7b7370e1c03a76ba7b0f1b14 Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sat, 31 Oct 2026 21:10:16 +0100 Subject: [PATCH 28/51] ci: identify oversized MSVC legal originals before copying Both MSVC addons build, but original SDK document collection stops at the existing 4 MiB per-file bound. Persist the complete legal path/size index before reading documents and identify the exact oversized original in the failure message. Do not raise any size limit, drop copyright text, skip required material or approve redistribution rights without examining it. Co-Authored-By: Claude Opus 5.5 --- scripts/collect_msvc_napi_evidence.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/collect_msvc_napi_evidence.py b/scripts/collect_msvc_napi_evidence.py index 3b24163..38e9a54 100644 --- a/scripts/collect_msvc_napi_evidence.py +++ b/scripts/collect_msvc_napi_evidence.py @@ -98,6 +98,17 @@ def collect(evidence, binary, original, sdk_info, reproduction, target): raise ValueError('SDK legal path enumeration exceeds bound') if path.is_file() and len(path.relative_to(parent).parts) <= 5: candidates.append((role, root, path)) + legal_index = [] + indexed = set() + for role, root, path in candidates: + if path.suffix.lower() not in {'.txt', '.html', '.htm', '.rtf', '.md'} or not re.search(r'license|licence|eula|notice|copyright|redist', path.name, re.I): + continue + key = role + '/' + path.relative_to(root).as_posix() + if key.casefold() in indexed: + continue + indexed.add(key.casefold()) + legal_index.append({'path': key, 'bytes': path.lstat().st_size, 'symlink': path.is_symlink()}) + (evidence / 'sdk-legal-index.json').write_text(json.dumps(legal_index, sort_keys=True, indent=2) + '\n', encoding='utf-8') legal = [] seen = set() total = 0 @@ -110,6 +121,8 @@ def collect(evidence, binary, original, sdk_info, reproduction, target): seen.add(key.casefold()) if not path.resolve().is_relative_to(root.resolve()): raise ValueError('SDK legal document escapes selected installation') + if path.stat().st_size > 4 * 1024 * 1024: + raise ValueError(f'SDK legal original exceeds 4 MiB: {key}; bytes={path.stat().st_size}') raw = read(path, 4 * 1024 * 1024) total += len(raw) if total > 32 * 1024 * 1024 or len(legal) >= 1024: From 77269a47d74c6878cd084788cfed41c72203b74d Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sat, 31 Oct 2026 21:30:24 +0100 Subject: [PATCH 29/51] fix(ci): collect the complete observed MSVC notice Keep the default 4 MiB legal-document cap. Permit the observed 6,167,634-byte ThirdPartyNotices.txt only at its exact selected Visual Studio, VC Tools and Windows SDK identity and relative path. Preserve complete original bytes, hashes, root checks and the total 32 MiB inventory cap. This is evidence collection, not a license allowlist or approval of redistribution rights. Add regressions for unchanged default bounds, changed installation identities, paths, sizes and reader overflow. Run them only in CI. Co-Authored-By: Claude Opus 5.5 --- ci/test_msvc_napi_evidence.py | 29 +++++++++++++++++++++++++++ scripts/collect_msvc_napi_evidence.py | 18 ++++++++++++++--- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/ci/test_msvc_napi_evidence.py b/ci/test_msvc_napi_evidence.py index 6bd97ec..e3f62b7 100644 --- a/ci/test_msvc_napi_evidence.py +++ b/ci/test_msvc_napi_evidence.py @@ -42,6 +42,35 @@ def test_outside_pe_offset_is_rejected(self): with self.assertRaisesRegex(ValueError, 'DLL image'): MSVC.pe_machine(data) + def test_default_legal_limit_is_unchanged(self): + self.assertEqual(MSVC.legal_read_limit('unknown/NOTICE.txt', {}, 4 * 1024 * 1024), 4 * 1024 * 1024) + with self.assertRaisesRegex(ValueError, 'exceeds 4 MiB'): + MSVC.legal_read_limit('unknown/NOTICE.txt', {}, 4 * 1024 * 1024 + 1) + + def test_observed_large_original_is_collectable_only_at_exact_identity(self): + key = 'visual-studio/Licenses/1033/ThirdPartyNotices.txt' + info = {'visual_studio_version': '18.11.12315.225', 'vctools_version': '14.51.36231', 'windows_sdk_version': '10.0.26100.0'} + self.assertEqual(MSVC.legal_read_limit(key, info, 6167634), 6167634) + for field in info: + with self.subTest(field=field), self.assertRaisesRegex(ValueError, 'exceeds 4 MiB'): + MSVC.legal_read_limit(key, {**info, field: 'unreviewed'}, 6167634) + for name in [key.lower(), key + '.other', 'windows-sdk/Licenses/1033/ThirdPartyNotices.txt']: + with self.subTest(path=name), self.assertRaisesRegex(ValueError, 'exceeds 4 MiB'): + MSVC.legal_read_limit(name, info, 6167634) + for size in [6167633, 6167635, 32 * 1024 * 1024]: + with self.subTest(size=size), self.assertRaisesRegex(ValueError, 'exceeds 4 MiB'): + MSVC.legal_read_limit(key, info, size) + + def test_large_original_reader_still_rejects_overflow(self): + with tempfile.TemporaryDirectory() as temporary: + path = Path(temporary) / 'ThirdPartyNotices.txt' + path.write_bytes(b'x' * 6167634) + self.assertEqual(len(MSVC.read(path, 6167634)), 6167634) + with path.open('ab') as output: + output.write(b'x') + with self.assertRaisesRegex(ValueError, 'exceeds bound'): + MSVC.read(path, 6167634) + def test_read_and_fingerprint_size_bounds(self): with tempfile.TemporaryDirectory() as temporary: path = Path(temporary) / 'input.data' diff --git a/scripts/collect_msvc_napi_evidence.py b/scripts/collect_msvc_napi_evidence.py index 38e9a54..99ed2dd 100644 --- a/scripts/collect_msvc_napi_evidence.py +++ b/scripts/collect_msvc_napi_evidence.py @@ -43,6 +43,20 @@ def pe_machine(data): return struct.unpack_from(' 4 * 1024 * 1024: - raise ValueError(f'SDK legal original exceeds 4 MiB: {key}; bytes={path.stat().st_size}') - raw = read(path, 4 * 1024 * 1024) + raw = read(path, legal_read_limit(key, info, path.stat().st_size)) total += len(raw) if total > 32 * 1024 * 1024 or len(legal) >= 1024: raise ValueError('MSVC SDK legal inventory exceeds bound') From d782af21147e0b6124306fc8988df3e2a880525b Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sat, 31 Oct 2026 21:38:16 +0100 Subject: [PATCH 30/51] fix(ci): check out pinned corpus for MSVC consumer The x64 addon builds and its complete legal evidence is collected. Its actual Node consumer then correctly rejects the missing spec manifest, invalid_utf8 fixtures and strict-lossy corpus. Initialize recursive submodules at the original 0.8.1 source ref. Do not change any spec pin, fixture, consumer assertion or version. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/napi-msvc-input-check.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/napi-msvc-input-check.yml b/.github/workflows/napi-msvc-input-check.yml index cc5a7da..0a2acfc 100644 --- a/.github/workflows/napi-msvc-input-check.yml +++ b/.github/workflows/napi-msvc-input-check.yml @@ -45,6 +45,7 @@ jobs: - uses: actions/checkout@v4 with: ref: ${{ env.SOURCE_REF }} + submodules: recursive persist-credentials: false - name: Restore tools and the two private resource changes only shell: python From 7d8148acc7681196283bd7e63593e5aa7863a12d Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sat, 31 Oct 2026 22:51:58 +0100 Subject: [PATCH 31/51] fix: retain Cargo and std notices in JS C ABI libraries Use the existing native-binding metadata pattern: a bounded gzip resource with marker, LE64 length and immutable exported static data. It is not a CString, callable parser API or ktav_free-owned buffer. Keep the default development stub when no prepared notice is given. Add four std-only Rust encoder tests and five source-preservation regressions, executed only in CI. Graft one include and its build hook onto original 0.8.1 source; do not copy newer core API code. Record the exact four native notice files, including the new untracked build hook, and reject other protected source changes. Build and scan both actual macOS C ABI resources against the reviewed Cargo/std JSON. Preserve existing CPU, SDK, import, source/core/lock and NAPI consumer checks. No dependency, unsafe code, parser function, MSRV, version, release or registry publication change is included. Other-target runtime grants and npm assembly remain separate work. Co-Authored-By: Claude Opus 5.5 --- .../workflows/macos-native-notice-check.yml | 37 +++++-- ci/test_cabi_notice_overlay.py | 41 +++++++ crates/cabi/build.rs | 103 ++++++++++++++++++ crates/cabi/src/lib.rs | 2 + scripts/patch_cabi_notice_source.py | 22 ++++ 5 files changed, 193 insertions(+), 12 deletions(-) create mode 100644 ci/test_cabi_notice_overlay.py create mode 100644 crates/cabi/build.rs create mode 100644 scripts/patch_cabi_notice_source.py diff --git a/.github/workflows/macos-native-notice-check.yml b/.github/workflows/macos-native-notice-check.yml index be2985f..b41ee33 100644 --- a/.github/workflows/macos-native-notice-check.yml +++ b/.github/workflows/macos-native-notice-check.yml @@ -34,7 +34,7 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'macos-native-tools' stage.mkdir() - names = ['Cargo.lock', 'ci/js-build-lock.json', 'crates/napi/build.rs', 'scripts/patch_napi_notice_source.py', 'scripts/macos_native_evidence.py', 'ci/test_macos_native_evidence.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json'] + names = ['Cargo.lock', 'ci/js-build-lock.json', 'crates/napi/build.rs', 'crates/cabi/build.rs', 'scripts/patch_napi_notice_source.py', 'scripts/patch_cabi_notice_source.py', 'ci/test_cabi_notice_overlay.py', 'scripts/macos_native_evidence.py', 'ci/test_macos_native_evidence.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json'] for name in names: destination = stage / name destination.parent.mkdir(parents=True, exist_ok=True) @@ -44,7 +44,7 @@ jobs: ref: ${{ env.SOURCE_REF }} submodules: recursive persist-credentials: false - - name: Restore tools and graft only private NAPI metadata + - name: Restore tools and graft only native notice metadata shell: python run: | import hashlib @@ -56,8 +56,8 @@ jobs: from pathlib import Path if subprocess.check_output(['git', 'rev-parse', 'HEAD'], text=True).strip() != os.environ['SOURCE_REF']: raise SystemExit('unexpected macOS source revision') - overlay = ['crates/napi/build.rs', 'crates/napi/src/lib.rs'] - baseline = {name: hashlib.sha256(Path(name).read_bytes()).hexdigest() for name in overlay} + overlay = ['crates/napi/build.rs', 'crates/napi/src/lib.rs', 'crates/cabi/build.rs', 'crates/cabi/src/lib.rs'] + baseline = {name: hashlib.sha256(Path(name).read_bytes()).hexdigest() if Path(name).is_file() else None for name in overlay} stage = Path(os.environ['RUNNER_TEMP']) / 'macos-native-tools' for path in stage.rglob('*'): if path.is_file(): @@ -65,10 +65,13 @@ jobs: destination.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(path, destination) subprocess.run([sys.executable, '-I', 'scripts/patch_napi_notice_source.py', 'crates/napi/src/lib.rs'], check=True) - changed = subprocess.check_output(['git', 'diff', '--name-only', '--', 'Cargo.toml', 'crates', 'tests/node', 'root-docs', 'package.json', 'package-lock.json'], text=True).splitlines() - if set(changed) != set(overlay): - raise SystemExit('macOS source overlay changed more than the two private resource files') - record = {'source_ref': os.environ['SOURCE_REF'], 'tooling_ref': os.environ['GITHUB_SHA'], 'binding_overlay': {name: {'baseline_sha256': baseline[name], 'compiled_sha256': hashlib.sha256(Path(name).read_bytes()).hexdigest()} for name in overlay}, 'scope': 'Original 0.8.1 source with private NAPI Cargo/std resource only; CABI source remains unchanged.'} + subprocess.run([sys.executable, '-I', 'scripts/patch_cabi_notice_source.py', 'crates/cabi/src/lib.rs'], check=True) + protected = ['Cargo.toml', 'crates', 'tests/node', 'root-docs', 'package.json', 'package-lock.json'] + changed = set(subprocess.check_output(['git', 'diff', '--name-only', '--', *protected], text=True).splitlines()) + changed.update(subprocess.check_output(['git', 'ls-files', '--others', '--exclude-standard', '--', *protected], text=True).splitlines()) + if changed != set(overlay): + raise SystemExit('macOS source overlay changed more than the four native notice files') + record = {'source_ref': os.environ['SOURCE_REF'], 'tooling_ref': os.environ['GITHUB_SHA'], 'binding_overlay': {name: {'baseline_sha256': baseline[name], 'compiled_sha256': hashlib.sha256(Path(name).read_bytes()).hexdigest()} for name in overlay}, 'scope': 'Original 0.8.1 parser APIs with NAPI/CABI Cargo/std notice metadata only; not historical dependency evidence.'} (Path(os.environ['RUNNER_TEMP']) / 'macos-native-source.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') - uses: actions/setup-node@v4 with: @@ -82,6 +85,17 @@ jobs: tool: cargo-about@0.9.3 - name: Verify Mach-O and SDK-boundary regressions run: python3 -I -m unittest discover -s ci -p test_macos_native_evidence.py -v + - name: Verify source-preserving C ABI overlay and resource encoder + shell: python + run: | + import os + import subprocess + import sys + from pathlib import Path + subprocess.run([sys.executable, '-I', '-m', 'unittest', 'discover', '-s', 'ci', '-p', 'test_cabi_notice_overlay.py', '-v'], check=True) + encoder = Path(os.environ['RUNNER_TEMP']) / 'cabi-notice-encoder-tests' + subprocess.run(['rustc', '--test', '--edition=2021', 'crates/cabi/build.rs', '-o', str(encoder)], check=True) + subprocess.run([str(encoder)], check=True) - name: Prepare reviewed Cargo/std notices and source evidence shell: python run: | @@ -123,7 +137,7 @@ jobs: flags = '-C' + chr(31) + 'link-arg=-Wl,-map,' + str(link_map) if role == 'napi': flags += chr(31) + '-C' + chr(31) + 'link-arg=-Wl,-dead_strip_dylibs' - environment = {**os.environ, 'CARGO_ENCODED_RUSTFLAGS': flags, 'KTAV_NAPI_NOTICES_GZIP': str(evidence / 'NOTICE.json.gz'), 'RUSTC_LOG': 'rustc_codegen_ssa::back::link=info'} + environment = {**os.environ, 'CARGO_ENCODED_RUSTFLAGS': flags, 'KTAV_NAPI_NOTICES_GZIP': str(evidence / 'NOTICE.json.gz'), 'KTAV_CABI_NOTICES_GZIP': str(evidence / 'NOTICE.json.gz'), 'RUSTC_LOG': 'rustc_codegen_ssa::back::link=info'} result = subprocess.run(command, env=environment, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (evidence / (role + '-linker-trace.txt')).write_bytes(result.stderr) sys.stdout.buffer.write(result.stdout) @@ -135,9 +149,8 @@ jobs: staged = evidence / binary.name shutil.copyfile(binary, staged) subprocess.run([sys.executable, '-I', 'scripts/macos_native_evidence.py', str(staged), str(original), str(link_map), str(evidence), target, role], check=True) - if role == 'napi': - report = subprocess.check_output([sys.executable, '-I', 'scripts/check_embedded_notices.py', str(staged), str(evidence / 'NOTICE.json')]) - (evidence / 'napi-embedded-verification.json').write_bytes(report) + report = subprocess.check_output([sys.executable, '-I', 'scripts/check_embedded_notices.py', str(staged), str(evidence / 'NOTICE.json')]) + (evidence / (role + '-embedded-verification.json')).write_bytes(report) if Path('Cargo.lock').read_bytes() != (evidence / 'Cargo.lock').read_bytes(): raise SystemExit('macOS build changed the reviewed Cargo lock') for name, command in [('clang-version.txt', ['clang', '--version']), ('sdk-version.txt', ['xcrun', '--show-sdk-version']), ('xcode-version.txt', ['xcodebuild', '-version'])]: diff --git a/ci/test_cabi_notice_overlay.py b/ci/test_cabi_notice_overlay.py new file mode 100644 index 0000000..cf7e1cc --- /dev/null +++ b/ci/test_cabi_notice_overlay.py @@ -0,0 +1,41 @@ +"""CI-регрессии source-preserving C ABI metadata overlay.""" + +import importlib.util +from pathlib import Path +import unittest + +SCRIPT = Path(__file__).resolve().parents[1] / 'scripts/patch_cabi_notice_source.py' +SPEC = importlib.util.spec_from_file_location('cabi_overlay', SCRIPT) +MODULE = importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(MODULE) + + +class CabiOverlayTests(unittest.TestCase): + def test_original_body_is_preserved(self): + source = '//! Original 0.8.1 source.\n\nktav::declare_cabi!();\n' + result = MODULE.patch_source(source) + self.assertEqual(result.replace(MODULE.INSERTION, '', 1), source) + self.assertEqual(result.count('native_notices.rs'), 1) + + def test_unrelated_newer_api_text_is_neither_added_nor_removed(self): + source = '//! Current ABI documentation.\nktav::declare_cabi!();\nfn extra_private_body() {}\n' + result = MODULE.patch_source(source) + self.assertEqual(result.replace(MODULE.INSERTION, '', 1), source) + original = MODULE.patch_source('ktav::declare_cabi!();\n') + self.assertNotIn('extra_private_body', original) + + def test_missing_anchor_is_rejected(self): + with self.assertRaisesRegex(ValueError, 'unreviewed'): + MODULE.patch_source('different source\n') + + def test_duplicate_anchor_is_rejected(self): + with self.assertRaisesRegex(ValueError, 'unreviewed'): + MODULE.patch_source('ktav::declare_cabi!();\nktav::declare_cabi!();\n') + + def test_repeated_overlay_is_rejected(self): + with self.assertRaisesRegex(ValueError, 'already patched'): + MODULE.patch_source(MODULE.patch_source('ktav::declare_cabi!();\n')) + + +if __name__ == '__main__': + unittest.main() diff --git a/crates/cabi/build.rs b/crates/cabi/build.rs new file mode 100644 index 0000000..a98ee0c --- /dev/null +++ b/crates/cabi/build.rs @@ -0,0 +1,103 @@ +use std::io::{self, Read}; + +const MARKER: &[u8] = b"KTAV-NOTICES-GZIP-v1\0"; +const MAX_GZIP: usize = 4 * 1024 * 1024; + +fn notice_resource(source: impl Read) -> io::Result> { + let mut payload = Vec::new(); + source + .take((MAX_GZIP + 1) as u64) + .read_to_end(&mut payload)?; + if payload.len() > MAX_GZIP || !payload.starts_with(&[0x1f, 0x8b, 0x08]) { + return Err(io::Error::new( + io::ErrorKind::InvalidData, + "C ABI notices must be a gzip payload of at most 4 MiB", + )); + } + let mut resource = Vec::with_capacity(MARKER.len() + 8 + payload.len()); + resource.extend_from_slice(MARKER); + resource.extend_from_slice(&(payload.len() as u64).to_le_bytes()); + resource.extend_from_slice(&payload); + Ok(resource) +} + +fn main() -> io::Result<()> { + println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rerun-if-env-changed=KTAV_CABI_NOTICES_GZIP"); + let output = std::env::var_os("OUT_DIR") + .ok_or_else(|| io::Error::new(io::ErrorKind::NotFound, "missing OUT_DIR"))?; + let output = std::path::PathBuf::from(output); + let declaration = output.join("native_notices.rs"); + let Some(path) = std::env::var_os("KTAV_CABI_NOTICES_GZIP") else { + return std::fs::write(declaration, ""); + }; + let path = std::path::PathBuf::from(path); + println!("cargo:rerun-if-changed={}", path.display()); + let resource = notice_resource(std::fs::File::open(path)?)?; + std::fs::write(output.join("native_notices.bin"), resource)?; + std::fs::write( + declaration, + r#"/// Статический resource; не CString и не передаётся в ktav_free. +#[used] +#[no_mangle] +pub static KTAV_THIRD_PARTY_NOTICES: [u8; include_bytes!(concat!(env!("OUT_DIR"), "/native_notices.bin")).len()] = + *include_bytes!(concat!(env!("OUT_DIR"), "/native_notices.bin")); +"#, + ) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn resource_keeps_marker_length_and_payload() { + let payload = [0x1f, 0x8b, 0x08, 0, 0]; + let resource = notice_resource(payload.as_slice()).unwrap(); + assert_eq!(&resource[..MARKER.len()], MARKER); + assert_eq!( + &resource[MARKER.len()..MARKER.len() + 8], + &(payload.len() as u64).to_le_bytes() + ); + assert_eq!(&resource[MARKER.len() + 8..], payload); + } + + #[test] + fn empty_and_non_gzip_payloads_are_rejected() { + for payload in [&[][..], b"not gzip", &[0x1f, 0x8b]] { + assert_eq!( + notice_resource(payload).unwrap_err().kind(), + io::ErrorKind::InvalidData + ); + } + } + + #[test] + fn exact_bound_is_allowed_but_one_extra_byte_is_rejected() { + let mut payload = vec![0; MAX_GZIP]; + payload[..3].copy_from_slice(&[0x1f, 0x8b, 0x08]); + assert_eq!( + notice_resource(payload.as_slice()).unwrap().len(), + MARKER.len() + 8 + MAX_GZIP + ); + payload.push(0); + assert_eq!( + notice_resource(payload.as_slice()).unwrap_err().kind(), + io::ErrorKind::InvalidData + ); + } + + #[test] + fn read_errors_are_propagated() { + struct Failed; + impl Read for Failed { + fn read(&mut self, _: &mut [u8]) -> io::Result { + Err(io::Error::new(io::ErrorKind::PermissionDenied, "fixture")) + } + } + assert_eq!( + notice_resource(Failed).unwrap_err().kind(), + io::ErrorKind::PermissionDenied + ); + } +} diff --git a/crates/cabi/src/lib.rs b/crates/cabi/src/lib.rs index 37c28b8..0b56ff8 100644 --- a/crates/cabi/src/lib.rs +++ b/crates/cabi/src/lib.rs @@ -25,3 +25,5 @@ //! The pinned ABI also exports insert/remove/rename operations, each with //! textual-path and literal-segments variants. ktav::declare_cabi!(); + +include!(concat!(env!("OUT_DIR"), "/native_notices.rs")); diff --git a/scripts/patch_cabi_notice_source.py b/scripts/patch_cabi_notice_source.py new file mode 100644 index 0000000..4d81af4 --- /dev/null +++ b/scripts/patch_cabi_notice_source.py @@ -0,0 +1,22 @@ +"""Наложить одну metadata-вставку, не перенося APIs другой версии core.""" + +from pathlib import Path +import sys + +ANCHOR = 'ktav::declare_cabi!();' +INSERTION = '\n\ninclude!(concat!(env!("OUT_DIR"), "/native_notices.rs"));' + + +def patch_source(source): + if 'native_notices.rs' in source or source.count(ANCHOR) != 1: + raise ValueError('unreviewed or already patched C ABI source') + return source.replace(ANCHOR, ANCHOR + INSERTION) + + +if __name__ == '__main__': + if len(sys.argv) != 2: + raise SystemExit('usage: patch_cabi_notice_source.py SOURCE') + path = Path(sys.argv[1]) + if path.is_symlink() or not path.is_file() or path.stat().st_size > 1024 * 1024: + raise SystemExit('missing, symlinked or oversized C ABI source') + path.write_bytes(patch_source(path.read_bytes().decode('utf-8')).encode('utf-8')) From 98abb686a31aed73162c3da5712bb7b1a9140c32 Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sat, 31 Oct 2026 23:35:52 +0100 Subject: [PATCH 32/51] fix: bind Windows C ABI notices to actual DLL runtime inputs Keep original 0.8.1 parser APIs, reviewed lock and the checksum-pinned LLVM-MinGW SDK. Graft only the existing C ABI resource hook/include. Bind Cargo/std plus runtime notices to 28 x64 and 21 ARM retained runtime objects and fourteen exact SDK inputs per target. Do not transfer executable-startup clearance from the LSP: inspect and retain grants for the three new DLL-specific inputs, including crtdll and DLL constructor/destructor support. Preserve the complete original legal collection and exact source/header notice records. Verify every source hash/Git blob and final binary/resource/input binding; keep the conservative notice-superset scope explicit. Add ten boundary regressions. Require exactly ten original callable exports and a separate immutable metadata export. Execute matching x64 Bun and Deno FFI corpus consumers with SDK paths removed, beyond the existing clean-path loader probe. ARM is inspected, not executed. No dependency/version, fake DLL, target spoof, unsafe code, parser API, release, npm publication or historical asset change is included. Co-Authored-By: Claude Opus 5.5 --- .../workflows/windows-cabi-gnullvm-check.yml | 97 ++- ci/licenses/cabi-gnullvm-runtime.json | 784 ++++++++++++++++++ ci/test_cabi_gnullvm_notices.py | 104 +++ scripts/cabi_gnullvm_notices.py | 213 +++++ 4 files changed, 1189 insertions(+), 9 deletions(-) create mode 100644 ci/licenses/cabi-gnullvm-runtime.json create mode 100644 ci/test_cabi_gnullvm_notices.py create mode 100644 scripts/cabi_gnullvm_notices.py diff --git a/.github/workflows/windows-cabi-gnullvm-check.yml b/.github/workflows/windows-cabi-gnullvm-check.yml index 1d9bc0b..189f073 100644 --- a/.github/workflows/windows-cabi-gnullvm-check.yml +++ b/.github/workflows/windows-cabi-gnullvm-check.yml @@ -13,6 +13,7 @@ jobs: cabi-gnullvm: name: C ABI GNU LLVM / ${{ matrix.target }} runs-on: windows-latest + timeout-minutes: 45 strategy: fail-fast: false matrix: @@ -37,30 +38,43 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'cabi-gnullvm-tools' stage.mkdir() - for name in ['Cargo.lock', 'ci/js-build-lock.json', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'ci/about.toml', 'ci/licenses/js-source-supplements.json']: + for name in ['Cargo.lock', 'ci/js-build-lock.json', 'crates/cabi/build.rs', 'scripts/patch_cabi_notice_source.py', 'ci/test_cabi_notice_overlay.py', 'scripts/cabi_gnullvm_notices.py', 'ci/test_cabi_gnullvm_notices.py', 'ci/licenses/cabi-gnullvm-runtime.json', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'ci/about.toml', 'ci/licenses/js-source-supplements.json']: path = stage / name path.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(name, path) - uses: actions/checkout@v4 with: ref: ${{ env.SOURCE_REF }} + submodules: recursive persist-credentials: false - - name: Restore tools without changing any binding sources + - name: Restore tools and graft only C ABI notice metadata shell: python run: | + import hashlib + import json import os import shutil import subprocess + import sys from pathlib import Path if subprocess.check_output(['git', 'rev-parse', 'HEAD'], text=True).strip() != os.environ['SOURCE_REF']: raise SystemExit('unexpected Windows C ABI source') + overlay = ['crates/cabi/build.rs', 'crates/cabi/src/lib.rs'] + baseline = {name: hashlib.sha256(Path(name).read_bytes()).hexdigest() if Path(name).is_file() else None for name in overlay} stage = Path(os.environ['RUNNER_TEMP']) / 'cabi-gnullvm-tools' for path in stage.rglob('*'): if path.is_file(): destination = Path(path.relative_to(stage)) destination.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(path, destination) - subprocess.run(['git', 'diff', '--exit-code', '--', 'Cargo.toml', 'crates', 'package.json', 'package-lock.json'], check=True) + subprocess.run([sys.executable, '-I', 'scripts/patch_cabi_notice_source.py', 'crates/cabi/src/lib.rs'], check=True) + protected = ['Cargo.toml', 'crates', 'tests', 'root-docs', 'package.json', 'package-lock.json'] + changed = set(subprocess.check_output(['git', 'diff', '--name-only', '--', *protected], text=True).splitlines()) + changed.update(subprocess.check_output(['git', 'ls-files', '--others', '--exclude-standard', '--', *protected], text=True).splitlines()) + if changed != set(overlay): + raise SystemExit('C ABI source overlay changed more than its notice hook/include') + record = {name: {'baseline_sha256': baseline[name], 'compiled_sha256': hashlib.sha256(Path(name).read_bytes()).hexdigest()} for name in overlay} + (Path(os.environ['RUNNER_TEMP']) / 'cabi-gnullvm-source-overlay.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') - uses: actions/setup-python@v5 with: python-version: '3.12' @@ -71,7 +85,14 @@ jobs: - uses: taiki-e/install-action@v2 with: tool: cargo-about@0.9.3 - - name: Prepare reviewed Cargo/std evidence + - name: Verify C ABI overlay and runtime source boundary regressions + shell: python + run: | + import subprocess + import sys + for pattern in ['test_cabi_notice_overlay.py', 'test_cabi_gnullvm_notices.py']: + subprocess.run([sys.executable, '-I', '-m', 'unittest', 'discover', '-s', 'ci', '-p', pattern, '-v'], check=True) + - name: Prepare reviewed Cargo/std and C ABI runtime notices shell: python run: | import os @@ -83,6 +104,9 @@ jobs: subprocess.run([sys.executable, 'scripts/prepare_js_notices.py', str(evidence)], check=True) for name in ['LICENSE-MIT', 'LICENSE-APACHE']: shutil.copyfile(name, evidence / name) + subprocess.run([sys.executable, '-I', 'scripts/cabi_gnullvm_notices.py', 'prepare', str(evidence), os.environ['CABI_TARGET']], check=True) + with Path(os.environ['GITHUB_ENV']).open('a', encoding='utf-8') as output: + output.write('KTAV_CABI_NOTICES_GZIP=' + str(evidence / 'NOTICE.json.gz') + '\n') - name: Install the exact previously reviewed LLVM MinGW SDK shell: python run: | @@ -124,7 +148,7 @@ jobs: raise SystemExit('candidate compiler missing') evidence = root / 'cabi-gnullvm-evidence' (evidence / 'compiler-version.txt').write_bytes(subprocess.check_output([str(compiler), '--version'])) - record = {'source_ref': os.environ['SOURCE_REF'], 'tooling_ref': os.environ['GITHUB_SHA'], 'target': os.environ['CABI_TARGET'], 'sdk_archive_sha256': checksum.hexdigest(), 'sdk_source': url, 'coverage': 'Compatibility and input probe only; not completed runtime licensing, embedded CABI notices, npm delivery or NAPI compatibility.'} + record = {'source_ref': os.environ['SOURCE_REF'], 'tooling_ref': os.environ['GITHUB_SHA'], 'target': os.environ['CABI_TARGET'], 'sdk_archive_sha256': checksum.hexdigest(), 'sdk_source': url, 'notice_overlay': json.loads((root / 'cabi-gnullvm-source-overlay.json').read_text(encoding='utf-8')), 'coverage': 'Original 0.8.1 C ABI with source-bound runtime notices; not npm delivery, NAPI compatibility or historical dependency evidence.'} (evidence / 'source-provenance.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') key = 'CARGO_TARGET_' + os.environ['CABI_TARGET'].upper().replace('-', '_') + '_LINKER' flags = ['-C', 'target-feature=+crt-static', '-C', 'link-arg=-Wl,-Map,' + (evidence / 'native-link.map').as_posix(), '-C', 'link-arg=-Wl,--reproduce=' + (root / 'cabi-gnullvm-link.tar').as_posix()] @@ -133,7 +157,7 @@ jobs: output.write(name + '=' + value + '\n') with Path(os.environ['GITHUB_PATH']).open('a', encoding='utf-8') as output: output.write(str(install / 'bin') + '\n') - - name: Build the unchanged C ABI crate + - name: Build original C ABI APIs with the reviewed notice resource run: cargo build --locked --release -p ktav-cabi --target ${{ matrix.target }} - name: Capture exact PE, link inputs and original SDK legal documents shell: python @@ -146,6 +170,7 @@ jobs: import shutil import struct import subprocess + import sys import tarfile from pathlib import Path, PurePosixPath root = Path(os.environ['RUNNER_TEMP']) @@ -173,8 +198,11 @@ jobs: if not imports or not all(os_import(name) for name in imports): raise SystemExit('C ABI candidate imports a non-OS runtime DLL: ' + repr(imports)) exports = re.findall(rb'^\s*Name: (ktav_[^\r\n]+)\s*$', pe, re.M) - if not {b'ktav_version', b'ktav_loads', b'ktav_free'} <= set(exports): - raise SystemExit('expected C ABI exports missing') + expected_exports = {b'ktav_loads', b'ktav_loads_strict', b'ktav_dumps', b'ktav_dumps_force_strings', b'ktav_emit_canonical', b'ktav_format', b'ktav_canonical_from_source', b'ktav_free', b'ktav_version', b'ktav_abi_version'} + if len(exports) != 10 or set(exports) != expected_exports: + raise SystemExit('original callable C ABI export set differs') + if len(re.findall(rb'^\s*Name: KTAV_THIRD_PARTY_NOTICES\s*$', pe, re.M)) != 1: + raise SystemExit('C ABI notice static export missing') link_map = evidence / 'native-link.map' if not link_map.is_file() or not 0 < link_map.stat().st_size <= 32 * 1024 * 1024: raise SystemExit('missing or oversized actual C ABI map') @@ -228,8 +256,9 @@ jobs: (evidence / 'sdk-legal.json').write_text(json.dumps(legal, ensure_ascii=False, indent=2) + '\n', encoding='utf-8') if Path('Cargo.lock').read_bytes() != (evidence / 'Cargo.lock').read_bytes(): raise SystemExit('candidate changed the reviewed Cargo lock') - result = {'target': os.environ['CABI_TARGET'], 'binary_sha256': hashlib.sha256(binary.read_bytes()).hexdigest(), 'map_sha256': hashlib.sha256(link_map.read_bytes()).hexdigest(), 'machine': int(os.environ['CABI_MACHINE']), 'imports': imports, 'exports': [name.decode('ascii') for name in exports], 'sdk_legal_files': len(legal), 'coverage': 'Actual PE and input fingerprints; runtime source/member licensing and distribution notices remain separate.'} + result = {'target': os.environ['CABI_TARGET'], 'binary_sha256': hashlib.sha256(binary.read_bytes()).hexdigest(), 'map_sha256': hashlib.sha256(link_map.read_bytes()).hexdigest(), 'machine': int(os.environ['CABI_MACHINE']), 'imports': imports, 'exports': [name.decode('ascii') for name in exports], 'sdk_legal_files': len(legal), 'coverage': 'Actual PE/input identity; source-bound runtime/resource verification is recorded separately in native-runtime-verification.json.'} (evidence / 'native-verification.json').write_text(json.dumps(result, sort_keys=True, indent=2) + '\n', encoding='utf-8') + subprocess.run([sys.executable, '-I', 'scripts/cabi_gnullvm_notices.py', 'verify', str(evidence), str(binary), os.environ['CABI_TARGET']], check=True) - name: Load the actual x64 C ABI with SDK paths removed if: matrix.target == 'x86_64-pc-windows-gnullvm' shell: python @@ -256,6 +285,56 @@ jobs: raise SystemExit('actual C ABI library failed to load with SDK paths removed') record = {'sdk_path_removed': True, 'only_own_dll_staged': True, 'exit_code': result.returncode, 'binary_sha256': hashlib.sha256(binary.read_bytes()).hexdigest(), 'scope': 'Matching-x64 DLL loader/export probe only; no Bun/Deno or parser-corpus claim. ARM DLL not executed.'} (evidence / 'loader-probe.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') + - uses: actions/setup-node@v4 + if: matrix.target == 'x86_64-pc-windows-gnullvm' + with: + node-version: '24' + - uses: oven-sh/setup-bun@v2 + if: matrix.target == 'x86_64-pc-windows-gnullvm' + - uses: denoland/setup-deno@v2 + if: matrix.target == 'x86_64-pc-windows-gnullvm' + with: + deno-version: v2.x + - name: Run actual x64 Bun and Deno C ABI corpus consumers + if: matrix.target == 'x86_64-pc-windows-gnullvm' + shell: python + run: | + import hashlib + import json + import os + import shutil + import subprocess + import sys + from pathlib import Path + evidence = Path(os.environ['RUNNER_TEMP']) / 'cabi-gnullvm-evidence' + sdk = Path(os.environ['LLVM_MINGW_CANDIDATE']).resolve() + consumer = Path(os.environ['RUNNER_TEMP']) / 'cabi-gnullvm-consumer' + (consumer / 'release').mkdir(parents=True) + binary = consumer / 'release/ktav_cabi.dll' + shutil.copyfile(evidence / 'ktav_cabi.dll', binary) + clean_path = os.pathsep.join(part for part in os.environ['PATH'].split(os.pathsep) if part and not Path(part).resolve().is_relative_to(sdk)) + environment = {**os.environ, 'PATH': clean_path, 'CARGO_TARGET_DIR': str(consumer), 'EXPECTED_CABI': str(binary)} + shutil.copyfile('package-lock.json', evidence / 'consumer-npm-lock-source.json') + subprocess.run(['npm.cmd', 'install', '--ignore-scripts', '--no-audit', '--no-fund'], env=environment, check=True) + subprocess.run(['git', 'diff', '--exit-code', '--', 'package.json'], check=True) + shutil.copyfile('package-lock.json', evidence / 'consumer-npm-lock-resolved.json') + subprocess.run(['node', 'scripts/check-npm-licenses.mjs'], env=environment, check=True) + subprocess.run(['npm.cmd', 'run', 'build:ts'], env=environment, check=True) + preflight = 'import assert from "node:assert/strict";import {realpathSync} from "node:fs";import * as paths from "./tests/shared/test-paths.mjs";assert.ok(paths.cabiBuilt());assert.equal(realpathSync(paths.cabi),realpathSync(process.env.EXPECTED_CABI));' + subprocess.run(['node', '--input-type=module', '-e', preflight], env=environment, check=True) + commands = [('bun', ['bun', 'run', 'tests/bun/run-bun-ffi.mjs']), ('deno', ['deno', 'run', '--allow-ffi', '--allow-env', '--allow-read', 'tests/deno/run-deno-ffi.ts'])] + for role, command in commands: + result = subprocess.run(command, env=environment, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + (evidence / (role + '-consumer-stdout.txt')).write_bytes(result.stdout) + (evidence / (role + '-consumer-stderr.txt')).write_bytes(result.stderr) + sys.stdout.buffer.write(result.stdout) + sys.stderr.buffer.write(result.stderr) + if result.returncode or b'passed' not in result.stdout or b'skipping' in result.stdout.lower(): + raise SystemExit(role + ' actual C ABI corpus failed or skipped') + if binary.read_bytes() != (evidence / 'ktav_cabi.dll').read_bytes(): + raise SystemExit('actual consumer DLL bytes changed') + record = {'target': os.environ['CABI_TARGET'], 'binary_sha256': hashlib.sha256(binary.read_bytes()).hexdigest(), 'sdk_path_removed': True, 'actual_bun_corpus': True, 'actual_deno_corpus': True, 'bun_version': subprocess.check_output(['bun', '--version'], env=environment, text=True).strip(), 'deno_version': subprocess.check_output(['deno', '--version'], env=environment, text=True).strip(), 'scope': 'Matching-x64 actual C ABI consumers with pinned spec corpus. ARM DLL inspected only; no NAPI claim.'} + (evidence / 'consumer-verification.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') - uses: actions/upload-artifact@v4 if: always() with: diff --git a/ci/licenses/cabi-gnullvm-runtime.json b/ci/licenses/cabi-gnullvm-runtime.json new file mode 100644 index 0000000..e58e298 --- /dev/null +++ b/ci/licenses/cabi-gnullvm-runtime.json @@ -0,0 +1,784 @@ +{ + "coverage": "Reviewed C ABI DLL startup/MinGW runtime/libunwind source grants. Exact target-specific SDK fingerprints and retained objects are separate fixed roles. The original source/header notice collection is conservative and does not assert that all source records or SDK components are linked. Not an SDK source-build reproducibility claim.", + "llvm_revision": "7a941dfb2877a0b8cf30323fefa85ad019e0b0f5", + "mingw_revision": "0d6dfbc348dfad714761c0a7151615767f96bcb5", + "original_documents": [ + { + "git_blob": "fa6ac540007032cbd0ec772a1c72e6cb5527a4fe", + "path": "LICENSE.TXT", + "sha256": "8d85c1057d742e597985c7d4e6320b015a9139385cff4cbae06ffc0ebe89afee", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/LICENSE.TXT", + "text": "==============================================================================\nThe LLVM Project is under the Apache License v2.0 with LLVM Exceptions:\n==============================================================================\n\n Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n APPENDIX: How to apply the Apache License to your work.\n\n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n\n Copyright [yyyy] [name of copyright owner]\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n\n---- LLVM Exceptions to the Apache 2.0 License ----\n\nAs an exception, if, as a result of your compiling your source code, portions\nof this Software are embedded into an Object form of such source code, you\nmay redistribute such embedded portions in such Object form without complying\nwith the conditions of Sections 4(a), 4(b) and 4(d) of the License.\n\nIn addition, if you combine or link compiled forms of this Software with\nsoftware that is licensed under the GPLv2 (\"Combined Software\") and if a\ncourt of competent jurisdiction determines that the patent provision (Section\n3), the indemnity provision (Section 9) or other Section of the License\nconflicts with the conditions of the GPLv2, you may retroactively and\nprospectively choose to deem waived or otherwise exclude such Section(s) of\nthe License, but only in their entirety and only with respect to the Combined\nSoftware.\n\n==============================================================================\nSoftware from third parties included in the LLVM Project:\n==============================================================================\nThe LLVM Project contains third party software which is under different license\nterms. All such code will be identified clearly using at least one of two\nmechanisms:\n1) It will be in a separate directory tree with its own `LICENSE.txt` or\n `LICENSE` file at the top containing the specific license and restrictions\n which apply to that software, or\n2) It will contain specific license and restriction terms at the top of every\n file.\n\n==============================================================================\nLegacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy):\n==============================================================================\nUniversity of Illinois/NCSA\nOpen Source License\n\nCopyright (c) 2003-2019 University of Illinois at Urbana-Champaign.\nAll rights reserved.\n\nDeveloped by:\n\n LLVM Team\n\n University of Illinois at Urbana-Champaign\n\n http://llvm.org\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal with\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\n * Redistributions of source code must retain the above copyright notice,\n this list of conditions and the following disclaimers.\n\n * Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimers in the\n documentation and/or other materials provided with the distribution.\n\n * Neither the names of the LLVM Team, University of Illinois at\n Urbana-Champaign, nor the names of its contributors may be used to\n endorse or promote products derived from this Software without specific\n prior written permission.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nCONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE\nSOFTWARE.\n\n" + }, + { + "git_blob": "1e3120621caeb62648745a42f7a9a25d1e2731ab", + "path": "libunwind/LICENSE.TXT", + "sha256": "b5efebcaca80879234098e52d1725e6d9eb8fb96a19fce625d39184b705f7b6d", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/LICENSE.TXT", + "text": "==============================================================================\nThe LLVM Project is under the Apache License v2.0 with LLVM Exceptions:\n==============================================================================\n\n Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n APPENDIX: How to apply the Apache License to your work.\n\n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n\n Copyright [yyyy] [name of copyright owner]\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n\n---- LLVM Exceptions to the Apache 2.0 License ----\n\nAs an exception, if, as a result of your compiling your source code, portions\nof this Software are embedded into an Object form of such source code, you\nmay redistribute such embedded portions in such Object form without complying\nwith the conditions of Sections 4(a), 4(b) and 4(d) of the License.\n\nIn addition, if you combine or link compiled forms of this Software with\nsoftware that is licensed under the GPLv2 (\"Combined Software\") and if a\ncourt of competent jurisdiction determines that the patent provision (Section\n3), the indemnity provision (Section 9) or other Section of the License\nconflicts with the conditions of the GPLv2, you may retroactively and\nprospectively choose to deem waived or otherwise exclude such Section(s) of\nthe License, but only in their entirety and only with respect to the Combined\nSoftware.\n\n==============================================================================\nSoftware from third parties included in the LLVM Project:\n==============================================================================\nThe LLVM Project contains third party software which is under different license\nterms. All such code will be identified clearly using at least one of two\nmechanisms:\n1) It will be in a separate directory tree with its own `LICENSE.txt` or\n `LICENSE` file at the top containing the specific license and restrictions\n which apply to that software, or\n2) It will contain specific license and restriction terms at the top of every\n file.\n\n==============================================================================\nLegacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy):\n==============================================================================\n\nThe libunwind library is dual licensed under both the University of Illinois\n\"BSD-Like\" license and the MIT license. As a user of this code you may choose\nto use it under either license. As a contributor, you agree to allow your code\nto be used under both.\n\nFull text of the relevant licenses is included below.\n\n==============================================================================\n\nUniversity of Illinois/NCSA\nOpen Source License\n\nCopyright (c) 2009-2019 by the contributors listed in CREDITS.TXT\n\nAll rights reserved.\n\nDeveloped by:\n\n LLVM Team\n\n University of Illinois at Urbana-Champaign\n\n http://llvm.org\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal with\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\n * Redistributions of source code must retain the above copyright notice,\n this list of conditions and the following disclaimers.\n\n * Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimers in the\n documentation and/or other materials provided with the distribution.\n\n * Neither the names of the LLVM Team, University of Illinois at\n Urbana-Champaign, nor the names of its contributors may be used to\n endorse or promote products derived from this Software without specific\n prior written permission.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nCONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE\nSOFTWARE.\n\n==============================================================================\n\nCopyright (c) 2009-2014 by the contributors listed in CREDITS.TXT\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n" + }, + { + "git_blob": "776d5f1034240f6dae0ce59d592f9c6f4ad29e7d", + "path": "COPYING.MinGW-w64-runtime/COPYING.MinGW-w64-runtime.txt", + "sha256": "1db8da07b436c68833c0673ffee3d9fcb2526047f3820b81661865dfedc79a1f", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/COPYING.MinGW-w64-runtime/COPYING.MinGW-w64-runtime.txt", + "text": "MinGW-w64 runtime licensing\n***************************\n\nThis program or library was built using MinGW-w64 and statically\nlinked against the MinGW-w64 runtime. Some parts of the runtime\nare under licenses which require that the copyright and license\nnotices are included when distributing the code in binary form.\nThese notices are listed below.\n\n\n========================\nOverall copyright notice\n========================\n\nCopyright (c) 2009, 2010, 2011, 2012, 2013 by the mingw-w64 project\n\nThis license has been certified as open source. It has also been designated\nas GPL compatible by the Free Software Foundation (FSF).\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n 1. Redistributions in source code must retain the accompanying copyright\n notice, this list of conditions, and the following disclaimer.\n 2. Redistributions in binary form must reproduce the accompanying\n copyright notice, this list of conditions, and the following disclaimer\n in the documentation and/or other materials provided with the\n distribution.\n 3. Names of the copyright holders must not be used to endorse or promote\n products derived from this software without prior written permission\n from the copyright holders.\n 4. The right to distribute this software or to use it for any purpose does\n not give you the right to use Servicemarks (sm) or Trademarks (tm) of\n the copyright holders. Use of them is covered by separate agreement\n with the copyright holders.\n 5. If any files are modified, you must cause the modified files to carry\n prominent notices stating that you changed the files and the date of\n any change.\n\nDisclaimer\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED\nOR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\nOF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO\nEVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\nOR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\nEVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n======================================== \ngetopt, getopt_long, and getop_long_only\n======================================== \n\nCopyright (c) 2002 Todd C. Miller \n \nPermission to use, copy, modify, and distribute this software for any \npurpose with or without fee is hereby granted, provided that the above \ncopyright notice and this permission notice appear in all copies. \n \t \nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\nWITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\nMERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\nANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\nACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\nOR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n\nSponsored in part by the Defense Advanced Research Projects\nAgency (DARPA) and Air Force Research Laboratory, Air Force\nMateriel Command, USAF, under agreement number F39502-99-1-0512.\n\n * * * * * * * \n\nCopyright (c) 2000 The NetBSD Foundation, Inc.\nAll rights reserved.\n\nThis code is derived from software contributed to The NetBSD Foundation\nby Dieter Baron and Thomas Klausner.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n 1. Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n 2. Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS\n``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\nTO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\nINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\nCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\nARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE.\n\n\n===============================================================\ngdtoa: Converting between IEEE floating point numbers and ASCII\n===============================================================\n\nThe author of this software is David M. Gay.\n\nCopyright (C) 1997, 1998, 1999, 2000, 2001 by Lucent Technologies\nAll Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and\nits documentation for any purpose and without fee is hereby\ngranted, provided that the above copyright notice appear in all\ncopies and that both that the copyright notice and this\npermission notice and warranty disclaimer appear in supporting\ndocumentation, and that the name of Lucent or any of its entities\nnot be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior\npermission.\n\nLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.\nIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY\nSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\nIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n\n * * * * * * *\n\nThe author of this software is David M. Gay.\n\nCopyright (C) 2005 by David M. Gay\nAll Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and its\ndocumentation for any purpose and without fee is hereby granted,\nprovided that the above copyright notice appear in all copies and that\nboth that the copyright notice and this permission notice and warranty\ndisclaimer appear in supporting documentation, and that the name of\nthe author or any of his current or former employers not be used in\nadvertising or publicity pertaining to distribution of the software\nwithout specific, written prior permission.\n\nTHE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN\nNO EVENT SHALL THE AUTHOR OR ANY OF HIS CURRENT OR FORMER EMPLOYERS BE\nLIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY\nDAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\nWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\nSOFTWARE.\n\n * * * * * * *\n\nThe author of this software is David M. Gay.\n\nCopyright (C) 2004 by David M. Gay.\nAll Rights Reserved\nBased on material in the rest of /netlib/fp/gdota.tar.gz,\nwhich is copyright (C) 1998, 2000 by Lucent Technologies.\n\nPermission to use, copy, modify, and distribute this software and\nits documentation for any purpose and without fee is hereby\ngranted, provided that the above copyright notice appear in all\ncopies and that both that the copyright notice and this\npermission notice and warranty disclaimer appear in supporting\ndocumentation, and that the name of Lucent or any of its entities\nnot be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior\npermission.\n\nLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.\nIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY\nSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\nIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n\n\n=========================\nParts of the math library\n=========================\n\nCopyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\n\nDeveloped at SunSoft, a Sun Microsystems, Inc. business.\nPermission to use, copy, modify, and distribute this\nsoftware is freely granted, provided that this notice\nis preserved.\n\n * * * * * * *\n\nCopyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\n\nDeveloped at SunPro, a Sun Microsystems, Inc. business.\nPermission to use, copy, modify, and distribute this\nsoftware is freely granted, provided that this notice\nis preserved.\n\n * * * * * * *\n\nFIXME: Cephes math lib\nCopyright (C) 1984-1998 Stephen L. Moshier\n\nIt sounds vague, but as to be found at\n, it gives an\nimpression that the author could be willing to give an explicit\npermission to distribute those files e.g. under a BSD style license. So\nprobably there is no problem here, although it could be good to get a\npermission from the author and then add a license into the Cephes files\nin MinGW runtime. At least on follow-up it is marked that debian sees the\nversion a-like BSD one. As MinGW.org (where those cephes parts are coming\nfrom) distributes them now over 6 years, it should be fine.\n\n=================================================\nSome string, memory and time conversion functions\n=================================================\n\nCopyright © 2005-2020 Rich Felker, et al.\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n===================================\nHeaders and IDLs imported from Wine\n===================================\n\nSome header and IDL files were imported from the Wine project. These files\nare prominent maked in source. Their copyright belongs to contributors and\nthey are distributed under LGPL license.\n\nDisclaimer\n\nThis library is free software; you can redistribute it and/or\nmodify it under the terms of the GNU Lesser General Public\nLicense as published by the Free Software Foundation; either\nversion 2.1 of the License, or (at your option) any later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\nLesser General Public License for more details.\n" + }, + { + "git_blob": "51261a8ec4b5c5b6b074317fab1d7f506eb30425", + "path": "DISCLAIMER", + "sha256": "039ed6b4f31bb7fb97e733170b58cc435335352e4745734fcfd113877fdaf340", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/DISCLAIMER", + "source_revision": "0d6dfbc348dfad714761c0a7151615767f96bcb5", + "text": "/*\n This Software is provided under the Zope Public License (ZPL) Version 2.1.\n\n Copyright (c) 2009, 2010 by the mingw-w64 project\n\n See the AUTHORS file for the list of contributors to the mingw-w64 project.\n\n This license has been certified as open source. It has also been designated\n as GPL compatible by the Free Software Foundation (FSF).\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are met:\n\n 1. Redistributions in source code must retain the accompanying copyright\n notice, this list of conditions, and the following disclaimer.\n 2. Redistributions in binary form must reproduce the accompanying\n copyright notice, this list of conditions, and the following disclaimer\n in the documentation and/or other materials provided with the\n distribution.\n 3. Names of the copyright holders must not be used to endorse or promote\n products derived from this software without prior written permission\n from the copyright holders.\n 4. The right to distribute this software or to use it for any purpose does\n not give you the right to use Servicemarks (sm) or Trademarks (tm) of\n the copyright holders. Use of them is covered by separate agreement\n with the copyright holders.\n 5. If any files are modified, you must cause the modified files to carry\n prominent notices stating that you changed the files and the date of\n any change.\n\n Disclaimer\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED\n OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO\n EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,\n INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, \n OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n" + }, + { + "git_blob": "91fb0d6dc9d1f65394cbec575a857e635868ed74", + "path": "DISCLAIMER.PD", + "sha256": "87f33608570312a0f2a9745edcb2527275df813b13982e8c3b3f893d88a4141a", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/DISCLAIMER.PD", + "source_revision": "0d6dfbc348dfad714761c0a7151615767f96bcb5", + "text": "/**\n * DISCLAIMER\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n *\n * The mingw-w64 runtime package and its code is distributed in the hope that it \n * will be useful but WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESSED OR \n * IMPLIED ARE HEREBY DISCLAIMED. This includes but is not limited to \n * warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n */\n" + }, + { + "git_blob": "4b40f2beb3cac255a09ff12616c22aa89aa9d80f", + "path": "AUTHORS", + "sha256": "8f308316e7a94b8410f871868bd3948f126526dc1775aeee97a0e365f9a0fd9f", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/AUTHORS", + "source_revision": "0d6dfbc348dfad714761c0a7151615767f96bcb5", + "text": "Note\n====\n\nThis file contains information about people who are permitted to make\nchanges to various parts of the runtimes, headers, associated tools,\nand associated libraries. Also the list of contributors to mingw-w64\nare listed here, too.\n\nPlease do not contact the people in this file directly to report\nproblems in mingw-w64.\n\nFor general information about mingw-w64, please visit:\n\n http://sourceforge.net/projects/mingw-w64/\n\nTo report problems in mingw-w64, please visit bug-tracker on:\n\n http://sourceforge.net/projects/mingw-w64/\n\nMaintainers\n===========\n\nMook \nNightStrike \nKai Tietz \n\nDevelopers with write after approval\n====================================\n\nkjk_hyperion \nTor Lillqvist \nAlexey Pushkin \nRoland Schwingel \nOzkan Sezer \nFridrich Strba \nChris Sutcliffe \nJonathan Yong \nJarrod Chesney \nDoug Semler \nJacek Caban \nCorinna Vinschen \nAndré Hentschel \nLiu Hao \nRuslan Garipov \n\nProject members without SVN/Git access\n==================================\n\nxenofears \n\nContributors\n============\n\nWe want to thank the following list of people for supporting us\nby contributions:\n\n20-40 \nProfessor Brian Ripley \nsduplichan \nWesley W. Terpstra \nzhou drangon \nPiotr Caban \n\nand additional thanks to the following organizations:\n\nOneVision Software AG\nReactos project\nWine project\n\nand many others, we possibly missed to mention here and are sorry for this.\n\nIf you think your name is missing and should be mentioned here, please\ncontact us for adding you.\n" + } + ], + "reviewed_cabi_evidence": { + "repository": "ktav-lang/js", + "run": 41245571952, + "source_ref": "562deb3fde092d63a78f359be095e5079929d0d1", + "tooling_head": "7d8148acc7681196283bd7e63593e5aa7863a12d" + }, + "schema_version": 1, + "sdk_archive_sha256": "fd5462b7f5d93b2ff981fcd3f9c7e427e47f3203c64ea91c27bcc444eebd74cd", + "sdk_recipe_revision": "e08a31fbfe5cfdad07b698299af22d66e5608383", + "sdk_version": "20261020", + "source_files": [ + { + "git_blob": "a1179c73c5906b2df9bb3973cd7918ad1f42b28a", + "path": "libunwind/include/__libunwind_config.h", + "sha256": "0bb004911d967d5cc2d87d07f81e03668d1cf42c6b9347a95285d9e18f82954c", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/include/__libunwind_config.h", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "6c2dfe58e53bf1f97bca6c78dacb47cc3676b8dc", + "path": "libunwind/include/libunwind.h", + "sha256": "3b411eb68de64e829937faaeec942bbc8e3e3a1c013b55107be2c679df64173c", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/include/libunwind.h", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Compatible with libunwind API documented at:\n// http://www.nongnu.org/libunwind/man/libunwind(3).html\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "c495b83c40b90ae517e390fe659061a7bbbe2603", + "path": "libunwind/include/mach-o/compact_unwind_encoding.h", + "sha256": "a458a96b1257048618e22688e3ad6fc4c36f99e1229b1492b7b800911e651a68", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/include/mach-o/compact_unwind_encoding.h", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Darwin's alternative to DWARF based unwind encodings.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "b1775d3a3decc76e1a0916fead1aafbc6fa0fb51", + "path": "libunwind/include/unwind.h", + "sha256": "e4a58637fc8ca1d29cd600c3c4416aafed50085edf276fa076214c8d81c263f0", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/include/unwind.h", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// C++ ABI Level 1 ABI documented at:\n// https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "68e02e47602d60de9f9d33267e270cb5f73fc5aa", + "path": "libunwind/include/unwind_arm_ehabi.h", + "sha256": "04cf22a069866ae35bf075c36f8d9112700bb9772653d80d9c6c4c856f4e7dbb", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/include/unwind_arm_ehabi.h", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// C++ ABI Level 1 ABI documented at:\n// https://github.com/ARM-software/abi-aa/blob/main/ehabi32/ehabi32.rst\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "860ad36cdf14e2e06cd6fe2f77b9070434240434", + "path": "libunwind/include/unwind_itanium.h", + "sha256": "43ad2c8ca672c8fb9a4eb80d7e05a687ae9134f4899641357c86cecde4efbd1f", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/include/unwind_itanium.h", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// C++ ABI Level 1 ABI documented at:\n// https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "ff3b5fc6fea77fba0f4ebc4d74e72bac984935fa", + "path": "libunwind/src/Unwind-EHABI.h", + "sha256": "c04fdebcd31e26de7615b82751373cc64ef83d02b24dbaaf0e112d0a559acc6b", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/src/Unwind-EHABI.h", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "0b1930b44d1c648b89099b6f2f796b4233f1c877", + "path": "libunwind/src/Unwind-seh.cpp", + "sha256": "058ae089c7d42ade35b730f87443b34018b21bea75a4ea2226e9fffdf7500160", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/src/Unwind-seh.cpp", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n//\n// Implements SEH-based Itanium C++ exceptions.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "1764499b304f1ac4ed665829d7cc47793ebf9766", + "path": "libunwind/src/UnwindLevel1-gcc-ext.c", + "sha256": "93d2bb050caf6b4f80819b93340ae5aad91f44e633996cc7dd32dca90da05fe0", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/src/UnwindLevel1-gcc-ext.c", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Implements gcc extensions to the C++ ABI Exception Handling Level 1.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "834fdae6a76d3e28bde5ece20c45f367a47b1f12", + "path": "libunwind/src/UnwindLevel1.c", + "sha256": "16e16fbc0c85873df1a445d7b204fb363e46c68d6a2815dc68257108b5c944c8", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/src/UnwindLevel1.c", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Implements C++ ABI Exception Handling Level 1 as documented at:\n// https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html\n// using libunwind\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "f44f6a1331968cf75de46a3cf64a0cc5c8f485b2", + "path": "libunwind/src/UnwindRegistersSave.S", + "sha256": "c5d0da824062363be10dc33bcd1156f16cd69811e71603c667f931a91fab5eb1", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/src/UnwindRegistersSave.S", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "84c9d526f1d7594e456b5a31c11adff57f79551a", + "path": "libunwind/src/assembly.h", + "sha256": "1b802ab55f7b949a9e8b1a1c7c82b6a84d068610aeb823993bdeee1964c98eb3", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/src/assembly.h", + "source_notices": [ + "/* ===-- assembly.h - libUnwind assembler support macros -------------------===\n *\n * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n * See https://llvm.org/LICENSE.txt for license information.\n * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n *\n * ===----------------------------------------------------------------------===\n *\n * This file defines macros for use in libUnwind assembler source.\n * This file is not part of the interface of this library.\n *\n * ===----------------------------------------------------------------------===\n */" + ] + }, + { + "git_blob": "f017403fa2234f7234e784eefeafe8eae6b1a59b", + "path": "libunwind/src/config.h", + "sha256": "fd99264860ced6f5b5cd4d5e0ef6eb444a4ab511a47a8b0d91bfab254ab21a1e", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/src/config.h", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Defines macros used within libunwind project.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "68ad882347203ca193d05bcb2e3f34d4500edca0", + "path": "libunwind/src/dwarf2.h", + "sha256": "e10d240e2f19de7121a8afaf3d4841a65936723e69d636f7e3241e14802d0bfc", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/src/dwarf2.h", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n", + "/*\n These constants were taken from version 3 of the DWARF standard,\n which is Copyright (c) 2005 Free Standards Group, and\n Copyright (c) 1992, 1993 UNIX International, Inc.\n*/" + ] + }, + { + "git_blob": "0b9d56ec805bca92f0ed4b93be549c8cf982e809", + "path": "libunwind/src/libunwind.cpp", + "sha256": "51ccb27829d15988ca5678541b1b32bb3c2bdea87e02be31bf4faca48a0ee2ad", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/src/libunwind.cpp", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Implements unw_* functions from \n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "8acf2212d1eae32433764070421727d73b07e372", + "path": "libunwind/src/libunwind_ext.h", + "sha256": "2efb28c93eb3c32cf491733b8e9c7b5715cb15fa0d6afb7b23ee4ca6de40cc98", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/src/libunwind_ext.h", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Extensions to libunwind API.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "b00ca2c9327c74cc40f678cb4db3b56ed18dc405", + "path": "libunwind/src/shadow_stack_unwind.h", + "sha256": "c18056e575fcf2deed7ccfe469c1c7e6c1f390f64b28cac5aa304de3bb7a50fa", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/src/shadow_stack_unwind.h", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "26fc8ef70c024ab756b1fb1b03eed646a63a03ab", + "path": "mingw-w64-crt/cfguard/guard_dispatch.S", + "sha256": "a479e2319b9a2789afd6f91aedb3e6c640ed16b746df6babffbb17f810432811", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/cfguard/guard_dispatch.S", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "5c736e162339dc590723f402380c4264601aefe3", + "path": "mingw-w64-crt/cfguard/mingw_cfguard_support.c", + "sha256": "a05b0eb6e9d6553ae934f81324fced9c3a6dc89f71ad073dad8ef174d424d693", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/cfguard/mingw_cfguard_support.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "c8a8bfbeebcc7f325d7d1a729bc95bbf10b7d7d9", + "path": "mingw-w64-crt/crt/CRT_fp10.c", + "sha256": "fa9af6a9c58207fc596b3babe8f0b91ebbd75a9cf73e15aa849289e7eb300643", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/CRT_fp10.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "2bb5d94a279942260b3091ae7278ac6e000351c5", + "path": "mingw-w64-crt/crt/_newmode.c", + "sha256": "d85bb76f70f90b246c780ffbfbe6540a4d787b7801e98c8ac8c3edd50dcee971", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/_newmode.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "9e6931c4fc4b5dbd41d5338a9be793b170596802", + "path": "mingw-w64-crt/crt/cinitexe.c", + "sha256": "98c9238561c0ed1b3d7edfd1e32423dfda93c3ae285807873f637d03406bdcc9", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/cinitexe.c", + "source_notices": [] + }, + { + "git_blob": "39c0d85610f70f746f91adc9af67ccf2480b937b", + "path": "mingw-w64-crt/crt/crtbegin.c", + "sha256": "692fdc825a472b8dfda48e65eace55caf5396c8536236b814b967007c978a8b0", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/crtbegin.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "15ee52a7c3348bdd64b7c4ecb0cbe626e6f8d092", + "path": "mingw-w64-crt/crt/crtdll.c", + "sha256": "158dcc7681f335dc36c4bcf86e41444d6507679cab80a68433666df690217990", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/crtdll.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "39c0d85610f70f746f91adc9af67ccf2480b937b", + "path": "mingw-w64-crt/crt/crtend.c", + "sha256": "692fdc825a472b8dfda48e65eace55caf5396c8536236b814b967007c978a8b0", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/crtend.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "ca9b0069160c14aca643a860386c9d5180fcbd0c", + "path": "mingw-w64-crt/crt/crtexe.c", + "sha256": "0624cd5c19dfcd4f6f17a3608582db6d0d4f92a468c391890b8f9114784a4b82", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/crtexe.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "d6be1bc7c2cf76471df995bdf7509590cd4d8f4d", + "path": "mingw-w64-crt/crt/dllargv.c", + "sha256": "98a1bf05b8a037d68ba1ea98ae40a2230a4e734196879fee4bd215c5c3283112", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/dllargv.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "7edf8360c91c182f8ec6e5a695c262332ee6c3ba", + "path": "mingw-w64-crt/crt/gccmain.c", + "sha256": "07c83e890740008bb74b26ecf60d97048cfeb74d89d973b6e8db4f437bc66ac9", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/gccmain.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "5aba73462de3018c7d35ec93d5afcc6eda8276ff", + "path": "mingw-w64-crt/crt/loadcfg.S", + "sha256": "ea3b2928757e53d5f68edbacfc271f4b6070f8a118bf44e50f6a4dd44baba545", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/loadcfg.S", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "687aab4a90bc7dc14ff14f86ce95136d5c1a2422", + "path": "mingw-w64-crt/crt/merr.c", + "sha256": "37d23d36e2041d5ea6e04e6674d84c227937ec477d246742fa062b5e61e1f5ea", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/merr.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "8143c6b72998473c4df1efa0654f36e59fbc2b53", + "path": "mingw-w64-crt/crt/mingw_dll_ctors_dtors.c", + "sha256": "682be7d58c77d70fdf116ad53168c893dbeaa0c85b8a9b86300493e66d3eeaae", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/mingw_dll_ctors_dtors.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "84413cdb7c9fed8e923e3620334e0f29ccf145f2", + "path": "mingw-w64-crt/crt/mingw_helpers.c", + "sha256": "a5639b68c3176c4c6a358c48f869c2a081434c07d7a0e435013f44909a2003c5", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/mingw_helpers.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "5008790e1eefed244e387f654bf4efbe5f3b2250", + "path": "mingw-w64-crt/crt/natstart.c", + "sha256": "c65fb9a3cb70536b8f757e07df8febb0b1a5fd72889bcff4fee924add1078d14", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/natstart.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "5b903c21d211138864d6b484c5b5d8c0c5df6cf3", + "path": "mingw-w64-crt/crt/pseudo-reloc-list.c", + "sha256": "853116d1ba135ea499714152be5705c72678a86fbd9bd5b90469b0ad51ab8acc", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/pseudo-reloc-list.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "dd2a28e8c2a82fbd0d00731c38e666c09738d1f3", + "path": "mingw-w64-crt/crt/pseudo-reloc.c", + "sha256": "24d57d7fec056a84268fcb3fa43dc7fc726c3c3f4c2ff4796652ca3dba33314a", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/pseudo-reloc.c", + "source_notices": [ + "/* pseudo-reloc.c\n\n Contributed by Egor Duda \n Modified by addition of runtime_pseudo_reloc version 2\n by Kai Tietz \n\t\n THIS SOFTWARE IS NOT COPYRIGHTED\n\n This source code is offered for use in the public domain. You may\n use, modify or distribute it freely.\n\n This code is distributed in the hope that it will be useful but\n WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY\n DISCLAMED. This includes but is not limited to warranties of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n*/" + ] + }, + { + "git_blob": "6273a1c527116aa889d3958bf10de7306a20d2a2", + "path": "mingw-w64-crt/crt/tlssup.c", + "sha256": "3f330e9f97d39637245c74d8cd940b2e0238b50c56aee2ff579cff9314e48e9c", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/tlssup.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n *\n * Written by Kai Tietz \n */" + ] + }, + { + "git_blob": "fce059e14e90c9ca16425e793e43dcc803130561", + "path": "mingw-w64-crt/crt/usermatherr.c", + "sha256": "9642a86e0f68b59b958866afaca5aa602ae632d361565128237b71cff4759e48", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/usermatherr.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "b53cc18ec0c05a14962269e453b1d18b2ae1084d", + "path": "mingw-w64-crt/crt/wildcard.c", + "sha256": "a574c6324511ef40619b62a7bfdfcfd4a24a101b790074979a53fd54f9b6b363", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/wildcard.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "b2ec312f09f4f03755c048a20b29ad7454b823a8", + "path": "mingw-w64-crt/crt/xncommod.c", + "sha256": "011050a8ff748ea000d630892a16dff86ab9ffc43503befe52c1c0b79cb25479", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/xncommod.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "973ff45b16e494acf60cd8e26870460a754e9ac7", + "path": "mingw-w64-crt/crt/xthdloc.c", + "sha256": "3320df224c561ac5335121ad4e1f342b90bda7a291d0f14e89ce16c2cb17e54d", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/xthdloc.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "dcbbe11846a5d0c9cea993f7adcc87bd6a5fe958", + "path": "mingw-w64-crt/crt/xtxtmode.c", + "sha256": "a1c826ee8a440cf86dbb1ae6db80e727af5f079b5797f93a3e3a616b3db2bdb9", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/xtxtmode.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "c61e9fa8a52159f500db0e1497594b503dbcc5cd", + "path": "mingw-w64-crt/gdtoa/dmisc.c", + "sha256": "e73637f5fe5e171d13ab4ce51671f20af98c2707fe6c3ba4f25c7bcd108e0f85", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/gdtoa/dmisc.c", + "source_notices": [ + "/****************************************************************\n\nThe author of this software is David M. Gay.\n\nCopyright (C) 1998 by Lucent Technologies\nAll Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and\nits documentation for any purpose and without fee is hereby\ngranted, provided that the above copyright notice appear in all\ncopies and that both that the copyright notice and this\npermission notice and warranty disclaimer appear in supporting\ndocumentation, and that the name of Lucent or any of its entities\nnot be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior\npermission.\n\nLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.\nIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY\nSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\nIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n\n****************************************************************/" + ] + }, + { + "git_blob": "1cfe1953e4c16b19dfd7a0446da5d20ec67f3de4", + "path": "mingw-w64-crt/gdtoa/gdtoa.c", + "sha256": "09ea9686def889450b16910562c5a884e87eee161c52e6c127d373688aac8559", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/gdtoa/gdtoa.c", + "source_notices": [ + "/****************************************************************\n\nThe author of this software is David M. Gay.\n\nCopyright (C) 1998, 1999 by Lucent Technologies\nAll Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and\nits documentation for any purpose and without fee is hereby\ngranted, provided that the above copyright notice appear in all\ncopies and that both that the copyright notice and this\npermission notice and warranty disclaimer appear in supporting\ndocumentation, and that the name of Lucent or any of its entities\nnot be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior\npermission.\n\nLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.\nIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY\nSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\nIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n\n****************************************************************/" + ] + }, + { + "git_blob": "b2b4c54151a0da327338210940e5470cbca33f11", + "path": "mingw-w64-crt/gdtoa/gdtoa.h", + "sha256": "9ea503624739483d5a981d426a9b7a74fd2ee2e04599594e74b886d09beb0403", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/gdtoa/gdtoa.h", + "source_notices": [ + "/****************************************************************\n\nThe author of this software is David M. Gay.\n\nCopyright (C) 1998 by Lucent Technologies\nAll Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and\nits documentation for any purpose and without fee is hereby\ngranted, provided that the above copyright notice appear in all\ncopies and that both that the copyright notice and this\npermission notice and warranty disclaimer appear in supporting\ndocumentation, and that the name of Lucent or any of its entities\nnot be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior\npermission.\n\nLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.\nIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY\nSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\nIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n\n****************************************************************/" + ] + }, + { + "git_blob": "cc2007cd5fa3f0654b14acee99db363d515c44ad", + "path": "mingw-w64-crt/gdtoa/gdtoaimp.h", + "sha256": "cd4e3796364b4eb9d9c5cf3ff00d3abc8e114102376454bc1d2413183ca3e44d", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/gdtoa/gdtoaimp.h", + "source_notices": [ + "/****************************************************************\n\nThe author of this software is David M. Gay.\n\nCopyright (C) 1998-2000 by Lucent Technologies\nAll Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and\nits documentation for any purpose and without fee is hereby\ngranted, provided that the above copyright notice appear in all\ncopies and that both that the copyright notice and this\npermission notice and warranty disclaimer appear in supporting\ndocumentation, and that the name of Lucent or any of its entities\nnot be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior\npermission.\n\nLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.\nIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY\nSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\nIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n\n****************************************************************/" + ] + }, + { + "git_blob": "157e872319f033f3fcc838c26a93b7fc8b9c9826", + "path": "mingw-w64-crt/gdtoa/gmisc.c", + "sha256": "7b4327dfc978aacfb950bd4c6970696ccc76ddb7159800a244ef2a0bb593dc5c", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/gdtoa/gmisc.c", + "source_notices": [ + "/****************************************************************\n\nThe author of this software is David M. Gay.\n\nCopyright (C) 1998 by Lucent Technologies\nAll Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and\nits documentation for any purpose and without fee is hereby\ngranted, provided that the above copyright notice appear in all\ncopies and that both that the copyright notice and this\npermission notice and warranty disclaimer appear in supporting\ndocumentation, and that the name of Lucent or any of its entities\nnot be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior\npermission.\n\nLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.\nIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY\nSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\nIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n\n****************************************************************/" + ] + }, + { + "git_blob": "960543a606eeda45b24a4886e6149963fe6bae79", + "path": "mingw-w64-crt/gdtoa/misc.c", + "sha256": "02486c21b11fe4538bde37d4c740b486a5eef76c8fdeec8e74a9c409c8acb6dc", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/gdtoa/misc.c", + "source_notices": [ + "/****************************************************************\n\nThe author of this software is David M. Gay.\n\nCopyright (C) 1998, 1999 by Lucent Technologies\nAll Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and\nits documentation for any purpose and without fee is hereby\ngranted, provided that the above copyright notice appear in all\ncopies and that both that the copyright notice and this\npermission notice and warranty disclaimer appear in supporting\ndocumentation, and that the name of Lucent or any of its entities\nnot be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior\npermission.\n\nLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.\nIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY\nSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\nIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n\n****************************************************************/" + ] + }, + { + "git_blob": "30b11f284226c16e8e5320e4b3d164cc4a3c425d", + "path": "mingw-w64-crt/misc/__initenv.c", + "sha256": "7ca289f2891fef05351cc52879413c219b30de0258b950dbc7d4e10d05a01f97", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/misc/__initenv.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "e3f880b38408689890dff6091f2fe1ef831f8c46", + "path": "mingw-w64-crt/misc/__p___initenv.c", + "sha256": "034d66df82c6da68cc4bc59ff829ff3f18edd431cbe2f6376d51667f9b90f509", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/misc/__p___initenv.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "3f5b5261bffae5b63826829a9103d290d7bf5708", + "path": "mingw-w64-crt/misc/dllmain.c", + "sha256": "ad3eb745bc2e614de38f43700c274cae2b7edec7ee40950cc918d8b98d3d9505", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/misc/dllmain.c", + "source_notices": [] + }, + { + "git_blob": "21529682983729e6197d22fe532d974ca113fcf2", + "path": "mingw-w64-crt/misc/mingw_matherr.c", + "sha256": "47ccdea07abacdd4629596084796291ecf35f4ccf951fa6b5038b6db2eb4c336", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/misc/mingw_matherr.c", + "source_notices": [] + }, + { + "git_blob": "72fef92cc36e674db13500d74dee10a27a060631", + "path": "mingw-w64-crt/misc/ucrt__getmainargs.c", + "sha256": "7d9139300468218e77c1f4b1bc52ba2802b9273ad1f1b1c3e50be624039d2f5e", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/misc/ucrt__getmainargs.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "0aad4f6c368a7f284568ffb1e96c8e48f011e56a", + "path": "mingw-w64-crt/misc/ucrt_amsg_exit.c", + "sha256": "ad8dd7eb0b4e2fef5b5c16f4934b7f5bca265246e18440ecb380ab8ffe1a8c6d", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/misc/ucrt_amsg_exit.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "438941f7e3f473462007cffc12d967c88bf315e9", + "path": "mingw-w64-crt/stdio/mingw_fprintf.c", + "sha256": "c19ffaac9e0ee6056bf4cd0316d021596b37ac800d04dd187b01db01533d839e", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/stdio/mingw_fprintf.c", + "source_notices": [ + "/* fprintf.c\n *\n * $Id: fprintf.c,v 1.1 2008/08/11 22:41:55 keithmarshall Exp $\n *\n * Provides an implementation of the \"fprintf\" function, conforming\n * generally to C99 and SUSv3/POSIX specifications, with extensions\n * to support Microsoft's non-standard format specifications. This\n * is included in libmingwex.a, whence it may replace the Microsoft\n * function of the same name.\n *\n * Written by Keith Marshall \n *\n * This implementation of \"fprintf\" will normally be invoked by calling\n * \"__mingw_fprintf()\" in preference to a direct reference to \"fprintf()\"\n * itself; this leaves the MSVCRT implementation as the default, which\n * will be deployed when user code invokes \"fprint()\". Users who then\n * wish to use this implementation may either call \"__mingw_fprintf()\"\n * directly, or may use conditional preprocessor defines, to redirect\n * references to \"fprintf()\" to \"__mingw_fprintf()\".\n *\n * Compiling this module with \"-D INSTALL_AS_DEFAULT\" will change this\n * recommended convention, such that references to \"fprintf()\" in user\n * code will ALWAYS be redirected to \"__mingw_fprintf()\"; if this option\n * is adopted, then users wishing to use the MSVCRT implementation of\n * \"fprintf()\" will be forced to use a \"back-door\" mechanism to do so.\n * Such a \"back-door\" mechanism is provided with MinGW, allowing the\n * MSVCRT implementation to be called as \"__msvcrt_fprintf()\"; however,\n * since users may not expect this behaviour, a standard libmingwex.a\n * installation does not employ this option.\n *\n *\n * This is free software. You may redistribute and/or modify it as you\n * see fit, without restriction of copyright.\n *\n * This software is provided \"as is\", in the hope that it may be useful,\n * but WITHOUT WARRANTY OF ANY KIND, not even any implied warranty of\n * MERCHANTABILITY, nor of FITNESS FOR ANY PARTICULAR PURPOSE. At no\n * time will the author accept any form of liability for any damages,\n * however caused, resulting from the use of this software.\n *\n */" + ] + }, + { + "git_blob": "2bbe5203b52fe37cd977c6c11bc11c7924dab2ae", + "path": "mingw-w64-crt/stdio/mingw_pformat.c", + "sha256": "8ad4e2a80cb56291deb8ab42238c5084fa256a65dbf08412109f08c3ced85225", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/stdio/mingw_pformat.c", + "source_notices": [ + "/* pformat.c\n *\n * $Id: pformat.c,v 1.9 2011/01/07 22:57:00 keithmarshall Exp $\n *\n * Provides a core implementation of the formatting capabilities\n * common to the entire `printf()' family of functions; it conforms\n * generally to C99 and SUSv3/POSIX specifications, with extensions\n * to support Microsoft's non-standard format specifications.\n *\n * Written by Keith Marshall \n *\n * This is free software. You may redistribute and/or modify it as you\n * see fit, without restriction of copyright.\n *\n * This software is provided \"as is\", in the hope that it may be useful,\n * but WITHOUT WARRANTY OF ANY KIND, not even any implied warranty of\n * MERCHANTABILITY, nor of FITNESS FOR ANY PARTICULAR PURPOSE. At no\n * time will the author accept any form of liability for any damages,\n * however caused, resulting from the use of this software.\n *\n * The elements of this implementation which deal with the formatting\n * of floating point numbers, (i.e. the `%e', `%E', `%f', `%F', `%g'\n * and `%G' format specifiers, but excluding the hexadecimal floating\n * point `%a' and `%A' specifiers), make use of the `__gdtoa' function\n * written by David M. Gay, and are modelled on his sample code, which\n * has been deployed under its accompanying terms of use:--\n *\n ******************************************************************\n * Copyright (C) 1997, 1999, 2001 Lucent Technologies\n * All Rights Reserved\n *\n * Permission to use, copy, modify, and distribute this software and\n * its documentation for any purpose and without fee is hereby\n * granted, provided that the above copyright notice appear in all\n * copies and that both that the copyright notice and this\n * permission notice and warranty disclaimer appear in supporting\n * documentation, and that the name of Lucent or any of its entities\n * not be used in advertising or publicity pertaining to\n * distribution of the software without specific, written prior\n * permission.\n *\n * LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\n * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.\n * IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY\n * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\n * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\n * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\n * THIS SOFTWARE.\n ******************************************************************\n *\n */" + ] + }, + { + "git_blob": "ee98ac1ac827877eaa8e5de8a675bdc9dcced18c", + "path": "mingw-w64-crt/stdio/ucrt___local_stdio_printf_options.c", + "sha256": "0c8ab6443db6f80930f95ee4f380faf7e0bd7a04ecafa0fcba8016bd77a0c98c", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/stdio/ucrt___local_stdio_printf_options.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "0b06b14e9653a4dca58436e30cc2ad2feb9a5f2b", + "path": "mingw-w64-crt/stdio/ucrt_fprintf.c", + "sha256": "080d99fcea70a61cde96b5347e8a381c28778928584227cb6b70a543c3b0933c", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/stdio/ucrt_fprintf.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "6ac1bb8c115a5cbf82d3d1a364fc3460eeb47380", + "path": "mingw-w64-crt/stdio/ucrt_vfprintf.c", + "sha256": "682fc042d9007afcfa6c022373178d22591af8c9cb93de9ab5525b3d17cd5b75", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/stdio/ucrt_vfprintf.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + } + ], + "targets": { + "aarch64-pc-windows-gnullvm": { + "retained_objects": [ + "Unwind-seh.cpp.obj", + "UnwindLevel1-gcc-ext.c.obj", + "UnwindLevel1.c.obj", + "UnwindRegistersSave.S.obj", + "crtbegin.o", + "crtend.o", + "dllcrt2.o", + "libarm64_libmingw32_a-cinitexe.o", + "libarm64_libmingw32_a-mingw_dll_ctors_dtors.o", + "libarm64_libmingw32_a-mingw_helpers.o", + "libarm64_libmingw32_a-natstart.o", + "libarm64_libmingw32_a-pseudo-reloc-list.o", + "libarm64_libmingw32_a-pseudo-reloc.o", + "libarm64_libmingw32_a-tlssup.o", + "libarm64_libmingwex_a-dllmain.o", + "libarm64_libmingwex_a-loadcfg.o", + "libarm64_libmingwex_a-mingw_cfguard_support.o", + "libarm64_libucrt_extra_a-ucrt___local_stdio_printf_options.o", + "libarm64_libucrt_extra_a-ucrt_fprintf.o", + "libarm64_libucrt_extra_a-ucrt_vfprintf.o", + "libunwind.cpp.obj" + ], + "sdk_inputs": [ + { + "path": "aarch64-w64-mingw32/lib/crtbegin.o", + "sha256": "4ba912486f310ab85d7d06a90d4c46c22485edce0255a03a1f74c0c8510eff9e", + "size": 1309 + }, + { + "path": "aarch64-w64-mingw32/lib/crtend.o", + "sha256": "eefb57102e2168200514c7565f27b14fe519bb5a853e7f00d3e4dd2a5c777470", + "size": 1309 + }, + { + "path": "aarch64-w64-mingw32/lib/dllcrt2.o", + "sha256": "bf86f93b1ce6b401fc837edbac68e8b9ae474a3af335c67ba1659febd25305a6", + "size": 42872 + }, + { + "path": "aarch64-w64-mingw32/lib/libdbghelp.a", + "sha256": "b5d39301a039d48a1513c6222e5254efd96eb641508fac9a4635cd5e5da27968", + "size": 103246 + }, + { + "path": "aarch64-w64-mingw32/lib/libkernel32.a", + "sha256": "f5197cec7cea31be9847bfb6c3912bea507319be63740a6887d02a0b6bbdd893", + "size": 1009086 + }, + { + "path": "aarch64-w64-mingw32/lib/libmingw32.a", + "sha256": "ff45b29605c4c9de82d6ad40fcc7fe4139b37467df10541b286336f7929257c3", + "size": 339550 + }, + { + "path": "aarch64-w64-mingw32/lib/libmingwex.a", + "sha256": "d1108040c5e08d84d58108f4dfe40cb3793a0eee61d0a1fa6919f8469be5ea73", + "size": 4168698 + }, + { + "path": "aarch64-w64-mingw32/lib/libmsvcrt.a", + "sha256": "062c0d06384cb8f8db2666eda5e50dab9a300e2e662f9dda2711bd48576ae34d", + "size": 1796926 + }, + { + "path": "aarch64-w64-mingw32/lib/libntdll.a", + "sha256": "3c91ccf64aa2c8d2fa47bedf45531ec2c972ff37200eb541afb16d7259cce96c", + "size": 1126014 + }, + { + "path": "aarch64-w64-mingw32/lib/libunwind.a", + "sha256": "1a983632d86eb33d808534b4853e5185f31419adc787048c9f5bc3e76a79d9b9", + "size": 231528 + }, + { + "path": "aarch64-w64-mingw32/lib/libuser32.a", + "sha256": "fd1f8ad6376a7d57a01c9d0361f89ca038c8c03dde43b8298f094e73f24c6bf9", + "size": 434306 + }, + { + "path": "aarch64-w64-mingw32/lib/libuserenv.a", + "sha256": "fbc1da1ed5165754594e48fa8e1199a0fbe395e6ab29531d33633c14725789c5", + "size": 40108 + }, + { + "path": "aarch64-w64-mingw32/lib/libws2_32.a", + "sha256": "04d7f776550e3732b37cef7b2759862e82b2485e99cc9baf354df573da489483", + "size": 411636 + }, + { + "path": "lib/clang/23/lib/windows/libclang_rt.builtins-aarch64.a", + "sha256": "0eadf5121c8d6c9169769130d8e83a549251b91bd2686150d75f3914eb8ac6df", + "size": 760636 + } + ] + }, + "x86_64-pc-windows-gnullvm": { + "retained_objects": [ + "Unwind-seh.cpp.obj", + "UnwindLevel1-gcc-ext.c.obj", + "UnwindLevel1.c.obj", + "UnwindRegistersSave.S.obj", + "crtbegin.o", + "crtend.o", + "dllcrt2.o", + "lib64_libmingw32_a-cinitexe.o", + "lib64_libmingw32_a-mingw_dll_ctors_dtors.o", + "lib64_libmingw32_a-mingw_helpers.o", + "lib64_libmingw32_a-natstart.o", + "lib64_libmingw32_a-pseudo-reloc-list.o", + "lib64_libmingw32_a-pseudo-reloc.o", + "lib64_libmingw32_a-tlssup.o", + "lib64_libmingwex_a-dllmain.o", + "lib64_libmingwex_a-dmisc.o", + "lib64_libmingwex_a-gdtoa.o", + "lib64_libmingwex_a-gmisc.o", + "lib64_libmingwex_a-guard_dispatch.o", + "lib64_libmingwex_a-loadcfg.o", + "lib64_libmingwex_a-mingw_cfguard_support.o", + "lib64_libmingwex_a-mingw_fprintf.o", + "lib64_libmingwex_a-mingw_pformat.o", + "lib64_libmingwex_a-misc.o", + "lib64_libucrt_extra_a-ucrt___local_stdio_printf_options.o", + "lib64_libucrt_extra_a-ucrt_fprintf.o", + "lib64_libucrt_extra_a-ucrt_vfprintf.o", + "libunwind.cpp.obj" + ], + "sdk_inputs": [ + { + "path": "lib/clang/23/lib/windows/libclang_rt.builtins-x86_64.a", + "sha256": "fa6a7a18518ff5372a5f32a386ab0d689099d8c258c18eaea2431f514154c55b", + "size": 256660 + }, + { + "path": "x86_64-w64-mingw32/lib/crtbegin.o", + "sha256": "5dc28a7b0ecf42c769578f63b8d169c89c958f95c2e67b3a0d8f94b8bd3c6c60", + "size": 628 + }, + { + "path": "x86_64-w64-mingw32/lib/crtend.o", + "sha256": "c6b583eaf68b432e35507013e3213557edd2656c33916a7878c8efda18b95c19", + "size": 628 + }, + { + "path": "x86_64-w64-mingw32/lib/dllcrt2.o", + "sha256": "a846dd86db648a38ad5ee3d382295b6fa084df639a8c26cd32646ff9f71bfc47", + "size": 17632 + }, + { + "path": "x86_64-w64-mingw32/lib/libdbghelp.a", + "sha256": "f407acff38e12cb5227a6bad5f023f31c3705aca0a5339fc9b25ec433342e3cc", + "size": 49766 + }, + { + "path": "x86_64-w64-mingw32/lib/libkernel32.a", + "sha256": "6ee0041fafa7ad06bd7dc8b6b387e4ca066e76ccfeca56ae84af5a2a6d42a345", + "size": 577358 + }, + { + "path": "x86_64-w64-mingw32/lib/libmingw32.a", + "sha256": "a0aad43b481208ad1ff583102c00bd2a1e56e855b2045e282ed03845a44feef7", + "size": 139220 + }, + { + "path": "x86_64-w64-mingw32/lib/libmingwex.a", + "sha256": "df21bc3944a8766542f1b4c1ffc864e2b5dd997f2d14604eec12d3ba9258bfea", + "size": 1881848 + }, + { + "path": "x86_64-w64-mingw32/lib/libmsvcrt.a", + "sha256": "e4e38200c764bbfd217f3290f64b9bd3cc963dd782b34f3d747df27780360f62", + "size": 848642 + }, + { + "path": "x86_64-w64-mingw32/lib/libntdll.a", + "sha256": "a9e9a4eacaff6d5c186c514a8f27840df9de44c86de4dfbfe38dab0cae907cea", + "size": 545270 + }, + { + "path": "x86_64-w64-mingw32/lib/libunwind.a", + "sha256": "b37299ed084757834d7cee8d723aff6b349890d61505478602e9e981dcca839c", + "size": 91768 + }, + { + "path": "x86_64-w64-mingw32/lib/libuser32.a", + "sha256": "6b2bea0a02e6a95bcbb684ff4ede16a4a51c8bd0a55e7e15b81255c4467190bb", + "size": 207984 + }, + { + "path": "x86_64-w64-mingw32/lib/libuserenv.a", + "sha256": "c9d73aedfcbde527e9a41e9c1bb72924bd6fac5e8a4d0cae13483e8b72e2f94b", + "size": 19538 + }, + { + "path": "x86_64-w64-mingw32/lib/libws2_32.a", + "sha256": "fbb7fff6f90697b20285a1e4dfdeffb8cc5fdf7c8932ea39bc66bd722e3e33ad", + "size": 171084 + } + ] + } + } +} diff --git a/ci/test_cabi_gnullvm_notices.py b/ci/test_cabi_gnullvm_notices.py new file mode 100644 index 0000000..e126160 --- /dev/null +++ b/ci/test_cabi_gnullvm_notices.py @@ -0,0 +1,104 @@ +"""CI-регрессии exact C ABI SDK/source/runtime boundary.""" + +import copy +import hashlib +import importlib.util +from pathlib import Path +import tempfile +import unittest + +ROOT = Path(__file__).resolve().parents[1] +SPEC = importlib.util.spec_from_file_location('cabi_runtime', ROOT / 'scripts/cabi_gnullvm_notices.py') +MODULE = importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(MODULE) +TARGET = 'x86_64-pc-windows-gnullvm' + + +class CabiRuntimeTests(unittest.TestCase): + def profile(self): + return MODULE.catalogue(ROOT) + + def link_fixture(self): + document = self.profile() + profile = document['targets'][TARGET] + items = [{'path': 'link/llvm-mingw-20261020-ucrt-x86_64/' + value['path'], 'bytes': value['size'], 'sha256': value['sha256']} for value in profile['sdk_inputs']] + mapping = ''.join('00001000 00000010 16 ' + value + ':(.text)\n' for value in profile['retained_objects']).encode() + return document, items, mapping + + def test_exact_profile_has_dll_specific_targets_and_source_grants(self): + document = self.profile() + self.assertEqual(len(document['source_files']), 58) + self.assertEqual(len(document['original_documents']), 6) + self.assertEqual(len(document['targets'][TARGET]['retained_objects']), 28) + self.assertEqual(len(document['targets']['aarch64-pc-windows-gnullvm']['retained_objects']), 21) + self.assertIn('mingw-w64-crt/crt/crtdll.c', {item['path'] for item in document['source_files']}) + + def test_profile_mutation_is_rejected(self): + with tempfile.TemporaryDirectory() as temporary: + root = Path(temporary) + destination = root / MODULE.CATALOG + destination.parent.mkdir(parents=True) + destination.write_bytes((ROOT / MODULE.CATALOG).read_bytes() + b'\n') + with self.assertRaisesRegex(ValueError, 'unreviewed C ABI runtime catalogue'): + MODULE.catalogue(root) + + def test_augmentation_preserves_original_cargo_bundle(self): + before = {'schema_version': 1, 'coverage': 'Cargo/std fixture', 'packages': [{'name': 'fixture'}]} + saved = copy.deepcopy(before) + result = MODULE.augment(before, self.profile(), TARGET) + self.assertEqual(before, saved) + self.assertEqual(result['packages'], saved['packages']) + self.assertEqual(result['non_cargo_runtimes'][0]['selected_inputs']['retained_objects'], self.profile()['targets'][TARGET]['retained_objects']) + + def test_unknown_target_and_repeated_augmentation_are_rejected(self): + before = {'schema_version': 1, 'coverage': 'fixture'} + for target, bundle in [('unknown', before), (TARGET, MODULE.augment(before, self.profile(), TARGET))]: + with self.assertRaisesRegex(ValueError, 'unexpected C ABI runtime'): + MODULE.augment(bundle, self.profile(), target) + + def test_source_hash_and_original_notice_changes_are_rejected(self): + raw = b'/* Copyright fixture. Permission fixture. */\nint value;\n' + item = {'source': 'fixture', 'path': 'fixture.c', 'sha256': hashlib.sha256(raw).hexdigest(), 'source_notices': ['/* Copyright fixture. Permission fixture. */']} + document = {'source_files': [item], 'original_documents': []} + MODULE.verify_sources(document, fetch=lambda _: raw) + with self.assertRaisesRegex(ValueError, 'source/grant bytes differ'): + MODULE.verify_sources(document, fetch=lambda _: raw + b'changed') + changed = copy.deepcopy(document) + changed['source_files'][0]['source_notices'] = [] + with self.assertRaisesRegex(ValueError, 'original notice differs'): + MODULE.verify_sources(changed, fetch=lambda _: raw) + + def test_foreign_source_url_is_rejected_before_fetch(self): + with self.assertRaisesRegex(ValueError, 'unreviewed C ABI runtime source URL'): + MODULE.original('https://example.invalid/source.c') + + def test_exact_sdk_bytes_and_objects_are_accepted(self): + document, items, mapping = self.link_fixture() + MODULE.verify_inputs(items, mapping, document, TARGET) + + def test_changed_sdk_bytes_or_missing_retained_member_are_rejected(self): + document, items, mapping = self.link_fixture() + changed = copy.deepcopy(items) + changed[0]['sha256'] = '0' * 64 + with self.assertRaisesRegex(ValueError, 'differ from reviewed profile'): + MODULE.verify_inputs(changed, mapping, document, TARGET) + with self.assertRaisesRegex(ValueError, 'differ from reviewed profile'): + MODULE.verify_inputs(items, b'\n'.join(mapping.splitlines()[1:]), document, TARGET) + + def test_foreign_native_input_and_duplicate_sdk_input_are_rejected(self): + document, items, mapping = self.link_fixture() + foreign = {'path': 'external/foreign.a', 'bytes': 1, 'sha256': '0' * 64} + with self.assertRaisesRegex(ValueError, 'outside reviewed SDK/Rust boundary'): + MODULE.verify_inputs([*items, foreign], mapping, document, TARGET) + with self.assertRaisesRegex(ValueError, 'duplicate or unsafe SDK'): + MODULE.verify_inputs([*items, items[0]], mapping, document, TARGET) + + def test_legal_collection_does_not_drop_full_original_documents(self): + document = self.profile() + plain = MODULE.plain_notice(document) + for item in document['original_documents']: + self.assertIn(item['text'].encode('utf-8'), plain) + + +if __name__ == '__main__': + unittest.main() diff --git a/scripts/cabi_gnullvm_notices.py b/scripts/cabi_gnullvm_notices.py new file mode 100644 index 0000000..4e27e3e --- /dev/null +++ b/scripts/cabi_gnullvm_notices.py @@ -0,0 +1,213 @@ +"""Подготовить и проверить C ABI-specific GNU/LLVM runtime notices.""" + +import gzip +import hashlib +import importlib.util +import json +from pathlib import Path, PurePosixPath +import re +import sys +import urllib.error +import urllib.request + +CATALOG = 'ci/licenses/cabi-gnullvm-runtime.json' +CATALOG_SHA = '793c61f930c31a27f987c169eec4a07cc8c140dd16e91653fec3d029f803a816' +SDK_SHA = 'fd5462b7f5d93b2ff981fcd3f9c7e427e47f3203c64ea91c27bcc444eebd74cd' +REVISIONS = {'mingw-w64/mingw-w64': '0d6dfbc348dfad714761c0a7151615767f96bcb5', 'llvm/llvm-project': '7a941dfb2877a0b8cf30323fefa85ad019e0b0f5'} +DATA_ONLY = {'mingw-w64-crt/crt/cinitexe.c', 'mingw-w64-crt/misc/mingw_matherr.c', 'mingw-w64-crt/misc/dllmain.c'} +MAX_FILE = 4 * 1024 * 1024 +MAX_TOTAL = 64 * 1024 * 1024 + + +def read(path, limit): + if path.is_symlink() or not path.is_file(): + raise ValueError('missing or symlinked C ABI runtime input') + with path.open('rb') as source: + raw = source.read(limit + 1) + if len(raw) > limit: + raise ValueError('C ABI runtime input exceeds bound') + return raw + + +def catalogue(root): + raw = read(root / CATALOG, MAX_FILE) + if hashlib.sha256(raw).hexdigest() != CATALOG_SHA: + raise ValueError('unreviewed C ABI runtime catalogue') + document = json.loads(raw) + if document['sdk_archive_sha256'] != SDK_SHA or len(document['source_files']) != 58 or len(document['original_documents']) != 6: + raise ValueError('C ABI runtime catalogue roles differ') + return document + + +def source_file_path(evidence, item): + relative = PurePosixPath(item['path']) + if relative.is_absolute() or '..' in relative.parts or '\\' in item['path']: + raise ValueError('unsafe original source path') + matches = [repo.split('/')[-1] for repo, revision in REVISIONS.items() if item['source'].startswith('https://raw.githubusercontent.com/' + repo + '/' + revision + '/')] + if len(matches) != 1: + raise ValueError('unreviewed C ABI source repository') + return evidence / 'runtime-originals' / matches[0] / item['path'] + + +def original(url): + if not any(url.startswith('https://raw.githubusercontent.com/' + repo + '/' + revision + '/') for repo, revision in REVISIONS.items()): + raise ValueError('unreviewed C ABI runtime source URL') + for attempt in range(3): + try: + with urllib.request.urlopen(url, timeout=90) as response: + raw = response.read(MAX_FILE + 1) + break + except urllib.error.HTTPError as error: + if error.code not in {500, 502, 503, 504} or attempt == 2: + raise + except (TimeoutError, urllib.error.URLError): + if attempt == 2: + raise + if len(raw) > MAX_FILE: + raise ValueError('C ABI original source exceeds bound') + return raw + + +def verify_sources(document, fetch=original, evidence=None): + seen = set() + total = 0 + for item in [*document['source_files'], *document['original_documents']]: + if item['source'] in seen: + raise ValueError('duplicate C ABI original source') + seen.add(item['source']) + raw = fetch(item['source']) + total += len(raw) + blob = hashlib.sha1(b'blob ' + str(len(raw)).encode() + b'\0' + raw).hexdigest() + if len(raw) > MAX_FILE or total > MAX_TOTAL or hashlib.sha256(raw).hexdigest() != item['sha256'] or item.get('git_blob', blob) != blob: + raise ValueError('C ABI source/grant bytes differ') + if 'text' in item: + if item['text'].encode('utf-8') != raw: + raise ValueError('C ABI legal document differs') + else: + comments = re.findall(r'/\*.*?\*/|(?:^[ \t]*//[^\n]*(?:\n|$))+', raw.decode('utf-8'), re.M | re.S) + notices = [value for value in comments if re.search(r'copyright|licens|public domain|permission|redistribution', value, re.I)] + if item['source_notices'] != notices or not notices and item['path'] not in DATA_ONLY: + raise ValueError('C ABI file-level original notice differs') + if evidence is not None: + path = source_file_path(evidence, item) + path.parent.mkdir(parents=True, exist_ok=True) + path.write_bytes(raw) + + +def augment(bundle, document, target): + if target not in document['targets'] or bundle.get('schema_version') != 1 or 'non_cargo_runtimes' in bundle: + raise ValueError('unexpected C ABI runtime preparation state') + runtime = {'name': 'LLVM-MinGW DLL startup, MinGW runtime and LLVM libunwind', 'target': target, 'catalog_sha256': CATALOG_SHA, 'sdk_archive_sha256': SDK_SHA, 'sdk_recipe_revision': document['sdk_recipe_revision'], 'mingw_revision': document['mingw_revision'], 'llvm_revision': document['llvm_revision'], 'selected_inputs': document['targets'][target], 'source_files': document['source_files'], 'original_documents': document['original_documents'], 'coverage': document['coverage']} + return {**bundle, 'non_cargo_runtimes': [runtime], 'coverage': bundle['coverage'] + ' Includes source-reviewed C ABI GNU/LLVM runtime grants; final retained-input gate is required.'} + + +def plain_notice(document): + sections = ['Ktav C ABI Windows GNU/LLVM runtime notices.\nOriginal terms follow unchanged; the source/header notice set is conservative.\n'] + for item in document['original_documents']: + sections.extend(['\n===== ' + item['source'] + ' =====\n', item['text']]) + for item in document['source_files']: + sections.extend(['\n===== ' + item['source'] + ' =====\n', '\n'.join(item['source_notices'])]) + return '\n'.join(sections).encode('utf-8') + + +def prepare(evidence, target): + root = Path(__file__).resolve().parents[1] + document = catalogue(root) + if target not in document['targets'] or (evidence / 'NOTICE.cargo-std.json').exists(): + raise ValueError('unreviewed target or runtime already prepared') + verify_sources(document, evidence=evidence) + before = read(evidence / 'NOTICE.json', MAX_TOTAL) + combined = (json.dumps(augment(json.loads(before), document, target), ensure_ascii=False, sort_keys=True, indent=2) + '\n').encode('utf-8') + payload = gzip.compress(combined, mtime=0) + if len(combined) > MAX_TOTAL or len(payload) > MAX_FILE: + raise ValueError('C ABI combined runtime notice exceeds bound') + (evidence / 'NOTICE.cargo-std.json').write_bytes(before) + (evidence / 'NOTICE.json').write_bytes(combined) + (evidence / 'NOTICE.json.gz').write_bytes(payload) + (evidence / 'NOTICE.windows-runtime.txt').write_bytes(plain_notice(document)) + (evidence / 'cabi-gnullvm-runtime.json').write_bytes(read(root / CATALOG, MAX_FILE)) + + +def retained_objects(raw): + objects = set() + for line in raw.splitlines(): + match = re.match(rb'^[0-9a-fA-F]+\s+[0-9a-fA-F]+\s+\d+\s{2,}(.+):\([^\r\n]*\)\s*$', line) + if match and b'.rcgu.o' not in match[1]: + objects.add(match[1].decode('utf-8').replace('\\', '/').rsplit('/', 1)[-1]) + return objects + + +def sdk_inputs(items, target): + selected = [] + marker = 'llvm-mingw-20261020-ucrt-x86_64/' + seen = set() + for item in items: + name = item['path'].replace('\\', '/') + if not name.endswith(('.a', '.o', '.obj', '.rlib', '.lib')): + continue + if marker not in name: + cargo = r'/target/' + re.escape(target) + r'/release/deps/' + rust = r'/[.]rustup/toolchains/1[.]99[.]1-x86_64-pc-windows-msvc/lib/rustlib/' + re.escape(target) + r'/lib/' + accepted = re.search(cargo + r'ktav_cabi[.][^/]+[.]rcgu[.]o$', name) or re.search(cargo + r'rustc[^/]+/libstd-[0-9a-f]+[.]rlib$', name) or re.search(rust + r'libcompiler_builtins-[0-9a-f]+[.]rlib$', name) + if not accepted: + raise ValueError('native linker input outside reviewed SDK/Rust boundary') + continue + if name.count(marker) != 1: + raise ValueError('unreviewed SDK linker input path') + relative = name.split(marker, 1)[1] + if relative in seen or '..' in PurePosixPath(relative).parts: + raise ValueError('duplicate or unsafe SDK linker input') + seen.add(relative) + selected.append({'path': relative, 'size': item['bytes'], 'sha256': item['sha256']}) + return sorted(selected, key=lambda item: item['path']) + + +def verify_inputs(items, mapping, document, target): + if target not in document['targets']: + raise ValueError('unreviewed C ABI target') + expected = document['targets'][target] + if sdk_inputs(items, target) != expected['sdk_inputs'] or retained_objects(mapping) != set(expected['retained_objects']): + raise ValueError('C ABI SDK bytes or retained objects differ from reviewed profile') + + +def verify(evidence, binary, target): + spec = importlib.util.spec_from_file_location('cabi_notice_scanner', Path(__file__).with_name('check_embedded_notices.py')) + scanner = importlib.util.module_from_spec(spec) + spec.loader.exec_module(scanner) + + document = catalogue(Path(__file__).resolve().parents[1]) + if target not in document['targets']: + raise ValueError('unreviewed C ABI target') + records = {item['source']: item for item in [*document['source_files'], *document['original_documents']]} + verify_sources(document, fetch=lambda url: read(source_file_path(evidence, records[url]), MAX_FILE)) + raw = read(binary, 128 * 1024 * 1024) + notice = read(evidence / 'NOTICE.json', MAX_TOTAL) + before = json.loads(read(evidence / 'NOTICE.cargo-std.json', MAX_TOTAL)) + if json.loads(notice) != augment(before, document, target) or scanner._extract(raw)[0] != notice: + raise ValueError('actual C ABI runtime resource differs') + if read(evidence / 'NOTICE.windows-runtime.txt', MAX_TOTAL) != plain_notice(document): + raise ValueError('plain C ABI original notices differ') + if read(evidence / 'cabi-gnullvm-runtime.json', MAX_FILE) != read(Path(__file__).resolve().parents[1] / CATALOG, MAX_FILE): + raise ValueError('staged C ABI catalogue differs') + identity = json.loads(read(evidence / 'native-verification.json', MAX_FILE)) + mapping = read(evidence / 'native-link.map', 32 * 1024 * 1024) + if identity['target'] != target or identity['binary_sha256'] != hashlib.sha256(raw).hexdigest() or identity['map_sha256'] != hashlib.sha256(mapping).hexdigest(): + raise ValueError('actual C ABI release/map identity differs') + expected = document['targets'][target] + inputs = json.loads(read(evidence / 'link-input-fingerprints.json', MAX_FILE)) + verify_inputs(inputs, mapping, document, target) + provenance = json.loads(read(evidence / 'source-provenance.json', MAX_FILE)) + if provenance['sdk_archive_sha256'] != SDK_SHA or provenance['source_ref'] != '562deb3fde092d63a78f359be095e5079929d0d1': + raise ValueError('C ABI source/SDK identity differs') + report = {'target': target, 'binary_sha256': identity['binary_sha256'], 'notice_sha256': hashlib.sha256(notice).hexdigest(), 'catalog_sha256': CATALOG_SHA, 'sdk_inputs': len(expected['sdk_inputs']), 'retained_runtime_objects': len(expected['retained_objects']), 'source_records': len(document['source_files']), 'scope': 'Actual C ABI DLL resource and target-specific SDK input/source-grant binding; not NAPI compatibility, other targets or historical published artifact clearance.'} + (evidence / 'native-runtime-verification.json').write_text(json.dumps(report, sort_keys=True, indent=2) + '\n', encoding='utf-8') + print(json.dumps(report, sort_keys=True)) + + +if __name__ == '__main__': + if len(sys.argv) == 4 and sys.argv[1] == 'prepare': + prepare(Path(sys.argv[2]), sys.argv[3]) + elif len(sys.argv) == 5 and sys.argv[1] == 'verify': + verify(Path(sys.argv[2]), Path(sys.argv[3]), sys.argv[4]) + else: + raise SystemExit('usage: cabi_gnullvm_notices.py prepare EVIDENCE TARGET | verify EVIDENCE BINARY TARGET') From 3f9569c4784bd36415d64c72bbbfba9382000161 Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sat, 31 Oct 2026 23:47:42 +0100 Subject: [PATCH 33/51] fix(ci): bind oversized SDK legal reads to document bytes The runner Visual Studio installation changed from 18.11.12315.225 to 18.11.12328.437 while VC Tools, Windows SDK, linker bytes and the observed large notice path/size remained unchanged. An installer build number is not the identity of that legal document. Keep the default 4 MiB and total 32 MiB guards. Permit only the known exact 6,167,634-byte notice path, then require its previously collected original SHA256 before accepting the complete bytes. Reject unknown same-size content and report its actual digest. This changes evidence collection, not redistribution approval. Retain reader overflow/path/size regressions and add actual-byte hash rejection and unchanged small-document preservation tests. No SDK downgrade, copyright truncation or test skip is used. Co-Authored-By: Claude Opus 5.5 --- ci/test_msvc_napi_evidence.py | 29 ++++++++++++++++++--------- scripts/collect_msvc_napi_evidence.py | 20 +++++++++--------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/ci/test_msvc_napi_evidence.py b/ci/test_msvc_napi_evidence.py index e3f62b7..1796ae1 100644 --- a/ci/test_msvc_napi_evidence.py +++ b/ci/test_msvc_napi_evidence.py @@ -43,23 +43,32 @@ def test_outside_pe_offset_is_rejected(self): MSVC.pe_machine(data) def test_default_legal_limit_is_unchanged(self): - self.assertEqual(MSVC.legal_read_limit('unknown/NOTICE.txt', {}, 4 * 1024 * 1024), 4 * 1024 * 1024) + self.assertEqual(MSVC.legal_read_limit('unknown/NOTICE.txt', 4 * 1024 * 1024), 4 * 1024 * 1024) with self.assertRaisesRegex(ValueError, 'exceeds 4 MiB'): - MSVC.legal_read_limit('unknown/NOTICE.txt', {}, 4 * 1024 * 1024 + 1) + MSVC.legal_read_limit('unknown/NOTICE.txt', 4 * 1024 * 1024 + 1) - def test_observed_large_original_is_collectable_only_at_exact_identity(self): + def test_large_document_bound_is_path_and_size_specific(self): key = 'visual-studio/Licenses/1033/ThirdPartyNotices.txt' - info = {'visual_studio_version': '18.11.12315.225', 'vctools_version': '14.51.36231', 'windows_sdk_version': '10.0.26100.0'} - self.assertEqual(MSVC.legal_read_limit(key, info, 6167634), 6167634) - for field in info: - with self.subTest(field=field), self.assertRaisesRegex(ValueError, 'exceeds 4 MiB'): - MSVC.legal_read_limit(key, {**info, field: 'unreviewed'}, 6167634) + self.assertEqual(MSVC.legal_read_limit(key, 6167634), 6167634) for name in [key.lower(), key + '.other', 'windows-sdk/Licenses/1033/ThirdPartyNotices.txt']: with self.subTest(path=name), self.assertRaisesRegex(ValueError, 'exceeds 4 MiB'): - MSVC.legal_read_limit(name, info, 6167634) + MSVC.legal_read_limit(name, 6167634) for size in [6167633, 6167635, 32 * 1024 * 1024]: with self.subTest(size=size), self.assertRaisesRegex(ValueError, 'exceeds 4 MiB'): - MSVC.legal_read_limit(key, info, size) + MSVC.legal_read_limit(key, size) + + def test_unknown_same_size_legal_bytes_are_rejected(self): + with tempfile.TemporaryDirectory() as temporary: + path = Path(temporary) / 'ThirdPartyNotices.txt' + path.write_bytes(b'x' * 6167634) + with self.assertRaisesRegex(ValueError, 'unreviewed oversized SDK legal SHA256'): + MSVC.legal_document(path, 'visual-studio/Licenses/1033/ThirdPartyNotices.txt') + + def test_default_legal_document_bytes_are_preserved(self): + with tempfile.TemporaryDirectory() as temporary: + path = Path(temporary) / 'LICENSE.txt' + path.write_bytes(b'full original copyright and grant') + self.assertEqual(MSVC.legal_document(path, 'unknown/LICENSE.txt'), path.read_bytes()) def test_large_original_reader_still_rejects_overflow(self): with tempfile.TemporaryDirectory() as temporary: diff --git a/scripts/collect_msvc_napi_evidence.py b/scripts/collect_msvc_napi_evidence.py index 99ed2dd..14b0c52 100644 --- a/scripts/collect_msvc_napi_evidence.py +++ b/scripts/collect_msvc_napi_evidence.py @@ -43,20 +43,22 @@ def pe_machine(data): return struct.unpack_from(' 4 * 1024 * 1024 and checksum != 'c18053db908528af47ca838e482442ae822d8bf7fef93b9d6e8f043a38d378db': + raise ValueError(f'unreviewed oversized SDK legal SHA256: {key}; sha256={checksum}') + return raw + + def collect(evidence, binary, original, sdk_info, reproduction, target): machines = {'x86_64-pc-windows-msvc': 0x8664, 'aarch64-pc-windows-msvc': 0xAA64} if target not in machines: @@ -135,7 +137,7 @@ def collect(evidence, binary, original, sdk_info, reproduction, target): seen.add(key.casefold()) if not path.resolve().is_relative_to(root.resolve()): raise ValueError('SDK legal document escapes selected installation') - raw = read(path, legal_read_limit(key, info, path.stat().st_size)) + raw = legal_document(path, key) total += len(raw) if total > 32 * 1024 * 1024 or len(legal) >= 1024: raise ValueError('MSVC SDK legal inventory exceeds bound') From bb3a7328c7a12e399ea96ff798fb5033bb539246 Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sun, 1 Nov 2026 00:23:57 +0100 Subject: [PATCH 34/51] ci: gate GNU C ABI resources on exact Zig runtime inputs Build both original 0.8.1 C ABI targets with the reviewed lock and only the existing notice hook/include. Reuse the source-reviewed Zig 0.14.0 catalogue without asserting its prior linked-code proof applies automatically to these new binaries. Pin the 37 source/legal roles and require actual source hashes and unchanged original grants. Preserve Cargo/std material, full plain runtime notices and embedded combined resources. Capture one real link command, all seven expected archive members, and fingerprints of both archives from a fresh job-owned Zig cache. Check actual ELF64 CPU, original callable/data export roles, OS-only imports, absence of SDK loader paths and glibc 2.17 compatibility. Run source/notice/ELF regressions and actual matching-x64 Bun/Deno FFI corpus consumers in CI; ARM remains cross-binary inspection. No parser, dependency, MSRV, product version, release, registry publication or historical artifact change is included. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/gnu-cabi-notice-check.yml | 192 +++++++++++++ ci/test_gnu_cabi_notices.py | 108 +++++++ ci/zig-runtime-catalog.json | 299 ++++++++++++++++++++ scripts/capture-zig-link.sh | 9 + scripts/check_gnu_cabi_evidence.py | 77 +++++ scripts/zig_runtime_notices.py | 178 ++++++++++++ 6 files changed, 863 insertions(+) create mode 100644 .github/workflows/gnu-cabi-notice-check.yml create mode 100644 ci/test_gnu_cabi_notices.py create mode 100644 ci/zig-runtime-catalog.json create mode 100755 scripts/capture-zig-link.sh create mode 100644 scripts/check_gnu_cabi_evidence.py create mode 100644 scripts/zig_runtime_notices.py diff --git a/.github/workflows/gnu-cabi-notice-check.yml b/.github/workflows/gnu-cabi-notice-check.yml new file mode 100644 index 0000000..aa22fd9 --- /dev/null +++ b/.github/workflows/gnu-cabi-notice-check.yml @@ -0,0 +1,192 @@ +name: Linux GNU C ABI notice evidence + +on: + pull_request: + +permissions: + contents: read + +env: + SOURCE_REF: 562deb3fde092d63a78f359be095e5079929d0d1 + LC_ALL: C + +jobs: + gnu-cabi: + name: GNU C ABI notices / ${{ matrix.target }} + runs-on: ubuntu-latest + timeout-minutes: 35 + strategy: + fail-fast: false + matrix: + target: [x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu] + env: + CABI_TARGET: ${{ matrix.target }} + steps: + - uses: actions/checkout@v4 + - name: Preserve reviewed source overlay and notice tools + shell: python + run: | + import os + import shutil + from pathlib import Path + stage = Path(os.environ['RUNNER_TEMP']) / 'gnu-cabi-tools' + stage.mkdir() + names = ['Cargo.lock', 'ci/js-build-lock.json', 'crates/cabi/build.rs', 'scripts/patch_cabi_notice_source.py', 'ci/test_cabi_notice_overlay.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json', 'scripts/zig_runtime_notices.py', 'scripts/capture-zig-link.sh', 'scripts/check_gnu_cabi_evidence.py', 'ci/zig-runtime-catalog.json', 'ci/test_gnu_cabi_notices.py'] + for name in names: + path = stage / name + path.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(name, path) + - uses: actions/checkout@v4 + with: + ref: ${{ env.SOURCE_REF }} + submodules: recursive + persist-credentials: false + - name: Restore only the original C ABI notice hook and include + shell: python + run: | + import hashlib + import json + import os + import shutil + import subprocess + import sys + from pathlib import Path + if subprocess.check_output(['git', 'rev-parse', 'HEAD'], text=True).strip() != os.environ['SOURCE_REF']: + raise SystemExit('unexpected GNU C ABI source') + overlay = ['crates/cabi/build.rs', 'crates/cabi/src/lib.rs'] + baseline = {name: hashlib.sha256(Path(name).read_bytes()).hexdigest() if Path(name).is_file() else None for name in overlay} + stage = Path(os.environ['RUNNER_TEMP']) / 'gnu-cabi-tools' + for path in stage.rglob('*'): + if path.is_file(): + destination = Path(path.relative_to(stage)) + destination.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(path, destination) + subprocess.run([sys.executable, '-I', 'scripts/patch_cabi_notice_source.py', 'crates/cabi/src/lib.rs'], check=True) + protected = ['Cargo.toml', 'crates', 'tests', 'root-docs', 'package.json', 'package-lock.json'] + changed = set(subprocess.check_output(['git', 'diff', '--name-only', '--', *protected], text=True).splitlines()) + changed.update(subprocess.check_output(['git', 'ls-files', '--others', '--exclude-standard', '--', *protected], text=True).splitlines()) + if changed != set(overlay): + raise SystemExit('GNU source changed beyond its notice hook/include') + record = {'source_ref': os.environ['SOURCE_REF'], 'tooling_ref': os.environ['GITHUB_SHA'], 'target': os.environ['CABI_TARGET'], 'notice_overlay': {name: {'baseline_sha256': baseline[name], 'compiled_sha256': hashlib.sha256(Path(name).read_bytes()).hexdigest()} for name in overlay}, 'scope': 'Original 0.8.1 parser APIs and reviewed dependency graph with C ABI notice metadata only; not historical published dependency evidence.'} + (Path(os.environ['RUNNER_TEMP']) / 'gnu-cabi-source.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - uses: dtolnay/rust-toolchain@1.99.1 + with: + targets: ${{ matrix.target }} + components: rust-docs + - uses: mlugg/setup-zig@v2 + with: + version: 0.14.0 + - uses: taiki-e/install-action@v2 + with: + tool: cargo-zigbuild@0.24.0 + - uses: taiki-e/install-action@v2 + with: + tool: cargo-about@0.9.3 + - name: Verify source, archive, notice and ELF regression guards + shell: bash + run: | + set -euo pipefail + python3 -I -m unittest discover -s ci -p test_cabi_notice_overlay.py -v + python3 -I -m unittest discover -s ci -p test_gnu_cabi_notices.py -v + - name: Prepare full reviewed Cargo/std and Zig runtime notices + shell: python + run: | + import os + import shutil + import subprocess + import sys + from pathlib import Path + evidence = Path(os.environ['RUNNER_TEMP']) / 'gnu-cabi-evidence' + subprocess.run([sys.executable, 'scripts/prepare_js_notices.py', str(evidence)], check=True) + subprocess.run([sys.executable, '-I', 'scripts/zig_runtime_notices.py', 'prepare', str(evidence)], check=True) + shutil.copyfile(Path(os.environ['RUNNER_TEMP']) / 'gnu-cabi-source.json', evidence / 'source-provenance.json') + for name in ['LICENSE-MIT', 'LICENSE-APACHE']: + shutil.copyfile(name, evidence / name) + - name: Build original C ABI with exact Zig map and command capture + shell: bash + run: | + set -euo pipefail + if [[ -n "${RUSTFLAGS:-}" || -n "${CARGO_ENCODED_RUSTFLAGS:-}" ]]; then + printf '%s\n' 'Preexisting GNU linker flags require review' >&2 + exit 1 + fi + evidence="$RUNNER_TEMP/gnu-cabi-evidence" + zig version > "$evidence/zig-version.txt" + zig env > "$evidence/zig-env.json" + cargo zigbuild --version > "$evidence/cargo-zigbuild-version.txt" + sha256sum "$(command -v cargo-zigbuild)" > "$evidence/cargo-zigbuild.sha256" + sha256sum "$(command -v zig)" > "$evidence/zig.sha256" + export ZIG_GLOBAL_CACHE_DIR="$RUNNER_TEMP/gnu-cabi-zig-cache" + mkdir "$ZIG_GLOBAL_CACHE_DIR" + export KTAV_REAL_ZIG="$(command -v zig)" + export KTAV_LINK_MAP="$evidence/native-link.map" + export KTAV_LINK_COMMAND="$evidence/native-link-command.json" + export CARGO_ZIGBUILD_ZIG_COMMAND="$PWD/scripts/capture-zig-link.sh" + unset CARGO_ZIGBUILD_ZIG_COMMAND_ARGS + chmod +x "$CARGO_ZIGBUILD_ZIG_COMMAND" + export KTAV_CABI_NOTICES_GZIP="$evidence/NOTICE.json.gz" + RUSTFLAGS='-C link-arg=-Wl,--print-map' cargo zigbuild --locked --release -p ktav-cabi --target "$CABI_TARGET.2.17" + python3 -I scripts/zig_runtime_notices.py verify "$evidence" + cp "target/$CABI_TARGET/release/libktav_cabi.so" "$evidence/libktav_cabi.so" + python3 -I scripts/check_gnu_cabi_evidence.py "$evidence/libktav_cabi.so" "$evidence" "$CABI_TARGET" + python3 -I scripts/check_embedded_notices.py "$evidence/libktav_cabi.so" "$evidence/NOTICE.json" > "$evidence/embedded-verification.json" + cmp Cargo.lock "$evidence/Cargo.lock" + - uses: actions/setup-node@v4 + if: matrix.target == 'x86_64-unknown-linux-gnu' + with: + node-version: '24' + - uses: oven-sh/setup-bun@v2 + if: matrix.target == 'x86_64-unknown-linux-gnu' + - uses: denoland/setup-deno@v2 + if: matrix.target == 'x86_64-unknown-linux-gnu' + with: + deno-version: v2.x + - name: Run actual x64 Bun and Deno FFI corpus consumers + if: matrix.target == 'x86_64-unknown-linux-gnu' + shell: python + run: | + import hashlib + import json + import os + import shutil + import subprocess + import sys + from pathlib import Path + evidence = Path(os.environ['RUNNER_TEMP']) / 'gnu-cabi-evidence' + sdk = Path(json.loads((evidence / 'zig-env.json').read_bytes())['lib_dir']).resolve().parent + consumer = Path(os.environ['RUNNER_TEMP']) / 'gnu-cabi-consumer' + (consumer / 'release').mkdir(parents=True) + binary = consumer / 'release/libktav_cabi.so' + shutil.copyfile(evidence / binary.name, binary) + environment = {**os.environ, 'CARGO_TARGET_DIR': str(consumer), 'EXPECTED_CABI': str(binary)} + for key in ['PATH', 'LD_LIBRARY_PATH']: + environment[key] = os.pathsep.join(part for part in environment.get(key, '').split(os.pathsep) if part and not Path(part).resolve().is_relative_to(sdk)) + shutil.copyfile('package-lock.json', evidence / 'consumer-npm-lock-source.json') + subprocess.run(['npm', 'install', '--ignore-scripts', '--no-audit', '--no-fund'], env=environment, check=True) + subprocess.run(['git', 'diff', '--exit-code', '--', 'package.json'], check=True) + shutil.copyfile('package-lock.json', evidence / 'consumer-npm-lock-resolved.json') + subprocess.run(['node', 'scripts/check-npm-licenses.mjs'], env=environment, check=True) + subprocess.run(['npm', 'run', 'build:ts'], env=environment, check=True) + preflight = 'import assert from "node:assert/strict";import {realpathSync} from "node:fs";import * as paths from "./tests/shared/test-paths.mjs";assert.ok(paths.cabiBuilt());assert.equal(realpathSync(paths.cabi),realpathSync(process.env.EXPECTED_CABI));' + subprocess.run(['node', '--input-type=module', '-e', preflight], env=environment, check=True) + for role, command in [('bun', ['bun', 'run', 'tests/bun/run-bun-ffi.mjs']), ('deno', ['deno', 'run', '--allow-ffi', '--allow-env', '--allow-read', 'tests/deno/run-deno-ffi.ts'])]: + result = subprocess.run(command, env=environment, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + (evidence / (role + '-consumer-stdout.txt')).write_bytes(result.stdout) + (evidence / (role + '-consumer-stderr.txt')).write_bytes(result.stderr) + sys.stdout.buffer.write(result.stdout) + sys.stderr.buffer.write(result.stderr) + if result.returncode or b'passed' not in result.stdout or b'skipping' in result.stdout.lower(): + raise SystemExit(role + ' actual GNU C ABI corpus failed or skipped') + if binary.read_bytes() != (evidence / 'libktav_cabi.so').read_bytes(): + raise SystemExit('actual consumer library bytes changed') + record = {'binary_sha256': hashlib.sha256(binary.read_bytes()).hexdigest(), 'target': os.environ['CABI_TARGET'], 'actual_bun_corpus': True, 'actual_deno_corpus': True, 'sdk_paths_removed': True, 'scope': 'Matching-x64 C ABI corpus only; ARM cross binary inspected, not executed.'} + (evidence / 'consumer-verification.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') + - uses: actions/upload-artifact@v4 + if: always() + with: + name: gnu-cabi-evidence-${{ matrix.target }} + path: ${{ runner.temp }}/gnu-cabi-evidence/ + if-no-files-found: warn diff --git a/ci/test_gnu_cabi_notices.py b/ci/test_gnu_cabi_notices.py new file mode 100644 index 0000000..96ff8d6 --- /dev/null +++ b/ci/test_gnu_cabi_notices.py @@ -0,0 +1,108 @@ +"""CI-регрессии source-bound Zig notices и actual ELF boundaries.""" + +import copy +import hashlib +import importlib.util +import json +from pathlib import Path +import struct +import unittest +from unittest import mock + +ROOT = Path(__file__).resolve().parents[1] + + +def load(name, filename): + spec = importlib.util.spec_from_file_location(name, ROOT / 'scripts' / filename) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +RUNTIME = load('zig_runtime', 'zig_runtime_notices.py') +ELF = load('gnu_elf', 'check_gnu_cabi_evidence.py') + + +def mapping(members=None): + pairs = RUNTIME.EXPECTED_MEMBERS if members is None else members + return '\n'.join('/cache/' + archive + '(' + member + '):(.text)' for archive, member in pairs) + '\n/build/ktav_cabi.unit.rcgu.o:(.text)\n' + + +class GnuCabiTests(unittest.TestCase): + def test_exact_profile_preserves_all_source_legal_roles(self): + catalog, raw = RUNTIME._catalogue() + self.assertEqual(hashlib.sha256(raw).hexdigest(), RUNTIME.CATALOG_SHA) + self.assertEqual(len(catalog['files']), 37) + self.assertEqual(catalog['zig_version'], '0.14.0') + + def test_profile_permission_text_cannot_change(self): + catalog, _ = RUNTIME._catalogue() + catalog['credits'] += 'changed attribution' + with mock.patch.object(RUNTIME, '_read', return_value=json.dumps(catalog).encode()): + with self.assertRaisesRegex(ValueError, 'unreviewed Zig runtime catalogue'): + RUNTIME._catalogue() + + def test_exact_members_are_accepted(self): + self.assertEqual(RUNTIME._members(mapping()), sorted(RUNTIME.EXPECTED_MEMBERS)) + + def test_missing_or_extra_static_member_is_rejected(self): + pairs = set(RUNTIME.EXPECTED_MEMBERS) + pairs.pop() + for changed in [pairs, RUNTIME.EXPECTED_MEMBERS | {('foreign.a', 'foreign.o')}]: + with self.subTest(members=changed), self.assertRaisesRegex(ValueError, 'unreviewed archive membership'): + RUNTIME._members(mapping(changed)) + + def test_foreign_direct_object_is_rejected(self): + with self.assertRaisesRegex(ValueError, 'unreviewed direct object'): + RUNTIME._members(mapping() + '/foreign/startup.o:(.text)\n') + + def test_cargo_materials_are_preserved_without_mutation(self): + before = {'schema_version': 1, 'coverage': 'fixture', 'licenses': ['original']} + saved = copy.deepcopy(before) + result = RUNTIME._augment(before, RUNTIME._catalogue()[0]) + self.assertEqual(before, saved) + self.assertEqual(result['licenses'], ['original']) + with self.assertRaisesRegex(ValueError, 'unexpected native notice'): + RUNTIME._augment(result, RUNTIME._catalogue()[0]) + + def test_plain_notice_retains_complete_original_grants(self): + catalog, _ = RUNTIME._catalogue() + plain = RUNTIME._plain_notice(catalog) + for item in catalog['files']: + texts = [item['license_text']] if 'license_text' in item else item['source_notices'] + for text in texts: + self.assertIn(text.encode('utf-8'), plain) + + def test_matching_elf64_cpu_is_required(self): + data = bytearray(64) + data[:6] = b'\x7fELF\x02\x01' + struct.pack_into(' to obtain a copy.\n\f\nThe file inet/rcmd.c is under a UCB copyright and the following:\n\nCopyright (C) 1998 WIDE Project.\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n1. Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n2. Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n3. Neither the name of the project nor the names of its contributors\n may be used to endorse or promote products derived from this software\n without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\nARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE\nFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\nOR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\nHOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\nLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\nOUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGE.\n\f\nThe file posix/runtests.c is copyright Tom Lord:\n\nCopyright 1995 by Tom Lord\n\n All Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and its\ndocumentation for any purpose and without fee is hereby granted,\nprovided that the above copyright notice appear in all copies and that\nboth that copyright notice and this permission notice appear in\nsupporting documentation, and that the name of the copyright holder not be\nused in advertising or publicity pertaining to distribution of the\nsoftware without specific, written prior permission.\n\nTom Lord DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO\nEVENT SHALL TOM LORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR\nCONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF\nUSE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n\f\nThe posix/rxspencer tests are copyright Henry Spencer:\n\nCopyright 1992, 1993, 1994, 1997 Henry Spencer. All rights reserved.\nThis software is not subject to any license of the American Telephone\nand Telegraph Company or of the Regents of the University of California.\n\nPermission is granted to anyone to use this software for any purpose on\nany computer system, and to alter it and redistribute it, subject\nto the following restrictions:\n\n1. The author is not responsible for the consequences of use of this\n software, no matter how awful, even if they arise from flaws in it.\n\n2. The origin of this software must not be misrepresented, either by\n explicit claim or by omission. Since few users ever read sources,\n credits must appear in the documentation.\n\n3. Altered versions must be plainly marked as such, and must not be\n misrepresented as being the original software. Since few users\n ever read sources, credits must appear in the documentation.\n\n4. This notice may not be removed or altered.\n\f\nThe file posix/PCRE.tests is copyright University of Cambridge:\n\nCopyright (c) 1997-2003 University of Cambridge\n\nPermission is granted to anyone to use this software for any purpose on any\ncomputer system, and to redistribute it freely, subject to the following\nrestrictions:\n\n1. This software is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n2. The origin of this software must not be misrepresented, either by\n explicit claim or by omission. In practice, this means that if you use\n PCRE in software that you distribute to others, commercially or\n otherwise, you must put a sentence like this\n\n Regular expression support is provided by the PCRE library package,\n which is open source software, written by Philip Hazel, and copyright\n by the University of Cambridge, England.\n\n somewhere reasonably visible in your documentation and in any relevant\n files or online help data or similar. A reference to the ftp site for\n the source, that is, to\n\n ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/\n\n should also be given in the documentation. However, this condition is not\n intended to apply to whole chains of software. If package A includes PCRE,\n it must acknowledge it, but if package B is software that includes package\n A, the condition is not imposed on package B (unless it uses PCRE\n independently).\n\n3. Altered versions must be plainly marked as such, and must not be\n misrepresented as being the original software.\n\n4. If PCRE is embedded in any software that is released under the GNU\n General Purpose Licence (GPL), or Lesser General Purpose Licence (LGPL),\n then the terms of that licence shall supersede any condition above with\n which it is incompatible.\n\f\nFiles from Sun fdlibm are copyright Sun Microsystems, Inc.:\n\nCopyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\n\nDeveloped at SunPro, a Sun Microsystems, Inc. business.\nPermission to use, copy, modify, and distribute this\nsoftware is freely granted, provided that this notice\nis preserved.\n\f\nVarious long double libm functions are copyright Stephen L. Moshier:\n\nCopyright 2001 by Stephen L. Moshier \n\n This library is free software; you can redistribute it and/or\n modify it under the terms of the GNU Lesser General Public\n License as published by the Free Software Foundation; either\n version 2.1 of the License, or (at your option) any later version.\n\n This library is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public\n License along with this library; if not, see\n . */\n\f\nCopyright (c) 1995 IBM Corporation\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\f\nVarious files in sysdeps/ieee754/flt-32, taken from the CORE-MATH project\n, are distributed under the\nfollowing license:\n\nCopyright (c) 2022-2024 Alexei Sibidanov. Paul Zimmermann.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n", + "path": "lib/libc/glibc/LICENSES", + "sha256": "b22a69aa3f80a5201818c66cb0df0f25f9fa13cf5861b0093a058dbd12d50dce" + }, + { + "git_blob": "c4dd3acd604680a20d52ec46d1c4384806bd4a15", + "path": "lib/libc/glibc/io/fstat64-2.32.c", + "sha256": "cd4bac3397e220917fbb81bfbe56385a724a750936a0e1e6a1dc377cfca1c65a", + "source_notices": [ + "/* Copyright (C) 1996-2020 Free Software Foundation, Inc.\n This file is part of the GNU C Library.\n\n The GNU C Library is free software; you can redistribute it and/or\n modify it under the terms of the GNU Lesser General Public\n License as published by the Free Software Foundation; either\n version 2.1 of the License, or (at your option) any later version.\n\n In addition to the permissions in the GNU Lesser General Public\n License, the Free Software Foundation gives you unlimited\n permission to link the compiled version of this file with other\n programs, and to distribute those programs without any restriction\n coming from the use of this file. (The GNU Lesser General Public\n License restrictions do apply in other respects; for example, they\n cover modification of the file, and distribution when not linked\n into another program.)\n\n Note that people who make modified versions of this file are not\n obligated to grant this special exception for their modified\n versions; it is their choice whether to do so. The GNU Lesser\n General Public License gives permission to release a modified\n version without this exception; this exception also makes it\n possible to release a modified version which carries forward this\n exception.\n\n The GNU C Library is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public\n License along with the GNU C Library; if not, see\n . */" + ] + }, + { + "git_blob": "8b6b662f3ac4f69357ae6ffbf6d9692b4c646170", + "path": "lib/libc/glibc/io/stat64-2.32.c", + "sha256": "dfa5093069bbbca665a543cf1a3c9d19aec1f69b125b6a668b91e0c1f272a848", + "source_notices": [ + "/* Copyright (C) 1996-2020 Free Software Foundation, Inc.\n This file is part of the GNU C Library.\n\n The GNU C Library is free software; you can redistribute it and/or\n modify it under the terms of the GNU Lesser General Public\n License as published by the Free Software Foundation; either\n version 2.1 of the License, or (at your option) any later version.\n\n In addition to the permissions in the GNU Lesser General Public\n License, the Free Software Foundation gives you unlimited\n permission to link the compiled version of this file with other\n programs, and to distribute those programs without any restriction\n coming from the use of this file. (The GNU Lesser General Public\n License restrictions do apply in other respects; for example, they\n cover modification of the file, and distribution when not linked\n into another program.)\n\n Note that people who make modified versions of this file are not\n obligated to grant this special exception for their modified\n versions; it is their choice whether to do so. The GNU Lesser\n General Public License gives permission to release a modified\n version without this exception; this exception also makes it\n possible to release a modified version which carries forward this\n exception.\n\n The GNU C Library is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public\n License along with the GNU C Library; if not, see\n . */" + ] + }, + { + "git_blob": "1e3120621caeb62648745a42f7a9a25d1e2731ab", + "license_text": "==============================================================================\nThe LLVM Project is under the Apache License v2.0 with LLVM Exceptions:\n==============================================================================\n\n Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n APPENDIX: How to apply the Apache License to your work.\n\n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n\n Copyright [yyyy] [name of copyright owner]\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n\n---- LLVM Exceptions to the Apache 2.0 License ----\n\nAs an exception, if, as a result of your compiling your source code, portions\nof this Software are embedded into an Object form of such source code, you\nmay redistribute such embedded portions in such Object form without complying\nwith the conditions of Sections 4(a), 4(b) and 4(d) of the License.\n\nIn addition, if you combine or link compiled forms of this Software with\nsoftware that is licensed under the GPLv2 (\"Combined Software\") and if a\ncourt of competent jurisdiction determines that the patent provision (Section\n3), the indemnity provision (Section 9) or other Section of the License\nconflicts with the conditions of the GPLv2, you may retroactively and\nprospectively choose to deem waived or otherwise exclude such Section(s) of\nthe License, but only in their entirety and only with respect to the Combined\nSoftware.\n\n==============================================================================\nSoftware from third parties included in the LLVM Project:\n==============================================================================\nThe LLVM Project contains third party software which is under different license\nterms. All such code will be identified clearly using at least one of two\nmechanisms:\n1) It will be in a separate directory tree with its own `LICENSE.txt` or\n `LICENSE` file at the top containing the specific license and restrictions\n which apply to that software, or\n2) It will contain specific license and restriction terms at the top of every\n file.\n\n==============================================================================\nLegacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy):\n==============================================================================\n\nThe libunwind library is dual licensed under both the University of Illinois\n\"BSD-Like\" license and the MIT license. As a user of this code you may choose\nto use it under either license. As a contributor, you agree to allow your code\nto be used under both.\n\nFull text of the relevant licenses is included below.\n\n==============================================================================\n\nUniversity of Illinois/NCSA\nOpen Source License\n\nCopyright (c) 2009-2019 by the contributors listed in CREDITS.TXT\n\nAll rights reserved.\n\nDeveloped by:\n\n LLVM Team\n\n University of Illinois at Urbana-Champaign\n\n http://llvm.org\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal with\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\n * Redistributions of source code must retain the above copyright notice,\n this list of conditions and the following disclaimers.\n\n * Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimers in the\n documentation and/or other materials provided with the distribution.\n\n * Neither the names of the LLVM Team, University of Illinois at\n Urbana-Champaign, nor the names of its contributors may be used to\n endorse or promote products derived from this Software without specific\n prior written permission.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nCONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE\nSOFTWARE.\n\n==============================================================================\n\nCopyright (c) 2009-2014 by the contributors listed in CREDITS.TXT\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n", + "path": "lib/libunwind/LICENSE.TXT", + "sha256": "b5efebcaca80879234098e52d1725e6d9eb8fb96a19fce625d39184b705f7b6d" + }, + { + "git_blob": "bb7fe4c83a3c17774f1466e8f8378d8dc0dd810f", + "path": "lib/libunwind/include/__libunwind_config.h", + "sha256": "5e963e752482bf8cefcabbb6b4f3f09ae3bff247f59b7a2f1d8fcabbe539c18b", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "b2dae8feed9a3b57d017fe72b4f8cf0a7a41ba50", + "path": "lib/libunwind/include/libunwind.h", + "sha256": "9f9a52c31dbb093e09ccef880652fdced398070b6062515a2fa118361cf8afb7", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Compatible with libunwind API documented at:\n// http://www.nongnu.org/libunwind/man/libunwind(3).html\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "4c48e33c3c177d9cdf7e4805fc4797628ff54ac4", + "path": "lib/libunwind/include/mach-o/compact_unwind_encoding.h", + "sha256": "06f58e9d0058583b6da91ca2328fa663f80d089496a4979754ee7608fe9bd877", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Darwin's alternative to DWARF based unwind encodings.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "b1775d3a3decc76e1a0916fead1aafbc6fa0fb51", + "path": "lib/libunwind/include/unwind.h", + "sha256": "e4a58637fc8ca1d29cd600c3c4416aafed50085edf276fa076214c8d81c263f0", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// C++ ABI Level 1 ABI documented at:\n// https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "6277a1457f8966012848302489915bf7298e10ec", + "path": "lib/libunwind/include/unwind_arm_ehabi.h", + "sha256": "80edc55ea33440f46e676e4ac805ecdc64a7222f2c9107f8ff6b1097eb8a51df", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// C++ ABI Level 1 ABI documented at:\n// https://github.com/ARM-software/abi-aa/blob/main/ehabi32/ehabi32.rst\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "d94a6183be2901e3167779691726b307970254a7", + "path": "lib/libunwind/include/unwind_itanium.h", + "sha256": "c8cc61d806e13a2e75e93f1c15afd432f93a99283d27d15f5a28a3ebee989cba", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// C++ ABI Level 1 ABI documented at:\n// https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "5551c7d4bef1c569decb20ba240c923581453457", + "path": "lib/libunwind/src/AddressSpace.hpp", + "sha256": "c12382512621f8c749d4ecfa05964c59905a340ba1ea75adecf944d69b383def", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Abstracts accessing local vs remote address spaces.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "a7a8a153d86a43fe1ae02a353faec2530a8bb1a9", + "path": "lib/libunwind/src/CompactUnwinder.hpp", + "sha256": "438d320fb6503e1c82160d96fe8c774e03d51a755226deb28a1b7d248bd4ef9a", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Does runtime stack unwinding using compact unwind encodings.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "bd9ece60ee5881ac64b0f853eb7076ff797db02e", + "path": "lib/libunwind/src/DwarfInstructions.hpp", + "sha256": "cb6a9be6832b948089b2dcdb2f008fcca0e723b2269c420d9a138a227bfa1b8c", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Processor specific interpretation of DWARF unwind info.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "0682942ce13799e87ee1bad80323f41d9d050d22", + "path": "lib/libunwind/src/DwarfParser.hpp", + "sha256": "b468ad4ab82af4f9e9c4aae7664529a49051e22b69ffad964794ae9a9370b87c", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Parses DWARF CFIs (FDEs and CIEs).\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "0662a1321e2c75e1e8f13f0f049d1b3748d4295f", + "path": "lib/libunwind/src/EHHeaderParser.hpp", + "sha256": "31c22a99d0a0eef3341db272812e343b08b0de00518b2372eb189d977d9dda38", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Parses ELF .eh_frame_hdr sections.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "296064d8e2e675994a39227e2912c893892b8612", + "path": "lib/libunwind/src/FrameHeaderCache.hpp", + "sha256": "ba9d7a8ae3c936fce48639f3f0964f67657cc8ffcccdb75416d3fa7c304845e9", + "source_notices": [ + "//===-FrameHeaderCache.hpp ------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n// Cache the elf program headers necessary to unwind the stack more efficiently\n// in the presence of many dsos.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "344d35641f07a8037f9cb2535106479b8a6d26f2", + "path": "lib/libunwind/src/RWMutex.hpp", + "sha256": "3d6f718c49944207310eafc2231767016a971c6be6612d31dcc673312f23e724", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Abstract interface to shared reader/writer log, hiding platform and\n// configuration differences.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "861e6b5f6f2c583344713e80a7d85e1f9682e2f4", + "path": "lib/libunwind/src/Registers.hpp", + "sha256": "1cb6f74ec9a42ef8a3ebe242e348e4a35b9758bb416d884e9c62e806dd2c3157", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Models register sets for supported processors.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "05475c6ac1e2fe60db522a0c138f5acb3f5b1945", + "path": "lib/libunwind/src/Unwind-EHABI.cpp", + "sha256": "352ab8ec8eaa93a790c261c418ffea18fc78d55ba805601df369a310dc086417", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Implements ARM zero-cost C++ exceptions\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "ff3b5fc6fea77fba0f4ebc4d74e72bac984935fa", + "path": "lib/libunwind/src/Unwind-EHABI.h", + "sha256": "c04fdebcd31e26de7615b82751373cc64ef83d02b24dbaaf0e112d0a559acc6b", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "b2bb119ed6d2997664383ef5f7e278d305d5403d", + "path": "lib/libunwind/src/Unwind-seh.cpp", + "sha256": "fcbd1821df294fe80c4870a03f663cb1156b809a598a53ebfaf68bb57110ae19", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n//\n// Implements SEH-based Itanium C++ exceptions.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "7e8faf098fe14b11625de7c5bbc6e58bdb3c46dd", + "path": "lib/libunwind/src/Unwind-sjlj.c", + "sha256": "708ea7f9377fea810c2df6196448763f9436aff28fb81463d79f09548c70f096", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Implements setjump-longjump based C++ exceptions\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "b18b32c5d17847afaeff405e6f63474f2b188de2", + "path": "lib/libunwind/src/Unwind-wasm.c", + "sha256": "5b7d0b8e2befed5899b32682e907f9cde35f244df1c9d61f82c9013e1c824d2c", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Implements Wasm exception handling proposal\n// (https://github.com/WebAssembly/exception-handling) based C++ exceptions\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "06e654197351df6449ca5a3da88794fadd4c2c38", + "path": "lib/libunwind/src/UnwindCursor.hpp", + "sha256": "61cf048bb46b1f023796b1b9a951233ee7a0fb1c03468254daeb1e268f883e53", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// C++ interface to lower levels of libunwind\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "32c872ffade1fd0c02c6e9d30a56fb48c2080193", + "path": "lib/libunwind/src/UnwindLevel1-gcc-ext.c", + "sha256": "3bed106de18fec9d1c52cb7bc3d5db89d3225252f3c0312597d159edbbd6e802", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Implements gcc extensions to the C++ ABI Exception Handling Level 1.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "7e785f4d31e716a3be3febb9d6f569cf41fef217", + "path": "lib/libunwind/src/UnwindLevel1.c", + "sha256": "829414f3c44b210ae26d14aac61ea59b6ba1a57bfc46c8500d7561dd60c42d4e", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Implements C++ ABI Exception Handling Level 1 as documented at:\n// https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html\n// using libunwind\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "9d34c7909ed3719b9a083275af8c3558e5255dc0", + "path": "lib/libunwind/src/UnwindRegistersRestore.S", + "sha256": "83a0e71b5a1ea8c90be705882c16b8fbc5b2e2c9866566988dd1094abcacd183", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "5bf6055fe4147f660d9f97715fe455488ea0e5d3", + "path": "lib/libunwind/src/UnwindRegistersSave.S", + "sha256": "5d4d94842641d34a0213947bc33c69c2283ca4bf54d70673c41ce77303bb68ad", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "66194ab4a16ba227b321ef8160845803fa1d0ce5", + "path": "lib/libunwind/src/Unwind_AIXExtras.cpp", + "sha256": "fec55a3209fcd9ad4eac0f9820d599ceef2750a155e2aa10f66aacdf6f0fb536", + "source_notices": [ + "//===--------------------- Unwind_AIXExtras.cpp -------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "f8e83e138eff50eb526eefa8ba83d06fe0b643a0", + "path": "lib/libunwind/src/assembly.h", + "sha256": "c3d765a0642dd4bc59e2f92ab16be2e9192432fcb834b8b313a69eb9165e699a", + "source_notices": [ + "/* ===-- assembly.h - libUnwind assembler support macros -------------------===\n *\n * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n * See https://llvm.org/LICENSE.txt for license information.\n * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n *\n * ===----------------------------------------------------------------------===\n *\n * This file defines macros for use in libUnwind assembler source.\n * This file is not part of the interface of this library.\n *\n * ===----------------------------------------------------------------------===\n */" + ] + }, + { + "git_blob": "47d7616a7322c3224ed4569735731ee8275606df", + "path": "lib/libunwind/src/cet_unwind.h", + "sha256": "52ae0493950aa103238c9d923f674ba062171ffed4c5f5a64609c64a06baeeff", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "deb5a4d4d73d467f72d4e7d183b5d25b0128f7cf", + "path": "lib/libunwind/src/config.h", + "sha256": "65d0561fb6af948fbbf32e9c9b087bbc7013c94faae9565d7edabc18336bce95", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Defines macros used within libunwind project.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "174277d5a795084bbd20e2a58a5244620deceb81", + "path": "lib/libunwind/src/dwarf2.h", + "sha256": "d57f3a7a4dff483b64a8503d6a0ac8e8c3a79c52da9cdc637b8d53d52a16a1f6", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n", + "/*\n These constants were taken from version 3 of the DWARF standard,\n which is Copyright (c) 2005 Free Standards Group, and\n Copyright (c) 1992, 1993 UNIX International, Inc.\n*/" + ] + }, + { + "git_blob": "1d9c7f4d17b85038ea2412ad47d8d48cf054fed6", + "path": "lib/libunwind/src/gcc_personality_v0.c", + "sha256": "f83c80299344ddf08ca6dc7f7032249dfac5c00ebac3b222f01d27556147294e", + "source_notices": [ + "//===-- gcc_personality_v0.c - Implement __gcc_personality_v0 -------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "cf39ec5f7dbdf9b6485cccb804f5104f3b3a83d1", + "path": "lib/libunwind/src/libunwind.cpp", + "sha256": "0be28214f509a9301f7745b20b8f5e0667a9bd4f42ecf946dd7ee5dcec40b0d1", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Implements unw_* functions from \n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "28db43a4f6eef20dd5967f420a8d8fea552cf8c5", + "path": "lib/libunwind/src/libunwind_ext.h", + "sha256": "ee76dbef4b8a910e6d9302e643ae4566ce5ed8f4cbe5e612804506a089b291e1", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Extensions to libunwind API.\n//\n//===----------------------------------------------------------------------===//\n" + ] + } + ], + "schema_version": 1, + "source_revision": "5ad91a646a753cc3eecd8751e61cf458dadd9ac4", + "zig_version": "0.14.0" +} \ No newline at end of file diff --git a/scripts/capture-zig-link.sh b/scripts/capture-zig-link.sh new file mode 100755 index 0000000..cbe1c64 --- /dev/null +++ b/scripts/capture-zig-link.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [[ " $* " == *"--print-map"* ]]; then + python3 -I -c 'import json, os, sys; f = open(os.environ["KTAV_LINK_COMMAND"], "x", encoding="utf-8"); json.dump(sys.argv[1:], f, indent=2); f.close()' "$@" + "${KTAV_REAL_ZIG:?}" "$@" | tee -a "${KTAV_LINK_MAP:?}" +else + exec "${KTAV_REAL_ZIG:?}" "$@" +fi diff --git a/scripts/check_gnu_cabi_evidence.py b/scripts/check_gnu_cabi_evidence.py new file mode 100644 index 0000000..de4a4ad --- /dev/null +++ b/scripts/check_gnu_cabi_evidence.py @@ -0,0 +1,77 @@ +"""Проверить actual GNU C ABI ELF, runtime imports и callable/data exports.""" + +import hashlib +import json +from pathlib import Path +import re +import struct +import subprocess +import sys + +FUNCTIONS = {'ktav_loads', 'ktav_loads_strict', 'ktav_dumps', 'ktav_dumps_force_strings', 'ktav_emit_canonical', 'ktav_format', 'ktav_canonical_from_source', 'ktav_free', 'ktav_version', 'ktav_abi_version'} +OS_LIBRARIES = {'libc.so.6', 'libm.so.6', 'libpthread.so.0', 'libdl.so.2', 'librt.so.1', 'ld-linux-x86-64.so.2', 'ld-linux-aarch64.so.1'} + + +def machine(data, target): + expected = {'x86_64-unknown-linux-gnu': 62, 'aarch64-unknown-linux-gnu': 183} + if target not in expected or len(data) < 64 or data[:6] != b'\x7fELF\x02\x01' or struct.unpack_from(' (2, 17, 0) for value in versions): + raise ValueError('GNU C ABI requires newer than glibc 2.17') + return ['.'.join(map(str, value)) for value in sorted(versions)] + + +def exports(text): + symbols = {} + for line in text.splitlines(): + fields = line.split() + if len(fields) >= 2: + symbols[fields[0]] = fields[1] + calls = {name for name in symbols if name.startswith('ktav_')} + if calls != FUNCTIONS or any(symbols[name].upper() != 'T' for name in calls): + raise ValueError('original callable GNU C ABI exports differ') + if symbols.get('KTAV_THIRD_PARTY_NOTICES') not in {'R', 'D'}: + raise ValueError('immutable C ABI resource export missing') + return sorted(calls) + + +def main(binary, evidence, target): + if binary.is_symlink() or not binary.is_file() or binary.stat().st_size > 128 * 1024 * 1024: + raise ValueError('unreviewed actual GNU binary input') + data = binary.read_bytes() + cpu = machine(data, target) + dynamic = subprocess.check_output(['readelf', '--dynamic', str(binary)], text=True) + versions = subprocess.check_output(['readelf', '--version-info', str(binary)], text=True) + symbols = subprocess.check_output(['nm', '-D', '--defined-only', '--format=posix', str(binary)], text=True) + (evidence / 'elf-dynamic.txt').write_text(dynamic, encoding='utf-8') + (evidence / 'elf-version-info.txt').write_text(versions, encoding='utf-8') + (evidence / 'elf-exports.txt').write_text(symbols, encoding='utf-8') + imports = dependencies(dynamic) + other_loader = 'ld-linux-aarch64.so.1' if target.startswith('x86_64') else 'ld-linux-x86-64.so.2' + if other_loader in imports: + raise ValueError('GNU C ABI imports the other CPU loader') + report = {'target': target, 'binary_sha256': hashlib.sha256(data).hexdigest(), 'machine': cpu, 'imports': imports, 'glibc_versions': glibc_versions(versions), 'callable_exports': exports(symbols), 'metadata_export': 'KTAV_THIRD_PARTY_NOTICES', 'scope': 'Actual GNU C ABI ELF/ABI/import metadata only; embedded source/runtime resource and archive members are checked separately.'} + (evidence / 'native-gnu-verification.json').write_text(json.dumps(report, sort_keys=True, indent=2) + '\n', encoding='utf-8') + print(json.dumps(report, sort_keys=True)) + + +if __name__ == '__main__': + if len(sys.argv) != 4: + raise SystemExit('usage: check_gnu_cabi_evidence.py BINARY EVIDENCE TARGET') + main(Path(sys.argv[1]), Path(sys.argv[2]), sys.argv[3]) diff --git a/scripts/zig_runtime_notices.py b/scripts/zig_runtime_notices.py new file mode 100644 index 0000000..715df78 --- /dev/null +++ b/scripts/zig_runtime_notices.py @@ -0,0 +1,178 @@ +"""Сохранить проверенные Zig runtime notices и проверить actual link inputs.""" + +import gzip +import hashlib +import json +import os +from pathlib import Path, PurePosixPath +import re +import subprocess +import sys + +REVISION = '5ad91a646a753cc3eecd8751e61cf458dadd9ac4' +CATALOG_SHA = 'baad05bad75045fe31853320a35d8c533068586c194ce5c81ab6adeda10fe435' +EXPECTED_MEMBERS = { + ('libunwind.a', 'UnwindLevel1.o'), + ('libunwind.a', 'UnwindLevel1-gcc-ext.o'), + ('libunwind.a', 'UnwindRegistersSave.o'), + ('libunwind.a', 'UnwindRegistersRestore.o'), + ('libunwind.a', 'libunwind.o'), + ('libc_nonshared.a', 'stat64-2.32.o'), + ('libc_nonshared.a', 'fstat64-2.32.o'), +} + + +def _read(path, limit=4 * 1024 * 1024): + with path.open('rb') as source: + data = source.read(limit + 1) + if len(data) > limit: + raise ValueError('runtime evidence file exceeds limit') + return data + + +def _catalogue(): + path = Path(__file__).resolve().parents[1] / 'ci/zig-runtime-catalog.json' + if path.is_symlink() or not path.is_file(): + raise ValueError('missing or symlinked Zig runtime catalogue') + raw = _read(path) + if hashlib.sha256(raw).hexdigest() != CATALOG_SHA: + raise ValueError('unreviewed Zig runtime catalogue') + catalog = json.loads(raw) + if len(catalog['files']) != 37: + raise ValueError('required Zig runtime source/legal roles differ') + return catalog, raw + + +def _sources(lib, catalog): + if catalog.get('source_revision') != REVISION or catalog.get('zig_version') != '0.14.0': + raise ValueError('unreviewed Zig runtime source revision') + lib = lib.resolve() + for item in catalog['files']: + relative = PurePosixPath(item['path']) + if relative.is_absolute() or '..' in relative.parts: + raise ValueError('invalid runtime source path') + if item['path'] == 'LICENSE': + source = lib.parent / 'LICENSE' + boundary = lib.parent + elif relative.parts[0] == 'lib': + source = lib.joinpath(*relative.parts[1:]) + boundary = lib + else: + raise ValueError('unexpected runtime source path') + if not source.resolve().is_relative_to(boundary): + raise ValueError('runtime source escapes Zig installation') + data = _read(source) + if hashlib.sha256(data).hexdigest() != item['sha256']: + raise ValueError(f"Zig runtime source changed: {item['path']}") + if 'license_text' in item and item['license_text'].encode('utf-8') != data: + raise ValueError('Zig full legal original differs') + if any(notice.encode('utf-8') not in data for notice in item.get('source_notices', [])): + raise ValueError('Zig file-level copyright/grant text differs') + return catalog['files'] + + +def _runtime(catalog): + return { + 'name': 'Zig vendored LLVM libunwind and glibc nonshared runtime', + 'zig_version': '0.14.0', + 'source_revision': REVISION, + 'coverage': 'Conservative source notices; actual archive members are checked after linking.', + 'catalog_sha256': CATALOG_SHA, + 'files': catalog['files'], + 'credits': catalog['credits'], + } + + +def _augment(bundle, catalog): + if bundle.get('schema_version') != 1 or 'non_cargo_runtimes' in bundle: + raise ValueError('unexpected native notice bundle state') + return {**bundle, 'non_cargo_runtimes': [_runtime(catalog)], 'coverage': bundle['coverage'] + ' Includes verified Zig runtime source notices; linked archive members require the post-build map gate.'} + + +def _plain_notice(catalog): + sections = ['Ktav C ABI Linux GNU Zig runtime notices.\nComplete original legal text and source-file notices follow unchanged.\n'] + for item in catalog['files']: + sections.append('\n===== ' + item['path'] + ' =====\n') + sections.append(item['license_text'] if 'license_text' in item else '\n'.join(item['source_notices'])) + sections.append('\n' + catalog['credits'] + '\n') + return '\n'.join(sections).encode('utf-8') + + +def _prepare(evidence): + version = subprocess.check_output(['zig', 'version'], text=True).strip() + if version != '0.14.0': + raise ValueError('unreviewed Zig version') + environment = json.loads(subprocess.check_output(['zig', 'env'])) + lib = Path(environment['lib_dir']) + catalog, catalog_bytes = _catalogue() + files = _sources(lib, catalog) + notice_path = evidence / 'NOTICE.json' + original = _read(notice_path, 64 * 1024 * 1024) + bundle = _augment(json.loads(original), catalog) + data = (json.dumps(bundle, ensure_ascii=False, sort_keys=True, indent=2) + '\n').encode('utf-8') + compressed = gzip.compress(data, mtime=0) + if len(data) > 64 * 1024 * 1024 or len(compressed) > 4 * 1024 * 1024: + raise ValueError('combined runtime notices exceed resource limit') + with (evidence / 'NOTICE.cargo-std.json').open('xb') as out: + out.write(original) + with (evidence / 'zig-runtime-catalog.json').open('xb') as out: + out.write(catalog_bytes) + notice_path.write_bytes(data) + (evidence / 'NOTICE.json.gz').write_bytes(compressed) + (evidence / 'NOTICE.zig-runtime.txt').write_bytes(_plain_notice(catalog)) + print(f'Included {len(files)} exact Zig runtime source records') + + +def _members(text): + matches = re.findall(r'([^\s()]+[.]a)\(([^()\n]+)\)', text) + members = {(PurePosixPath(archive).name, PurePosixPath(member).name) for archive, member in matches} + if members != EXPECTED_MEMBERS: + raise ValueError(f'unreviewed archive membership: {sorted(members ^ EXPECTED_MEMBERS)}') + objects = set(re.findall(r'[^\s()]+[.]o(?=:\()', text)) + if not objects or any(not path.endswith('.rcgu.o') for path in objects): + raise ValueError('unreviewed direct object input') + return sorted(members) + + +def _verify(evidence): + bundle = json.loads(_read(evidence / 'NOTICE.json', 64 * 1024 * 1024)) + catalog, raw = _catalogue() + before = json.loads(_read(evidence / 'NOTICE.cargo-std.json', 64 * 1024 * 1024)) + if bundle != _augment(before, catalog) or _read(evidence / 'zig-runtime-catalog.json') != raw: + raise ValueError('Zig runtime source/notice roles differ from reviewed originals') + if _read(evidence / 'NOTICE.zig-runtime.txt', 64 * 1024 * 1024) != _plain_notice(catalog): + raise ValueError('plain Zig runtime legal originals differ') + if subprocess.check_output(['zig', 'version'], text=True).strip() != '0.14.0': + raise ValueError('unreviewed post-build Zig version') + _sources(Path(json.loads(subprocess.check_output(['zig', 'env']))['lib_dir']), catalog) + mapping = _read(evidence / 'native-link.map', 16 * 1024 * 1024).decode('utf-8') + members = _members(mapping) + cache = Path(os.environ['ZIG_GLOBAL_CACHE_DIR']).resolve() + paths = sorted(set(re.findall(r'([^\s()]+[.]a)\([^()\n]+\)', mapping))) + fingerprints = [] + seen = set() + for name in paths: + path = Path(name) + if not path.resolve().is_relative_to(cache) or path.name in seen: + raise ValueError('unreviewed or duplicate Zig archive origin') + seen.add(path.name) + data = _read(path, 64 * 1024 * 1024) + fingerprints.append({'path': path.resolve().relative_to(cache).as_posix(), 'bytes': len(data), 'sha256': hashlib.sha256(data).hexdigest()}) + if seen != {'libunwind.a', 'libc_nonshared.a'}: + raise ValueError('selected Zig archive roles differ') + with (evidence / 'zig-runtime-members.json').open('x', encoding='utf-8') as out: + json.dump({'source_revision': REVISION, 'archive_members': members, 'archive_fingerprints': fingerprints}, out, sort_keys=True, indent=2) + print('Verified all seven static Zig runtime archive members') + + +def main(): + if len(sys.argv) != 3 or sys.argv[1] not in ('prepare', 'verify'): + raise SystemExit('usage: zig_runtime_notices.py prepare|verify EVIDENCE_DIRECTORY') + try: + (_prepare if sys.argv[1] == 'prepare' else _verify)(Path(sys.argv[2])) + except (OSError, ValueError, KeyError, TypeError, subprocess.CalledProcessError) as error: + raise SystemExit(str(error)) from error + + +if __name__ == '__main__': + main() From 873997c8962b16f3a933008d96c5c86d186105f0 Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sun, 1 Nov 2026 00:33:31 +0100 Subject: [PATCH 35/51] fix(ci): query cargo-zigbuild version at CLI root Both GNU targets stop before compilation because the zigbuild subcommand does not accept --version. The pinned v0.24.0 CLI source defines that flag on its root parser. Invoke cargo-zigbuild directly. Preserve every source, notice, linker and binary guard unchanged. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/gnu-cabi-notice-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gnu-cabi-notice-check.yml b/.github/workflows/gnu-cabi-notice-check.yml index aa22fd9..2a3deff 100644 --- a/.github/workflows/gnu-cabi-notice-check.yml +++ b/.github/workflows/gnu-cabi-notice-check.yml @@ -116,7 +116,7 @@ jobs: evidence="$RUNNER_TEMP/gnu-cabi-evidence" zig version > "$evidence/zig-version.txt" zig env > "$evidence/zig-env.json" - cargo zigbuild --version > "$evidence/cargo-zigbuild-version.txt" + cargo-zigbuild --version > "$evidence/cargo-zigbuild-version.txt" sha256sum "$(command -v cargo-zigbuild)" > "$evidence/cargo-zigbuild.sha256" sha256sum "$(command -v zig)" > "$evidence/zig.sha256" export ZIG_GLOBAL_CACHE_DIR="$RUNNER_TEMP/gnu-cabi-zig-cache" From 659b3c8acf3a45e7624e36a24d2285cf990ca8e6 Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sun, 1 Nov 2026 01:08:01 +0100 Subject: [PATCH 36/51] ci: capture original musl native resources and actual inputs Keep the existing musl compatibility/edit/spec09 checks untouched. Add a separate original 0.8.1 notice/input workflow with the reviewed lock and four source-preserving NAPI/CABI metadata files only. Preserve napi --cross-compile and the real musl compiler target. Collect actual linker commands/maps/archive/direct inputs, ELF CPU, musl-only imports and full matching embedded resources for both roles. Include a hash-pinned conservative libunwind/musl original-notice collection, excluding GNU glibc roles. This is input evidence, not a completed retained-source review or production distribution approval. Run Node NAPI and Bun FFI corpus consumers in digest-pinned Node 22 Alpine on matching x64/ARM64 hosts. Verify pinned Bun-musl tool assets without shipping them in the product/evidence payload. Do not claim Deno-musl support where the selected Deno release has no musl asset. No local builds/tests, parser/dependency/product-version changes, rollback of newer APIs, publication or historical asset repair. Co-Authored-By: Claude Opus 5.5 --- .../workflows/musl-native-notice-check.yml | 249 +++++++++++++++ ci/musl-runtime-catalog.json | 284 ++++++++++++++++++ ci/test_musl_native_evidence.py | 57 ++++ scripts/musl_native_evidence.py | 130 ++++++++ 4 files changed, 720 insertions(+) create mode 100644 .github/workflows/musl-native-notice-check.yml create mode 100644 ci/musl-runtime-catalog.json create mode 100644 ci/test_musl_native_evidence.py create mode 100644 scripts/musl_native_evidence.py diff --git a/.github/workflows/musl-native-notice-check.yml b/.github/workflows/musl-native-notice-check.yml new file mode 100644 index 0000000..52103ca --- /dev/null +++ b/.github/workflows/musl-native-notice-check.yml @@ -0,0 +1,249 @@ +name: Musl native notice and input evidence + +on: + pull_request: + +permissions: + contents: read + +env: + SOURCE_REF: 562deb3fde092d63a78f359be095e5079929d0d1 + LC_ALL: C + NODE_MUSL_IMAGE: node@sha256:fe4f6d74e20370acb04ad889077d14d0f64a9c8ea6a42bc60cddf1e844699914 + +jobs: + musl-notices: + name: Musl notice inputs / ${{ matrix.target }} + runs-on: ${{ matrix.runner }} + timeout-minutes: 40 + strategy: + fail-fast: false + matrix: + include: + - target: x86_64-unknown-linux-musl + runner: ubuntu-latest + platform: linux/amd64 + arch: x64 + addon: ktav.linux-x64-musl.node + bun: bun-linux-x64-musl + bun_sha: a5a8ccc5e74dcb883fe974f125a7bdb3b41e5195ed1b870e73f17effd3eb2b2d + - target: aarch64-unknown-linux-musl + runner: ubuntu-24.04-arm + platform: linux/arm64 + arch: arm64 + addon: ktav.linux-arm64-musl.node + bun: bun-linux-aarch64-musl + bun_sha: 57f01b02ac7113c61c935f28f38c2eab849e3c970dab21f8b640a87b1ef65009 + env: + MUSL_TARGET: ${{ matrix.target }} + MUSL_PLATFORM: ${{ matrix.platform }} + MUSL_ARCH: ${{ matrix.arch }} + MUSL_ADDON: ${{ matrix.addon }} + MUSL_BUN: ${{ matrix.bun }} + MUSL_BUN_SHA: ${{ matrix.bun_sha }} + steps: + - uses: actions/checkout@v4 + - name: Preserve reviewed notice tools and four-file native overlay + shell: python + run: | + import os + import shutil + from pathlib import Path + stage = Path(os.environ['RUNNER_TEMP']) / 'musl-notice-tools' + stage.mkdir() + names = ['Cargo.lock', 'ci/js-build-lock.json', 'crates/napi/build.rs', 'crates/cabi/build.rs', 'scripts/patch_napi_notice_source.py', 'scripts/patch_cabi_notice_source.py', 'ci/test_cabi_notice_overlay.py', 'ci/test_napi_notice_overlay.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json', 'scripts/capture-zig-link.sh', 'scripts/musl_native_evidence.py', 'ci/musl-runtime-catalog.json', 'ci/test_musl_native_evidence.py'] + for name in names: + destination = stage / name + destination.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(name, destination) + - uses: actions/checkout@v4 + with: + ref: ${{ env.SOURCE_REF }} + submodules: recursive + persist-credentials: false + - name: Graft native metadata without newer core APIs + shell: python + run: | + import hashlib + import json + import os + import shutil + import subprocess + import sys + from pathlib import Path + if subprocess.check_output(['git', 'rev-parse', 'HEAD'], text=True).strip() != os.environ['SOURCE_REF']: + raise SystemExit('unexpected musl source ref') + overlay = ['crates/napi/build.rs', 'crates/napi/src/lib.rs', 'crates/cabi/build.rs', 'crates/cabi/src/lib.rs'] + baseline = {name: hashlib.sha256(Path(name).read_bytes()).hexdigest() if Path(name).is_file() else None for name in overlay} + stage = Path(os.environ['RUNNER_TEMP']) / 'musl-notice-tools' + for path in stage.rglob('*'): + if path.is_file(): + destination = Path(path.relative_to(stage)) + destination.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(path, destination) + subprocess.run([sys.executable, '-I', 'scripts/patch_napi_notice_source.py', 'crates/napi/src/lib.rs'], check=True) + subprocess.run([sys.executable, '-I', 'scripts/patch_cabi_notice_source.py', 'crates/cabi/src/lib.rs'], check=True) + protected = ['Cargo.toml', 'crates', 'tests', 'root-docs', 'package.json', 'package-lock.json'] + changed = set(subprocess.check_output(['git', 'diff', '--name-only', '--', *protected], text=True).splitlines()) + changed.update(subprocess.check_output(['git', 'ls-files', '--others', '--exclude-standard', '--', *protected], text=True).splitlines()) + if changed != set(overlay): + raise SystemExit('musl source changed beyond four native notice files') + record = {'source_ref': os.environ['SOURCE_REF'], 'tooling_ref': os.environ['GITHUB_SHA'], 'target': os.environ['MUSL_TARGET'], 'notice_overlay': {name: {'baseline_sha256': baseline[name], 'compiled_sha256': hashlib.sha256(Path(name).read_bytes()).hexdigest()} for name in overlay}, 'scope': 'Original 0.8.1 source with NAPI/CABI notices; conservative runtime collection only, actual retained input review remains required.'} + (Path(os.environ['RUNNER_TEMP']) / 'musl-notice-source.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - uses: actions/setup-node@v4 + with: + node-version: '22' + - uses: dtolnay/rust-toolchain@1.99.1 + with: + targets: ${{ matrix.target }} + components: rust-docs + - uses: mlugg/setup-zig@v2 + with: + version: 0.14.0 + - uses: taiki-e/install-action@v2 + with: + tool: cargo-zigbuild@0.24.0 + - uses: taiki-e/install-action@v2 + with: + tool: cargo-about@0.9.3 + - name: Verify source preservation and musl ABI regression guards + shell: bash + run: | + set -euo pipefail + for test in test_cabi_notice_overlay.py test_napi_notice_overlay.py test_musl_native_evidence.py; do + python3 -I -m unittest discover -s ci -p "$test" -v + done + - name: Prepare reviewed source-bound candidate notices and npm tools + shell: python + run: | + import os + import shutil + import subprocess + import sys + from pathlib import Path + evidence = Path(os.environ['RUNNER_TEMP']) / 'musl-native-evidence' + subprocess.run([sys.executable, 'scripts/prepare_js_notices.py', str(evidence)], check=True) + subprocess.run([sys.executable, '-I', 'scripts/musl_native_evidence.py', 'prepare', str(evidence)], check=True) + shutil.copyfile(Path(os.environ['RUNNER_TEMP']) / 'musl-notice-source.json', evidence / 'source-provenance.json') + for name in ['LICENSE-MIT', 'LICENSE-APACHE']: + shutil.copyfile(name, evidence / name) + shutil.copyfile('package-lock.json', evidence / 'npm-lock-source.json') + subprocess.run(['npm', 'install', '--ignore-scripts', '--no-audit', '--no-fund'], check=True) + subprocess.run(['git', 'diff', '--exit-code', '--', 'package.json'], check=True) + shutil.copyfile('package-lock.json', evidence / 'npm-lock-resolved.json') + subprocess.run(['node', 'scripts/check-npm-licenses.mjs'], check=True) + subprocess.run(['node', '-e', 'if(require("@napi-rs/cli/package.json").version!=="3.6.2")throw new Error("NAPI CLI version requires review")'], check=True) + subprocess.run(['npm', 'run', 'build:ts'], check=True) + - name: Build both musl roles and collect actual input evidence + shell: python + run: | + import os + import shutil + import subprocess + import sys + from pathlib import Path + evidence = Path(os.environ['RUNNER_TEMP']) / 'musl-native-evidence' + if os.environ.get('RUSTFLAGS') or os.environ.get('CARGO_ENCODED_RUSTFLAGS'): + raise SystemExit('preexisting musl flags require review') + target = os.environ['MUSL_TARGET'] + sysroot = subprocess.check_output(['rustc', '--print', 'sysroot'], text=True).strip() + wrapper = Path('scripts/capture-zig-link.sh').resolve() + wrapper.chmod(0o755) + commands = [('napi', ['npx', '--no-install', 'napi', 'build', '--release', '-p', 'ktav-napi', '--target', target, '--platform', '--js', 'false', '--output-dir', '.', '--cross-compile']), ('cabi', ['cargo', 'zigbuild', '--locked', '--release', '-p', 'ktav-cabi', '--target', target])] + for role, command in commands: + directory = evidence / role + directory.mkdir() + cache = Path(os.environ['RUNNER_TEMP']) / ('musl-zig-cache-' + role) + cache.mkdir() + environment = {**os.environ, 'RUSTFLAGS': '-C target-feature=-crt-static -C link-arg=-Wl,--print-map', 'ZIG_GLOBAL_CACHE_DIR': str(cache), 'CARGO_ZIGBUILD_ZIG_COMMAND': str(wrapper), 'KTAV_REAL_ZIG': shutil.which('zig'), 'KTAV_LINK_MAP': str(directory / 'native-link.map'), 'KTAV_LINK_COMMAND': str(directory / 'native-link-command.json'), 'KTAV_NAPI_NOTICES_GZIP': str(evidence / 'NOTICE.json.gz'), 'KTAV_CABI_NOTICES_GZIP': str(evidence / 'NOTICE.json.gz'), 'RUSTC_LOG': 'rustc_codegen_ssa::back::link=info'} + environment.pop('CARGO_ZIGBUILD_ZIG_COMMAND_ARGS', None) + result = subprocess.run(command, env=environment, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + (directory / 'build-stdout.txt').write_bytes(result.stdout) + (directory / 'build-stderr.txt').write_bytes(result.stderr) + sys.stdout.buffer.write(result.stdout) + sys.stderr.buffer.write(result.stderr) + if result.returncode: + raise SystemExit(result.returncode) + original = Path('target') / target / 'release' / ('libktav_' + role + '.so') + binary = Path(os.environ['MUSL_ADDON']) if role == 'napi' else original + if binary.read_bytes() != original.read_bytes(): + raise SystemExit('musl staged/original bytes differ') + subprocess.run([sys.executable, '-I', 'scripts/musl_native_evidence.py', 'capture', str(binary), str(directory), target, role, str(cache), sysroot], check=True) + report = subprocess.check_output([sys.executable, '-I', 'scripts/check_embedded_notices.py', str(directory / binary.name), str(evidence / 'NOTICE.json')]) + (directory / 'embedded-verification.json').write_bytes(report) + if Path('Cargo.lock').read_bytes() != (evidence / 'Cargo.lock').read_bytes(): + raise SystemExit('musl build changed reviewed lock') + - name: Run actual matching-CPU Node and Bun consumers in pinned Alpine + shell: python + run: | + import hashlib + import json + import os + import platform + import shutil + import stat + import subprocess + import urllib.request + import zipfile + from pathlib import Path, PurePosixPath + expected_host = 'x86_64' if os.environ['MUSL_ARCH'] == 'x64' else 'aarch64' + if platform.machine() != expected_host: + raise SystemExit('native matching-CPU musl runner required; no emulation claim') + temporary = Path(os.environ['RUNNER_TEMP']) + evidence = temporary / 'musl-native-evidence' + tools = temporary / 'musl-consumer-tools' + tools.mkdir() + archive = tools / 'bun.zip' + url = 'https://github.com/oven-sh/bun/releases/download/bun-v1.4.4/' + os.environ['MUSL_BUN'] + '.zip' + checksum = hashlib.sha256() + total = 0 + with urllib.request.urlopen(url, timeout=120) as response, archive.open('xb') as output: + while chunk := response.read(1024 * 1024): + total += len(chunk) + if total > 128 * 1024 * 1024: + raise SystemExit('musl Bun tool archive exceeds bound') + checksum.update(chunk) + output.write(chunk) + if checksum.hexdigest() != os.environ['MUSL_BUN_SHA']: + raise SystemExit('musl Bun tool bytes differ') + stage = temporary / 'musl-consumer-stage' + for folder in ['tools', 'dist/native', 'cabi/release', 'spec']: + (stage / folder).mkdir(parents=True, exist_ok=True) + with zipfile.ZipFile(archive) as source: + member = source.getinfo(os.environ['MUSL_BUN'] + '/bun') + if not member.file_size <= 256 * 1024 * 1024 or member.is_dir() or stat.S_IFMT(member.external_attr >> 16) == stat.S_IFLNK: + raise SystemExit('unexpected musl Bun executable member') + with source.open(member) as input_file, (stage / 'tools/bun').open('xb') as output: + shutil.copyfileobj(input_file, output, 1024 * 1024) + (stage / 'tools/bun').chmod(0o755) + shutil.copyfile(evidence / 'napi' / os.environ['MUSL_ADDON'], stage / 'dist/native' / os.environ['MUSL_ADDON']) + shutil.copyfile(evidence / 'cabi/libktav_cabi.so', stage / 'cabi/release/libktav_cabi.so') + shutil.copytree('dist/ts', stage / 'dist/ts') + shutil.copytree('tests', stage / 'tests') + shutil.copytree('spec/versions', stage / 'spec/versions') + shutil.copyfile('package.json', stage / 'package.json') + image = os.environ['NODE_MUSL_IMAGE'] + docker_platform = os.environ['MUSL_PLATFORM'] + subprocess.run(['docker', 'pull', '--platform', docker_platform, image], check=True) + (evidence / 'consumer-image.json').write_bytes(subprocess.check_output(['docker', 'image', 'inspect', image])) + node_script = 'import assert from "node:assert/strict";import {createRequire} from "node:module";import {realpathSync} from "node:fs";assert.equal(process.arch,process.env.EXPECTED_ARCH);await import("./dist/ts/node.js");const require=createRequire(import.meta.url);assert.deepEqual(Object.keys(require.cache).filter(p=>p.endsWith(".node")),[realpathSync("dist/native/"+process.env.ADDON)]);await import("./tests/node/run-node-napi.mjs");' + commands = [('node', ['node', '--input-type=module', '-e', node_script]), ('bun', ['/work/tools/bun', 'run', 'tests/bun/run-bun-ffi.mjs'])] + for role, command in commands: + result = subprocess.run(['docker', 'run', '--rm', '--platform', docker_platform, '--network', 'none', '--mount', 'type=bind,source=' + str(stage) + ',target=/work,readonly', '--workdir', '/work', '--env', 'EXPECTED_ARCH=' + os.environ['MUSL_ARCH'], '--env', 'ADDON=' + os.environ['MUSL_ADDON'], '--env', 'CARGO_TARGET_DIR=/work/cabi', image, *command], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + (evidence / (role + '-consumer-stdout.txt')).write_bytes(result.stdout) + (evidence / (role + '-consumer-stderr.txt')).write_bytes(result.stderr) + if result.returncode or b'passed' not in result.stdout or b'skipping' in result.stdout.lower(): + sys_stdout = result.stdout.decode('utf-8', errors='replace') + sys_stderr = result.stderr.decode('utf-8', errors='replace') + raise SystemExit(role + ' actual musl corpus failed:\n' + sys_stdout + '\n' + sys_stderr) + record = {'target': os.environ['MUSL_TARGET'], 'native_runner_arch': platform.machine(), 'node_napi_corpus': True, 'bun_cabi_corpus': True, 'emulated': False, 'napi_sha256': hashlib.sha256((stage / 'dist/native' / os.environ['MUSL_ADDON']).read_bytes()).hexdigest(), 'cabi_sha256': hashlib.sha256((stage / 'cabi/release/libktav_cabi.so').read_bytes()).hexdigest(), 'bun_archive_sha256': checksum.hexdigest(), 'node_image': image, 'scope': 'Actual matching-CPU Alpine Node/Bun corpus execution. No Deno-musl or completed retained-runtime licensing claim.'} + (evidence / 'consumer-verification.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') + - uses: actions/upload-artifact@v4 + if: always() + with: + name: musl-native-evidence-${{ matrix.target }} + path: ${{ runner.temp }}/musl-native-evidence/ + if-no-files-found: warn diff --git a/ci/musl-runtime-catalog.json b/ci/musl-runtime-catalog.json new file mode 100644 index 0000000..c40f940 --- /dev/null +++ b/ci/musl-runtime-catalog.json @@ -0,0 +1,284 @@ +{ + "coverage": "Conservative Zig libunwind and musl original notice collection for candidate input review. No GNU glibc roles. Actual retained musl inputs require a separate final-binary/source review before production delivery.", + "credits": "libunwind LICENSE.TXT refers to CREDITS.TXT, which is absent from this pinned Zig subtree.", + "files": [ + { + "git_blob": "9ce01373c89082fd81e8ea0793aab0978140526b", + "license_text": "The MIT License (Expat)\n\nCopyright (c) Zig contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n", + "path": "LICENSE", + "sha256": "5c537d6853e005298a285d508cff9ac7192cea23576c840d485b2b586a7ff177" + }, + { + "git_blob": "c1628e9ac84f927fe791124ec172fb61c760bb9b", + "license_text": "musl as a whole is licensed under the following standard MIT license:\n\n----------------------------------------------------------------------\nCopyright © 2005-2020 Rich Felker, et al.\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n----------------------------------------------------------------------\n\nAuthors/contributors include:\n\nA. Wilcox\nAda Worcester\nAlex Dowad\nAlex Suykov\nAlexander Monakov\nAndre McCurdy\nAndrew Kelley\nAnthony G. Basile\nAric Belsito\nArvid Picciani\nBartosz Brachaczek\nBenjamin Peterson\nBobby Bingham\nBoris Brezillon\nBrent Cook\nChris Spiegel\nClément Vasseur\nDaniel Micay\nDaniel Sabogal\nDaurnimator\nDavid Carlier\nDavid Edelsohn\nDenys Vlasenko\nDmitry Ivanov\nDmitry V. Levin\nDrew DeVault\nEmil Renner Berthing\nFangrui Song\nFelix Fietkau\nFelix Janda\nGianluca Anzolin\nHauke Mehrtens\nHe X\nHiltjo Posthuma\nIsaac Dunham\nJaydeep Patil\nJens Gustedt\nJeremy Huntwork\nJo-Philipp Wich\nJoakim Sindholt\nJohn Spencer\nJulien Ramseier\nJustin Cormack\nKaarle Ritvanen\nKhem Raj\nKylie McClain\nLeah Neukirchen\nLuca Barbato\nLuka Perkov\nM Farkas-Dyck (Strake)\nMahesh Bodapati\nMarkus Wichmann\nMasanori Ogino\nMichael Clark\nMichael Forney\nMikhail Kremnyov\nNatanael Copa\nNicholas J. Kain\norc\nPascal Cuoq\nPatrick Oppenlander\nPetr Hosek\nPetr Skocik\nPierre Carrier\nReini Urban\nRich Felker\nRichard Pennington\nRyan Fairfax\nSamuel Holland\nSegev Finer\nShiz\nsin\nSolar Designer\nStefan Kristiansson\nStefan O'Rear\nSzabolcs Nagy\nTimo Teräs\nTrutz Behn\nValentin Ochs\nWill Dietz\nWilliam Haddon\nWilliam Pitcock\n\nPortions of this software are derived from third-party works licensed\nunder terms compatible with the above MIT license:\n\nThe TRE regular expression implementation (src/regex/reg* and\nsrc/regex/tre*) is Copyright © 2001-2008 Ville Laurikari and licensed\nunder a 2-clause BSD license (license text in the source files). The\nincluded version has been heavily modified by Rich Felker in 2012, in\nthe interests of size, simplicity, and namespace cleanliness.\n\nMuch of the math library code (src/math/* and src/complex/*) is\nCopyright © 1993,2004 Sun Microsystems or\nCopyright © 2003-2011 David Schultz or\nCopyright © 2003-2009 Steven G. Kargl or\nCopyright © 2003-2009 Bruce D. Evans or\nCopyright © 2008 Stephen L. Moshier or\nCopyright © 2017-2018 Arm Limited\nand labelled as such in comments in the individual source files. All\nhave been licensed under extremely permissive terms.\n\nThe ARM memcpy code (src/string/arm/memcpy.S) is Copyright © 2008\nThe Android Open Source Project and is licensed under a two-clause BSD\nlicense. It was taken from Bionic libc, used on Android.\n\nThe AArch64 memcpy and memset code (src/string/aarch64/*) are\nCopyright © 1999-2019, Arm Limited.\n\nThe implementation of DES for crypt (src/crypt/crypt_des.c) is\nCopyright © 1994 David Burren. It is licensed under a BSD license.\n\nThe implementation of blowfish crypt (src/crypt/crypt_blowfish.c) was\noriginally written by Solar Designer and placed into the public\ndomain. The code also comes with a fallback permissive license for use\nin jurisdictions that may not recognize the public domain.\n\nThe smoothsort implementation (src/stdlib/qsort.c) is Copyright © 2011\nValentin Ochs and is licensed under an MIT-style license.\n\nThe x86_64 port was written by Nicholas J. Kain and is licensed under\nthe standard MIT terms.\n\nThe mips and microblaze ports were originally written by Richard\nPennington for use in the ellcc project. The original code was adapted\nby Rich Felker for build system and code conventions during upstream\nintegration. It is licensed under the standard MIT terms.\n\nThe mips64 port was contributed by Imagination Technologies and is\nlicensed under the standard MIT terms.\n\nThe powerpc port was also originally written by Richard Pennington,\nand later supplemented and integrated by John Spencer. It is licensed\nunder the standard MIT terms.\n\nAll other files which have no copyright comments are original works\nproduced specifically for use as part of this library, written either\nby Rich Felker, the main author of the library, or by one or more\ncontibutors listed above. Details on authorship of individual files\ncan be found in the git version control history of the project. The\nomission of copyright and license comments in each file is in the\ninterest of source tree size.\n\nIn addition, permission is hereby granted for all public header files\n(include/* and arch/*/bits/*) and crt files intended to be linked into\napplications (crt/*, ldso/dlstart.c, and arch/*/crt_arch.h) to omit\nthe copyright notice and permission notice otherwise required by the\nlicense, and to use these files without any requirement of\nattribution. These files include substantial contributions from:\n\nBobby Bingham\nJohn Spencer\nNicholas J. Kain\nRich Felker\nRichard Pennington\nStefan Kristiansson\nSzabolcs Nagy\n\nall of whom have explicitly granted such permission.\n\nThis file previously contained text expressing a belief that most of\nthe files covered by the above exception were sufficiently trivial not\nto be subject to copyright, resulting in confusion over whether it\nnegated the permissions granted in the license. In the spirit of\npermissive licensing, and of not having licensing issues being an\nobstacle to adoption, that text has been removed.\n", + "path": "lib/libc/musl/COPYRIGHT", + "sha256": "f9bc4423732350eb0b3f7ed7e91d530298476f8fec0c6c427a1c04ade22655af" + }, + { + "git_blob": "1e3120621caeb62648745a42f7a9a25d1e2731ab", + "license_text": "==============================================================================\nThe LLVM Project is under the Apache License v2.0 with LLVM Exceptions:\n==============================================================================\n\n Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n APPENDIX: How to apply the Apache License to your work.\n\n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n\n Copyright [yyyy] [name of copyright owner]\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n\n---- LLVM Exceptions to the Apache 2.0 License ----\n\nAs an exception, if, as a result of your compiling your source code, portions\nof this Software are embedded into an Object form of such source code, you\nmay redistribute such embedded portions in such Object form without complying\nwith the conditions of Sections 4(a), 4(b) and 4(d) of the License.\n\nIn addition, if you combine or link compiled forms of this Software with\nsoftware that is licensed under the GPLv2 (\"Combined Software\") and if a\ncourt of competent jurisdiction determines that the patent provision (Section\n3), the indemnity provision (Section 9) or other Section of the License\nconflicts with the conditions of the GPLv2, you may retroactively and\nprospectively choose to deem waived or otherwise exclude such Section(s) of\nthe License, but only in their entirety and only with respect to the Combined\nSoftware.\n\n==============================================================================\nSoftware from third parties included in the LLVM Project:\n==============================================================================\nThe LLVM Project contains third party software which is under different license\nterms. All such code will be identified clearly using at least one of two\nmechanisms:\n1) It will be in a separate directory tree with its own `LICENSE.txt` or\n `LICENSE` file at the top containing the specific license and restrictions\n which apply to that software, or\n2) It will contain specific license and restriction terms at the top of every\n file.\n\n==============================================================================\nLegacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy):\n==============================================================================\n\nThe libunwind library is dual licensed under both the University of Illinois\n\"BSD-Like\" license and the MIT license. As a user of this code you may choose\nto use it under either license. As a contributor, you agree to allow your code\nto be used under both.\n\nFull text of the relevant licenses is included below.\n\n==============================================================================\n\nUniversity of Illinois/NCSA\nOpen Source License\n\nCopyright (c) 2009-2019 by the contributors listed in CREDITS.TXT\n\nAll rights reserved.\n\nDeveloped by:\n\n LLVM Team\n\n University of Illinois at Urbana-Champaign\n\n http://llvm.org\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal with\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\n * Redistributions of source code must retain the above copyright notice,\n this list of conditions and the following disclaimers.\n\n * Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimers in the\n documentation and/or other materials provided with the distribution.\n\n * Neither the names of the LLVM Team, University of Illinois at\n Urbana-Champaign, nor the names of its contributors may be used to\n endorse or promote products derived from this Software without specific\n prior written permission.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nCONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE\nSOFTWARE.\n\n==============================================================================\n\nCopyright (c) 2009-2014 by the contributors listed in CREDITS.TXT\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n", + "path": "lib/libunwind/LICENSE.TXT", + "sha256": "b5efebcaca80879234098e52d1725e6d9eb8fb96a19fce625d39184b705f7b6d" + }, + { + "git_blob": "bb7fe4c83a3c17774f1466e8f8378d8dc0dd810f", + "path": "lib/libunwind/include/__libunwind_config.h", + "sha256": "5e963e752482bf8cefcabbb6b4f3f09ae3bff247f59b7a2f1d8fcabbe539c18b", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "b2dae8feed9a3b57d017fe72b4f8cf0a7a41ba50", + "path": "lib/libunwind/include/libunwind.h", + "sha256": "9f9a52c31dbb093e09ccef880652fdced398070b6062515a2fa118361cf8afb7", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Compatible with libunwind API documented at:\n// http://www.nongnu.org/libunwind/man/libunwind(3).html\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "4c48e33c3c177d9cdf7e4805fc4797628ff54ac4", + "path": "lib/libunwind/include/mach-o/compact_unwind_encoding.h", + "sha256": "06f58e9d0058583b6da91ca2328fa663f80d089496a4979754ee7608fe9bd877", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Darwin's alternative to DWARF based unwind encodings.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "b1775d3a3decc76e1a0916fead1aafbc6fa0fb51", + "path": "lib/libunwind/include/unwind.h", + "sha256": "e4a58637fc8ca1d29cd600c3c4416aafed50085edf276fa076214c8d81c263f0", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// C++ ABI Level 1 ABI documented at:\n// https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "6277a1457f8966012848302489915bf7298e10ec", + "path": "lib/libunwind/include/unwind_arm_ehabi.h", + "sha256": "80edc55ea33440f46e676e4ac805ecdc64a7222f2c9107f8ff6b1097eb8a51df", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// C++ ABI Level 1 ABI documented at:\n// https://github.com/ARM-software/abi-aa/blob/main/ehabi32/ehabi32.rst\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "d94a6183be2901e3167779691726b307970254a7", + "path": "lib/libunwind/include/unwind_itanium.h", + "sha256": "c8cc61d806e13a2e75e93f1c15afd432f93a99283d27d15f5a28a3ebee989cba", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// C++ ABI Level 1 ABI documented at:\n// https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "5551c7d4bef1c569decb20ba240c923581453457", + "path": "lib/libunwind/src/AddressSpace.hpp", + "sha256": "c12382512621f8c749d4ecfa05964c59905a340ba1ea75adecf944d69b383def", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Abstracts accessing local vs remote address spaces.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "a7a8a153d86a43fe1ae02a353faec2530a8bb1a9", + "path": "lib/libunwind/src/CompactUnwinder.hpp", + "sha256": "438d320fb6503e1c82160d96fe8c774e03d51a755226deb28a1b7d248bd4ef9a", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Does runtime stack unwinding using compact unwind encodings.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "bd9ece60ee5881ac64b0f853eb7076ff797db02e", + "path": "lib/libunwind/src/DwarfInstructions.hpp", + "sha256": "cb6a9be6832b948089b2dcdb2f008fcca0e723b2269c420d9a138a227bfa1b8c", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Processor specific interpretation of DWARF unwind info.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "0682942ce13799e87ee1bad80323f41d9d050d22", + "path": "lib/libunwind/src/DwarfParser.hpp", + "sha256": "b468ad4ab82af4f9e9c4aae7664529a49051e22b69ffad964794ae9a9370b87c", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Parses DWARF CFIs (FDEs and CIEs).\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "0662a1321e2c75e1e8f13f0f049d1b3748d4295f", + "path": "lib/libunwind/src/EHHeaderParser.hpp", + "sha256": "31c22a99d0a0eef3341db272812e343b08b0de00518b2372eb189d977d9dda38", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Parses ELF .eh_frame_hdr sections.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "296064d8e2e675994a39227e2912c893892b8612", + "path": "lib/libunwind/src/FrameHeaderCache.hpp", + "sha256": "ba9d7a8ae3c936fce48639f3f0964f67657cc8ffcccdb75416d3fa7c304845e9", + "source_notices": [ + "//===-FrameHeaderCache.hpp ------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n// Cache the elf program headers necessary to unwind the stack more efficiently\n// in the presence of many dsos.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "344d35641f07a8037f9cb2535106479b8a6d26f2", + "path": "lib/libunwind/src/RWMutex.hpp", + "sha256": "3d6f718c49944207310eafc2231767016a971c6be6612d31dcc673312f23e724", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Abstract interface to shared reader/writer log, hiding platform and\n// configuration differences.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "861e6b5f6f2c583344713e80a7d85e1f9682e2f4", + "path": "lib/libunwind/src/Registers.hpp", + "sha256": "1cb6f74ec9a42ef8a3ebe242e348e4a35b9758bb416d884e9c62e806dd2c3157", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Models register sets for supported processors.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "05475c6ac1e2fe60db522a0c138f5acb3f5b1945", + "path": "lib/libunwind/src/Unwind-EHABI.cpp", + "sha256": "352ab8ec8eaa93a790c261c418ffea18fc78d55ba805601df369a310dc086417", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Implements ARM zero-cost C++ exceptions\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "ff3b5fc6fea77fba0f4ebc4d74e72bac984935fa", + "path": "lib/libunwind/src/Unwind-EHABI.h", + "sha256": "c04fdebcd31e26de7615b82751373cc64ef83d02b24dbaaf0e112d0a559acc6b", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "b2bb119ed6d2997664383ef5f7e278d305d5403d", + "path": "lib/libunwind/src/Unwind-seh.cpp", + "sha256": "fcbd1821df294fe80c4870a03f663cb1156b809a598a53ebfaf68bb57110ae19", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n//\n// Implements SEH-based Itanium C++ exceptions.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "7e8faf098fe14b11625de7c5bbc6e58bdb3c46dd", + "path": "lib/libunwind/src/Unwind-sjlj.c", + "sha256": "708ea7f9377fea810c2df6196448763f9436aff28fb81463d79f09548c70f096", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Implements setjump-longjump based C++ exceptions\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "b18b32c5d17847afaeff405e6f63474f2b188de2", + "path": "lib/libunwind/src/Unwind-wasm.c", + "sha256": "5b7d0b8e2befed5899b32682e907f9cde35f244df1c9d61f82c9013e1c824d2c", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Implements Wasm exception handling proposal\n// (https://github.com/WebAssembly/exception-handling) based C++ exceptions\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "06e654197351df6449ca5a3da88794fadd4c2c38", + "path": "lib/libunwind/src/UnwindCursor.hpp", + "sha256": "61cf048bb46b1f023796b1b9a951233ee7a0fb1c03468254daeb1e268f883e53", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// C++ interface to lower levels of libunwind\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "32c872ffade1fd0c02c6e9d30a56fb48c2080193", + "path": "lib/libunwind/src/UnwindLevel1-gcc-ext.c", + "sha256": "3bed106de18fec9d1c52cb7bc3d5db89d3225252f3c0312597d159edbbd6e802", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Implements gcc extensions to the C++ ABI Exception Handling Level 1.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "7e785f4d31e716a3be3febb9d6f569cf41fef217", + "path": "lib/libunwind/src/UnwindLevel1.c", + "sha256": "829414f3c44b210ae26d14aac61ea59b6ba1a57bfc46c8500d7561dd60c42d4e", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Implements C++ ABI Exception Handling Level 1 as documented at:\n// https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html\n// using libunwind\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "9d34c7909ed3719b9a083275af8c3558e5255dc0", + "path": "lib/libunwind/src/UnwindRegistersRestore.S", + "sha256": "83a0e71b5a1ea8c90be705882c16b8fbc5b2e2c9866566988dd1094abcacd183", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "5bf6055fe4147f660d9f97715fe455488ea0e5d3", + "path": "lib/libunwind/src/UnwindRegistersSave.S", + "sha256": "5d4d94842641d34a0213947bc33c69c2283ca4bf54d70673c41ce77303bb68ad", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "66194ab4a16ba227b321ef8160845803fa1d0ce5", + "path": "lib/libunwind/src/Unwind_AIXExtras.cpp", + "sha256": "fec55a3209fcd9ad4eac0f9820d599ceef2750a155e2aa10f66aacdf6f0fb536", + "source_notices": [ + "//===--------------------- Unwind_AIXExtras.cpp -------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "f8e83e138eff50eb526eefa8ba83d06fe0b643a0", + "path": "lib/libunwind/src/assembly.h", + "sha256": "c3d765a0642dd4bc59e2f92ab16be2e9192432fcb834b8b313a69eb9165e699a", + "source_notices": [ + "/* ===-- assembly.h - libUnwind assembler support macros -------------------===\n *\n * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n * See https://llvm.org/LICENSE.txt for license information.\n * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n *\n * ===----------------------------------------------------------------------===\n *\n * This file defines macros for use in libUnwind assembler source.\n * This file is not part of the interface of this library.\n *\n * ===----------------------------------------------------------------------===\n */" + ] + }, + { + "git_blob": "47d7616a7322c3224ed4569735731ee8275606df", + "path": "lib/libunwind/src/cet_unwind.h", + "sha256": "52ae0493950aa103238c9d923f674ba062171ffed4c5f5a64609c64a06baeeff", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "deb5a4d4d73d467f72d4e7d183b5d25b0128f7cf", + "path": "lib/libunwind/src/config.h", + "sha256": "65d0561fb6af948fbbf32e9c9b087bbc7013c94faae9565d7edabc18336bce95", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Defines macros used within libunwind project.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "174277d5a795084bbd20e2a58a5244620deceb81", + "path": "lib/libunwind/src/dwarf2.h", + "sha256": "d57f3a7a4dff483b64a8503d6a0ac8e8c3a79c52da9cdc637b8d53d52a16a1f6", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n", + "/*\n These constants were taken from version 3 of the DWARF standard,\n which is Copyright (c) 2005 Free Standards Group, and\n Copyright (c) 1992, 1993 UNIX International, Inc.\n*/" + ] + }, + { + "git_blob": "1d9c7f4d17b85038ea2412ad47d8d48cf054fed6", + "path": "lib/libunwind/src/gcc_personality_v0.c", + "sha256": "f83c80299344ddf08ca6dc7f7032249dfac5c00ebac3b222f01d27556147294e", + "source_notices": [ + "//===-- gcc_personality_v0.c - Implement __gcc_personality_v0 -------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "cf39ec5f7dbdf9b6485cccb804f5104f3b3a83d1", + "path": "lib/libunwind/src/libunwind.cpp", + "sha256": "0be28214f509a9301f7745b20b8f5e0667a9bd4f42ecf946dd7ee5dcec40b0d1", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Implements unw_* functions from \n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "28db43a4f6eef20dd5967f420a8d8fea552cf8c5", + "path": "lib/libunwind/src/libunwind_ext.h", + "sha256": "ee76dbef4b8a910e6d9302e643ae4566ce5ed8f4cbe5e612804506a089b291e1", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Extensions to libunwind API.\n//\n//===----------------------------------------------------------------------===//\n" + ] + } + ], + "schema_version": 1, + "source_revision": "5ad91a646a753cc3eecd8751e61cf458dadd9ac4", + "zig_version": "0.14.0" +} diff --git a/ci/test_musl_native_evidence.py b/ci/test_musl_native_evidence.py new file mode 100644 index 0000000..6d8bada --- /dev/null +++ b/ci/test_musl_native_evidence.py @@ -0,0 +1,57 @@ +"""CI-регрессии musl-only ABI и conservative source collection.""" + +import hashlib +import importlib.util +import json +from pathlib import Path +import struct +import unittest + +ROOT = Path(__file__).resolve().parents[1] +SPEC = importlib.util.spec_from_file_location('musl_evidence', ROOT / 'scripts/musl_native_evidence.py') +MODULE = importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(MODULE) + + +class MuslEvidenceTests(unittest.TestCase): + def test_catalogue_is_pinned_and_excludes_gnu_glibc_roles(self): + raw = (ROOT / 'ci/musl-runtime-catalog.json').read_bytes() + self.assertEqual(hashlib.sha256(raw).hexdigest(), MODULE.CATALOG_SHA) + profile = json.loads(raw) + self.assertEqual(len(profile['files']), 35) + self.assertFalse(any('glibc' in item['path'] for item in profile['files'])) + self.assertIn('lib/libc/musl/COPYRIGHT', {item['path'] for item in profile['files']}) + + def test_matching_little_endian_musl_cpu_is_required(self): + data = bytearray(64) + data[:6] = b'\x7fELF\x02\x01' + struct.pack_into(' limit: + raise ValueError('musl evidence input exceeds bound') + return raw + + +def machine(data, target): + expected = {'x86_64-unknown-linux-musl': 62, 'aarch64-unknown-linux-musl': 183} + if target not in expected or len(data) < 64 or data[:6] != b'\x7fELF\x02\x01' or struct.unpack_from(' 64 * 1024 * 1024 or len(compressed) > 4 * 1024 * 1024: + raise ValueError('musl candidate notice resource exceeds bound') + (evidence / 'NOTICE.cargo-std.json').write_bytes(before) + (evidence / 'NOTICE.json').write_bytes(raw) + (evidence / 'NOTICE.json.gz').write_bytes(compressed) + (evidence / 'musl-runtime-catalog.json').write_bytes(profile_raw) + (evidence / 'NOTICE.musl-runtime.txt').write_bytes('\n'.join(sections).encode('utf-8')) + + +def capture(binary, evidence, target, role, cache, sysroot): + data = read(binary, 128 * 1024 * 1024) + cpu = machine(data, target) + dynamic = subprocess.check_output(['readelf', '--dynamic', str(binary)], text=True) + versions = subprocess.check_output(['readelf', '--version-info', str(binary)], text=True) + symbols = subprocess.check_output(['nm', '-D', '--defined-only', '--format=posix', str(binary)], text=True) + needed = dependencies(dynamic, versions, target) + for name, text in [('elf-dynamic.txt', dynamic), ('elf-versions.txt', versions), ('elf-exports.txt', symbols)]: + (evidence / name).write_text(text, encoding='utf-8') + mapping = read(evidence / 'native-link.map', 32 * 1024 * 1024) + command = json.loads(read(evidence / 'native-link-command.json', 4 * 1024 * 1024)) + if not command or not any('--print-map' in value for value in command): + raise ValueError('actual musl final linker command missing') + archives = {} + for archive, member in re.findall(r'([^\s()]+[.](?:a|rlib))\(([^()\n]+)\)', mapping.decode('utf-8')): + archives.setdefault(archive, set()).add(member) + records = [] + roots = {'zig-cache': cache.resolve(), 'rust-sysroot': sysroot.resolve(), 'cargo-target': (Path.cwd() / 'target').resolve()} + for name, members in sorted(archives.items()): + path = Path(name) + resolved = path.resolve() + origin = next((key for key, base in roots.items() if resolved.is_relative_to(base)), None) + if origin is None: + raise ValueError('native musl archive escapes selected SDK/Rust/source roots') + record = {'path': resolved.relative_to(roots[origin]).as_posix(), 'origin': origin, 'members': sorted(members), 'available_after_link': path.is_file()} + if path.is_file(): + raw = read(path, 128 * 1024 * 1024) + record.update({'bytes': len(raw), 'sha256': hashlib.sha256(raw).hexdigest()}) + records.append(record) + direct = sorted(set(re.findall(r'[^\s()]+[.]o(?=:\()', mapping.decode('utf-8')))) + for name in ['NOTICE.json', 'NOTICE.json.gz', 'NOTICE.cargo-std.json', 'musl-runtime-catalog.json', 'NOTICE.musl-runtime.txt', 'Cargo.lock', 'source-provenance.json']: + shutil.copyfile(evidence.parent / name, evidence / name) + destination = evidence / binary.name + if destination.resolve() != binary.resolve(): + shutil.copyfile(binary, destination) + report = {'target': target, 'role': role, 'machine': cpu, 'binary_sha256': hashlib.sha256(data).hexdigest(), 'map_sha256': hashlib.sha256(mapping).hexdigest(), 'imports': needed, 'archive_inputs': records, 'direct_objects': direct, 'scope': 'Actual musl candidate binary/resource/input collection only. Retained-source grant review still required; no production npm delivery approval.'} + (evidence / 'native-verification.json').write_text(json.dumps(report, sort_keys=True, indent=2) + '\n', encoding='utf-8') + print(json.dumps(report, sort_keys=True)) + + +if __name__ == '__main__': + if len(sys.argv) == 3 and sys.argv[1] == 'prepare': + prepare(Path(sys.argv[2])) + elif len(sys.argv) == 8 and sys.argv[1] == 'capture': + capture(Path(sys.argv[2]), Path(sys.argv[3]), sys.argv[4], sys.argv[5], Path(sys.argv[6]), Path(sys.argv[7])) + else: + raise SystemExit('usage: musl_native_evidence.py prepare EVIDENCE | capture BINARY ROLE_EVIDENCE TARGET ROLE CACHE SYSROOT') From ad1dfaf1f3212e06703e283585cd812b96e32db0 Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sun, 1 Nov 2026 01:43:11 +0100 Subject: [PATCH 37/51] fix: gate musl resources on exact retained source grants The actual input probe and native x64/ARM Node/Bun corpus passed. Do not treat its conservative notice set as complete runtime proof: ARM retains additional Rust compiler-builtins LSE/CPU-model objects, with different NAPI and C ABI member sets; x64 NAPI retains trunc. Pin each role's real archive/member/sysroot identity and reject unknown archives or direct objects. Fingerprint actual Zig member bytes and ELF CPU from the fresh cache, not only archive headers. Preserve complete Rust/LLVM/libm original sources, permissions and credits from the exact Rust/LLVM revisions with SHA/Git-blob gates. Keep the compiler-builtins composite MIT AND Apache-2.0 WITH LLVM exception text unchanged, plus libm and LLVM original legal records. Augment the full binary/plain notice and verify every original role, Cargo/std preservation and actual resource after linking. Add seven per-role/corruption regression methods, executed only in CI. No parser, dependency, MSRV, version, target spoof, local application execution, publication or historical asset change is included. Co-Authored-By: Claude Opus 5.5 --- .../workflows/musl-native-notice-check.yml | 13 +- ci/licenses/musl-rust-originals/llvm-5.txt | 270 ++++++++ ci/licenses/musl-rust-originals/llvm-6.txt | 94 +++ ci/licenses/musl-rust-originals/llvm-7.txt | 311 +++++++++ ci/licenses/musl-rust-originals/llvm-8.txt | 36 + ci/licenses/musl-rust-originals/rust-0.txt | 275 ++++++++ ci/licenses/musl-rust-originals/rust-1.txt | 62 ++ ci/licenses/musl-rust-originals/rust-10.txt | 147 ++++ ci/licenses/musl-rust-originals/rust-11.txt | 258 +++++++ ci/licenses/musl-rust-originals/rust-2.txt | 649 ++++++++++++++++++ ci/licenses/musl-rust-originals/rust-3.txt | 17 + ci/licenses/musl-rust-originals/rust-4.txt | 467 +++++++++++++ ci/licenses/musl-rust-originals/rust-9.txt | 211 ++++++ .../rust-generic-trunc.txt | 36 + ci/musl-retained-runtime.json | 293 ++++++++ ci/test_musl_retained_runtime.py | 90 +++ scripts/musl_native_evidence.py | 21 +- scripts/musl_retained_runtime.py | 159 +++++ 18 files changed, 3403 insertions(+), 6 deletions(-) create mode 100644 ci/licenses/musl-rust-originals/llvm-5.txt create mode 100644 ci/licenses/musl-rust-originals/llvm-6.txt create mode 100644 ci/licenses/musl-rust-originals/llvm-7.txt create mode 100644 ci/licenses/musl-rust-originals/llvm-8.txt create mode 100644 ci/licenses/musl-rust-originals/rust-0.txt create mode 100644 ci/licenses/musl-rust-originals/rust-1.txt create mode 100644 ci/licenses/musl-rust-originals/rust-10.txt create mode 100644 ci/licenses/musl-rust-originals/rust-11.txt create mode 100644 ci/licenses/musl-rust-originals/rust-2.txt create mode 100644 ci/licenses/musl-rust-originals/rust-3.txt create mode 100644 ci/licenses/musl-rust-originals/rust-4.txt create mode 100644 ci/licenses/musl-rust-originals/rust-9.txt create mode 100644 ci/licenses/musl-rust-originals/rust-generic-trunc.txt create mode 100644 ci/musl-retained-runtime.json create mode 100644 ci/test_musl_retained_runtime.py create mode 100644 scripts/musl_retained_runtime.py diff --git a/.github/workflows/musl-native-notice-check.yml b/.github/workflows/musl-native-notice-check.yml index 52103ca..146f1c3 100644 --- a/.github/workflows/musl-native-notice-check.yml +++ b/.github/workflows/musl-native-notice-check.yml @@ -46,12 +46,19 @@ jobs: - name: Preserve reviewed notice tools and four-file native overlay shell: python run: | + import hashlib + import json import os import shutil from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'musl-notice-tools' stage.mkdir() names = ['Cargo.lock', 'ci/js-build-lock.json', 'crates/napi/build.rs', 'crates/cabi/build.rs', 'scripts/patch_napi_notice_source.py', 'scripts/patch_cabi_notice_source.py', 'ci/test_cabi_notice_overlay.py', 'ci/test_napi_notice_overlay.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json', 'scripts/capture-zig-link.sh', 'scripts/musl_native_evidence.py', 'ci/musl-runtime-catalog.json', 'ci/test_musl_native_evidence.py'] + retained = Path('ci/musl-retained-runtime.json').read_bytes() + if hashlib.sha256(retained).hexdigest() != 'ed6146168bd64b5022037c7a4ff30e71a21da74b07c697aa848799520166c1b5': + raise SystemExit('unreviewed retained musl source profile') + names += ['scripts/musl_retained_runtime.py', 'ci/musl-retained-runtime.json', 'ci/test_musl_retained_runtime.py'] + names += [item['path'] for item in json.loads(retained)['materials']] for name in names: destination = stage / name destination.parent.mkdir(parents=True, exist_ok=True) @@ -113,7 +120,7 @@ jobs: shell: bash run: | set -euo pipefail - for test in test_cabi_notice_overlay.py test_napi_notice_overlay.py test_musl_native_evidence.py; do + for test in test_cabi_notice_overlay.py test_napi_notice_overlay.py test_musl_native_evidence.py test_musl_retained_runtime.py; do python3 -I -m unittest discover -s ci -p "$test" -v done - name: Prepare reviewed source-bound candidate notices and npm tools @@ -127,6 +134,7 @@ jobs: evidence = Path(os.environ['RUNNER_TEMP']) / 'musl-native-evidence' subprocess.run([sys.executable, 'scripts/prepare_js_notices.py', str(evidence)], check=True) subprocess.run([sys.executable, '-I', 'scripts/musl_native_evidence.py', 'prepare', str(evidence)], check=True) + subprocess.run([sys.executable, '-I', 'scripts/musl_retained_runtime.py', 'prepare', str(evidence)], check=True) shutil.copyfile(Path(os.environ['RUNNER_TEMP']) / 'musl-notice-source.json', evidence / 'source-provenance.json') for name in ['LICENSE-MIT', 'LICENSE-APACHE']: shutil.copyfile(name, evidence / name) @@ -174,6 +182,7 @@ jobs: subprocess.run([sys.executable, '-I', 'scripts/musl_native_evidence.py', 'capture', str(binary), str(directory), target, role, str(cache), sysroot], check=True) report = subprocess.check_output([sys.executable, '-I', 'scripts/check_embedded_notices.py', str(directory / binary.name), str(evidence / 'NOTICE.json')]) (directory / 'embedded-verification.json').write_bytes(report) + subprocess.run([sys.executable, '-I', 'scripts/musl_retained_runtime.py', 'verify', str(evidence), target, role], check=True) if Path('Cargo.lock').read_bytes() != (evidence / 'Cargo.lock').read_bytes(): raise SystemExit('musl build changed reviewed lock') - name: Run actual matching-CPU Node and Bun consumers in pinned Alpine @@ -239,7 +248,7 @@ jobs: sys_stdout = result.stdout.decode('utf-8', errors='replace') sys_stderr = result.stderr.decode('utf-8', errors='replace') raise SystemExit(role + ' actual musl corpus failed:\n' + sys_stdout + '\n' + sys_stderr) - record = {'target': os.environ['MUSL_TARGET'], 'native_runner_arch': platform.machine(), 'node_napi_corpus': True, 'bun_cabi_corpus': True, 'emulated': False, 'napi_sha256': hashlib.sha256((stage / 'dist/native' / os.environ['MUSL_ADDON']).read_bytes()).hexdigest(), 'cabi_sha256': hashlib.sha256((stage / 'cabi/release/libktav_cabi.so').read_bytes()).hexdigest(), 'bun_archive_sha256': checksum.hexdigest(), 'node_image': image, 'scope': 'Actual matching-CPU Alpine Node/Bun corpus execution. No Deno-musl or completed retained-runtime licensing claim.'} + record = {'target': os.environ['MUSL_TARGET'], 'native_runner_arch': platform.machine(), 'node_napi_corpus': True, 'bun_cabi_corpus': True, 'emulated': False, 'napi_sha256': hashlib.sha256((stage / 'dist/native' / os.environ['MUSL_ADDON']).read_bytes()).hexdigest(), 'cabi_sha256': hashlib.sha256((stage / 'cabi/release/libktav_cabi.so').read_bytes()).hexdigest(), 'bun_archive_sha256': checksum.hexdigest(), 'node_image': image, 'scope': 'Actual matching-CPU Alpine Node/Bun corpus execution. Exact source/grant gates are separate; no Deno-musl or production npm delivery claim.'} (evidence / 'consumer-verification.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') - uses: actions/upload-artifact@v4 if: always() diff --git a/ci/licenses/musl-rust-originals/llvm-5.txt b/ci/licenses/musl-rust-originals/llvm-5.txt new file mode 100644 index 0000000..a444d82 --- /dev/null +++ b/ci/licenses/musl-rust-originals/llvm-5.txt @@ -0,0 +1,270 @@ +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "assembly.h" + +// Out-of-line LSE atomics helpers. Ported from libgcc library. +// N = {1, 2, 4, 8} +// M = {1, 2, 4, 8, 16} +// ORDER = {'relax', 'acq', 'rel', 'acq_rel', 'sync'} +// Routines implemented: +// +// iM __aarch64_casM_ORDER(iM expected, iM desired, iM *ptr) +// iN __aarch64_swpN_ORDER(iN val, iN *ptr) +// iN __aarch64_ldaddN_ORDER(iN val, iN *ptr) +// iN __aarch64_ldclrN_ORDER(iN val, iN *ptr) +// iN __aarch64_ldeorN_ORDER(iN val, iN *ptr) +// iN __aarch64_ldsetN_ORDER(iN val, iN *ptr) +// +// Routines may modify temporary registers tmp0, tmp1, tmp2, +// return value x0 and the flags only. + +#if defined(__aarch64__) || defined(__arm64ec__) + +#ifdef HAS_ASM_LSE +.arch armv8-a+lse +#else +.arch armv8-a +#endif + +#if !defined(__APPLE__) +HIDDEN(__aarch64_have_lse_atomics) +#else +HIDDEN(___aarch64_have_lse_atomics) +#endif + +// Generate mnemonics for +// L_cas: SIZE: 1,2,4,8,16 MODEL: 1,2,3,4,5 +// L_swp L_ldadd L_ldclr L_ldeor L_ldset: SIZE: 1,2,4,8 MODEL: 1,2,3,4,5 + +#if SIZE == 1 +#define S b +#define UXT uxtb +#define B 0x00000000 +#elif SIZE == 2 +#define S h +#define UXT uxth +#define B 0x40000000 +#elif SIZE == 4 || SIZE == 8 || SIZE == 16 +#define S +#define UXT mov +#if SIZE == 4 +#define B 0x80000000 +#elif SIZE == 8 +#define B 0xc0000000 +#endif +#else +#error +#endif // SIZE + +#if MODEL == 1 +#define SUFF _relax +#define A +#define L +#define M 0x000000 +#define N 0x000000 +#define BARRIER +#elif MODEL == 2 +#define SUFF _acq +#define A a +#define L +#define M 0x400000 +#define N 0x800000 +#define BARRIER +#elif MODEL == 3 +#define SUFF _rel +#define A +#define L l +#define M 0x008000 +#define N 0x400000 +#define BARRIER +#elif MODEL == 4 +#define SUFF _acq_rel +#define A a +#define L l +#define M 0x408000 +#define N 0xc00000 +#define BARRIER +#elif MODEL == 5 +#define SUFF _sync +#ifdef L_swp +// swp has _acq semantics. +#define A a +#define L +#define M 0x400000 +#define N 0x800000 +#else +// All other _sync functions have _seq semantics. +#define A a +#define L l +#define M 0x408000 +#define N 0xc00000 +#endif +#define BARRIER dmb ish +#else +#error +#endif // MODEL + +// Define register size. +#define x(N) GLUE2(x, N) +#define w(N) GLUE2(w, N) +#if SIZE < 8 +#define s(N) w(N) +#else +#define s(N) x(N) +#endif + +#define NAME(BASE) GLUE4(__aarch64_, BASE, SIZE, SUFF) +#if MODEL == 5 +// Drop A for _sync functions. +#define LDXR GLUE3(ld, xr, S) +#else +#define LDXR GLUE4(ld, A, xr, S) +#endif +#define STXR GLUE4(st, L, xr, S) + +// Define temporary registers. +#define tmp0 16 +#define tmp1 17 +#define tmp2 15 + +// Macro for branch to label if no LSE available +.macro JUMP_IF_NOT_LSE label +#if !defined(__APPLE__) + adrp x(tmp0), __aarch64_have_lse_atomics + ldrb w(tmp0), [x(tmp0), :lo12:__aarch64_have_lse_atomics] +#else + adrp x(tmp0), ___aarch64_have_lse_atomics@page + ldrb w(tmp0), [x(tmp0), ___aarch64_have_lse_atomics@pageoff] +#endif + cbz w(tmp0), \label +.endm + +#ifdef L_cas +DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(cas)) + JUMP_IF_NOT_LSE 8f +#if SIZE < 16 +#ifdef HAS_ASM_LSE +#define CAS GLUE4(cas, A, L, S) s(0), s(1), [x2] +#else +#define CAS .inst 0x08a07c41 + B + M +#endif + CAS // s(0), s(1), [x2] + ret +8: + UXT s(tmp0), s(0) +0: + LDXR s(0), [x2] + cmp s(0), s(tmp0) + bne 1f + STXR w(tmp1), s(1), [x2] + cbnz w(tmp1), 0b +1: + BARRIER + ret +#else +#if MODEL == 5 +// Drop A for _sync functions. +#define LDXP GLUE2(ld, xp) +#else +#define LDXP GLUE3(ld, A, xp) +#endif +#define STXP GLUE3(st, L, xp) +#ifdef HAS_ASM_LSE +#define CASP GLUE3(casp, A, L) x0, x1, x2, x3, [x4] +#else +#define CASP .inst 0x48207c82 + M +#endif + + CASP // x0, x1, x2, x3, [x4] + ret +8: + mov x(tmp0), x0 + mov x(tmp1), x1 +0: + LDXP x0, x1, [x4] + cmp x0, x(tmp0) + ccmp x1, x(tmp1), #0, eq + bne 1f + STXP w(tmp2), x2, x3, [x4] + cbnz w(tmp2), 0b +1: + BARRIER + ret +#endif +END_COMPILERRT_OUTLINE_FUNCTION(NAME(cas)) +#endif // L_cas + +#ifdef L_swp +#ifdef HAS_ASM_LSE +#define SWP GLUE4(swp, A, L, S) s(0), s(0), [x1] +#else +#define SWP .inst 0x38208020 + B + N +#endif +DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(swp)) + JUMP_IF_NOT_LSE 8f + SWP // s(0), s(0), [x1] + ret +8: + mov s(tmp0), s(0) +0: + LDXR s(0), [x1] + STXR w(tmp1), s(tmp0), [x1] + cbnz w(tmp1), 0b + BARRIER + ret +END_COMPILERRT_OUTLINE_FUNCTION(NAME(swp)) +#endif // L_swp + +#if defined(L_ldadd) || defined(L_ldclr) || \ + defined(L_ldeor) || defined(L_ldset) + +#ifdef L_ldadd +#define LDNM ldadd +#define OP add +#define OPN 0x0000 +#elif defined(L_ldclr) +#define LDNM ldclr +#define OP bic +#define OPN 0x1000 +#elif defined(L_ldeor) +#define LDNM ldeor +#define OP eor +#define OPN 0x2000 +#elif defined(L_ldset) +#define LDNM ldset +#define OP orr +#define OPN 0x3000 +#else +#error +#endif + +#ifdef HAS_ASM_LSE +#define LDOP GLUE4(LDNM, A, L, S) s(0), s(0), [x1] +#else +#define LDOP .inst 0x38200020 + OPN + B + N +#endif + +DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(LDNM)) + JUMP_IF_NOT_LSE 8f + LDOP // s(0), s(0), [x1] + ret +8: + mov s(tmp0), s(0) +0: + LDXR s(0), [x1] + OP s(tmp1), s(0), s(tmp0) + STXR w(tmp2), s(tmp1), [x1] + cbnz w(tmp2), 0b + BARRIER + ret +END_COMPILERRT_OUTLINE_FUNCTION(NAME(LDNM)) +#endif // L_ldadd L_ldclr L_ldeor L_ldset + +NO_EXEC_STACK_DIRECTIVE + +// GNU property note for BTI, PAC, and GCS +GNU_PROPERTY_BTI_PAC_GCS + +#endif // defined(__aarch64__) || defined(__arm64ec__) diff --git a/ci/licenses/musl-rust-originals/llvm-6.txt b/ci/licenses/musl-rust-originals/llvm-6.txt new file mode 100644 index 0000000..347bb4e --- /dev/null +++ b/ci/licenses/musl-rust-originals/llvm-6.txt @@ -0,0 +1,94 @@ +//===-- cpu_model/aarch64.c - Support for __cpu_model builtin ----*- C -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file is based on LLVM's lib/Support/Host.cpp. +// It implements __aarch64_have_lse_atomics, __aarch64_cpu_features for +// AArch64. +// +//===----------------------------------------------------------------------===// + +#include "aarch64.h" + +#if !defined(__aarch64__) && !defined(__arm64__) && !defined(_M_ARM64) && \ + !defined(__arm64ec__) && !defined(_M_ARM64EC) +#error This file is intended only for aarch64-based targets +#endif + +#if __has_include() +#include +#else +typedef struct __ifunc_arg_t { + unsigned long _size; + unsigned long _hwcap; + unsigned long _hwcap2; +} __ifunc_arg_t; +#endif // __has_include() + +// LSE support detection for out-of-line atomics +// using HWCAP and Auxiliary vector +_Bool __aarch64_have_lse_atomics + __attribute__((visibility("hidden"), nocommon)) = false; + +// The formatter wants to re-order these includes, but doing so is incorrect: +// clang-format off +#if defined(__FreeBSD__) || defined(__OpenBSD__) +#include +#include "aarch64/hwcap.inc" +#include "aarch64/lse_atomics/elf_aux_info.inc" +#elif defined(__Fuchsia__) +#include "aarch64/hwcap.inc" +#include "aarch64/lse_atomics/fuchsia.inc" +#elif defined(__ANDROID__) +#include +#include "aarch64/hwcap.inc" +#include "aarch64/lse_atomics/android.inc" +#elif defined(__linux__) +#include +#include "aarch64/hwcap.inc" +#include "aarch64/lse_atomics/getauxval.inc" +#elif defined(_WIN32) +#include "aarch64/lse_atomics/windows.inc" +#else +// When unimplemented, we leave __aarch64_have_lse_atomics initialized to false. +#endif +// clang-format on + +#if !defined(DISABLE_AARCH64_FMV) + +// Architecture features used +// in Function Multi Versioning +struct { + unsigned long long features; + // As features grows new fields could be added +} __aarch64_cpu_features __attribute__((visibility("hidden"), nocommon)); + +// The formatter wants to re-order these includes, but doing so is incorrect: +// clang-format off +#if defined(TARGET_BAREMETAL_AARCH64) +#include "aarch64/fmv/baremetal.inc" +#elif defined(__APPLE__) +#include "aarch64/fmv/apple.inc" +#elif defined(__FreeBSD__) || defined(__OpenBSD__) +#include "aarch64/fmv/hwcap.inc" +#include "aarch64/fmv/elf_aux_info.inc" +#elif defined(__Fuchsia__) +#include "aarch64/fmv/fuchsia.inc" +#elif defined(__ANDROID__) +#include "aarch64/fmv/hwcap.inc" +#include "aarch64/fmv/android.inc" +#elif defined(__linux__) +#include "aarch64/fmv/hwcap.inc" +#include "aarch64/fmv/getauxval.inc" +#elif defined(_WIN32) +#include "aarch64/fmv/windows.inc" +#else +#include "aarch64/fmv/unimplemented.inc" +#endif +// clang-format on + +#endif // !defined(DISABLE_AARCH64_FMV) diff --git a/ci/licenses/musl-rust-originals/llvm-7.txt b/ci/licenses/musl-rust-originals/llvm-7.txt new file mode 100644 index 0000000..5a79a1b --- /dev/null +++ b/ci/licenses/musl-rust-originals/llvm-7.txt @@ -0,0 +1,311 @@ +============================================================================== +The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: +============================================================================== + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +---- LLVM Exceptions to the Apache 2.0 License ---- + +As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into an Object form of such source code, you +may redistribute such embedded portions in such Object form without complying +with the conditions of Sections 4(a), 4(b) and 4(d) of the License. + +In addition, if you combine or link compiled forms of this Software with +software that is licensed under the GPLv2 ("Combined Software") and if a +court of competent jurisdiction determines that the patent provision (Section +3), the indemnity provision (Section 9) or other Section of the License +conflicts with the conditions of the GPLv2, you may retroactively and +prospectively choose to deem waived or otherwise exclude such Section(s) of +the License, but only in their entirety and only with respect to the Combined +Software. + +============================================================================== +Software from third parties included in the LLVM Project: +============================================================================== +The LLVM Project contains third party software which is under different license +terms. All such code will be identified clearly using at least one of two +mechanisms: +1) It will be in a separate directory tree with its own `LICENSE.txt` or + `LICENSE` file at the top containing the specific license and restrictions + which apply to that software, or +2) It will contain specific license and restriction terms at the top of every + file. + +============================================================================== +Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy): +============================================================================== + +The compiler_rt library is dual licensed under both the University of Illinois +"BSD-Like" license and the MIT license. As a user of this code you may choose +to use it under either license. As a contributor, you agree to allow your code +to be used under both. + +Full text of the relevant licenses is included below. + +============================================================================== + +University of Illinois/NCSA +Open Source License + +Copyright (c) 2009-2019 by the contributors listed in CREDITS.TXT + +All rights reserved. + +Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE +SOFTWARE. + +============================================================================== + +Copyright (c) 2009-2015 by the contributors listed in CREDITS.TXT + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/ci/licenses/musl-rust-originals/llvm-8.txt b/ci/licenses/musl-rust-originals/llvm-8.txt new file mode 100644 index 0000000..6964eba --- /dev/null +++ b/ci/licenses/musl-rust-originals/llvm-8.txt @@ -0,0 +1,36 @@ +This file is a partial list of people who have contributed to the LLVM/CompilerRT +project. If you have contributed a patch or made some other contribution to +LLVM/CompilerRT, please submit a patch to this file to add yourself, and it will be +done! + +The list is sorted by surname and formatted to allow easy grepping and +beautification by scripts. The fields are: name (N), email (E), web-address +(W), PGP key ID and fingerprint (P), description (D), and snail-mail address +(S). + +N: Craig van Vliet +E: cvanvliet@auroraux.org +W: http://www.auroraux.org +D: Code style and Readability fixes. + +N: Edward O'Callaghan +E: eocallaghan@auroraux.org +W: http://www.auroraux.org +D: CMake'ify Compiler-RT build system +D: Maintain Solaris & AuroraUX ports of Compiler-RT + +N: Howard Hinnant +E: hhinnant@apple.com +D: Architect and primary author of compiler-rt + +N: Guan-Hong Liu +E: koviankevin@hotmail.com +D: IEEE Quad-precision functions + +N: Joerg Sonnenberger +E: joerg@NetBSD.org +D: Maintains NetBSD port. + +N: Matt Thomas +E: matt@NetBSD.org +D: ARM improvements. diff --git a/ci/licenses/musl-rust-originals/rust-0.txt b/ci/licenses/musl-rust-originals/rust-0.txt new file mode 100644 index 0000000..00ae614 --- /dev/null +++ b/ci/licenses/musl-rust-originals/rust-0.txt @@ -0,0 +1,275 @@ +The compiler-builtins crate is available for use under both the MIT license +and the Apache-2.0 license with the LLVM exception (MIT AND Apache-2.0 WITH +LLVM-exception). + +The libm crate is available for use under the MIT license. + +As a contributor, you agree that your code may be used under any of the +following: the MIT license, the Apache-2.0 license, or the Apache-2.0 license +with the LLVM exception. In other words, original (non-derivative) work is +licensed under MIT OR Apache-2.0 OR Apache-2.0 WITH LLVM-exception. This is +the default license for all other source in this repository. + +Text of the relevant licenses is provided below: + +------------------------------------------------------------------------------ +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + 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. + + +---- LLVM Exceptions to the Apache 2.0 License ---- + +As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into an Object form of such source code, you +may redistribute such embedded portions in such Object form without complying +with the conditions of Sections 4(a), 4(b) and 4(d) of the License. + +In addition, if you combine or link compiled forms of this Software with +software that is licensed under the GPLv2 ("Combined Software") and if a +court of competent jurisdiction determines that the patent provision (Section +3), the indemnity provision (Section 9) or other Section of the License +conflicts with the conditions of the GPLv2, you may retroactively and +prospectively choose to deem waived or otherwise exclude such Section(s) of +the License, but only in their entirety and only with respect to the Combined +Software. +------------------------------------------------------------------------------ + +Portions of this software are derived from third-party works licensed under +terms compatible with the above Apache-2.0 WITH LLVM-exception AND MIT +license: + +* compiler-builtins is derived from LLVM's compiler-rt (https://llvm.org/). + Work derived from compiler-rt prior to 2019-01-19 is usable under the MIT + license, with the following copyright: + + Copyright (c) 2009-2016 by the contributors listed in CREDITS.TXT + + The relevant CREDITS.TXT is located at + https://github.com/llvm/llvm-project/blob/main/compiler-rt/CREDITS.TXT. + +* Work derived from compiler-rt after 2019-01-19 is usable under the + Apache-2.0 license with the LLVM exception. + +* The bundled `math` module is from the libm crate, usable under the MIT + license. For further details and copyrights, see see libm/LICENSE.txt at + https://github.com/rust-lang/compiler-builtins. + +Additionally, some source files may contain comments with specific copyrights +or licenses. diff --git a/ci/licenses/musl-rust-originals/rust-1.txt b/ci/licenses/musl-rust-originals/rust-1.txt new file mode 100644 index 0000000..b2f1443 --- /dev/null +++ b/ci/licenses/musl-rust-originals/rust-1.txt @@ -0,0 +1,62 @@ +# NOTE: Must be kept in sync with `../builtins-shim/Cargo.toml`. +# +# This manifest is actually used in-tree by rust-lang/rust, +# `../builtins-shim/Cargo.toml` is used by out-of-tree testing. See the other +# manifest for further details. + +[package] +name = "compiler_builtins" +version = "0.1.160" +authors = [ + "Alex Crichton ", + "Amanieu d'Antras ", + "Jorge Aparicio ", + "Trevor Gross ", +] +description = "Compiler intrinsics used by the Rust compiler." +repository = "https://github.com/rust-lang/compiler-builtins" +license = "MIT AND Apache-2.0 WITH LLVM-exception AND (MIT OR Apache-2.0)" +edition = "2024" +publish = false +links = "compiler-rt" + +[lib] +bench = false +doctest = false +test = false +# make sure this crate isn't included in public standard library docs +doc = false + +[dependencies] +core = { path = "../../core", optional = true } + +[build-dependencies] +cc = { version = "1.2", optional = true } + +[features] +default = ["arch"] + +# Enable architecture-specific features such as SIMD or assembly routines. If +# disabled, the generic version can be tested on any platform. +arch = [] + +# Enable compilation of C code in compiler-rt, filling in some more optimized +# implementations and also filling in unimplemented intrinsics +c = ["dep:cc"] + +# Flag this library as the unstable compiler-builtins lib. This must be enabled +# when using as `std`'s dependency.' +compiler-builtins = ["dep:core", "unmangled-names"] + +# Enable `no_mangle` symbols for memory-related intrinsics like memcpy. The +# mangled versions are always available. +mem = [] + +# Enable `no_mangle` symbols so this crate gets used as the runtime intrinsic +# implementation. Leave this disabled for testing to avoid conflicting with +# the system intrinsics. +unmangled-names = [] + +# This makes certain traits and function specializations public that +# are not normally public but are required by the `builtins-test` +unstable-public-internals = [] diff --git a/ci/licenses/musl-rust-originals/rust-10.txt b/ci/licenses/musl-rust-originals/rust-10.txt new file mode 100644 index 0000000..9eb902e --- /dev/null +++ b/ci/licenses/musl-rust-originals/rust-10.txt @@ -0,0 +1,147 @@ +use super::generic; + +/// Rounds the number toward 0 to the closest integral value (f16). +/// +/// This effectively removes the decimal part of the number, leaving the integral part. +#[cfg(f16_enabled)] +#[cfg_attr(assert_no_panic, no_panic::no_panic)] +pub fn truncf16(x: f16) -> f16 { + generic::trunc_status(x).val +} + +/// Rounds the number toward 0 to the closest integral value (f32). +/// +/// This effectively removes the decimal part of the number, leaving the integral part. +#[cfg_attr(assert_no_panic, no_panic::no_panic)] +pub fn truncf(x: f32) -> f32 { + select_implementation! { + name: truncf, + use_arch: all(target_arch = "wasm32", intrinsics_enabled), + args: x, + } + + generic::trunc_status(x).val +} + +/// Rounds the number toward 0 to the closest integral value (f64). +/// +/// This effectively removes the decimal part of the number, leaving the integral part. +#[cfg_attr(assert_no_panic, no_panic::no_panic)] +pub fn trunc(x: f64) -> f64 { + select_implementation! { + name: trunc, + use_arch: all(target_arch = "wasm32", intrinsics_enabled), + args: x, + } + + generic::trunc_status(x).val +} + +/// Rounds the number toward 0 to the closest integral value (f128). +/// +/// This effectively removes the decimal part of the number, leaving the integral part. +#[cfg(f128_enabled)] +#[cfg_attr(assert_no_panic, no_panic::no_panic)] +pub fn truncf128(x: f128) -> f128 { + generic::trunc_status(x).val +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::support::{Float, FpResult, Hex, Status}; + + macro_rules! cases { + ($f:ty) => { + [ + // roundtrip + (0.0, 0.0, Status::OK), + (-0.0, -0.0, Status::OK), + (1.0, 1.0, Status::OK), + (-1.0, -1.0, Status::OK), + (<$f>::INFINITY, <$f>::INFINITY, Status::OK), + (<$f>::NEG_INFINITY, <$f>::NEG_INFINITY, Status::OK), + // with rounding + (0.1, 0.0, Status::INEXACT), + (-0.1, -0.0, Status::INEXACT), + (0.5, 0.0, Status::INEXACT), + (-0.5, -0.0, Status::INEXACT), + (0.9, 0.0, Status::INEXACT), + (-0.9, -0.0, Status::INEXACT), + (1.1, 1.0, Status::INEXACT), + (-1.1, -1.0, Status::INEXACT), + (1.5, 1.0, Status::INEXACT), + (-1.5, -1.0, Status::INEXACT), + (1.9, 1.0, Status::INEXACT), + (-1.9, -1.0, Status::INEXACT), + ] + }; + } + + #[track_caller] + fn check(f: fn(F) -> F, cases: &[(F, F, Status)]) { + for &(x, exp_res, exp_stat) in cases { + let FpResult { val, status } = generic::trunc_status(x); + assert_biteq!(val, exp_res, "generic::trunc_status({x:?}) ({})", Hex(x)); + assert_eq!( + status, + exp_stat, + "{x:?} {} -> {exp_res:?} {}", + Hex(x), + Hex(exp_res) + ); + let val = f(x); + assert_biteq!(val, exp_res, "trunc({x:?}) ({})", Hex(x)); + } + } + + #[test] + #[cfg(f16_enabled)] + fn check_f16() { + check::(truncf16, &cases!(f16)); + check::( + truncf16, + &[ + (hf16!("0x1p10"), hf16!("0x1p10"), Status::OK), + (hf16!("-0x1p10"), hf16!("-0x1p10"), Status::OK), + ], + ); + } + + #[test] + fn check_f32() { + check::(truncf, &cases!(f32)); + check::( + truncf, + &[ + (hf32!("0x1p23"), hf32!("0x1p23"), Status::OK), + (hf32!("-0x1p23"), hf32!("-0x1p23"), Status::OK), + ], + ); + } + + #[test] + fn check_f64() { + check::(trunc, &cases!(f64)); + check::( + trunc, + &[ + (hf64!("0x1p52"), hf64!("0x1p52"), Status::OK), + (hf64!("-0x1p52"), hf64!("-0x1p52"), Status::OK), + ], + ); + } + + #[test] + #[cfg(f128_enabled)] + fn check_f128() { + check::(truncf128, &cases!(f128)); + check::( + truncf128, + &[ + (hf128!("0x1p112"), hf128!("0x1p112"), Status::OK), + (hf128!("-0x1p112"), hf128!("-0x1p112"), Status::OK), + ], + ); + } +} diff --git a/ci/licenses/musl-rust-originals/rust-11.txt b/ci/licenses/musl-rust-originals/rust-11.txt new file mode 100644 index 0000000..2f8e41f --- /dev/null +++ b/ci/licenses/musl-rust-originals/rust-11.txt @@ -0,0 +1,258 @@ +rust-lang/libm as a whole is available for use under the MIT license: + +------------------------------------------------------------------------------ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ + +As a contributor, you agree that your code can be used under either the MIT +license or the Apache-2.0 license: + +------------------------------------------------------------------------------ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + 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. +------------------------------------------------------------------------------ + +This Rust library contains the following copyrights: + + Copyright (c) 2018 Jorge Aparicio + +Portions of this software are derived from third-party works licensed under +terms compatible with the above MIT license: + +* musl libc https://www.musl-libc.org/. This library contains the following + copyright: + + Copyright © 2005-2020 Rich Felker, et al. + +* The CORE-MATH project https://core-math.gitlabpages.inria.fr/. CORE-MATH + routines are available under the MIT license on a per-file basis. + +The musl libc COPYRIGHT file also includes the following notice relevant to +math portions of the library: + +------------------------------------------------------------------------------ +Much of the math library code (src/math/* and src/complex/*) is +Copyright © 1993,2004 Sun Microsystems or +Copyright © 2003-2011 David Schultz or +Copyright © 2003-2009 Steven G. Kargl or +Copyright © 2003-2009 Bruce D. Evans or +Copyright © 2008 Stephen L. Moshier or +Copyright © 2017-2018 Arm Limited +and labelled as such in comments in the individual source files. All +have been licensed under extremely permissive terms. +------------------------------------------------------------------------------ + +Copyright notices are retained in src/* files where relevant. diff --git a/ci/licenses/musl-rust-originals/rust-2.txt b/ci/licenses/musl-rust-originals/rust-2.txt new file mode 100644 index 0000000..e86c784 --- /dev/null +++ b/ci/licenses/musl-rust-originals/rust-2.txt @@ -0,0 +1,649 @@ +#[path = "../libm/configure.rs"] +mod configure; + +use std::env; + +use configure::{Config, Library, set_cfg}; + +fn main() { + let cfg = Config::from_env(Library::CompilerBuiltins); + let llvm_target = &cfg.target_triple_split; + + // Work around building as part of `builtins-shim`: if only `build.rs` is used, Cargo always + // considers the build dirty because `builtins-shim/build.rs` does not exist. If only + // `../c-b/build.rs` is used, the same may happen if not built in the workspace. + // Note: this may be `None` if CARGO_MANIFEST_DIR doesn't end in a directory name (e.g. ".") + if let Some(dir) = cfg.manifest_dir.file_name() + && dir == "builtins-shim" + { + println!("cargo::rerun-if-changed=../compiler-builtins/build.rs"); + } else { + println!("cargo::rerun-if-changed=build.rs"); + } + + println!("cargo::rerun-if-changed=../libm/configure.rs"); + + configure::emit(&cfg); + configure_check_cfg(); + + let cwd = env::current_dir().unwrap(); + println!("cargo:compiler-rt={}", cwd.join("compiler-rt").display()); + + // Forcibly enable memory intrinsics on wasm & SGX as we don't have a libc to + // provide them. + if (cfg.target_triple.contains("wasm") && !cfg.target_triple.contains("wasi")) + || (cfg.target_triple.contains("sgx") && cfg.target_triple.contains("fortanix")) + || cfg.target_triple.contains("-none") + || cfg.target_triple.contains("nvptx") + || cfg.target_triple.contains("uefi") + || cfg.target_triple.contains("xous") + { + println!("cargo:rustc-cfg=feature=\"mem\""); + } + + // These targets have hardware unaligned access support. + let mem_unaligned = cfg.target_arch.contains("x86_64") + || cfg.target_arch.contains("x86") + || cfg.target_arch.contains("aarch64") + || cfg.target_arch.contains("bpf"); + set_cfg("mem_unaligned", mem_unaligned); + + // Only emit the ARM Linux atomic emulation on pre-ARMv6 architectures. This + // includes the old androideabi. It is deprecated but it is available as a + // rustc target (arm-linux-androideabi). + let kernel_user_helpers = llvm_target[0] == "armv4t" + || llvm_target[0] == "armv5te" + || cfg.target_triple == "arm-linux-androideabi"; + set_cfg("kernel_user_helpers", kernel_user_helpers); + + let mut maybe_build_c = true; + + // Emscripten's runtime includes all the builtins + if cfg.target_os == "emscripten" { + maybe_build_c = false; + } + + // OpenBSD provides compiler_rt by default, use it instead of rebuilding it from source + if cfg.target_os == "openbsd" { + println!("cargo:rustc-link-search=native=/usr/lib"); + println!("cargo:rustc-link-lib=compiler_rt"); + maybe_build_c = false; + } + + // Everything is LLVM bitcode, not compatible with mixed C/Rust + if cfg.target_arch.contains("nvptx") { + maybe_build_c = false; + } + + // Build missing intrinsics from compiler-rt C source code. If we're + // mangling names though we assume that we're also in test mode so we don't + // build anything and we rely on the upstream implementation of compiler-rt + // functions + if cfg!(feature = "unmangled-names") && cfg!(feature = "c") && maybe_build_c { + #[cfg(feature = "c")] + c::compile(&cfg); + } +} + +/// Emit directives for features we expect to support that aren't in `Cargo.toml`. +/// +/// These are mostly cfg elements emitted by this `build.rs`. +fn configure_check_cfg() { + // Functions where we can set the "optimized-c" flag + const HAS_OPTIMIZED_C: &[&str] = &[ + "__ashldi3", + "__ashlsi3", + "__ashrdi3", + "__ashrsi3", + "__bswapsi2", + "__bswapdi2", + "__bswapti2", + "__divdi3", + "__divsi3", + "__divmoddi4", + "__divmodsi4", + "__divmodsi4", + "__divmodti4", + "__lshrdi3", + "__lshrsi3", + "__moddi3", + "__modsi3", + "__muldi3", + "__udivdi3", + "__udivmoddi4", + "__udivmodsi4", + "__udivsi3", + "__umoddi3", + "__umodsi3", + ]; + + // Build a list of all aarch64 atomic operation functions + let mut aarch_atomic = Vec::new(); + for aarch_op in ["cas", "ldadd", "ldclr", "ldeor", "ldset", "swp"] { + let op_sizes = if aarch_op == "cas" { + [1, 2, 4, 8, 16].as_slice() + } else { + [1, 2, 4, 8].as_slice() + }; + + for op_size in op_sizes { + for ordering in ["relax", "acq", "rel", "acq_rel"] { + aarch_atomic.push(format!("__aarch64_{aarch_op}{op_size}_{ordering}")); + } + } + } + + for fn_name in HAS_OPTIMIZED_C + .iter() + .copied() + .chain(aarch_atomic.iter().map(|s| s.as_str())) + { + println!("cargo::rustc-check-cfg=cfg({fn_name}, values(\"optimized-c\"))",); + } + + // Rustc is unaware of sparc target features, but this does show up from + // `rustc --print target-features --target sparc64-unknown-linux-gnu`. + println!("cargo::rustc-check-cfg=cfg(target_feature, values(\"vis3\"))"); +} + +#[cfg(feature = "c")] +mod c { + use std::collections::{BTreeMap, HashSet}; + use std::env; + use std::fs::{self, File}; + use std::io::Write; + use std::path::{Path, PathBuf}; + + use super::Config; + + struct Sources { + // SYMBOL -> PATH TO SOURCE + map: BTreeMap<&'static str, &'static str>, + } + + impl Sources { + fn new() -> Sources { + Sources { + map: BTreeMap::new(), + } + } + + fn extend(&mut self, sources: &[(&'static str, &'static str)]) { + // NOTE Some intrinsics have both a generic implementation (e.g. + // `floatdidf.c`) and an arch optimized implementation + // (`x86_64/floatdidf.c`). In those cases, we keep the arch optimized + // implementation and discard the generic implementation. If we don't + // and keep both implementations, the linker will yell at us about + // duplicate symbols! + for (symbol, src) in sources { + if src.contains("/") { + // Arch-optimized implementation (preferred) + self.map.insert(symbol, src); + } else { + // Generic implementation + if !self.map.contains_key(symbol) { + self.map.insert(symbol, src); + } + } + } + } + + fn remove(&mut self, symbols: &[&str]) { + for symbol in symbols { + self.map.remove(*symbol).unwrap(); + } + } + } + + /// Compile intrinsics from the compiler-rt C source code + pub fn compile(cfg: &Config) { + let llvm_target = &cfg.target_triple_split; + let mut consider_float_intrinsics = true; + let build = &mut cc::Build::new(); + + // AArch64 GCCs exit with an error condition when they encounter any kind of floating point + // code if the `nofp` and/or `nosimd` compiler flags have been set. + // + // Therefore, evaluate if those flags are present and set a boolean that causes any + // compiler-rt intrinsics that contain floating point source to be excluded for this target. + if cfg.target_arch == "aarch64" { + let cflags_key = String::from("CFLAGS_") + &(cfg.target_triple.replace("-", "_")); + if let Ok(cflags_value) = env::var(cflags_key) { + if cflags_value.contains("+nofp") || cflags_value.contains("+nosimd") { + consider_float_intrinsics = false; + } + } + } + + // `compiler-rt` requires `COMPILER_RT_HAS_FLOAT16` to be defined to make it use the + // `_Float16` type for `f16` intrinsics. This shouldn't matter as all existing `f16` + // intrinsics have been ported to Rust in `compiler-builtins` as C compilers don't + // support `_Float16` on all targets (whereas Rust does). However, define the macro + // anyway to prevent issues like rust#118813 and rust#123885 silently reoccuring if more + // `f16` intrinsics get accidentally added here in the future. + build.define("COMPILER_RT_HAS_FLOAT16", None); + + build.warnings(false); + + if cfg.target_env == "msvc" { + // Don't pull in extra libraries on MSVC + build.flag("/Zl"); + + // Emulate C99 and C++11's __func__ for MSVC prior to 2013 CTP + build.define("__func__", Some("__FUNCTION__")); + } else { + // Turn off various features of gcc and such, mostly copying + // compiler-rt's build system already + build.flag("-fno-builtin"); + build.flag("-fvisibility=hidden"); + build.flag("-ffreestanding"); + // Avoid the following warning appearing once **per file**: + // clang: warning: optimization flag '-fomit-frame-pointer' is not supported for target 'armv7' [-Wignored-optimization-argument] + // + // Note that compiler-rt's build system also checks + // + // `check_cxx_compiler_flag(-fomit-frame-pointer COMPILER_RT_HAS_FOMIT_FRAME_POINTER_FLAG)` + // + // in https://github.com/rust-lang/compiler-rt/blob/c8fbcb3/cmake/config-ix.cmake#L19. + build.flag_if_supported("-fomit-frame-pointer"); + build.define("VISIBILITY_HIDDEN", None); + + if let "aarch64" | "arm64ec" = cfg.target_arch.as_str() { + // FIXME(llvm20): Older GCCs on A64 fail to build with + // -Werror=implicit-function-declaration due to a compiler-rt bug. + // With a newer LLVM we should be able to enable the flag everywhere. + // https://github.com/llvm/llvm-project/commit/8aa9d6206ce55bdaaf422839c351fbd63f033b89 + } else { + // Avoid implicitly creating references to undefined functions + build.flag("-Werror=implicit-function-declaration"); + } + } + + // int_util.c tries to include stdlib.h if `_WIN32` is defined, + // which it is when compiling UEFI targets with clang. This is + // at odds with compiling with `-ffreestanding`, as the header + // may be incompatible or not present. Create a minimal stub + // header to use instead. + if cfg.target_os == "uefi" { + let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); + let include_dir = out_dir.join("include"); + if !include_dir.exists() { + fs::create_dir(&include_dir).unwrap(); + } + fs::write(include_dir.join("stdlib.h"), "#include ").unwrap(); + build.flag(&format!("-I{}", include_dir.to_str().unwrap())); + } + + let mut sources = Sources::new(); + sources.extend(&[ + ("__absvdi2", "absvdi2.c"), + ("__absvsi2", "absvsi2.c"), + ("__addvdi3", "addvdi3.c"), + ("__addvsi3", "addvsi3.c"), + ("__cmpdi2", "cmpdi2.c"), + ("__int_util", "int_util.c"), + ("__mulvdi3", "mulvdi3.c"), + ("__mulvsi3", "mulvsi3.c"), + ("__negdi2", "negdi2.c"), + ("__negvdi2", "negvdi2.c"), + ("__negvsi2", "negvsi2.c"), + ("__paritydi2", "paritydi2.c"), + ("__paritysi2", "paritysi2.c"), + ("__popcountdi2", "popcountdi2.c"), + ("__popcountsi2", "popcountsi2.c"), + ("__subvdi3", "subvdi3.c"), + ("__subvsi3", "subvsi3.c"), + ("__ucmpdi2", "ucmpdi2.c"), + ]); + + if consider_float_intrinsics { + sources.extend(&[ + ("__divdc3", "divdc3.c"), + ("__divsc3", "divsc3.c"), + ("__muldc3", "muldc3.c"), + ("__mulsc3", "mulsc3.c"), + ("__negdf2", "negdf2.c"), + ("__negsf2", "negsf2.c"), + ]); + } + + // On iOS and 32-bit OSX these are all just empty intrinsics, no need to + // include them. + if cfg.target_vendor != "apple" || cfg.target_arch != "x86" { + sources.extend(&[ + ("__absvti2", "absvti2.c"), + ("__addvti3", "addvti3.c"), + ("__cmpti2", "cmpti2.c"), + ("__ffsti2", "ffsti2.c"), + ("__mulvti3", "mulvti3.c"), + ("__negti2", "negti2.c"), + ("__parityti2", "parityti2.c"), + ("__popcountti2", "popcountti2.c"), + ("__subvti3", "subvti3.c"), + ("__ucmpti2", "ucmpti2.c"), + ]); + + if consider_float_intrinsics { + sources.extend(&[("__negvti2", "negvti2.c")]); + } + } + + if cfg.target_vendor == "apple" { + sources.extend(&[ + ("atomic_flag_clear", "atomic_flag_clear.c"), + ("atomic_flag_clear_explicit", "atomic_flag_clear_explicit.c"), + ("atomic_flag_test_and_set", "atomic_flag_test_and_set.c"), + ( + "atomic_flag_test_and_set_explicit", + "atomic_flag_test_and_set_explicit.c", + ), + ("atomic_signal_fence", "atomic_signal_fence.c"), + ("atomic_thread_fence", "atomic_thread_fence.c"), + ]); + } + + if cfg.target_env != "msvc" { + if cfg.target_arch == "x86" { + sources.extend(&[ + ("__ashldi3", "i386/ashldi3.S"), + ("__ashrdi3", "i386/ashrdi3.S"), + ("__divdi3", "i386/divdi3.S"), + ("__lshrdi3", "i386/lshrdi3.S"), + ("__moddi3", "i386/moddi3.S"), + ("__muldi3", "i386/muldi3.S"), + ("__udivdi3", "i386/udivdi3.S"), + ("__umoddi3", "i386/umoddi3.S"), + ]); + } + } + + if cfg.target_arch == "arm" && cfg.target_vendor != "apple" && cfg.target_env != "msvc" { + sources.extend(&[ + ("__aeabi_div0", "arm/aeabi_div0.c"), + ("__aeabi_drsub", "arm/aeabi_drsub.c"), + ("__aeabi_frsub", "arm/aeabi_frsub.c"), + ("__bswapdi2", "arm/bswapdi2.S"), + ("__bswapsi2", "arm/bswapsi2.S"), + ("__divmodsi4", "arm/divmodsi4.S"), + ("__divsi3", "arm/divsi3.S"), + ("__modsi3", "arm/modsi3.S"), + ("__switch16", "arm/switch16.S"), + ("__switch32", "arm/switch32.S"), + ("__switch8", "arm/switch8.S"), + ("__switchu8", "arm/switchu8.S"), + ("__sync_synchronize", "arm/sync_synchronize.S"), + ("__udivmodsi4", "arm/udivmodsi4.S"), + ("__udivsi3", "arm/udivsi3.S"), + ("__umodsi3", "arm/umodsi3.S"), + ]); + + if cfg.target_os == "freebsd" { + sources.extend(&[("__clear_cache", "clear_cache.c")]); + } + + // First of all aeabi_cdcmp and aeabi_cfcmp are never called by LLVM. + // Second are little-endian only, so build fail on big-endian targets. + // Temporally workaround: exclude these files for big-endian targets. + if !llvm_target[0].starts_with("thumbeb") && !llvm_target[0].starts_with("armeb") { + sources.extend(&[ + ("__aeabi_cdcmp", "arm/aeabi_cdcmp.S"), + ("__aeabi_cdcmpeq_check_nan", "arm/aeabi_cdcmpeq_check_nan.c"), + ("__aeabi_cfcmp", "arm/aeabi_cfcmp.S"), + ("__aeabi_cfcmpeq_check_nan", "arm/aeabi_cfcmpeq_check_nan.c"), + ]); + } + } + + if llvm_target[0] == "armv7" { + sources.extend(&[ + ("__sync_fetch_and_add_4", "arm/sync_fetch_and_add_4.S"), + ("__sync_fetch_and_add_8", "arm/sync_fetch_and_add_8.S"), + ("__sync_fetch_and_and_4", "arm/sync_fetch_and_and_4.S"), + ("__sync_fetch_and_and_8", "arm/sync_fetch_and_and_8.S"), + ("__sync_fetch_and_max_4", "arm/sync_fetch_and_max_4.S"), + ("__sync_fetch_and_max_8", "arm/sync_fetch_and_max_8.S"), + ("__sync_fetch_and_min_4", "arm/sync_fetch_and_min_4.S"), + ("__sync_fetch_and_min_8", "arm/sync_fetch_and_min_8.S"), + ("__sync_fetch_and_nand_4", "arm/sync_fetch_and_nand_4.S"), + ("__sync_fetch_and_nand_8", "arm/sync_fetch_and_nand_8.S"), + ("__sync_fetch_and_or_4", "arm/sync_fetch_and_or_4.S"), + ("__sync_fetch_and_or_8", "arm/sync_fetch_and_or_8.S"), + ("__sync_fetch_and_sub_4", "arm/sync_fetch_and_sub_4.S"), + ("__sync_fetch_and_sub_8", "arm/sync_fetch_and_sub_8.S"), + ("__sync_fetch_and_umax_4", "arm/sync_fetch_and_umax_4.S"), + ("__sync_fetch_and_umax_8", "arm/sync_fetch_and_umax_8.S"), + ("__sync_fetch_and_umin_4", "arm/sync_fetch_and_umin_4.S"), + ("__sync_fetch_and_umin_8", "arm/sync_fetch_and_umin_8.S"), + ("__sync_fetch_and_xor_4", "arm/sync_fetch_and_xor_4.S"), + ("__sync_fetch_and_xor_8", "arm/sync_fetch_and_xor_8.S"), + ]); + } + + if llvm_target.last().unwrap().ends_with("eabihf") { + if !llvm_target[0].starts_with("thumbv7em") + && !llvm_target[0].starts_with("thumbv8m.main") + { + // The FPU option chosen for these architectures in cc-rs, ie: + // -mfpu=fpv4-sp-d16 for thumbv7em + // -mfpu=fpv5-sp-d16 for thumbv8m.main + // do not support double precision floating points conversions so the files + // that include such instructions are not included for these targets. + sources.extend(&[ + ("__fixdfsivfp", "arm/fixdfsivfp.S"), + ("__fixunsdfsivfp", "arm/fixunsdfsivfp.S"), + ("__floatsidfvfp", "arm/floatsidfvfp.S"), + ("__floatunssidfvfp", "arm/floatunssidfvfp.S"), + ]); + } + + sources.extend(&[ + ("__fixsfsivfp", "arm/fixsfsivfp.S"), + ("__fixunssfsivfp", "arm/fixunssfsivfp.S"), + ("__floatsisfvfp", "arm/floatsisfvfp.S"), + ("__floatunssisfvfp", "arm/floatunssisfvfp.S"), + ("__floatunssisfvfp", "arm/floatunssisfvfp.S"), + ("__restore_vfp_d8_d15_regs", "arm/restore_vfp_d8_d15_regs.S"), + ("__save_vfp_d8_d15_regs", "arm/save_vfp_d8_d15_regs.S"), + ("__negdf2vfp", "arm/negdf2vfp.S"), + ("__negsf2vfp", "arm/negsf2vfp.S"), + ]); + } + + if (cfg.target_arch == "aarch64" || cfg.target_arch == "arm64ec") + && consider_float_intrinsics + { + sources.extend(&[ + ("__fe_getround", "fp_mode.c"), + ("__fe_raise_inexact", "fp_mode.c"), + ]); + + if cfg.target_os != "windows" && cfg.target_os != "cygwin" { + sources.extend(&[("__multc3", "multc3.c")]); + } + } + + if cfg.target_arch == "mips" || cfg.target_arch == "riscv32" || cfg.target_arch == "riscv64" + { + sources.extend(&[("__bswapsi2", "bswapsi2.c")]); + } + + if cfg.target_arch == "mips64" { + sources.extend(&[("__fe_getround", "fp_mode.c")]); + } + + if cfg.target_arch == "loongarch64" { + sources.extend(&[("__fe_getround", "fp_mode.c")]); + } + + // Remove the assembly implementations that won't compile for the target + if llvm_target[0] == "thumbv6m" + || llvm_target[0] == "thumbv8m.base" + || cfg.target_os == "uefi" + { + let mut to_remove = Vec::new(); + for (k, v) in sources.map.iter() { + if v.ends_with(".S") { + to_remove.push(*k); + } + } + sources.remove(&to_remove); + } + + if llvm_target[0] == "thumbv7m" || llvm_target[0] == "thumbv7em" { + sources.remove(&["__aeabi_cdcmp", "__aeabi_cfcmp"]); + } + + // Android and Cygwin uses emulated TLS so we need a runtime support function. + if cfg.target_os == "android" || cfg.target_os == "cygwin" { + sources.extend(&[("__emutls_get_address", "emutls.c")]); + } + + // Work around a bug in the NDK headers (fixed in + // https://r.android.com/2038949 which will be released in a future + // NDK version) by providing a definition of LONG_BIT. + if cfg.target_os == "android" { + build.define("LONG_BIT", "(8 * sizeof(long))"); + } + + // OpenHarmony also uses emulated TLS. + if cfg.target_env == "ohos" { + sources.extend(&[("__emutls_get_address", "emutls.c")]); + } + + // Optionally, link against a prebuilt llvm compiler-rt containing the builtins + // library. Only the builtins library is required. On many platforms, this is + // available as a library named libclang_rt.builtins.a. + let link_against_prebuilt_rt = env::var_os("LLVM_COMPILER_RT_LIB").is_some(); + + // When compiling the C code we require the user to tell us where the + // source code is, and this is largely done so when we're compiling as + // part of rust-lang/rust we can use the same llvm-project repository as + // rust-lang/rust. + let root = match env::var_os("RUST_COMPILER_RT_ROOT") { + Some(s) => PathBuf::from(s), + // If a prebuild libcompiler-rt is provided, set a valid + // path to simplify later logic. Nothing should be compiled. + None if link_against_prebuilt_rt => PathBuf::new(), + None => { + panic!( + "RUST_COMPILER_RT_ROOT is not set. You may need to run \ + `ci/download-compiler-rt.sh`." + ); + } + }; + if !link_against_prebuilt_rt && !root.exists() { + panic!("RUST_COMPILER_RT_ROOT={} does not exist", root.display()); + } + + // Support deterministic builds by remapping the __FILE__ prefix if the + // compiler supports it. This fixes the nondeterminism caused by the + // use of that macro in lib/builtins/int_util.h in compiler-rt. + build.flag_if_supported(&format!("-ffile-prefix-map={}=.", root.display())); + + // Include out-of-line atomics for aarch64, which are all generated by supplying different + // sets of flags to the same source file. + // Note: Out-of-line aarch64 atomics are not supported by the msvc toolchain (#430) and + // on uefi. + let src_dir = root.join("lib/builtins"); + if cfg.target_arch == "aarch64" && cfg.target_env != "msvc" && cfg.target_os != "uefi" { + // See below for why we're building these as separate libraries. + build_aarch64_out_of_line_atomics_libraries(&src_dir, build, link_against_prebuilt_rt); + + // Some run-time CPU feature detection is necessary, as well. + let cpu_model_src = if src_dir.join("cpu_model.c").exists() { + "cpu_model.c" + } else { + "cpu_model/aarch64.c" + }; + sources.extend(&[("__aarch64_have_lse_atomics", cpu_model_src)]); + } + + let mut added_sources = HashSet::new(); + for (sym, src) in sources.map.iter() { + let src = src_dir.join(src); + if !link_against_prebuilt_rt && added_sources.insert(src.clone()) { + build.file(&src); + println!("cargo:rerun-if-changed={}", src.display()); + } + println!("cargo:rustc-cfg={}=\"optimized-c\"", sym); + } + + if link_against_prebuilt_rt { + let rt_builtins_ext = PathBuf::from(env::var_os("LLVM_COMPILER_RT_LIB").unwrap()); + if !rt_builtins_ext.exists() { + panic!( + "LLVM_COMPILER_RT_LIB={} does not exist", + rt_builtins_ext.display() + ); + } + if let Some(dir) = rt_builtins_ext.parent() { + println!("cargo::rustc-link-search=native={}", dir.display()); + } + if let Some(lib) = rt_builtins_ext.file_name() { + println!( + "cargo::rustc-link-lib=static:+verbatim={}", + lib.to_str().unwrap() + ); + } + } else { + build.compile("libcompiler-rt.a"); + } + } + + fn build_aarch64_out_of_line_atomics_libraries( + builtins_dir: &Path, + cfg: &mut cc::Build, + link_against_prebuilt_rt: bool, + ) { + let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); + let outlined_atomics_file = builtins_dir.join("aarch64").join("lse.S"); + if !link_against_prebuilt_rt { + println!("cargo:rerun-if-changed={}", outlined_atomics_file.display()); + } + + cfg.include(&builtins_dir); + + for instruction_type in &["cas", "swp", "ldadd", "ldclr", "ldeor", "ldset"] { + for size in &[1, 2, 4, 8, 16] { + if *size == 16 && *instruction_type != "cas" { + continue; + } + + for (model_number, model_name) in + &[(1, "relax"), (2, "acq"), (3, "rel"), (4, "acq_rel")] + { + let sym = format!("__aarch64_{}{}_{}", instruction_type, size, model_name); + println!("cargo:rustc-cfg={}=\"optimized-c\"", sym); + + if link_against_prebuilt_rt { + continue; + } + + // The original compiler-rt build system compiles the same + // source file multiple times with different compiler + // options. Here we do something slightly different: we + // create multiple .S files with the proper #defines and + // then include the original file. + // + // This is needed because the cc crate doesn't allow us to + // override the name of object files and libtool requires + // all objects in an archive to have unique names. + let path = + out_dir.join(format!("lse_{}{}_{}.S", instruction_type, size, model_name)); + let mut file = File::create(&path).unwrap(); + writeln!(file, "#define L_{}", instruction_type).unwrap(); + writeln!(file, "#define SIZE {}", size).unwrap(); + writeln!(file, "#define MODEL {}", model_number).unwrap(); + writeln!( + file, + "#include \"{}\"", + outlined_atomics_file.canonicalize().unwrap().display() + ) + .unwrap(); + drop(file); + cfg.file(path); + } + } + } + } +} diff --git a/ci/licenses/musl-rust-originals/rust-3.txt b/ci/licenses/musl-rust-originals/rust-3.txt new file mode 100644 index 0000000..2c12cb7 --- /dev/null +++ b/ci/licenses/musl-rust-originals/rust-3.txt @@ -0,0 +1,17 @@ +intrinsics! { + #[unsafe(naked)] + #[cfg(any(all(windows, target_env = "gnu"), target_os = "uefi"))] + pub unsafe extern "custom" fn __chkstk() { + core::arch::naked_asm!( + ".p2align 2", + "lsl x16, x15, #4", + "mov x17, sp", + "1:", + "sub x17, x17, 4096", + "subs x16, x16, 4096", + "ldr xzr, [x17]", + "b.gt 1b", + "ret", + ); + } +} diff --git a/ci/licenses/musl-rust-originals/rust-4.txt b/ci/licenses/musl-rust-originals/rust-4.txt new file mode 100644 index 0000000..367768e --- /dev/null +++ b/ci/licenses/musl-rust-originals/rust-4.txt @@ -0,0 +1,467 @@ +//! Aarch64 targets have two possible implementations for atomics: +//! 1. Load-Locked, Store-Conditional (LL/SC), older and slower. +//! 2. Large System Extensions (LSE), newer and faster. +//! To avoid breaking backwards compat, C toolchains introduced a concept of "outlined atomics", +//! where atomic operations call into the compiler runtime to dispatch between two depending on +//! which is supported on the current CPU. +//! See for more discussion. +//! +//! Ported from `aarch64/lse.S` in LLVM's compiler-rt. +//! +//! Generate functions for each of the following symbols: +//! __aarch64_casM_ORDER +//! __aarch64_swpN_ORDER +//! __aarch64_ldaddN_ORDER +//! __aarch64_ldclrN_ORDER +//! __aarch64_ldeorN_ORDER +//! __aarch64_ldsetN_ORDER +//! for N = {1, 2, 4, 8}, M = {1, 2, 4, 8, 16}, ORDER = { relax, acq, rel, acq_rel } +//! +//! The original `lse.S` has some truly horrifying code that expects to be compiled multiple times with different constants. +//! We do something similar, but with macro arguments. +#![cfg_attr(feature = "c", allow(unused_macros))] // avoid putting the macros into a submodule + +use core::sync::atomic::{AtomicU8, Ordering}; + +/// non-zero if the host supports LSE atomics. +static HAVE_LSE_ATOMICS: AtomicU8 = AtomicU8::new(0); + +intrinsics! { + /// Call to enable LSE in outline atomic operations. The caller must verify + /// LSE operations are supported. + pub extern "C" fn __rust_enable_lse() { + HAVE_LSE_ATOMICS.store(1, Ordering::Relaxed); + } +} + +/// Function to enable/disable LSE. To be used only for testing purposes. +#[cfg(feature = "unstable-public-internals")] +pub unsafe fn set_have_lse_atomics(has_lse: bool) { + let lse_flag = if has_lse { 1 } else { 0 }; + HAVE_LSE_ATOMICS.store(lse_flag, Ordering::Relaxed); +} + +/// Function to obtain whether LSE is enabled or not. To be used only for testing purposes. +#[cfg(feature = "unstable-public-internals")] +pub fn get_have_lse_atomics() -> bool { + HAVE_LSE_ATOMICS.load(Ordering::Relaxed) != 0 +} + +/// Translate a byte size to a Rust type. +#[rustfmt::skip] +macro_rules! int_ty { + (1) => { u8 }; + (2) => { u16 }; + (4) => { u32 }; + (8) => { u64 }; + (16) => { u128 }; +} + +/// Given a byte size and a register number, return a register of the appropriate size. +/// +/// See . +#[rustfmt::skip] +macro_rules! reg { + (1, $num:literal) => { concat!("w", $num) }; + (2, $num:literal) => { concat!("w", $num) }; + (4, $num:literal) => { concat!("w", $num) }; + (8, $num:literal) => { concat!("x", $num) }; + (16, $num:literal) => { concat!("x", $num) }; +} + +/// Given an atomic ordering, translate it to the acquire suffix for the lxdr aarch64 ASM instruction. +#[rustfmt::skip] +macro_rules! acquire { + (Relaxed) => { "" }; + (Acquire) => { "a" }; + (Release) => { "" }; + (AcqRel) => { "a" }; +} + +/// Given an atomic ordering, translate it to the release suffix for the stxr aarch64 ASM instruction. +#[rustfmt::skip] +macro_rules! release { + (Relaxed) => { "" }; + (Acquire) => { "" }; + (Release) => { "l" }; + (AcqRel) => { "l" }; +} + +/// Given a size in bytes, translate it to the byte suffix for an aarch64 ASM instruction. +#[rustfmt::skip] +macro_rules! size { + (1) => { "b" }; + (2) => { "h" }; + (4) => { "" }; + (8) => { "" }; + (16) => { "" }; +} + +/// Given a byte size, translate it to an Unsigned eXTend instruction +/// with the correct semantics. +/// +/// See +#[rustfmt::skip] +macro_rules! uxt { + (1) => { "uxtb" }; + (2) => { "uxth" }; + ($_:tt) => { "mov" }; +} + +/// Given an atomic ordering and byte size, translate it to a LoaD eXclusive Register instruction +/// with the correct semantics. +/// +/// See . +macro_rules! ldxr { + ($ordering:ident, $bytes:tt) => { + concat!("ld", acquire!($ordering), "xr", size!($bytes)) + }; +} + +/// Given an atomic ordering and byte size, translate it to a STore eXclusive Register instruction +/// with the correct semantics. +/// +/// See . +macro_rules! stxr { + ($ordering:ident, $bytes:tt) => { + concat!("st", release!($ordering), "xr", size!($bytes)) + }; +} + +/// Given an atomic ordering and byte size, translate it to a LoaD eXclusive Pair of registers instruction +/// with the correct semantics. +/// +/// See +macro_rules! ldxp { + ($ordering:ident) => { + concat!("ld", acquire!($ordering), "xp") + }; +} + +/// Given an atomic ordering and byte size, translate it to a STore eXclusive Pair of registers instruction +/// with the correct semantics. +/// +/// See . +macro_rules! stxp { + ($ordering:ident) => { + concat!("st", release!($ordering), "xp") + }; +} + +// The AArch64 assembly syntax for relocation specifiers +// when accessing symbols changes depending on the target executable format. +// In ELF (used in Linux), we have a prefix notation surrounded by colons (:specifier:sym), +// while in Mach-O object files (used in MacOS), a postfix notation is used (sym@specifier). + +/// AArch64 ELF position-independent addressing: +/// +/// adrp xN, symbol +/// add xN, xN, :lo12:symbol +/// +/// The :lo12: modifier selects the low 12 bits of the symbol address +/// and emits an ELF relocation such as R_AARCH64_ADD_ABS_LO12_NC. +/// +/// Defined by the AArch64 ELF psABI. +/// See: . +#[cfg(not(target_vendor = "apple"))] +macro_rules! sym { + ($sym:literal) => { + $sym + }; +} + +#[cfg(not(target_vendor = "apple"))] +macro_rules! sym_off { + ($sym:literal) => { + concat!(":lo12:", $sym) + }; +} + +/// Mach-O ARM64 relocation types: +/// ARM64_RELOC_PAGE21 +/// ARM64_RELOC_PAGEOFF12 +/// +/// These relocations implement the @PAGE / @PAGEOFF split used by +/// adrp + add sequences on Apple platforms. +/// +/// adrp xN, symbol@PAGE -> ARM64_RELOC_PAGE21 +/// add xN, xN, symbol@PAGEOFF -> ARM64_RELOC_PAGEOFF12 +/// +/// Relocation types defined by Apple in XNU: . +/// See: . +#[cfg(target_vendor = "apple")] +macro_rules! sym { + ($sym:literal) => { + concat!($sym, "@PAGE") + }; +} + +#[cfg(target_vendor = "apple")] +macro_rules! sym_off { + ($sym:literal) => { + concat!($sym, "@PAGEOFF") + }; +} + +// If supported, perform the requested LSE op and return, or fallthrough. +macro_rules! try_lse_op { + ($op: literal, $ordering:ident, $bytes:tt, $($reg:literal,)* [ $mem:ident ] ) => { + concat!( + ".arch_extension lse\n", + concat!("adrp x16, ", sym!("{have_lse}"), "\n"), + concat!("ldrb w16, [x16, ", sym_off!("{have_lse}"), "]\n"), + "cbz w16, 8f\n", + // LSE_OP s(reg),* [$mem] + concat!(lse!($op, $ordering, $bytes), $( " ", reg!($bytes, $reg), ", " ,)* "[", stringify!($mem), "]\n",), + "ret + 8:" + ) + }; +} + +// Translate memory ordering to the LSE suffix +#[rustfmt::skip] +macro_rules! lse_mem_sfx { + (Relaxed) => { "" }; + (Acquire) => { "a" }; + (Release) => { "l" }; + (AcqRel) => { "al" }; +} + +// Generate the aarch64 LSE operation for memory ordering and width +macro_rules! lse { + ($op:literal, $order:ident, 16) => { + concat!($op, "p", lse_mem_sfx!($order)) + }; + ($op:literal, $order:ident, $bytes:tt) => { + concat!($op, lse_mem_sfx!($order), size!($bytes)) + }; +} + +/// See . +macro_rules! compare_and_swap { + ($ordering:ident, $bytes:tt, $name:ident) => { + intrinsics! { + #[maybe_use_optimized_c_shim] + #[unsafe(naked)] + pub unsafe extern "C" fn $name ( + expected: int_ty!($bytes), desired: int_ty!($bytes), ptr: *mut int_ty!($bytes) + ) -> int_ty!($bytes) { + // We can't use `AtomicI8::compare_and_swap`; we *are* compare_and_swap. + core::arch::naked_asm! { + // CAS s(0), s(1), [x2]; if LSE supported. + try_lse_op!("cas", $ordering, $bytes, 0, 1, [x2]), + // UXT s(tmp0), s(0) + concat!(uxt!($bytes), " ", reg!($bytes, 16), ", ", reg!($bytes, 0)), + "0:", + // LDXR s(0), [x2] + concat!(ldxr!($ordering, $bytes), " ", reg!($bytes, 0), ", [x2]"), + // cmp s(0), s(tmp0) + concat!("cmp ", reg!($bytes, 0), ", ", reg!($bytes, 16)), + "bne 1f", + // STXR w(tmp1), s(1), [x2] + concat!(stxr!($ordering, $bytes), " w17, ", reg!($bytes, 1), ", [x2]"), + "cbnz w17, 0b", + "1:", + "ret", + have_lse = sym crate::aarch64_outline_atomics::HAVE_LSE_ATOMICS, + } + } + } + }; +} + +// u128 uses a completely different impl, so it has its own macro. +macro_rules! compare_and_swap_u128 { + ($ordering:ident, $name:ident) => { + intrinsics! { + #[maybe_use_optimized_c_shim] + #[unsafe(naked)] + pub unsafe extern "C" fn $name ( + expected: u128, desired: u128, ptr: *mut u128 + ) -> u128 { + core::arch::naked_asm! { + // CASP x0, x1, x2, x3, [x4]; if LSE supported. + try_lse_op!("cas", $ordering, 16, 0, 1, 2, 3, [x4]), + "mov x16, x0", + "mov x17, x1", + "0:", + // LDXP x0, x1, [x4] + concat!(ldxp!($ordering), " x0, x1, [x4]"), + "cmp x0, x16", + "ccmp x1, x17, #0, eq", + "bne 1f", + // STXP w(tmp2), x2, x3, [x4] + concat!(stxp!($ordering), " w15, x2, x3, [x4]"), + "cbnz w15, 0b", + "1:", + "ret", + have_lse = sym crate::aarch64_outline_atomics::HAVE_LSE_ATOMICS, + } + } + } + }; +} + +/// See . +macro_rules! swap { + ($ordering:ident, $bytes:tt, $name:ident) => { + intrinsics! { + #[maybe_use_optimized_c_shim] + #[unsafe(naked)] + pub unsafe extern "C" fn $name ( + left: int_ty!($bytes), right_ptr: *mut int_ty!($bytes) + ) -> int_ty!($bytes) { + core::arch::naked_asm! { + // SWP s(0), s(0), [x1]; if LSE supported. + try_lse_op!("swp", $ordering, $bytes, 0, 0, [x1]), + // mov s(tmp0), s(0) + concat!("mov ", reg!($bytes, 16), ", ", reg!($bytes, 0)), + "0:", + // LDXR s(0), [x1] + concat!(ldxr!($ordering, $bytes), " ", reg!($bytes, 0), ", [x1]"), + // STXR w(tmp1), s(tmp0), [x1] + concat!(stxr!($ordering, $bytes), " w17, ", reg!($bytes, 16), ", [x1]"), + "cbnz w17, 0b", + "ret", + have_lse = sym crate::aarch64_outline_atomics::HAVE_LSE_ATOMICS, + } + } + } + }; +} + +/// See (e.g.) . +macro_rules! fetch_op { + ($ordering:ident, $bytes:tt, $name:ident, $op:literal, $lse_op:literal) => { + intrinsics! { + #[maybe_use_optimized_c_shim] + #[unsafe(naked)] + pub unsafe extern "C" fn $name ( + val: int_ty!($bytes), ptr: *mut int_ty!($bytes) + ) -> int_ty!($bytes) { + core::arch::naked_asm! { + // LSEOP s(0), s(0), [x1]; if LSE supported. + try_lse_op!($lse_op, $ordering, $bytes, 0, 0, [x1]), + // mov s(tmp0), s(0) + concat!("mov ", reg!($bytes, 16), ", ", reg!($bytes, 0)), + "0:", + // LDXR s(0), [x1] + concat!(ldxr!($ordering, $bytes), " ", reg!($bytes, 0), ", [x1]"), + // OP s(tmp1), s(0), s(tmp0) + concat!($op, " ", reg!($bytes, 17), ", ", reg!($bytes, 0), ", ", reg!($bytes, 16)), + // STXR w(tmp2), s(tmp1), [x1] + concat!(stxr!($ordering, $bytes), " w15, ", reg!($bytes, 17), ", [x1]"), + "cbnz w15, 0b", + "ret", + have_lse = sym crate::aarch64_outline_atomics::HAVE_LSE_ATOMICS, + } + } + } + } +} + +// We need a single macro to pass to `foreach_ldadd`. +macro_rules! add { + ($ordering:ident, $bytes:tt, $name:ident) => { + fetch_op! { $ordering, $bytes, $name, "add", "ldadd" } + }; +} + +macro_rules! and { + ($ordering:ident, $bytes:tt, $name:ident) => { + fetch_op! { $ordering, $bytes, $name, "bic", "ldclr" } + }; +} + +macro_rules! xor { + ($ordering:ident, $bytes:tt, $name:ident) => { + fetch_op! { $ordering, $bytes, $name, "eor", "ldeor" } + }; +} + +macro_rules! or { + ($ordering:ident, $bytes:tt, $name:ident) => { + fetch_op! { $ordering, $bytes, $name, "orr", "ldset" } + }; +} + +#[macro_export] +macro_rules! foreach_ordering { + ($macro:path, $bytes:tt, $name:ident) => { + $macro!( Relaxed, $bytes, ${concat($name, _relax)} ); + $macro!( Acquire, $bytes, ${concat($name, _acq)} ); + $macro!( Release, $bytes, ${concat($name, _rel)} ); + $macro!( AcqRel, $bytes, ${concat($name, _acq_rel)} ); + }; + ($macro:path, $name:ident) => { + $macro!( Relaxed, ${concat($name, _relax)} ); + $macro!( Acquire, ${concat($name, _acq)} ); + $macro!( Release, ${concat($name, _rel)} ); + $macro!( AcqRel, ${concat($name, _acq_rel)} ); + }; +} + +#[macro_export] +macro_rules! foreach_bytes { + ($macro:path, $name:ident) => { + foreach_ordering!( $macro, 1, ${concat(__aarch64_, $name, "1")} ); + foreach_ordering!( $macro, 2, ${concat(__aarch64_, $name, "2")} ); + foreach_ordering!( $macro, 4, ${concat(__aarch64_, $name, "4")} ); + foreach_ordering!( $macro, 8, ${concat(__aarch64_, $name, "8")} ); + }; +} + +/// Generate different macros for cas/swp/add/clr/eor/set so that we can test them separately. +#[macro_export] +macro_rules! foreach_cas { + ($macro:path) => { + foreach_bytes!($macro, cas); + }; +} + +/// Only CAS supports 16 bytes, and it has a different implementation that uses a different macro. +#[macro_export] +macro_rules! foreach_cas16 { + ($macro:path) => { + foreach_ordering!($macro, __aarch64_cas16); + }; +} +#[macro_export] +macro_rules! foreach_swp { + ($macro:path) => { + foreach_bytes!($macro, swp); + }; +} +#[macro_export] +macro_rules! foreach_ldadd { + ($macro:path) => { + foreach_bytes!($macro, ldadd); + }; +} +#[macro_export] +macro_rules! foreach_ldclr { + ($macro:path) => { + foreach_bytes!($macro, ldclr); + }; +} +#[macro_export] +macro_rules! foreach_ldeor { + ($macro:path) => { + foreach_bytes!($macro, ldeor); + }; +} +#[macro_export] +macro_rules! foreach_ldset { + ($macro:path) => { + foreach_bytes!($macro, ldset); + }; +} + +foreach_cas!(compare_and_swap); +foreach_cas16!(compare_and_swap_u128); +foreach_swp!(swap); +foreach_ldadd!(add); +foreach_ldclr!(and); +foreach_ldeor!(xor); +foreach_ldset!(or); diff --git a/ci/licenses/musl-rust-originals/rust-9.txt b/ci/licenses/musl-rust-originals/rust-9.txt new file mode 100644 index 0000000..3dfa386 --- /dev/null +++ b/ci/licenses/musl-rust-originals/rust-9.txt @@ -0,0 +1,211 @@ +#[rustfmt::skip] +#[allow(dead_code)] +#[allow(unused_imports)] +#[allow(clippy::all)] +#[path = "../../../libm/src/math/mod.rs"] +pub(crate) mod libm_math; + +macro_rules! libm_intrinsics { + ($(fn $fun:ident($($iid:ident : $ity:ty),+) -> $oty:ty;)+) => { + intrinsics! { + $( + pub extern "C" fn $fun($($iid: $ity),+) -> $oty { + $crate::math::libm_math::$fun($($iid),+) + } + )+ + } + } +} + +/// This set of functions is well tested in `libm` and known to provide similar performance to +/// system `libm`, as well as the same or better accuracy. +pub mod full_availability { + #[cfg(f16_enabled)] + libm_intrinsics! { + fn ceilf16(x: f16) -> f16; + fn copysignf16(x: f16, y: f16) -> f16; + fn fabsf16(x: f16) -> f16; + fn fdimf16(x: f16, y: f16) -> f16; + fn floorf16(x: f16) -> f16; + fn fmaxf16(x: f16, y: f16) -> f16; + fn fmaximum_numf16(x: f16, y: f16) -> f16; + fn fmaximumf16(x: f16, y: f16) -> f16; + fn fminf16(x: f16, y: f16) -> f16; + fn fminimum_numf16(x: f16, y: f16) -> f16; + fn fminimumf16(x: f16, y: f16) -> f16; + fn fmodf16(x: f16, y: f16) -> f16; + fn rintf16(x: f16) -> f16; + fn roundevenf16(x: f16) -> f16; + fn roundf16(x: f16) -> f16; + fn sqrtf16(x: f16) -> f16; + fn truncf16(x: f16) -> f16; + } + + /* Weak linkage is unreliable on Windows and Apple, so we don't expose symbols that we know + * the system libc provides in order to avoid conflicts. */ + + #[cfg(all(not(windows), not(target_vendor = "apple")))] + libm_intrinsics! { + /* f32 */ + fn cbrtf(n: f32) -> f32; + fn ceilf(x: f32) -> f32; + fn copysignf(x: f32, y: f32) -> f32; + fn fabsf(x: f32) -> f32; + fn fdimf(a: f32, b: f32) -> f32; + fn floorf(x: f32) -> f32; + fn fmaf(x: f32, y: f32, z: f32) -> f32; + fn fmaxf(x: f32, y: f32) -> f32; + fn fminf(x: f32, y: f32) -> f32; + fn fmodf(x: f32, y: f32) -> f32; + fn rintf(x: f32) -> f32; + fn roundf(x: f32) -> f32; + fn sqrtf(x: f32) -> f32; + fn truncf(x: f32) -> f32; + + /* f64 */ + fn cbrt(x: f64) -> f64; + fn ceil(x: f64) -> f64; + fn copysign(x: f64, y: f64) -> f64; + fn fabs(x: f64) -> f64; + fn fdim(a: f64, b: f64) -> f64; + fn floor(x: f64) -> f64; + fn fma(x: f64, y: f64, z: f64) -> f64; + fn fmax(x: f64, y: f64) -> f64; + fn fmin(x: f64, y: f64) -> f64; + fn fmod(x: f64, y: f64) -> f64; + fn rint(x: f64) -> f64; + fn round(x: f64) -> f64; + fn sqrt(x: f64) -> f64; + fn trunc(x: f64) -> f64; + } + + // Windows and MacOS do not yet expose roundeven and IEEE 754-2019 `maximum` / `minimum`, + // however, so we still provide a fallback. + libm_intrinsics! { + fn fmaximum(x: f64, y: f64) -> f64; + fn fmaximum_num(x: f64, y: f64) -> f64; + fn fmaximum_numf(x: f32, y: f32) -> f32; + fn fmaximumf(x: f32, y: f32) -> f32; + fn fminimum(x: f64, y: f64) -> f64; + fn fminimum_num(x: f64, y: f64) -> f64; + fn fminimum_numf(x: f32, y: f32) -> f32; + fn fminimumf(x: f32, y: f32) -> f32; + fn roundeven(x: f64) -> f64; + fn roundevenf(x: f32) -> f32; + } + + #[cfg(f128_enabled)] + libm_intrinsics! { + fn ceilf128(x: f128) -> f128; + fn copysignf128(x: f128, y: f128) -> f128; + fn fabsf128(x: f128) -> f128; + fn fdimf128(x: f128, y: f128) -> f128; + fn floorf128(x: f128) -> f128; + fn fmaf128(x: f128, y: f128, z: f128) -> f128; + fn fmaxf128(x: f128, y: f128) -> f128; + fn fmaximum_numf128(x: f128, y: f128) -> f128; + fn fmaximumf128(x: f128, y: f128) -> f128; + fn fminf128(x: f128, y: f128) -> f128; + fn fminimum_numf128(x: f128, y: f128) -> f128; + fn fminimumf128(x: f128, y: f128) -> f128; + fn fmodf128(x: f128, y: f128) -> f128; + fn rintf128(x: f128) -> f128; + fn roundevenf128(x: f128) -> f128; + fn roundf128(x: f128) -> f128; + fn sqrtf128(x: f128) -> f128; + fn truncf128(x: f128) -> f128; + } +} + +/// This group of functions has more performance or precision issues than system versions, or +/// are otherwise less well tested. Provide them only on platforms that have problems with the +/// system `libm`. +/// +/// As `libm` improves, more functions will be moved from this group to the first group. +/// +/// Do not supply for any of the following: +/// - x86 without sse2 due to ABI issues +/// - +/// - but exclude UEFI since it is a soft-float target +/// - +/// - All unix targets (linux, macos, freebsd, android, etc) +/// - wasm with known target_os +#[cfg(not(any( + all( + target_arch = "x86", + not(target_feature = "sse2"), + not(target_os = "uefi"), + ), + unix, + all(target_family = "wasm", not(target_os = "unknown")) +)))] +pub mod partial_availability { + #[cfg(not(windows))] + libm_intrinsics! { + fn acos(x: f64) -> f64; + fn acosf(n: f32) -> f32; + fn acosh(x: f64) -> f64; + fn acoshf(x: f32) -> f32; + fn asin(x: f64) -> f64; + fn asinf(n: f32) -> f32; + fn asinh(x: f64) -> f64; + fn asinhf(x: f32) -> f32; + fn atan(x: f64) -> f64; + fn atan2(x: f64, y: f64) -> f64; + fn atan2f(a: f32, b: f32) -> f32; + fn atanf(n: f32) -> f32; + fn cos(x: f64) -> f64; + fn cosf(x: f32) -> f32; + fn cosh(x: f64) -> f64; + fn coshf(n: f32) -> f32; + fn erf(x: f64) -> f64; + fn erfc(x: f64) -> f64; + fn erfcf(x: f32) -> f32; + fn erff(x: f32) -> f32; + fn exp(x: f64) -> f64; + fn exp2(x: f64) -> f64; + fn exp2f(x: f32) -> f32; + fn expf(x: f32) -> f32; + fn expm1(x: f64) -> f64; + fn expm1f(n: f32) -> f32; + fn hypot(x: f64, y: f64) -> f64; + fn hypotf(x: f32, y: f32) -> f32; + fn ldexp(f: f64, n: i32) -> f64; + fn ldexpf(f: f32, n: i32) -> f32; + fn log(x: f64) -> f64; + fn log10(x: f64) -> f64; + fn log10f(x: f32) -> f32; + fn log1p(x: f64) -> f64; + fn log1pf(n: f32) -> f32; + fn log2(x: f64) -> f64; + fn log2f(x: f32) -> f32; + fn logf(x: f32) -> f32; + fn pow(x: f64, y: f64) -> f64; + fn powf(x: f32, y: f32) -> f32; + fn sin(x: f64) -> f64; + fn sinf(x: f32) -> f32; + fn sinh(x: f64) -> f64; + fn sinhf(n: f32) -> f32; + fn tan(x: f64) -> f64; + fn tanf(n: f32) -> f32; + fn tanh(x: f64) -> f64; + fn tanhf(n: f32) -> f32; + fn tgamma(x: f64) -> f64; + fn tgammaf(x: f32) -> f32; + } + + // allow for windows (and other targets) + intrinsics! { + pub extern "C" fn lgamma_r(x: f64, s: &mut i32) -> f64 { + let r = super::libm_math::lgamma_r(x); + *s = r.1; + r.0 + } + + pub extern "C" fn lgammaf_r(x: f32, s: &mut i32) -> f32 { + let r = super::libm_math::lgammaf_r(x); + *s = r.1; + r.0 + } + } +} diff --git a/ci/licenses/musl-rust-originals/rust-generic-trunc.txt b/ci/licenses/musl-rust-originals/rust-generic-trunc.txt new file mode 100644 index 0000000..0b252fa --- /dev/null +++ b/ci/licenses/musl-rust-originals/rust-generic-trunc.txt @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: MIT + * origin: musl src/math/trunc.c */ + +use crate::support::{Float, FpResult, Int, IntTy, MinInt, Status}; + +#[inline] +pub fn trunc_status(x: F) -> FpResult { + let xi: F::Int = x.to_bits(); + let e: i32 = x.exp_unbiased(); + + // The represented value has no fractional part, so no truncation is needed + if e >= F::SIG_BITS as i32 { + return FpResult::ok(x); + } + + let clear_mask = if e < 0 { + // If the exponent is negative, the result will be zero so we clear everything + // except the sign. + !F::SIGN_MASK + } else { + // Otherwise, we keep `e` fractional bits and clear the rest. + F::SIG_MASK >> e.unsigned() + }; + + let cleared = xi & clear_mask; + let status = if cleared == IntTy::::ZERO { + // If the to-be-zeroed portion is already zero, we have an exact result. + Status::OK + } else { + // Otherwise the result is inexact and we will truncate, so indicate `FE_INEXACT`. + Status::INEXACT + }; + + // Now zero the bits we need to truncate and return. + FpResult::new(F::from_bits(xi ^ cleared), status) +} diff --git a/ci/musl-retained-runtime.json b/ci/musl-retained-runtime.json new file mode 100644 index 0000000..d1013a5 --- /dev/null +++ b/ci/musl-retained-runtime.json @@ -0,0 +1,293 @@ +{ + "coverage": "Exact per-target/per-role retained input policy plus complete original Rust compiler-builtins/LLVM/libm materials. Does not assert every material source line survived optimization or coverage of other toolchain versions.", + "llvm_revision": "1b9c0d5ff9bbe7634aead059efe6b11a7eeba145", + "materials": [ + { + "bytes": 15078, + "git_blob": "00ae6140bd54e1b538d833f60438e11ed8be12cf", + "legal_document": true, + "path": "ci/licenses/musl-rust-originals/rust-0.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "rust-0", + "sha256": "ab6eec6caf0fa5775e411c7a8bc6a45c4ef2956b0980b157ab74fc5cd62a928b", + "upstream_path": "library/compiler-builtins/LICENSE.txt" + }, + { + "bytes": 2005, + "git_blob": "b2f1443f2eb09d297b62c7b44fce9e31d71b10a2", + "legal_document": false, + "path": "ci/licenses/musl-rust-originals/rust-1.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "rust-1", + "sha256": "d89e31fed70f2cad9c6e91b787bf4c0fb680c631196b2a7215c81745aaf7fb7e", + "upstream_path": "library/compiler-builtins/compiler-builtins/Cargo.toml" + }, + { + "bytes": 27313, + "git_blob": "e86c784b5c6317a53e9ff89104b15e60ba7ac4bf", + "legal_document": false, + "path": "ci/licenses/musl-rust-originals/rust-2.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "rust-2", + "sha256": "dd1d07d0852fd6a654c69d6dafd8ae66744853cb5678610008dbf6ae6baec11e", + "upstream_path": "library/compiler-builtins/compiler-builtins/build.rs" + }, + { + "bytes": 463, + "git_blob": "2c12cb7f3095b2ace3938a666ebd1b607b8a269c", + "legal_document": false, + "path": "ci/licenses/musl-rust-originals/rust-3.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "rust-3", + "sha256": "5acb367779a8e6e6e06e188e715d6d2ff76b9c3208acd899e139957bd1d3c877", + "upstream_path": "library/compiler-builtins/compiler-builtins/src/aarch64.rs" + }, + { + "bytes": 16463, + "git_blob": "367768ecb60d65069679b3c84a9ef932c5ab6962", + "legal_document": false, + "path": "ci/licenses/musl-rust-originals/rust-4.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "rust-4", + "sha256": "d2e6ed0066ac36db55dfaa245bdc814353456dda92437aba539cc828d2011ae9", + "upstream_path": "library/compiler-builtins/compiler-builtins/src/aarch64_outline_atomics.rs" + }, + { + "bytes": 5851, + "git_blob": "a444d82892c36f8c1e3ba5f1977638d56fb929f8", + "legal_document": false, + "path": "ci/licenses/musl-rust-originals/llvm-5.txt", + "repository": "rust-lang/llvm-project", + "revision": "1b9c0d5ff9bbe7634aead059efe6b11a7eeba145", + "role": "llvm-5", + "sha256": "dcd05cb984ef8d777642eb960e3ef61b1140f268c3e4744f8f738aa46fd8ed66", + "upstream_path": "compiler-rt/lib/builtins/aarch64/lse.S" + }, + { + "bytes": 3026, + "git_blob": "347bb4e121c97c98aa6e7440b1c952978bfedc9b", + "legal_document": false, + "path": "ci/licenses/musl-rust-originals/llvm-6.txt", + "repository": "rust-lang/llvm-project", + "revision": "1b9c0d5ff9bbe7634aead059efe6b11a7eeba145", + "role": "llvm-6", + "sha256": "405b2ad2520db341af1338be2e58cce9d28a9f63006486d1c9572f4fe10ae032", + "upstream_path": "compiler-rt/lib/builtins/cpu_model/aarch64.c" + }, + { + "bytes": 16708, + "git_blob": "5a79a1b9d5cb0af9a779751f07033e44ca3b14d8", + "legal_document": true, + "path": "ci/licenses/musl-rust-originals/llvm-7.txt", + "repository": "rust-lang/llvm-project", + "revision": "1b9c0d5ff9bbe7634aead059efe6b11a7eeba145", + "role": "llvm-7", + "sha256": "1a8f1058753f1ba890de984e48f0242a3a5c29a6a8f2ed9fd813f36985387e8d", + "upstream_path": "compiler-rt/LICENSE.TXT" + }, + { + "bytes": 1049, + "git_blob": "6964eba020b8aa7a08629b249e3b9aea3ce3e448", + "legal_document": true, + "path": "ci/licenses/musl-rust-originals/llvm-8.txt", + "repository": "rust-lang/llvm-project", + "revision": "1b9c0d5ff9bbe7634aead059efe6b11a7eeba145", + "role": "llvm-8", + "sha256": "a9901f47a089da41e4690682d00ce4cedaa2baf41fedbe79beee366d43ac2461", + "upstream_path": "compiler-rt/CREDITS.TXT" + }, + { + "bytes": 7270, + "git_blob": "3dfa3863bb77007fbec01b7c931bf1c349953d11", + "legal_document": false, + "path": "ci/licenses/musl-rust-originals/rust-9.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "rust-9", + "sha256": "a3ff615e04d9ae9a0bb36cfbfd9a0aaf183ab6e32ddfe836cdf4f243f97a401e", + "upstream_path": "library/compiler-builtins/compiler-builtins/src/math/mod.rs" + }, + { + "bytes": 4407, + "git_blob": "9eb902ea578f87588d8236619a67ab7db72c8ba8", + "legal_document": false, + "path": "ci/licenses/musl-rust-originals/rust-10.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "rust-10", + "sha256": "ef59952a1a80ec93be27eb78c977189084ff7fcae0e8f782d60b5947e1de141c", + "upstream_path": "library/compiler-builtins/libm/src/math/trunc.rs" + }, + { + "bytes": 14088, + "git_blob": "2f8e41f147472510b05e0adeadf350df6f5a6b96", + "legal_document": true, + "path": "ci/licenses/musl-rust-originals/rust-11.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "rust-11", + "sha256": "3823dda7cf046602f4b4e77ec8e227863dc4736037cc85bb33d9f19febe16bb7", + "upstream_path": "library/compiler-builtins/libm/LICENSE.txt" + }, + { + "bytes": 1152, + "git_blob": "0b252fab94ae1d54aac4df8d5ab6f7a2e919bd32", + "legal_document": false, + "path": "ci/licenses/musl-rust-originals/rust-generic-trunc.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "rust-generic-trunc", + "sha256": "3a3ca091cd1d750276601dc2dfeb2a8ff058636ea2b66a748c55a1804bc8f00a", + "upstream_path": "library/compiler-builtins/libm/src/math/generic/trunc.rs" + } + ], + "reviewed_inputs": { + "head": "659b3c8acf3a45e7624e36a24d2285cf990ca8e6", + "repository": "ktav-lang/js", + "run": 41255394835 + }, + "rust_revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "rust_version": "1.99.1", + "schema_version": 1, + "targets": { + "aarch64-unknown-linux-musl": { + "cabi": { + "archives": [ + { + "bytes": 5063072, + "members": [ + "2f14b52d98676ab3-lse_cas1_relax.o", + "2f14b52d98676ab3-lse_cas4_acq.o", + "2f14b52d98676ab3-lse_cas4_relax.o", + "2f14b52d98676ab3-lse_ldadd4_rel.o", + "2f14b52d98676ab3-lse_ldadd8_rel.o", + "2f14b52d98676ab3-lse_ldadd8_relax.o", + "2f14b52d98676ab3-lse_swp1_relax.o", + "2f14b52d98676ab3-lse_swp4_acq.o", + "2f14b52d98676ab3-lse_swp4_rel.o", + "670c1ed24249df13-aarch64.o" + ], + "name": "libcompiler_builtins-29674cca14587d3c.rlib", + "origin": "rust-sysroot", + "path": "lib/rustlib/aarch64-unknown-linux-musl/lib/libcompiler_builtins-29674cca14587d3c.rlib", + "sha256": "d696daeff228aef6460e3ebcf6355e5a8b2545e937a4e20c6db296acc4278e5e" + }, + { + "members": [ + "UnwindLevel1-gcc-ext.o", + "UnwindLevel1.o", + "UnwindRegistersRestore.o", + "UnwindRegistersSave.o", + "libunwind.o" + ], + "name": "libunwind.a", + "origin": "zig-cache" + } + ], + "direct_rust_objects": 1, + "dynamic_imports": [ + "libc.so" + ] + }, + "napi": { + "archives": [ + { + "bytes": 5063072, + "members": [ + "2f14b52d98676ab3-lse_cas1_relax.o", + "2f14b52d98676ab3-lse_cas4_acq.o", + "2f14b52d98676ab3-lse_cas4_relax.o", + "2f14b52d98676ab3-lse_cas8_acq.o", + "2f14b52d98676ab3-lse_cas8_acq_rel.o", + "2f14b52d98676ab3-lse_cas8_relax.o", + "2f14b52d98676ab3-lse_ldadd4_rel.o", + "2f14b52d98676ab3-lse_ldadd8_acq_rel.o", + "2f14b52d98676ab3-lse_ldadd8_rel.o", + "2f14b52d98676ab3-lse_ldadd8_relax.o", + "2f14b52d98676ab3-lse_swp1_relax.o", + "2f14b52d98676ab3-lse_swp4_acq.o", + "2f14b52d98676ab3-lse_swp4_rel.o", + "670c1ed24249df13-aarch64.o" + ], + "name": "libcompiler_builtins-29674cca14587d3c.rlib", + "origin": "rust-sysroot", + "path": "lib/rustlib/aarch64-unknown-linux-musl/lib/libcompiler_builtins-29674cca14587d3c.rlib", + "sha256": "d696daeff228aef6460e3ebcf6355e5a8b2545e937a4e20c6db296acc4278e5e" + }, + { + "members": [ + "UnwindLevel1-gcc-ext.o", + "UnwindLevel1.o", + "UnwindRegistersRestore.o", + "UnwindRegistersSave.o", + "libunwind.o" + ], + "name": "libunwind.a", + "origin": "zig-cache" + } + ], + "direct_rust_objects": 1, + "dynamic_imports": [ + "libc.so" + ] + } + }, + "x86_64-unknown-linux-musl": { + "cabi": { + "archives": [ + { + "members": [ + "UnwindLevel1-gcc-ext.o", + "UnwindLevel1.o", + "UnwindRegistersRestore.o", + "UnwindRegistersSave.o", + "libunwind.o" + ], + "name": "libunwind.a", + "origin": "zig-cache" + } + ], + "direct_rust_objects": 1, + "dynamic_imports": [ + "libc.so" + ] + }, + "napi": { + "archives": [ + { + "bytes": 4770054, + "members": [ + "compiler_builtins-648b0fadff3f0e71.compiler_builtins.6194a6b7615163bc-cgu.146.rcgu.o" + ], + "name": "libcompiler_builtins-648b0fadff3f0e71.rlib", + "origin": "rust-sysroot", + "path": "lib/rustlib/x86_64-unknown-linux-musl/lib/libcompiler_builtins-648b0fadff3f0e71.rlib", + "sha256": "7656e712abe38ff555b33cda0ce0cfbc624e94d1352883fe216c0b1425072709" + }, + { + "members": [ + "UnwindLevel1-gcc-ext.o", + "UnwindLevel1.o", + "UnwindRegistersRestore.o", + "UnwindRegistersSave.o", + "libunwind.o" + ], + "name": "libunwind.a", + "origin": "zig-cache" + } + ], + "direct_rust_objects": 1, + "dynamic_imports": [ + "libc.so" + ] + } + } + }, + "zig_revision": "5ad91a646a753cc3eecd8751e61cf458dadd9ac4", + "zig_version": "0.14.0" +} diff --git a/ci/test_musl_retained_runtime.py b/ci/test_musl_retained_runtime.py new file mode 100644 index 0000000..bf7872b --- /dev/null +++ b/ci/test_musl_retained_runtime.py @@ -0,0 +1,90 @@ +"""CI-регрессии точных target/role/member и полных original Rust grants.""" + +import copy +import importlib.util +from pathlib import Path +import shutil +import tempfile +import unittest + +ROOT = Path(__file__).resolve().parents[1] +SPEC = importlib.util.spec_from_file_location('musl_retained', ROOT / 'scripts/musl_retained_runtime.py') +MODULE = importlib.util.module_from_spec(SPEC) +SPEC.loader.exec_module(MODULE) + + +class MuslRetainedTests(unittest.TestCase): + def fixture(self, target, role): + document, _ = MODULE.profile(ROOT) + archives = [] + cpu = 62 if target.startswith('x86_64') else 183 + for item in document['targets'][target][role]['archives']: + archive = copy.deepcopy(item) + archive.setdefault('path', 'o/fixture/' + archive['name']) + archive['available_after_link'] = True + if archive['origin'] == 'zig-cache': + archive['object_inputs'] = [{'name': name, 'machine': cpu, 'bytes': 64, 'sha256': 'a' * 64} for name in archive['members']] + archives.append(archive) + report = {'target': target, 'role': role, 'imports': ['libc.so'], 'archive_inputs': archives, 'direct_objects': ['/project/target/' + target + '/release/deps/ktav_' + role + '.fixture.rcgu.o']} + return document, report + + def test_profile_preserves_all_original_material_roles(self): + document, _ = MODULE.profile(ROOT) + materials = MODULE.originals(ROOT, document) + self.assertEqual(len(materials), 13) + self.assertEqual(sum(item['legal_document'] for item in materials), 4) + self.assertTrue(any('MIT AND Apache-2.0 WITH' in item.get('text', '') for item in materials)) + + def test_all_four_actual_role_policies_are_distinct_and_accepted(self): + for target in ['x86_64-unknown-linux-musl', 'aarch64-unknown-linux-musl']: + for role in ['napi', 'cabi']: + document, report = self.fixture(target, role) + MODULE.verify_inputs(report, document, target, role) + + def test_missing_or_changed_builtin_member_is_rejected(self): + target = 'aarch64-unknown-linux-musl' + document, report = self.fixture(target, 'napi') + rust = next(item for item in report['archive_inputs'] if item['origin'] == 'rust-sysroot') + rust['members'].pop() + with self.assertRaisesRegex(ValueError, 'retained musl source/archive members differ'): + MODULE.verify_inputs(report, document, target, 'napi') + + def test_changed_rust_archive_bytes_are_rejected(self): + target = 'aarch64-unknown-linux-musl' + document, report = self.fixture(target, 'napi') + next(item for item in report['archive_inputs'] if item['origin'] == 'rust-sysroot')['sha256'] = '0' * 64 + with self.assertRaisesRegex(ValueError, 'retained musl source/archive members differ'): + MODULE.verify_inputs(report, document, target, 'napi') + + def test_role_swap_and_extra_direct_object_are_rejected(self): + target = 'x86_64-unknown-linux-musl' + document, report = self.fixture(target, 'napi') + with self.assertRaisesRegex(ValueError, 'retained musl source/archive members differ'): + MODULE.verify_inputs(report, document, target, 'cabi') + report['direct_objects'].append('/foreign/crt.o') + with self.assertRaisesRegex(ValueError, 'unreviewed direct musl'): + MODULE.verify_inputs(report, document, target, 'napi') + + def test_actual_member_cpu_fingerprints_are_required(self): + target = 'x86_64-unknown-linux-musl' + document, report = self.fixture(target, 'cabi') + next(item for item in report['archive_inputs'] if item['origin'] == 'zig-cache')['object_inputs'][0]['machine'] = 183 + with self.assertRaisesRegex(ValueError, 'actual Zig member'): + MODULE.verify_inputs(report, document, target, 'cabi') + + def test_original_copyright_material_cannot_be_truncated(self): + document, _ = MODULE.profile(ROOT) + with tempfile.TemporaryDirectory() as temporary: + root = Path(temporary) + for item in document['materials']: + destination = root / item['path'] + destination.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(ROOT / item['path'], destination) + selected = document['materials'][0] + (root / selected['path']).write_bytes(b'truncated grant') + with self.assertRaisesRegex(ValueError, 'original musl Rust/LLVM/libm bytes differ'): + MODULE.originals(root, document) + + +if __name__ == '__main__': + unittest.main() diff --git a/scripts/musl_native_evidence.py b/scripts/musl_native_evidence.py index 9a2d756..e3b62f9 100644 --- a/scripts/musl_native_evidence.py +++ b/scripts/musl_native_evidence.py @@ -50,7 +50,7 @@ def prepare(evidence): if subprocess.check_output(['zig', 'version'], text=True).strip() != '0.14.0': raise ValueError('unreviewed musl Zig version') lib = Path(json.loads(subprocess.check_output(['zig', 'env']))['lib_dir']).resolve() - sections = ['Ktav musl candidate runtime notice collection.\nActual retained inputs still require review before production delivery.\n'] + sections = ['Ktav musl runtime source notice collection.\nExact role/target retained input gates are recorded separately.\n'] for item in profile['files']: relative = PurePosixPath(item['path']) if relative.is_absolute() or '..' in relative.parts or '\\' in item['path']: @@ -68,8 +68,8 @@ def prepare(evidence): bundle = json.loads(before) if 'non_cargo_runtimes' in bundle or (evidence / 'NOTICE.cargo-std.json').exists(): raise ValueError('musl candidate notices already augmented') - bundle['non_cargo_runtimes'] = [{'name': 'Conservative Zig libunwind/musl source-notice collection', 'source_revision': REVISION, 'catalog_sha256': CATALOG_SHA, 'files': profile['files'], 'credits': profile['credits'], 'coverage': profile['coverage']}] - bundle['coverage'] += ' Candidate musl source notice collection only; retained runtime input review remains required.' + bundle['non_cargo_runtimes'] = [{'name': 'Zig libunwind/musl original source-notice collection', 'source_revision': REVISION, 'catalog_sha256': CATALOG_SHA, 'files': profile['files'], 'credits': profile['credits'], 'coverage': profile['coverage']}] + bundle['coverage'] += ' Includes original musl source notice collection; exact retained input/source gates are required separately.' raw = (json.dumps(bundle, ensure_ascii=False, sort_keys=True, indent=2) + '\n').encode('utf-8') compressed = gzip.compress(raw, mtime=0) if len(raw) > 64 * 1024 * 1024 or len(compressed) > 4 * 1024 * 1024: @@ -109,6 +109,19 @@ def capture(binary, evidence, target, role, cache, sysroot): if path.is_file(): raw = read(path, 128 * 1024 * 1024) record.update({'bytes': len(raw), 'sha256': hashlib.sha256(raw).hexdigest()}) + if origin == 'zig-cache': + objects = [] + for member in sorted(members): + selected = Path(member) + if not selected.is_absolute(): + selected = path.parent / selected + if not selected.resolve().is_relative_to(cache.resolve()): + raise ValueError('actual Zig member escapes fresh cache') + raw = read(selected, 16 * 1024 * 1024) + if len(raw) < 64 or raw[:6] != b'\x7fELF\x02\x01' or struct.unpack_from(' limit: + raise ValueError('musl retained input exceeds bound') + return raw + + +def profile(root): + raw = read(root / PROFILE, 1024 * 1024) + if hashlib.sha256(raw).hexdigest() != PROFILE_SHA: + raise ValueError('unreviewed per-role musl runtime profile') + document = json.loads(raw) + if len(document['materials']) != 13 or sum(item['legal_document'] for item in document['materials']) != 4: + raise ValueError('musl Rust original source/legal roles differ') + return document, raw + + +def originals(root, document): + result = [] + total = 0 + for item in document['materials']: + relative = PurePosixPath(item['path']) + if relative.is_absolute() or '..' in relative.parts or '\\' in item['path']: + raise ValueError('unsafe musl Rust material path') + raw = read(root / item['path'], 4 * 1024 * 1024) + total += len(raw) + blob = hashlib.sha1(b'blob ' + str(len(raw)).encode() + b'\0' + raw).hexdigest() + if total > 32 * 1024 * 1024 or len(raw) != item['bytes'] or hashlib.sha256(raw).hexdigest() != item['sha256'] or blob != item['git_blob']: + raise ValueError('original musl Rust/LLVM/libm bytes differ') + comments = re.findall(r'/\*.*?\*/|(?:^[ \t]*//[^\n]*(?:\n|$))+', raw.decode('utf-8'), re.M | re.S) + notices = [value for value in comments if re.search(r'copyright|licens|permission|SPDX|public domain|redistribution', value, re.I)] + result.append({**item, **({'text': raw.decode('utf-8')} if item['legal_document'] else {'source_notices': notices})}) + return result + + +def runtime_record(document, materials): + return {'name': 'Rust compiler-builtins, incorporated LLVM compiler-rt and libm', 'rust_version': document['rust_version'], 'rust_revision': document['rust_revision'], 'llvm_revision': document['llvm_revision'], 'compiler_builtins_license': 'MIT AND Apache-2.0 WITH LLVM-exception', 'profile_sha256': PROFILE_SHA, 'materials': materials, 'coverage': document['coverage']} + + +def plain_notice(materials): + sections = ['Original Rust compiler-builtins/LLVM/libm permissions and source notices.\n'] + for item in materials: + sections.extend(['\n===== ' + item['repository'] + '@' + item['revision'] + '/' + item['upstream_path'] + ' =====\n', item['text'] if item['legal_document'] else '\n'.join(item['source_notices'])]) + return '\n'.join(sections).encode('utf-8') + + +def prepare(evidence): + root = Path(__file__).resolve().parents[1] + document, raw_profile = profile(root) + materials = originals(root, document) + before = read(evidence / 'NOTICE.json', 64 * 1024 * 1024) + bundle = json.loads(before) + runtimes = bundle.get('non_cargo_runtimes', []) + if len(runtimes) != 1 or (evidence / 'musl-retained-runtime.json').exists(): + raise ValueError('unexpected musl retained preparation state') + bundle['non_cargo_runtimes'] = [*runtimes, runtime_record(document, materials)] + raw = (json.dumps(bundle, ensure_ascii=False, sort_keys=True, indent=2) + '\n').encode('utf-8') + compressed = gzip.compress(raw, mtime=0) + if len(raw) > 64 * 1024 * 1024 or len(compressed) > 4 * 1024 * 1024: + raise ValueError('full musl retained notice exceeds bound') + (evidence / 'NOTICE.source-collection.json').write_bytes(before) + (evidence / 'NOTICE.json').write_bytes(raw) + (evidence / 'NOTICE.json.gz').write_bytes(compressed) + (evidence / 'musl-retained-runtime.json').write_bytes(raw_profile) + for item in document['materials']: + data = read(root / item['path'], 4 * 1024 * 1024) + destination = evidence / 'runtime-rust-originals' / (item['role'] + '.txt') + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(data) + (evidence / 'NOTICE.rust-builtins.txt').write_bytes(plain_notice(materials)) + + +def normalized_archives(items): + result = [] + for item in items: + value = {'origin': item['origin'], 'name': Path(item['path']).name, 'members': sorted(Path(member).name for member in item['members'])} + if not item['available_after_link']: + raise ValueError('actual retained archive bytes unavailable') + if item['origin'] == 'rust-sysroot': + value.update({'path': item['path'], 'bytes': item['bytes'], 'sha256': item['sha256']}) + elif item['origin'] != 'zig-cache' or value['name'] != 'libunwind.a': + raise ValueError('unreviewed musl archive origin/role') + result.append(value) + return sorted(result, key=lambda item: (item['origin'], item['name'])) + + +def verify_inputs(report, document, target, role): + if target not in document['targets'] or role not in document['targets'][target]: + raise ValueError('unreviewed musl target/role') + expected = document['targets'][target][role] + if report['target'] != target or report['role'] != role or report['imports'] != expected['dynamic_imports'] or normalized_archives(report['archive_inputs']) != expected['archives']: + raise ValueError('actual retained musl source/archive members differ') + cpu = 62 if target.startswith('x86_64') else 183 + for archive in report['archive_inputs']: + if archive['origin'] == 'zig-cache': + inputs = archive.get('object_inputs', []) + if sorted(item['name'] for item in inputs) != sorted(Path(name).name for name in archive['members']) or any(item['machine'] != cpu or not 0 < item['bytes'] <= 16 * 1024 * 1024 or re.fullmatch('[0-9a-f]{64}', item['sha256']) is None for item in inputs): + raise ValueError('actual Zig member byte/CPU fingerprints missing') + objects = report['direct_objects'] + marker = '/target/' + target + '/release/deps/ktav_' + role + '.' + if len(objects) != 1 or marker not in objects[0] or not objects[0].endswith('.rcgu.o'): + raise ValueError('unreviewed direct musl runtime object') + + +def verify(evidence, target, role): + root = Path(__file__).resolve().parents[1] + document, raw_profile = profile(root) + materials = originals(root, document) + report = json.loads(read(evidence / role / 'native-verification.json', 4 * 1024 * 1024)) + verify_inputs(report, document, target, role) + if read(evidence / 'musl-retained-runtime.json', 1024 * 1024) != raw_profile: + raise ValueError('staged per-role musl profile differs') + for item in document['materials']: + if read(evidence / 'runtime-rust-originals' / (item['role'] + '.txt'), 4 * 1024 * 1024) != read(root / item['path'], 4 * 1024 * 1024): + raise ValueError('actual staged Rust original differs') + notice = read(evidence / 'NOTICE.json', 64 * 1024 * 1024) + bundle = json.loads(notice) + before = json.loads(read(evidence / 'NOTICE.source-collection.json', 64 * 1024 * 1024)) + expected_bundle = {**before, 'non_cargo_runtimes': [*before['non_cargo_runtimes'], runtime_record(document, materials)]} + if bundle != expected_bundle: + raise ValueError('required full musl Rust/Cargo/source/grant roles differ') + if read(evidence / 'NOTICE.rust-builtins.txt', 64 * 1024 * 1024) != plain_notice(materials): + raise ValueError('plain original Rust/LLVM/libm grant text differs') + binary_name = 'libktav_cabi.so' if role == 'cabi' else ('ktav.linux-x64-musl.node' if target.startswith('x86_64') else 'ktav.linux-arm64-musl.node') + binary = read(evidence / role / binary_name, 128 * 1024 * 1024) + scanner_spec = importlib.util.spec_from_file_location('musl_scanner', Path(__file__).with_name('check_embedded_notices.py')) + scanner = importlib.util.module_from_spec(scanner_spec) + scanner_spec.loader.exec_module(scanner) + if hashlib.sha256(binary).hexdigest() != report['binary_sha256'] or scanner._extract(binary)[0] != notice: + raise ValueError('actual musl binary/resource identity differs') + result = {'target': target, 'role': role, 'binary_sha256': report['binary_sha256'], 'notice_sha256': hashlib.sha256(notice).hexdigest(), 'retained_profile_sha256': PROFILE_SHA, 'retained_archives': normalized_archives(report['archive_inputs']), 'full_rust_original_materials': len(materials), 'scope': 'Exact musl role/target retained-source/input and full original Rust grant resource gate; not other toolchain versions or npm production assembly.'} + (evidence / role / 'retained-runtime-verification.json').write_text(json.dumps(result, sort_keys=True, indent=2) + '\n', encoding='utf-8') + print(json.dumps(result, sort_keys=True)) + + +if __name__ == '__main__': + if len(sys.argv) == 3 and sys.argv[1] == 'prepare': + prepare(Path(sys.argv[2])) + elif len(sys.argv) == 5 and sys.argv[1] == 'verify': + verify(Path(sys.argv[2]), sys.argv[3], sys.argv[4]) + else: + raise SystemExit('usage: musl_retained_runtime.py prepare EVIDENCE | verify EVIDENCE TARGET ROLE') From eea79456fe3c0e68d6779215adfacf982f2b4bb6 Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sun, 1 Nov 2026 01:54:44 +0100 Subject: [PATCH 38/51] fix(ci): run browser checks on supported Ubuntu 24.04 The ubuntu-latest rollout now selects Ubuntu 26.04, which the installed Playwright 1.59.1 rejects before browser tests start. Pin only the Linux browser matrix entry to the supported LTS image. Do not upgrade project dependencies, spoof Playwright platform metadata, skip browser tests or weaken the aggregate test summary. All other OS/job entries remain unchanged. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index b37c77a..dbcf73e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -324,7 +324,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + os: [ubuntu-24.04, macos-latest, windows-latest] steps: - uses: actions/checkout@v6 with: From 91521332503c878ab12956fbbcb983efa97e7730 Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sun, 1 Nov 2026 06:41:11 +0100 Subject: [PATCH 39/51] fix(licenses): retain GNU NAPI libm notices Deliver complete pinned Rust compiler-builtins, LLVM and libm original grants and credits alongside the reviewed GNU SDK notices. The x64 retained trunc implementation requires libm attribution that the standard-library copyright report does not provide. Reuse existing checksum-verified source originals without copying musl input policies to GNU. Bind both GNU target/member sets to the actual map and exact Rust commit, retain all original Cargo/std material, and verify full readable and embedded notice bytes. Add fail-closed regression coverage for missing members, source changes, toolchain drift and complete original grant delivery. No Cargo graph, parser API, version or publisher changes. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/napi-notice-check.yml | 2 +- ci/napi-gnu-rust-builtins.json | 183 ++++++++++++++++++++++++ ci/test_napi_gnu_runtime_notices.py | 86 ++++++++++- scripts/napi_gnu_runtime_notices.py | 51 ++++++- 4 files changed, 319 insertions(+), 3 deletions(-) create mode 100644 ci/napi-gnu-rust-builtins.json diff --git a/.github/workflows/napi-notice-check.yml b/.github/workflows/napi-notice-check.yml index 5a54586..66a8770 100644 --- a/.github/workflows/napi-notice-check.yml +++ b/.github/workflows/napi-notice-check.yml @@ -31,7 +31,7 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'napi-notice-tools' stage.mkdir() - for name in ['crates/napi/build.rs', 'scripts/patch_napi_notice_source.py', 'ci/test_napi_notice_overlay.py', 'scripts/check_embedded_notices.py', 'Cargo.lock', 'ci/js-build-lock.json', 'ci/test_js_build_lock.py', 'scripts/capture_napi_cross_link.py', 'scripts/collect_napi_link_evidence.py', 'ci/test_napi_cross_link.py', 'ci/napi-gnu-sdk-inputs.json', 'ci/licenses/napi-gnu-runtime.json', 'ci/test_napi_gnu_runtime_notices.py', 'scripts/napi_gnu_runtime_notices.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json']: + for name in ['ci/napi-gnu-rust-builtins.json', *[str(path) for path in Path('ci/licenses/musl-rust-originals').glob('*.txt')], 'crates/napi/build.rs', 'scripts/patch_napi_notice_source.py', 'ci/test_napi_notice_overlay.py', 'scripts/check_embedded_notices.py', 'Cargo.lock', 'ci/js-build-lock.json', 'ci/test_js_build_lock.py', 'scripts/capture_napi_cross_link.py', 'scripts/collect_napi_link_evidence.py', 'ci/test_napi_cross_link.py', 'ci/napi-gnu-sdk-inputs.json', 'ci/licenses/napi-gnu-runtime.json', 'ci/test_napi_gnu_runtime_notices.py', 'scripts/napi_gnu_runtime_notices.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json']: target = stage / name target.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(name, target) diff --git a/ci/napi-gnu-rust-builtins.json b/ci/napi-gnu-rust-builtins.json new file mode 100644 index 0000000..946c695 --- /dev/null +++ b/ci/napi-gnu-rust-builtins.json @@ -0,0 +1,183 @@ +{ + "coverage": "GNU NAPI retained Rust input policy with complete original Rust/LLVM/libm source and legal materials. Materials are a conservative source/notice superset, not a claim that every source line is retained. No other target, toolchain version, historical package or npm container claim.", + "llvm_revision": "1b9c0d5ff9bbe7634aead059efe6b11a7eeba145", + "materials": [ + { + "bytes": 15078, + "git_blob": "00ae6140bd54e1b538d833f60438e11ed8be12cf", + "legal_document": true, + "path": "ci/licenses/musl-rust-originals/rust-0.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "rust-0", + "sha256": "ab6eec6caf0fa5775e411c7a8bc6a45c4ef2956b0980b157ab74fc5cd62a928b", + "upstream_path": "library/compiler-builtins/LICENSE.txt" + }, + { + "bytes": 2005, + "git_blob": "b2f1443f2eb09d297b62c7b44fce9e31d71b10a2", + "legal_document": false, + "path": "ci/licenses/musl-rust-originals/rust-1.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "rust-1", + "sha256": "d89e31fed70f2cad9c6e91b787bf4c0fb680c631196b2a7215c81745aaf7fb7e", + "upstream_path": "library/compiler-builtins/compiler-builtins/Cargo.toml" + }, + { + "bytes": 27313, + "git_blob": "e86c784b5c6317a53e9ff89104b15e60ba7ac4bf", + "legal_document": false, + "path": "ci/licenses/musl-rust-originals/rust-2.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "rust-2", + "sha256": "dd1d07d0852fd6a654c69d6dafd8ae66744853cb5678610008dbf6ae6baec11e", + "upstream_path": "library/compiler-builtins/compiler-builtins/build.rs" + }, + { + "bytes": 463, + "git_blob": "2c12cb7f3095b2ace3938a666ebd1b607b8a269c", + "legal_document": false, + "path": "ci/licenses/musl-rust-originals/rust-3.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "rust-3", + "sha256": "5acb367779a8e6e6e06e188e715d6d2ff76b9c3208acd899e139957bd1d3c877", + "upstream_path": "library/compiler-builtins/compiler-builtins/src/aarch64.rs" + }, + { + "bytes": 16463, + "git_blob": "367768ecb60d65069679b3c84a9ef932c5ab6962", + "legal_document": false, + "path": "ci/licenses/musl-rust-originals/rust-4.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "rust-4", + "sha256": "d2e6ed0066ac36db55dfaa245bdc814353456dda92437aba539cc828d2011ae9", + "upstream_path": "library/compiler-builtins/compiler-builtins/src/aarch64_outline_atomics.rs" + }, + { + "bytes": 5851, + "git_blob": "a444d82892c36f8c1e3ba5f1977638d56fb929f8", + "legal_document": false, + "path": "ci/licenses/musl-rust-originals/llvm-5.txt", + "repository": "rust-lang/llvm-project", + "revision": "1b9c0d5ff9bbe7634aead059efe6b11a7eeba145", + "role": "llvm-5", + "sha256": "dcd05cb984ef8d777642eb960e3ef61b1140f268c3e4744f8f738aa46fd8ed66", + "upstream_path": "compiler-rt/lib/builtins/aarch64/lse.S" + }, + { + "bytes": 3026, + "git_blob": "347bb4e121c97c98aa6e7440b1c952978bfedc9b", + "legal_document": false, + "path": "ci/licenses/musl-rust-originals/llvm-6.txt", + "repository": "rust-lang/llvm-project", + "revision": "1b9c0d5ff9bbe7634aead059efe6b11a7eeba145", + "role": "llvm-6", + "sha256": "405b2ad2520db341af1338be2e58cce9d28a9f63006486d1c9572f4fe10ae032", + "upstream_path": "compiler-rt/lib/builtins/cpu_model/aarch64.c" + }, + { + "bytes": 16708, + "git_blob": "5a79a1b9d5cb0af9a779751f07033e44ca3b14d8", + "legal_document": true, + "path": "ci/licenses/musl-rust-originals/llvm-7.txt", + "repository": "rust-lang/llvm-project", + "revision": "1b9c0d5ff9bbe7634aead059efe6b11a7eeba145", + "role": "llvm-7", + "sha256": "1a8f1058753f1ba890de984e48f0242a3a5c29a6a8f2ed9fd813f36985387e8d", + "upstream_path": "compiler-rt/LICENSE.TXT" + }, + { + "bytes": 1049, + "git_blob": "6964eba020b8aa7a08629b249e3b9aea3ce3e448", + "legal_document": true, + "path": "ci/licenses/musl-rust-originals/llvm-8.txt", + "repository": "rust-lang/llvm-project", + "revision": "1b9c0d5ff9bbe7634aead059efe6b11a7eeba145", + "role": "llvm-8", + "sha256": "a9901f47a089da41e4690682d00ce4cedaa2baf41fedbe79beee366d43ac2461", + "upstream_path": "compiler-rt/CREDITS.TXT" + }, + { + "bytes": 7270, + "git_blob": "3dfa3863bb77007fbec01b7c931bf1c349953d11", + "legal_document": false, + "path": "ci/licenses/musl-rust-originals/rust-9.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "rust-9", + "sha256": "a3ff615e04d9ae9a0bb36cfbfd9a0aaf183ab6e32ddfe836cdf4f243f97a401e", + "upstream_path": "library/compiler-builtins/compiler-builtins/src/math/mod.rs" + }, + { + "bytes": 4407, + "git_blob": "9eb902ea578f87588d8236619a67ab7db72c8ba8", + "legal_document": false, + "path": "ci/licenses/musl-rust-originals/rust-10.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "rust-10", + "sha256": "ef59952a1a80ec93be27eb78c977189084ff7fcae0e8f782d60b5947e1de141c", + "upstream_path": "library/compiler-builtins/libm/src/math/trunc.rs" + }, + { + "bytes": 14088, + "git_blob": "2f8e41f147472510b05e0adeadf350df6f5a6b96", + "legal_document": true, + "path": "ci/licenses/musl-rust-originals/rust-11.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "rust-11", + "sha256": "3823dda7cf046602f4b4e77ec8e227863dc4736037cc85bb33d9f19febe16bb7", + "upstream_path": "library/compiler-builtins/libm/LICENSE.txt" + }, + { + "bytes": 1152, + "git_blob": "0b252fab94ae1d54aac4df8d5ab6f7a2e919bd32", + "legal_document": false, + "path": "ci/licenses/musl-rust-originals/rust-generic-trunc.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "rust-generic-trunc", + "sha256": "3a3ca091cd1d750276601dc2dfeb2a8ff058636ea2b66a748c55a1804bc8f00a", + "upstream_path": "library/compiler-builtins/libm/src/math/generic/trunc.rs" + } + ], + "reviewed_inputs": { + "repository": "ktav-lang/js", + "run": 41222641651 + }, + "rust_revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "rust_version": "1.99.1", + "schema_version": 1, + "targets": { + "aarch64-unknown-linux-gnu": { + "archive": "libcompiler_builtins-6d387bb3469b4925.rlib", + "members": [ + "0b878bd900bb1336-lse_cas1_relax.o", + "0b878bd900bb1336-lse_cas4_acq.o", + "0b878bd900bb1336-lse_cas4_relax.o", + "0b878bd900bb1336-lse_cas8_acq.o", + "0b878bd900bb1336-lse_cas8_acq_rel.o", + "0b878bd900bb1336-lse_cas8_relax.o", + "0b878bd900bb1336-lse_ldadd4_rel.o", + "0b878bd900bb1336-lse_ldadd8_acq_rel.o", + "0b878bd900bb1336-lse_ldadd8_rel.o", + "0b878bd900bb1336-lse_ldadd8_relax.o", + "0b878bd900bb1336-lse_swp1_relax.o", + "0b878bd900bb1336-lse_swp4_acq.o", + "0b878bd900bb1336-lse_swp4_rel.o", + "670c1ed24249df13-aarch64.o" + ] + }, + "x86_64-unknown-linux-gnu": { + "archive": "libcompiler_builtins-2d9557d6e902a200.rlib", + "members": [ + "compiler_builtins-2d9557d6e902a200.compiler_builtins.2ae8f9d4cd35b9b2-cgu.242.rcgu.o" + ] + } + } +} diff --git a/ci/test_napi_gnu_runtime_notices.py b/ci/test_napi_gnu_runtime_notices.py index 5934d3c..0d3ba28 100644 --- a/ci/test_napi_gnu_runtime_notices.py +++ b/ci/test_napi_gnu_runtime_notices.py @@ -108,7 +108,7 @@ def test_changed_rust_toolchain_is_rejected(self): def test_prepare_preserves_cargo_bundle_and_compressed_bytes(self): with tempfile.TemporaryDirectory() as temporary: evidence = Path(temporary) - (evidence / 'NOTICE.json').write_text(json.dumps({'cargo_fixture': ['unchanged']}), encoding='utf-8') + (evidence / 'NOTICE.json').write_text(json.dumps({'cargo_fixture': ['unchanged'], 'rustc': 'rustc 1.99.1\ncommit-hash: ' + RUNTIME.RUST_REVISION + '\nrelease: 1.99.1\n'}), encoding='utf-8') RUNTIME.prepare(ROOT, evidence, TARGET) raw = (evidence / 'NOTICE.json').read_bytes() bundle = json.loads(raw) @@ -118,6 +118,90 @@ def test_prepare_preserves_cargo_bundle_and_compressed_bytes(self): with self.assertRaisesRegex(ValueError, 'already exists'): RUNTIME.prepare(ROOT, evidence, TARGET) + def builtins_fixture(self, target=TARGET): + notice = RUNTIME.runtime_notice(ROOT, target) + retained = notice['rust_compiler_builtins']['retained'] + archive = '/rust/lib/rustlib/' + target + '/lib/' + retained['archive'] + mapping = '\n'.join(archive + '(' + member + ')' for member in retained['members']) + rustc = 'rustc 1.99.1\ncommit-hash: ' + RUNTIME.RUST_REVISION + '\nrelease: 1.99.1\n' + return notice, mapping, rustc + + def test_exact_builtins_members_for_both_gnu_targets(self): + for target in RUNTIME.TARGETS: + with self.subTest(target=target): + notice, mapping, rustc = self.builtins_fixture(target) + self.assertTrue(RUNTIME.verify_builtins(notice, mapping, rustc).endswith(notice['rust_compiler_builtins']['retained']['archive'])) + + def test_full_original_grants_and_credits_are_delivered(self): + for target in RUNTIME.TARGETS: + notice = RUNTIME.runtime_notice(ROOT, target) + builtins = notice['rust_compiler_builtins'] + self.assertEqual(builtins['compiler_builtins_license'], 'MIT AND Apache-2.0 WITH LLVM-exception') + self.assertEqual(len(builtins['materials']), 13) + data, plain = RUNTIME.notice_bytes(notice) + self.assertIn(b'Copyright (c) 2018 Jorge Aparicio', plain) + self.assertIn('Copyright © 2005-2020 Rich Felker, et al.'.encode(), plain) + self.assertIn(b'Copyright (c) 2009-2016', plain) + for item in builtins['materials']: + original = (ROOT / item['path']).read_bytes() + self.assertEqual(item['text'].encode(), original) + if item['legal_document']: + self.assertIn(original, plain) + self.assertEqual(json.loads(data)['rust_compiler_builtins'], builtins) + + def test_unknown_or_missing_builtins_member_is_rejected(self): + for target in RUNTIME.TARGETS: + notice, mapping, rustc = self.builtins_fixture(target) + for changed in ['', mapping + '\n' + mapping.split('(')[0] + '(unknown.o)', '\n'.join(mapping.splitlines()[1:])]: + with self.subTest(target=target, mapping=changed): + with self.assertRaisesRegex(ValueError, 'builtins (archive set|retained inputs) differs?'): + RUNTIME.verify_builtins(notice, changed, rustc) + + def test_foreign_target_and_archive_are_rejected(self): + notice, mapping, rustc = self.builtins_fixture() + for changed in [mapping.replace(TARGET, 'x86_64-unknown-linux-musl'), mapping.replace('2d9557d6e902a200.rlib', 'abcdef.rlib'), mapping + '\n' + mapping.replace('/rust/', '/other/')]: + with self.subTest(mapping=changed): + with self.assertRaises(ValueError): + RUNTIME.verify_builtins(notice, changed, rustc) + + def test_same_version_unknown_rust_commit_is_rejected(self): + notice, mapping, rustc = self.builtins_fixture() + with self.assertRaisesRegex(ValueError, 'compiler identity differs'): + RUNTIME.verify_builtins(notice, mapping, rustc.replace(RUNTIME.RUST_REVISION, '0' * 40)) + + def test_changed_rust_material_is_rejected(self): + with tempfile.TemporaryDirectory() as temporary: + root = Path(temporary) + (root / 'ci').mkdir() + (root / 'ci/napi-gnu-rust-builtins.json').write_bytes((ROOT / 'ci/napi-gnu-rust-builtins.json').read_bytes()) + first = json.loads((ROOT / 'ci/napi-gnu-rust-builtins.json').read_text())['materials'][0] + path = root / first['path'] + path.parent.mkdir(parents=True) + path.write_bytes(b'changed') + with self.assertRaisesRegex(ValueError, 'material identity differs'): + RUNTIME.builtins_notice(root, TARGET) + path.unlink() + with self.assertRaisesRegex(ValueError, 'missing or symlinked'): + RUNTIME.builtins_notice(root, TARGET) + + def test_changed_rust_profile_is_rejected(self): + with tempfile.TemporaryDirectory() as temporary: + root = Path(temporary) + (root / 'ci').mkdir() + (root / 'ci/napi-gnu-rust-builtins.json').write_text('{}') + with self.assertRaisesRegex(ValueError, 'profile differs from review'): + RUNTIME.builtins_notice(root, TARGET) + + def test_prepare_rejects_unknown_rust_before_writing(self): + with tempfile.TemporaryDirectory() as temporary: + evidence = Path(temporary) + original = b'{"cargo_fixture": true, "rustc": "rustc 1.99.1"}' + (evidence / 'NOTICE.json').write_bytes(original) + with self.assertRaisesRegex(ValueError, 'compiler identity differs'): + RUNTIME.prepare(ROOT, evidence, TARGET) + self.assertEqual((evidence / 'NOTICE.json').read_bytes(), original) + self.assertFalse((evidence / 'GNU-RUNTIME-NOTICE.json').exists()) + def test_modified_or_missing_material_profile_is_rejected(self): with tempfile.TemporaryDirectory() as temporary: root = Path(temporary) diff --git a/scripts/napi_gnu_runtime_notices.py b/scripts/napi_gnu_runtime_notices.py index 1e8c4ed..7884b51 100644 --- a/scripts/napi_gnu_runtime_notices.py +++ b/scripts/napi_gnu_runtime_notices.py @@ -35,6 +35,43 @@ def reviewed(root): return json.loads(profile), json.loads(catalog) +BUILTINS_SHA256 = '7b8e2f772be9d0263e725dd7322490e651149d77c7787664ab9af1162085b8c3' +RUST_REVISION = '58cf8f9c35b355199727627d07ae34a4e2846d67' + + +def builtins_notice(root, target): + raw = read(root / 'ci/napi-gnu-rust-builtins.json', 1024 * 1024) + if hashlib.sha256(raw).hexdigest() != BUILTINS_SHA256: + raise ValueError('GNU Rust builtins profile differs from review') + profile = json.loads(raw) + materials = [] + for item in profile['materials']: + path = PurePosixPath(item['path']) + if path.is_absolute() or '..' in path.parts or '\\' in item['path']: + raise ValueError('unsafe GNU Rust original path') + data = read(root / item['path'], 4 * 1024 * 1024) + blob = hashlib.sha1(b'blob ' + str(len(data)).encode() + b'\0' + data).hexdigest() + if len(data) != item['bytes'] or hashlib.sha256(data).hexdigest() != item['sha256'] or blob != item['git_blob']: + raise ValueError('GNU Rust original material identity differs') + materials.append({**item, 'text': data.decode('utf-8')}) + return {'profile_sha256': BUILTINS_SHA256, 'rust_revision': profile['rust_revision'], 'llvm_revision': profile['llvm_revision'], 'compiler_builtins_license': 'MIT AND Apache-2.0 WITH LLVM-exception', 'libm_license': 'MIT', 'retained': profile['targets'][target], 'materials': materials, 'coverage': profile['coverage']} + + +def verify_builtins(notice, mapping, rustc): + if '\ncommit-hash: ' + RUST_REVISION + '\n' not in rustc or '\nrelease: 1.99.1\n' not in rustc: + raise ValueError('GNU Rust builtins compiler identity differs') + pairs = set(re.findall(r'([^\s()]*libcompiler_builtins-[0-9a-f]+[.]rlib)\(([^()\n]+)\)', mapping)) + paths = {archive for archive, _ in pairs} + expected = notice['rust_compiler_builtins']['retained'] + if len(paths) != 1: + raise ValueError('GNU Rust builtins archive set differs') + archive = paths.pop() + suffix = '/lib/rustlib/' + notice['target'] + '/lib/' + expected['archive'] + if not PurePosixPath(archive).is_absolute() or not archive.endswith(suffix) or sorted(member for _, member in pairs) != expected['members']: + raise ValueError('GNU Rust builtins retained inputs differ') + return archive + + def runtime_notice(root, target): if target not in TARGETS: raise ValueError('unreviewed GNU runtime target') @@ -47,7 +84,7 @@ def runtime_notice(root, target): blob = hashlib.sha1(b'blob ' + str(len(data)).encode() + b'\0' + data).hexdigest() if len(data) != item['bytes'] or hashlib.sha256(data).hexdigest() != item['sha256'] or blob != item['git_blob']: raise ValueError('GNU source or license material identity mismatch') - return {'schema_version': 1, 'target': target, 'profile_sha256': PROFILE_SHA256, 'sdk_catalog_sha256': CATALOG_SHA256, 'sdk_revision': profile['sdk_revision'], 'sdk_inputs': catalog['targets'][target], 'archive_members': MEMBERS, 'loaded_crt_objects': sorted(CRT), 'materials': materials, 'glibc_terms': profile['glibc_terms'], 'gcc_terms': profile['gcc_terms'], 'compilation_process': profile['compilation_process'], 'scope': profile['scope'], 'unused_archive': 'libpthread_nonshared.a is loaded, but no members are retained by this reviewed link profile.', 'host_libraries': 'System shared libraries including glibc and libgcc_s are host-provided, not redistributed in this addon payload; their dynamic use is distinct from the selected compiled-in CRT members.'} + return {'schema_version': 1, 'target': target, 'rust_compiler_builtins': builtins_notice(root, target), 'profile_sha256': PROFILE_SHA256, 'sdk_catalog_sha256': CATALOG_SHA256, 'sdk_revision': profile['sdk_revision'], 'sdk_inputs': catalog['targets'][target], 'archive_members': MEMBERS, 'loaded_crt_objects': sorted(CRT), 'materials': materials, 'glibc_terms': profile['glibc_terms'], 'gcc_terms': profile['gcc_terms'], 'compilation_process': profile['compilation_process'], 'scope': profile['scope'], 'unused_archive': 'libpthread_nonshared.a is loaded, but no members are retained by this reviewed link profile.', 'host_libraries': 'System shared libraries including glibc and libgcc_s are host-provided, not redistributed in this addon payload; their dynamic use is distinct from the selected compiled-in CRT members.'} def notice_bytes(notice): @@ -55,6 +92,10 @@ def notice_bytes(notice): sections = ['GNU NAPI runtime notices — ' + notice['target'], notice['scope'], notice['glibc_terms'], notice['gcc_terms'], notice['compilation_process'], notice['unused_archive'], notice['host_libraries']] for item in notice['materials']: sections.extend(['=' * 72, item['id'], item['repository'] + ' @ ' + item['revision'], 'Git blob: ' + item['git_blob'] + '; SHA256: ' + item['sha256'], item['text']]) + sections.extend([notice['rust_compiler_builtins']['coverage'], 'Rust compiler-builtins: MIT AND Apache-2.0 WITH LLVM-exception; libm: MIT.']) + for item in notice['rust_compiler_builtins']['materials']: + if item['legal_document']: + sections.extend(['=' * 72, item['repository'] + ' @ ' + item['revision'], item['upstream_path'], item['text']]) plain = ('\n\n'.join(sections) + '\n').encode('utf-8') return data, plain @@ -66,6 +107,8 @@ def prepare(root, evidence, target): if any(path.exists() or path.is_symlink() for path in paths): raise ValueError('GNU runtime notice output already exists') bundle = json.loads(read(evidence / 'NOTICE.json', 64 * 1024 * 1024)) + if '\ncommit-hash: ' + RUST_REVISION + '\n' not in bundle.get('rustc', '') or '\nrelease: 1.99.1\n' not in bundle.get('rustc', ''): + raise ValueError('GNU Rust builtins compiler identity differs') if 'napi_gnu_runtime' in bundle: raise ValueError('GNU runtime bundle already augmented') bundle['napi_gnu_runtime'] = notice @@ -146,6 +189,12 @@ def verify(root, evidence, target): raise ValueError('GNU compressed bundle differs from readable notice') if bundle.get('napi_gnu_runtime') != notice: raise ValueError('GNU runtime notice absent from augmented bundle') + rustc = read(evidence / 'rustc.txt', 64 * 1024).decode('utf-8') + mapping = read(evidence / 'native-link.map', 32 * 1024 * 1024) + archive = verify_builtins(notice, mapping.decode('utf-8'), rustc) + archive_bytes = read(Path(archive), 128 * 1024 * 1024) + builtins_result = {'target': target, 'rust_revision': RUST_REVISION, 'profile_sha256': BUILTINS_SHA256, 'map_sha256': hashlib.sha256(mapping).hexdigest(), 'archive': PurePosixPath(archive).name, 'archive_bytes': len(archive_bytes), 'archive_sha256': hashlib.sha256(archive_bytes).hexdigest(), 'members': notice['rust_compiler_builtins']['retained']['members']} + (evidence / 'rust-builtins-verification.json').write_text(json.dumps(builtins_result, sort_keys=True, indent=2) + '\n', encoding='utf-8') report = json.loads(read(evidence / 'native-link-inputs.json', 1024 * 1024)) verify_link(notice, report, json.loads(read(evidence / 'sdk-notice-files.json', 48 * 1024 * 1024)), json.loads(read(evidence / 'native-link-command.json', 1024 * 1024)), read(evidence / 'rustc.txt', 64 * 1024).decode('utf-8'), read(evidence / 'compiler-version.txt', 64 * 1024).decode('utf-8')) result = {'target': target, 'binary_sha256': report['binary_sha256'], 'runtime_notice_sha256': hashlib.sha256(data).hexdigest(), 'plain_notice_sha256': hashlib.sha256(plain).hexdigest(), 'profile_sha256': PROFILE_SHA256, 'scope': 'Actual GNU SDK inputs, selected source/license notices and final link process verified; embedding and npm delivery are separate gates, not established by this report.'} From 0eb4370fb0fc4d85a4fcab86c031b9a1cb0d6985 Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sun, 1 Nov 2026 09:40:10 +0100 Subject: [PATCH 40/51] ci(licenses): probe GNU NAPI source variant Test a separate original-0.8.1 Windows GNU LLVM NAPI candidate. Activate the existing dyn-symbols feature and narrowly bypass import-library setup in the two checksum-bound build scripts. Keep all other dependency versions and checksums unchanged. Record the derivative lock and source hashes explicitly instead of presenting the patched source as the original registry graph. Check genuine target cfg, PE CPU/imports, actual link evidence, and the matching x64 Node corpus with the built addon. Upload diagnostic JSON, maps and text only, never native binaries. This probe does not change production release assembly or establish final runtime/source redistribution clearance. No fake DLL, target spoof, registry-cache patch, parser API or version change. Co-Authored-By: Claude Opus 5.5 --- .../windows-gnu-napi-variant-check.yml | 238 ++++++++++++++++++ .../windows-gnu-napi/project-Cargo.toml.txt | 35 +++ .../windows-gnu-napi/project-build.rs.txt | 6 + ci/test_windows_gnu_napi_variant.py | 112 +++++++++ scripts/windows_gnu_napi_variant.py | 152 +++++++++++ 5 files changed, 543 insertions(+) create mode 100644 .github/workflows/windows-gnu-napi-variant-check.yml create mode 100644 ci/fixtures/windows-gnu-napi/project-Cargo.toml.txt create mode 100644 ci/fixtures/windows-gnu-napi/project-build.rs.txt create mode 100644 ci/test_windows_gnu_napi_variant.py create mode 100644 scripts/windows_gnu_napi_variant.py diff --git a/.github/workflows/windows-gnu-napi-variant-check.yml b/.github/workflows/windows-gnu-napi-variant-check.yml new file mode 100644 index 0000000..bbe1776 --- /dev/null +++ b/.github/workflows/windows-gnu-napi-variant-check.yml @@ -0,0 +1,238 @@ +name: Windows GNU NAPI source variant probe + +on: + pull_request: + +permissions: + contents: read + +env: + SOURCE_REF: 562deb3fde092d63a78f359be095e5079929d0d1 + +jobs: + variant: + name: GNU NAPI variant / ${{ matrix.target }} + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + include: + - target: x86_64-pc-windows-gnullvm + compiler: x86_64-w64-mingw32-clang.exe + machine: '34404' + - target: aarch64-pc-windows-gnullvm + compiler: aarch64-w64-mingw32-clang.exe + machine: '43620' + env: + NAPI_TARGET: ${{ matrix.target }} + NAPI_COMPILER: ${{ matrix.compiler }} + NAPI_MACHINE: ${{ matrix.machine }} + steps: + - uses: actions/checkout@v4 + - name: Preserve only reviewed lock and variant tooling + shell: python + run: | + import os + import shutil + from pathlib import Path + stage = Path(os.environ['RUNNER_TEMP']) / 'gnu-napi-tools' + stage.mkdir() + names = ['Cargo.lock', 'scripts/windows_gnu_napi_variant.py', 'ci/test_windows_gnu_napi_variant.py', 'ci/fixtures/windows-gnu-napi/project-build.rs.txt', 'ci/fixtures/windows-gnu-napi/project-Cargo.toml.txt'] + for name in names: + target = stage / name + target.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(name, target) + - uses: actions/checkout@v4 + with: + ref: ${{ env.SOURCE_REF }} + submodules: recursive + persist-credentials: false + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - uses: actions/setup-node@v4 + with: + node-version: '24' + - uses: dtolnay/rust-toolchain@1.99.1 + with: + targets: ${{ matrix.target }} + - name: Restore tooling without copying current binding APIs + shell: python + run: | + import os + import shutil + import subprocess + from pathlib import Path + stage = Path(os.environ['RUNNER_TEMP']) / 'gnu-napi-tools' + for source in stage.rglob('*'): + if source.is_file(): + target = Path(source.relative_to(stage)) + target.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(source, target) + subprocess.run(['git', 'diff', '--exit-code', '--', 'Cargo.toml', 'crates', 'ts', 'tests', 'package.json', 'package-lock.json'], check=True) + - name: Verify source and lock variant guards + run: python -I -m unittest discover -s ci -p test_windows_gnu_napi_variant.py -v + - name: Fetch the original locked dependency graph + run: cargo fetch --locked + - name: Install checksum-pinned LLVM MinGW SDK + shell: python + run: | + import hashlib + import os + import stat + import subprocess + import urllib.request + import zipfile + from pathlib import Path, PurePosixPath + root = Path(os.environ['RUNNER_TEMP']) + sdk = root / 'gnu-napi-sdk' + sdk.mkdir() + archive_path = sdk / 'sdk.zip' + url = 'https://github.com/mstorsjo/llvm-mingw/releases/download/20261020/llvm-mingw-20261020-ucrt-x86_64.zip' + digest = hashlib.sha256() + size = 0 + with urllib.request.urlopen(url, timeout=120) as source, archive_path.open('xb') as output: + while chunk := source.read(1024 * 1024): + size += len(chunk) + if size > 256 * 1024 * 1024: + raise SystemExit('SDK archive exceeds bound') + digest.update(chunk) + output.write(chunk) + if digest.hexdigest() != 'fd5462b7f5d93b2ff981fcd3f9c7e427e47f3203c64ea91c27bcc444eebd74cd': + raise SystemExit('SDK archive differs from reviewed LLVM MinGW input') + with zipfile.ZipFile(archive_path) as archive: + seen = set() + for item in archive.infolist(): + path = PurePosixPath(item.filename) + if path.is_absolute() or '..' in path.parts or '\\' in item.filename or ':' in item.filename or item.filename.casefold() in seen or stat.S_ISLNK(item.external_attr >> 16): + raise SystemExit('unsafe or duplicate SDK member') + seen.add(item.filename.casefold()) + archive.extractall(sdk) + install = sdk / 'llvm-mingw-20261020-ucrt-x86_64' + compiler = install / 'bin' / os.environ['NAPI_COMPILER'] + if not compiler.is_file(): + raise SystemExit('exact target compiler missing') + key = 'CARGO_TARGET_' + os.environ['NAPI_TARGET'].upper().replace('-', '_') + '_LINKER' + flags = ['-C', 'target-feature=+crt-static', '-C', 'link-arg=-Wl,-Map,' + (root / 'gnu-napi-evidence/native-link.map').as_posix()] + with Path(os.environ['GITHUB_ENV']).open('a', encoding='utf-8') as output: + for name, value in [(key, str(compiler)), ('CARGO_ENCODED_RUSTFLAGS', chr(31).join(flags)), ('LLVM_MINGW_PROBE', str(install))]: + output.write(name + '=' + value + '\n') + with Path(os.environ['GITHUB_PATH']).open('a', encoding='utf-8') as output: + output.write(str(install / 'bin') + '\n') + - name: Prepare explicit derivative source and feature graph + shell: python + run: | + import hashlib + import json + import os + import subprocess + import sys + import urllib.request + from pathlib import Path + root = Path(os.environ['RUNNER_TEMP']) + archive = root / 'napi-original-3.15.0.crate' + with urllib.request.urlopen('https://static.crates.io/crates/napi/napi-3.15.0.crate', timeout=60) as source: + raw = source.read(8 * 1024 * 1024 + 1) + if len(raw) > 8 * 1024 * 1024 or hashlib.sha256(raw).hexdigest() != '6a746ad50efbfb632ade1de4025519a477decbbd798cea1a6ac41d7c44f80083': + raise SystemExit('upstream napi archive identity differs') + archive.write_bytes(raw) + evidence = root / 'gnu-napi-evidence' + config = subprocess.check_output([sys.executable, '-I', 'scripts/windows_gnu_napi_variant.py', str(archive), str(root / 'gnu-napi-vendor'), str(evidence)], text=True).strip() + cfg = subprocess.check_output(['rustc', '--print', 'cfg', '--target', os.environ['NAPI_TARGET']], text=True) + if 'target_os="windows"' not in cfg or 'target_env="gnu"' not in cfg: + raise SystemExit('genuine GNU target cfg required') + rustc = subprocess.check_output(['rustc', '--version', '--verbose']) + if b'commit-hash: 58cf8f9c35b355199727627d07ae34a4e2846d67' not in rustc: + raise SystemExit('unreviewed Rust compiler') + (evidence / 'rustc.txt').write_bytes(rustc) + (evidence / 'target-cfg.txt').write_text(cfg, encoding='utf-8') + compiler = Path(os.environ['LLVM_MINGW_PROBE']) / 'bin' / os.environ['NAPI_COMPILER'] + (evidence / 'compiler-version.txt').write_bytes(subprocess.check_output([str(compiler), '--version'])) + record = json.loads((evidence / 'source-variant.json').read_text(encoding='utf-8')) + record.update({'target': os.environ['NAPI_TARGET'], 'tooling_ref': os.environ['GITHUB_SHA'], 'sdk_archive_sha256': 'fd5462b7f5d93b2ff981fcd3f9c7e427e47f3203c64ea91c27bcc444eebd74cd', 'compiler_sha256': hashlib.sha256(compiler.read_bytes()).hexdigest()}) + (evidence / 'source-variant.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') + subprocess.run(['cargo', 'build', '--locked', '--release', '-p', 'ktav-napi', '--target', os.environ['NAPI_TARGET'], '--config', config], check=True) + - name: Capture actual GNU PE and link evidence without distributing binaries + shell: python + run: | + import hashlib + import json + import os + import re + import struct + import subprocess + from pathlib import Path + root = Path(os.environ['RUNNER_TEMP']) + evidence = root / 'gnu-napi-evidence' + binary = Path('target') / os.environ['NAPI_TARGET'] / 'release/ktav_napi.dll' + raw = binary.read_bytes() + if len(raw) < 64 or len(raw) > 128 * 1024 * 1024 or raw[:2] != b'MZ': + raise SystemExit('bounded native PE required') + offset = int.from_bytes(raw[60:64], 'little') + if offset + 24 > len(raw) or raw[offset:offset + 4] != b'PE\0\0' or struct.unpack_from(' limit: + raise ValueError('variant input exceeds bound') + return raw + + +def replace_once(raw, old, new): + if raw.count(old) != 1: + raise ValueError('variant source anchor differs') + return raw.replace(old, new) + + +def patch_upstream(raw): + if sha(raw) != UPSTREAM_BUILD_SHA: + raise ValueError('unreviewed napi build script') + old = b'if target_os == "windows" && target_env == "gnu" {' + new = b'if target_os == "windows" && target_env == "gnu"\n && std::env::var_os("CARGO_FEATURE_DYN_SYMBOLS").is_none() {' + return replace_once(raw, old, new) + + +def patch_project(raw): + if sha(raw) != PROJECT_BUILD_SHA: + raise ValueError('unreviewed first-party NAPI build script') + old = b' napi_build::setup();' + new = b' if !(std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows")\n && std::env::var("CARGO_CFG_TARGET_ENV").as_deref() == Ok("gnu")) {\n napi_build::setup();\n }' + return replace_once(raw, old, new) + + +def patch_manifest(raw): + if sha(raw) != MANIFEST_SHA: + raise ValueError('unreviewed first-party NAPI manifest') + return replace_once(raw, b'features = ["napi8", "compat-mode"]', b'features = ["napi8", "compat-mode", "dyn-symbols"]') + + +def verify_lock(before, after): + if before.get('version') not in {3, 4} or after.get('version') not in {3, 4}: + raise ValueError('unreviewed variant lock format') + expected = copy.deepcopy(before['package']) + original = [item for item in expected if item['name'] == 'napi'] + if len(original) != 1 or original[0]['version'] != '3.15.0' or original[0].get('checksum') != CRATE_SHA: + raise ValueError('original napi registry identity differs') + original[0].pop('source') + original[0].pop('checksum') + order = lambda item: (item['name'], item['version'], item.get('source', '')) + if sorted(expected, key=order) != sorted(after['package'], key=order): + raise ValueError('variant changes packages beyond the explicit napi source identity') + + +def unpack(archive_path, destination): + raw = read(archive_path, 8 * 1024 * 1024) + if sha(raw) != CRATE_SHA: + raise ValueError('original napi archive checksum differs') + destination.mkdir() + with tarfile.open(archive_path, 'r:gz') as archive: + entries = archive.getmembers() + if len(entries) > 4096 or sum(item.size for item in entries) > 64 * 1024 * 1024: + raise ValueError('napi source archive exceeds bounds') + seen = set() + for item in entries: + path = PurePosixPath(item.name) + if path.is_absolute() or '..' in path.parts or '\\' in item.name or ':' in item.name or not path.parts or path.parts[0] != 'napi-3.15.0' or item.name.casefold() in seen or not (item.isdir() or item.isfile()): + raise ValueError('unsafe or duplicate napi source entry') + seen.add(item.name.casefold()) + target = destination.joinpath(*path.parts) + if item.isdir(): + target.mkdir(parents=True, exist_ok=True) + else: + if item.size > 4 * 1024 * 1024: + raise ValueError('napi source member exceeds bound') + target.parent.mkdir(parents=True, exist_ok=True) + with archive.extractfile(item) as source, target.open('xb') as output: + content = source.read(4 * 1024 * 1024 + 1) + if len(content) != item.size: + raise ValueError('napi source member size differs') + output.write(content) + return destination / 'napi-3.15.0' + + +def prepare(archive_path, vendor_directory, evidence): + if subprocess.check_output(['git', 'rev-parse', 'HEAD'], text=True).strip() != SOURCE: + raise ValueError('variant requires exact original 0.8.1 source') + lock = read(Path('Cargo.lock'), 4 * 1024 * 1024) + if sha(lock) != LOCK_SHA: + raise ValueError('variant requires exact reviewed original lock') + evidence.mkdir() + (evidence / 'Cargo.original.lock').write_bytes(lock) + before_source = read(Path('crates/napi/src/lib.rs'), 1024 * 1024) + vendor = unpack(archive_path, vendor_directory) + overlays = [] + for role, path, patch in [('upstream-build', vendor / 'build.rs', patch_upstream), ('project-build', Path('crates/napi/build.rs'), patch_project), ('project-manifest', Path('crates/napi/Cargo.toml'), patch_manifest)]: + original = read(path, 1024 * 1024) + changed = patch(original) + path.write_bytes(changed) + overlays.append({'role': role, 'original_sha256': sha(original), 'compiled_sha256': sha(changed)}) + config = 'patch.crates-io.napi.path=' + json.dumps(str(vendor.resolve())) + command = ['cargo', 'metadata', '--offline', '--format-version', '1', '--manifest-path', 'crates/napi/Cargo.toml', '--config', config] + metadata_raw = subprocess.check_output(command) + metadata = json.loads(metadata_raw) + after_lock = read(Path('Cargo.lock'), 4 * 1024 * 1024) + verify_lock(tomllib.loads(lock.decode()), tomllib.loads(after_lock.decode())) + for name, version in [('napi', '3.15.0'), ('napi-sys', '3.4.1')]: + packages = [item for item in metadata['packages'] if item['name'] == name and item['version'] == version] + if len(packages) != 1: + raise ValueError('expected exact dynamic NAPI package identity') + if name == 'napi' and (packages[0].get('source') is not None or Path(packages[0]['manifest_path']).resolve() != (vendor / 'Cargo.toml').resolve()): + raise ValueError('variant did not select the explicit patched source') + nodes = [item for item in metadata['resolve']['nodes'] if item['id'] == packages[0]['id']] + if len(nodes) != 1 or 'dyn-symbols' not in nodes[0]['features']: + raise ValueError('GNU probe requires actual resolved dyn-symbols') + if read(Path('crates/napi/src/lib.rs'), 1024 * 1024) != before_source: + raise ValueError('variant changed parser binding source') + changed = subprocess.check_output(['git', 'diff', '--name-only', '--', 'Cargo.toml', '.cargo', 'crates', 'ts', 'tests', 'package.json', 'package-lock.json'], text=True).splitlines() + if set(changed) != {'crates/napi/build.rs', 'crates/napi/Cargo.toml'}: + raise ValueError('variant changed unreviewed first-party source files') + (evidence / 'Cargo.variant.lock').write_bytes(after_lock) + (evidence / 'metadata.variant.json').write_bytes(metadata_raw) + record = {'source_ref': SOURCE, 'upstream_archive_sha256': CRATE_SHA, 'original_lock_sha256': LOCK_SHA, 'variant_lock_sha256': sha(after_lock), 'binding_lib_sha256': sha(before_source), 'overlays': overlays, 'config': config, 'scope': 'Explicit experimental source/feature variant, not the original registry graph, production build or historical package. Other locked packages unchanged.'} + (evidence / 'source-variant.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') + return config + + +if __name__ == '__main__': + if len(sys.argv) != 4: + raise SystemExit('usage: windows_gnu_napi_variant.py ARCHIVE NEW_VENDOR_DIRECTORY NEW_EVIDENCE_DIRECTORY') + print(prepare(*map(Path, sys.argv[1:]))) From 4d9615c92ad6e5b9ecffd3af5b2eaa47fb7e5654 Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sun, 1 Nov 2026 11:04:32 +0100 Subject: [PATCH 41/51] ci(licenses): bind GNU NAPI grants to native inputs Prepare complete Cargo, Rust compiler, MinGW, LLVM and upstream NAPI notices for the explicit original-0.8.1 GNU source/feature variant. Keep both upstream MIT attribution sections and exact source grants. Require checksum-bound SDK inputs, the target-specific retained COFF object ledger and actual embedded-resource equality before staging native artifacts. Retain complete legal and source roles with a hashed payload manifest. Upload native candidates only after all gates, including the matching-x64 Node corpus, pass. Keep linker reproduction archives private to CI and ARM execution unclaimed. Do not change production release assembly, versions, registry cache, parser APIs, other dependency identities or historical packages. Co-Authored-By: Claude Opus 5.5 --- .../windows-gnu-napi-variant-check.yml | 45 +- .../windows-gnu-napi/project-config.toml.txt | 29 + .../windows-gnu-napi/resource-build.rs.txt | 101 +++ ci/licenses/napi-gnullvm-runtime.json | 819 ++++++++++++++++++ .../compiler-builtins-Cargo.toml.txt | 62 ++ .../compiler-builtins-LICENSE.txt | 275 ++++++ ...er-builtins-aarch64-outline-atomics.rs.txt | 467 ++++++++++ .../compiler-builtins-aarch64.rs.txt | 17 + .../compiler-builtins-build.rs.txt | 649 ++++++++++++++ .../compiler-builtins-float-conv.rs.txt | 508 +++++++++++ .../compiler-builtins-math-mod.rs.txt | 211 +++++ .../compiler-rt-CREDITS.TXT | 36 + .../compiler-rt-LICENSE.TXT | 311 +++++++ .../compiler-rt-aarch64-cpu-model.c.txt | 94 ++ .../compiler-rt-aarch64-lse.S.txt | 270 ++++++ .../rust-compiler-originals/libm-LICENSE.txt | 258 ++++++ .../libm-generic-trunc.rs.txt | 36 + .../rust-compiler-originals/libm-trunc.rs.txt | 147 ++++ ci/rust-compiler-notices.json | 163 ++++ ci/test_napi_gnullvm_notices.py | 145 ++++ scripts/napi_gnullvm_notices.py | 213 +++++ scripts/prepare_gnu_napi_variant_notices.py | 144 +++ scripts/rust_compiler_notices.py | 65 ++ scripts/stage_gnu_napi_variant.py | 130 +++ 24 files changed, 5189 insertions(+), 6 deletions(-) create mode 100644 ci/fixtures/windows-gnu-napi/project-config.toml.txt create mode 100644 ci/fixtures/windows-gnu-napi/resource-build.rs.txt create mode 100644 ci/licenses/napi-gnullvm-runtime.json create mode 100644 ci/licenses/rust-compiler-originals/compiler-builtins-Cargo.toml.txt create mode 100644 ci/licenses/rust-compiler-originals/compiler-builtins-LICENSE.txt create mode 100644 ci/licenses/rust-compiler-originals/compiler-builtins-aarch64-outline-atomics.rs.txt create mode 100644 ci/licenses/rust-compiler-originals/compiler-builtins-aarch64.rs.txt create mode 100644 ci/licenses/rust-compiler-originals/compiler-builtins-build.rs.txt create mode 100644 ci/licenses/rust-compiler-originals/compiler-builtins-float-conv.rs.txt create mode 100644 ci/licenses/rust-compiler-originals/compiler-builtins-math-mod.rs.txt create mode 100644 ci/licenses/rust-compiler-originals/compiler-rt-CREDITS.TXT create mode 100644 ci/licenses/rust-compiler-originals/compiler-rt-LICENSE.TXT create mode 100644 ci/licenses/rust-compiler-originals/compiler-rt-aarch64-cpu-model.c.txt create mode 100644 ci/licenses/rust-compiler-originals/compiler-rt-aarch64-lse.S.txt create mode 100644 ci/licenses/rust-compiler-originals/libm-LICENSE.txt create mode 100644 ci/licenses/rust-compiler-originals/libm-generic-trunc.rs.txt create mode 100644 ci/licenses/rust-compiler-originals/libm-trunc.rs.txt create mode 100644 ci/rust-compiler-notices.json create mode 100644 ci/test_napi_gnullvm_notices.py create mode 100644 scripts/napi_gnullvm_notices.py create mode 100644 scripts/prepare_gnu_napi_variant_notices.py create mode 100644 scripts/rust_compiler_notices.py create mode 100644 scripts/stage_gnu_napi_variant.py diff --git a/.github/workflows/windows-gnu-napi-variant-check.yml b/.github/workflows/windows-gnu-napi-variant-check.yml index bbe1776..8d7f472 100644 --- a/.github/workflows/windows-gnu-napi-variant-check.yml +++ b/.github/workflows/windows-gnu-napi-variant-check.yml @@ -1,4 +1,4 @@ -name: Windows GNU NAPI source variant probe +name: Windows GNU NAPI source-bound notice candidate on: pull_request: @@ -13,6 +13,7 @@ jobs: variant: name: GNU NAPI variant / ${{ matrix.target }} runs-on: windows-latest + timeout-minutes: 45 strategy: fail-fast: false matrix: @@ -37,7 +38,9 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'gnu-napi-tools' stage.mkdir() - names = ['Cargo.lock', 'scripts/windows_gnu_napi_variant.py', 'ci/test_windows_gnu_napi_variant.py', 'ci/fixtures/windows-gnu-napi/project-build.rs.txt', 'ci/fixtures/windows-gnu-napi/project-Cargo.toml.txt'] + names = ['Cargo.lock', 'scripts/windows_gnu_napi_variant.py', 'ci/test_windows_gnu_napi_variant.py', 'ci/fixtures/windows-gnu-napi/project-build.rs.txt', 'ci/fixtures/windows-gnu-napi/project-Cargo.toml.txt', + 'scripts/prepare_gnu_napi_variant_notices.py', 'scripts/stage_gnu_napi_variant.py', 'scripts/napi_gnullvm_notices.py', 'scripts/rust_compiler_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/patch_napi_notice_source.py', 'scripts/check_embedded_notices.py', 'ci/about.toml', 'ci/licenses/js-source-supplements.json', 'ci/licenses/napi-gnullvm-runtime.json', 'ci/rust-compiler-notices.json', 'ci/test_napi_gnullvm_notices.py', 'ci/fixtures/windows-gnu-napi/project-config.toml.txt', 'ci/fixtures/windows-gnu-napi/resource-build.rs.txt', + *[str(path) for path in Path('ci/licenses/rust-compiler-originals').glob('*')]] for name in names: target = stage / name target.parent.mkdir(parents=True, exist_ok=True) @@ -56,6 +59,10 @@ jobs: - uses: dtolnay/rust-toolchain@1.99.1 with: targets: ${{ matrix.target }} + components: rust-docs + - uses: taiki-e/install-action@v2 + with: + tool: cargo-about@0.9.3 - name: Restore tooling without copying current binding APIs shell: python run: | @@ -72,6 +79,8 @@ jobs: subprocess.run(['git', 'diff', '--exit-code', '--', 'Cargo.toml', 'crates', 'ts', 'tests', 'package.json', 'package-lock.json'], check=True) - name: Verify source and lock variant guards run: python -I -m unittest discover -s ci -p test_windows_gnu_napi_variant.py -v + - name: Verify complete source/runtime grants and resource overlays + run: python -I -m unittest discover -s ci -p test_napi_gnullvm_notices.py -v - name: Fetch the original locked dependency graph run: cargo fetch --locked - name: Install checksum-pinned LLVM MinGW SDK @@ -113,7 +122,7 @@ jobs: if not compiler.is_file(): raise SystemExit('exact target compiler missing') key = 'CARGO_TARGET_' + os.environ['NAPI_TARGET'].upper().replace('-', '_') + '_LINKER' - flags = ['-C', 'target-feature=+crt-static', '-C', 'link-arg=-Wl,-Map,' + (root / 'gnu-napi-evidence/native-link.map').as_posix()] + flags = ['-C', 'target-feature=+crt-static', '-C', 'link-arg=-Wl,-Map,' + (root / 'gnu-napi-evidence/native-link.map').as_posix(), '-C', 'link-arg=-Wl,--reproduce=' + (root / 'gnu-napi-link.tar').as_posix()] with Path(os.environ['GITHUB_ENV']).open('a', encoding='utf-8') as output: for name, value in [(key, str(compiler)), ('CARGO_ENCODED_RUSTFLAGS', chr(31).join(flags)), ('LLVM_MINGW_PROBE', str(install))]: output.write(name + '=' + value + '\n') @@ -151,8 +160,13 @@ jobs: record = json.loads((evidence / 'source-variant.json').read_text(encoding='utf-8')) record.update({'target': os.environ['NAPI_TARGET'], 'tooling_ref': os.environ['GITHUB_SHA'], 'sdk_archive_sha256': 'fd5462b7f5d93b2ff981fcd3f9c7e427e47f3203c64ea91c27bcc444eebd74cd', 'compiler_sha256': hashlib.sha256(compiler.read_bytes()).hexdigest()}) (evidence / 'source-variant.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') - subprocess.run(['cargo', 'build', '--locked', '--release', '-p', 'ktav-napi', '--target', os.environ['NAPI_TARGET'], '--config', config], check=True) - - name: Capture actual GNU PE and link evidence without distributing binaries + subprocess.run([sys.executable, '-I', 'scripts/prepare_gnu_napi_variant_notices.py', str(evidence), os.environ['NAPI_TARGET']], check=True) + subprocess.run([sys.executable, '-I', 'scripts/napi_gnullvm_notices.py', 'prepare', str(evidence), os.environ['NAPI_TARGET']], check=True) + environment = {**os.environ, 'KTAV_NAPI_NOTICES_GZIP': str(evidence / 'NOTICE.json.gz')} + subprocess.run(['cargo', 'build', '--locked', '--release', '-p', 'ktav-napi', '--target', os.environ['NAPI_TARGET'], '--config', config], env=environment, check=True) + if Path('Cargo.lock').read_bytes() != (evidence / 'Cargo.variant.lock').read_bytes(): + raise SystemExit('compiled variant lock changed') + - name: Capture actual GNU PE and verify source-bound notices before native upload shell: python run: | import hashlib @@ -161,6 +175,7 @@ jobs: import re import struct import subprocess + import sys from pathlib import Path root = Path(os.environ['RUNNER_TEMP']) evidence = root / 'gnu-napi-evidence' @@ -186,8 +201,10 @@ jobs: map_raw = mapping.read_bytes() if re.search(rb'(?i)(?:vcruntime|libcmt)[^\s()]*[.]lib|VC[/\\]Tools[/\\]MSVC', map_raw): raise SystemExit('actual map contains Microsoft startup inputs') - record = {'target': os.environ['NAPI_TARGET'], 'binary_sha256': hashlib.sha256(raw).hexdigest(), 'map_sha256': hashlib.sha256(map_raw).hexdigest(), 'imports': imports, 'machine': int(os.environ['NAPI_MACHINE']), 'native_binary_uploaded': False, 'scope': 'Experimental GNU source-variant compilation and PE/link evidence only. Not production distribution or final runtime/source grant clearance.'} + subprocess.run([sys.executable, '-I', 'scripts/stage_gnu_napi_variant.py', 'capture', str(root / 'gnu-napi-link.tar'), str(evidence / 'link-input-fingerprints.json')], check=True) + record = {'target': os.environ['NAPI_TARGET'], 'binary_sha256': hashlib.sha256(raw).hexdigest(), 'map_sha256': hashlib.sha256(map_raw).hexdigest(), 'imports': imports, 'machine': int(os.environ['NAPI_MACHINE']), 'scope': 'Actual GNU source-variant PE and linker input identity; runtime/resource gate recorded separately. Not npm or historical package clearance.'} (evidence / 'binary-verification.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') + subprocess.run([sys.executable, '-I', 'scripts/napi_gnullvm_notices.py', 'verify', str(evidence), str(binary), os.environ['NAPI_TARGET']], check=True) - name: Verify actual x64 Node consumer using the built GNU addon if: matrix.target == 'x86_64-pc-windows-gnullvm' shell: python @@ -226,6 +243,22 @@ jobs: raise SystemExit('native corpus incomplete or summary missing') record = {'target': os.environ['NAPI_TARGET'], 'binary_sha256': hashlib.sha256(binary.read_bytes()).hexdigest(), 'loaded_built_addon': True, 'sdk_path_removed': True, 'legacy_loader_filename': destination.name, 'scope': 'Legacy loader filename compatibility, not an MSVC target claim. Actual GNU target is recorded in compiler and PE evidence. ARM execution not claimed.'} (evidence / 'consumer-verification.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') + - name: Stage complete native legal and source roles after all gates + shell: python + run: | + import os + import subprocess + import sys + from pathlib import Path + evidence = Path(os.environ['RUNNER_TEMP']) / 'gnu-napi-evidence' + binary = Path('target') / os.environ['NAPI_TARGET'] / 'release/ktav_napi.dll' + subprocess.run([sys.executable, '-I', 'scripts/stage_gnu_napi_variant.py', 'stage', str(evidence), str(binary), os.environ['NAPI_TARGET']], check=True) + - uses: actions/upload-artifact@v4 + with: + name: gnu-napi-native-candidate-${{ matrix.target }} + path: ${{ runner.temp }}/gnu-napi-native-payload/ + include-hidden-files: true + if-no-files-found: error - uses: actions/upload-artifact@v4 if: always() with: diff --git a/ci/fixtures/windows-gnu-napi/project-config.toml.txt b/ci/fixtures/windows-gnu-napi/project-config.toml.txt new file mode 100644 index 0000000..08fb8ec --- /dev/null +++ b/ci/fixtures/windows-gnu-napi/project-config.toml.txt @@ -0,0 +1,29 @@ +# Cargo aliases for the common lint / check flows. +# +# Use with the GNU toolchain on Windows to dodge the MSVC linker +# dance for `ktav-wasm`: +# +# cargo +stable-x86_64-pc-windows-gnu clippy-wasm -- -D warnings +# +# On Linux / macOS (or a Windows box whose default toolchain is +# already GNU) the `+` prefix is unnecessary: +# +# cargo clippy-wasm -- -D warnings +# +# `clippy-napi` always needs the MSVC toolchain on Windows — the +# final cdylib links against node.dll imports. Either launch it from +# a shell with vcvars64 sourced, or run `npm run lint:rust` which +# dispatches to `scripts/lint-rust-napi-windows.bat` for you. +[alias] +clippy-wasm = ["clippy", "-p", "ktav-wasm", "--target", "wasm32-unknown-unknown", "--all-targets"] +clippy-napi = ["clippy", "-p", "ktav-napi", "--all-targets"] + +# musl cdylib needs dynamic crt — Rust's default for musl targets is +# `crt-static`, which refuses cdylib with `cannot produce cdylib ... +# does not support these crate types`. Disable it for both musl targets +# we cross-compile to. +[target.aarch64-unknown-linux-musl] +rustflags = ["-C", "target-feature=-crt-static"] + +[target.x86_64-unknown-linux-musl] +rustflags = ["-C", "target-feature=-crt-static"] diff --git a/ci/fixtures/windows-gnu-napi/resource-build.rs.txt b/ci/fixtures/windows-gnu-napi/resource-build.rs.txt new file mode 100644 index 0000000..e904702 --- /dev/null +++ b/ci/fixtures/windows-gnu-napi/resource-build.rs.txt @@ -0,0 +1,101 @@ +use std::io::{self, Read}; + +const MARKER: &[u8] = b"KTAV-NOTICES-GZIP-v1\0"; +const MAX_GZIP: usize = 4 * 1024 * 1024; + +fn notice_resource(source: impl Read) -> io::Result> { + let mut payload = Vec::new(); + source + .take((MAX_GZIP + 1) as u64) + .read_to_end(&mut payload)?; + if payload.len() > MAX_GZIP || !payload.starts_with(&[0x1f, 0x8b, 0x08]) { + return Err(io::Error::new( + io::ErrorKind::InvalidData, + "NAPI notices must be a gzip payload of at most 4 MiB", + )); + } + let mut resource = Vec::with_capacity(MARKER.len() + 8 + payload.len()); + resource.extend_from_slice(MARKER); + resource.extend_from_slice(&(payload.len() as u64).to_le_bytes()); + resource.extend_from_slice(&payload); + Ok(resource) +} + +// napi-build injects the linker flags N-API needs on each platform — +// on macOS, `-undefined dynamic_lookup`; on Windows, the import lib for +// node.dll; on Linux, nothing extra. Required by `napi-rs`. +fn main() -> io::Result<()> { + napi_build::setup(); + println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rerun-if-env-changed=KTAV_NAPI_NOTICES_GZIP"); + let resource = match std::env::var_os("KTAV_NAPI_NOTICES_GZIP") { + Some(path) => { + let path = std::path::PathBuf::from(path); + println!("cargo:rerun-if-changed={}", path.display()); + notice_resource(std::fs::File::open(path)?)? + } + None => Vec::new(), + }; + let output = std::env::var_os("OUT_DIR") + .ok_or_else(|| io::Error::new(io::ErrorKind::NotFound, "missing OUT_DIR"))?; + std::fs::write( + std::path::PathBuf::from(output).join("ktav-napi-notices.resource"), + resource, + ) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn resource_keeps_marker_length_and_payload() { + let payload = [0x1f, 0x8b, 0x08, 0, 0]; + let resource = notice_resource(payload.as_slice()).unwrap(); + assert_eq!(&resource[..MARKER.len()], MARKER); + assert_eq!( + &resource[MARKER.len()..MARKER.len() + 8], + &(payload.len() as u64).to_le_bytes() + ); + assert_eq!(&resource[MARKER.len() + 8..], payload); + } + + #[test] + fn empty_and_non_gzip_payloads_are_rejected() { + for payload in [&[][..], b"not gzip", &[0x1f, 0x8b]] { + assert_eq!( + notice_resource(payload).unwrap_err().kind(), + io::ErrorKind::InvalidData + ); + } + } + + #[test] + fn exact_bound_is_allowed_but_one_extra_byte_is_rejected() { + let mut payload = vec![0; MAX_GZIP]; + payload[..3].copy_from_slice(&[0x1f, 0x8b, 0x08]); + assert_eq!( + notice_resource(payload.as_slice()).unwrap().len(), + MARKER.len() + 8 + MAX_GZIP + ); + payload.push(0); + assert_eq!( + notice_resource(payload.as_slice()).unwrap_err().kind(), + io::ErrorKind::InvalidData + ); + } + + #[test] + fn read_errors_are_propagated() { + struct Failed; + impl Read for Failed { + fn read(&mut self, _: &mut [u8]) -> io::Result { + Err(io::Error::new(io::ErrorKind::PermissionDenied, "fixture")) + } + } + assert_eq!( + notice_resource(Failed).unwrap_err().kind(), + io::ErrorKind::PermissionDenied + ); + } +} diff --git a/ci/licenses/napi-gnullvm-runtime.json b/ci/licenses/napi-gnullvm-runtime.json new file mode 100644 index 0000000..1614888 --- /dev/null +++ b/ci/licenses/napi-gnullvm-runtime.json @@ -0,0 +1,819 @@ +{ + "coverage": "Exact Windows GNU NAPI retained-object policy, complete original SDK/NAPI legal documents and conservative source/header notice witnesses. Does not claim that every collected source line is linked, an unpatched registry graph, ARM execution, SDK source-build reproducibility or historical asset repair.", + "llvm_revision": "7a941dfb2877a0b8cf30323fefa85ad019e0b0f5", + "mingw_revision": "0d6dfbc348dfad714761c0a7151615767f96bcb5", + "original_documents": [ + { + "git_blob": "fa6ac540007032cbd0ec772a1c72e6cb5527a4fe", + "path": "LICENSE.TXT", + "sha256": "8d85c1057d742e597985c7d4e6320b015a9139385cff4cbae06ffc0ebe89afee", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/LICENSE.TXT", + "text": "==============================================================================\nThe LLVM Project is under the Apache License v2.0 with LLVM Exceptions:\n==============================================================================\n\n Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n APPENDIX: How to apply the Apache License to your work.\n\n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n\n Copyright [yyyy] [name of copyright owner]\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n\n---- LLVM Exceptions to the Apache 2.0 License ----\n\nAs an exception, if, as a result of your compiling your source code, portions\nof this Software are embedded into an Object form of such source code, you\nmay redistribute such embedded portions in such Object form without complying\nwith the conditions of Sections 4(a), 4(b) and 4(d) of the License.\n\nIn addition, if you combine or link compiled forms of this Software with\nsoftware that is licensed under the GPLv2 (\"Combined Software\") and if a\ncourt of competent jurisdiction determines that the patent provision (Section\n3), the indemnity provision (Section 9) or other Section of the License\nconflicts with the conditions of the GPLv2, you may retroactively and\nprospectively choose to deem waived or otherwise exclude such Section(s) of\nthe License, but only in their entirety and only with respect to the Combined\nSoftware.\n\n==============================================================================\nSoftware from third parties included in the LLVM Project:\n==============================================================================\nThe LLVM Project contains third party software which is under different license\nterms. All such code will be identified clearly using at least one of two\nmechanisms:\n1) It will be in a separate directory tree with its own `LICENSE.txt` or\n `LICENSE` file at the top containing the specific license and restrictions\n which apply to that software, or\n2) It will contain specific license and restriction terms at the top of every\n file.\n\n==============================================================================\nLegacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy):\n==============================================================================\nUniversity of Illinois/NCSA\nOpen Source License\n\nCopyright (c) 2003-2019 University of Illinois at Urbana-Champaign.\nAll rights reserved.\n\nDeveloped by:\n\n LLVM Team\n\n University of Illinois at Urbana-Champaign\n\n http://llvm.org\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal with\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\n * Redistributions of source code must retain the above copyright notice,\n this list of conditions and the following disclaimers.\n\n * Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimers in the\n documentation and/or other materials provided with the distribution.\n\n * Neither the names of the LLVM Team, University of Illinois at\n Urbana-Champaign, nor the names of its contributors may be used to\n endorse or promote products derived from this Software without specific\n prior written permission.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nCONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE\nSOFTWARE.\n\n" + }, + { + "git_blob": "1e3120621caeb62648745a42f7a9a25d1e2731ab", + "path": "libunwind/LICENSE.TXT", + "sha256": "b5efebcaca80879234098e52d1725e6d9eb8fb96a19fce625d39184b705f7b6d", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/LICENSE.TXT", + "text": "==============================================================================\nThe LLVM Project is under the Apache License v2.0 with LLVM Exceptions:\n==============================================================================\n\n Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n APPENDIX: How to apply the Apache License to your work.\n\n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n\n Copyright [yyyy] [name of copyright owner]\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n\n---- LLVM Exceptions to the Apache 2.0 License ----\n\nAs an exception, if, as a result of your compiling your source code, portions\nof this Software are embedded into an Object form of such source code, you\nmay redistribute such embedded portions in such Object form without complying\nwith the conditions of Sections 4(a), 4(b) and 4(d) of the License.\n\nIn addition, if you combine or link compiled forms of this Software with\nsoftware that is licensed under the GPLv2 (\"Combined Software\") and if a\ncourt of competent jurisdiction determines that the patent provision (Section\n3), the indemnity provision (Section 9) or other Section of the License\nconflicts with the conditions of the GPLv2, you may retroactively and\nprospectively choose to deem waived or otherwise exclude such Section(s) of\nthe License, but only in their entirety and only with respect to the Combined\nSoftware.\n\n==============================================================================\nSoftware from third parties included in the LLVM Project:\n==============================================================================\nThe LLVM Project contains third party software which is under different license\nterms. All such code will be identified clearly using at least one of two\nmechanisms:\n1) It will be in a separate directory tree with its own `LICENSE.txt` or\n `LICENSE` file at the top containing the specific license and restrictions\n which apply to that software, or\n2) It will contain specific license and restriction terms at the top of every\n file.\n\n==============================================================================\nLegacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy):\n==============================================================================\n\nThe libunwind library is dual licensed under both the University of Illinois\n\"BSD-Like\" license and the MIT license. As a user of this code you may choose\nto use it under either license. As a contributor, you agree to allow your code\nto be used under both.\n\nFull text of the relevant licenses is included below.\n\n==============================================================================\n\nUniversity of Illinois/NCSA\nOpen Source License\n\nCopyright (c) 2009-2019 by the contributors listed in CREDITS.TXT\n\nAll rights reserved.\n\nDeveloped by:\n\n LLVM Team\n\n University of Illinois at Urbana-Champaign\n\n http://llvm.org\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal with\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\n * Redistributions of source code must retain the above copyright notice,\n this list of conditions and the following disclaimers.\n\n * Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimers in the\n documentation and/or other materials provided with the distribution.\n\n * Neither the names of the LLVM Team, University of Illinois at\n Urbana-Champaign, nor the names of its contributors may be used to\n endorse or promote products derived from this Software without specific\n prior written permission.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nCONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE\nSOFTWARE.\n\n==============================================================================\n\nCopyright (c) 2009-2014 by the contributors listed in CREDITS.TXT\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n" + }, + { + "git_blob": "776d5f1034240f6dae0ce59d592f9c6f4ad29e7d", + "path": "COPYING.MinGW-w64-runtime/COPYING.MinGW-w64-runtime.txt", + "sha256": "1db8da07b436c68833c0673ffee3d9fcb2526047f3820b81661865dfedc79a1f", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/COPYING.MinGW-w64-runtime/COPYING.MinGW-w64-runtime.txt", + "text": "MinGW-w64 runtime licensing\n***************************\n\nThis program or library was built using MinGW-w64 and statically\nlinked against the MinGW-w64 runtime. Some parts of the runtime\nare under licenses which require that the copyright and license\nnotices are included when distributing the code in binary form.\nThese notices are listed below.\n\n\n========================\nOverall copyright notice\n========================\n\nCopyright (c) 2009, 2010, 2011, 2012, 2013 by the mingw-w64 project\n\nThis license has been certified as open source. It has also been designated\nas GPL compatible by the Free Software Foundation (FSF).\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n 1. Redistributions in source code must retain the accompanying copyright\n notice, this list of conditions, and the following disclaimer.\n 2. Redistributions in binary form must reproduce the accompanying\n copyright notice, this list of conditions, and the following disclaimer\n in the documentation and/or other materials provided with the\n distribution.\n 3. Names of the copyright holders must not be used to endorse or promote\n products derived from this software without prior written permission\n from the copyright holders.\n 4. The right to distribute this software or to use it for any purpose does\n not give you the right to use Servicemarks (sm) or Trademarks (tm) of\n the copyright holders. Use of them is covered by separate agreement\n with the copyright holders.\n 5. If any files are modified, you must cause the modified files to carry\n prominent notices stating that you changed the files and the date of\n any change.\n\nDisclaimer\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED\nOR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\nOF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO\nEVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\nOR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\nEVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n======================================== \ngetopt, getopt_long, and getop_long_only\n======================================== \n\nCopyright (c) 2002 Todd C. Miller \n \nPermission to use, copy, modify, and distribute this software for any \npurpose with or without fee is hereby granted, provided that the above \ncopyright notice and this permission notice appear in all copies. \n \t \nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\nWITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\nMERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\nANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\nACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\nOR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n\nSponsored in part by the Defense Advanced Research Projects\nAgency (DARPA) and Air Force Research Laboratory, Air Force\nMateriel Command, USAF, under agreement number F39502-99-1-0512.\n\n * * * * * * * \n\nCopyright (c) 2000 The NetBSD Foundation, Inc.\nAll rights reserved.\n\nThis code is derived from software contributed to The NetBSD Foundation\nby Dieter Baron and Thomas Klausner.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n 1. Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n 2. Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS\n``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\nTO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\nINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\nCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\nARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE.\n\n\n===============================================================\ngdtoa: Converting between IEEE floating point numbers and ASCII\n===============================================================\n\nThe author of this software is David M. Gay.\n\nCopyright (C) 1997, 1998, 1999, 2000, 2001 by Lucent Technologies\nAll Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and\nits documentation for any purpose and without fee is hereby\ngranted, provided that the above copyright notice appear in all\ncopies and that both that the copyright notice and this\npermission notice and warranty disclaimer appear in supporting\ndocumentation, and that the name of Lucent or any of its entities\nnot be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior\npermission.\n\nLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.\nIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY\nSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\nIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n\n * * * * * * *\n\nThe author of this software is David M. Gay.\n\nCopyright (C) 2005 by David M. Gay\nAll Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and its\ndocumentation for any purpose and without fee is hereby granted,\nprovided that the above copyright notice appear in all copies and that\nboth that the copyright notice and this permission notice and warranty\ndisclaimer appear in supporting documentation, and that the name of\nthe author or any of his current or former employers not be used in\nadvertising or publicity pertaining to distribution of the software\nwithout specific, written prior permission.\n\nTHE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN\nNO EVENT SHALL THE AUTHOR OR ANY OF HIS CURRENT OR FORMER EMPLOYERS BE\nLIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY\nDAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\nWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\nSOFTWARE.\n\n * * * * * * *\n\nThe author of this software is David M. Gay.\n\nCopyright (C) 2004 by David M. Gay.\nAll Rights Reserved\nBased on material in the rest of /netlib/fp/gdota.tar.gz,\nwhich is copyright (C) 1998, 2000 by Lucent Technologies.\n\nPermission to use, copy, modify, and distribute this software and\nits documentation for any purpose and without fee is hereby\ngranted, provided that the above copyright notice appear in all\ncopies and that both that the copyright notice and this\npermission notice and warranty disclaimer appear in supporting\ndocumentation, and that the name of Lucent or any of its entities\nnot be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior\npermission.\n\nLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.\nIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY\nSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\nIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n\n\n=========================\nParts of the math library\n=========================\n\nCopyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\n\nDeveloped at SunSoft, a Sun Microsystems, Inc. business.\nPermission to use, copy, modify, and distribute this\nsoftware is freely granted, provided that this notice\nis preserved.\n\n * * * * * * *\n\nCopyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\n\nDeveloped at SunPro, a Sun Microsystems, Inc. business.\nPermission to use, copy, modify, and distribute this\nsoftware is freely granted, provided that this notice\nis preserved.\n\n * * * * * * *\n\nFIXME: Cephes math lib\nCopyright (C) 1984-1998 Stephen L. Moshier\n\nIt sounds vague, but as to be found at\n, it gives an\nimpression that the author could be willing to give an explicit\npermission to distribute those files e.g. under a BSD style license. So\nprobably there is no problem here, although it could be good to get a\npermission from the author and then add a license into the Cephes files\nin MinGW runtime. At least on follow-up it is marked that debian sees the\nversion a-like BSD one. As MinGW.org (where those cephes parts are coming\nfrom) distributes them now over 6 years, it should be fine.\n\n=================================================\nSome string, memory and time conversion functions\n=================================================\n\nCopyright © 2005-2020 Rich Felker, et al.\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n===================================\nHeaders and IDLs imported from Wine\n===================================\n\nSome header and IDL files were imported from the Wine project. These files\nare prominent maked in source. Their copyright belongs to contributors and\nthey are distributed under LGPL license.\n\nDisclaimer\n\nThis library is free software; you can redistribute it and/or\nmodify it under the terms of the GNU Lesser General Public\nLicense as published by the Free Software Foundation; either\nversion 2.1 of the License, or (at your option) any later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\nLesser General Public License for more details.\n" + }, + { + "git_blob": "51261a8ec4b5c5b6b074317fab1d7f506eb30425", + "path": "DISCLAIMER", + "sha256": "039ed6b4f31bb7fb97e733170b58cc435335352e4745734fcfd113877fdaf340", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/DISCLAIMER", + "source_revision": "0d6dfbc348dfad714761c0a7151615767f96bcb5", + "text": "/*\n This Software is provided under the Zope Public License (ZPL) Version 2.1.\n\n Copyright (c) 2009, 2010 by the mingw-w64 project\n\n See the AUTHORS file for the list of contributors to the mingw-w64 project.\n\n This license has been certified as open source. It has also been designated\n as GPL compatible by the Free Software Foundation (FSF).\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are met:\n\n 1. Redistributions in source code must retain the accompanying copyright\n notice, this list of conditions, and the following disclaimer.\n 2. Redistributions in binary form must reproduce the accompanying\n copyright notice, this list of conditions, and the following disclaimer\n in the documentation and/or other materials provided with the\n distribution.\n 3. Names of the copyright holders must not be used to endorse or promote\n products derived from this software without prior written permission\n from the copyright holders.\n 4. The right to distribute this software or to use it for any purpose does\n not give you the right to use Servicemarks (sm) or Trademarks (tm) of\n the copyright holders. Use of them is covered by separate agreement\n with the copyright holders.\n 5. If any files are modified, you must cause the modified files to carry\n prominent notices stating that you changed the files and the date of\n any change.\n\n Disclaimer\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED\n OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO\n EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,\n INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, \n OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n" + }, + { + "git_blob": "91fb0d6dc9d1f65394cbec575a857e635868ed74", + "path": "DISCLAIMER.PD", + "sha256": "87f33608570312a0f2a9745edcb2527275df813b13982e8c3b3f893d88a4141a", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/DISCLAIMER.PD", + "source_revision": "0d6dfbc348dfad714761c0a7151615767f96bcb5", + "text": "/**\n * DISCLAIMER\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n *\n * The mingw-w64 runtime package and its code is distributed in the hope that it \n * will be useful but WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESSED OR \n * IMPLIED ARE HEREBY DISCLAIMED. This includes but is not limited to \n * warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n */\n" + }, + { + "git_blob": "4b40f2beb3cac255a09ff12616c22aa89aa9d80f", + "path": "AUTHORS", + "sha256": "8f308316e7a94b8410f871868bd3948f126526dc1775aeee97a0e365f9a0fd9f", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/AUTHORS", + "source_revision": "0d6dfbc348dfad714761c0a7151615767f96bcb5", + "text": "Note\n====\n\nThis file contains information about people who are permitted to make\nchanges to various parts of the runtimes, headers, associated tools,\nand associated libraries. Also the list of contributors to mingw-w64\nare listed here, too.\n\nPlease do not contact the people in this file directly to report\nproblems in mingw-w64.\n\nFor general information about mingw-w64, please visit:\n\n http://sourceforge.net/projects/mingw-w64/\n\nTo report problems in mingw-w64, please visit bug-tracker on:\n\n http://sourceforge.net/projects/mingw-w64/\n\nMaintainers\n===========\n\nMook \nNightStrike \nKai Tietz \n\nDevelopers with write after approval\n====================================\n\nkjk_hyperion \nTor Lillqvist \nAlexey Pushkin \nRoland Schwingel \nOzkan Sezer \nFridrich Strba \nChris Sutcliffe \nJonathan Yong \nJarrod Chesney \nDoug Semler \nJacek Caban \nCorinna Vinschen \nAndré Hentschel \nLiu Hao \nRuslan Garipov \n\nProject members without SVN/Git access\n==================================\n\nxenofears \n\nContributors\n============\n\nWe want to thank the following list of people for supporting us\nby contributions:\n\n20-40 \nProfessor Brian Ripley \nsduplichan \nWesley W. Terpstra \nzhou drangon \nPiotr Caban \n\nand additional thanks to the following organizations:\n\nOneVision Software AG\nReactos project\nWine project\n\nand many others, we possibly missed to mention here and are sorry for this.\n\nIf you think your name is missing and should be mentioned here, please\ncontact us for adding you.\n" + }, + { + "git_blob": "7fe7e35eff46457f65a4e30a717fada632de9e03", + "path": "LICENSE", + "sha256": "3f1ce66533302df3a32edbfdfc0b78f0dd34659e4c1f5817162e5ea3c2297215", + "source": "https://raw.githubusercontent.com/napi-rs/napi-rs/d9cb526c15e63ba30e06b4d169068c9854180595/LICENSE", + "text": "MIT License\n\nCopyright (c) 2020-present LongYinan\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\nMIT License\n\nCopyright (c) 2018 GitHub\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n" + } + ], + "reviewed_napi_evidence": { + "head": "0eb4370fb0fc4d85a4fcab86c031b9a1cb0d6985", + "repository": "ktav-lang/js", + "run": 41289835203 + }, + "schema_version": 1, + "sdk_archive_sha256": "fd5462b7f5d93b2ff981fcd3f9c7e427e47f3203c64ea91c27bcc444eebd74cd", + "sdk_recipe_revision": "e08a31fbfe5cfdad07b698299af22d66e5608383", + "sdk_version": "20261020", + "source_files": [ + { + "git_blob": "a1179c73c5906b2df9bb3973cd7918ad1f42b28a", + "path": "libunwind/include/__libunwind_config.h", + "sha256": "0bb004911d967d5cc2d87d07f81e03668d1cf42c6b9347a95285d9e18f82954c", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/include/__libunwind_config.h", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "6c2dfe58e53bf1f97bca6c78dacb47cc3676b8dc", + "path": "libunwind/include/libunwind.h", + "sha256": "3b411eb68de64e829937faaeec942bbc8e3e3a1c013b55107be2c679df64173c", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/include/libunwind.h", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Compatible with libunwind API documented at:\n// http://www.nongnu.org/libunwind/man/libunwind(3).html\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "c495b83c40b90ae517e390fe659061a7bbbe2603", + "path": "libunwind/include/mach-o/compact_unwind_encoding.h", + "sha256": "a458a96b1257048618e22688e3ad6fc4c36f99e1229b1492b7b800911e651a68", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/include/mach-o/compact_unwind_encoding.h", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Darwin's alternative to DWARF based unwind encodings.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "b1775d3a3decc76e1a0916fead1aafbc6fa0fb51", + "path": "libunwind/include/unwind.h", + "sha256": "e4a58637fc8ca1d29cd600c3c4416aafed50085edf276fa076214c8d81c263f0", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/include/unwind.h", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// C++ ABI Level 1 ABI documented at:\n// https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "68e02e47602d60de9f9d33267e270cb5f73fc5aa", + "path": "libunwind/include/unwind_arm_ehabi.h", + "sha256": "04cf22a069866ae35bf075c36f8d9112700bb9772653d80d9c6c4c856f4e7dbb", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/include/unwind_arm_ehabi.h", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// C++ ABI Level 1 ABI documented at:\n// https://github.com/ARM-software/abi-aa/blob/main/ehabi32/ehabi32.rst\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "860ad36cdf14e2e06cd6fe2f77b9070434240434", + "path": "libunwind/include/unwind_itanium.h", + "sha256": "43ad2c8ca672c8fb9a4eb80d7e05a687ae9134f4899641357c86cecde4efbd1f", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/include/unwind_itanium.h", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// C++ ABI Level 1 ABI documented at:\n// https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "ff3b5fc6fea77fba0f4ebc4d74e72bac984935fa", + "path": "libunwind/src/Unwind-EHABI.h", + "sha256": "c04fdebcd31e26de7615b82751373cc64ef83d02b24dbaaf0e112d0a559acc6b", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/src/Unwind-EHABI.h", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "0b1930b44d1c648b89099b6f2f796b4233f1c877", + "path": "libunwind/src/Unwind-seh.cpp", + "sha256": "058ae089c7d42ade35b730f87443b34018b21bea75a4ea2226e9fffdf7500160", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/src/Unwind-seh.cpp", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n//\n// Implements SEH-based Itanium C++ exceptions.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "1764499b304f1ac4ed665829d7cc47793ebf9766", + "path": "libunwind/src/UnwindLevel1-gcc-ext.c", + "sha256": "93d2bb050caf6b4f80819b93340ae5aad91f44e633996cc7dd32dca90da05fe0", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/src/UnwindLevel1-gcc-ext.c", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Implements gcc extensions to the C++ ABI Exception Handling Level 1.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "834fdae6a76d3e28bde5ece20c45f367a47b1f12", + "path": "libunwind/src/UnwindLevel1.c", + "sha256": "16e16fbc0c85873df1a445d7b204fb363e46c68d6a2815dc68257108b5c944c8", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/src/UnwindLevel1.c", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Implements C++ ABI Exception Handling Level 1 as documented at:\n// https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html\n// using libunwind\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "f44f6a1331968cf75de46a3cf64a0cc5c8f485b2", + "path": "libunwind/src/UnwindRegistersSave.S", + "sha256": "c5d0da824062363be10dc33bcd1156f16cd69811e71603c667f931a91fab5eb1", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/src/UnwindRegistersSave.S", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "84c9d526f1d7594e456b5a31c11adff57f79551a", + "path": "libunwind/src/assembly.h", + "sha256": "1b802ab55f7b949a9e8b1a1c7c82b6a84d068610aeb823993bdeee1964c98eb3", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/src/assembly.h", + "source_notices": [ + "/* ===-- assembly.h - libUnwind assembler support macros -------------------===\n *\n * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n * See https://llvm.org/LICENSE.txt for license information.\n * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n *\n * ===----------------------------------------------------------------------===\n *\n * This file defines macros for use in libUnwind assembler source.\n * This file is not part of the interface of this library.\n *\n * ===----------------------------------------------------------------------===\n */" + ] + }, + { + "git_blob": "f017403fa2234f7234e784eefeafe8eae6b1a59b", + "path": "libunwind/src/config.h", + "sha256": "fd99264860ced6f5b5cd4d5e0ef6eb444a4ab511a47a8b0d91bfab254ab21a1e", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/src/config.h", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Defines macros used within libunwind project.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "68ad882347203ca193d05bcb2e3f34d4500edca0", + "path": "libunwind/src/dwarf2.h", + "sha256": "e10d240e2f19de7121a8afaf3d4841a65936723e69d636f7e3241e14802d0bfc", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/src/dwarf2.h", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//===----------------------------------------------------------------------===//\n", + "/*\n These constants were taken from version 3 of the DWARF standard,\n which is Copyright (c) 2005 Free Standards Group, and\n Copyright (c) 1992, 1993 UNIX International, Inc.\n*/" + ] + }, + { + "git_blob": "0b9d56ec805bca92f0ed4b93be549c8cf982e809", + "path": "libunwind/src/libunwind.cpp", + "sha256": "51ccb27829d15988ca5678541b1b32bb3c2bdea87e02be31bf4faca48a0ee2ad", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/src/libunwind.cpp", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Implements unw_* functions from \n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "8acf2212d1eae32433764070421727d73b07e372", + "path": "libunwind/src/libunwind_ext.h", + "sha256": "2efb28c93eb3c32cf491733b8e9c7b5715cb15fa0d6afb7b23ee4ca6de40cc98", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/src/libunwind_ext.h", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n// Extensions to libunwind API.\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "b00ca2c9327c74cc40f678cb4db3b56ed18dc405", + "path": "libunwind/src/shadow_stack_unwind.h", + "sha256": "c18056e575fcf2deed7ccfe469c1c7e6c1f390f64b28cac5aa304de3bb7a50fa", + "source": "https://raw.githubusercontent.com/llvm/llvm-project/7a941dfb2877a0b8cf30323fefa85ad019e0b0f5/libunwind/src/shadow_stack_unwind.h", + "source_notices": [ + "//===----------------------------------------------------------------------===//\n//\n// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.\n// See https://llvm.org/LICENSE.txt for license information.\n// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n//\n//\n//===----------------------------------------------------------------------===//\n" + ] + }, + { + "git_blob": "26fc8ef70c024ab756b1fb1b03eed646a63a03ab", + "path": "mingw-w64-crt/cfguard/guard_dispatch.S", + "sha256": "a479e2319b9a2789afd6f91aedb3e6c640ed16b746df6babffbb17f810432811", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/cfguard/guard_dispatch.S", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "5c736e162339dc590723f402380c4264601aefe3", + "path": "mingw-w64-crt/cfguard/mingw_cfguard_support.c", + "sha256": "a05b0eb6e9d6553ae934f81324fced9c3a6dc89f71ad073dad8ef174d424d693", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/cfguard/mingw_cfguard_support.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "c8a8bfbeebcc7f325d7d1a729bc95bbf10b7d7d9", + "path": "mingw-w64-crt/crt/CRT_fp10.c", + "sha256": "fa9af6a9c58207fc596b3babe8f0b91ebbd75a9cf73e15aa849289e7eb300643", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/CRT_fp10.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "2bb5d94a279942260b3091ae7278ac6e000351c5", + "path": "mingw-w64-crt/crt/_newmode.c", + "sha256": "d85bb76f70f90b246c780ffbfbe6540a4d787b7801e98c8ac8c3edd50dcee971", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/_newmode.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "9e6931c4fc4b5dbd41d5338a9be793b170596802", + "path": "mingw-w64-crt/crt/cinitexe.c", + "sha256": "98c9238561c0ed1b3d7edfd1e32423dfda93c3ae285807873f637d03406bdcc9", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/cinitexe.c", + "source_notices": [] + }, + { + "git_blob": "39c0d85610f70f746f91adc9af67ccf2480b937b", + "path": "mingw-w64-crt/crt/crtbegin.c", + "sha256": "692fdc825a472b8dfda48e65eace55caf5396c8536236b814b967007c978a8b0", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/crtbegin.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "15ee52a7c3348bdd64b7c4ecb0cbe626e6f8d092", + "path": "mingw-w64-crt/crt/crtdll.c", + "sha256": "158dcc7681f335dc36c4bcf86e41444d6507679cab80a68433666df690217990", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/crtdll.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "39c0d85610f70f746f91adc9af67ccf2480b937b", + "path": "mingw-w64-crt/crt/crtend.c", + "sha256": "692fdc825a472b8dfda48e65eace55caf5396c8536236b814b967007c978a8b0", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/crtend.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "ca9b0069160c14aca643a860386c9d5180fcbd0c", + "path": "mingw-w64-crt/crt/crtexe.c", + "sha256": "0624cd5c19dfcd4f6f17a3608582db6d0d4f92a468c391890b8f9114784a4b82", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/crtexe.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "d6be1bc7c2cf76471df995bdf7509590cd4d8f4d", + "path": "mingw-w64-crt/crt/dllargv.c", + "sha256": "98a1bf05b8a037d68ba1ea98ae40a2230a4e734196879fee4bd215c5c3283112", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/dllargv.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "7edf8360c91c182f8ec6e5a695c262332ee6c3ba", + "path": "mingw-w64-crt/crt/gccmain.c", + "sha256": "07c83e890740008bb74b26ecf60d97048cfeb74d89d973b6e8db4f437bc66ac9", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/gccmain.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "5aba73462de3018c7d35ec93d5afcc6eda8276ff", + "path": "mingw-w64-crt/crt/loadcfg.S", + "sha256": "ea3b2928757e53d5f68edbacfc271f4b6070f8a118bf44e50f6a4dd44baba545", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/loadcfg.S", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "687aab4a90bc7dc14ff14f86ce95136d5c1a2422", + "path": "mingw-w64-crt/crt/merr.c", + "sha256": "37d23d36e2041d5ea6e04e6674d84c227937ec477d246742fa062b5e61e1f5ea", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/merr.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "8143c6b72998473c4df1efa0654f36e59fbc2b53", + "path": "mingw-w64-crt/crt/mingw_dll_ctors_dtors.c", + "sha256": "682be7d58c77d70fdf116ad53168c893dbeaa0c85b8a9b86300493e66d3eeaae", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/mingw_dll_ctors_dtors.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "84413cdb7c9fed8e923e3620334e0f29ccf145f2", + "path": "mingw-w64-crt/crt/mingw_helpers.c", + "sha256": "a5639b68c3176c4c6a358c48f869c2a081434c07d7a0e435013f44909a2003c5", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/mingw_helpers.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "5008790e1eefed244e387f654bf4efbe5f3b2250", + "path": "mingw-w64-crt/crt/natstart.c", + "sha256": "c65fb9a3cb70536b8f757e07df8febb0b1a5fd72889bcff4fee924add1078d14", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/natstart.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "5b903c21d211138864d6b484c5b5d8c0c5df6cf3", + "path": "mingw-w64-crt/crt/pseudo-reloc-list.c", + "sha256": "853116d1ba135ea499714152be5705c72678a86fbd9bd5b90469b0ad51ab8acc", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/pseudo-reloc-list.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "dd2a28e8c2a82fbd0d00731c38e666c09738d1f3", + "path": "mingw-w64-crt/crt/pseudo-reloc.c", + "sha256": "24d57d7fec056a84268fcb3fa43dc7fc726c3c3f4c2ff4796652ca3dba33314a", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/pseudo-reloc.c", + "source_notices": [ + "/* pseudo-reloc.c\n\n Contributed by Egor Duda \n Modified by addition of runtime_pseudo_reloc version 2\n by Kai Tietz \n\t\n THIS SOFTWARE IS NOT COPYRIGHTED\n\n This source code is offered for use in the public domain. You may\n use, modify or distribute it freely.\n\n This code is distributed in the hope that it will be useful but\n WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY\n DISCLAMED. This includes but is not limited to warranties of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n*/" + ] + }, + { + "git_blob": "6273a1c527116aa889d3958bf10de7306a20d2a2", + "path": "mingw-w64-crt/crt/tlssup.c", + "sha256": "3f330e9f97d39637245c74d8cd940b2e0238b50c56aee2ff579cff9314e48e9c", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/tlssup.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n *\n * Written by Kai Tietz \n */" + ] + }, + { + "git_blob": "fce059e14e90c9ca16425e793e43dcc803130561", + "path": "mingw-w64-crt/crt/usermatherr.c", + "sha256": "9642a86e0f68b59b958866afaca5aa602ae632d361565128237b71cff4759e48", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/usermatherr.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "b53cc18ec0c05a14962269e453b1d18b2ae1084d", + "path": "mingw-w64-crt/crt/wildcard.c", + "sha256": "a574c6324511ef40619b62a7bfdfcfd4a24a101b790074979a53fd54f9b6b363", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/wildcard.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "b2ec312f09f4f03755c048a20b29ad7454b823a8", + "path": "mingw-w64-crt/crt/xncommod.c", + "sha256": "011050a8ff748ea000d630892a16dff86ab9ffc43503befe52c1c0b79cb25479", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/xncommod.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "973ff45b16e494acf60cd8e26870460a754e9ac7", + "path": "mingw-w64-crt/crt/xthdloc.c", + "sha256": "3320df224c561ac5335121ad4e1f342b90bda7a291d0f14e89ce16c2cb17e54d", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/xthdloc.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "dcbbe11846a5d0c9cea993f7adcc87bd6a5fe958", + "path": "mingw-w64-crt/crt/xtxtmode.c", + "sha256": "a1c826ee8a440cf86dbb1ae6db80e727af5f079b5797f93a3e3a616b3db2bdb9", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/xtxtmode.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "c61e9fa8a52159f500db0e1497594b503dbcc5cd", + "path": "mingw-w64-crt/gdtoa/dmisc.c", + "sha256": "e73637f5fe5e171d13ab4ce51671f20af98c2707fe6c3ba4f25c7bcd108e0f85", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/gdtoa/dmisc.c", + "source_notices": [ + "/****************************************************************\n\nThe author of this software is David M. Gay.\n\nCopyright (C) 1998 by Lucent Technologies\nAll Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and\nits documentation for any purpose and without fee is hereby\ngranted, provided that the above copyright notice appear in all\ncopies and that both that the copyright notice and this\npermission notice and warranty disclaimer appear in supporting\ndocumentation, and that the name of Lucent or any of its entities\nnot be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior\npermission.\n\nLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.\nIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY\nSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\nIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n\n****************************************************************/" + ] + }, + { + "git_blob": "1cfe1953e4c16b19dfd7a0446da5d20ec67f3de4", + "path": "mingw-w64-crt/gdtoa/gdtoa.c", + "sha256": "09ea9686def889450b16910562c5a884e87eee161c52e6c127d373688aac8559", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/gdtoa/gdtoa.c", + "source_notices": [ + "/****************************************************************\n\nThe author of this software is David M. Gay.\n\nCopyright (C) 1998, 1999 by Lucent Technologies\nAll Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and\nits documentation for any purpose and without fee is hereby\ngranted, provided that the above copyright notice appear in all\ncopies and that both that the copyright notice and this\npermission notice and warranty disclaimer appear in supporting\ndocumentation, and that the name of Lucent or any of its entities\nnot be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior\npermission.\n\nLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.\nIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY\nSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\nIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n\n****************************************************************/" + ] + }, + { + "git_blob": "b2b4c54151a0da327338210940e5470cbca33f11", + "path": "mingw-w64-crt/gdtoa/gdtoa.h", + "sha256": "9ea503624739483d5a981d426a9b7a74fd2ee2e04599594e74b886d09beb0403", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/gdtoa/gdtoa.h", + "source_notices": [ + "/****************************************************************\n\nThe author of this software is David M. Gay.\n\nCopyright (C) 1998 by Lucent Technologies\nAll Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and\nits documentation for any purpose and without fee is hereby\ngranted, provided that the above copyright notice appear in all\ncopies and that both that the copyright notice and this\npermission notice and warranty disclaimer appear in supporting\ndocumentation, and that the name of Lucent or any of its entities\nnot be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior\npermission.\n\nLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.\nIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY\nSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\nIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n\n****************************************************************/" + ] + }, + { + "git_blob": "cc2007cd5fa3f0654b14acee99db363d515c44ad", + "path": "mingw-w64-crt/gdtoa/gdtoaimp.h", + "sha256": "cd4e3796364b4eb9d9c5cf3ff00d3abc8e114102376454bc1d2413183ca3e44d", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/gdtoa/gdtoaimp.h", + "source_notices": [ + "/****************************************************************\n\nThe author of this software is David M. Gay.\n\nCopyright (C) 1998-2000 by Lucent Technologies\nAll Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and\nits documentation for any purpose and without fee is hereby\ngranted, provided that the above copyright notice appear in all\ncopies and that both that the copyright notice and this\npermission notice and warranty disclaimer appear in supporting\ndocumentation, and that the name of Lucent or any of its entities\nnot be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior\npermission.\n\nLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.\nIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY\nSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\nIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n\n****************************************************************/" + ] + }, + { + "git_blob": "157e872319f033f3fcc838c26a93b7fc8b9c9826", + "path": "mingw-w64-crt/gdtoa/gmisc.c", + "sha256": "7b4327dfc978aacfb950bd4c6970696ccc76ddb7159800a244ef2a0bb593dc5c", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/gdtoa/gmisc.c", + "source_notices": [ + "/****************************************************************\n\nThe author of this software is David M. Gay.\n\nCopyright (C) 1998 by Lucent Technologies\nAll Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and\nits documentation for any purpose and without fee is hereby\ngranted, provided that the above copyright notice appear in all\ncopies and that both that the copyright notice and this\npermission notice and warranty disclaimer appear in supporting\ndocumentation, and that the name of Lucent or any of its entities\nnot be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior\npermission.\n\nLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.\nIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY\nSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\nIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n\n****************************************************************/" + ] + }, + { + "git_blob": "960543a606eeda45b24a4886e6149963fe6bae79", + "path": "mingw-w64-crt/gdtoa/misc.c", + "sha256": "02486c21b11fe4538bde37d4c740b486a5eef76c8fdeec8e74a9c409c8acb6dc", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/gdtoa/misc.c", + "source_notices": [ + "/****************************************************************\n\nThe author of this software is David M. Gay.\n\nCopyright (C) 1998, 1999 by Lucent Technologies\nAll Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and\nits documentation for any purpose and without fee is hereby\ngranted, provided that the above copyright notice appear in all\ncopies and that both that the copyright notice and this\npermission notice and warranty disclaimer appear in supporting\ndocumentation, and that the name of Lucent or any of its entities\nnot be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior\npermission.\n\nLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.\nIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY\nSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\nIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n\n****************************************************************/" + ] + }, + { + "git_blob": "30b11f284226c16e8e5320e4b3d164cc4a3c425d", + "path": "mingw-w64-crt/misc/__initenv.c", + "sha256": "7ca289f2891fef05351cc52879413c219b30de0258b950dbc7d4e10d05a01f97", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/misc/__initenv.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "e3f880b38408689890dff6091f2fe1ef831f8c46", + "path": "mingw-w64-crt/misc/__p___initenv.c", + "sha256": "034d66df82c6da68cc4bc59ff829ff3f18edd431cbe2f6376d51667f9b90f509", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/misc/__p___initenv.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "3f5b5261bffae5b63826829a9103d290d7bf5708", + "path": "mingw-w64-crt/misc/dllmain.c", + "sha256": "ad3eb745bc2e614de38f43700c274cae2b7edec7ee40950cc918d8b98d3d9505", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/misc/dllmain.c", + "source_notices": [] + }, + { + "git_blob": "21529682983729e6197d22fe532d974ca113fcf2", + "path": "mingw-w64-crt/misc/mingw_matherr.c", + "sha256": "47ccdea07abacdd4629596084796291ecf35f4ccf951fa6b5038b6db2eb4c336", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/misc/mingw_matherr.c", + "source_notices": [] + }, + { + "git_blob": "72fef92cc36e674db13500d74dee10a27a060631", + "path": "mingw-w64-crt/misc/ucrt__getmainargs.c", + "sha256": "7d9139300468218e77c1f4b1bc52ba2802b9273ad1f1b1c3e50be624039d2f5e", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/misc/ucrt__getmainargs.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "0aad4f6c368a7f284568ffb1e96c8e48f011e56a", + "path": "mingw-w64-crt/misc/ucrt_amsg_exit.c", + "sha256": "ad8dd7eb0b4e2fef5b5c16f4934b7f5bca265246e18440ecb380ab8ffe1a8c6d", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/misc/ucrt_amsg_exit.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "438941f7e3f473462007cffc12d967c88bf315e9", + "path": "mingw-w64-crt/stdio/mingw_fprintf.c", + "sha256": "c19ffaac9e0ee6056bf4cd0316d021596b37ac800d04dd187b01db01533d839e", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/stdio/mingw_fprintf.c", + "source_notices": [ + "/* fprintf.c\n *\n * $Id: fprintf.c,v 1.1 2008/08/11 22:41:55 keithmarshall Exp $\n *\n * Provides an implementation of the \"fprintf\" function, conforming\n * generally to C99 and SUSv3/POSIX specifications, with extensions\n * to support Microsoft's non-standard format specifications. This\n * is included in libmingwex.a, whence it may replace the Microsoft\n * function of the same name.\n *\n * Written by Keith Marshall \n *\n * This implementation of \"fprintf\" will normally be invoked by calling\n * \"__mingw_fprintf()\" in preference to a direct reference to \"fprintf()\"\n * itself; this leaves the MSVCRT implementation as the default, which\n * will be deployed when user code invokes \"fprint()\". Users who then\n * wish to use this implementation may either call \"__mingw_fprintf()\"\n * directly, or may use conditional preprocessor defines, to redirect\n * references to \"fprintf()\" to \"__mingw_fprintf()\".\n *\n * Compiling this module with \"-D INSTALL_AS_DEFAULT\" will change this\n * recommended convention, such that references to \"fprintf()\" in user\n * code will ALWAYS be redirected to \"__mingw_fprintf()\"; if this option\n * is adopted, then users wishing to use the MSVCRT implementation of\n * \"fprintf()\" will be forced to use a \"back-door\" mechanism to do so.\n * Such a \"back-door\" mechanism is provided with MinGW, allowing the\n * MSVCRT implementation to be called as \"__msvcrt_fprintf()\"; however,\n * since users may not expect this behaviour, a standard libmingwex.a\n * installation does not employ this option.\n *\n *\n * This is free software. You may redistribute and/or modify it as you\n * see fit, without restriction of copyright.\n *\n * This software is provided \"as is\", in the hope that it may be useful,\n * but WITHOUT WARRANTY OF ANY KIND, not even any implied warranty of\n * MERCHANTABILITY, nor of FITNESS FOR ANY PARTICULAR PURPOSE. At no\n * time will the author accept any form of liability for any damages,\n * however caused, resulting from the use of this software.\n *\n */" + ] + }, + { + "git_blob": "2bbe5203b52fe37cd977c6c11bc11c7924dab2ae", + "path": "mingw-w64-crt/stdio/mingw_pformat.c", + "sha256": "8ad4e2a80cb56291deb8ab42238c5084fa256a65dbf08412109f08c3ced85225", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/stdio/mingw_pformat.c", + "source_notices": [ + "/* pformat.c\n *\n * $Id: pformat.c,v 1.9 2011/01/07 22:57:00 keithmarshall Exp $\n *\n * Provides a core implementation of the formatting capabilities\n * common to the entire `printf()' family of functions; it conforms\n * generally to C99 and SUSv3/POSIX specifications, with extensions\n * to support Microsoft's non-standard format specifications.\n *\n * Written by Keith Marshall \n *\n * This is free software. You may redistribute and/or modify it as you\n * see fit, without restriction of copyright.\n *\n * This software is provided \"as is\", in the hope that it may be useful,\n * but WITHOUT WARRANTY OF ANY KIND, not even any implied warranty of\n * MERCHANTABILITY, nor of FITNESS FOR ANY PARTICULAR PURPOSE. At no\n * time will the author accept any form of liability for any damages,\n * however caused, resulting from the use of this software.\n *\n * The elements of this implementation which deal with the formatting\n * of floating point numbers, (i.e. the `%e', `%E', `%f', `%F', `%g'\n * and `%G' format specifiers, but excluding the hexadecimal floating\n * point `%a' and `%A' specifiers), make use of the `__gdtoa' function\n * written by David M. Gay, and are modelled on his sample code, which\n * has been deployed under its accompanying terms of use:--\n *\n ******************************************************************\n * Copyright (C) 1997, 1999, 2001 Lucent Technologies\n * All Rights Reserved\n *\n * Permission to use, copy, modify, and distribute this software and\n * its documentation for any purpose and without fee is hereby\n * granted, provided that the above copyright notice appear in all\n * copies and that both that the copyright notice and this\n * permission notice and warranty disclaimer appear in supporting\n * documentation, and that the name of Lucent or any of its entities\n * not be used in advertising or publicity pertaining to\n * distribution of the software without specific, written prior\n * permission.\n *\n * LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\n * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.\n * IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY\n * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\n * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\n * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\n * THIS SOFTWARE.\n ******************************************************************\n *\n */" + ] + }, + { + "git_blob": "ee98ac1ac827877eaa8e5de8a675bdc9dcced18c", + "path": "mingw-w64-crt/stdio/ucrt___local_stdio_printf_options.c", + "sha256": "0c8ab6443db6f80930f95ee4f380faf7e0bd7a04ecafa0fcba8016bd77a0c98c", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/stdio/ucrt___local_stdio_printf_options.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "0b06b14e9653a4dca58436e30cc2ad2feb9a5f2b", + "path": "mingw-w64-crt/stdio/ucrt_fprintf.c", + "sha256": "080d99fcea70a61cde96b5347e8a381c28778928584227cb6b70a543c3b0933c", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/stdio/ucrt_fprintf.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "6ac1bb8c115a5cbf82d3d1a364fc3460eeb47380", + "path": "mingw-w64-crt/stdio/ucrt_vfprintf.c", + "sha256": "682fc042d9007afcfa6c022373178d22591af8c9cb93de9ab5525b3d17cd5b75", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/stdio/ucrt_vfprintf.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "06c708316d72bda920940cbf8b0f735aa0abd729", + "path": "mingw-w64-crt/crt/crtdll_atexit_register.c", + "sha256": "53268a62ba7b80f6bda1bca04a5a43affddb8799c8db512b2051696af1192e08", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-crt/crt/crtdll_atexit_register.c", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "c4c2ff0130d13cb6bdafebb30ae4a364aa09fb28", + "path": "mingw-w64-headers/crt/stdlib.h", + "sha256": "d12b66adbee8f0458e833f5a4dbe1effd060d32d589ce48854bc5e14af6d8e6c", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-headers/crt/stdlib.h", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + }, + { + "git_blob": "6afa761c56ea5c5aac0e65d087db08e13c65e2fe", + "path": "mingw-w64-headers/crt/corecrt_startup.h", + "sha256": "c1314b1d68ed6df6d424ec910bdee258ebe2e8633ddc758be5301b4cd203b6dd", + "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/mingw-w64-headers/crt/corecrt_startup.h", + "source_notices": [ + "/**\n * This file has no copyright assigned and is placed in the Public Domain.\n * This file is part of the mingw-w64 runtime package.\n * No warranty is given; refer to the file DISCLAIMER.PD within this package.\n */" + ] + } + ], + "targets": { + "aarch64-pc-windows-gnullvm": { + "retained_objects": [ + "Unwind-seh.cpp.obj", + "UnwindLevel1-gcc-ext.c.obj", + "UnwindLevel1.c.obj", + "UnwindRegistersSave.S.obj", + "crtbegin.o", + "crtend.o", + "dllcrt2.o", + "libarm64_libmingw32_a-cinitexe.o", + "libarm64_libmingw32_a-crtdll_atexit_register.o", + "libarm64_libmingw32_a-mingw_dll_ctors_dtors.o", + "libarm64_libmingw32_a-mingw_helpers.o", + "libarm64_libmingw32_a-natstart.o", + "libarm64_libmingw32_a-pseudo-reloc-list.o", + "libarm64_libmingw32_a-pseudo-reloc.o", + "libarm64_libmingw32_a-tlssup.o", + "libarm64_libmingwex_a-dllmain.o", + "libarm64_libmingwex_a-loadcfg.o", + "libarm64_libmingwex_a-mingw_cfguard_support.o", + "libarm64_libucrt_extra_a-ucrt___local_stdio_printf_options.o", + "libarm64_libucrt_extra_a-ucrt_fprintf.o", + "libarm64_libucrt_extra_a-ucrt_vfprintf.o", + "libunwind.cpp.obj" + ], + "sdk_inputs": [ + { + "path": "aarch64-w64-mingw32/lib/crtbegin.o", + "sha256": "4ba912486f310ab85d7d06a90d4c46c22485edce0255a03a1f74c0c8510eff9e", + "size": 1309 + }, + { + "path": "aarch64-w64-mingw32/lib/crtend.o", + "sha256": "eefb57102e2168200514c7565f27b14fe519bb5a853e7f00d3e4dd2a5c777470", + "size": 1309 + }, + { + "path": "aarch64-w64-mingw32/lib/dllcrt2.o", + "sha256": "bf86f93b1ce6b401fc837edbac68e8b9ae474a3af335c67ba1659febd25305a6", + "size": 42872 + }, + { + "path": "aarch64-w64-mingw32/lib/libdbghelp.a", + "sha256": "b5d39301a039d48a1513c6222e5254efd96eb641508fac9a4635cd5e5da27968", + "size": 103246 + }, + { + "path": "aarch64-w64-mingw32/lib/libkernel32.a", + "sha256": "f5197cec7cea31be9847bfb6c3912bea507319be63740a6887d02a0b6bbdd893", + "size": 1009086 + }, + { + "path": "aarch64-w64-mingw32/lib/libmingw32.a", + "sha256": "ff45b29605c4c9de82d6ad40fcc7fe4139b37467df10541b286336f7929257c3", + "size": 339550 + }, + { + "path": "aarch64-w64-mingw32/lib/libmingwex.a", + "sha256": "d1108040c5e08d84d58108f4dfe40cb3793a0eee61d0a1fa6919f8469be5ea73", + "size": 4168698 + }, + { + "path": "aarch64-w64-mingw32/lib/libmsvcrt.a", + "sha256": "062c0d06384cb8f8db2666eda5e50dab9a300e2e662f9dda2711bd48576ae34d", + "size": 1796926 + }, + { + "path": "aarch64-w64-mingw32/lib/libntdll.a", + "sha256": "3c91ccf64aa2c8d2fa47bedf45531ec2c972ff37200eb541afb16d7259cce96c", + "size": 1126014 + }, + { + "path": "aarch64-w64-mingw32/lib/libunwind.a", + "sha256": "1a983632d86eb33d808534b4853e5185f31419adc787048c9f5bc3e76a79d9b9", + "size": 231528 + }, + { + "path": "aarch64-w64-mingw32/lib/libuser32.a", + "sha256": "fd1f8ad6376a7d57a01c9d0361f89ca038c8c03dde43b8298f094e73f24c6bf9", + "size": 434306 + }, + { + "path": "aarch64-w64-mingw32/lib/libuserenv.a", + "sha256": "fbc1da1ed5165754594e48fa8e1199a0fbe395e6ab29531d33633c14725789c5", + "size": 40108 + }, + { + "path": "aarch64-w64-mingw32/lib/libws2_32.a", + "sha256": "04d7f776550e3732b37cef7b2759862e82b2485e99cc9baf354df573da489483", + "size": 411636 + }, + { + "path": "lib/clang/23/lib/windows/libclang_rt.builtins-aarch64.a", + "sha256": "0eadf5121c8d6c9169769130d8e83a549251b91bd2686150d75f3914eb8ac6df", + "size": 760636 + } + ] + }, + "x86_64-pc-windows-gnullvm": { + "retained_objects": [ + "Unwind-seh.cpp.obj", + "UnwindLevel1-gcc-ext.c.obj", + "UnwindLevel1.c.obj", + "UnwindRegistersSave.S.obj", + "crtbegin.o", + "crtend.o", + "dllcrt2.o", + "lib64_libmingw32_a-cinitexe.o", + "lib64_libmingw32_a-crtdll_atexit_register.o", + "lib64_libmingw32_a-mingw_dll_ctors_dtors.o", + "lib64_libmingw32_a-mingw_helpers.o", + "lib64_libmingw32_a-natstart.o", + "lib64_libmingw32_a-pseudo-reloc-list.o", + "lib64_libmingw32_a-pseudo-reloc.o", + "lib64_libmingw32_a-tlssup.o", + "lib64_libmingwex_a-dllmain.o", + "lib64_libmingwex_a-dmisc.o", + "lib64_libmingwex_a-gdtoa.o", + "lib64_libmingwex_a-gmisc.o", + "lib64_libmingwex_a-guard_dispatch.o", + "lib64_libmingwex_a-loadcfg.o", + "lib64_libmingwex_a-mingw_cfguard_support.o", + "lib64_libmingwex_a-mingw_fprintf.o", + "lib64_libmingwex_a-mingw_pformat.o", + "lib64_libmingwex_a-misc.o", + "lib64_libucrt_extra_a-ucrt___local_stdio_printf_options.o", + "lib64_libucrt_extra_a-ucrt_fprintf.o", + "lib64_libucrt_extra_a-ucrt_vfprintf.o", + "libunwind.cpp.obj" + ], + "sdk_inputs": [ + { + "path": "lib/clang/23/lib/windows/libclang_rt.builtins-x86_64.a", + "sha256": "fa6a7a18518ff5372a5f32a386ab0d689099d8c258c18eaea2431f514154c55b", + "size": 256660 + }, + { + "path": "x86_64-w64-mingw32/lib/crtbegin.o", + "sha256": "5dc28a7b0ecf42c769578f63b8d169c89c958f95c2e67b3a0d8f94b8bd3c6c60", + "size": 628 + }, + { + "path": "x86_64-w64-mingw32/lib/crtend.o", + "sha256": "c6b583eaf68b432e35507013e3213557edd2656c33916a7878c8efda18b95c19", + "size": 628 + }, + { + "path": "x86_64-w64-mingw32/lib/dllcrt2.o", + "sha256": "a846dd86db648a38ad5ee3d382295b6fa084df639a8c26cd32646ff9f71bfc47", + "size": 17632 + }, + { + "path": "x86_64-w64-mingw32/lib/libdbghelp.a", + "sha256": "f407acff38e12cb5227a6bad5f023f31c3705aca0a5339fc9b25ec433342e3cc", + "size": 49766 + }, + { + "path": "x86_64-w64-mingw32/lib/libkernel32.a", + "sha256": "6ee0041fafa7ad06bd7dc8b6b387e4ca066e76ccfeca56ae84af5a2a6d42a345", + "size": 577358 + }, + { + "path": "x86_64-w64-mingw32/lib/libmingw32.a", + "sha256": "a0aad43b481208ad1ff583102c00bd2a1e56e855b2045e282ed03845a44feef7", + "size": 139220 + }, + { + "path": "x86_64-w64-mingw32/lib/libmingwex.a", + "sha256": "df21bc3944a8766542f1b4c1ffc864e2b5dd997f2d14604eec12d3ba9258bfea", + "size": 1881848 + }, + { + "path": "x86_64-w64-mingw32/lib/libmsvcrt.a", + "sha256": "e4e38200c764bbfd217f3290f64b9bd3cc963dd782b34f3d747df27780360f62", + "size": 848642 + }, + { + "path": "x86_64-w64-mingw32/lib/libntdll.a", + "sha256": "a9e9a4eacaff6d5c186c514a8f27840df9de44c86de4dfbfe38dab0cae907cea", + "size": 545270 + }, + { + "path": "x86_64-w64-mingw32/lib/libunwind.a", + "sha256": "b37299ed084757834d7cee8d723aff6b349890d61505478602e9e981dcca839c", + "size": 91768 + }, + { + "path": "x86_64-w64-mingw32/lib/libuser32.a", + "sha256": "6b2bea0a02e6a95bcbb684ff4ede16a4a51c8bd0a55e7e15b81255c4467190bb", + "size": 207984 + }, + { + "path": "x86_64-w64-mingw32/lib/libuserenv.a", + "sha256": "c9d73aedfcbde527e9a41e9c1bb72924bd6fac5e8a4d0cae13483e8b72e2f94b", + "size": 19538 + }, + { + "path": "x86_64-w64-mingw32/lib/libws2_32.a", + "sha256": "fbb7fff6f90697b20285a1e4dfdeffb8cc5fdf7c8932ea39bc66bd722e3e33ad", + "size": 171084 + } + ] + } + } +} diff --git a/ci/licenses/rust-compiler-originals/compiler-builtins-Cargo.toml.txt b/ci/licenses/rust-compiler-originals/compiler-builtins-Cargo.toml.txt new file mode 100644 index 0000000..b2f1443 --- /dev/null +++ b/ci/licenses/rust-compiler-originals/compiler-builtins-Cargo.toml.txt @@ -0,0 +1,62 @@ +# NOTE: Must be kept in sync with `../builtins-shim/Cargo.toml`. +# +# This manifest is actually used in-tree by rust-lang/rust, +# `../builtins-shim/Cargo.toml` is used by out-of-tree testing. See the other +# manifest for further details. + +[package] +name = "compiler_builtins" +version = "0.1.160" +authors = [ + "Alex Crichton ", + "Amanieu d'Antras ", + "Jorge Aparicio ", + "Trevor Gross ", +] +description = "Compiler intrinsics used by the Rust compiler." +repository = "https://github.com/rust-lang/compiler-builtins" +license = "MIT AND Apache-2.0 WITH LLVM-exception AND (MIT OR Apache-2.0)" +edition = "2024" +publish = false +links = "compiler-rt" + +[lib] +bench = false +doctest = false +test = false +# make sure this crate isn't included in public standard library docs +doc = false + +[dependencies] +core = { path = "../../core", optional = true } + +[build-dependencies] +cc = { version = "1.2", optional = true } + +[features] +default = ["arch"] + +# Enable architecture-specific features such as SIMD or assembly routines. If +# disabled, the generic version can be tested on any platform. +arch = [] + +# Enable compilation of C code in compiler-rt, filling in some more optimized +# implementations and also filling in unimplemented intrinsics +c = ["dep:cc"] + +# Flag this library as the unstable compiler-builtins lib. This must be enabled +# when using as `std`'s dependency.' +compiler-builtins = ["dep:core", "unmangled-names"] + +# Enable `no_mangle` symbols for memory-related intrinsics like memcpy. The +# mangled versions are always available. +mem = [] + +# Enable `no_mangle` symbols so this crate gets used as the runtime intrinsic +# implementation. Leave this disabled for testing to avoid conflicting with +# the system intrinsics. +unmangled-names = [] + +# This makes certain traits and function specializations public that +# are not normally public but are required by the `builtins-test` +unstable-public-internals = [] diff --git a/ci/licenses/rust-compiler-originals/compiler-builtins-LICENSE.txt b/ci/licenses/rust-compiler-originals/compiler-builtins-LICENSE.txt new file mode 100644 index 0000000..00ae614 --- /dev/null +++ b/ci/licenses/rust-compiler-originals/compiler-builtins-LICENSE.txt @@ -0,0 +1,275 @@ +The compiler-builtins crate is available for use under both the MIT license +and the Apache-2.0 license with the LLVM exception (MIT AND Apache-2.0 WITH +LLVM-exception). + +The libm crate is available for use under the MIT license. + +As a contributor, you agree that your code may be used under any of the +following: the MIT license, the Apache-2.0 license, or the Apache-2.0 license +with the LLVM exception. In other words, original (non-derivative) work is +licensed under MIT OR Apache-2.0 OR Apache-2.0 WITH LLVM-exception. This is +the default license for all other source in this repository. + +Text of the relevant licenses is provided below: + +------------------------------------------------------------------------------ +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + 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. + + +---- LLVM Exceptions to the Apache 2.0 License ---- + +As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into an Object form of such source code, you +may redistribute such embedded portions in such Object form without complying +with the conditions of Sections 4(a), 4(b) and 4(d) of the License. + +In addition, if you combine or link compiled forms of this Software with +software that is licensed under the GPLv2 ("Combined Software") and if a +court of competent jurisdiction determines that the patent provision (Section +3), the indemnity provision (Section 9) or other Section of the License +conflicts with the conditions of the GPLv2, you may retroactively and +prospectively choose to deem waived or otherwise exclude such Section(s) of +the License, but only in their entirety and only with respect to the Combined +Software. +------------------------------------------------------------------------------ + +Portions of this software are derived from third-party works licensed under +terms compatible with the above Apache-2.0 WITH LLVM-exception AND MIT +license: + +* compiler-builtins is derived from LLVM's compiler-rt (https://llvm.org/). + Work derived from compiler-rt prior to 2019-01-19 is usable under the MIT + license, with the following copyright: + + Copyright (c) 2009-2016 by the contributors listed in CREDITS.TXT + + The relevant CREDITS.TXT is located at + https://github.com/llvm/llvm-project/blob/main/compiler-rt/CREDITS.TXT. + +* Work derived from compiler-rt after 2019-01-19 is usable under the + Apache-2.0 license with the LLVM exception. + +* The bundled `math` module is from the libm crate, usable under the MIT + license. For further details and copyrights, see see libm/LICENSE.txt at + https://github.com/rust-lang/compiler-builtins. + +Additionally, some source files may contain comments with specific copyrights +or licenses. diff --git a/ci/licenses/rust-compiler-originals/compiler-builtins-aarch64-outline-atomics.rs.txt b/ci/licenses/rust-compiler-originals/compiler-builtins-aarch64-outline-atomics.rs.txt new file mode 100644 index 0000000..367768e --- /dev/null +++ b/ci/licenses/rust-compiler-originals/compiler-builtins-aarch64-outline-atomics.rs.txt @@ -0,0 +1,467 @@ +//! Aarch64 targets have two possible implementations for atomics: +//! 1. Load-Locked, Store-Conditional (LL/SC), older and slower. +//! 2. Large System Extensions (LSE), newer and faster. +//! To avoid breaking backwards compat, C toolchains introduced a concept of "outlined atomics", +//! where atomic operations call into the compiler runtime to dispatch between two depending on +//! which is supported on the current CPU. +//! See for more discussion. +//! +//! Ported from `aarch64/lse.S` in LLVM's compiler-rt. +//! +//! Generate functions for each of the following symbols: +//! __aarch64_casM_ORDER +//! __aarch64_swpN_ORDER +//! __aarch64_ldaddN_ORDER +//! __aarch64_ldclrN_ORDER +//! __aarch64_ldeorN_ORDER +//! __aarch64_ldsetN_ORDER +//! for N = {1, 2, 4, 8}, M = {1, 2, 4, 8, 16}, ORDER = { relax, acq, rel, acq_rel } +//! +//! The original `lse.S` has some truly horrifying code that expects to be compiled multiple times with different constants. +//! We do something similar, but with macro arguments. +#![cfg_attr(feature = "c", allow(unused_macros))] // avoid putting the macros into a submodule + +use core::sync::atomic::{AtomicU8, Ordering}; + +/// non-zero if the host supports LSE atomics. +static HAVE_LSE_ATOMICS: AtomicU8 = AtomicU8::new(0); + +intrinsics! { + /// Call to enable LSE in outline atomic operations. The caller must verify + /// LSE operations are supported. + pub extern "C" fn __rust_enable_lse() { + HAVE_LSE_ATOMICS.store(1, Ordering::Relaxed); + } +} + +/// Function to enable/disable LSE. To be used only for testing purposes. +#[cfg(feature = "unstable-public-internals")] +pub unsafe fn set_have_lse_atomics(has_lse: bool) { + let lse_flag = if has_lse { 1 } else { 0 }; + HAVE_LSE_ATOMICS.store(lse_flag, Ordering::Relaxed); +} + +/// Function to obtain whether LSE is enabled or not. To be used only for testing purposes. +#[cfg(feature = "unstable-public-internals")] +pub fn get_have_lse_atomics() -> bool { + HAVE_LSE_ATOMICS.load(Ordering::Relaxed) != 0 +} + +/// Translate a byte size to a Rust type. +#[rustfmt::skip] +macro_rules! int_ty { + (1) => { u8 }; + (2) => { u16 }; + (4) => { u32 }; + (8) => { u64 }; + (16) => { u128 }; +} + +/// Given a byte size and a register number, return a register of the appropriate size. +/// +/// See . +#[rustfmt::skip] +macro_rules! reg { + (1, $num:literal) => { concat!("w", $num) }; + (2, $num:literal) => { concat!("w", $num) }; + (4, $num:literal) => { concat!("w", $num) }; + (8, $num:literal) => { concat!("x", $num) }; + (16, $num:literal) => { concat!("x", $num) }; +} + +/// Given an atomic ordering, translate it to the acquire suffix for the lxdr aarch64 ASM instruction. +#[rustfmt::skip] +macro_rules! acquire { + (Relaxed) => { "" }; + (Acquire) => { "a" }; + (Release) => { "" }; + (AcqRel) => { "a" }; +} + +/// Given an atomic ordering, translate it to the release suffix for the stxr aarch64 ASM instruction. +#[rustfmt::skip] +macro_rules! release { + (Relaxed) => { "" }; + (Acquire) => { "" }; + (Release) => { "l" }; + (AcqRel) => { "l" }; +} + +/// Given a size in bytes, translate it to the byte suffix for an aarch64 ASM instruction. +#[rustfmt::skip] +macro_rules! size { + (1) => { "b" }; + (2) => { "h" }; + (4) => { "" }; + (8) => { "" }; + (16) => { "" }; +} + +/// Given a byte size, translate it to an Unsigned eXTend instruction +/// with the correct semantics. +/// +/// See +#[rustfmt::skip] +macro_rules! uxt { + (1) => { "uxtb" }; + (2) => { "uxth" }; + ($_:tt) => { "mov" }; +} + +/// Given an atomic ordering and byte size, translate it to a LoaD eXclusive Register instruction +/// with the correct semantics. +/// +/// See . +macro_rules! ldxr { + ($ordering:ident, $bytes:tt) => { + concat!("ld", acquire!($ordering), "xr", size!($bytes)) + }; +} + +/// Given an atomic ordering and byte size, translate it to a STore eXclusive Register instruction +/// with the correct semantics. +/// +/// See . +macro_rules! stxr { + ($ordering:ident, $bytes:tt) => { + concat!("st", release!($ordering), "xr", size!($bytes)) + }; +} + +/// Given an atomic ordering and byte size, translate it to a LoaD eXclusive Pair of registers instruction +/// with the correct semantics. +/// +/// See +macro_rules! ldxp { + ($ordering:ident) => { + concat!("ld", acquire!($ordering), "xp") + }; +} + +/// Given an atomic ordering and byte size, translate it to a STore eXclusive Pair of registers instruction +/// with the correct semantics. +/// +/// See . +macro_rules! stxp { + ($ordering:ident) => { + concat!("st", release!($ordering), "xp") + }; +} + +// The AArch64 assembly syntax for relocation specifiers +// when accessing symbols changes depending on the target executable format. +// In ELF (used in Linux), we have a prefix notation surrounded by colons (:specifier:sym), +// while in Mach-O object files (used in MacOS), a postfix notation is used (sym@specifier). + +/// AArch64 ELF position-independent addressing: +/// +/// adrp xN, symbol +/// add xN, xN, :lo12:symbol +/// +/// The :lo12: modifier selects the low 12 bits of the symbol address +/// and emits an ELF relocation such as R_AARCH64_ADD_ABS_LO12_NC. +/// +/// Defined by the AArch64 ELF psABI. +/// See: . +#[cfg(not(target_vendor = "apple"))] +macro_rules! sym { + ($sym:literal) => { + $sym + }; +} + +#[cfg(not(target_vendor = "apple"))] +macro_rules! sym_off { + ($sym:literal) => { + concat!(":lo12:", $sym) + }; +} + +/// Mach-O ARM64 relocation types: +/// ARM64_RELOC_PAGE21 +/// ARM64_RELOC_PAGEOFF12 +/// +/// These relocations implement the @PAGE / @PAGEOFF split used by +/// adrp + add sequences on Apple platforms. +/// +/// adrp xN, symbol@PAGE -> ARM64_RELOC_PAGE21 +/// add xN, xN, symbol@PAGEOFF -> ARM64_RELOC_PAGEOFF12 +/// +/// Relocation types defined by Apple in XNU: . +/// See: . +#[cfg(target_vendor = "apple")] +macro_rules! sym { + ($sym:literal) => { + concat!($sym, "@PAGE") + }; +} + +#[cfg(target_vendor = "apple")] +macro_rules! sym_off { + ($sym:literal) => { + concat!($sym, "@PAGEOFF") + }; +} + +// If supported, perform the requested LSE op and return, or fallthrough. +macro_rules! try_lse_op { + ($op: literal, $ordering:ident, $bytes:tt, $($reg:literal,)* [ $mem:ident ] ) => { + concat!( + ".arch_extension lse\n", + concat!("adrp x16, ", sym!("{have_lse}"), "\n"), + concat!("ldrb w16, [x16, ", sym_off!("{have_lse}"), "]\n"), + "cbz w16, 8f\n", + // LSE_OP s(reg),* [$mem] + concat!(lse!($op, $ordering, $bytes), $( " ", reg!($bytes, $reg), ", " ,)* "[", stringify!($mem), "]\n",), + "ret + 8:" + ) + }; +} + +// Translate memory ordering to the LSE suffix +#[rustfmt::skip] +macro_rules! lse_mem_sfx { + (Relaxed) => { "" }; + (Acquire) => { "a" }; + (Release) => { "l" }; + (AcqRel) => { "al" }; +} + +// Generate the aarch64 LSE operation for memory ordering and width +macro_rules! lse { + ($op:literal, $order:ident, 16) => { + concat!($op, "p", lse_mem_sfx!($order)) + }; + ($op:literal, $order:ident, $bytes:tt) => { + concat!($op, lse_mem_sfx!($order), size!($bytes)) + }; +} + +/// See . +macro_rules! compare_and_swap { + ($ordering:ident, $bytes:tt, $name:ident) => { + intrinsics! { + #[maybe_use_optimized_c_shim] + #[unsafe(naked)] + pub unsafe extern "C" fn $name ( + expected: int_ty!($bytes), desired: int_ty!($bytes), ptr: *mut int_ty!($bytes) + ) -> int_ty!($bytes) { + // We can't use `AtomicI8::compare_and_swap`; we *are* compare_and_swap. + core::arch::naked_asm! { + // CAS s(0), s(1), [x2]; if LSE supported. + try_lse_op!("cas", $ordering, $bytes, 0, 1, [x2]), + // UXT s(tmp0), s(0) + concat!(uxt!($bytes), " ", reg!($bytes, 16), ", ", reg!($bytes, 0)), + "0:", + // LDXR s(0), [x2] + concat!(ldxr!($ordering, $bytes), " ", reg!($bytes, 0), ", [x2]"), + // cmp s(0), s(tmp0) + concat!("cmp ", reg!($bytes, 0), ", ", reg!($bytes, 16)), + "bne 1f", + // STXR w(tmp1), s(1), [x2] + concat!(stxr!($ordering, $bytes), " w17, ", reg!($bytes, 1), ", [x2]"), + "cbnz w17, 0b", + "1:", + "ret", + have_lse = sym crate::aarch64_outline_atomics::HAVE_LSE_ATOMICS, + } + } + } + }; +} + +// u128 uses a completely different impl, so it has its own macro. +macro_rules! compare_and_swap_u128 { + ($ordering:ident, $name:ident) => { + intrinsics! { + #[maybe_use_optimized_c_shim] + #[unsafe(naked)] + pub unsafe extern "C" fn $name ( + expected: u128, desired: u128, ptr: *mut u128 + ) -> u128 { + core::arch::naked_asm! { + // CASP x0, x1, x2, x3, [x4]; if LSE supported. + try_lse_op!("cas", $ordering, 16, 0, 1, 2, 3, [x4]), + "mov x16, x0", + "mov x17, x1", + "0:", + // LDXP x0, x1, [x4] + concat!(ldxp!($ordering), " x0, x1, [x4]"), + "cmp x0, x16", + "ccmp x1, x17, #0, eq", + "bne 1f", + // STXP w(tmp2), x2, x3, [x4] + concat!(stxp!($ordering), " w15, x2, x3, [x4]"), + "cbnz w15, 0b", + "1:", + "ret", + have_lse = sym crate::aarch64_outline_atomics::HAVE_LSE_ATOMICS, + } + } + } + }; +} + +/// See . +macro_rules! swap { + ($ordering:ident, $bytes:tt, $name:ident) => { + intrinsics! { + #[maybe_use_optimized_c_shim] + #[unsafe(naked)] + pub unsafe extern "C" fn $name ( + left: int_ty!($bytes), right_ptr: *mut int_ty!($bytes) + ) -> int_ty!($bytes) { + core::arch::naked_asm! { + // SWP s(0), s(0), [x1]; if LSE supported. + try_lse_op!("swp", $ordering, $bytes, 0, 0, [x1]), + // mov s(tmp0), s(0) + concat!("mov ", reg!($bytes, 16), ", ", reg!($bytes, 0)), + "0:", + // LDXR s(0), [x1] + concat!(ldxr!($ordering, $bytes), " ", reg!($bytes, 0), ", [x1]"), + // STXR w(tmp1), s(tmp0), [x1] + concat!(stxr!($ordering, $bytes), " w17, ", reg!($bytes, 16), ", [x1]"), + "cbnz w17, 0b", + "ret", + have_lse = sym crate::aarch64_outline_atomics::HAVE_LSE_ATOMICS, + } + } + } + }; +} + +/// See (e.g.) . +macro_rules! fetch_op { + ($ordering:ident, $bytes:tt, $name:ident, $op:literal, $lse_op:literal) => { + intrinsics! { + #[maybe_use_optimized_c_shim] + #[unsafe(naked)] + pub unsafe extern "C" fn $name ( + val: int_ty!($bytes), ptr: *mut int_ty!($bytes) + ) -> int_ty!($bytes) { + core::arch::naked_asm! { + // LSEOP s(0), s(0), [x1]; if LSE supported. + try_lse_op!($lse_op, $ordering, $bytes, 0, 0, [x1]), + // mov s(tmp0), s(0) + concat!("mov ", reg!($bytes, 16), ", ", reg!($bytes, 0)), + "0:", + // LDXR s(0), [x1] + concat!(ldxr!($ordering, $bytes), " ", reg!($bytes, 0), ", [x1]"), + // OP s(tmp1), s(0), s(tmp0) + concat!($op, " ", reg!($bytes, 17), ", ", reg!($bytes, 0), ", ", reg!($bytes, 16)), + // STXR w(tmp2), s(tmp1), [x1] + concat!(stxr!($ordering, $bytes), " w15, ", reg!($bytes, 17), ", [x1]"), + "cbnz w15, 0b", + "ret", + have_lse = sym crate::aarch64_outline_atomics::HAVE_LSE_ATOMICS, + } + } + } + } +} + +// We need a single macro to pass to `foreach_ldadd`. +macro_rules! add { + ($ordering:ident, $bytes:tt, $name:ident) => { + fetch_op! { $ordering, $bytes, $name, "add", "ldadd" } + }; +} + +macro_rules! and { + ($ordering:ident, $bytes:tt, $name:ident) => { + fetch_op! { $ordering, $bytes, $name, "bic", "ldclr" } + }; +} + +macro_rules! xor { + ($ordering:ident, $bytes:tt, $name:ident) => { + fetch_op! { $ordering, $bytes, $name, "eor", "ldeor" } + }; +} + +macro_rules! or { + ($ordering:ident, $bytes:tt, $name:ident) => { + fetch_op! { $ordering, $bytes, $name, "orr", "ldset" } + }; +} + +#[macro_export] +macro_rules! foreach_ordering { + ($macro:path, $bytes:tt, $name:ident) => { + $macro!( Relaxed, $bytes, ${concat($name, _relax)} ); + $macro!( Acquire, $bytes, ${concat($name, _acq)} ); + $macro!( Release, $bytes, ${concat($name, _rel)} ); + $macro!( AcqRel, $bytes, ${concat($name, _acq_rel)} ); + }; + ($macro:path, $name:ident) => { + $macro!( Relaxed, ${concat($name, _relax)} ); + $macro!( Acquire, ${concat($name, _acq)} ); + $macro!( Release, ${concat($name, _rel)} ); + $macro!( AcqRel, ${concat($name, _acq_rel)} ); + }; +} + +#[macro_export] +macro_rules! foreach_bytes { + ($macro:path, $name:ident) => { + foreach_ordering!( $macro, 1, ${concat(__aarch64_, $name, "1")} ); + foreach_ordering!( $macro, 2, ${concat(__aarch64_, $name, "2")} ); + foreach_ordering!( $macro, 4, ${concat(__aarch64_, $name, "4")} ); + foreach_ordering!( $macro, 8, ${concat(__aarch64_, $name, "8")} ); + }; +} + +/// Generate different macros for cas/swp/add/clr/eor/set so that we can test them separately. +#[macro_export] +macro_rules! foreach_cas { + ($macro:path) => { + foreach_bytes!($macro, cas); + }; +} + +/// Only CAS supports 16 bytes, and it has a different implementation that uses a different macro. +#[macro_export] +macro_rules! foreach_cas16 { + ($macro:path) => { + foreach_ordering!($macro, __aarch64_cas16); + }; +} +#[macro_export] +macro_rules! foreach_swp { + ($macro:path) => { + foreach_bytes!($macro, swp); + }; +} +#[macro_export] +macro_rules! foreach_ldadd { + ($macro:path) => { + foreach_bytes!($macro, ldadd); + }; +} +#[macro_export] +macro_rules! foreach_ldclr { + ($macro:path) => { + foreach_bytes!($macro, ldclr); + }; +} +#[macro_export] +macro_rules! foreach_ldeor { + ($macro:path) => { + foreach_bytes!($macro, ldeor); + }; +} +#[macro_export] +macro_rules! foreach_ldset { + ($macro:path) => { + foreach_bytes!($macro, ldset); + }; +} + +foreach_cas!(compare_and_swap); +foreach_cas16!(compare_and_swap_u128); +foreach_swp!(swap); +foreach_ldadd!(add); +foreach_ldclr!(and); +foreach_ldeor!(xor); +foreach_ldset!(or); diff --git a/ci/licenses/rust-compiler-originals/compiler-builtins-aarch64.rs.txt b/ci/licenses/rust-compiler-originals/compiler-builtins-aarch64.rs.txt new file mode 100644 index 0000000..2c12cb7 --- /dev/null +++ b/ci/licenses/rust-compiler-originals/compiler-builtins-aarch64.rs.txt @@ -0,0 +1,17 @@ +intrinsics! { + #[unsafe(naked)] + #[cfg(any(all(windows, target_env = "gnu"), target_os = "uefi"))] + pub unsafe extern "custom" fn __chkstk() { + core::arch::naked_asm!( + ".p2align 2", + "lsl x16, x15, #4", + "mov x17, sp", + "1:", + "sub x17, x17, 4096", + "subs x16, x16, 4096", + "ldr xzr, [x17]", + "b.gt 1b", + "ret", + ); + } +} diff --git a/ci/licenses/rust-compiler-originals/compiler-builtins-build.rs.txt b/ci/licenses/rust-compiler-originals/compiler-builtins-build.rs.txt new file mode 100644 index 0000000..e86c784 --- /dev/null +++ b/ci/licenses/rust-compiler-originals/compiler-builtins-build.rs.txt @@ -0,0 +1,649 @@ +#[path = "../libm/configure.rs"] +mod configure; + +use std::env; + +use configure::{Config, Library, set_cfg}; + +fn main() { + let cfg = Config::from_env(Library::CompilerBuiltins); + let llvm_target = &cfg.target_triple_split; + + // Work around building as part of `builtins-shim`: if only `build.rs` is used, Cargo always + // considers the build dirty because `builtins-shim/build.rs` does not exist. If only + // `../c-b/build.rs` is used, the same may happen if not built in the workspace. + // Note: this may be `None` if CARGO_MANIFEST_DIR doesn't end in a directory name (e.g. ".") + if let Some(dir) = cfg.manifest_dir.file_name() + && dir == "builtins-shim" + { + println!("cargo::rerun-if-changed=../compiler-builtins/build.rs"); + } else { + println!("cargo::rerun-if-changed=build.rs"); + } + + println!("cargo::rerun-if-changed=../libm/configure.rs"); + + configure::emit(&cfg); + configure_check_cfg(); + + let cwd = env::current_dir().unwrap(); + println!("cargo:compiler-rt={}", cwd.join("compiler-rt").display()); + + // Forcibly enable memory intrinsics on wasm & SGX as we don't have a libc to + // provide them. + if (cfg.target_triple.contains("wasm") && !cfg.target_triple.contains("wasi")) + || (cfg.target_triple.contains("sgx") && cfg.target_triple.contains("fortanix")) + || cfg.target_triple.contains("-none") + || cfg.target_triple.contains("nvptx") + || cfg.target_triple.contains("uefi") + || cfg.target_triple.contains("xous") + { + println!("cargo:rustc-cfg=feature=\"mem\""); + } + + // These targets have hardware unaligned access support. + let mem_unaligned = cfg.target_arch.contains("x86_64") + || cfg.target_arch.contains("x86") + || cfg.target_arch.contains("aarch64") + || cfg.target_arch.contains("bpf"); + set_cfg("mem_unaligned", mem_unaligned); + + // Only emit the ARM Linux atomic emulation on pre-ARMv6 architectures. This + // includes the old androideabi. It is deprecated but it is available as a + // rustc target (arm-linux-androideabi). + let kernel_user_helpers = llvm_target[0] == "armv4t" + || llvm_target[0] == "armv5te" + || cfg.target_triple == "arm-linux-androideabi"; + set_cfg("kernel_user_helpers", kernel_user_helpers); + + let mut maybe_build_c = true; + + // Emscripten's runtime includes all the builtins + if cfg.target_os == "emscripten" { + maybe_build_c = false; + } + + // OpenBSD provides compiler_rt by default, use it instead of rebuilding it from source + if cfg.target_os == "openbsd" { + println!("cargo:rustc-link-search=native=/usr/lib"); + println!("cargo:rustc-link-lib=compiler_rt"); + maybe_build_c = false; + } + + // Everything is LLVM bitcode, not compatible with mixed C/Rust + if cfg.target_arch.contains("nvptx") { + maybe_build_c = false; + } + + // Build missing intrinsics from compiler-rt C source code. If we're + // mangling names though we assume that we're also in test mode so we don't + // build anything and we rely on the upstream implementation of compiler-rt + // functions + if cfg!(feature = "unmangled-names") && cfg!(feature = "c") && maybe_build_c { + #[cfg(feature = "c")] + c::compile(&cfg); + } +} + +/// Emit directives for features we expect to support that aren't in `Cargo.toml`. +/// +/// These are mostly cfg elements emitted by this `build.rs`. +fn configure_check_cfg() { + // Functions where we can set the "optimized-c" flag + const HAS_OPTIMIZED_C: &[&str] = &[ + "__ashldi3", + "__ashlsi3", + "__ashrdi3", + "__ashrsi3", + "__bswapsi2", + "__bswapdi2", + "__bswapti2", + "__divdi3", + "__divsi3", + "__divmoddi4", + "__divmodsi4", + "__divmodsi4", + "__divmodti4", + "__lshrdi3", + "__lshrsi3", + "__moddi3", + "__modsi3", + "__muldi3", + "__udivdi3", + "__udivmoddi4", + "__udivmodsi4", + "__udivsi3", + "__umoddi3", + "__umodsi3", + ]; + + // Build a list of all aarch64 atomic operation functions + let mut aarch_atomic = Vec::new(); + for aarch_op in ["cas", "ldadd", "ldclr", "ldeor", "ldset", "swp"] { + let op_sizes = if aarch_op == "cas" { + [1, 2, 4, 8, 16].as_slice() + } else { + [1, 2, 4, 8].as_slice() + }; + + for op_size in op_sizes { + for ordering in ["relax", "acq", "rel", "acq_rel"] { + aarch_atomic.push(format!("__aarch64_{aarch_op}{op_size}_{ordering}")); + } + } + } + + for fn_name in HAS_OPTIMIZED_C + .iter() + .copied() + .chain(aarch_atomic.iter().map(|s| s.as_str())) + { + println!("cargo::rustc-check-cfg=cfg({fn_name}, values(\"optimized-c\"))",); + } + + // Rustc is unaware of sparc target features, but this does show up from + // `rustc --print target-features --target sparc64-unknown-linux-gnu`. + println!("cargo::rustc-check-cfg=cfg(target_feature, values(\"vis3\"))"); +} + +#[cfg(feature = "c")] +mod c { + use std::collections::{BTreeMap, HashSet}; + use std::env; + use std::fs::{self, File}; + use std::io::Write; + use std::path::{Path, PathBuf}; + + use super::Config; + + struct Sources { + // SYMBOL -> PATH TO SOURCE + map: BTreeMap<&'static str, &'static str>, + } + + impl Sources { + fn new() -> Sources { + Sources { + map: BTreeMap::new(), + } + } + + fn extend(&mut self, sources: &[(&'static str, &'static str)]) { + // NOTE Some intrinsics have both a generic implementation (e.g. + // `floatdidf.c`) and an arch optimized implementation + // (`x86_64/floatdidf.c`). In those cases, we keep the arch optimized + // implementation and discard the generic implementation. If we don't + // and keep both implementations, the linker will yell at us about + // duplicate symbols! + for (symbol, src) in sources { + if src.contains("/") { + // Arch-optimized implementation (preferred) + self.map.insert(symbol, src); + } else { + // Generic implementation + if !self.map.contains_key(symbol) { + self.map.insert(symbol, src); + } + } + } + } + + fn remove(&mut self, symbols: &[&str]) { + for symbol in symbols { + self.map.remove(*symbol).unwrap(); + } + } + } + + /// Compile intrinsics from the compiler-rt C source code + pub fn compile(cfg: &Config) { + let llvm_target = &cfg.target_triple_split; + let mut consider_float_intrinsics = true; + let build = &mut cc::Build::new(); + + // AArch64 GCCs exit with an error condition when they encounter any kind of floating point + // code if the `nofp` and/or `nosimd` compiler flags have been set. + // + // Therefore, evaluate if those flags are present and set a boolean that causes any + // compiler-rt intrinsics that contain floating point source to be excluded for this target. + if cfg.target_arch == "aarch64" { + let cflags_key = String::from("CFLAGS_") + &(cfg.target_triple.replace("-", "_")); + if let Ok(cflags_value) = env::var(cflags_key) { + if cflags_value.contains("+nofp") || cflags_value.contains("+nosimd") { + consider_float_intrinsics = false; + } + } + } + + // `compiler-rt` requires `COMPILER_RT_HAS_FLOAT16` to be defined to make it use the + // `_Float16` type for `f16` intrinsics. This shouldn't matter as all existing `f16` + // intrinsics have been ported to Rust in `compiler-builtins` as C compilers don't + // support `_Float16` on all targets (whereas Rust does). However, define the macro + // anyway to prevent issues like rust#118813 and rust#123885 silently reoccuring if more + // `f16` intrinsics get accidentally added here in the future. + build.define("COMPILER_RT_HAS_FLOAT16", None); + + build.warnings(false); + + if cfg.target_env == "msvc" { + // Don't pull in extra libraries on MSVC + build.flag("/Zl"); + + // Emulate C99 and C++11's __func__ for MSVC prior to 2013 CTP + build.define("__func__", Some("__FUNCTION__")); + } else { + // Turn off various features of gcc and such, mostly copying + // compiler-rt's build system already + build.flag("-fno-builtin"); + build.flag("-fvisibility=hidden"); + build.flag("-ffreestanding"); + // Avoid the following warning appearing once **per file**: + // clang: warning: optimization flag '-fomit-frame-pointer' is not supported for target 'armv7' [-Wignored-optimization-argument] + // + // Note that compiler-rt's build system also checks + // + // `check_cxx_compiler_flag(-fomit-frame-pointer COMPILER_RT_HAS_FOMIT_FRAME_POINTER_FLAG)` + // + // in https://github.com/rust-lang/compiler-rt/blob/c8fbcb3/cmake/config-ix.cmake#L19. + build.flag_if_supported("-fomit-frame-pointer"); + build.define("VISIBILITY_HIDDEN", None); + + if let "aarch64" | "arm64ec" = cfg.target_arch.as_str() { + // FIXME(llvm20): Older GCCs on A64 fail to build with + // -Werror=implicit-function-declaration due to a compiler-rt bug. + // With a newer LLVM we should be able to enable the flag everywhere. + // https://github.com/llvm/llvm-project/commit/8aa9d6206ce55bdaaf422839c351fbd63f033b89 + } else { + // Avoid implicitly creating references to undefined functions + build.flag("-Werror=implicit-function-declaration"); + } + } + + // int_util.c tries to include stdlib.h if `_WIN32` is defined, + // which it is when compiling UEFI targets with clang. This is + // at odds with compiling with `-ffreestanding`, as the header + // may be incompatible or not present. Create a minimal stub + // header to use instead. + if cfg.target_os == "uefi" { + let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); + let include_dir = out_dir.join("include"); + if !include_dir.exists() { + fs::create_dir(&include_dir).unwrap(); + } + fs::write(include_dir.join("stdlib.h"), "#include ").unwrap(); + build.flag(&format!("-I{}", include_dir.to_str().unwrap())); + } + + let mut sources = Sources::new(); + sources.extend(&[ + ("__absvdi2", "absvdi2.c"), + ("__absvsi2", "absvsi2.c"), + ("__addvdi3", "addvdi3.c"), + ("__addvsi3", "addvsi3.c"), + ("__cmpdi2", "cmpdi2.c"), + ("__int_util", "int_util.c"), + ("__mulvdi3", "mulvdi3.c"), + ("__mulvsi3", "mulvsi3.c"), + ("__negdi2", "negdi2.c"), + ("__negvdi2", "negvdi2.c"), + ("__negvsi2", "negvsi2.c"), + ("__paritydi2", "paritydi2.c"), + ("__paritysi2", "paritysi2.c"), + ("__popcountdi2", "popcountdi2.c"), + ("__popcountsi2", "popcountsi2.c"), + ("__subvdi3", "subvdi3.c"), + ("__subvsi3", "subvsi3.c"), + ("__ucmpdi2", "ucmpdi2.c"), + ]); + + if consider_float_intrinsics { + sources.extend(&[ + ("__divdc3", "divdc3.c"), + ("__divsc3", "divsc3.c"), + ("__muldc3", "muldc3.c"), + ("__mulsc3", "mulsc3.c"), + ("__negdf2", "negdf2.c"), + ("__negsf2", "negsf2.c"), + ]); + } + + // On iOS and 32-bit OSX these are all just empty intrinsics, no need to + // include them. + if cfg.target_vendor != "apple" || cfg.target_arch != "x86" { + sources.extend(&[ + ("__absvti2", "absvti2.c"), + ("__addvti3", "addvti3.c"), + ("__cmpti2", "cmpti2.c"), + ("__ffsti2", "ffsti2.c"), + ("__mulvti3", "mulvti3.c"), + ("__negti2", "negti2.c"), + ("__parityti2", "parityti2.c"), + ("__popcountti2", "popcountti2.c"), + ("__subvti3", "subvti3.c"), + ("__ucmpti2", "ucmpti2.c"), + ]); + + if consider_float_intrinsics { + sources.extend(&[("__negvti2", "negvti2.c")]); + } + } + + if cfg.target_vendor == "apple" { + sources.extend(&[ + ("atomic_flag_clear", "atomic_flag_clear.c"), + ("atomic_flag_clear_explicit", "atomic_flag_clear_explicit.c"), + ("atomic_flag_test_and_set", "atomic_flag_test_and_set.c"), + ( + "atomic_flag_test_and_set_explicit", + "atomic_flag_test_and_set_explicit.c", + ), + ("atomic_signal_fence", "atomic_signal_fence.c"), + ("atomic_thread_fence", "atomic_thread_fence.c"), + ]); + } + + if cfg.target_env != "msvc" { + if cfg.target_arch == "x86" { + sources.extend(&[ + ("__ashldi3", "i386/ashldi3.S"), + ("__ashrdi3", "i386/ashrdi3.S"), + ("__divdi3", "i386/divdi3.S"), + ("__lshrdi3", "i386/lshrdi3.S"), + ("__moddi3", "i386/moddi3.S"), + ("__muldi3", "i386/muldi3.S"), + ("__udivdi3", "i386/udivdi3.S"), + ("__umoddi3", "i386/umoddi3.S"), + ]); + } + } + + if cfg.target_arch == "arm" && cfg.target_vendor != "apple" && cfg.target_env != "msvc" { + sources.extend(&[ + ("__aeabi_div0", "arm/aeabi_div0.c"), + ("__aeabi_drsub", "arm/aeabi_drsub.c"), + ("__aeabi_frsub", "arm/aeabi_frsub.c"), + ("__bswapdi2", "arm/bswapdi2.S"), + ("__bswapsi2", "arm/bswapsi2.S"), + ("__divmodsi4", "arm/divmodsi4.S"), + ("__divsi3", "arm/divsi3.S"), + ("__modsi3", "arm/modsi3.S"), + ("__switch16", "arm/switch16.S"), + ("__switch32", "arm/switch32.S"), + ("__switch8", "arm/switch8.S"), + ("__switchu8", "arm/switchu8.S"), + ("__sync_synchronize", "arm/sync_synchronize.S"), + ("__udivmodsi4", "arm/udivmodsi4.S"), + ("__udivsi3", "arm/udivsi3.S"), + ("__umodsi3", "arm/umodsi3.S"), + ]); + + if cfg.target_os == "freebsd" { + sources.extend(&[("__clear_cache", "clear_cache.c")]); + } + + // First of all aeabi_cdcmp and aeabi_cfcmp are never called by LLVM. + // Second are little-endian only, so build fail on big-endian targets. + // Temporally workaround: exclude these files for big-endian targets. + if !llvm_target[0].starts_with("thumbeb") && !llvm_target[0].starts_with("armeb") { + sources.extend(&[ + ("__aeabi_cdcmp", "arm/aeabi_cdcmp.S"), + ("__aeabi_cdcmpeq_check_nan", "arm/aeabi_cdcmpeq_check_nan.c"), + ("__aeabi_cfcmp", "arm/aeabi_cfcmp.S"), + ("__aeabi_cfcmpeq_check_nan", "arm/aeabi_cfcmpeq_check_nan.c"), + ]); + } + } + + if llvm_target[0] == "armv7" { + sources.extend(&[ + ("__sync_fetch_and_add_4", "arm/sync_fetch_and_add_4.S"), + ("__sync_fetch_and_add_8", "arm/sync_fetch_and_add_8.S"), + ("__sync_fetch_and_and_4", "arm/sync_fetch_and_and_4.S"), + ("__sync_fetch_and_and_8", "arm/sync_fetch_and_and_8.S"), + ("__sync_fetch_and_max_4", "arm/sync_fetch_and_max_4.S"), + ("__sync_fetch_and_max_8", "arm/sync_fetch_and_max_8.S"), + ("__sync_fetch_and_min_4", "arm/sync_fetch_and_min_4.S"), + ("__sync_fetch_and_min_8", "arm/sync_fetch_and_min_8.S"), + ("__sync_fetch_and_nand_4", "arm/sync_fetch_and_nand_4.S"), + ("__sync_fetch_and_nand_8", "arm/sync_fetch_and_nand_8.S"), + ("__sync_fetch_and_or_4", "arm/sync_fetch_and_or_4.S"), + ("__sync_fetch_and_or_8", "arm/sync_fetch_and_or_8.S"), + ("__sync_fetch_and_sub_4", "arm/sync_fetch_and_sub_4.S"), + ("__sync_fetch_and_sub_8", "arm/sync_fetch_and_sub_8.S"), + ("__sync_fetch_and_umax_4", "arm/sync_fetch_and_umax_4.S"), + ("__sync_fetch_and_umax_8", "arm/sync_fetch_and_umax_8.S"), + ("__sync_fetch_and_umin_4", "arm/sync_fetch_and_umin_4.S"), + ("__sync_fetch_and_umin_8", "arm/sync_fetch_and_umin_8.S"), + ("__sync_fetch_and_xor_4", "arm/sync_fetch_and_xor_4.S"), + ("__sync_fetch_and_xor_8", "arm/sync_fetch_and_xor_8.S"), + ]); + } + + if llvm_target.last().unwrap().ends_with("eabihf") { + if !llvm_target[0].starts_with("thumbv7em") + && !llvm_target[0].starts_with("thumbv8m.main") + { + // The FPU option chosen for these architectures in cc-rs, ie: + // -mfpu=fpv4-sp-d16 for thumbv7em + // -mfpu=fpv5-sp-d16 for thumbv8m.main + // do not support double precision floating points conversions so the files + // that include such instructions are not included for these targets. + sources.extend(&[ + ("__fixdfsivfp", "arm/fixdfsivfp.S"), + ("__fixunsdfsivfp", "arm/fixunsdfsivfp.S"), + ("__floatsidfvfp", "arm/floatsidfvfp.S"), + ("__floatunssidfvfp", "arm/floatunssidfvfp.S"), + ]); + } + + sources.extend(&[ + ("__fixsfsivfp", "arm/fixsfsivfp.S"), + ("__fixunssfsivfp", "arm/fixunssfsivfp.S"), + ("__floatsisfvfp", "arm/floatsisfvfp.S"), + ("__floatunssisfvfp", "arm/floatunssisfvfp.S"), + ("__floatunssisfvfp", "arm/floatunssisfvfp.S"), + ("__restore_vfp_d8_d15_regs", "arm/restore_vfp_d8_d15_regs.S"), + ("__save_vfp_d8_d15_regs", "arm/save_vfp_d8_d15_regs.S"), + ("__negdf2vfp", "arm/negdf2vfp.S"), + ("__negsf2vfp", "arm/negsf2vfp.S"), + ]); + } + + if (cfg.target_arch == "aarch64" || cfg.target_arch == "arm64ec") + && consider_float_intrinsics + { + sources.extend(&[ + ("__fe_getround", "fp_mode.c"), + ("__fe_raise_inexact", "fp_mode.c"), + ]); + + if cfg.target_os != "windows" && cfg.target_os != "cygwin" { + sources.extend(&[("__multc3", "multc3.c")]); + } + } + + if cfg.target_arch == "mips" || cfg.target_arch == "riscv32" || cfg.target_arch == "riscv64" + { + sources.extend(&[("__bswapsi2", "bswapsi2.c")]); + } + + if cfg.target_arch == "mips64" { + sources.extend(&[("__fe_getround", "fp_mode.c")]); + } + + if cfg.target_arch == "loongarch64" { + sources.extend(&[("__fe_getround", "fp_mode.c")]); + } + + // Remove the assembly implementations that won't compile for the target + if llvm_target[0] == "thumbv6m" + || llvm_target[0] == "thumbv8m.base" + || cfg.target_os == "uefi" + { + let mut to_remove = Vec::new(); + for (k, v) in sources.map.iter() { + if v.ends_with(".S") { + to_remove.push(*k); + } + } + sources.remove(&to_remove); + } + + if llvm_target[0] == "thumbv7m" || llvm_target[0] == "thumbv7em" { + sources.remove(&["__aeabi_cdcmp", "__aeabi_cfcmp"]); + } + + // Android and Cygwin uses emulated TLS so we need a runtime support function. + if cfg.target_os == "android" || cfg.target_os == "cygwin" { + sources.extend(&[("__emutls_get_address", "emutls.c")]); + } + + // Work around a bug in the NDK headers (fixed in + // https://r.android.com/2038949 which will be released in a future + // NDK version) by providing a definition of LONG_BIT. + if cfg.target_os == "android" { + build.define("LONG_BIT", "(8 * sizeof(long))"); + } + + // OpenHarmony also uses emulated TLS. + if cfg.target_env == "ohos" { + sources.extend(&[("__emutls_get_address", "emutls.c")]); + } + + // Optionally, link against a prebuilt llvm compiler-rt containing the builtins + // library. Only the builtins library is required. On many platforms, this is + // available as a library named libclang_rt.builtins.a. + let link_against_prebuilt_rt = env::var_os("LLVM_COMPILER_RT_LIB").is_some(); + + // When compiling the C code we require the user to tell us where the + // source code is, and this is largely done so when we're compiling as + // part of rust-lang/rust we can use the same llvm-project repository as + // rust-lang/rust. + let root = match env::var_os("RUST_COMPILER_RT_ROOT") { + Some(s) => PathBuf::from(s), + // If a prebuild libcompiler-rt is provided, set a valid + // path to simplify later logic. Nothing should be compiled. + None if link_against_prebuilt_rt => PathBuf::new(), + None => { + panic!( + "RUST_COMPILER_RT_ROOT is not set. You may need to run \ + `ci/download-compiler-rt.sh`." + ); + } + }; + if !link_against_prebuilt_rt && !root.exists() { + panic!("RUST_COMPILER_RT_ROOT={} does not exist", root.display()); + } + + // Support deterministic builds by remapping the __FILE__ prefix if the + // compiler supports it. This fixes the nondeterminism caused by the + // use of that macro in lib/builtins/int_util.h in compiler-rt. + build.flag_if_supported(&format!("-ffile-prefix-map={}=.", root.display())); + + // Include out-of-line atomics for aarch64, which are all generated by supplying different + // sets of flags to the same source file. + // Note: Out-of-line aarch64 atomics are not supported by the msvc toolchain (#430) and + // on uefi. + let src_dir = root.join("lib/builtins"); + if cfg.target_arch == "aarch64" && cfg.target_env != "msvc" && cfg.target_os != "uefi" { + // See below for why we're building these as separate libraries. + build_aarch64_out_of_line_atomics_libraries(&src_dir, build, link_against_prebuilt_rt); + + // Some run-time CPU feature detection is necessary, as well. + let cpu_model_src = if src_dir.join("cpu_model.c").exists() { + "cpu_model.c" + } else { + "cpu_model/aarch64.c" + }; + sources.extend(&[("__aarch64_have_lse_atomics", cpu_model_src)]); + } + + let mut added_sources = HashSet::new(); + for (sym, src) in sources.map.iter() { + let src = src_dir.join(src); + if !link_against_prebuilt_rt && added_sources.insert(src.clone()) { + build.file(&src); + println!("cargo:rerun-if-changed={}", src.display()); + } + println!("cargo:rustc-cfg={}=\"optimized-c\"", sym); + } + + if link_against_prebuilt_rt { + let rt_builtins_ext = PathBuf::from(env::var_os("LLVM_COMPILER_RT_LIB").unwrap()); + if !rt_builtins_ext.exists() { + panic!( + "LLVM_COMPILER_RT_LIB={} does not exist", + rt_builtins_ext.display() + ); + } + if let Some(dir) = rt_builtins_ext.parent() { + println!("cargo::rustc-link-search=native={}", dir.display()); + } + if let Some(lib) = rt_builtins_ext.file_name() { + println!( + "cargo::rustc-link-lib=static:+verbatim={}", + lib.to_str().unwrap() + ); + } + } else { + build.compile("libcompiler-rt.a"); + } + } + + fn build_aarch64_out_of_line_atomics_libraries( + builtins_dir: &Path, + cfg: &mut cc::Build, + link_against_prebuilt_rt: bool, + ) { + let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); + let outlined_atomics_file = builtins_dir.join("aarch64").join("lse.S"); + if !link_against_prebuilt_rt { + println!("cargo:rerun-if-changed={}", outlined_atomics_file.display()); + } + + cfg.include(&builtins_dir); + + for instruction_type in &["cas", "swp", "ldadd", "ldclr", "ldeor", "ldset"] { + for size in &[1, 2, 4, 8, 16] { + if *size == 16 && *instruction_type != "cas" { + continue; + } + + for (model_number, model_name) in + &[(1, "relax"), (2, "acq"), (3, "rel"), (4, "acq_rel")] + { + let sym = format!("__aarch64_{}{}_{}", instruction_type, size, model_name); + println!("cargo:rustc-cfg={}=\"optimized-c\"", sym); + + if link_against_prebuilt_rt { + continue; + } + + // The original compiler-rt build system compiles the same + // source file multiple times with different compiler + // options. Here we do something slightly different: we + // create multiple .S files with the proper #defines and + // then include the original file. + // + // This is needed because the cc crate doesn't allow us to + // override the name of object files and libtool requires + // all objects in an archive to have unique names. + let path = + out_dir.join(format!("lse_{}{}_{}.S", instruction_type, size, model_name)); + let mut file = File::create(&path).unwrap(); + writeln!(file, "#define L_{}", instruction_type).unwrap(); + writeln!(file, "#define SIZE {}", size).unwrap(); + writeln!(file, "#define MODEL {}", model_number).unwrap(); + writeln!( + file, + "#include \"{}\"", + outlined_atomics_file.canonicalize().unwrap().display() + ) + .unwrap(); + drop(file); + cfg.file(path); + } + } + } + } +} diff --git a/ci/licenses/rust-compiler-originals/compiler-builtins-float-conv.rs.txt b/ci/licenses/rust-compiler-originals/compiler-builtins-float-conv.rs.txt new file mode 100644 index 0000000..6193aa4 --- /dev/null +++ b/ci/licenses/rust-compiler-originals/compiler-builtins-float-conv.rs.txt @@ -0,0 +1,508 @@ +use core::ops::Neg; + +use crate::support::{CastFrom, CastInto, Float, Int, MinInt}; + +/// Conversions from integers to floats. +/// +/// The algorithm is explained here: . It roughly does the following: +/// - Calculate a base mantissa by shifting the integer into mantissa position. This gives us a +/// mantissa _with the implicit bit set_! +/// - Figure out if rounding needs to occur by classifying the bits that are to be truncated. Some +/// patterns are used to simplify this. Adjust the mantissa with the result if needed. +/// - Calculate the exponent based on the base-2 logarithm of `i` (leading zeros). Subtract one. +/// - Shift the exponent and add the mantissa to create the final representation. Subtracting one +/// from the exponent (above) accounts for the explicit bit being set in the mantissa. +/// +/// # Terminology +/// +/// - `i`: the original integer +/// - `i_m`: the integer, shifted fully left (no leading zeros) +/// - `n`: number of leading zeroes +/// - `e`: the resulting exponent. Usually 1 is subtracted to offset the mantissa implicit bit. +/// - `m_base`: the mantissa before adjusting for truncated bits. Implicit bit is usually set. +/// - `adj`: the bits that will be truncated, possibly compressed in some way. +/// - `m`: the resulting mantissa. Implicit bit is usually set. +mod int_to_float { + use super::*; + + /// Calculate the exponent from the number of leading zeros. + /// + /// Usually 1 is subtracted from this function's result, so that a mantissa with the implicit + /// bit set can be added back later. + fn exp>>(n: u32) -> F::Int { + F::Int::cast_from(F::EXP_BIAS - 1 + I::BITS - n) + } + + /// Adjust a mantissa with dropped bits to perform correct rounding. + /// + /// The dropped bits should be exactly the bits that get truncated (left-aligned), but they + /// can be combined or compressed in some way that simplifies operations. + fn m_adj(m_base: F::Int, dropped_bits: F::Int) -> F::Int { + // Branchlessly extract a `1` if rounding up should happen, 0 otherwise + // This accounts for rounding to even. + let adj = (dropped_bits - ((dropped_bits >> (F::BITS - 1)) & !m_base)) >> (F::BITS - 1); + + // Add one when we need to round up. Break ties to even. + m_base + adj + } + + /// Shift the exponent to its position and add the mantissa. + /// + /// If the mantissa has the implicit bit set, the exponent should be one less than its actual + /// value to cancel it out. + fn repr(e: F::Int, m: F::Int) -> F::Int { + // + rather than | so the mantissa can overflow into the exponent + (e << F::SIG_BITS) + m + } + + /// Shift distance from a left-aligned integer to a smaller float. + fn shift_f_lt_i() -> u32 { + (I::BITS - F::BITS) + F::EXP_BITS + } + + /// Shift distance from an integer with `n` leading zeros to a smaller float. + fn shift_f_gt_i(n: u32) -> u32 { + F::SIG_BITS - I::BITS + 1 + n + } + + /// Perform a signed operation as unsigned, then add the sign back. + pub fn signed(i: I, conv: Conv) -> F + where + F: Float, + I: Int, + F::Int: CastFrom, + Conv: Fn(I::Unsigned) -> F::Int, + { + let sign_bit = F::Int::cast_from_lossy(i >> (I::BITS - 1)) << (F::BITS - 1); + F::from_bits(conv(i.unsigned_abs()) | sign_bit) + } + + pub fn u32_to_f32_bits(i: u32) -> u32 { + if i == 0 { + return 0; + } + let n = i.leading_zeros(); + // Mantissa with implicit bit set (significant bits) + let m_base = (i << n) >> f32::EXP_BITS; + // Bits that will be dropped (insignificant bits) + let adj = (i << n) << (f32::SIG_BITS + 1); + let m = m_adj::(m_base, adj); + let e = exp::(n) - 1; + repr::(e, m) + } + + pub fn u32_to_f64_bits(i: u32) -> u64 { + if i == 0 { + return 0; + } + let n = i.leading_zeros(); + // Mantissa with implicit bit set + let m = (i as u64) << shift_f_gt_i::(n); + let e = exp::(n) - 1; + repr::(e, m) + } + + #[cfg(f128_enabled)] + pub fn u32_to_f128_bits(i: u32) -> u128 { + if i == 0 { + return 0; + } + let n = i.leading_zeros(); + + // Shift into mantissa position that is correct for the type, but shifted into the lower + // 64 bits over so can can avoid 128-bit math. + let m = (i as u64) << (shift_f_gt_i::(n) - 64); + let e = exp::(n) as u64 - 1; + // High 64 bits of f128 representation. + let h = (e << (f128::SIG_BITS - 64)) + m; + + // Shift back to the high bits, the rest of the mantissa will always be 0. + (h as u128) << 64 + } + + pub fn u64_to_f32_bits(i: u64) -> u32 { + let n = i.leading_zeros(); + let i_m = i.wrapping_shl(n); + // Mantissa with implicit bit set + let m_base: u32 = (i_m >> shift_f_lt_i::()) as u32; + // The entire lower half of `i` will be truncated (masked portion), plus the + // next `EXP_BITS` bits. + let adj = ((i_m >> f32::EXP_BITS) | i_m & 0xFFFF) as u32; + let m = m_adj::(m_base, adj); + let e = if i == 0 { 0 } else { exp::(n) - 1 }; + repr::(e, m) + } + + pub fn u64_to_f64_bits(i: u64) -> u64 { + if i == 0 { + return 0; + } + let n = i.leading_zeros(); + // Mantissa with implicit bit set + let m_base = (i << n) >> f64::EXP_BITS; + let adj = (i << n) << (f64::SIG_BITS + 1); + let m = m_adj::(m_base, adj); + let e = exp::(n) - 1; + repr::(e, m) + } + + #[cfg(f128_enabled)] + pub fn u64_to_f128_bits(i: u64) -> u128 { + if i == 0 { + return 0; + } + let n = i.leading_zeros(); + // Mantissa with implicit bit set + let m = (i as u128) << shift_f_gt_i::(n); + let e = exp::(n) - 1; + repr::(e, m) + } + + pub fn u128_to_f32_bits(i: u128) -> u32 { + let n = i.leading_zeros(); + let i_m = i.wrapping_shl(n); // Mantissa, shifted so the first bit is nonzero + let m_base: u32 = (i_m >> shift_f_lt_i::()) as u32; + + // Within the upper `F::BITS`, everything except for the signifcand + // gets truncated + let d1: u32 = (i_m >> (u128::BITS - f32::BITS - f32::SIG_BITS - 1)).cast_lossy(); + + // The entire rest of `i_m` gets truncated. Zero the upper `F::BITS` then just + // check if it is nonzero. + let d2: u32 = (i_m << f32::BITS >> f32::BITS != 0).into(); + let adj = d1 | d2; + + // Mantissa with implicit bit set + let m = m_adj::(m_base, adj); + let e = if i == 0 { 0 } else { exp::(n) - 1 }; + repr::(e, m) + } + + pub fn u128_to_f64_bits(i: u128) -> u64 { + let n = i.leading_zeros(); + let i_m = i.wrapping_shl(n); + // Mantissa with implicit bit set + let m_base: u64 = (i_m >> shift_f_lt_i::()) as u64; + // The entire lower half of `i` will be truncated (masked portion), plus the + // next `EXP_BITS` bits. + let adj = ((i_m >> f64::EXP_BITS) | i_m & 0xFFFF_FFFF) as u64; + let m = m_adj::(m_base, adj); + let e = if i == 0 { 0 } else { exp::(n) - 1 }; + repr::(e, m) + } + + #[cfg(f128_enabled)] + pub fn u128_to_f128_bits(i: u128) -> u128 { + if i == 0 { + return 0; + } + let n = i.leading_zeros(); + // Mantissa with implicit bit set + let m_base = (i << n) >> f128::EXP_BITS; + let adj = (i << n) << (f128::SIG_BITS + 1); + let m = m_adj::(m_base, adj); + let e = exp::(n) - 1; + repr::(e, m) + } +} + +// Conversions from unsigned integers to floats. +intrinsics! { + #[arm_aeabi_alias = __aeabi_ui2f] + pub extern "C" fn __floatunsisf(i: u32) -> f32 { + f32::from_bits(int_to_float::u32_to_f32_bits(i)) + } + + #[arm_aeabi_alias = __aeabi_ui2d] + pub extern "C" fn __floatunsidf(i: u32) -> f64 { + f64::from_bits(int_to_float::u32_to_f64_bits(i)) + } + + #[arm_aeabi_alias = __aeabi_ul2f] + pub extern "C" fn __floatundisf(i: u64) -> f32 { + f32::from_bits(int_to_float::u64_to_f32_bits(i)) + } + + #[arm_aeabi_alias = __aeabi_ul2d] + pub extern "C" fn __floatundidf(i: u64) -> f64 { + f64::from_bits(int_to_float::u64_to_f64_bits(i)) + } + + #[cfg(not(all(target_os = "uefi", target_arch = "x86_64")))] + pub extern "C" fn __floatuntisf(i: u128) -> f32 { + f32::from_bits(int_to_float::u128_to_f32_bits(i)) + } + + #[cfg(all(target_os = "uefi", target_arch = "x86_64"))] + pub extern "C" fn __floatuntisf(lo: u64, hi: u64) -> f32 { + f32::from_bits(int_to_float::u128_to_f32_bits((u128::from(hi) << 64) | u128::from(lo))) + } + + #[cfg(not(all(target_os = "uefi", target_arch = "x86_64")))] + pub extern "C" fn __floatuntidf(i: u128) -> f64 { + f64::from_bits(int_to_float::u128_to_f64_bits(i)) + } + + #[cfg(all(target_os = "uefi", target_arch = "x86_64"))] + pub extern "C" fn __floatuntidf(lo: u64, hi: u64) -> f64 { + f64::from_bits(int_to_float::u128_to_f64_bits((u128::from(hi) << 64) | u128::from(lo))) + } + + #[ppc_alias = __floatunsikf] + #[cfg(f128_enabled)] + pub extern "C" fn __floatunsitf(i: u32) -> f128 { + f128::from_bits(int_to_float::u32_to_f128_bits(i)) + } + + #[ppc_alias = __floatundikf] + #[cfg(f128_enabled)] + pub extern "C" fn __floatunditf(i: u64) -> f128 { + f128::from_bits(int_to_float::u64_to_f128_bits(i)) + } + + #[ppc_alias = __floatuntikf] + #[cfg(f128_enabled)] + pub extern "C" fn __floatuntitf(i: u128) -> f128 { + f128::from_bits(int_to_float::u128_to_f128_bits(i)) + } +} + +// Conversions from signed integers to floats. +intrinsics! { + #[arm_aeabi_alias = __aeabi_i2f] + pub extern "C" fn __floatsisf(i: i32) -> f32 { + int_to_float::signed(i, int_to_float::u32_to_f32_bits) + } + + #[arm_aeabi_alias = __aeabi_i2d] + pub extern "C" fn __floatsidf(i: i32) -> f64 { + int_to_float::signed(i, int_to_float::u32_to_f64_bits) + } + + #[arm_aeabi_alias = __aeabi_l2f] + pub extern "C" fn __floatdisf(i: i64) -> f32 { + int_to_float::signed(i, int_to_float::u64_to_f32_bits) + } + + #[arm_aeabi_alias = __aeabi_l2d] + pub extern "C" fn __floatdidf(i: i64) -> f64 { + int_to_float::signed(i, int_to_float::u64_to_f64_bits) + } + + #[cfg(not(all(target_os = "uefi", target_arch = "x86_64")))] + pub extern "C" fn __floattisf(i: i128) -> f32 { + int_to_float::signed(i, int_to_float::u128_to_f32_bits) + } + + #[cfg(all(target_os = "uefi", target_arch = "x86_64"))] + pub extern "C" fn __floattisf(lo: u64, hi: u64) -> f32 { + int_to_float::signed((i128::from(hi) << 64) | i128::from(lo), int_to_float::u128_to_f32_bits) + } + + #[cfg(not(all(target_os = "uefi", target_arch = "x86_64")))] + pub extern "C" fn __floattidf(i: i128) -> f64 { + int_to_float::signed(i, int_to_float::u128_to_f64_bits) + } + + #[cfg(all(target_os = "uefi", target_arch = "x86_64"))] + pub extern "C" fn __floattidf(lo: u64, hi: u64) -> f64 { + int_to_float::signed((i128::from(hi) << 64) | i128::from(lo), int_to_float::u128_to_f64_bits) + } + + #[ppc_alias = __floatsikf] + #[cfg(f128_enabled)] + pub extern "C" fn __floatsitf(i: i32) -> f128 { + int_to_float::signed(i, int_to_float::u32_to_f128_bits) + } + + #[ppc_alias = __floatdikf] + #[cfg(f128_enabled)] + pub extern "C" fn __floatditf(i: i64) -> f128 { + int_to_float::signed(i, int_to_float::u64_to_f128_bits) + } + + #[ppc_alias = __floattikf] + #[cfg(f128_enabled)] + pub extern "C" fn __floattitf(i: i128) -> f128 { + int_to_float::signed(i, int_to_float::u128_to_f128_bits) + } +} + +/// Generic float to unsigned int conversions. +fn float_to_unsigned_int(f: F) -> U +where + F: Float, + U: Int, + F::Int: CastInto, + F::Int: CastFrom, + F::Int: CastInto, + u32: CastFrom, +{ + float_to_int_inner::(f.to_bits(), |i: U| i, || U::MAX) +} + +/// Generic float to signed int conversions. +fn float_to_signed_int(f: F) -> I +where + F: Float, + I: Int + Neg, + I::Unsigned: Int, + F::Int: CastInto, + F::Int: CastFrom, + u32: CastFrom, +{ + float_to_int_inner::( + f.to_bits() & !F::SIGN_MASK, + |i: I| if f.is_sign_negative() { -i } else { i }, + || if f.is_sign_negative() { I::MIN } else { I::MAX }, + ) +} + +/// Float to int conversions, generic for both signed and unsigned. +/// +/// Parameters: +/// - `fbits`: `abg(f)` bitcasted to an integer. +/// - `map_inbounds`: apply this transformation to integers that are within range (add the sign back). +/// - `out_of_bounds`: return value when out of range for `I`. +fn float_to_int_inner( + fbits: F::Int, + map_inbounds: FnFoo, + out_of_bounds: FnOob, +) -> I +where + F: Float, + I: Int, + FnFoo: FnOnce(I) -> I, + FnOob: FnOnce() -> I, + I::Unsigned: Int, + F::Int: CastInto, + F::Int: CastFrom, + u32: CastFrom, +{ + let int_max_exp = F::EXP_BIAS + I::MAX.ilog2() + 1; + let foobar = F::EXP_BIAS + I::Unsigned::BITS - 1; + + if fbits < F::ONE.to_bits() { + // < 0 gets rounded to 0 + I::ZERO + } else if fbits < F::Int::cast_from(int_max_exp) << F::SIG_BITS { + // >= 1, < integer max + let m_base = if I::Unsigned::BITS >= F::Int::BITS { + I::Unsigned::cast_from(fbits) << (I::BITS - F::SIG_BITS - 1) + } else { + I::Unsigned::cast_from_lossy(fbits >> (F::SIG_BITS - I::BITS + 1)) + }; + + // Set the implicit 1-bit. + let m: I::Unsigned = (I::Unsigned::ONE << (I::BITS - 1)) | m_base; + + // Shift based on the exponent and bias. + let s: u32 = (foobar) - u32::cast_from(fbits >> F::SIG_BITS); + + let unsigned = m >> s; + map_inbounds(I::from_unsigned(unsigned)) + } else if fbits <= F::EXP_MASK { + // >= max (incl. inf) + out_of_bounds() + } else { + I::ZERO + } +} + +// Conversions from floats to unsigned integers. +intrinsics! { + #[arm_aeabi_alias = __aeabi_f2uiz] + pub extern "C" fn __fixunssfsi(f: f32) -> u32 { + float_to_unsigned_int(f) + } + + #[arm_aeabi_alias = __aeabi_f2ulz] + pub extern "C" fn __fixunssfdi(f: f32) -> u64 { + float_to_unsigned_int(f) + } + + pub extern "C" fn __fixunssfti(f: f32) -> u128 { + float_to_unsigned_int(f) + } + + #[arm_aeabi_alias = __aeabi_d2uiz] + pub extern "C" fn __fixunsdfsi(f: f64) -> u32 { + float_to_unsigned_int(f) + } + + #[arm_aeabi_alias = __aeabi_d2ulz] + pub extern "C" fn __fixunsdfdi(f: f64) -> u64 { + float_to_unsigned_int(f) + } + + pub extern "C" fn __fixunsdfti(f: f64) -> u128 { + float_to_unsigned_int(f) + } + + #[ppc_alias = __fixunskfsi] + #[cfg(f128_enabled)] + pub extern "C" fn __fixunstfsi(f: f128) -> u32 { + float_to_unsigned_int(f) + } + + #[ppc_alias = __fixunskfdi] + #[cfg(f128_enabled)] + pub extern "C" fn __fixunstfdi(f: f128) -> u64 { + float_to_unsigned_int(f) + } + + #[ppc_alias = __fixunskfti] + #[cfg(f128_enabled)] + pub extern "C" fn __fixunstfti(f: f128) -> u128 { + float_to_unsigned_int(f) + } +} + +// Conversions from floats to signed integers. +intrinsics! { + #[arm_aeabi_alias = __aeabi_f2iz] + pub extern "C" fn __fixsfsi(f: f32) -> i32 { + float_to_signed_int(f) + } + + #[arm_aeabi_alias = __aeabi_f2lz] + pub extern "C" fn __fixsfdi(f: f32) -> i64 { + float_to_signed_int(f) + } + + pub extern "C" fn __fixsfti(f: f32) -> i128 { + float_to_signed_int(f) + } + + #[arm_aeabi_alias = __aeabi_d2iz] + pub extern "C" fn __fixdfsi(f: f64) -> i32 { + float_to_signed_int(f) + } + + #[arm_aeabi_alias = __aeabi_d2lz] + pub extern "C" fn __fixdfdi(f: f64) -> i64 { + float_to_signed_int(f) + } + + pub extern "C" fn __fixdfti(f: f64) -> i128 { + float_to_signed_int(f) + } + + #[ppc_alias = __fixkfsi] + #[cfg(f128_enabled)] + pub extern "C" fn __fixtfsi(f: f128) -> i32 { + float_to_signed_int(f) + } + + #[ppc_alias = __fixkfdi] + #[cfg(f128_enabled)] + pub extern "C" fn __fixtfdi(f: f128) -> i64 { + float_to_signed_int(f) + } + + #[ppc_alias = __fixkfti] + #[cfg(f128_enabled)] + pub extern "C" fn __fixtfti(f: f128) -> i128 { + float_to_signed_int(f) + } +} diff --git a/ci/licenses/rust-compiler-originals/compiler-builtins-math-mod.rs.txt b/ci/licenses/rust-compiler-originals/compiler-builtins-math-mod.rs.txt new file mode 100644 index 0000000..3dfa386 --- /dev/null +++ b/ci/licenses/rust-compiler-originals/compiler-builtins-math-mod.rs.txt @@ -0,0 +1,211 @@ +#[rustfmt::skip] +#[allow(dead_code)] +#[allow(unused_imports)] +#[allow(clippy::all)] +#[path = "../../../libm/src/math/mod.rs"] +pub(crate) mod libm_math; + +macro_rules! libm_intrinsics { + ($(fn $fun:ident($($iid:ident : $ity:ty),+) -> $oty:ty;)+) => { + intrinsics! { + $( + pub extern "C" fn $fun($($iid: $ity),+) -> $oty { + $crate::math::libm_math::$fun($($iid),+) + } + )+ + } + } +} + +/// This set of functions is well tested in `libm` and known to provide similar performance to +/// system `libm`, as well as the same or better accuracy. +pub mod full_availability { + #[cfg(f16_enabled)] + libm_intrinsics! { + fn ceilf16(x: f16) -> f16; + fn copysignf16(x: f16, y: f16) -> f16; + fn fabsf16(x: f16) -> f16; + fn fdimf16(x: f16, y: f16) -> f16; + fn floorf16(x: f16) -> f16; + fn fmaxf16(x: f16, y: f16) -> f16; + fn fmaximum_numf16(x: f16, y: f16) -> f16; + fn fmaximumf16(x: f16, y: f16) -> f16; + fn fminf16(x: f16, y: f16) -> f16; + fn fminimum_numf16(x: f16, y: f16) -> f16; + fn fminimumf16(x: f16, y: f16) -> f16; + fn fmodf16(x: f16, y: f16) -> f16; + fn rintf16(x: f16) -> f16; + fn roundevenf16(x: f16) -> f16; + fn roundf16(x: f16) -> f16; + fn sqrtf16(x: f16) -> f16; + fn truncf16(x: f16) -> f16; + } + + /* Weak linkage is unreliable on Windows and Apple, so we don't expose symbols that we know + * the system libc provides in order to avoid conflicts. */ + + #[cfg(all(not(windows), not(target_vendor = "apple")))] + libm_intrinsics! { + /* f32 */ + fn cbrtf(n: f32) -> f32; + fn ceilf(x: f32) -> f32; + fn copysignf(x: f32, y: f32) -> f32; + fn fabsf(x: f32) -> f32; + fn fdimf(a: f32, b: f32) -> f32; + fn floorf(x: f32) -> f32; + fn fmaf(x: f32, y: f32, z: f32) -> f32; + fn fmaxf(x: f32, y: f32) -> f32; + fn fminf(x: f32, y: f32) -> f32; + fn fmodf(x: f32, y: f32) -> f32; + fn rintf(x: f32) -> f32; + fn roundf(x: f32) -> f32; + fn sqrtf(x: f32) -> f32; + fn truncf(x: f32) -> f32; + + /* f64 */ + fn cbrt(x: f64) -> f64; + fn ceil(x: f64) -> f64; + fn copysign(x: f64, y: f64) -> f64; + fn fabs(x: f64) -> f64; + fn fdim(a: f64, b: f64) -> f64; + fn floor(x: f64) -> f64; + fn fma(x: f64, y: f64, z: f64) -> f64; + fn fmax(x: f64, y: f64) -> f64; + fn fmin(x: f64, y: f64) -> f64; + fn fmod(x: f64, y: f64) -> f64; + fn rint(x: f64) -> f64; + fn round(x: f64) -> f64; + fn sqrt(x: f64) -> f64; + fn trunc(x: f64) -> f64; + } + + // Windows and MacOS do not yet expose roundeven and IEEE 754-2019 `maximum` / `minimum`, + // however, so we still provide a fallback. + libm_intrinsics! { + fn fmaximum(x: f64, y: f64) -> f64; + fn fmaximum_num(x: f64, y: f64) -> f64; + fn fmaximum_numf(x: f32, y: f32) -> f32; + fn fmaximumf(x: f32, y: f32) -> f32; + fn fminimum(x: f64, y: f64) -> f64; + fn fminimum_num(x: f64, y: f64) -> f64; + fn fminimum_numf(x: f32, y: f32) -> f32; + fn fminimumf(x: f32, y: f32) -> f32; + fn roundeven(x: f64) -> f64; + fn roundevenf(x: f32) -> f32; + } + + #[cfg(f128_enabled)] + libm_intrinsics! { + fn ceilf128(x: f128) -> f128; + fn copysignf128(x: f128, y: f128) -> f128; + fn fabsf128(x: f128) -> f128; + fn fdimf128(x: f128, y: f128) -> f128; + fn floorf128(x: f128) -> f128; + fn fmaf128(x: f128, y: f128, z: f128) -> f128; + fn fmaxf128(x: f128, y: f128) -> f128; + fn fmaximum_numf128(x: f128, y: f128) -> f128; + fn fmaximumf128(x: f128, y: f128) -> f128; + fn fminf128(x: f128, y: f128) -> f128; + fn fminimum_numf128(x: f128, y: f128) -> f128; + fn fminimumf128(x: f128, y: f128) -> f128; + fn fmodf128(x: f128, y: f128) -> f128; + fn rintf128(x: f128) -> f128; + fn roundevenf128(x: f128) -> f128; + fn roundf128(x: f128) -> f128; + fn sqrtf128(x: f128) -> f128; + fn truncf128(x: f128) -> f128; + } +} + +/// This group of functions has more performance or precision issues than system versions, or +/// are otherwise less well tested. Provide them only on platforms that have problems with the +/// system `libm`. +/// +/// As `libm` improves, more functions will be moved from this group to the first group. +/// +/// Do not supply for any of the following: +/// - x86 without sse2 due to ABI issues +/// - +/// - but exclude UEFI since it is a soft-float target +/// - +/// - All unix targets (linux, macos, freebsd, android, etc) +/// - wasm with known target_os +#[cfg(not(any( + all( + target_arch = "x86", + not(target_feature = "sse2"), + not(target_os = "uefi"), + ), + unix, + all(target_family = "wasm", not(target_os = "unknown")) +)))] +pub mod partial_availability { + #[cfg(not(windows))] + libm_intrinsics! { + fn acos(x: f64) -> f64; + fn acosf(n: f32) -> f32; + fn acosh(x: f64) -> f64; + fn acoshf(x: f32) -> f32; + fn asin(x: f64) -> f64; + fn asinf(n: f32) -> f32; + fn asinh(x: f64) -> f64; + fn asinhf(x: f32) -> f32; + fn atan(x: f64) -> f64; + fn atan2(x: f64, y: f64) -> f64; + fn atan2f(a: f32, b: f32) -> f32; + fn atanf(n: f32) -> f32; + fn cos(x: f64) -> f64; + fn cosf(x: f32) -> f32; + fn cosh(x: f64) -> f64; + fn coshf(n: f32) -> f32; + fn erf(x: f64) -> f64; + fn erfc(x: f64) -> f64; + fn erfcf(x: f32) -> f32; + fn erff(x: f32) -> f32; + fn exp(x: f64) -> f64; + fn exp2(x: f64) -> f64; + fn exp2f(x: f32) -> f32; + fn expf(x: f32) -> f32; + fn expm1(x: f64) -> f64; + fn expm1f(n: f32) -> f32; + fn hypot(x: f64, y: f64) -> f64; + fn hypotf(x: f32, y: f32) -> f32; + fn ldexp(f: f64, n: i32) -> f64; + fn ldexpf(f: f32, n: i32) -> f32; + fn log(x: f64) -> f64; + fn log10(x: f64) -> f64; + fn log10f(x: f32) -> f32; + fn log1p(x: f64) -> f64; + fn log1pf(n: f32) -> f32; + fn log2(x: f64) -> f64; + fn log2f(x: f32) -> f32; + fn logf(x: f32) -> f32; + fn pow(x: f64, y: f64) -> f64; + fn powf(x: f32, y: f32) -> f32; + fn sin(x: f64) -> f64; + fn sinf(x: f32) -> f32; + fn sinh(x: f64) -> f64; + fn sinhf(n: f32) -> f32; + fn tan(x: f64) -> f64; + fn tanf(n: f32) -> f32; + fn tanh(x: f64) -> f64; + fn tanhf(n: f32) -> f32; + fn tgamma(x: f64) -> f64; + fn tgammaf(x: f32) -> f32; + } + + // allow for windows (and other targets) + intrinsics! { + pub extern "C" fn lgamma_r(x: f64, s: &mut i32) -> f64 { + let r = super::libm_math::lgamma_r(x); + *s = r.1; + r.0 + } + + pub extern "C" fn lgammaf_r(x: f32, s: &mut i32) -> f32 { + let r = super::libm_math::lgammaf_r(x); + *s = r.1; + r.0 + } + } +} diff --git a/ci/licenses/rust-compiler-originals/compiler-rt-CREDITS.TXT b/ci/licenses/rust-compiler-originals/compiler-rt-CREDITS.TXT new file mode 100644 index 0000000..6964eba --- /dev/null +++ b/ci/licenses/rust-compiler-originals/compiler-rt-CREDITS.TXT @@ -0,0 +1,36 @@ +This file is a partial list of people who have contributed to the LLVM/CompilerRT +project. If you have contributed a patch or made some other contribution to +LLVM/CompilerRT, please submit a patch to this file to add yourself, and it will be +done! + +The list is sorted by surname and formatted to allow easy grepping and +beautification by scripts. The fields are: name (N), email (E), web-address +(W), PGP key ID and fingerprint (P), description (D), and snail-mail address +(S). + +N: Craig van Vliet +E: cvanvliet@auroraux.org +W: http://www.auroraux.org +D: Code style and Readability fixes. + +N: Edward O'Callaghan +E: eocallaghan@auroraux.org +W: http://www.auroraux.org +D: CMake'ify Compiler-RT build system +D: Maintain Solaris & AuroraUX ports of Compiler-RT + +N: Howard Hinnant +E: hhinnant@apple.com +D: Architect and primary author of compiler-rt + +N: Guan-Hong Liu +E: koviankevin@hotmail.com +D: IEEE Quad-precision functions + +N: Joerg Sonnenberger +E: joerg@NetBSD.org +D: Maintains NetBSD port. + +N: Matt Thomas +E: matt@NetBSD.org +D: ARM improvements. diff --git a/ci/licenses/rust-compiler-originals/compiler-rt-LICENSE.TXT b/ci/licenses/rust-compiler-originals/compiler-rt-LICENSE.TXT new file mode 100644 index 0000000..5a79a1b --- /dev/null +++ b/ci/licenses/rust-compiler-originals/compiler-rt-LICENSE.TXT @@ -0,0 +1,311 @@ +============================================================================== +The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: +============================================================================== + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +---- LLVM Exceptions to the Apache 2.0 License ---- + +As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into an Object form of such source code, you +may redistribute such embedded portions in such Object form without complying +with the conditions of Sections 4(a), 4(b) and 4(d) of the License. + +In addition, if you combine or link compiled forms of this Software with +software that is licensed under the GPLv2 ("Combined Software") and if a +court of competent jurisdiction determines that the patent provision (Section +3), the indemnity provision (Section 9) or other Section of the License +conflicts with the conditions of the GPLv2, you may retroactively and +prospectively choose to deem waived or otherwise exclude such Section(s) of +the License, but only in their entirety and only with respect to the Combined +Software. + +============================================================================== +Software from third parties included in the LLVM Project: +============================================================================== +The LLVM Project contains third party software which is under different license +terms. All such code will be identified clearly using at least one of two +mechanisms: +1) It will be in a separate directory tree with its own `LICENSE.txt` or + `LICENSE` file at the top containing the specific license and restrictions + which apply to that software, or +2) It will contain specific license and restriction terms at the top of every + file. + +============================================================================== +Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy): +============================================================================== + +The compiler_rt library is dual licensed under both the University of Illinois +"BSD-Like" license and the MIT license. As a user of this code you may choose +to use it under either license. As a contributor, you agree to allow your code +to be used under both. + +Full text of the relevant licenses is included below. + +============================================================================== + +University of Illinois/NCSA +Open Source License + +Copyright (c) 2009-2019 by the contributors listed in CREDITS.TXT + +All rights reserved. + +Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE +SOFTWARE. + +============================================================================== + +Copyright (c) 2009-2015 by the contributors listed in CREDITS.TXT + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/ci/licenses/rust-compiler-originals/compiler-rt-aarch64-cpu-model.c.txt b/ci/licenses/rust-compiler-originals/compiler-rt-aarch64-cpu-model.c.txt new file mode 100644 index 0000000..347bb4e --- /dev/null +++ b/ci/licenses/rust-compiler-originals/compiler-rt-aarch64-cpu-model.c.txt @@ -0,0 +1,94 @@ +//===-- cpu_model/aarch64.c - Support for __cpu_model builtin ----*- C -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file is based on LLVM's lib/Support/Host.cpp. +// It implements __aarch64_have_lse_atomics, __aarch64_cpu_features for +// AArch64. +// +//===----------------------------------------------------------------------===// + +#include "aarch64.h" + +#if !defined(__aarch64__) && !defined(__arm64__) && !defined(_M_ARM64) && \ + !defined(__arm64ec__) && !defined(_M_ARM64EC) +#error This file is intended only for aarch64-based targets +#endif + +#if __has_include() +#include +#else +typedef struct __ifunc_arg_t { + unsigned long _size; + unsigned long _hwcap; + unsigned long _hwcap2; +} __ifunc_arg_t; +#endif // __has_include() + +// LSE support detection for out-of-line atomics +// using HWCAP and Auxiliary vector +_Bool __aarch64_have_lse_atomics + __attribute__((visibility("hidden"), nocommon)) = false; + +// The formatter wants to re-order these includes, but doing so is incorrect: +// clang-format off +#if defined(__FreeBSD__) || defined(__OpenBSD__) +#include +#include "aarch64/hwcap.inc" +#include "aarch64/lse_atomics/elf_aux_info.inc" +#elif defined(__Fuchsia__) +#include "aarch64/hwcap.inc" +#include "aarch64/lse_atomics/fuchsia.inc" +#elif defined(__ANDROID__) +#include +#include "aarch64/hwcap.inc" +#include "aarch64/lse_atomics/android.inc" +#elif defined(__linux__) +#include +#include "aarch64/hwcap.inc" +#include "aarch64/lse_atomics/getauxval.inc" +#elif defined(_WIN32) +#include "aarch64/lse_atomics/windows.inc" +#else +// When unimplemented, we leave __aarch64_have_lse_atomics initialized to false. +#endif +// clang-format on + +#if !defined(DISABLE_AARCH64_FMV) + +// Architecture features used +// in Function Multi Versioning +struct { + unsigned long long features; + // As features grows new fields could be added +} __aarch64_cpu_features __attribute__((visibility("hidden"), nocommon)); + +// The formatter wants to re-order these includes, but doing so is incorrect: +// clang-format off +#if defined(TARGET_BAREMETAL_AARCH64) +#include "aarch64/fmv/baremetal.inc" +#elif defined(__APPLE__) +#include "aarch64/fmv/apple.inc" +#elif defined(__FreeBSD__) || defined(__OpenBSD__) +#include "aarch64/fmv/hwcap.inc" +#include "aarch64/fmv/elf_aux_info.inc" +#elif defined(__Fuchsia__) +#include "aarch64/fmv/fuchsia.inc" +#elif defined(__ANDROID__) +#include "aarch64/fmv/hwcap.inc" +#include "aarch64/fmv/android.inc" +#elif defined(__linux__) +#include "aarch64/fmv/hwcap.inc" +#include "aarch64/fmv/getauxval.inc" +#elif defined(_WIN32) +#include "aarch64/fmv/windows.inc" +#else +#include "aarch64/fmv/unimplemented.inc" +#endif +// clang-format on + +#endif // !defined(DISABLE_AARCH64_FMV) diff --git a/ci/licenses/rust-compiler-originals/compiler-rt-aarch64-lse.S.txt b/ci/licenses/rust-compiler-originals/compiler-rt-aarch64-lse.S.txt new file mode 100644 index 0000000..a444d82 --- /dev/null +++ b/ci/licenses/rust-compiler-originals/compiler-rt-aarch64-lse.S.txt @@ -0,0 +1,270 @@ +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "assembly.h" + +// Out-of-line LSE atomics helpers. Ported from libgcc library. +// N = {1, 2, 4, 8} +// M = {1, 2, 4, 8, 16} +// ORDER = {'relax', 'acq', 'rel', 'acq_rel', 'sync'} +// Routines implemented: +// +// iM __aarch64_casM_ORDER(iM expected, iM desired, iM *ptr) +// iN __aarch64_swpN_ORDER(iN val, iN *ptr) +// iN __aarch64_ldaddN_ORDER(iN val, iN *ptr) +// iN __aarch64_ldclrN_ORDER(iN val, iN *ptr) +// iN __aarch64_ldeorN_ORDER(iN val, iN *ptr) +// iN __aarch64_ldsetN_ORDER(iN val, iN *ptr) +// +// Routines may modify temporary registers tmp0, tmp1, tmp2, +// return value x0 and the flags only. + +#if defined(__aarch64__) || defined(__arm64ec__) + +#ifdef HAS_ASM_LSE +.arch armv8-a+lse +#else +.arch armv8-a +#endif + +#if !defined(__APPLE__) +HIDDEN(__aarch64_have_lse_atomics) +#else +HIDDEN(___aarch64_have_lse_atomics) +#endif + +// Generate mnemonics for +// L_cas: SIZE: 1,2,4,8,16 MODEL: 1,2,3,4,5 +// L_swp L_ldadd L_ldclr L_ldeor L_ldset: SIZE: 1,2,4,8 MODEL: 1,2,3,4,5 + +#if SIZE == 1 +#define S b +#define UXT uxtb +#define B 0x00000000 +#elif SIZE == 2 +#define S h +#define UXT uxth +#define B 0x40000000 +#elif SIZE == 4 || SIZE == 8 || SIZE == 16 +#define S +#define UXT mov +#if SIZE == 4 +#define B 0x80000000 +#elif SIZE == 8 +#define B 0xc0000000 +#endif +#else +#error +#endif // SIZE + +#if MODEL == 1 +#define SUFF _relax +#define A +#define L +#define M 0x000000 +#define N 0x000000 +#define BARRIER +#elif MODEL == 2 +#define SUFF _acq +#define A a +#define L +#define M 0x400000 +#define N 0x800000 +#define BARRIER +#elif MODEL == 3 +#define SUFF _rel +#define A +#define L l +#define M 0x008000 +#define N 0x400000 +#define BARRIER +#elif MODEL == 4 +#define SUFF _acq_rel +#define A a +#define L l +#define M 0x408000 +#define N 0xc00000 +#define BARRIER +#elif MODEL == 5 +#define SUFF _sync +#ifdef L_swp +// swp has _acq semantics. +#define A a +#define L +#define M 0x400000 +#define N 0x800000 +#else +// All other _sync functions have _seq semantics. +#define A a +#define L l +#define M 0x408000 +#define N 0xc00000 +#endif +#define BARRIER dmb ish +#else +#error +#endif // MODEL + +// Define register size. +#define x(N) GLUE2(x, N) +#define w(N) GLUE2(w, N) +#if SIZE < 8 +#define s(N) w(N) +#else +#define s(N) x(N) +#endif + +#define NAME(BASE) GLUE4(__aarch64_, BASE, SIZE, SUFF) +#if MODEL == 5 +// Drop A for _sync functions. +#define LDXR GLUE3(ld, xr, S) +#else +#define LDXR GLUE4(ld, A, xr, S) +#endif +#define STXR GLUE4(st, L, xr, S) + +// Define temporary registers. +#define tmp0 16 +#define tmp1 17 +#define tmp2 15 + +// Macro for branch to label if no LSE available +.macro JUMP_IF_NOT_LSE label +#if !defined(__APPLE__) + adrp x(tmp0), __aarch64_have_lse_atomics + ldrb w(tmp0), [x(tmp0), :lo12:__aarch64_have_lse_atomics] +#else + adrp x(tmp0), ___aarch64_have_lse_atomics@page + ldrb w(tmp0), [x(tmp0), ___aarch64_have_lse_atomics@pageoff] +#endif + cbz w(tmp0), \label +.endm + +#ifdef L_cas +DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(cas)) + JUMP_IF_NOT_LSE 8f +#if SIZE < 16 +#ifdef HAS_ASM_LSE +#define CAS GLUE4(cas, A, L, S) s(0), s(1), [x2] +#else +#define CAS .inst 0x08a07c41 + B + M +#endif + CAS // s(0), s(1), [x2] + ret +8: + UXT s(tmp0), s(0) +0: + LDXR s(0), [x2] + cmp s(0), s(tmp0) + bne 1f + STXR w(tmp1), s(1), [x2] + cbnz w(tmp1), 0b +1: + BARRIER + ret +#else +#if MODEL == 5 +// Drop A for _sync functions. +#define LDXP GLUE2(ld, xp) +#else +#define LDXP GLUE3(ld, A, xp) +#endif +#define STXP GLUE3(st, L, xp) +#ifdef HAS_ASM_LSE +#define CASP GLUE3(casp, A, L) x0, x1, x2, x3, [x4] +#else +#define CASP .inst 0x48207c82 + M +#endif + + CASP // x0, x1, x2, x3, [x4] + ret +8: + mov x(tmp0), x0 + mov x(tmp1), x1 +0: + LDXP x0, x1, [x4] + cmp x0, x(tmp0) + ccmp x1, x(tmp1), #0, eq + bne 1f + STXP w(tmp2), x2, x3, [x4] + cbnz w(tmp2), 0b +1: + BARRIER + ret +#endif +END_COMPILERRT_OUTLINE_FUNCTION(NAME(cas)) +#endif // L_cas + +#ifdef L_swp +#ifdef HAS_ASM_LSE +#define SWP GLUE4(swp, A, L, S) s(0), s(0), [x1] +#else +#define SWP .inst 0x38208020 + B + N +#endif +DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(swp)) + JUMP_IF_NOT_LSE 8f + SWP // s(0), s(0), [x1] + ret +8: + mov s(tmp0), s(0) +0: + LDXR s(0), [x1] + STXR w(tmp1), s(tmp0), [x1] + cbnz w(tmp1), 0b + BARRIER + ret +END_COMPILERRT_OUTLINE_FUNCTION(NAME(swp)) +#endif // L_swp + +#if defined(L_ldadd) || defined(L_ldclr) || \ + defined(L_ldeor) || defined(L_ldset) + +#ifdef L_ldadd +#define LDNM ldadd +#define OP add +#define OPN 0x0000 +#elif defined(L_ldclr) +#define LDNM ldclr +#define OP bic +#define OPN 0x1000 +#elif defined(L_ldeor) +#define LDNM ldeor +#define OP eor +#define OPN 0x2000 +#elif defined(L_ldset) +#define LDNM ldset +#define OP orr +#define OPN 0x3000 +#else +#error +#endif + +#ifdef HAS_ASM_LSE +#define LDOP GLUE4(LDNM, A, L, S) s(0), s(0), [x1] +#else +#define LDOP .inst 0x38200020 + OPN + B + N +#endif + +DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(LDNM)) + JUMP_IF_NOT_LSE 8f + LDOP // s(0), s(0), [x1] + ret +8: + mov s(tmp0), s(0) +0: + LDXR s(0), [x1] + OP s(tmp1), s(0), s(tmp0) + STXR w(tmp2), s(tmp1), [x1] + cbnz w(tmp2), 0b + BARRIER + ret +END_COMPILERRT_OUTLINE_FUNCTION(NAME(LDNM)) +#endif // L_ldadd L_ldclr L_ldeor L_ldset + +NO_EXEC_STACK_DIRECTIVE + +// GNU property note for BTI, PAC, and GCS +GNU_PROPERTY_BTI_PAC_GCS + +#endif // defined(__aarch64__) || defined(__arm64ec__) diff --git a/ci/licenses/rust-compiler-originals/libm-LICENSE.txt b/ci/licenses/rust-compiler-originals/libm-LICENSE.txt new file mode 100644 index 0000000..2f8e41f --- /dev/null +++ b/ci/licenses/rust-compiler-originals/libm-LICENSE.txt @@ -0,0 +1,258 @@ +rust-lang/libm as a whole is available for use under the MIT license: + +------------------------------------------------------------------------------ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ + +As a contributor, you agree that your code can be used under either the MIT +license or the Apache-2.0 license: + +------------------------------------------------------------------------------ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + 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. +------------------------------------------------------------------------------ + +This Rust library contains the following copyrights: + + Copyright (c) 2018 Jorge Aparicio + +Portions of this software are derived from third-party works licensed under +terms compatible with the above MIT license: + +* musl libc https://www.musl-libc.org/. This library contains the following + copyright: + + Copyright © 2005-2020 Rich Felker, et al. + +* The CORE-MATH project https://core-math.gitlabpages.inria.fr/. CORE-MATH + routines are available under the MIT license on a per-file basis. + +The musl libc COPYRIGHT file also includes the following notice relevant to +math portions of the library: + +------------------------------------------------------------------------------ +Much of the math library code (src/math/* and src/complex/*) is +Copyright © 1993,2004 Sun Microsystems or +Copyright © 2003-2011 David Schultz or +Copyright © 2003-2009 Steven G. Kargl or +Copyright © 2003-2009 Bruce D. Evans or +Copyright © 2008 Stephen L. Moshier or +Copyright © 2017-2018 Arm Limited +and labelled as such in comments in the individual source files. All +have been licensed under extremely permissive terms. +------------------------------------------------------------------------------ + +Copyright notices are retained in src/* files where relevant. diff --git a/ci/licenses/rust-compiler-originals/libm-generic-trunc.rs.txt b/ci/licenses/rust-compiler-originals/libm-generic-trunc.rs.txt new file mode 100644 index 0000000..0b252fa --- /dev/null +++ b/ci/licenses/rust-compiler-originals/libm-generic-trunc.rs.txt @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: MIT + * origin: musl src/math/trunc.c */ + +use crate::support::{Float, FpResult, Int, IntTy, MinInt, Status}; + +#[inline] +pub fn trunc_status(x: F) -> FpResult { + let xi: F::Int = x.to_bits(); + let e: i32 = x.exp_unbiased(); + + // The represented value has no fractional part, so no truncation is needed + if e >= F::SIG_BITS as i32 { + return FpResult::ok(x); + } + + let clear_mask = if e < 0 { + // If the exponent is negative, the result will be zero so we clear everything + // except the sign. + !F::SIGN_MASK + } else { + // Otherwise, we keep `e` fractional bits and clear the rest. + F::SIG_MASK >> e.unsigned() + }; + + let cleared = xi & clear_mask; + let status = if cleared == IntTy::::ZERO { + // If the to-be-zeroed portion is already zero, we have an exact result. + Status::OK + } else { + // Otherwise the result is inexact and we will truncate, so indicate `FE_INEXACT`. + Status::INEXACT + }; + + // Now zero the bits we need to truncate and return. + FpResult::new(F::from_bits(xi ^ cleared), status) +} diff --git a/ci/licenses/rust-compiler-originals/libm-trunc.rs.txt b/ci/licenses/rust-compiler-originals/libm-trunc.rs.txt new file mode 100644 index 0000000..9eb902e --- /dev/null +++ b/ci/licenses/rust-compiler-originals/libm-trunc.rs.txt @@ -0,0 +1,147 @@ +use super::generic; + +/// Rounds the number toward 0 to the closest integral value (f16). +/// +/// This effectively removes the decimal part of the number, leaving the integral part. +#[cfg(f16_enabled)] +#[cfg_attr(assert_no_panic, no_panic::no_panic)] +pub fn truncf16(x: f16) -> f16 { + generic::trunc_status(x).val +} + +/// Rounds the number toward 0 to the closest integral value (f32). +/// +/// This effectively removes the decimal part of the number, leaving the integral part. +#[cfg_attr(assert_no_panic, no_panic::no_panic)] +pub fn truncf(x: f32) -> f32 { + select_implementation! { + name: truncf, + use_arch: all(target_arch = "wasm32", intrinsics_enabled), + args: x, + } + + generic::trunc_status(x).val +} + +/// Rounds the number toward 0 to the closest integral value (f64). +/// +/// This effectively removes the decimal part of the number, leaving the integral part. +#[cfg_attr(assert_no_panic, no_panic::no_panic)] +pub fn trunc(x: f64) -> f64 { + select_implementation! { + name: trunc, + use_arch: all(target_arch = "wasm32", intrinsics_enabled), + args: x, + } + + generic::trunc_status(x).val +} + +/// Rounds the number toward 0 to the closest integral value (f128). +/// +/// This effectively removes the decimal part of the number, leaving the integral part. +#[cfg(f128_enabled)] +#[cfg_attr(assert_no_panic, no_panic::no_panic)] +pub fn truncf128(x: f128) -> f128 { + generic::trunc_status(x).val +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::support::{Float, FpResult, Hex, Status}; + + macro_rules! cases { + ($f:ty) => { + [ + // roundtrip + (0.0, 0.0, Status::OK), + (-0.0, -0.0, Status::OK), + (1.0, 1.0, Status::OK), + (-1.0, -1.0, Status::OK), + (<$f>::INFINITY, <$f>::INFINITY, Status::OK), + (<$f>::NEG_INFINITY, <$f>::NEG_INFINITY, Status::OK), + // with rounding + (0.1, 0.0, Status::INEXACT), + (-0.1, -0.0, Status::INEXACT), + (0.5, 0.0, Status::INEXACT), + (-0.5, -0.0, Status::INEXACT), + (0.9, 0.0, Status::INEXACT), + (-0.9, -0.0, Status::INEXACT), + (1.1, 1.0, Status::INEXACT), + (-1.1, -1.0, Status::INEXACT), + (1.5, 1.0, Status::INEXACT), + (-1.5, -1.0, Status::INEXACT), + (1.9, 1.0, Status::INEXACT), + (-1.9, -1.0, Status::INEXACT), + ] + }; + } + + #[track_caller] + fn check(f: fn(F) -> F, cases: &[(F, F, Status)]) { + for &(x, exp_res, exp_stat) in cases { + let FpResult { val, status } = generic::trunc_status(x); + assert_biteq!(val, exp_res, "generic::trunc_status({x:?}) ({})", Hex(x)); + assert_eq!( + status, + exp_stat, + "{x:?} {} -> {exp_res:?} {}", + Hex(x), + Hex(exp_res) + ); + let val = f(x); + assert_biteq!(val, exp_res, "trunc({x:?}) ({})", Hex(x)); + } + } + + #[test] + #[cfg(f16_enabled)] + fn check_f16() { + check::(truncf16, &cases!(f16)); + check::( + truncf16, + &[ + (hf16!("0x1p10"), hf16!("0x1p10"), Status::OK), + (hf16!("-0x1p10"), hf16!("-0x1p10"), Status::OK), + ], + ); + } + + #[test] + fn check_f32() { + check::(truncf, &cases!(f32)); + check::( + truncf, + &[ + (hf32!("0x1p23"), hf32!("0x1p23"), Status::OK), + (hf32!("-0x1p23"), hf32!("-0x1p23"), Status::OK), + ], + ); + } + + #[test] + fn check_f64() { + check::(trunc, &cases!(f64)); + check::( + trunc, + &[ + (hf64!("0x1p52"), hf64!("0x1p52"), Status::OK), + (hf64!("-0x1p52"), hf64!("-0x1p52"), Status::OK), + ], + ); + } + + #[test] + #[cfg(f128_enabled)] + fn check_f128() { + check::(truncf128, &cases!(f128)); + check::( + truncf128, + &[ + (hf128!("0x1p112"), hf128!("0x1p112"), Status::OK), + (hf128!("-0x1p112"), hf128!("-0x1p112"), Status::OK), + ], + ); + } +} diff --git a/ci/rust-compiler-notices.json b/ci/rust-compiler-notices.json new file mode 100644 index 0000000..7cdc2d0 --- /dev/null +++ b/ci/rust-compiler-notices.json @@ -0,0 +1,163 @@ +{ + "coverage": "Complete original Rust compiler-builtins, LLVM compiler-rt and libm grants and a conservative source witness collection for the pinned compiler. Not a retained-code inventory, all-target input proof or change to the first-party MIT OR Apache-2.0 license.", + "llvm_revision": "1b9c0d5ff9bbe7634aead059efe6b11a7eeba145", + "materials": [ + { + "bytes": 15078, + "git_blob": "00ae6140bd54e1b538d833f60438e11ed8be12cf", + "legal_document": true, + "path": "ci/licenses/rust-compiler-originals/compiler-builtins-LICENSE.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "compiler-builtins-LICENSE.txt", + "sha256": "ab6eec6caf0fa5775e411c7a8bc6a45c4ef2956b0980b157ab74fc5cd62a928b", + "upstream_path": "library/compiler-builtins/LICENSE.txt" + }, + { + "bytes": 2005, + "git_blob": "b2f1443f2eb09d297b62c7b44fce9e31d71b10a2", + "legal_document": false, + "path": "ci/licenses/rust-compiler-originals/compiler-builtins-Cargo.toml.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "compiler-builtins-Cargo.toml.txt", + "sha256": "d89e31fed70f2cad9c6e91b787bf4c0fb680c631196b2a7215c81745aaf7fb7e", + "upstream_path": "library/compiler-builtins/compiler-builtins/Cargo.toml" + }, + { + "bytes": 27313, + "git_blob": "e86c784b5c6317a53e9ff89104b15e60ba7ac4bf", + "legal_document": false, + "path": "ci/licenses/rust-compiler-originals/compiler-builtins-build.rs.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "compiler-builtins-build.rs.txt", + "sha256": "dd1d07d0852fd6a654c69d6dafd8ae66744853cb5678610008dbf6ae6baec11e", + "upstream_path": "library/compiler-builtins/compiler-builtins/build.rs" + }, + { + "bytes": 463, + "git_blob": "2c12cb7f3095b2ace3938a666ebd1b607b8a269c", + "legal_document": false, + "path": "ci/licenses/rust-compiler-originals/compiler-builtins-aarch64.rs.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "compiler-builtins-aarch64.rs.txt", + "sha256": "5acb367779a8e6e6e06e188e715d6d2ff76b9c3208acd899e139957bd1d3c877", + "upstream_path": "library/compiler-builtins/compiler-builtins/src/aarch64.rs" + }, + { + "bytes": 16463, + "git_blob": "367768ecb60d65069679b3c84a9ef932c5ab6962", + "legal_document": false, + "path": "ci/licenses/rust-compiler-originals/compiler-builtins-aarch64-outline-atomics.rs.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "compiler-builtins-aarch64-outline-atomics.rs.txt", + "sha256": "d2e6ed0066ac36db55dfaa245bdc814353456dda92437aba539cc828d2011ae9", + "upstream_path": "library/compiler-builtins/compiler-builtins/src/aarch64_outline_atomics.rs" + }, + { + "bytes": 5851, + "git_blob": "a444d82892c36f8c1e3ba5f1977638d56fb929f8", + "legal_document": false, + "path": "ci/licenses/rust-compiler-originals/compiler-rt-aarch64-lse.S.txt", + "repository": "rust-lang/llvm-project", + "revision": "1b9c0d5ff9bbe7634aead059efe6b11a7eeba145", + "role": "compiler-rt-aarch64-lse.S.txt", + "sha256": "dcd05cb984ef8d777642eb960e3ef61b1140f268c3e4744f8f738aa46fd8ed66", + "upstream_path": "compiler-rt/lib/builtins/aarch64/lse.S" + }, + { + "bytes": 3026, + "git_blob": "347bb4e121c97c98aa6e7440b1c952978bfedc9b", + "legal_document": false, + "path": "ci/licenses/rust-compiler-originals/compiler-rt-aarch64-cpu-model.c.txt", + "repository": "rust-lang/llvm-project", + "revision": "1b9c0d5ff9bbe7634aead059efe6b11a7eeba145", + "role": "compiler-rt-aarch64-cpu-model.c.txt", + "sha256": "405b2ad2520db341af1338be2e58cce9d28a9f63006486d1c9572f4fe10ae032", + "upstream_path": "compiler-rt/lib/builtins/cpu_model/aarch64.c" + }, + { + "bytes": 16708, + "git_blob": "5a79a1b9d5cb0af9a779751f07033e44ca3b14d8", + "legal_document": true, + "path": "ci/licenses/rust-compiler-originals/compiler-rt-LICENSE.TXT", + "repository": "rust-lang/llvm-project", + "revision": "1b9c0d5ff9bbe7634aead059efe6b11a7eeba145", + "role": "compiler-rt-LICENSE.TXT", + "sha256": "1a8f1058753f1ba890de984e48f0242a3a5c29a6a8f2ed9fd813f36985387e8d", + "upstream_path": "compiler-rt/LICENSE.TXT" + }, + { + "bytes": 1049, + "git_blob": "6964eba020b8aa7a08629b249e3b9aea3ce3e448", + "legal_document": true, + "path": "ci/licenses/rust-compiler-originals/compiler-rt-CREDITS.TXT", + "repository": "rust-lang/llvm-project", + "revision": "1b9c0d5ff9bbe7634aead059efe6b11a7eeba145", + "role": "compiler-rt-CREDITS.TXT", + "sha256": "a9901f47a089da41e4690682d00ce4cedaa2baf41fedbe79beee366d43ac2461", + "upstream_path": "compiler-rt/CREDITS.TXT" + }, + { + "bytes": 7270, + "git_blob": "3dfa3863bb77007fbec01b7c931bf1c349953d11", + "legal_document": false, + "path": "ci/licenses/rust-compiler-originals/compiler-builtins-math-mod.rs.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "compiler-builtins-math-mod.rs.txt", + "sha256": "a3ff615e04d9ae9a0bb36cfbfd9a0aaf183ab6e32ddfe836cdf4f243f97a401e", + "upstream_path": "library/compiler-builtins/compiler-builtins/src/math/mod.rs" + }, + { + "bytes": 4407, + "git_blob": "9eb902ea578f87588d8236619a67ab7db72c8ba8", + "legal_document": false, + "path": "ci/licenses/rust-compiler-originals/libm-trunc.rs.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "libm-trunc.rs.txt", + "sha256": "ef59952a1a80ec93be27eb78c977189084ff7fcae0e8f782d60b5947e1de141c", + "upstream_path": "library/compiler-builtins/libm/src/math/trunc.rs" + }, + { + "bytes": 14088, + "git_blob": "2f8e41f147472510b05e0adeadf350df6f5a6b96", + "legal_document": true, + "path": "ci/licenses/rust-compiler-originals/libm-LICENSE.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "libm-LICENSE.txt", + "sha256": "3823dda7cf046602f4b4e77ec8e227863dc4736037cc85bb33d9f19febe16bb7", + "upstream_path": "library/compiler-builtins/libm/LICENSE.txt" + }, + { + "bytes": 1152, + "git_blob": "0b252fab94ae1d54aac4df8d5ab6f7a2e919bd32", + "legal_document": false, + "path": "ci/licenses/rust-compiler-originals/libm-generic-trunc.rs.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "libm-generic-trunc.rs.txt", + "sha256": "3a3ca091cd1d750276601dc2dfeb2a8ff058636ea2b66a748c55a1804bc8f00a", + "upstream_path": "library/compiler-builtins/libm/src/math/generic/trunc.rs" + }, + { + "bytes": 16862, + "git_blob": "6193aa416e22249ed25e856aa03dda2f5a585b62", + "legal_document": false, + "path": "ci/licenses/rust-compiler-originals/compiler-builtins-float-conv.rs.txt", + "repository": "rust-lang/rust", + "revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "role": "compiler-builtins-float-conv.rs.txt", + "sha256": "740286ec154ddd78a9a8e5e6b8fad2c564585d1a76051cd6ee429c313d660070", + "upstream_path": "library/compiler-builtins/compiler-builtins/src/float/conv.rs" + } + ], + "rust_revision": "58cf8f9c35b355199727627d07ae34a4e2846d67", + "rust_version": "1.99.1", + "schema_version": 1 +} diff --git a/ci/test_napi_gnullvm_notices.py b/ci/test_napi_gnullvm_notices.py new file mode 100644 index 0000000..86ffdd6 --- /dev/null +++ b/ci/test_napi_gnullvm_notices.py @@ -0,0 +1,145 @@ +"""Проверить source/grant/input boundaries licensed GNU NAPI variant без toolchain.""" + +import copy +import hashlib +import io +import json +from pathlib import Path +import sys +import tempfile +import tarfile +import tomllib +import unittest + +ROOT = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(ROOT / 'scripts')) +import napi_gnullvm_notices as RUNTIME +from prepare_gnu_napi_variant_notices import configure, resource_hook +from stage_gnu_napi_variant import fingerprints + + +class NapiRuntimeTests(unittest.TestCase): + def fixture(self, target='x86_64-pc-windows-gnullvm'): + document = RUNTIME.catalogue(ROOT) + selected = document['targets'][target] + inputs = [{'path': 'repro/llvm-mingw-20261020-ucrt-x86_64/' + item['path'], 'bytes': item['size'], 'sha256': item['sha256']} for item in selected['sdk_inputs']] + mapping = '\n'.join('00001000 00000004 4 ' + name + ':(.text)' for name in selected['retained_objects']).encode() + return document, inputs, mapping, target + + def test_both_exact_target_input_policies(self): + for target in ['x86_64-pc-windows-gnullvm', 'aarch64-pc-windows-gnullvm']: + document, inputs, mapping, target = self.fixture(target) + RUNTIME.verify_inputs(inputs, mapping, document, target) + self.assertEqual(len(document['targets'][target]['retained_objects']), 29 if target.startswith('x86_64') else 22) + + def test_complete_new_original_license_is_retained(self): + document = RUNTIME.catalogue(ROOT) + self.assertEqual(len(document['source_files']), 61) + self.assertEqual(len(document['original_documents']), 7) + text = RUNTIME.plain_notice(document) + self.assertIn(b'Copyright (c) 2020-present LongYinan', text) + self.assertIn(b'Copyright (c) 2018 GitHub', text) + for item in document['original_documents']: + self.assertIn(item['text'].encode(), text) + sources = [item for item in document['source_files'] if item['path'].endswith('crtdll_atexit_register.c')] + self.assertEqual(len(sources), 1) + self.assertIn('Public Domain', sources[0]['source_notices'][0]) + + def test_unknown_or_missing_retained_object_is_rejected(self): + for extra in [True, False]: + document, inputs, mapping, target = self.fixture() + if extra: + mapping += b'\n00001000 00000004 4 foreign.o:(.text)' + else: + mapping = b'\n'.join(mapping.splitlines()[1:]) + with self.assertRaisesRegex(ValueError, 'SDK bytes or retained objects differ'): + RUNTIME.verify_inputs(inputs, mapping, document, target) + + def test_changed_sdk_archive_or_size_is_rejected(self): + for key in ['bytes', 'sha256']: + document, inputs, mapping, target = self.fixture() + inputs[0][key] = 0 if key == 'bytes' else '0' * 64 + with self.assertRaisesRegex(ValueError, 'SDK bytes or retained objects differ'): + RUNTIME.verify_inputs(inputs, mapping, document, target) + + def test_unknown_native_input_is_rejected(self): + document, inputs, mapping, target = self.fixture() + inputs.append({'path': 'foreign/foreign.lib', 'bytes': 1, 'sha256': '0' * 64}) + with self.assertRaisesRegex(ValueError, 'outside reviewed SDK/Rust boundary'): + RUNTIME.verify_inputs(inputs, mapping, document, target) + + def test_changed_catalogue_is_rejected(self): + with tempfile.TemporaryDirectory() as temporary: + root = Path(temporary) + path = root / RUNTIME.CATALOG + path.parent.mkdir(parents=True) + path.write_text('{}') + with self.assertRaisesRegex(ValueError, 'unreviewed'): + RUNTIME.catalogue(root) + + def test_source_fetch_allowlist_is_exact(self): + for url in ['https://foreign.invalid/LICENSE', 'https://raw.githubusercontent.com/napi-rs/napi-rs/main/LICENSE']: + with self.assertRaisesRegex(ValueError, 'unreviewed'): + RUNTIME.original(url) + + def test_augment_preserves_original_cargo_compiler_and_variant_roles(self): + document = RUNTIME.catalogue(ROOT) + before = {'schema_version': 1, 'coverage': 'fixture', 'packages': ['original'], 'rust_compiler_builtins': {'materials': ['unchanged']}, 'source_variant': {'source_ref': 'unchanged'}} + result = RUNTIME.augment(copy.deepcopy(before), document, 'x86_64-pc-windows-gnullvm') + self.assertEqual({key: value for key, value in result.items() if key not in {'coverage', 'non_cargo_runtimes'}}, {key: value for key, value in before.items() if key != 'coverage'}) + with self.assertRaisesRegex(ValueError, 'preparation state'): + RUNTIME.augment(result, document, 'x86_64-pc-windows-gnullvm') + + def test_explicit_local_patch_preserves_original_cargo_config(self): + source = (ROOT / 'ci/fixtures/windows-gnu-napi/project-config.toml.txt').read_bytes() + patched = configure(source, Path('vendor/napi').resolve()) + parsed = tomllib.loads(patched.decode()) + self.assertEqual(parsed.pop('patch'), {'crates-io': {'napi': {'path': Path('vendor/napi').resolve().as_posix()}}}) + self.assertEqual(parsed, tomllib.loads(source.decode())) + with self.assertRaisesRegex(ValueError, 'Cargo config'): + configure(patched, Path('vendor/napi').resolve()) + + def test_resource_overlay_keeps_encoder_and_only_guards_setup(self): + source = (ROOT / 'ci/fixtures/windows-gnu-napi/resource-build.rs.txt').read_bytes() + patched = resource_hook(source) + self.assertIn(b'CARGO_CFG_TARGET_ENV', patched) + self.assertIn(b'KTAV-NOTICES-GZIP-v1', patched) + self.assertEqual(patched.count(b'napi_build::setup();'), 1) + with self.assertRaisesRegex(ValueError, 'resource template'): + resource_hook(source + b'changed') + + def test_linker_fingerprints_preserve_actual_bytes(self): + with tempfile.TemporaryDirectory() as temporary: + path = Path(temporary) / 'link.tar' + with tarfile.open(path, 'w:') as archive: + item = tarfile.TarInfo('repro/response.txt') + item.size = 3 + archive.addfile(item, io.BytesIO(b'abc')) + self.assertEqual(fingerprints(path), [{'path': 'repro/response.txt', 'bytes': 3, 'sha256': hashlib.sha256(b'abc').hexdigest()}]) + + def test_unsafe_or_duplicate_linker_members_are_rejected(self): + for name in ['../response.txt', '/response.txt', 'C:/response.txt', 'repro\\response.txt', 'repro/response.txt']: + with self.subTest(name=name), tempfile.TemporaryDirectory() as temporary: + path = Path(temporary) / 'link.tar' + with tarfile.open(path, 'w:') as archive: + archive.addfile(tarfile.TarInfo('repro/response.txt'), io.BytesIO(b'')) + archive.addfile(tarfile.TarInfo(name), io.BytesIO(b'')) + with self.assertRaisesRegex(ValueError, 'unsafe or duplicate'): + fingerprints(path) + + def test_linker_symlink_and_missing_response_are_rejected(self): + for symlink in [True, False]: + with tempfile.TemporaryDirectory() as temporary: + path = Path(temporary) / 'link.tar' + with tarfile.open(path, 'w:') as archive: + item = tarfile.TarInfo('repro/object.o') + if symlink: + item.type = tarfile.SYMTYPE + item.linkname = 'foreign' + archive.addfile(item, io.BytesIO(b'')) + with self.assertRaisesRegex(ValueError, 'type/size|response missing'): + fingerprints(path) + + +if __name__ == '__main__': + unittest.main() diff --git a/scripts/napi_gnullvm_notices.py b/scripts/napi_gnullvm_notices.py new file mode 100644 index 0000000..85da2f4 --- /dev/null +++ b/scripts/napi_gnullvm_notices.py @@ -0,0 +1,213 @@ +"""Подготовить и проверить GNU NAPI-specific GNU/LLVM runtime notices.""" + +import gzip +import hashlib +import importlib.util +import json +from pathlib import Path, PurePosixPath +import re +import sys +import urllib.error +import urllib.request + +CATALOG = 'ci/licenses/napi-gnullvm-runtime.json' +CATALOG_SHA = 'f1642eb589e5481d017f5d05178e593249efd94e9eb8de8b85f203adc057a85d' +SDK_SHA = 'fd5462b7f5d93b2ff981fcd3f9c7e427e47f3203c64ea91c27bcc444eebd74cd' +REVISIONS = {'mingw-w64/mingw-w64': '0d6dfbc348dfad714761c0a7151615767f96bcb5', 'llvm/llvm-project': '7a941dfb2877a0b8cf30323fefa85ad019e0b0f5', 'napi-rs/napi-rs': 'd9cb526c15e63ba30e06b4d169068c9854180595'} +DATA_ONLY = {'mingw-w64-crt/crt/cinitexe.c', 'mingw-w64-crt/misc/mingw_matherr.c', 'mingw-w64-crt/misc/dllmain.c'} +MAX_FILE = 4 * 1024 * 1024 +MAX_TOTAL = 64 * 1024 * 1024 + + +def read(path, limit): + if path.is_symlink() or not path.is_file(): + raise ValueError('missing or symlinked GNU NAPI runtime input') + with path.open('rb') as source: + raw = source.read(limit + 1) + if len(raw) > limit: + raise ValueError('GNU NAPI runtime input exceeds bound') + return raw + + +def catalogue(root): + raw = read(root / CATALOG, MAX_FILE) + if hashlib.sha256(raw).hexdigest() != CATALOG_SHA: + raise ValueError('unreviewed GNU NAPI runtime catalogue') + document = json.loads(raw) + if document['sdk_archive_sha256'] != SDK_SHA or len(document['source_files']) != 61 or len(document['original_documents']) != 7: + raise ValueError('GNU NAPI runtime catalogue roles differ') + return document + + +def source_file_path(evidence, item): + relative = PurePosixPath(item['path']) + if relative.is_absolute() or '..' in relative.parts or '\\' in item['path']: + raise ValueError('unsafe original source path') + matches = [repo.split('/')[-1] for repo, revision in REVISIONS.items() if item['source'].startswith('https://raw.githubusercontent.com/' + repo + '/' + revision + '/')] + if len(matches) != 1: + raise ValueError('unreviewed GNU NAPI source repository') + return evidence / 'runtime-originals' / matches[0] / item['path'] + + +def original(url): + if not any(url.startswith('https://raw.githubusercontent.com/' + repo + '/' + revision + '/') for repo, revision in REVISIONS.items()): + raise ValueError('unreviewed GNU NAPI runtime source URL') + for attempt in range(3): + try: + with urllib.request.urlopen(url, timeout=90) as response: + raw = response.read(MAX_FILE + 1) + break + except urllib.error.HTTPError as error: + if error.code not in {500, 502, 503, 504} or attempt == 2: + raise + except (TimeoutError, urllib.error.URLError): + if attempt == 2: + raise + if len(raw) > MAX_FILE: + raise ValueError('GNU NAPI original source exceeds bound') + return raw + + +def verify_sources(document, fetch=original, evidence=None): + seen = set() + total = 0 + for item in [*document['source_files'], *document['original_documents']]: + if item['source'] in seen: + raise ValueError('duplicate GNU NAPI original source') + seen.add(item['source']) + raw = fetch(item['source']) + total += len(raw) + blob = hashlib.sha1(b'blob ' + str(len(raw)).encode() + b'\0' + raw).hexdigest() + if len(raw) > MAX_FILE or total > MAX_TOTAL or hashlib.sha256(raw).hexdigest() != item['sha256'] or item.get('git_blob', blob) != blob: + raise ValueError('GNU NAPI source/grant bytes differ') + if 'text' in item: + if item['text'].encode('utf-8') != raw: + raise ValueError('GNU NAPI legal document differs') + else: + comments = re.findall(r'/\*.*?\*/|(?:^[ \t]*//[^\n]*(?:\n|$))+', raw.decode('utf-8'), re.M | re.S) + notices = [value for value in comments if re.search(r'copyright|licens|public domain|permission|redistribution', value, re.I)] + if item['source_notices'] != notices or not notices and item['path'] not in DATA_ONLY: + raise ValueError('GNU NAPI file-level original notice differs') + if evidence is not None: + path = source_file_path(evidence, item) + path.parent.mkdir(parents=True, exist_ok=True) + path.write_bytes(raw) + + +def augment(bundle, document, target): + if target not in document['targets'] or bundle.get('schema_version') != 1 or 'non_cargo_runtimes' in bundle: + raise ValueError('unexpected GNU NAPI runtime preparation state') + runtime = {'name': 'LLVM-MinGW DLL startup, MinGW runtime and LLVM libunwind', 'target': target, 'catalog_sha256': CATALOG_SHA, 'sdk_archive_sha256': SDK_SHA, 'sdk_recipe_revision': document['sdk_recipe_revision'], 'mingw_revision': document['mingw_revision'], 'llvm_revision': document['llvm_revision'], 'selected_inputs': document['targets'][target], 'source_files': document['source_files'], 'original_documents': document['original_documents'], 'coverage': document['coverage']} + return {**bundle, 'non_cargo_runtimes': [runtime], 'coverage': bundle['coverage'] + ' Includes source-reviewed GNU NAPI GNU/LLVM runtime grants; final retained-input gate is required.'} + + +def plain_notice(document): + sections = ['Ktav GNU NAPI Windows GNU/LLVM runtime notices.\nOriginal terms follow unchanged; the source/header notice set is conservative.\n'] + for item in document['original_documents']: + sections.extend(['\n===== ' + item['source'] + ' =====\n', item['text']]) + for item in document['source_files']: + sections.extend(['\n===== ' + item['source'] + ' =====\n', '\n'.join(item['source_notices'])]) + return '\n'.join(sections).encode('utf-8') + + +def prepare(evidence, target): + root = Path(__file__).resolve().parents[1] + document = catalogue(root) + if target not in document['targets'] or (evidence / 'NOTICE.cargo-std.json').exists(): + raise ValueError('unreviewed target or runtime already prepared') + verify_sources(document, evidence=evidence) + before = read(evidence / 'NOTICE.json', MAX_TOTAL) + combined = (json.dumps(augment(json.loads(before), document, target), ensure_ascii=False, sort_keys=True, indent=2) + '\n').encode('utf-8') + payload = gzip.compress(combined, mtime=0) + if len(combined) > MAX_TOTAL or len(payload) > MAX_FILE: + raise ValueError('GNU NAPI combined runtime notice exceeds bound') + (evidence / 'NOTICE.cargo-std.json').write_bytes(before) + (evidence / 'NOTICE.json').write_bytes(combined) + (evidence / 'NOTICE.json.gz').write_bytes(payload) + (evidence / 'NOTICE.windows-runtime.txt').write_bytes(plain_notice(document)) + (evidence / 'napi-gnullvm-runtime.json').write_bytes(read(root / CATALOG, MAX_FILE)) + + +def retained_objects(raw): + objects = set() + for line in raw.splitlines(): + match = re.match(rb'^[0-9a-fA-F]+\s+[0-9a-fA-F]+\s+\d+\s{2,}(.+):\([^\r\n]*\)\s*$', line) + if match and b'.rcgu.o' not in match[1]: + objects.add(match[1].decode('utf-8').replace('\\', '/').rsplit('/', 1)[-1]) + return objects + + +def sdk_inputs(items, target): + selected = [] + marker = 'llvm-mingw-20261020-ucrt-x86_64/' + seen = set() + for item in items: + name = item['path'].replace('\\', '/') + if not name.endswith(('.a', '.o', '.obj', '.rlib', '.lib')): + continue + if marker not in name: + cargo = r'/target/' + re.escape(target) + r'/release/deps/' + rust = r'/[.]rustup/toolchains/1[.]99[.]1-x86_64-pc-windows-msvc/lib/rustlib/' + re.escape(target) + r'/lib/' + accepted = re.search(cargo + r'ktav_napi[.][^/]+[.]rcgu[.]o$', name) or re.search(cargo + r'rustc[^/]+/libstd-[0-9a-f]+[.]rlib$', name) or re.search(rust + r'libcompiler_builtins-[0-9a-f]+[.]rlib$', name) + if not accepted: + raise ValueError('native linker input outside reviewed SDK/Rust boundary') + continue + if name.count(marker) != 1: + raise ValueError('unreviewed SDK linker input path') + relative = name.split(marker, 1)[1] + if relative in seen or '..' in PurePosixPath(relative).parts: + raise ValueError('duplicate or unsafe SDK linker input') + seen.add(relative) + selected.append({'path': relative, 'size': item['bytes'], 'sha256': item['sha256']}) + return sorted(selected, key=lambda item: item['path']) + + +def verify_inputs(items, mapping, document, target): + if target not in document['targets']: + raise ValueError('unreviewed GNU NAPI target') + expected = document['targets'][target] + if sdk_inputs(items, target) != expected['sdk_inputs'] or retained_objects(mapping) != set(expected['retained_objects']): + raise ValueError('GNU NAPI SDK bytes or retained objects differ from reviewed profile') + + +def verify(evidence, binary, target): + spec = importlib.util.spec_from_file_location('napi_notice_scanner', Path(__file__).with_name('check_embedded_notices.py')) + scanner = importlib.util.module_from_spec(spec) + spec.loader.exec_module(scanner) + + document = catalogue(Path(__file__).resolve().parents[1]) + if target not in document['targets']: + raise ValueError('unreviewed GNU NAPI target') + records = {item['source']: item for item in [*document['source_files'], *document['original_documents']]} + verify_sources(document, fetch=lambda url: read(source_file_path(evidence, records[url]), MAX_FILE)) + raw = read(binary, 128 * 1024 * 1024) + notice = read(evidence / 'NOTICE.json', MAX_TOTAL) + before = json.loads(read(evidence / 'NOTICE.cargo-std.json', MAX_TOTAL)) + if json.loads(notice) != augment(before, document, target) or scanner._extract(raw)[0] != notice: + raise ValueError('actual GNU NAPI runtime resource differs') + if read(evidence / 'NOTICE.windows-runtime.txt', MAX_TOTAL) != plain_notice(document): + raise ValueError('plain GNU NAPI original notices differ') + if read(evidence / 'napi-gnullvm-runtime.json', MAX_FILE) != read(Path(__file__).resolve().parents[1] / CATALOG, MAX_FILE): + raise ValueError('staged GNU NAPI catalogue differs') + identity = json.loads(read(evidence / 'binary-verification.json', MAX_FILE)) + mapping = read(evidence / 'native-link.map', 32 * 1024 * 1024) + if identity['target'] != target or identity['binary_sha256'] != hashlib.sha256(raw).hexdigest() or identity['map_sha256'] != hashlib.sha256(mapping).hexdigest(): + raise ValueError('actual GNU NAPI release/map identity differs') + expected = document['targets'][target] + inputs = json.loads(read(evidence / 'link-input-fingerprints.json', MAX_FILE)) + verify_inputs(inputs, mapping, document, target) + provenance = json.loads(read(evidence / 'source-variant.json', MAX_FILE)) + if provenance['sdk_archive_sha256'] != SDK_SHA or provenance['source_ref'] != '562deb3fde092d63a78f359be095e5079929d0d1': + raise ValueError('GNU NAPI source/SDK identity differs') + report = {'target': target, 'binary_sha256': identity['binary_sha256'], 'notice_sha256': hashlib.sha256(notice).hexdigest(), 'catalog_sha256': CATALOG_SHA, 'sdk_inputs': len(expected['sdk_inputs']), 'retained_runtime_objects': len(expected['retained_objects']), 'source_records': len(document['source_files']), 'scope': 'Actual GNU NAPI DLL resource and target-specific SDK input/source-grant binding; not npm delivery, ARM execution, other targets or historical published artifact clearance.'} + (evidence / 'native-runtime-verification.json').write_text(json.dumps(report, sort_keys=True, indent=2) + '\n', encoding='utf-8') + print(json.dumps(report, sort_keys=True)) + + +if __name__ == '__main__': + if len(sys.argv) == 4 and sys.argv[1] == 'prepare': + prepare(Path(sys.argv[2]), sys.argv[3]) + elif len(sys.argv) == 5 and sys.argv[1] == 'verify': + verify(Path(sys.argv[2]), Path(sys.argv[3]), sys.argv[4]) + else: + raise SystemExit('usage: napi_gnullvm_notices.py prepare EVIDENCE TARGET | verify EVIDENCE BINARY TARGET') diff --git a/scripts/prepare_gnu_napi_variant_notices.py b/scripts/prepare_gnu_napi_variant_notices.py new file mode 100644 index 0000000..6bbeca0 --- /dev/null +++ b/scripts/prepare_gnu_napi_variant_notices.py @@ -0,0 +1,144 @@ +"""Собрать полный notice explicit GNU source variant без ослабления original guards.""" + +import gzip +import hashlib +import json +from pathlib import Path +import shutil +import subprocess +import sys +import tomllib + +sys.path.insert(0, str(Path(__file__).resolve().parent)) + +from cargo_notice_bundle import _build +from napi_gnullvm_notices import catalogue +from rust_compiler_notices import collect as compiler_notices +from source_license_supplements import supplement_fallbacks +from windows_gnu_napi_variant import CRATE_SHA, LOCK_SHA, SOURCE, verify_lock + +CONFIG_SHA = 'a07d75d5baee5944ed39294edea0c6d7adab50fb3b0aa7dea7d31b672c83ce2e' +RESOURCE_SHA = '8ef48240113ac78b88b612ad044a1584ccd4b0050d155b05d0cfcd89f50518e9' +NAPI_VCS = 'd9cb526c15e63ba30e06b4d169068c9854180595' + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def configure(original, vendor): + if sha(original) != CONFIG_SHA or 'patch' in tomllib.loads(original.decode('utf-8')): + raise ValueError('unreviewed original Cargo config') + appended = '\n[patch.crates-io]\nnapi = { path = ' + json.dumps(vendor.as_posix()) + ' }\n' + changed = original + appended.encode('utf-8') + parsed = tomllib.loads(changed.decode('utf-8')) + parsed.pop('patch') + if parsed != tomllib.loads(original.decode('utf-8')): + raise ValueError('variant changes unrelated Cargo config') + return changed + + +def resource_hook(template): + if sha(template) != RESOURCE_SHA or template.count(b' napi_build::setup();') != 1: + raise ValueError('unreviewed notice resource template') + replacement = b' if !(std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows")\n && std::env::var("CARGO_CFG_TARGET_ENV").as_deref() == Ok("gnu")) {\n napi_build::setup();\n }' + return template.replace(b' napi_build::setup();', replacement) + + +def prepare(evidence, target): + root = Path.cwd().resolve() + evidence = evidence.resolve() + if evidence.is_relative_to(root) or (evidence / 'NOTICE.json').exists(): + raise ValueError('variant evidence must be outside source and not already prepared') + document = catalogue(root) + if target not in document['targets']: + raise ValueError('unreviewed GNU NAPI target') + variant = json.loads((evidence / 'source-variant.json').read_text(encoding='utf-8')) + if variant['source_ref'] != SOURCE or variant['original_lock_sha256'] != LOCK_SHA or variant['upstream_archive_sha256'] != CRATE_SHA: + raise ValueError('unreviewed source variant identity') + original_lock = (evidence / 'Cargo.original.lock').read_bytes() + locked = Path('Cargo.lock').read_bytes() + if sha(original_lock) != LOCK_SHA or sha(locked) != variant['variant_lock_sha256']: + raise ValueError('source variant lock identity differs') + verify_lock(tomllib.loads(original_lock.decode()), tomllib.loads(locked.decode())) + core = [item for item in tomllib.loads(locked.decode())['package'] if item['name'] == 'ktav'] + if len(core) != 1 or core[0]['version'] != '0.8.1' or core[0].get('checksum') != '7140dfe2fa6c320e74768cd6a637828c2d26f81746254f4fcd805f3993bd3fd5': + raise ValueError('variant registry core changed') + patch = tomllib.loads(variant['config'])['patch']['crates-io']['napi'] + vendor = Path(patch['path']).resolve() + vcs = json.loads((vendor / '.cargo_vcs_info.json').read_text(encoding='utf-8')) + if vcs != {'git': {'sha1': NAPI_VCS}, 'path_in_vcs': 'crates/napi'}: + raise ValueError('upstream source VCS identity differs') + grant = [item for item in document['original_documents'] if item['source'] == 'https://raw.githubusercontent.com/napi-rs/napi-rs/' + NAPI_VCS + '/LICENSE'] + if len(grant) != 1 or sha(grant[0]['text'].encode()) != grant[0]['sha256']: + raise ValueError('complete original upstream NAPI grant missing') + license_path = vendor / 'LICENSE' + if license_path.exists() or license_path.is_symlink(): + raise ValueError('upstream license attachment already exists') + license_path.write_bytes(grant[0]['text'].encode('utf-8')) + config_path = Path('.cargo/config.toml') + before_config = config_path.read_bytes() + changed_config = configure(before_config, vendor) + config_path.write_bytes(changed_config) + project_hook = Path('crates/napi/build.rs') + previous_hook = project_hook.read_bytes() + expected_hook = [item for item in variant['overlays'] if item['role'] == 'project-build'] + if len(expected_hook) != 1 or sha(previous_hook) != expected_hook[0]['compiled_sha256']: + raise ValueError('variant project hook differs before resource overlay') + template = (root / 'ci/fixtures/windows-gnu-napi/resource-build.rs.txt').read_bytes() + changed_hook = resource_hook(template) + project_hook.write_bytes(changed_hook) + lib = Path('crates/napi/src/lib.rs') + before_lib = lib.read_bytes() + if sha(before_lib) != variant['binding_lib_sha256']: + raise ValueError('original binding source differs before notice overlay') + subprocess.run([sys.executable, '-I', 'scripts/patch_napi_notice_source.py', str(lib)], check=True) + raw = subprocess.check_output(['cargo', 'metadata', '--locked', '--all-features', '--format-version', '1']) + metadata = json.loads(raw) + local = [item for item in metadata['packages'] if item.get('source') is None] + if {item['name'] for item in local} != {'ktav-cabi', 'ktav-napi', 'ktav-wasm', 'napi'}: + raise ValueError('unreviewed local package in variant graph') + for item in local: + package_root = Path(item['manifest_path']).resolve().parent + if item['name'] == 'napi': + if item['version'] != '3.15.0' or item.get('license') != 'MIT' or package_root != vendor: + raise ValueError('patched NAPI source/license identity differs') + continue + if item.get('license') != 'MIT OR Apache-2.0' or not package_root.is_relative_to(root): + raise ValueError('first-party variant license changed') + for name in ('LICENSE-MIT', 'LICENSE-APACHE'): + source, destination = root / name, package_root / name + if destination.is_symlink() or destination.exists() and destination.read_bytes() != source.read_bytes(): + raise ValueError('first-party license copy differs') + if not destination.exists(): + shutil.copyfile(source, destination) + (evidence / 'metadata.json').write_bytes(raw) + (evidence / 'Cargo.lock').write_bytes(locked) + rustc = subprocess.check_output(['rustc', '--version', '--verbose']) + (evidence / 'rustc.txt').write_bytes(rustc) + sysroot = subprocess.check_output(['rustc', '--print', 'sysroot'], text=True).strip() + shutil.copyfile(Path(sysroot) / 'share/doc/rust/COPYRIGHT-library.html', evidence / 'COPYRIGHT-library.html') + report = subprocess.check_output(['cargo', 'about', 'generate', '--locked', '--all-features', '--fail', '--config', 'ci/about.toml', '--format', 'json']) + (evidence / 'licenses-cargo-about.json').write_bytes(report) + combined, provenance = supplement_fallbacks(metadata, json.loads(report), locked, root / 'ci/licenses/js-source-supplements.json') + combined['source_license_supplements'] = provenance + (evidence / 'licenses.json').write_text(json.dumps(combined, ensure_ascii=False, indent=2) + '\n', encoding='utf-8') + bundle = json.loads(_build(evidence)) + bundle['rust_compiler_builtins'] = compiler_notices(root, bundle['rustc']) + variant['notice_overlay'] = {'resource_template_sha256': RESOURCE_SHA, 'project_build': {'before_sha256': sha(previous_hook), 'compiled_sha256': sha(changed_hook)}, 'binding_lib': {'before_sha256': sha(before_lib), 'compiled_sha256': sha(lib.read_bytes())}, 'cargo_config': {'before_sha256': sha(before_config), 'compiled_sha256': sha(changed_config)}, 'upstream_license_sha256': grant[0]['sha256']} + bundle['source_variant'] = {key: value for key, value in variant.items() if key != 'config'} + bundle['source_license_supplements'] = provenance + bundle['resolution_origin'] = 'Explicit checksum-bound patched NAPI source and feature variant; not the original registry graph or historical published dependency evidence.' + data = (json.dumps(bundle, ensure_ascii=False, sort_keys=True, indent=2) + '\n').encode('utf-8') + compressed = gzip.compress(data, mtime=0) + if len(data) > 64 * 1024 * 1024 or len(compressed) > 4 * 1024 * 1024 or Path('Cargo.lock').read_bytes() != locked: + raise ValueError('variant notice bounds exceeded or compiled lock changed') + (evidence / 'NOTICE.json').write_bytes(data) + (evidence / 'NOTICE.json.gz').write_bytes(compressed) + (evidence / 'source-variant.json').write_text(json.dumps(variant, sort_keys=True, indent=2) + '\n', encoding='utf-8') + + +if __name__ == '__main__': + if len(sys.argv) != 3: + raise SystemExit('usage: prepare_gnu_napi_variant_notices.py EVIDENCE TARGET') + prepare(Path(sys.argv[1]), sys.argv[2]) diff --git a/scripts/rust_compiler_notices.py b/scripts/rust_compiler_notices.py new file mode 100644 index 0000000..36bdc1b --- /dev/null +++ b/scripts/rust_compiler_notices.py @@ -0,0 +1,65 @@ +"""Сохранить полные compiler grants для exact Rust source revision.""" + +from __future__ import annotations + +import hashlib +import json +from pathlib import Path, PurePosixPath + +PROFILE_SHA256 = "39cbf18420d5e0c0a35fb2d5e5fbed4db755488ea0ca11414944ead9fbabab92" +RUST_REVISION = "58cf8f9c35b355199727627d07ae34a4e2846d67" + + +def _read(path: Path, limit: int) -> bytes: + if path.is_symlink() or not path.is_file(): + raise ValueError("missing or symlinked compiler notice input") + with path.open("rb") as source: + raw = source.read(limit + 1) + if len(raw) > limit: + raise ValueError("compiler notice input exceeds bound") + return raw + + +def collect(root: Path, rustc: str) -> dict: + """Сверить compiler identity и сохранить original legal/source bytes.""" + if ( + not rustc.startswith("rustc 1.99.1 ") + or "\nrelease: 1.99.1\n" not in rustc + or "\ncommit-hash: " + RUST_REVISION + "\n" not in rustc + ): + raise ValueError("unreviewed Rust compiler source identity") + root = root.resolve() + raw = _read(root / "ci/rust-compiler-notices.json", 1024 * 1024) + if hashlib.sha256(raw).hexdigest() != PROFILE_SHA256: + raise ValueError("compiler notice profile differs from review") + profile = json.loads(raw) + materials = [] + for item in profile["materials"]: + relative = PurePosixPath(item["path"]) + path = root / item["path"] + if ( + relative.is_absolute() + or ".." in relative.parts + or "\\" in item["path"] + or not path.resolve().is_relative_to(root) + ): + raise ValueError("unsafe compiler notice source path") + original = _read(path, 4 * 1024 * 1024) + blob = hashlib.sha1(b"blob " + str(len(original)).encode() + b"\0" + original).hexdigest() + if ( + len(original) != item["bytes"] + or hashlib.sha256(original).hexdigest() != item["sha256"] + or blob != item["git_blob"] + ): + raise ValueError("compiler notice original identity differs") + materials.append({**item, "text": original.decode("utf-8")}) + return { + "schema_version": 1, + "profile_sha256": PROFILE_SHA256, + "rust_revision": profile["rust_revision"], + "llvm_revision": profile["llvm_revision"], + "compiler_builtins_license": "MIT AND Apache-2.0 WITH LLVM-exception", + "libm_license": "MIT", + "coverage": profile["coverage"], + "materials": materials, + } diff --git a/scripts/stage_gnu_napi_variant.py b/scripts/stage_gnu_napi_variant.py new file mode 100644 index 0000000..c48c780 --- /dev/null +++ b/scripts/stage_gnu_napi_variant.py @@ -0,0 +1,130 @@ +"""Сохранить actual linker fingerprints и полный проверенный native payload.""" + +import hashlib +import json +from pathlib import Path, PurePosixPath +import shutil +import subprocess +import sys +import tarfile +import tomllib + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def fingerprints(archive_path): + if archive_path.is_symlink() or not archive_path.is_file() or archive_path.stat().st_size > 512 * 1024 * 1024: + raise ValueError('missing or oversized linker reproduction') + items = [] + seen = set() + total = 0 + with tarfile.open(archive_path, 'r:') as archive: + for item in archive: + path = PurePosixPath(item.name) + if path.is_absolute() or '..' in path.parts or '\\' in item.name or ':' in item.name or item.name.casefold() in seen: + raise ValueError('unsafe or duplicate linker input') + seen.add(item.name.casefold()) + if len(seen) > 8192: + raise ValueError('link input count exceeds bound') + if item.isdir(): + continue + if not item.isfile() or item.size > 128 * 1024 * 1024: + raise ValueError('invalid linker input type/size') + total += item.size + if total > 512 * 1024 * 1024: + raise ValueError('link input bytes exceed bound') + digest = hashlib.sha256() + size = 0 + with archive.extractfile(item) as source: + while chunk := source.read(1024 * 1024): + size += len(chunk) + digest.update(chunk) + if size != item.size: + raise ValueError('truncated linker input') + items.append({'path': item.name, 'bytes': size, 'sha256': digest.hexdigest()}) + if not any(item['path'].endswith('/response.txt') for item in items): + raise ValueError('actual linker response missing') + return items + + +def write_json(path, value): + path.write_text(json.dumps(value, ensure_ascii=False, sort_keys=True, indent=2) + '\n', encoding='utf-8') + + +def stage(evidence, binary, target): + evidence = evidence.resolve() + identity = json.loads((evidence / 'binary-verification.json').read_text(encoding='utf-8')) + verified = json.loads((evidence / 'native-runtime-verification.json').read_text(encoding='utf-8')) + if identity['target'] != target or verified['target'] != target or sha(binary.read_bytes()) != identity['binary_sha256'] or verified['binary_sha256'] != identity['binary_sha256']: + raise ValueError('native verification identities differ') + if target == 'x86_64-pc-windows-gnullvm': + consumer = json.loads((evidence / 'consumer-verification.json').read_text(encoding='utf-8')) + if consumer['binary_sha256'] != identity['binary_sha256'] or consumer.get('loaded_built_addon') is not True or consumer.get('sdk_path_removed') is not True: + raise ValueError('actual x64 consumer proof missing') + elif target != 'aarch64-pc-windows-gnullvm': + raise ValueError('unreviewed payload target') + payload = evidence.parent / 'gnu-napi-native-payload' + payload.mkdir() + shutil.copyfile(binary, payload / 'ktav_napi.node') + for name in ['LICENSE-MIT', 'LICENSE-APACHE']: + shutil.copyfile(name, payload / name) + for name in ['NOTICE.json', 'NOTICE.json.gz', 'NOTICE.cargo-std.json', 'NOTICE.windows-runtime.txt', 'COPYRIGHT-library.html', 'Cargo.original.lock', 'Cargo.variant.lock', 'Cargo.lock', 'napi-gnullvm-runtime.json', 'binary-verification.json', 'native-runtime-verification.json', 'link-input-fingerprints.json']: + shutil.copyfile(evidence / name, payload / name) + shutil.copytree(evidence / 'runtime-originals', payload / 'runtime-originals') + shutil.copytree('ci/licenses/rust-compiler-originals', payload / 'rust-compiler-originals') + shutil.copyfile('ci/rust-compiler-notices.json', payload / 'rust-compiler-notices.json') + variant = json.loads((evidence / 'source-variant.json').read_text(encoding='utf-8')) + config = variant.pop('config') + notice = json.loads((evidence / 'NOTICE.json').read_text(encoding='utf-8')) + if notice['source_variant'] != variant or sha((evidence / 'NOTICE.json').read_bytes()) != verified['notice_sha256']: + raise ValueError('staged source/notice provenance differs') + for name, expected in [('crates/napi/build.rs', variant['notice_overlay']['project_build']['compiled_sha256']), ('crates/napi/src/lib.rs', variant['notice_overlay']['binding_lib']['compiled_sha256']), ('crates/napi/Cargo.toml', next(item['compiled_sha256'] for item in variant['overlays'] if item['role'] == 'project-manifest'))]: + if sha(Path(name).read_bytes()) != expected: + raise ValueError('compiled first-party source changed before staging') + write_json(payload / 'source-variant.json', variant) + source = payload / 'source' + source.mkdir() + subprocess.run(['git', 'archive', '--format=tar', '--output=' + str(source / 'project-original.tar'), variant['source_ref']], check=True) + for name in ['crates/napi/build.rs', 'crates/napi/Cargo.toml', 'crates/napi/src/lib.rs']: + destination = source / 'overlays' / name + destination.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(name, destination) + vendor = Path(tomllib.loads(config)['patch']['crates-io']['napi']['path']).resolve() + with tarfile.open(source / 'napi-3.15.0-source.tar.gz', 'w:gz') as archive: + for path in sorted(vendor.rglob('*')): + if path.is_symlink() or not (path.is_file() or path.is_dir()): + raise ValueError('unexpected source entry') + if path.is_file(): + archive.add(path, arcname='napi-3.15.0/' + path.relative_to(vendor).as_posix(), recursive=False) + config_path = source / 'overlays/.cargo/config.toml' + config_path.parent.mkdir(parents=True, exist_ok=True) + original_config = Path('ci/fixtures/windows-gnu-napi/project-config.toml.txt').read_bytes() + relocatable = original_config + b'\n[patch.crates-io]\nnapi = { path = "vendor/napi-3.15.0" }\n' + tomllib.loads(relocatable.decode()) + config_path.write_bytes(relocatable) + (source / 'README.txt').write_text( + 'Source materials for the explicit GNU NAPI candidate, not the historical registry graph.\n' + 'Extract project-original.tar into a new project directory. Apply overlays/ there.\n' + 'Extract napi-3.15.0-source.tar.gz under that project vendor/ directory.\n' + 'Use Cargo.variant.lock as Cargo.lock. Preserve the original MIT and Apache-2.0 licenses.\n' + 'NOTICE.json.gz is the exact build-time KTAV_NAPI_NOTICES_GZIP input.\n' + 'Compiler, target and LLVM MinGW identities are recorded in the notice and evidence.\n' + 'These are source/provenance materials, not a claim of bit-for-bit reproducibility.\n', encoding='utf-8') + files = [] + for path in sorted(payload.rglob('*')): + if path.is_file(): + raw = path.read_bytes() + files.append({'path': path.relative_to(payload).as_posix(), 'bytes': len(raw), 'sha256': sha(raw)}) + write_json(payload / 'native-payload-manifest.json', {'schema_version': 1, 'target': target, 'source_ref': variant['source_ref'], 'binary_sha256': identity['binary_sha256'], 'notice_sha256': verified['notice_sha256'], 'files': files, 'scope': 'GNU source-bound native candidate with complete legal/source roles; not npm assembly or historical package clearance. ARM execution not claimed.'}) + print(str(payload)) + + +if __name__ == '__main__': + if len(sys.argv) == 4 and sys.argv[1] == 'capture': + write_json(Path(sys.argv[3]), fingerprints(Path(sys.argv[2]))) + elif len(sys.argv) == 5 and sys.argv[1] == 'stage': + stage(Path(sys.argv[2]), Path(sys.argv[3]), sys.argv[4]) + else: + raise SystemExit('usage: stage_gnu_napi_variant.py capture REPRO OUTPUT | stage EVIDENCE BINARY TARGET') From 27a33edcb6ca5a20a3d3c117050d46f87ea6f11a Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sun, 1 Nov 2026 11:10:43 +0100 Subject: [PATCH 42/51] fix(licenses): bind the explicit patched NAPI grant Cargo-about reports a generic MIT fallback for the local NAPI path source even after attaching the complete reviewed upstream license. The shared registry supplement guard correctly rejects that identity. Bind only the exact napi 3.15.0 path-source fallback to the complete checksum-bound original grant before processing registry supplements. Preserve both MIT attributions and every unrelated fallback. Reject source/version/license/path drift, changed grant bytes and incomplete or duplicate coverage. Keep the generic registry guard unchanged. Co-Authored-By: Claude Opus 5.5 --- ci/test_napi_gnullvm_notices.py | 26 ++++++++++++++- scripts/prepare_gnu_napi_variant_notices.py | 37 ++++++++++++++++++++- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/ci/test_napi_gnullvm_notices.py b/ci/test_napi_gnullvm_notices.py index 86ffdd6..d104e92 100644 --- a/ci/test_napi_gnullvm_notices.py +++ b/ci/test_napi_gnullvm_notices.py @@ -14,7 +14,7 @@ ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(ROOT / 'scripts')) import napi_gnullvm_notices as RUNTIME -from prepare_gnu_napi_variant_notices import configure, resource_hook +from prepare_gnu_napi_variant_notices import bind_variant_license, configure, resource_hook from stage_gnu_napi_variant import fingerprints @@ -108,6 +108,30 @@ def test_resource_overlay_keeps_encoder_and_only_guards_setup(self): with self.assertRaisesRegex(ValueError, 'resource template'): resource_hook(source + b'changed') + def test_variant_license_binding_preserves_other_registry_fallbacks(self): + with tempfile.TemporaryDirectory() as temporary: + vendor = Path(temporary) + grant = next(item for item in RUNTIME.catalogue(ROOT)['original_documents'] if 'napi-rs/napi-rs/' in item['source']) + (vendor / 'LICENSE').write_text(grant['text'], encoding='utf-8', newline='') + package = {'id': 'local-napi', 'name': 'napi', 'version': '3.15.0', 'source': None, 'license': 'MIT', 'manifest_path': str(vendor / 'Cargo.toml')} + metadata = {'packages': [package]} + entry = {'id': 'MIT', 'text': 'generic fallback', 'source_path': None, 'used_by': [{'crate': {'id': 'local-napi'}}, {'crate': {'id': 'registry-napi-sys'}}]} + report = {'licenses': [entry]} + combined = bind_variant_license(metadata, report, vendor, grant) + self.assertEqual(combined['licenses'][0], {**entry, 'used_by': [{'crate': {'id': 'registry-napi-sys'}}]}) + self.assertEqual(combined['licenses'][1]['text'], grant['text']) + self.assertEqual(combined['licenses'][1]['used_by'], [{'crate': {'id': 'local-napi'}}]) + self.assertEqual(report, {'licenses': [entry]}) + for key, wrong in [('version', '3.15.1'), ('source', 'registry+https://github.com/rust-lang/crates.io-index'), ('license', 'MIT OR GPL-3.0-only'), ('manifest_path', str(vendor / 'foreign/Cargo.toml'))]: + with self.subTest(key=key), self.assertRaisesRegex(ValueError, 'source identity differs'): + bind_variant_license({'packages': [{**package, key: wrong}]}, report, vendor, grant) + for licenses in [[], [entry, entry], [{**entry, 'id': 'Apache-2.0'}], [{**entry, 'source_path': 'foreign/LICENSE'}]]: + with self.assertRaisesRegex(ValueError, 'coverage differs|shape differs'): + bind_variant_license(metadata, {'licenses': licenses}, vendor, grant) + (vendor / 'LICENSE').write_bytes(b'changed') + with self.assertRaisesRegex(ValueError, 'original license differs'): + bind_variant_license(metadata, report, vendor, grant) + def test_linker_fingerprints_preserve_actual_bytes(self): with tempfile.TemporaryDirectory() as temporary: path = Path(temporary) / 'link.tar' diff --git a/scripts/prepare_gnu_napi_variant_notices.py b/scripts/prepare_gnu_napi_variant_notices.py index 6bbeca0..83dfc5f 100644 --- a/scripts/prepare_gnu_napi_variant_notices.py +++ b/scripts/prepare_gnu_napi_variant_notices.py @@ -1,5 +1,6 @@ """Собрать полный notice explicit GNU source variant без ослабления original guards.""" +import copy import gzip import hashlib import json @@ -45,6 +46,38 @@ def resource_hook(template): return template.replace(b' napi_build::setup();', replacement) +def bind_variant_license(metadata, report, vendor, grant): + packages = [item for item in metadata['packages'] if item['name'] == 'napi'] + if len(packages) != 1: + raise ValueError('variant NAPI license package count differs') + package = packages[0] + if package['version'] != '3.15.0' or package.get('source') is not None or package.get('license') != 'MIT' or Path(package['manifest_path']).resolve().parent != vendor.resolve(): + raise ValueError('variant NAPI license source identity differs') + path = vendor / 'LICENSE' + text = grant['text'] + if sha(text.encode()) != grant['sha256'] or path.is_symlink() or path.read_bytes() != text.encode(): + raise ValueError('variant NAPI complete original license differs') + combined = copy.deepcopy(report) + licenses = [] + matched = 0 + for entry in combined['licenses']: + uses = [use for use in entry['used_by'] if use['crate']['id'] == package['id']] + if not uses: + licenses.append(entry) + continue + if len(uses) != 1 or entry.get('id') != 'MIT' or entry.get('source_path'): + raise ValueError('variant NAPI fallback shape differs') + matched += 1 + others = [use for use in entry['used_by'] if use['crate']['id'] != package['id']] + if others: + licenses.append({**entry, 'used_by': others}) + licenses.append({**entry, 'text': text, 'source_path': str(path), 'used_by': uses, 'origin': 'checksum-bound-explicit-source-variant'}) + if matched != 1: + raise ValueError('variant NAPI fallback coverage differs') + combined['licenses'] = licenses + return combined + + def prepare(evidence, target): root = Path.cwd().resolve() evidence = evidence.resolve() @@ -120,7 +153,9 @@ def prepare(evidence, target): shutil.copyfile(Path(sysroot) / 'share/doc/rust/COPYRIGHT-library.html', evidence / 'COPYRIGHT-library.html') report = subprocess.check_output(['cargo', 'about', 'generate', '--locked', '--all-features', '--fail', '--config', 'ci/about.toml', '--format', 'json']) (evidence / 'licenses-cargo-about.json').write_bytes(report) - combined, provenance = supplement_fallbacks(metadata, json.loads(report), locked, root / 'ci/licenses/js-source-supplements.json') + variant_report = bind_variant_license(metadata, json.loads(report), vendor, grant[0]) + combined, provenance = supplement_fallbacks(metadata, variant_report, locked, root / 'ci/licenses/js-source-supplements.json') + provenance.append({'name': 'napi', 'version': '3.15.0', 'origin': 'checksum-bound-explicit-source-variant', 'upstream_archive_sha256': CRATE_SHA, 'vcs_revision': NAPI_VCS, 'license_sha256': grant[0]['sha256']}) combined['source_license_supplements'] = provenance (evidence / 'licenses.json').write_text(json.dumps(combined, ensure_ascii=False, indent=2) + '\n', encoding='utf-8') bundle = json.loads(_build(evidence)) From 201f2d1986b5d188578dc3a27a0858ef3ed7d981 Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sun, 1 Nov 2026 11:16:40 +0100 Subject: [PATCH 43/51] fix(licenses): preserve exact original grant text bytes Restore the two UTF-8 grant texts in the new GNU NAPI catalogue from checksum- and Git-blob-verified original source bytes. Keep the original source identities and legal terms unchanged. Validate every complete document against its SHA256 and Git blob when loading the catalogue, before network preparation. Extend the complete-grant regression to reject encoding corruption. Do not weaken post-fetch source equality or native upload gates. Co-Authored-By: Claude Opus 5.5 --- ci/licenses/napi-gnullvm-runtime.json | 4 ++-- ci/test_napi_gnullvm_notices.py | 5 ++++- scripts/napi_gnullvm_notices.py | 7 ++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ci/licenses/napi-gnullvm-runtime.json b/ci/licenses/napi-gnullvm-runtime.json index 1614888..7353d2e 100644 --- a/ci/licenses/napi-gnullvm-runtime.json +++ b/ci/licenses/napi-gnullvm-runtime.json @@ -22,7 +22,7 @@ "path": "COPYING.MinGW-w64-runtime/COPYING.MinGW-w64-runtime.txt", "sha256": "1db8da07b436c68833c0673ffee3d9fcb2526047f3820b81661865dfedc79a1f", "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/COPYING.MinGW-w64-runtime/COPYING.MinGW-w64-runtime.txt", - "text": "MinGW-w64 runtime licensing\n***************************\n\nThis program or library was built using MinGW-w64 and statically\nlinked against the MinGW-w64 runtime. Some parts of the runtime\nare under licenses which require that the copyright and license\nnotices are included when distributing the code in binary form.\nThese notices are listed below.\n\n\n========================\nOverall copyright notice\n========================\n\nCopyright (c) 2009, 2010, 2011, 2012, 2013 by the mingw-w64 project\n\nThis license has been certified as open source. It has also been designated\nas GPL compatible by the Free Software Foundation (FSF).\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n 1. Redistributions in source code must retain the accompanying copyright\n notice, this list of conditions, and the following disclaimer.\n 2. Redistributions in binary form must reproduce the accompanying\n copyright notice, this list of conditions, and the following disclaimer\n in the documentation and/or other materials provided with the\n distribution.\n 3. Names of the copyright holders must not be used to endorse or promote\n products derived from this software without prior written permission\n from the copyright holders.\n 4. The right to distribute this software or to use it for any purpose does\n not give you the right to use Servicemarks (sm) or Trademarks (tm) of\n the copyright holders. Use of them is covered by separate agreement\n with the copyright holders.\n 5. If any files are modified, you must cause the modified files to carry\n prominent notices stating that you changed the files and the date of\n any change.\n\nDisclaimer\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED\nOR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\nOF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO\nEVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\nOR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\nEVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n======================================== \ngetopt, getopt_long, and getop_long_only\n======================================== \n\nCopyright (c) 2002 Todd C. Miller \n \nPermission to use, copy, modify, and distribute this software for any \npurpose with or without fee is hereby granted, provided that the above \ncopyright notice and this permission notice appear in all copies. \n \t \nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\nWITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\nMERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\nANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\nACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\nOR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n\nSponsored in part by the Defense Advanced Research Projects\nAgency (DARPA) and Air Force Research Laboratory, Air Force\nMateriel Command, USAF, under agreement number F39502-99-1-0512.\n\n * * * * * * * \n\nCopyright (c) 2000 The NetBSD Foundation, Inc.\nAll rights reserved.\n\nThis code is derived from software contributed to The NetBSD Foundation\nby Dieter Baron and Thomas Klausner.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n 1. Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n 2. Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS\n``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\nTO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\nINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\nCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\nARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE.\n\n\n===============================================================\ngdtoa: Converting between IEEE floating point numbers and ASCII\n===============================================================\n\nThe author of this software is David M. Gay.\n\nCopyright (C) 1997, 1998, 1999, 2000, 2001 by Lucent Technologies\nAll Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and\nits documentation for any purpose and without fee is hereby\ngranted, provided that the above copyright notice appear in all\ncopies and that both that the copyright notice and this\npermission notice and warranty disclaimer appear in supporting\ndocumentation, and that the name of Lucent or any of its entities\nnot be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior\npermission.\n\nLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.\nIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY\nSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\nIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n\n * * * * * * *\n\nThe author of this software is David M. Gay.\n\nCopyright (C) 2005 by David M. Gay\nAll Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and its\ndocumentation for any purpose and without fee is hereby granted,\nprovided that the above copyright notice appear in all copies and that\nboth that the copyright notice and this permission notice and warranty\ndisclaimer appear in supporting documentation, and that the name of\nthe author or any of his current or former employers not be used in\nadvertising or publicity pertaining to distribution of the software\nwithout specific, written prior permission.\n\nTHE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN\nNO EVENT SHALL THE AUTHOR OR ANY OF HIS CURRENT OR FORMER EMPLOYERS BE\nLIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY\nDAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\nWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\nSOFTWARE.\n\n * * * * * * *\n\nThe author of this software is David M. Gay.\n\nCopyright (C) 2004 by David M. Gay.\nAll Rights Reserved\nBased on material in the rest of /netlib/fp/gdota.tar.gz,\nwhich is copyright (C) 1998, 2000 by Lucent Technologies.\n\nPermission to use, copy, modify, and distribute this software and\nits documentation for any purpose and without fee is hereby\ngranted, provided that the above copyright notice appear in all\ncopies and that both that the copyright notice and this\npermission notice and warranty disclaimer appear in supporting\ndocumentation, and that the name of Lucent or any of its entities\nnot be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior\npermission.\n\nLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.\nIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY\nSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\nIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n\n\n=========================\nParts of the math library\n=========================\n\nCopyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\n\nDeveloped at SunSoft, a Sun Microsystems, Inc. business.\nPermission to use, copy, modify, and distribute this\nsoftware is freely granted, provided that this notice\nis preserved.\n\n * * * * * * *\n\nCopyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\n\nDeveloped at SunPro, a Sun Microsystems, Inc. business.\nPermission to use, copy, modify, and distribute this\nsoftware is freely granted, provided that this notice\nis preserved.\n\n * * * * * * *\n\nFIXME: Cephes math lib\nCopyright (C) 1984-1998 Stephen L. Moshier\n\nIt sounds vague, but as to be found at\n, it gives an\nimpression that the author could be willing to give an explicit\npermission to distribute those files e.g. under a BSD style license. So\nprobably there is no problem here, although it could be good to get a\npermission from the author and then add a license into the Cephes files\nin MinGW runtime. At least on follow-up it is marked that debian sees the\nversion a-like BSD one. As MinGW.org (where those cephes parts are coming\nfrom) distributes them now over 6 years, it should be fine.\n\n=================================================\nSome string, memory and time conversion functions\n=================================================\n\nCopyright © 2005-2020 Rich Felker, et al.\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n===================================\nHeaders and IDLs imported from Wine\n===================================\n\nSome header and IDL files were imported from the Wine project. These files\nare prominent maked in source. Their copyright belongs to contributors and\nthey are distributed under LGPL license.\n\nDisclaimer\n\nThis library is free software; you can redistribute it and/or\nmodify it under the terms of the GNU Lesser General Public\nLicense as published by the Free Software Foundation; either\nversion 2.1 of the License, or (at your option) any later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\nLesser General Public License for more details.\n" + "text": "MinGW-w64 runtime licensing\n***************************\n\nThis program or library was built using MinGW-w64 and statically\nlinked against the MinGW-w64 runtime. Some parts of the runtime\nare under licenses which require that the copyright and license\nnotices are included when distributing the code in binary form.\nThese notices are listed below.\n\n\n========================\nOverall copyright notice\n========================\n\nCopyright (c) 2009, 2010, 2011, 2012, 2013 by the mingw-w64 project\n\nThis license has been certified as open source. It has also been designated\nas GPL compatible by the Free Software Foundation (FSF).\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n 1. Redistributions in source code must retain the accompanying copyright\n notice, this list of conditions, and the following disclaimer.\n 2. Redistributions in binary form must reproduce the accompanying\n copyright notice, this list of conditions, and the following disclaimer\n in the documentation and/or other materials provided with the\n distribution.\n 3. Names of the copyright holders must not be used to endorse or promote\n products derived from this software without prior written permission\n from the copyright holders.\n 4. The right to distribute this software or to use it for any purpose does\n not give you the right to use Servicemarks (sm) or Trademarks (tm) of\n the copyright holders. Use of them is covered by separate agreement\n with the copyright holders.\n 5. If any files are modified, you must cause the modified files to carry\n prominent notices stating that you changed the files and the date of\n any change.\n\nDisclaimer\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED\nOR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\nOF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO\nEVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\nOR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\nEVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n======================================== \ngetopt, getopt_long, and getop_long_only\n======================================== \n\nCopyright (c) 2002 Todd C. Miller \n \nPermission to use, copy, modify, and distribute this software for any \npurpose with or without fee is hereby granted, provided that the above \ncopyright notice and this permission notice appear in all copies. \n \t \nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\nWITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\nMERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\nANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\nACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\nOR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n\nSponsored in part by the Defense Advanced Research Projects\nAgency (DARPA) and Air Force Research Laboratory, Air Force\nMateriel Command, USAF, under agreement number F39502-99-1-0512.\n\n * * * * * * * \n\nCopyright (c) 2000 The NetBSD Foundation, Inc.\nAll rights reserved.\n\nThis code is derived from software contributed to The NetBSD Foundation\nby Dieter Baron and Thomas Klausner.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n 1. Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n 2. Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS\n``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\nTO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\nINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\nCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\nARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE.\n\n\n===============================================================\ngdtoa: Converting between IEEE floating point numbers and ASCII\n===============================================================\n\nThe author of this software is David M. Gay.\n\nCopyright (C) 1997, 1998, 1999, 2000, 2001 by Lucent Technologies\nAll Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and\nits documentation for any purpose and without fee is hereby\ngranted, provided that the above copyright notice appear in all\ncopies and that both that the copyright notice and this\npermission notice and warranty disclaimer appear in supporting\ndocumentation, and that the name of Lucent or any of its entities\nnot be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior\npermission.\n\nLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.\nIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY\nSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\nIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n\n * * * * * * *\n\nThe author of this software is David M. Gay.\n\nCopyright (C) 2005 by David M. Gay\nAll Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and its\ndocumentation for any purpose and without fee is hereby granted,\nprovided that the above copyright notice appear in all copies and that\nboth that the copyright notice and this permission notice and warranty\ndisclaimer appear in supporting documentation, and that the name of\nthe author or any of his current or former employers not be used in\nadvertising or publicity pertaining to distribution of the software\nwithout specific, written prior permission.\n\nTHE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN\nNO EVENT SHALL THE AUTHOR OR ANY OF HIS CURRENT OR FORMER EMPLOYERS BE\nLIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY\nDAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\nWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\nSOFTWARE.\n\n * * * * * * *\n\nThe author of this software is David M. Gay.\n\nCopyright (C) 2004 by David M. Gay.\nAll Rights Reserved\nBased on material in the rest of /netlib/fp/gdota.tar.gz,\nwhich is copyright (C) 1998, 2000 by Lucent Technologies.\n\nPermission to use, copy, modify, and distribute this software and\nits documentation for any purpose and without fee is hereby\ngranted, provided that the above copyright notice appear in all\ncopies and that both that the copyright notice and this\npermission notice and warranty disclaimer appear in supporting\ndocumentation, and that the name of Lucent or any of its entities\nnot be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior\npermission.\n\nLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.\nIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY\nSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\nIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n\n\n=========================\nParts of the math library\n=========================\n\nCopyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\n\nDeveloped at SunSoft, a Sun Microsystems, Inc. business.\nPermission to use, copy, modify, and distribute this\nsoftware is freely granted, provided that this notice\nis preserved.\n\n * * * * * * *\n\nCopyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\n\nDeveloped at SunPro, a Sun Microsystems, Inc. business.\nPermission to use, copy, modify, and distribute this\nsoftware is freely granted, provided that this notice\nis preserved.\n\n * * * * * * *\n\nFIXME: Cephes math lib\nCopyright (C) 1984-1998 Stephen L. Moshier\n\nIt sounds vague, but as to be found at\n, it gives an\nimpression that the author could be willing to give an explicit\npermission to distribute those files e.g. under a BSD style license. So\nprobably there is no problem here, although it could be good to get a\npermission from the author and then add a license into the Cephes files\nin MinGW runtime. At least on follow-up it is marked that debian sees the\nversion a-like BSD one. As MinGW.org (where those cephes parts are coming\nfrom) distributes them now over 6 years, it should be fine.\n\n=================================================\nSome string, memory and time conversion functions\n=================================================\n\nCopyright © 2005-2020 Rich Felker, et al.\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n===================================\nHeaders and IDLs imported from Wine\n===================================\n\nSome header and IDL files were imported from the Wine project. These files\nare prominent maked in source. Their copyright belongs to contributors and\nthey are distributed under LGPL license.\n\nDisclaimer\n\nThis library is free software; you can redistribute it and/or\nmodify it under the terms of the GNU Lesser General Public\nLicense as published by the Free Software Foundation; either\nversion 2.1 of the License, or (at your option) any later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\nLesser General Public License for more details.\n" }, { "git_blob": "51261a8ec4b5c5b6b074317fab1d7f506eb30425", @@ -46,7 +46,7 @@ "sha256": "8f308316e7a94b8410f871868bd3948f126526dc1775aeee97a0e365f9a0fd9f", "source": "https://raw.githubusercontent.com/mingw-w64/mingw-w64/0d6dfbc348dfad714761c0a7151615767f96bcb5/AUTHORS", "source_revision": "0d6dfbc348dfad714761c0a7151615767f96bcb5", - "text": "Note\n====\n\nThis file contains information about people who are permitted to make\nchanges to various parts of the runtimes, headers, associated tools,\nand associated libraries. Also the list of contributors to mingw-w64\nare listed here, too.\n\nPlease do not contact the people in this file directly to report\nproblems in mingw-w64.\n\nFor general information about mingw-w64, please visit:\n\n http://sourceforge.net/projects/mingw-w64/\n\nTo report problems in mingw-w64, please visit bug-tracker on:\n\n http://sourceforge.net/projects/mingw-w64/\n\nMaintainers\n===========\n\nMook \nNightStrike \nKai Tietz \n\nDevelopers with write after approval\n====================================\n\nkjk_hyperion \nTor Lillqvist \nAlexey Pushkin \nRoland Schwingel \nOzkan Sezer \nFridrich Strba \nChris Sutcliffe \nJonathan Yong \nJarrod Chesney \nDoug Semler \nJacek Caban \nCorinna Vinschen \nAndré Hentschel \nLiu Hao \nRuslan Garipov \n\nProject members without SVN/Git access\n==================================\n\nxenofears \n\nContributors\n============\n\nWe want to thank the following list of people for supporting us\nby contributions:\n\n20-40 \nProfessor Brian Ripley \nsduplichan \nWesley W. Terpstra \nzhou drangon \nPiotr Caban \n\nand additional thanks to the following organizations:\n\nOneVision Software AG\nReactos project\nWine project\n\nand many others, we possibly missed to mention here and are sorry for this.\n\nIf you think your name is missing and should be mentioned here, please\ncontact us for adding you.\n" + "text": "Note\n====\n\nThis file contains information about people who are permitted to make\nchanges to various parts of the runtimes, headers, associated tools,\nand associated libraries. Also the list of contributors to mingw-w64\nare listed here, too.\n\nPlease do not contact the people in this file directly to report\nproblems in mingw-w64.\n\nFor general information about mingw-w64, please visit:\n\n http://sourceforge.net/projects/mingw-w64/\n\nTo report problems in mingw-w64, please visit bug-tracker on:\n\n http://sourceforge.net/projects/mingw-w64/\n\nMaintainers\n===========\n\nMook \nNightStrike \nKai Tietz \n\nDevelopers with write after approval\n====================================\n\nkjk_hyperion \nTor Lillqvist \nAlexey Pushkin \nRoland Schwingel \nOzkan Sezer \nFridrich Strba \nChris Sutcliffe \nJonathan Yong \nJarrod Chesney \nDoug Semler \nJacek Caban \nCorinna Vinschen \nAndré Hentschel \nLiu Hao \nRuslan Garipov \n\nProject members without SVN/Git access\n==================================\n\nxenofears \n\nContributors\n============\n\nWe want to thank the following list of people for supporting us\nby contributions:\n\n20-40 \nProfessor Brian Ripley \nsduplichan \nWesley W. Terpstra \nzhou drangon \nPiotr Caban \n\nand additional thanks to the following organizations:\n\nOneVision Software AG\nReactos project\nWine project\n\nand many others, we possibly missed to mention here and are sorry for this.\n\nIf you think your name is missing and should be mentioned here, please\ncontact us for adding you.\n" }, { "git_blob": "7fe7e35eff46457f65a4e30a717fada632de9e03", diff --git a/ci/test_napi_gnullvm_notices.py b/ci/test_napi_gnullvm_notices.py index d104e92..eb75ffb 100644 --- a/ci/test_napi_gnullvm_notices.py +++ b/ci/test_napi_gnullvm_notices.py @@ -40,7 +40,10 @@ def test_complete_new_original_license_is_retained(self): self.assertIn(b'Copyright (c) 2020-present LongYinan', text) self.assertIn(b'Copyright (c) 2018 GitHub', text) for item in document['original_documents']: - self.assertIn(item['text'].encode(), text) + raw = item['text'].encode('utf-8') + self.assertIn(raw, text) + self.assertEqual(hashlib.sha256(raw).hexdigest(), item['sha256']) + self.assertEqual(hashlib.sha1(b'blob ' + str(len(raw)).encode() + b'\0' + raw).hexdigest(), item['git_blob']) sources = [item for item in document['source_files'] if item['path'].endswith('crtdll_atexit_register.c')] self.assertEqual(len(sources), 1) self.assertIn('Public Domain', sources[0]['source_notices'][0]) diff --git a/scripts/napi_gnullvm_notices.py b/scripts/napi_gnullvm_notices.py index 85da2f4..e20adea 100644 --- a/scripts/napi_gnullvm_notices.py +++ b/scripts/napi_gnullvm_notices.py @@ -11,7 +11,7 @@ import urllib.request CATALOG = 'ci/licenses/napi-gnullvm-runtime.json' -CATALOG_SHA = 'f1642eb589e5481d017f5d05178e593249efd94e9eb8de8b85f203adc057a85d' +CATALOG_SHA = '0a5390a23f29fefafd13d0ff389698c9b99bc29676f251efc9beccd41de3174d' SDK_SHA = 'fd5462b7f5d93b2ff981fcd3f9c7e427e47f3203c64ea91c27bcc444eebd74cd' REVISIONS = {'mingw-w64/mingw-w64': '0d6dfbc348dfad714761c0a7151615767f96bcb5', 'llvm/llvm-project': '7a941dfb2877a0b8cf30323fefa85ad019e0b0f5', 'napi-rs/napi-rs': 'd9cb526c15e63ba30e06b4d169068c9854180595'} DATA_ONLY = {'mingw-w64-crt/crt/cinitexe.c', 'mingw-w64-crt/misc/mingw_matherr.c', 'mingw-w64-crt/misc/dllmain.c'} @@ -36,6 +36,11 @@ def catalogue(root): document = json.loads(raw) if document['sdk_archive_sha256'] != SDK_SHA or len(document['source_files']) != 61 or len(document['original_documents']) != 7: raise ValueError('GNU NAPI runtime catalogue roles differ') + for item in document['original_documents']: + original_text = item['text'].encode('utf-8') + blob = hashlib.sha1(b'blob ' + str(len(original_text)).encode() + b'\0' + original_text).hexdigest() + if hashlib.sha256(original_text).hexdigest() != item['sha256'] or blob != item['git_blob']: + raise ValueError('GNU NAPI catalogue original text identity differs: ' + item['path']) return document From 6607949b47dedc1e8aba8dc247507b659505712b Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sun, 1 Nov 2026 11:23:52 +0100 Subject: [PATCH 44/51] fix(licenses): bind the GNU NAPI loader linker input Actual linker evidence contains the existing locked libloading 0.9.0 Rust output alongside the application, std and compiler-builtins. Its full Cargo grant is already delivered. Both target SDK archive fingerprints and retained COFF object sets match the reviewed profile. Recognize only that exact crate basename under the matching-target Rust temporary output directory. Require its exact registry package identity in the bound notice. Keep all SDK bytes/object policies and unknown-library rejection unchanged. Add positive and wrong-target, wrong-crate and foreign-path regression cases. Co-Authored-By: Claude Opus 5.5 --- ci/test_napi_gnullvm_notices.py | 9 +++++++++ scripts/napi_gnullvm_notices.py | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ci/test_napi_gnullvm_notices.py b/ci/test_napi_gnullvm_notices.py index eb75ffb..f6d67bb 100644 --- a/ci/test_napi_gnullvm_notices.py +++ b/ci/test_napi_gnullvm_notices.py @@ -65,6 +65,15 @@ def test_changed_sdk_archive_or_size_is_rejected(self): with self.assertRaisesRegex(ValueError, 'SDK bytes or retained objects differ'): RUNTIME.verify_inputs(inputs, mapping, document, target) + def test_exact_target_libloading_rust_output_is_accepted(self): + for target in ['x86_64-pc-windows-gnullvm', 'aarch64-pc-windows-gnullvm']: + document, inputs, mapping, target = self.fixture(target) + inputs.append({'path': 'repro/target/' + target + '/release/deps/rustcABC/liblibloading-0123456789abcdef.rlib', 'bytes': 2122, 'sha256': '0' * 64}) + RUNTIME.verify_inputs(inputs, mapping, document, target) + for path in ['repro/target/' + target + '/release/deps/rustcABC/libforeign-0123456789abcdef.rlib', 'repro/target/foreign-target/release/deps/rustcABC/liblibloading-0123456789abcdef.rlib', 'repro/foreign/liblibloading-0123456789abcdef.rlib']: + with self.subTest(path=path), self.assertRaisesRegex(ValueError, 'outside reviewed SDK/Rust boundary'): + RUNTIME.verify_inputs(inputs + [{'path': path, 'bytes': 2122, 'sha256': '0' * 64}], mapping, document, target) + def test_unknown_native_input_is_rejected(self): document, inputs, mapping, target = self.fixture() inputs.append({'path': 'foreign/foreign.lib', 'bytes': 1, 'sha256': '0' * 64}) diff --git a/scripts/napi_gnullvm_notices.py b/scripts/napi_gnullvm_notices.py index e20adea..0ee38e1 100644 --- a/scripts/napi_gnullvm_notices.py +++ b/scripts/napi_gnullvm_notices.py @@ -153,7 +153,7 @@ def sdk_inputs(items, target): if marker not in name: cargo = r'/target/' + re.escape(target) + r'/release/deps/' rust = r'/[.]rustup/toolchains/1[.]99[.]1-x86_64-pc-windows-msvc/lib/rustlib/' + re.escape(target) + r'/lib/' - accepted = re.search(cargo + r'ktav_napi[.][^/]+[.]rcgu[.]o$', name) or re.search(cargo + r'rustc[^/]+/libstd-[0-9a-f]+[.]rlib$', name) or re.search(rust + r'libcompiler_builtins-[0-9a-f]+[.]rlib$', name) + accepted = re.search(cargo + r'ktav_napi[.][^/]+[.]rcgu[.]o$', name) or re.search(cargo + r'rustc[^/]+/lib(?:std|libloading)-[0-9a-f]+[.]rlib$', name) or re.search(rust + r'libcompiler_builtins-[0-9a-f]+[.]rlib$', name) if not accepted: raise ValueError('native linker input outside reviewed SDK/Rust boundary') continue @@ -188,6 +188,9 @@ def verify(evidence, binary, target): raw = read(binary, 128 * 1024 * 1024) notice = read(evidence / 'NOTICE.json', MAX_TOTAL) before = json.loads(read(evidence / 'NOTICE.cargo-std.json', MAX_TOTAL)) + loading = [item for item in before['packages'] if item['name'] == 'libloading'] + if loading != [{'name': 'libloading', 'version': '0.9.0', 'source': 'registry+https://github.com/rust-lang/crates.io-index'}]: + raise ValueError('GNU NAPI dynamic-loader Cargo identity differs') if json.loads(notice) != augment(before, document, target) or scanner._extract(raw)[0] != notice: raise ValueError('actual GNU NAPI runtime resource differs') if read(evidence / 'NOTICE.windows-runtime.txt', MAX_TOTAL) != plain_notice(document): From 56bf7a3cdfa8ca5474a203f5de0fa60b1e2713a7 Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sun, 1 Nov 2026 11:54:57 +0100 Subject: [PATCH 45/51] ci(licenses): preserve complete native npm role payloads Prepare a shared source-bound NAPI/CABI staging and assembly contract. Keep actual compiler targets separate from compatibility filenames. Validate CPU/library kind, exact embedded and compressed notices, original and explicit derivative locks, core identity, producer proofs and every mandatory legal/source role before assembly. Retain distinct complete third-party trees for both native roles, original first-party licenses, relocation provenance and complete file manifests. Reject a missing legal role even if an input or package manifest is rewritten to hide the omission. Add isolated CI regressions for source/resource/metadata/path boundaries. This preparation does not yet wire production producers, pack npm containers, change versions or run any publication job. Those remain separate acceptance gates; historical packages are unchanged. Co-Authored-By: Claude Opus 5.5 --- .../workflows/native-npm-assembly-check.yml | 20 ++ ci/test_native_npm_payload.py | 229 +++++++++++++++ scripts/assemble_native_npm.py | 145 +++++++++ scripts/native_npm_payload.py | 278 ++++++++++++++++++ 4 files changed, 672 insertions(+) create mode 100644 .github/workflows/native-npm-assembly-check.yml create mode 100644 ci/test_native_npm_payload.py create mode 100644 scripts/assemble_native_npm.py create mode 100644 scripts/native_npm_payload.py diff --git a/.github/workflows/native-npm-assembly-check.yml b/.github/workflows/native-npm-assembly-check.yml new file mode 100644 index 0000000..e2a4a70 --- /dev/null +++ b/.github/workflows/native-npm-assembly-check.yml @@ -0,0 +1,20 @@ +name: Native npm payload and assembly guards + +on: + pull_request: + +permissions: + contents: read + +jobs: + payload-contract: + name: Complete native npm role contracts + runs-on: ubuntu-24.04 + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: Reject missing legal/source roles and altered native identities + run: python -I -m unittest discover -s ci -p test_native_npm_payload.py -v diff --git a/ci/test_native_npm_payload.py b/ci/test_native_npm_payload.py new file mode 100644 index 0000000..4a11795 --- /dev/null +++ b/ci/test_native_npm_payload.py @@ -0,0 +1,229 @@ +"""Проверить fail-closed native npm role layout без выполнения binaries.""" + +import contextlib +import gzip +import json +import os +from pathlib import Path +import struct +import sys +import tempfile +import unittest +from unittest.mock import patch + +ROOT = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(ROOT / 'scripts')) +import native_npm_payload as PAYLOAD +import assemble_native_npm as ASSEMBLY + + +@contextlib.contextmanager +def cwd(path): + before = Path.cwd() + os.chdir(path) + try: + yield + finally: + os.chdir(before) + + +class PayloadTests(unittest.TestCase): + def fixture(self, temporary, role='napi'): + root = Path(temporary) + evidence = root / ('evidence-' + role) + evidence.mkdir() + for name in PAYLOAD.LICENSES: + (root / name).write_bytes((ROOT / name).read_bytes()) + lock = ('version = 3\n\n[[package]]\nname = "ktav"\nversion = "0.8.1"\nchecksum = "' + PAYLOAD.CORE + '"\n').encode() + notice = (json.dumps({'schema_version': 1, 'cargo_lock_sha256': PAYLOAD.sha(lock)}) + '\n').encode() + compressed = gzip.compress(notice, mtime=0) + raw = bytearray(32) + raw[:4] = bytes.fromhex('cffaedfe') + struct.pack_into(' limit: + raise ValueError('payload input exceeds bound') + return raw + + +def relative(name): + path = PurePosixPath(name) + if not path.parts or path.is_absolute() or '..' in path.parts or chr(92) in name or ':' in name: + raise ValueError('unsafe payload path') + return path + + +def identity(rid, role): + if rid not in TARGETS or role not in {'napi', 'cabi'}: + raise ValueError('unreviewed native package role') + target = TARGETS[rid] + filename = 'ktav.' + rid + '.node' if role == 'napi' else ('ktav_cabi.dll' if rid.startswith('win32-') else 'libktav_cabi.' + ('dylib' if rid.startswith('darwin-') else 'so')) + return target, filename + + +def cpu(raw, target): + arm = target.startswith('aarch64-') + if target.endswith('-apple-darwin'): + if len(raw) < 32 or raw[:4] != b'\xcf\xfa\xed\xfe' or struct.unpack_from(' len(raw) or raw[offset:offset + 4] != b'PE\0\0' or struct.unpack_from('= 4096 or total > 256 * 1024 * 1024: + raise ValueError('payload inventory exceeds bound') + result.append({'path': name, 'bytes': len(raw), 'sha256': sha(raw)}) + return result + + +def check_manifest(root, manifest_name): + document = json.loads(read(root / manifest_name, 4 * 1024 * 1024)) + rows = document['files'] + if len(rows) != len({item['path'] for item in rows}): + raise ValueError('duplicate manifest role') + actual = [item for item in files(root) if item['path'] != manifest_name] + if sorted(rows, key=lambda item: item['path']) != actual: + raise ValueError('complete native payload manifest differs') + return document + + +def contract(root, rid, role): + document = check_manifest(root, 'native-role-manifest.json') + target, filename = identity(rid, role) + if document['schema_version'] != 1 or document['rid'] != rid or document['role'] != role or document['actual_target'] != target or document['source_ref'] != SOURCE or document['package_binary'] != filename: + raise ValueError('native role identity differs') + raw = read(root / 'binary', 128 * 1024 * 1024) + notice = read(root / 'legal/NOTICE.json') + cpu(raw, target) + decoded, compressed_bytes = _extract(raw) + start = raw.index(MARKER) + len(MARKER) + 8 + if sha(raw) != document['binary_sha256'] or sha(notice) != document['notice_sha256'] or decoded != notice or raw[start:start + compressed_bytes] != read(root / 'legal/NOTICE.json.gz', 4 * 1024 * 1024): + raise ValueError('native role actual resource identity differs') + for name, expected in LICENSES.items(): + if sha(read(root / name, 64 * 1024)) != expected: + raise ValueError('original first-party license differs') + required = set(COMMON) + trees = {} + if target.endswith('-gnullvm') and role == 'napi': + original = json.loads(read(root / 'legal/native-payload-manifest.json', 4 * 1024 * 1024)) + original_paths = {item['path'] for item in original['files']} + source_roles = {'source/project-original.tar', 'source/napi-3.15.0-source.tar.gz', 'source/README.txt', 'source/overlays/.cargo/config.toml', 'source/overlays/crates/napi/build.rs', 'source/overlays/crates/napi/Cargo.toml', 'source/overlays/crates/napi/src/lib.rs'} + if original['target'] != target or original['source_ref'] != SOURCE or original['binary_sha256'] != sha(raw) or original['notice_sha256'] != sha(notice) or len(original['files']) != 106 or len(original_paths) != 106 or not source_roles.issubset(original_paths) or sum(name.startswith('runtime-originals/') for name in original_paths) != 68 or sum(name.startswith('rust-compiler-originals/') for name in original_paths) != 14: + raise ValueError('complete GNU NAPI producer role set differs') + for item in original['files']: + path = relative(item['path']) + content = raw if str(path) == 'ktav_napi.node' else read(root / 'legal' / path, 128 * 1024 * 1024) + if len(content) != item['bytes'] or sha(content) != item['sha256']: + raise ValueError('GNU NAPI original producer role changed') + required = {item['path'] for item in original['files'] if item['path'] != 'ktav_napi.node'} | {'native-payload-manifest.json'} + elif target.endswith('-apple-darwin'): + required.update([role + '-macos-verification.json', role + '-embedded-verification.json', role + '-native-link.map']) + elif target.endswith('-musl'): + required.update(MUSL) + required.update(role + '/' + name for name in ['Cargo.lock', 'NOTICE.json', 'NOTICE.json.gz', 'NOTICE.cargo-std.json', 'NOTICE.musl-runtime.txt', 'musl-runtime-catalog.json', 'source-provenance.json', 'native-verification.json', 'retained-runtime-verification.json', 'embedded-verification.json', 'native-link-command.json', 'native-link.map']) + trees = {'runtime-rust-originals': 13} + elif target.endswith('-gnullvm'): + required.update(WINDOWS_CABI) + trees = {'runtime-originals': 64} + else: + required.update(GNU_NAPI if role == 'napi' else GNU_CABI) + actual = {item['path'] for item in document['files']} + for tree, count in trees.items(): + members = [name for name in actual if name.startswith('legal/' + tree + '/')] + if len(members) != count: + raise ValueError('mandatory original source tree roles differ') + required.update(name.removeprefix('legal/') for name in members) + if actual != {'binary', *LICENSES} | {'legal/' + name for name in required}: + raise ValueError('mandatory native legal/source role set differs') + lock = read(root / 'legal/Cargo.lock', 4 * 1024 * 1024) + bundle = json.loads(notice) + cores = [item for item in tomllib.loads(lock.decode())['package'] if item['name'] == 'ktav'] + if bundle.get('schema_version') != 1 or bundle['cargo_lock_sha256'] != sha(lock) or len(cores) != 1 or cores[0]['version'] != '0.8.1' or cores[0].get('checksum') != CORE: + raise ValueError('actual native source/core/lock identity differs') + windows_napi = target.endswith('-gnullvm') and role == 'napi' + if not windows_napi and sha(lock) != LOCK: + raise ValueError('original reviewed native lock differs') + provenance = json.loads(read(root / 'legal' / ('source-variant.json' if windows_napi else 'source-provenance.json'))) + if windows_napi: + original_lock = read(root / 'legal/Cargo.original.lock', 4 * 1024 * 1024) + if sha(original_lock) != LOCK or lock != read(root / 'legal/Cargo.variant.lock', 4 * 1024 * 1024) or provenance['variant_lock_sha256'] != sha(lock) or bundle['source_variant'] != provenance: + raise ValueError('explicit derivative native graph identity differs') + verify_lock(tomllib.loads(original_lock.decode()), tomllib.loads(lock.decode())) + proof_name = ('native-runtime-verification.json' if target.endswith('-gnullvm') else role + '-macos-verification.json' if target.endswith('-apple-darwin') else role + '/retained-runtime-verification.json' if target.endswith('-musl') else 'gnu-runtime-verification.json' if role == 'napi' else 'native-gnu-verification.json') + proof = json.loads(read(root / 'legal' / proof_name)) + if provenance['source_ref'] != SOURCE or provenance['tooling_ref'] != document['tooling_ref'] or proof['target'] != target or proof['binary_sha256'] != sha(raw) or proof.get('role', role) != role or proof.get('notice_sha256', sha(notice)) != sha(notice): + raise ValueError('actual producer source/target/resource proof differs') + return document + + +def stage(evidence, output, rid, role): + target, filename = identity(rid, role) + if evidence.is_symlink() or not evidence.is_dir(): + raise ValueError('invalid producer evidence directory') + entries = list(evidence.rglob('*')) + if len(entries) > 8192 or any(path.is_symlink() or not (path.is_file() or path.is_dir()) for path in entries): + raise ValueError('unsafe or oversized producer evidence tree') + if output.resolve().is_relative_to(evidence.resolve()): + raise ValueError('payload output must be outside producer evidence') + windows_napi = target.endswith('-gnullvm') and role == 'napi' + binary = evidence / ('ktav_napi.node' if windows_napi else filename) + if target.endswith('-musl'): + binary = evidence / role / filename + raw = read(binary, 128 * 1024 * 1024) + cpu(raw, target) + notice = read(evidence / 'NOTICE.json') + if _extract(raw)[0] != notice: + raise ValueError('producer binary does not retain actual notice') + bundle = json.loads(notice) + lock = read(evidence / 'Cargo.lock', 4 * 1024 * 1024) + if bundle['cargo_lock_sha256'] != sha(lock): + raise ValueError('native resource lock identity differs') + cores = [item for item in tomllib.loads(lock.decode())['package'] if item['name'] == 'ktav'] + if len(cores) != 1 or cores[0]['version'] != '0.8.1' or cores[0].get('checksum') != CORE: + raise ValueError('native resource registry core differs') + selected = list(COMMON) + trees = [] + if windows_napi: + producer = check_manifest(evidence, 'native-payload-manifest.json') + if producer['target'] != target or producer['source_ref'] != SOURCE or producer['binary_sha256'] != sha(raw) or producer['notice_sha256'] != sha(notice): + raise ValueError('GNU NAPI producer manifest identity differs') + selected = [item['path'] for item in producer['files'] if item['path'] != 'ktav_napi.node'] + ['native-payload-manifest.json'] + provenance = json.loads(read(evidence / 'source-variant.json')) + proof = json.loads(read(evidence / 'native-runtime-verification.json')) + if sha(read(evidence / 'Cargo.original.lock', 4 * 1024 * 1024)) != LOCK or bundle['source_variant'] != provenance or sha(lock) != provenance['variant_lock_sha256']: + raise ValueError('explicit derivative source/lock differs') + else: + if sha(lock) != LOCK: + raise ValueError('original reviewed lock differs') + provenance = json.loads(read(evidence / 'source-provenance.json')) + if target.endswith('-apple-darwin'): + selected += [role + '-macos-verification.json', role + '-embedded-verification.json', role + '-native-link.map'] + proof = json.loads(read(evidence / (role + '-macos-verification.json'))) + elif target.endswith('-musl'): + selected += MUSL + trees = ['runtime-rust-originals'] + selected += [role + '/' + name for name in ['Cargo.lock', 'NOTICE.json', 'NOTICE.json.gz', 'NOTICE.cargo-std.json', 'NOTICE.musl-runtime.txt', 'musl-runtime-catalog.json', 'source-provenance.json', 'native-verification.json', 'retained-runtime-verification.json', 'embedded-verification.json', 'native-link-command.json', 'native-link.map']] + proof = json.loads(read(evidence / role / 'retained-runtime-verification.json')) + if read(evidence / role / 'NOTICE.json') != notice: + raise ValueError('musl role notice differs from complete source collection') + elif target.endswith('-gnullvm'): + selected += WINDOWS_CABI + trees = ['runtime-originals'] + proof = json.loads(read(evidence / 'native-runtime-verification.json')) + elif role == 'napi': + selected += GNU_NAPI + proof = json.loads(read(evidence / 'gnu-runtime-verification.json')) + else: + selected += GNU_CABI + proof = json.loads(read(evidence / 'native-gnu-verification.json')) + if provenance['source_ref'] != SOURCE or proof['target'] != target or proof['binary_sha256'] != sha(raw) or proof.get('role', role) != role: + raise ValueError('producer source/target/binary proof differs') + if 'notice_sha256' in proof and proof['notice_sha256'] != sha(notice): + raise ValueError('producer actual notice proof differs') + for tree in trees: + entries = files(evidence / tree) + if not entries: + raise ValueError('mandatory original source tree is empty') + selected.extend(tree + '/' + item['path'] for item in entries) + if len(selected) != len(set(selected)): + raise ValueError('duplicate native source/legal role') + output.mkdir() + (output / 'legal').mkdir() + shutil.copyfile(binary, output / 'binary') + for name in selected: + relative(name) + original = evidence / name + content = read(original, 128 * 1024 * 1024) + destination = output / 'legal' / name + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(content) + for name, expected in LICENSES.items(): + content = read(Path(name), 64 * 1024) + if sha(content) != expected: + raise ValueError('source checkout first-party license differs') + (output / name).write_bytes(content) + document = {'schema_version': 1, 'rid': rid, 'role': role, 'actual_target': target, 'package_binary': filename, 'source_ref': SOURCE, 'tooling_ref': provenance['tooling_ref'], 'binary_sha256': sha(raw), 'notice_sha256': sha(notice), 'files': files(output), 'scope': 'Complete source-bound native role payload for npm assembly. Compatibility filenames do not identify the compiler target; historical package or native execution clearance is not implied.'} + (output / 'native-role-manifest.json').write_text(json.dumps(document, ensure_ascii=False, sort_keys=True, indent=2) + '\n', encoding='utf-8') + contract(output, rid, role) + print(json.dumps({'rid': rid, 'role': role, 'actual_target': target, 'binary_sha256': sha(raw), 'notice_sha256': sha(notice), 'files': len(document['files'])})) + + +if __name__ == '__main__': + if len(sys.argv) != 5: + raise SystemExit('usage: native_npm_payload.py EVIDENCE NEW_OUTPUT RID ROLE') + stage(Path(sys.argv[1]), Path(sys.argv[2]), sys.argv[3], sys.argv[4]) From 7a3407ab436480de0fd69dad22cb2a501a86d203 Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sun, 1 Nov 2026 13:18:16 +0100 Subject: [PATCH 46/51] ci(licenses): share the verified native npm release path Reuse all reviewed original-0.8.1 native and WASM producers through one non-publishing build/pack workflow. Keep their compiler matrices, flags, source/input/resource and native consumer gates intact. Stage all sixteen complete native roles only after successful gates. Pack eight native packages and the verified main package through the shared assembler. Inspect actual archive contents, complete legal and source roles, relocation manifests and original/derivative identities. Generate the platform documentation from the EN/RU/ZH source unit and record actual compiler targets independently of compatibility names. Make production release consume the same verified nine tarballs, with archive re-verification before publication. Keep existing tag, dry-run, environment and OIDC publication guards; dispatch no publisher job, create no tag/release and change no dependency or product version. Generated checked-in documentation is synchronized from CI separately. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/gnu-cabi-notice-check.yml | 30 +- .../workflows/macos-native-notice-check.yml | 36 ++- .../workflows/musl-native-notice-check.yml | 36 ++- .github/workflows/napi-notice-check.yml | 30 +- .../workflows/native-npm-assembly-check.yml | 9 +- .../workflows/native-npm-release-build.yml | 107 +++++++ .github/workflows/release.yml | 278 ++---------------- .github/workflows/wasm-notice-check.yml | 82 +++++- .../workflows/windows-cabi-gnullvm-check.yml | 30 +- .../windows-gnu-napi-variant-check.yml | 30 +- ci/test_native_npm_payload.py | 36 +++ root-docs/PLATFORM-README/overview/body-1.md | 50 +++- scripts/check_native_npm.py | 60 ++++ scripts/check_release_npm.py | 60 ++++ scripts/pack_native_npm.py | 118 ++++++++ 15 files changed, 702 insertions(+), 290 deletions(-) create mode 100644 .github/workflows/native-npm-release-build.yml create mode 100644 scripts/check_native_npm.py create mode 100644 scripts/check_release_npm.py create mode 100644 scripts/pack_native_npm.py diff --git a/.github/workflows/gnu-cabi-notice-check.yml b/.github/workflows/gnu-cabi-notice-check.yml index 2a3deff..9f0391c 100644 --- a/.github/workflows/gnu-cabi-notice-check.yml +++ b/.github/workflows/gnu-cabi-notice-check.yml @@ -1,7 +1,7 @@ name: Linux GNU C ABI notice evidence on: - pull_request: + workflow_call: permissions: contents: read @@ -31,7 +31,7 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'gnu-cabi-tools' stage.mkdir() - names = ['Cargo.lock', 'ci/js-build-lock.json', 'crates/cabi/build.rs', 'scripts/patch_cabi_notice_source.py', 'ci/test_cabi_notice_overlay.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json', 'scripts/zig_runtime_notices.py', 'scripts/capture-zig-link.sh', 'scripts/check_gnu_cabi_evidence.py', 'ci/zig-runtime-catalog.json', 'ci/test_gnu_cabi_notices.py'] + names = ['scripts/native_npm_payload.py', 'scripts/windows_gnu_napi_variant.py', 'Cargo.lock', 'ci/js-build-lock.json', 'crates/cabi/build.rs', 'scripts/patch_cabi_notice_source.py', 'ci/test_cabi_notice_overlay.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json', 'scripts/zig_runtime_notices.py', 'scripts/capture-zig-link.sh', 'scripts/check_gnu_cabi_evidence.py', 'ci/zig-runtime-catalog.json', 'ci/test_gnu_cabi_notices.py'] for name in names: path = stage / name path.parent.mkdir(parents=True, exist_ok=True) @@ -184,6 +184,32 @@ jobs: raise SystemExit('actual consumer library bytes changed') record = {'binary_sha256': hashlib.sha256(binary.read_bytes()).hexdigest(), 'target': os.environ['CABI_TARGET'], 'actual_bun_corpus': True, 'actual_deno_corpus': True, 'sdk_paths_removed': True, 'scope': 'Matching-x64 C ABI corpus only; ARM cross binary inspected, not executed.'} (evidence / 'consumer-verification.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') + - name: Stage complete source-bound native npm roles + env: + NPM_TARGET: ${{ matrix.target }} + shell: python + run: | + import os + from pathlib import Path + import subprocess + import sys + sys.path.insert(0, str(Path('scripts').resolve())) + from native_npm_payload import TARGETS + target = os.environ['NPM_TARGET'] + rid = next(name for name, value in TARGETS.items() if value == target) + root = Path(os.environ['RUNNER_TEMP']) + evidence = root / 'gnu-cabi-evidence' + for role in ['cabi']: + output = root / ('native-npm-' + rid + '-' + role) + subprocess.run([sys.executable, '-I', 'scripts/native_npm_payload.py', str(evidence), str(output), rid, role], check=True) + with Path(os.environ['GITHUB_ENV']).open('a', encoding='utf-8') as destination: + destination.write('NPM_RID=' + rid + '\n') + - uses: actions/upload-artifact@v4 + with: + name: ${{ env.NPM_RID }}-cabi + path: ${{ runner.temp }}/native-npm-${{ env.NPM_RID }}-cabi/ + include-hidden-files: true + if-no-files-found: error - uses: actions/upload-artifact@v4 if: always() with: diff --git a/.github/workflows/macos-native-notice-check.yml b/.github/workflows/macos-native-notice-check.yml index b41ee33..40f6974 100644 --- a/.github/workflows/macos-native-notice-check.yml +++ b/.github/workflows/macos-native-notice-check.yml @@ -1,7 +1,7 @@ name: macOS native runtime evidence on: - pull_request: + workflow_call: permissions: contents: read @@ -34,7 +34,7 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'macos-native-tools' stage.mkdir() - names = ['Cargo.lock', 'ci/js-build-lock.json', 'crates/napi/build.rs', 'crates/cabi/build.rs', 'scripts/patch_napi_notice_source.py', 'scripts/patch_cabi_notice_source.py', 'ci/test_cabi_notice_overlay.py', 'scripts/macos_native_evidence.py', 'ci/test_macos_native_evidence.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json'] + names = ['scripts/native_npm_payload.py', 'scripts/windows_gnu_napi_variant.py', 'Cargo.lock', 'ci/js-build-lock.json', 'crates/napi/build.rs', 'crates/cabi/build.rs', 'scripts/patch_napi_notice_source.py', 'scripts/patch_cabi_notice_source.py', 'ci/test_cabi_notice_overlay.py', 'scripts/macos_native_evidence.py', 'ci/test_macos_native_evidence.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json'] for name in names: destination = stage / name destination.parent.mkdir(parents=True, exist_ok=True) @@ -176,6 +176,38 @@ jobs: subprocess.run(['node', '--input-type=module', '-e', script], check=True) report = {'target': os.environ['MACOS_TARGET'], 'host_node_arch': host, 'native_execution': native, 'napi_binary_sha256': hashlib.sha256((evidence / os.environ['NAPI_ADDON']).read_bytes()).hexdigest(), 'scope': 'Matching-CPU NAPI consumer only; CABI binary inspected as data, not executed by this step.'} (evidence / 'execution-scope.json').write_text(json.dumps(report, sort_keys=True, indent=2) + '\n', encoding='utf-8') + - name: Stage complete source-bound native npm roles + env: + NPM_TARGET: ${{ matrix.target }} + shell: python + run: | + import os + from pathlib import Path + import subprocess + import sys + sys.path.insert(0, str(Path('scripts').resolve())) + from native_npm_payload import TARGETS + target = os.environ['NPM_TARGET'] + rid = next(name for name, value in TARGETS.items() if value == target) + root = Path(os.environ['RUNNER_TEMP']) + evidence = root / 'macos-native-notices' + for role in ['napi', 'cabi']: + output = root / ('native-npm-' + rid + '-' + role) + subprocess.run([sys.executable, '-I', 'scripts/native_npm_payload.py', str(evidence), str(output), rid, role], check=True) + with Path(os.environ['GITHUB_ENV']).open('a', encoding='utf-8') as destination: + destination.write('NPM_RID=' + rid + '\n') + - uses: actions/upload-artifact@v4 + with: + name: ${{ env.NPM_RID }}-napi + path: ${{ runner.temp }}/native-npm-${{ env.NPM_RID }}-napi/ + include-hidden-files: true + if-no-files-found: error + - uses: actions/upload-artifact@v4 + with: + name: ${{ env.NPM_RID }}-cabi + path: ${{ runner.temp }}/native-npm-${{ env.NPM_RID }}-cabi/ + include-hidden-files: true + if-no-files-found: error - uses: actions/upload-artifact@v4 if: always() with: diff --git a/.github/workflows/musl-native-notice-check.yml b/.github/workflows/musl-native-notice-check.yml index 146f1c3..14ea405 100644 --- a/.github/workflows/musl-native-notice-check.yml +++ b/.github/workflows/musl-native-notice-check.yml @@ -1,7 +1,7 @@ name: Musl native notice and input evidence on: - pull_request: + workflow_call: permissions: contents: read @@ -53,7 +53,7 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'musl-notice-tools' stage.mkdir() - names = ['Cargo.lock', 'ci/js-build-lock.json', 'crates/napi/build.rs', 'crates/cabi/build.rs', 'scripts/patch_napi_notice_source.py', 'scripts/patch_cabi_notice_source.py', 'ci/test_cabi_notice_overlay.py', 'ci/test_napi_notice_overlay.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json', 'scripts/capture-zig-link.sh', 'scripts/musl_native_evidence.py', 'ci/musl-runtime-catalog.json', 'ci/test_musl_native_evidence.py'] + names = ['scripts/native_npm_payload.py', 'scripts/windows_gnu_napi_variant.py', 'Cargo.lock', 'ci/js-build-lock.json', 'crates/napi/build.rs', 'crates/cabi/build.rs', 'scripts/patch_napi_notice_source.py', 'scripts/patch_cabi_notice_source.py', 'ci/test_cabi_notice_overlay.py', 'ci/test_napi_notice_overlay.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json', 'scripts/capture-zig-link.sh', 'scripts/musl_native_evidence.py', 'ci/musl-runtime-catalog.json', 'ci/test_musl_native_evidence.py'] retained = Path('ci/musl-retained-runtime.json').read_bytes() if hashlib.sha256(retained).hexdigest() != 'ed6146168bd64b5022037c7a4ff30e71a21da74b07c697aa848799520166c1b5': raise SystemExit('unreviewed retained musl source profile') @@ -250,6 +250,38 @@ jobs: raise SystemExit(role + ' actual musl corpus failed:\n' + sys_stdout + '\n' + sys_stderr) record = {'target': os.environ['MUSL_TARGET'], 'native_runner_arch': platform.machine(), 'node_napi_corpus': True, 'bun_cabi_corpus': True, 'emulated': False, 'napi_sha256': hashlib.sha256((stage / 'dist/native' / os.environ['MUSL_ADDON']).read_bytes()).hexdigest(), 'cabi_sha256': hashlib.sha256((stage / 'cabi/release/libktav_cabi.so').read_bytes()).hexdigest(), 'bun_archive_sha256': checksum.hexdigest(), 'node_image': image, 'scope': 'Actual matching-CPU Alpine Node/Bun corpus execution. Exact source/grant gates are separate; no Deno-musl or production npm delivery claim.'} (evidence / 'consumer-verification.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') + - name: Stage complete source-bound native npm roles + env: + NPM_TARGET: ${{ matrix.target }} + shell: python + run: | + import os + from pathlib import Path + import subprocess + import sys + sys.path.insert(0, str(Path('scripts').resolve())) + from native_npm_payload import TARGETS + target = os.environ['NPM_TARGET'] + rid = next(name for name, value in TARGETS.items() if value == target) + root = Path(os.environ['RUNNER_TEMP']) + evidence = root / 'musl-native-evidence' + for role in ['napi', 'cabi']: + output = root / ('native-npm-' + rid + '-' + role) + subprocess.run([sys.executable, '-I', 'scripts/native_npm_payload.py', str(evidence), str(output), rid, role], check=True) + with Path(os.environ['GITHUB_ENV']).open('a', encoding='utf-8') as destination: + destination.write('NPM_RID=' + rid + '\n') + - uses: actions/upload-artifact@v4 + with: + name: ${{ env.NPM_RID }}-napi + path: ${{ runner.temp }}/native-npm-${{ env.NPM_RID }}-napi/ + include-hidden-files: true + if-no-files-found: error + - uses: actions/upload-artifact@v4 + with: + name: ${{ env.NPM_RID }}-cabi + path: ${{ runner.temp }}/native-npm-${{ env.NPM_RID }}-cabi/ + include-hidden-files: true + if-no-files-found: error - uses: actions/upload-artifact@v4 if: always() with: diff --git a/.github/workflows/napi-notice-check.yml b/.github/workflows/napi-notice-check.yml index 66a8770..bb97171 100644 --- a/.github/workflows/napi-notice-check.yml +++ b/.github/workflows/napi-notice-check.yml @@ -1,7 +1,7 @@ name: NAPI GNU runtime evidence on: - pull_request: + workflow_call: permissions: contents: read @@ -31,7 +31,7 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'napi-notice-tools' stage.mkdir() - for name in ['ci/napi-gnu-rust-builtins.json', *[str(path) for path in Path('ci/licenses/musl-rust-originals').glob('*.txt')], 'crates/napi/build.rs', 'scripts/patch_napi_notice_source.py', 'ci/test_napi_notice_overlay.py', 'scripts/check_embedded_notices.py', 'Cargo.lock', 'ci/js-build-lock.json', 'ci/test_js_build_lock.py', 'scripts/capture_napi_cross_link.py', 'scripts/collect_napi_link_evidence.py', 'ci/test_napi_cross_link.py', 'ci/napi-gnu-sdk-inputs.json', 'ci/licenses/napi-gnu-runtime.json', 'ci/test_napi_gnu_runtime_notices.py', 'scripts/napi_gnu_runtime_notices.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json']: + for name in ['scripts/native_npm_payload.py', 'scripts/windows_gnu_napi_variant.py', 'ci/napi-gnu-rust-builtins.json', *[str(path) for path in Path('ci/licenses/musl-rust-originals').glob('*.txt')], 'crates/napi/build.rs', 'scripts/patch_napi_notice_source.py', 'ci/test_napi_notice_overlay.py', 'scripts/check_embedded_notices.py', 'Cargo.lock', 'ci/js-build-lock.json', 'ci/test_js_build_lock.py', 'scripts/capture_napi_cross_link.py', 'scripts/collect_napi_link_evidence.py', 'ci/test_napi_cross_link.py', 'ci/napi-gnu-sdk-inputs.json', 'ci/licenses/napi-gnu-runtime.json', 'ci/test_napi_gnu_runtime_notices.py', 'scripts/napi_gnu_runtime_notices.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json']: target = stage / name target.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(name, target) @@ -151,6 +151,32 @@ jobs: mkdir -p dist/native cp ${{ matrix.addon }} dist/native/${{ matrix.addon }} node --input-type=module -e 'import assert from "node:assert/strict";import {createRequire} from "node:module";import {readFileSync,realpathSync,writeFileSync} from "node:fs";import {createHash} from "node:crypto";await import("./dist/ts/node.js");const require=createRequire(import.meta.url);const expected=realpathSync("dist/native/ktav.linux-x64-gnu.node");assert.deepEqual(Object.keys(require.cache).filter(p=>p.endsWith(".node")),[expected]);writeFileSync(process.env.RUNNER_TEMP+"/napi-notices/consumer.json",JSON.stringify({loaded_built_addon:true,binary_sha256:createHash("sha256").update(readFileSync(expected)).digest("hex")}));await import("./tests/node/run-node-napi.mjs");' + - name: Stage complete source-bound native npm roles + env: + NPM_TARGET: ${{ matrix.target }} + shell: python + run: | + import os + from pathlib import Path + import subprocess + import sys + sys.path.insert(0, str(Path('scripts').resolve())) + from native_npm_payload import TARGETS + target = os.environ['NPM_TARGET'] + rid = next(name for name, value in TARGETS.items() if value == target) + root = Path(os.environ['RUNNER_TEMP']) + evidence = root / 'napi-notices' + for role in ['napi']: + output = root / ('native-npm-' + rid + '-' + role) + subprocess.run([sys.executable, '-I', 'scripts/native_npm_payload.py', str(evidence), str(output), rid, role], check=True) + with Path(os.environ['GITHUB_ENV']).open('a', encoding='utf-8') as destination: + destination.write('NPM_RID=' + rid + '\n') + - uses: actions/upload-artifact@v4 + with: + name: ${{ env.NPM_RID }}-napi + path: ${{ runner.temp }}/native-npm-${{ env.NPM_RID }}-napi/ + include-hidden-files: true + if-no-files-found: error - uses: actions/upload-artifact@v4 if: always() with: diff --git a/.github/workflows/native-npm-assembly-check.yml b/.github/workflows/native-npm-assembly-check.yml index e2a4a70..524ef07 100644 --- a/.github/workflows/native-npm-assembly-check.yml +++ b/.github/workflows/native-npm-assembly-check.yml @@ -1,7 +1,7 @@ name: Native npm payload and assembly guards on: - pull_request: + workflow_call: permissions: contents: read @@ -16,5 +16,12 @@ jobs: - uses: actions/setup-python@v5 with: python-version: '3.12' + - name: Require the reviewed version for tag-triggered builds + shell: python + run: | + import os + ref = os.environ['GITHUB_REF'] + if ref.startswith('refs/tags/') and ref != 'refs/tags/v0.8.1': + raise SystemExit('this source-bound release path requires separate review for a different version') - name: Reject missing legal/source roles and altered native identities run: python -I -m unittest discover -s ci -p test_native_npm_payload.py -v diff --git a/.github/workflows/native-npm-release-build.yml b/.github/workflows/native-npm-release-build.yml new file mode 100644 index 0000000..e3e688d --- /dev/null +++ b/.github/workflows/native-npm-release-build.yml @@ -0,0 +1,107 @@ +name: Source-bound native npm release build + +on: + pull_request: + workflow_call: + +permissions: + contents: read + +jobs: + contracts: + uses: ./.github/workflows/native-npm-assembly-check.yml + gnu-napi: + needs: contracts + uses: ./.github/workflows/napi-notice-check.yml + gnu-cabi: + needs: contracts + uses: ./.github/workflows/gnu-cabi-notice-check.yml + macos-native: + needs: contracts + uses: ./.github/workflows/macos-native-notice-check.yml + musl-native: + needs: contracts + uses: ./.github/workflows/musl-native-notice-check.yml + windows-cabi: + needs: contracts + uses: ./.github/workflows/windows-cabi-gnullvm-check.yml + windows-napi: + needs: contracts + uses: ./.github/workflows/windows-gnu-napi-variant-check.yml + wasm: + needs: contracts + uses: ./.github/workflows/wasm-notice-check.yml + assemble: + name: Pack eight native packages and the main package + needs: [gnu-napi, gnu-cabi, macos-native, musl-native, windows-cabi, windows-napi, wasm] + runs-on: ubuntu-24.04 + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 + - name: Preserve only the shared assembly and validation tooling + shell: python + run: | + import os + from pathlib import Path + import shutil + stage = Path(os.environ['RUNNER_TEMP']) / 'native-npm-assembly-tools' + stage.mkdir() + for name in ['scripts/native_npm_payload.py', 'scripts/assemble_native_npm.py', 'scripts/check_native_npm.py', 'scripts/check_release_npm.py', 'scripts/pack_native_npm.py', 'scripts/check_wasm_npm.py', 'scripts/check_embedded_notices.py', 'scripts/windows_gnu_napi_variant.py']: + destination = stage / name + destination.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(name, destination) + - uses: actions/checkout@v4 + with: + ref: 562deb3fde092d63a78f359be095e5079929d0d1 + persist-credentials: false + - name: Restore metadata tooling without copying current binding APIs + shell: python + run: | + import os + from pathlib import Path + import shutil + import subprocess + stage = Path(os.environ['RUNNER_TEMP']) / 'native-npm-assembly-tools' + for path in stage.rglob('*'): + if path.is_file(): + destination = Path(path.relative_to(stage)) + destination.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(path, destination) + subprocess.run(['git', 'diff', '--exit-code', '--', 'Cargo.toml', 'crates', 'ts', 'tests', 'package.json', 'package-lock.json'], check=True) + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - uses: actions/setup-node@v4 + with: + node-version: '24' + - uses: actions/download-artifact@v4 + with: + pattern: '*-napi' + path: ${{ runner.temp }}/native-npm-role-inputs + - uses: actions/download-artifact@v4 + with: + pattern: '*-cabi' + path: ${{ runner.temp }}/native-npm-role-inputs + - uses: actions/download-artifact@v4 + with: + name: platform-readmes-generated + path: ${{ runner.temp }}/native-npm-documentation + - uses: actions/download-artifact@v4 + with: + name: main-npm-package + path: ${{ runner.temp }}/native-npm-main-input + - name: Assemble complete roles and inspect every actual npm tarball + shell: python + run: | + import os + from pathlib import Path + import subprocess + import sys + root = Path(os.environ['RUNNER_TEMP']) + subprocess.run([sys.executable, '-I', 'scripts/pack_native_npm.py', str(root / 'native-npm-role-inputs'), str(root / 'native-npm-documentation'), str(root / 'native-npm-main-input'), str(root / 'native-npm-layout'), str(root / 'native-npm-release-packages')], check=True) + subprocess.run([sys.executable, '-I', 'scripts/check_release_npm.py', str(root / 'native-npm-release-packages')], check=True) + - uses: actions/upload-artifact@v4 + with: + name: native-npm-release-packages + path: ${{ runner.temp }}/native-npm-release-packages/ + if-no-files-found: error diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a120aca..68ac156 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,229 +37,16 @@ jobs: node-version: "24" - run: node scripts/check-npm-trust.mjs - # ------------------------------------------------------------------ - # Build .node binaries across the napi-rs target matrix. - # Each runner: checkout -> Rust + Node -> napi build -> upload - # artifact. `@napi-rs/cli` handles triple naming + renaming. - # ------------------------------------------------------------------ - build-native: - name: .node / ${{ matrix.settings.target }} - needs: auth-preflight - if: ${{ always() && (needs.auth-preflight.result == 'success' || needs.auth-preflight.result == 'skipped') }} - runs-on: ${{ matrix.settings.os }} - strategy: - fail-fast: false - matrix: - settings: - # Windows - - os: windows-latest - target: x86_64-pc-windows-msvc - build: npx napi build --release -p ktav-napi --target x86_64-pc-windows-msvc --platform --js false --output-dir . - - os: windows-latest - target: aarch64-pc-windows-msvc - build: npx napi build --release -p ktav-napi --target aarch64-pc-windows-msvc --platform --js false --output-dir . - - # macOS — both targets built on the `macos-latest` (Apple - # Silicon) runner. Rust + Apple's clang cross-compile x86_64 - # from arm64 hosts natively, and the arm64 runner pool is - # far less constrained than `macos-13` — avoids queue times - # that routinely hit 20+ minutes on Intel-Mac runners. - - os: macos-latest - target: x86_64-apple-darwin - build: npx napi build --release -p ktav-napi --target x86_64-apple-darwin --platform --js false --output-dir . - - os: macos-latest - target: aarch64-apple-darwin - build: npx napi build --release -p ktav-napi --target aarch64-apple-darwin --platform --js false --output-dir . - - # Linux gnu — native x64, cross-compile arm64 via @napi-rs/cli. - - os: ubuntu-latest - target: x86_64-unknown-linux-gnu - build: npx napi build --release -p ktav-napi --target x86_64-unknown-linux-gnu --platform --js false --output-dir . --use-napi-cross - - os: ubuntu-latest - target: aarch64-unknown-linux-gnu - build: npx napi build --release -p ktav-napi --target aarch64-unknown-linux-gnu --platform --js false --output-dir . --use-napi-cross - - # Оба musl target используют Zig и проверяют ELF. - - os: ubuntu-latest - target: x86_64-unknown-linux-musl - build: bash scripts/build-musl-addon.sh x86_64-unknown-linux-musl - - os: ubuntu-latest - target: aarch64-unknown-linux-musl - build: bash scripts/build-musl-addon.sh aarch64-unknown-linux-musl - - steps: - - uses: actions/checkout@v6 - with: - submodules: recursive - - uses: actions/setup-node@v6 - with: - node-version: "22" - cache: npm - - uses: dtolnay/rust-toolchain@stable - with: - targets: ${{ matrix.settings.target }} - - uses: Swatinem/rust-cache@v2 - with: - key: ${{ matrix.settings.target }} - - - name: Install zig (musl targets) - if: endsWith(matrix.settings.target, '-unknown-linux-musl') - uses: mlugg/setup-zig@v2 - with: - version: 0.14.0 - - name: Install cargo-zigbuild (musl targets) - if: endsWith(matrix.settings.target, '-unknown-linux-musl') - uses: taiki-e/install-action@v2 - with: - tool: cargo-zigbuild - - - run: npm install - - name: Build - run: ${{ matrix.settings.build }} - - name: Upload artifact - uses: actions/upload-artifact@v7 - with: - name: bindings-${{ matrix.settings.target }} - path: "*.node" - if-no-files-found: error - - # ------------------------------------------------------------------ - # Build the cdylib `ktav_cabi` for each platform — same C ABI as the - # Java / Go / .NET bindings, consumed by the new `/ffi` subexport - # (Deno via Deno.dlopen, Bun via bun:ffi). Dropped into each - # `npm//` subpackage at publish time. - # ------------------------------------------------------------------ - build-cabi: - name: cabi / ${{ matrix.settings.rid }} + native-packages: + name: Build and pack verified native npm candidates needs: auth-preflight if: ${{ always() && (needs.auth-preflight.result == 'success' || needs.auth-preflight.result == 'skipped') }} - runs-on: ${{ matrix.settings.os }} - strategy: - fail-fast: false - matrix: - settings: - - os: windows-latest - target: x86_64-pc-windows-msvc - rid: win32-x64-msvc - artifact: ktav_cabi.dll - use-zigbuild: false - - os: windows-latest - target: aarch64-pc-windows-msvc - rid: win32-arm64-msvc - artifact: ktav_cabi.dll - use-zigbuild: false - - os: macos-latest - target: x86_64-apple-darwin - rid: darwin-x64 - artifact: libktav_cabi.dylib - use-zigbuild: false - - os: macos-latest - target: aarch64-apple-darwin - rid: darwin-arm64 - artifact: libktav_cabi.dylib - use-zigbuild: false - - os: ubuntu-latest - target: x86_64-unknown-linux-gnu - rid: linux-x64-gnu - artifact: libktav_cabi.so - use-zigbuild: true - - os: ubuntu-latest - target: aarch64-unknown-linux-gnu - rid: linux-arm64-gnu - artifact: libktav_cabi.so - use-zigbuild: true - - os: ubuntu-latest - target: x86_64-unknown-linux-musl - rid: linux-x64-musl - artifact: libktav_cabi.so - use-zigbuild: true - - os: ubuntu-latest - target: aarch64-unknown-linux-musl - rid: linux-arm64-musl - artifact: libktav_cabi.so - use-zigbuild: true - - steps: - - uses: actions/checkout@v6 - - uses: dtolnay/rust-toolchain@stable - with: - targets: ${{ matrix.settings.target }} - - uses: Swatinem/rust-cache@v2 - with: - key: cabi-${{ matrix.settings.target }} - - - name: Install zig - if: matrix.settings.use-zigbuild - uses: mlugg/setup-zig@v2 - with: - version: 0.14.0 - - name: Install cargo-zigbuild - if: matrix.settings.use-zigbuild - uses: taiki-e/install-action@v2 - with: - tool: cargo-zigbuild - - - name: Build (zigbuild) - if: matrix.settings.use-zigbuild && !contains(matrix.settings.target, 'musl') - run: cargo zigbuild --release -p ktav-cabi --target ${{ matrix.settings.target }}.2.17 + uses: ./.github/workflows/native-npm-release-build.yml - - name: Build (zigbuild musl) - if: matrix.settings.use-zigbuild && contains(matrix.settings.target, 'musl') - run: cargo zigbuild --release -p ktav-cabi --target ${{ matrix.settings.target }} - - - name: Build (native) - if: ${{ !matrix.settings.use-zigbuild }} - run: cargo build --release -p ktav-cabi --target ${{ matrix.settings.target }} - - - name: Stage artifact - shell: bash - run: | - mkdir -p stage - cp "target/${{ matrix.settings.target }}/release/${{ matrix.settings.artifact }}" \ - "stage/${{ matrix.settings.artifact }}" - - - uses: actions/upload-artifact@v7 - with: - name: cabi-${{ matrix.settings.rid }} - path: stage/${{ matrix.settings.artifact }} - if-no-files-found: error - - # ------------------------------------------------------------------ - # Build wasm (web + bundler) — one job, any runner. - # ------------------------------------------------------------------ - build-wasm: - name: wasm targets - needs: auth-preflight - if: ${{ always() && (needs.auth-preflight.result == 'success' || needs.auth-preflight.result == 'skipped') }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - with: - submodules: recursive - - uses: actions/setup-node@v6 - with: - node-version: "22" - cache: npm - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - - run: rustup target add wasm32-unknown-unknown - - run: cargo install wasm-pack --locked - - run: npm install - - run: node scripts/build-wasm.mjs - - uses: actions/upload-artifact@v7 - with: - name: wasm - path: dist/wasm - if-no-files-found: error - - # ------------------------------------------------------------------ - # Assemble the npm tree: main `ktav` package + eight platform - # subpackages. Publish each. - # ------------------------------------------------------------------ publish: name: Publish to npm runs-on: ubuntu-latest - needs: [build-native, build-cabi, build-wasm] + needs: [native-packages] if: startsWith(github.ref, 'refs/tags/v') && inputs.dry-run != 'true' environment: name: npm @@ -301,62 +88,31 @@ jobs: } ' "$version" - - name: Download native artifacts - uses: actions/download-artifact@v8 - with: - path: artifacts - pattern: bindings-* - merge-multiple: true - - - name: Download wasm artifacts - uses: actions/download-artifact@v8 + - uses: actions/setup-python@v5 with: - name: wasm - path: dist/wasm - - - run: npm install - - - name: Build TypeScript - run: npm run build:ts - - - name: Move native binaries into platform subpackages - run: npx napi artifacts --npm-dir npm --build-output-dir artifacts - - - name: Download cabi artifacts - uses: actions/download-artifact@v8 + python-version: '3.12' + - name: Download only the complete verified npm archive set + uses: actions/download-artifact@v4 with: - path: cabi-staging - pattern: cabi-* - - - name: Drop cabi binaries into platform subpackages - shell: bash - run: | - set -e - for dir in cabi-staging/cabi-*/; do - rid="${dir#cabi-staging/cabi-}" - rid="${rid%/}" - file=$(ls "$dir") - target="npm/${rid}/${file}" - mkdir -p "npm/${rid}" - cp -v "${dir}${file}" "$target" - done - echo "--- after layout ---" - find npm -maxdepth 2 -type f -name '*ktav_cabi*' | sort + name: native-npm-release-packages + path: packed + - name: Recheck actual archives before any publication + run: python -I scripts/check_release_npm.py packed # Trusted Publishing is required for each of the nine packages: # GitHub repo ktav-lang/js, workflow release.yml, environment npm. - name: Publish platform subpackages run: | - for dir in npm/*/; do - echo "publishing $dir" + for archive in packed/ktav-lang-js-*-0.8.1.tgz; do + echo "publishing $archive" # EPUBLISHCONFLICT (409 `already published`) is not fatal — # happens when a previous run got partway through the # matrix then hit a separate error. Every other non-zero # exit propagates. - if ! out=$(npm publish --access public --tag latest --provenance "$dir" 2>&1); then + if ! out=$(npm publish --access public --tag latest --provenance "$archive" 2>&1); then echo "$out" if echo "$out" | grep -qE "EPUBLISHCONFLICT|previously published|cannot publish over"; then - echo "[publish] $dir already on registry — skipping" + echo "[publish] $archive already on registry — skipping" continue fi exit 1 @@ -365,7 +121,7 @@ jobs: - name: Publish main ktav run: | - if ! out=$(npm publish --access public --tag latest --provenance 2>&1); then + if ! out=$(npm publish --access public --tag latest --provenance "packed/ktav-lang-ktav-0.8.1.tgz" 2>&1); then echo "$out" if echo "$out" | grep -qE "EPUBLISHCONFLICT|previously published|cannot publish over"; then echo "[publish] main package already on registry — skipping" diff --git a/.github/workflows/wasm-notice-check.yml b/.github/workflows/wasm-notice-check.yml index 6b4dc64..df6e507 100644 --- a/.github/workflows/wasm-notice-check.yml +++ b/.github/workflows/wasm-notice-check.yml @@ -1,7 +1,7 @@ name: WASM notice evidence on: - pull_request: + workflow_call: permissions: contents: read @@ -23,7 +23,7 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'wasm-notice-tools' stage.mkdir() - for name in ['Cargo.lock', 'ci/js-build-lock.json', 'ci/test_js_build_lock.py', 'scripts/wasm-notice-resource.mjs', 'tests/wasm-notice-resource.test.mjs', 'tests/test_wasm_npm.py', 'scripts/prepare_js_notices.py', 'scripts/check_wasm_npm.py', 'scripts/check-npm-licenses.mjs', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/check_embedded_notices.py', 'ci/about.toml', 'scripts/source_license_supplements.py', 'ci/test_js_source_supplements.py', 'ci/licenses/js-source-supplements.json']: + for name in ['root-docs/PLATFORM-README/overview/body-1.md', 'Cargo.lock', 'ci/js-build-lock.json', 'ci/test_js_build_lock.py', 'scripts/wasm-notice-resource.mjs', 'tests/wasm-notice-resource.test.mjs', 'tests/test_wasm_npm.py', 'scripts/prepare_js_notices.py', 'scripts/check_wasm_npm.py', 'scripts/check-npm-licenses.mjs', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/check_embedded_notices.py', 'ci/about.toml', 'scripts/source_license_supplements.py', 'ci/test_js_source_supplements.py', 'ci/licenses/js-source-supplements.json']: target = stage / name target.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(name, target) @@ -44,11 +44,17 @@ jobs: if subprocess.check_output(['git', 'rev-parse', 'HEAD'], text=True).strip() != os.environ['SOURCE_REF']: raise SystemExit('unexpected WASM source revision') stage = Path(os.environ['RUNNER_TEMP']) / 'wasm-notice-tools' + document = Path('root-docs/PLATFORM-README/overview/body-1.md') + document_before = hashlib.sha256(document.read_bytes()).hexdigest() + if document_before != '86f38b1e176b5a9b7365e72f1f87192fb56bbf7e68945917b6ffa816cd6085d4': + raise SystemExit('original platform documentation source differs') for path in stage.rglob('*'): if path.is_file(): target = Path(path.relative_to(stage)) target.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(path, target) + if hashlib.sha256(document.read_bytes()).hexdigest() != '35f1387f0566eea501c65a7f378076afe1a6d9f17725fd8168bf5fc21fa58a58': + raise SystemExit('reviewed platform documentation overlay differs') script = Path('scripts/build-wasm.mjs') original = script.read_bytes() anchor = b'buildWebInline();' @@ -60,9 +66,11 @@ jobs: raise SystemExit('WASM build script interpreter changed') packaged = shebang + bytes([10]) + b'import { addNoticeFile } from "./wasm-notice-resource.mjs";' + bytes([10]) + body.replace(anchor, hook + bytes([10, 10]) + anchor) script.write_bytes(packaged) - record = {'source_ref': os.environ['SOURCE_REF'], 'tooling_ref': os.environ['GITHUB_SHA'], 'original_build_script_sha256': hashlib.sha256(original).hexdigest(), 'packaged_build_script_sha256': hashlib.sha256(packaged).hexdigest(), 'reviewed_lock_sha256': hashlib.sha256(Path('Cargo.lock').read_bytes()).hexdigest(), 'coverage': 'Audit-only Cargo/std prototype, not historical npm or non-Cargo runtime compliance.'} + record = {'source_ref': os.environ['SOURCE_REF'], 'tooling_ref': os.environ['GITHUB_SHA'], 'original_build_script_sha256': hashlib.sha256(original).hexdigest(), 'packaged_build_script_sha256': hashlib.sha256(packaged).hexdigest(), 'reviewed_lock_sha256': hashlib.sha256(Path('Cargo.lock').read_bytes()).hexdigest(), 'platform_documentation_overlay': {'path': 'root-docs/PLATFORM-README/overview/body-1.md', 'original_sha256': document_before, 'compiled_sha256': '35f1387f0566eea501c65a7f378076afe1a6d9f17725fd8168bf5fc21fa58a58'}, 'coverage': 'Audit-only Cargo/std prototype, not historical npm or non-Cargo runtime compliance.'} (Path(os.environ['RUNNER_TEMP']) / 'wasm-source-provenance.json').write_text(json.dumps(record, sort_keys=True, indent=2)) - subprocess.run(['git', 'diff', '--exit-code', '--', 'Cargo.toml', 'crates', 'tests/node', 'root-docs', 'package.json', 'package-lock.json'], check=True) + changed = subprocess.check_output(['git', 'diff', '--name-only', '--', 'Cargo.toml', 'crates', 'tests/node', 'root-docs', 'package.json', 'package-lock.json'], text=True).splitlines() + if set(changed) != {'root-docs/PLATFORM-README/overview/body-1.md'}: + raise SystemExit('WASM source changed beyond the reviewed documentation unit') - uses: actions/setup-node@v4 with: node-version: '24' @@ -98,6 +106,38 @@ jobs: git diff --exit-code -- package.json cp package-lock.json "$RUNNER_TEMP/wasm-notices/npm-lock-resolved.json" node scripts/check-npm-licenses.mjs + - name: Generate the EN/RU/ZH platform documentation from its reviewed unit + shell: python + run: | + import hashlib + import json + import os + from pathlib import Path + import shutil + import subprocess + source = Path('root-docs/PLATFORM-README/overview/body-1.md') + if hashlib.sha256(source.read_bytes()).hexdigest() != '35f1387f0566eea501c65a7f378076afe1a6d9f17725fd8168bf5fc21fa58a58': + raise SystemExit('platform documentation source changed before generation') + subprocess.run(['node', 'scripts/build-docs.mjs'], check=True) + subprocess.run(['node', 'scripts/build-docs.mjs', '--check'], check=True) + stage = Path(os.environ['RUNNER_TEMP']) / 'platform-readmes-generated' + stage.mkdir() + rows = [] + for rid in ['darwin-x64', 'darwin-arm64', 'linux-x64-gnu', 'linux-arm64-gnu', 'linux-x64-musl', 'linux-arm64-musl', 'win32-x64-msvc', 'win32-arm64-msvc']: + for name in ['README.md', 'README.ru.md', 'README.zh.md']: + path = Path('npm') / rid / name + raw = path.read_bytes() + destination = stage / path + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + rows.append({'path': path.as_posix(), 'bytes': len(raw), 'sha256': hashlib.sha256(raw).hexdigest()}) + record = {'source_ref': os.environ['SOURCE_REF'], 'tooling_ref': os.environ['GITHUB_SHA'], 'unit': 'root-docs/PLATFORM-README/overview/body-1.md', 'unit_sha256': '35f1387f0566eea501c65a7f378076afe1a6d9f17725fd8168bf5fc21fa58a58', 'files': rows} + (stage / 'platform-readme-manifest.json').write_text(json.dumps(record, ensure_ascii=False, sort_keys=True, indent=2) + '\n', encoding='utf-8') + - uses: actions/upload-artifact@v4 + with: + name: platform-readmes-generated + path: ${{ runner.temp }}/platform-readmes-generated/ + if-no-files-found: error - name: Build final WASM before inline generation env: CARGO_NET_OFFLINE: 'true' @@ -111,7 +151,9 @@ jobs: node --input-type=module -e 'import {readFileSync} from "node:fs"; import {verifyNotice} from "./scripts/wasm-notice-resource.mjs"; verifyNotice(readFileSync(process.argv[1]),readFileSync(process.env.KTAV_NATIVE_NOTICES));' "dist/wasm/$target/ktav_bg.wasm" python3 -I scripts/check_embedded_notices.py "dist/wasm/$target/ktav_bg.wasm" "$RUNNER_TEMP/wasm-notices/NOTICE.json" > "$RUNNER_TEMP/wasm-notices/resource-$target.json" done - cp "$RUNNER_TEMP/wasm-notices/NOTICE.json" dist/wasm/NOTICE.json + for name in NOTICE.json Cargo.lock COPYRIGHT-library.html source-provenance.json; do + cp "$RUNNER_TEMP/wasm-notices/$name" "dist/wasm/$name" + done - run: npm run build:ts - name: Verify host WASM consumer run: npm run test:node-wasm @@ -121,6 +163,36 @@ jobs: set -euo pipefail npm pack --ignore-scripts --json --pack-destination "$RUNNER_TEMP" > "$RUNNER_TEMP/wasm-notices/npm-pack.json" python3 -c 'import json,os,subprocess,sys; from pathlib import Path; e=Path(os.environ["RUNNER_TEMP"])/"wasm-notices"; p=json.loads((e/"npm-pack.json").read_text()); assert len(p)==1; name=p[0]["filename"]; assert Path(name).name==name; output=subprocess.check_output([sys.executable,"scripts/check_wasm_npm.py",str(e.parent/name),str(e),"."]); (e/"npm-verification.json").write_bytes(output)' + - name: Stage the exact verified main npm tarball without publication + shell: python + run: | + import hashlib + import json + import os + from pathlib import Path + import shutil + root = Path(os.environ['RUNNER_TEMP']) + evidence = root / 'wasm-notices' + packed = json.loads((evidence / 'npm-pack.json').read_bytes()) + if len(packed) != 1 or Path(packed[0]['filename']).name != packed[0]['filename']: + raise SystemExit('one exact main npm package required') + archive = root / packed[0]['filename'] + verification = json.loads((evidence / 'npm-verification.json').read_bytes()) + if hashlib.sha256(archive.read_bytes()).hexdigest() != verification['package_sha256']: + raise SystemExit('main package changed after verification') + stage = root / 'main-npm-package' + stage.mkdir() + shutil.copyfile(archive, stage / archive.name) + for name in ['NOTICE.json', 'Cargo.lock', 'COPYRIGHT-library.html', 'source-provenance.json', 'npm-verification.json']: + shutil.copyfile(evidence / name, stage / name) + rows = [{'path': path.name, 'bytes': path.stat().st_size, 'sha256': hashlib.sha256(path.read_bytes()).hexdigest()} for path in sorted(stage.iterdir())] + record = {'package': '@ktav-lang/ktav', 'version': '0.8.1', 'source_ref': os.environ['SOURCE_REF'], 'tooling_ref': os.environ['GITHUB_SHA'], 'archive': archive.name, 'files': rows} + (stage / 'main-package-manifest.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') + - uses: actions/upload-artifact@v4 + with: + name: main-npm-package + path: ${{ runner.temp }}/main-npm-package/ + if-no-files-found: error - uses: actions/upload-artifact@v4 if: always() with: diff --git a/.github/workflows/windows-cabi-gnullvm-check.yml b/.github/workflows/windows-cabi-gnullvm-check.yml index 189f073..5b4c5a7 100644 --- a/.github/workflows/windows-cabi-gnullvm-check.yml +++ b/.github/workflows/windows-cabi-gnullvm-check.yml @@ -1,7 +1,7 @@ name: Windows C ABI GNU LLVM compatibility evidence on: - pull_request: + workflow_call: permissions: contents: read @@ -38,7 +38,7 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'cabi-gnullvm-tools' stage.mkdir() - for name in ['Cargo.lock', 'ci/js-build-lock.json', 'crates/cabi/build.rs', 'scripts/patch_cabi_notice_source.py', 'ci/test_cabi_notice_overlay.py', 'scripts/cabi_gnullvm_notices.py', 'ci/test_cabi_gnullvm_notices.py', 'ci/licenses/cabi-gnullvm-runtime.json', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'ci/about.toml', 'ci/licenses/js-source-supplements.json']: + for name in ['scripts/native_npm_payload.py', 'scripts/windows_gnu_napi_variant.py', 'Cargo.lock', 'ci/js-build-lock.json', 'crates/cabi/build.rs', 'scripts/patch_cabi_notice_source.py', 'ci/test_cabi_notice_overlay.py', 'scripts/cabi_gnullvm_notices.py', 'ci/test_cabi_gnullvm_notices.py', 'ci/licenses/cabi-gnullvm-runtime.json', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'ci/about.toml', 'ci/licenses/js-source-supplements.json']: path = stage / name path.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(name, path) @@ -335,6 +335,32 @@ jobs: raise SystemExit('actual consumer DLL bytes changed') record = {'target': os.environ['CABI_TARGET'], 'binary_sha256': hashlib.sha256(binary.read_bytes()).hexdigest(), 'sdk_path_removed': True, 'actual_bun_corpus': True, 'actual_deno_corpus': True, 'bun_version': subprocess.check_output(['bun', '--version'], env=environment, text=True).strip(), 'deno_version': subprocess.check_output(['deno', '--version'], env=environment, text=True).strip(), 'scope': 'Matching-x64 actual C ABI consumers with pinned spec corpus. ARM DLL inspected only; no NAPI claim.'} (evidence / 'consumer-verification.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') + - name: Stage complete source-bound native npm roles + env: + NPM_TARGET: ${{ matrix.target }} + shell: python + run: | + import os + from pathlib import Path + import subprocess + import sys + sys.path.insert(0, str(Path('scripts').resolve())) + from native_npm_payload import TARGETS + target = os.environ['NPM_TARGET'] + rid = next(name for name, value in TARGETS.items() if value == target) + root = Path(os.environ['RUNNER_TEMP']) + evidence = root / 'cabi-gnullvm-evidence' + for role in ['cabi']: + output = root / ('native-npm-' + rid + '-' + role) + subprocess.run([sys.executable, '-I', 'scripts/native_npm_payload.py', str(evidence), str(output), rid, role], check=True) + with Path(os.environ['GITHUB_ENV']).open('a', encoding='utf-8') as destination: + destination.write('NPM_RID=' + rid + '\n') + - uses: actions/upload-artifact@v4 + with: + name: ${{ env.NPM_RID }}-cabi + path: ${{ runner.temp }}/native-npm-${{ env.NPM_RID }}-cabi/ + include-hidden-files: true + if-no-files-found: error - uses: actions/upload-artifact@v4 if: always() with: diff --git a/.github/workflows/windows-gnu-napi-variant-check.yml b/.github/workflows/windows-gnu-napi-variant-check.yml index 8d7f472..b9af6f0 100644 --- a/.github/workflows/windows-gnu-napi-variant-check.yml +++ b/.github/workflows/windows-gnu-napi-variant-check.yml @@ -1,7 +1,7 @@ name: Windows GNU NAPI source-bound notice candidate on: - pull_request: + workflow_call: permissions: contents: read @@ -38,7 +38,7 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'gnu-napi-tools' stage.mkdir() - names = ['Cargo.lock', 'scripts/windows_gnu_napi_variant.py', 'ci/test_windows_gnu_napi_variant.py', 'ci/fixtures/windows-gnu-napi/project-build.rs.txt', 'ci/fixtures/windows-gnu-napi/project-Cargo.toml.txt', + names = ['scripts/native_npm_payload.py', 'Cargo.lock', 'scripts/windows_gnu_napi_variant.py', 'ci/test_windows_gnu_napi_variant.py', 'ci/fixtures/windows-gnu-napi/project-build.rs.txt', 'ci/fixtures/windows-gnu-napi/project-Cargo.toml.txt', 'scripts/prepare_gnu_napi_variant_notices.py', 'scripts/stage_gnu_napi_variant.py', 'scripts/napi_gnullvm_notices.py', 'scripts/rust_compiler_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/patch_napi_notice_source.py', 'scripts/check_embedded_notices.py', 'ci/about.toml', 'ci/licenses/js-source-supplements.json', 'ci/licenses/napi-gnullvm-runtime.json', 'ci/rust-compiler-notices.json', 'ci/test_napi_gnullvm_notices.py', 'ci/fixtures/windows-gnu-napi/project-config.toml.txt', 'ci/fixtures/windows-gnu-napi/resource-build.rs.txt', *[str(path) for path in Path('ci/licenses/rust-compiler-originals').glob('*')]] for name in names: @@ -253,6 +253,32 @@ jobs: evidence = Path(os.environ['RUNNER_TEMP']) / 'gnu-napi-evidence' binary = Path('target') / os.environ['NAPI_TARGET'] / 'release/ktav_napi.dll' subprocess.run([sys.executable, '-I', 'scripts/stage_gnu_napi_variant.py', 'stage', str(evidence), str(binary), os.environ['NAPI_TARGET']], check=True) + - name: Stage complete source-bound native npm roles + env: + NPM_TARGET: ${{ matrix.target }} + shell: python + run: | + import os + from pathlib import Path + import subprocess + import sys + sys.path.insert(0, str(Path('scripts').resolve())) + from native_npm_payload import TARGETS + target = os.environ['NPM_TARGET'] + rid = next(name for name, value in TARGETS.items() if value == target) + root = Path(os.environ['RUNNER_TEMP']) + evidence = root / 'gnu-napi-native-payload' + for role in ['napi']: + output = root / ('native-npm-' + rid + '-' + role) + subprocess.run([sys.executable, '-I', 'scripts/native_npm_payload.py', str(evidence), str(output), rid, role], check=True) + with Path(os.environ['GITHUB_ENV']).open('a', encoding='utf-8') as destination: + destination.write('NPM_RID=' + rid + '\n') + - uses: actions/upload-artifact@v4 + with: + name: ${{ env.NPM_RID }}-napi + path: ${{ runner.temp }}/native-npm-${{ env.NPM_RID }}-napi/ + include-hidden-files: true + if-no-files-found: error - uses: actions/upload-artifact@v4 with: name: gnu-napi-native-candidate-${{ matrix.target }} diff --git a/ci/test_native_npm_payload.py b/ci/test_native_npm_payload.py index 4a11795..52f779b 100644 --- a/ci/test_native_npm_payload.py +++ b/ci/test_native_npm_payload.py @@ -2,12 +2,14 @@ import contextlib import gzip +import io import json import os from pathlib import Path import struct import sys import tempfile +import tarfile import unittest from unittest.mock import patch @@ -15,6 +17,7 @@ sys.path.insert(0, str(ROOT / 'scripts')) import native_npm_payload as PAYLOAD import assemble_native_npm as ASSEMBLY +import check_native_npm as PACKED @contextlib.contextmanager @@ -224,6 +227,39 @@ def test_exact_eight_platform_role_pairs_required(self): ASSEMBLY.assemble(payloads, root / 'templates', root / 'output') self.assertFalse((root / 'output').exists()) + def test_actual_native_tarball_retains_both_complete_roles(self): + with tempfile.TemporaryDirectory() as temporary: + root, inputs, template, output, lock = self.assembled_fixture(temporary) + with patch.object(PAYLOAD, 'LOCK', lock): + ASSEMBLY.assemble_platform('darwin-x64', inputs, template, output) + archive = root / 'package.tgz' + with tarfile.open(archive, 'w:gz') as packed: + for path in sorted(output.rglob('*')): + if path.is_file(): + packed.add(path, arcname='package/' + path.relative_to(output).as_posix(), recursive=False) + report = PACKED.verify(archive, 'darwin-x64') + self.assertEqual(report['package'], '@ktav-lang/js-darwin-x64') + self.assertEqual(set(report['roles']), {'napi', 'cabi'}) + self.assertEqual(report['package_sha256'], PAYLOAD.sha(archive.read_bytes())) + + def test_tar_traversal_symlinks_and_duplicate_aliases_are_rejected(self): + for name, symlink in [('../escape', False), ('package/alias', True), ('package/./package.json', False)]: + with self.subTest(name=name), tempfile.TemporaryDirectory() as temporary: + root = Path(temporary) + archive = root / 'package.tgz' + with tarfile.open(archive, 'w:gz') as packed: + first = tarfile.TarInfo('package/package.json') + first.size = 2 + packed.addfile(first, io.BytesIO(b'{}')) + entry = tarfile.TarInfo(name) + if symlink: + entry.type = tarfile.SYMTYPE + entry.linkname = '../../escape' + packed.addfile(entry, io.BytesIO(b'')) + with self.assertRaisesRegex(ValueError, 'unsafe or duplicate|kind/size'): + PACKED.unpack(archive, root / 'unpacked') + self.assertFalse((root / 'escape').exists()) + if __name__ == '__main__': unittest.main() diff --git a/root-docs/PLATFORM-README/overview/body-1.md b/root-docs/PLATFORM-README/overview/body-1.md index d14818e..74a50f4 100644 --- a/root-docs/PLATFORM-README/overview/body-1.md +++ b/root-docs/PLATFORM-README/overview/body-1.md @@ -1,21 +1,49 @@ >>>>> lang=en # `{{PACKAGE_NAME}}` platform binaries -This package contains the prebuilt N-API and C ABI libraries for -`{{TARGET_TRIPLE}}`. It is an optional dependency of [`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -and is normally installed automatically; install the main package to -use the JavaScript API. +This package contains the prebuilt N-API and C ABI libraries for the +compatibility platform `{{TARGET_TRIPLE}}`. It is an optional dependency of +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) and is normally +installed automatically; install the main package to use the JavaScript API. + +Platform identifiers and filenames preserve loader compatibility; they do not +identify the compiler used. Windows packages retain their legacy `msvc` names, +while the libraries in this build use GNU/LLVM. `native-package-manifest.json` +records the actual target, source identity and notice hashes for each library. + +Complete third-party notices and required original legal/source materials are +kept separately under `third_party/napi/` and `third_party/cabi/`. The root +`LICENSE-MIT` and `LICENSE-APACHE` files cover the project's own code; the bundled +third-party materials retain their original terms. >>>>> lang=ru # Платформенные бинарники `{{PACKAGE_NAME}}` -Этот пакет содержит готовые библиотеки N-API и C ABI для +Этот пакет содержит готовые библиотеки N-API и C ABI для платформы совместимости `{{TARGET_TRIPLE}}`. Он является необязательной зависимостью -[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -и обычно устанавливается автоматически. Для JavaScript API установите -основной пакет. +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) и обычно +устанавливается автоматически. Для JavaScript API установите основной пакет. + +Обозначения платформ и имена файлов сохраняют совместимость с загрузчиками, +но не определяют использованный компилятор. Windows-пакеты сохраняют прежние +имена с `msvc`, а библиотеки этой сборки собраны GNU/LLVM. +`native-package-manifest.json` содержит фактический target, идентификатор исходников +и хеши notices каждой библиотеки. + +Полные third-party notices и необходимые оригинальные лицензионные материалы +и исходники сохранены отдельно в `third_party/napi/` и `third_party/cabi/`. +Корневые `LICENSE-MIT` и `LICENSE-APACHE` относятся к собственному коду проекта; +для включённых сторонних материалов сохраняются исходные условия. >>>>> lang=zh # `{{PACKAGE_NAME}}` 平台二进制包 -此包包含用于 `{{TARGET_TRIPLE}}` 的预构建 N-API 和 C ABI 库。它是 -[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -的可选依赖,通常会自动安装;使用 JavaScript API 时请安装主包。 +此包包含兼容平台 `{{TARGET_TRIPLE}}` 的预构建 N-API 和 C ABI 库。它是 +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) 的可选依赖, +通常会自动安装;使用 JavaScript API 时请安装主包。 + +平台标识和文件名用于保持加载器兼容性,不代表实际使用的编译器。Windows 包保留 +含 `msvc` 的旧名称,而本次构建中的库使用 GNU/LLVM。 +`native-package-manifest.json` 记录每个库的实际 target、源代码标识及 notices 哈希。 + +完整的第三方 notices 及所需的原始法律和源代码材料分别保存在 +`third_party/napi/` 和 `third_party/cabi/` 中。根目录中的 `LICENSE-MIT` 和 +`LICENSE-APACHE` 适用于项目自身代码;捆绑的第三方材料保留其原始条款。 diff --git a/scripts/check_native_npm.py b/scripts/check_native_npm.py new file mode 100644 index 0000000..4aab6df --- /dev/null +++ b/scripts/check_native_npm.py @@ -0,0 +1,60 @@ +"""Проверить actual npm tar members и полные native роли без выполнения payload.""" + +import hashlib +import json +from pathlib import Path, PurePosixPath +import sys +import tarfile +import tempfile + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +from assemble_native_npm import verify_platform + + +def unpack(archive_path, output): + if archive_path.is_symlink() or not archive_path.is_file() or not 0 < archive_path.stat().st_size <= 128 * 1024 * 1024: + raise ValueError('npm archive is missing or exceeds bound') + output.mkdir() + seen = set() + total = 0 + with tarfile.open(archive_path, 'r:gz') as archive: + for item in archive: + path = PurePosixPath(item.name) + if path.is_absolute() or '..' in path.parts or chr(92) in item.name or ':' in item.name or not path.parts or path.parts[0] != 'package' or path.as_posix().casefold() in seen: + raise ValueError('unsafe or duplicate npm tar member') + seen.add(path.as_posix().casefold()) + if len(seen) > 8192: + raise ValueError('npm tar member count exceeds bound') + if item.isdir(): + continue + if not item.isfile() or item.size > 128 * 1024 * 1024 or len(path.parts) < 2: + raise ValueError('npm tar member kind/size differs') + total += item.size + if total > 256 * 1024 * 1024: + raise ValueError('npm tar decoded bytes exceed bound') + destination = output.joinpath(*path.parts[1:]) + destination.parent.mkdir(parents=True, exist_ok=True) + with archive.extractfile(item) as source, destination.open('xb') as target: + remaining = item.size + while remaining: + raw = source.read(min(remaining, 1024 * 1024)) + if not raw: + raise ValueError('truncated npm tar member') + target.write(raw) + remaining -= len(raw) + if not (output / 'package.json').is_file(): + raise ValueError('packed npm metadata missing') + + +def verify(archive_path, rid): + with tempfile.TemporaryDirectory(prefix='ktav-packed-native-') as temporary: + output = Path(temporary) / 'package' + unpack(archive_path, output) + document = verify_platform(output, rid) + return {'package': document['package'], 'version': document['version'], 'rid': rid, 'source_ref': document['source_ref'], 'tooling_ref': document['tooling_ref'], 'package_sha256': hashlib.sha256(archive_path.read_bytes()).hexdigest(), 'files': len(document['files']), 'roles': document['roles'], 'scope': 'Actual packed native npm file/resource/legal/source contract; native execution is a separate consumer gate.'} + + +if __name__ == '__main__': + if len(sys.argv) != 3: + raise SystemExit('usage: check_native_npm.py TARBALL RID') + print(json.dumps(verify(Path(sys.argv[1]), sys.argv[2]), ensure_ascii=False, sort_keys=True, indent=2)) diff --git a/scripts/check_release_npm.py b/scripts/check_release_npm.py new file mode 100644 index 0000000..fa60f74 --- /dev/null +++ b/scripts/check_release_npm.py @@ -0,0 +1,60 @@ +"""Повторно проверить exact nine-package release set перед передачей publisher job.""" + +import json +from pathlib import Path +import sys +import tempfile + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +from check_native_npm import unpack, verify as verify_native +from check_wasm_npm import verify as verify_wasm +from native_npm_payload import LICENSES, LOCK, SOURCE, TARGETS, read, sha +from pack_native_npm import DOC_SHA + + +def verify(root): + manifest = json.loads(read(root / 'native-npm-release-manifest.json', 4 * 1024 * 1024)) + expected = {'@ktav-lang/js-' + rid: 'ktav-lang-js-' + rid + '-0.8.1.tgz' for rid in TARGETS} + expected['@ktav-lang/ktav'] = 'ktav-lang-ktav-0.8.1.tgz' + records = manifest['packages'] + if manifest['schema_version'] != 1 or manifest['source_ref'] != SOURCE or manifest['documentation_unit_sha256'] != DOC_SHA or len(records) != 9 or {item['package'] for item in records} != set(expected): + raise ValueError('complete reviewed npm release set differs') + if any(path.is_symlink() or not path.is_file() for path in root.iterdir()) or {path.name for path in root.iterdir()} != set(expected.values()) | {'native-npm-release-manifest.json'}: + raise ValueError('release archive inventory differs') + for item in records: + if item['version'] != '0.8.1' or item['archive'] != expected[item['package']]: + raise ValueError('release package version/archive identity differs') + archive = root / item['archive'] + raw = read(archive, 128 * 1024 * 1024) + if len(raw) != item['bytes'] or sha(raw) != item['sha256']: + raise ValueError('release tarball bytes differ') + if item['package'] != '@ktav-lang/ktav': + report = verify_native(archive, item['rid']) + if report['package'] != item['package'] or report['tooling_ref'] != manifest['tooling_ref'] or report['roles'] != item['roles']: + raise ValueError('packed native role/provenance differs from release index') + continue + with tempfile.TemporaryDirectory(prefix='ktav-release-main-') as temporary: + package = Path(temporary) / 'package' + unpack(archive, package) + evidence = package / 'dist/wasm' + report = verify_wasm(archive, evidence, package) + provenance = json.loads(read(evidence / 'source-provenance.json')) + notice = json.loads(read(evidence / 'NOTICE.json')) + if report['wasm'] != item['wasm'] or report['package_sha256'] != item['sha256'] or provenance['source_ref'] != SOURCE or provenance['tooling_ref'] != manifest['tooling_ref'] or provenance['platform_documentation_overlay']['compiled_sha256'] != DOC_SHA or sha(read(evidence / 'Cargo.lock', 4 * 1024 * 1024)) != LOCK or notice['cargo_lock_sha256'] != LOCK: + raise ValueError('main package actual source/resource/lock identity differs') + copyright_report = read(evidence / 'COPYRIGHT-library.html') + if not copyright_report.strip() or notice['rust_standard_library']['text'].encode('utf-8') != copyright_report or notice['rust_standard_library']['sha256'] != sha(copyright_report): + raise ValueError('main package full compiler grant report differs') + for name, expected_sha in LICENSES.items(): + if sha(read(package / name, 64 * 1024)) != expected_sha: + raise ValueError('main package original first-party license differs') + metadata = json.loads(read(package / 'package.json', 1024 * 1024)) + if metadata['optionalDependencies'] != {'@ktav-lang/js-' + rid: '0.8.1' for rid in TARGETS} or metadata['license'] != 'MIT OR Apache-2.0': + raise ValueError('main package optional dependency/license metadata differs') + return {'packages': 9, 'source_ref': SOURCE, 'tooling_ref': manifest['tooling_ref'], 'version': '0.8.1', 'scope': 'Exact actual archive/resource/source/legal release contract. This check does not publish or repair existing registry assets.'} + + +if __name__ == '__main__': + if len(sys.argv) != 2: + raise SystemExit('usage: check_release_npm.py PACKED_RELEASE_DIRECTORY') + print(json.dumps(verify(Path(sys.argv[1])), sort_keys=True, indent=2)) diff --git a/scripts/pack_native_npm.py b/scripts/pack_native_npm.py new file mode 100644 index 0000000..1adbd25 --- /dev/null +++ b/scripts/pack_native_npm.py @@ -0,0 +1,118 @@ +"""Собрать и проверить девять source-bound npm tarballs без публикации.""" + +import json +from pathlib import Path +import shutil +import subprocess +import sys +import tempfile + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +from assemble_native_npm import DOCS, assemble +from check_native_npm import unpack, verify as verify_native +from check_wasm_npm import verify as verify_wasm +from native_npm_payload import LICENSES, LOCK, SOURCE, TARGETS, files, read, relative, sha + +DOC_UNIT = 'root-docs/PLATFORM-README/overview/body-1.md' +DOC_SHA = '35f1387f0566eea501c65a7f378076afe1a6d9f17725fd8168bf5fc21fa58a58' + + +def apply_documentation(root, tooling): + manifest = json.loads(read(root / 'platform-readme-manifest.json', 4 * 1024 * 1024)) + expected = {'npm/' + rid + '/' + name for rid in TARGETS for name in DOCS} + rows = manifest['files'] + if manifest['source_ref'] != SOURCE or manifest['tooling_ref'] != tooling or manifest['unit'] != DOC_UNIT or manifest['unit_sha256'] != DOC_SHA or len(rows) != len(expected) or {item['path'] for item in rows} != expected: + raise ValueError('generated platform documentation identity differs') + if {item['path'] for item in files(root)} != expected | {'platform-readme-manifest.json'}: + raise ValueError('generated platform documentation role set differs') + for item in rows: + relative(item['path']) + raw = read(root / item['path'], 4 * 1024 * 1024) + if len(raw) != item['bytes'] or sha(raw) != item['sha256']: + raise ValueError('generated platform documentation bytes differ') + destination = Path(item['path']) + read(destination, 4 * 1024 * 1024) + destination.write_bytes(raw) + + +def verify_main(root, tooling): + manifest = json.loads(read(root / 'main-package-manifest.json', 4 * 1024 * 1024)) + name = manifest['archive'] + if Path(name).name != name or name != 'ktav-lang-ktav-0.8.1.tgz' or manifest['package'] != '@ktav-lang/ktav' or manifest['version'] != '0.8.1' or manifest['source_ref'] != SOURCE or manifest['tooling_ref'] != tooling: + raise ValueError('main package producer identity differs') + rows = manifest['files'] + expected = {name, 'NOTICE.json', 'Cargo.lock', 'COPYRIGHT-library.html', 'source-provenance.json', 'npm-verification.json'} + if len(rows) != len(expected) or {item['path'] for item in rows} != expected or sorted(rows, key=lambda item: item['path']) != [item for item in files(root) if item['path'] != 'main-package-manifest.json']: + raise ValueError('complete main package producer role set differs') + lock = read(root / 'Cargo.lock', 4 * 1024 * 1024) + provenance = json.loads(read(root / 'source-provenance.json')) + if sha(lock) != LOCK or provenance['source_ref'] != SOURCE or provenance['tooling_ref'] != tooling or provenance['platform_documentation_overlay']['compiled_sha256'] != DOC_SHA: + raise ValueError('main package source/lock/documentation binding differs') + archive = root / name + original = json.loads(read(root / 'npm-verification.json')) + with tempfile.TemporaryDirectory(prefix='ktav-packed-main-') as temporary: + package = Path(temporary) / 'package' + unpack(archive, package) + actual = verify_wasm(archive, root, package) + for key in ['package_sha256', 'notice_sha256', 'wasm', 'inline_matches_web']: + if actual[key] != original[key]: + raise ValueError('packed main package differs from producer verification') + for filename in ['NOTICE.json', 'Cargo.lock', 'COPYRIGHT-library.html', 'source-provenance.json']: + if read(package / 'dist/wasm' / filename) != read(root / filename): + raise ValueError('packed main source/legal role differs') + for filename, expected_sha in LICENSES.items(): + if sha(read(package / filename, 64 * 1024)) != expected_sha: + raise ValueError('packed main first-party license differs') + metadata = json.loads(read(package / 'package.json', 1024 * 1024)) + expected_optional = {'@ktav-lang/js-' + rid: '0.8.1' for rid in TARGETS} + if metadata['optionalDependencies'] != expected_optional or metadata['license'] != 'MIT OR Apache-2.0': + raise ValueError('main optional dependency versions or license differ') + notice = json.loads(read(package / 'dist/wasm/NOTICE.json')) + if notice['cargo_lock_sha256'] != sha(lock): + raise ValueError('packed main notice lock differs') + return archive, actual + + +def pack(payloads, documentation, main, layout, output): + if subprocess.check_output(['git', 'rev-parse', 'HEAD'], text=True).strip() != SOURCE: + raise ValueError('npm assembly requires exact original project source') + protected = subprocess.check_output(['git', 'diff', '--name-only', '--', 'Cargo.toml', 'crates', 'package.json', 'package-lock.json'], text=True).splitlines() + if protected: + raise ValueError('npm assembly changed protected original source') + tooling = None + for rid in TARGETS: + for role in ['napi', 'cabi']: + record = json.loads(read(payloads / (rid + '-' + role) / 'native-role-manifest.json', 4 * 1024 * 1024)) + if tooling is not None and record['tooling_ref'] != tooling: + raise ValueError('native producer tooling identities differ') + tooling = record['tooling_ref'] + apply_documentation(documentation, tooling) + main_archive, main_verification = verify_main(main, tooling) + assemble(payloads, Path('npm'), layout) + output.mkdir() + records = [] + npm = shutil.which('npm') + if npm is None: + raise ValueError('npm packing tool missing') + for rid in TARGETS: + result = subprocess.check_output([npm, 'pack', '--ignore-scripts', '--json', '--pack-destination', str(output.resolve()), str((layout / rid).resolve())]) + packed = json.loads(result) + expected_name = 'ktav-lang-js-' + rid + '-0.8.1.tgz' + if len(packed) != 1 or packed[0]['filename'] != expected_name: + raise ValueError('unexpected native npm archive identity') + archive = output / expected_name + verification = verify_native(archive, rid) + records.append({'package': verification['package'], 'version': '0.8.1', 'rid': rid, 'archive': archive.name, 'bytes': archive.stat().st_size, 'sha256': verification['package_sha256'], 'roles': verification['roles']}) + shutil.copyfile(main_archive, output / main_archive.name) + if sha(read(output / main_archive.name, 128 * 1024 * 1024)) != main_verification['package_sha256']: + raise ValueError('staged main archive bytes differ') + records.append({'package': '@ktav-lang/ktav', 'version': '0.8.1', 'archive': main_archive.name, 'bytes': main_archive.stat().st_size, 'sha256': main_verification['package_sha256'], 'wasm': main_verification['wasm']}) + manifest = {'schema_version': 1, 'source_ref': SOURCE, 'tooling_ref': tooling, 'documentation_unit_sha256': DOC_SHA, 'packages': records, 'scope': 'Nine actual verified npm tarballs from the shared source-bound build and assembly path. No registry publication, historical immutable package repair or unexecuted native consumer claim.'} + (output / 'native-npm-release-manifest.json').write_text(json.dumps(manifest, ensure_ascii=False, sort_keys=True, indent=2) + '\n', encoding='utf-8') + print(json.dumps({'packages': len(records), 'source_ref': SOURCE, 'tooling_ref': tooling, 'version': '0.8.1'})) + + +if __name__ == '__main__': + if len(sys.argv) != 6: + raise SystemExit('usage: pack_native_npm.py PAYLOADS DOCUMENTATION MAIN NEW_LAYOUT NEW_OUTPUT') + pack(*map(Path, sys.argv[1:])) From 1486be452df24a4a0bdf4d6de279f5ec05394c5c Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sun, 1 Nov 2026 13:36:45 +0100 Subject: [PATCH 47/51] fix(licenses): canonicalize native payload inventory order Windows Path ordering is case-insensitive, unlike the POSIX string ordering used to compare serialized manifest paths. Canonicalize the inventory by its recorded relative path before comparing or emitting manifests. Keep file hashes, mandatory roles and all producer gates unchanged. Add a deterministic Windows-comparator regression that also runs on the Linux contract runner. Synchronize only the 24 EN/RU/ZH platform READMEs generated by the successful source-bound WASM job in run 41305849409. Verify every artifact hash, the exact source-unit identity and producer merge. Do not edit generated Markdown manually or suppress the docs check. Co-Authored-By: Claude Opus 5.5 --- ci/test_native_npm_payload.py | 21 +++++++++++++++++++++ npm/darwin-arm64/README.md | 18 ++++++++++++++---- npm/darwin-arm64/README.ru.md | 18 ++++++++++++++---- npm/darwin-arm64/README.zh.md | 14 +++++++++++--- npm/darwin-x64/README.md | 18 ++++++++++++++---- npm/darwin-x64/README.ru.md | 18 ++++++++++++++---- npm/darwin-x64/README.zh.md | 14 +++++++++++--- npm/linux-arm64-gnu/README.md | 18 ++++++++++++++---- npm/linux-arm64-gnu/README.ru.md | 18 ++++++++++++++---- npm/linux-arm64-gnu/README.zh.md | 14 +++++++++++--- npm/linux-arm64-musl/README.md | 18 ++++++++++++++---- npm/linux-arm64-musl/README.ru.md | 18 ++++++++++++++---- npm/linux-arm64-musl/README.zh.md | 14 +++++++++++--- npm/linux-x64-gnu/README.md | 18 ++++++++++++++---- npm/linux-x64-gnu/README.ru.md | 18 ++++++++++++++---- npm/linux-x64-gnu/README.zh.md | 14 +++++++++++--- npm/linux-x64-musl/README.md | 18 ++++++++++++++---- npm/linux-x64-musl/README.ru.md | 18 ++++++++++++++---- npm/linux-x64-musl/README.zh.md | 14 +++++++++++--- npm/win32-arm64-msvc/README.md | 18 ++++++++++++++---- npm/win32-arm64-msvc/README.ru.md | 18 ++++++++++++++---- npm/win32-arm64-msvc/README.zh.md | 14 +++++++++++--- npm/win32-x64-msvc/README.md | 18 ++++++++++++++---- npm/win32-x64-msvc/README.ru.md | 18 ++++++++++++++---- npm/win32-x64-msvc/README.zh.md | 14 +++++++++++--- scripts/native_npm_payload.py | 2 +- 26 files changed, 334 insertions(+), 89 deletions(-) diff --git a/ci/test_native_npm_payload.py b/ci/test_native_npm_payload.py index 52f779b..63a63b8 100644 --- a/ci/test_native_npm_payload.py +++ b/ci/test_native_npm_payload.py @@ -227,6 +227,27 @@ def test_exact_eight_platform_role_pairs_required(self): ASSEMBLY.assemble(payloads, root / 'templates', root / 'output') self.assertFalse((root / 'output').exists()) + def test_inventory_order_is_canonical_with_windows_path_comparison(self): + class WindowsEntry: + def __init__(self, path): + self.path = path + + def __getattr__(self, name): + return getattr(self.path, name) + + def __lt__(self, other): + return self.path.name.casefold() < other.path.name.casefold() + + with tempfile.TemporaryDirectory() as temporary: + root = Path(temporary) + names = ['Cargo.lock', 'COPYRIGHT-library.html', 'binary', 'LICENSE-MIT'] + for name in names: + (root / name).write_bytes(name.encode()) + entries = [WindowsEntry(root / name) for name in names] + with patch.object(Path, 'rglob', return_value=entries): + inventory = PAYLOAD.files(root) + self.assertEqual([item['path'] for item in inventory], sorted(names)) + def test_actual_native_tarball_retains_both_complete_roles(self): with tempfile.TemporaryDirectory() as temporary: root, inputs, template, output, lock = self.assembled_fixture(temporary) diff --git a/npm/darwin-arm64/README.md b/npm/darwin-arm64/README.md index 7d72ea4..6b20881 100644 --- a/npm/darwin-arm64/README.md +++ b/npm/darwin-arm64/README.md @@ -1,6 +1,16 @@ # `@ktav-lang/js-darwin-arm64` platform binaries -This package contains the prebuilt N-API and C ABI libraries for -`aarch64-apple-darwin`. It is an optional dependency of [`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -and is normally installed automatically; install the main package to -use the JavaScript API. +This package contains the prebuilt N-API and C ABI libraries for the +compatibility platform `aarch64-apple-darwin`. It is an optional dependency of +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) and is normally +installed automatically; install the main package to use the JavaScript API. + +Platform identifiers and filenames preserve loader compatibility; they do not +identify the compiler used. Windows packages retain their legacy `msvc` names, +while the libraries in this build use GNU/LLVM. `native-package-manifest.json` +records the actual target, source identity and notice hashes for each library. + +Complete third-party notices and required original legal/source materials are +kept separately under `third_party/napi/` and `third_party/cabi/`. The root +`LICENSE-MIT` and `LICENSE-APACHE` files cover the project's own code; the bundled +third-party materials retain their original terms. diff --git a/npm/darwin-arm64/README.ru.md b/npm/darwin-arm64/README.ru.md index 4e09794..96b6d36 100644 --- a/npm/darwin-arm64/README.ru.md +++ b/npm/darwin-arm64/README.ru.md @@ -1,7 +1,17 @@ # Платформенные бинарники `@ktav-lang/js-darwin-arm64` -Этот пакет содержит готовые библиотеки N-API и C ABI для +Этот пакет содержит готовые библиотеки N-API и C ABI для платформы совместимости `aarch64-apple-darwin`. Он является необязательной зависимостью -[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -и обычно устанавливается автоматически. Для JavaScript API установите -основной пакет. +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) и обычно +устанавливается автоматически. Для JavaScript API установите основной пакет. + +Обозначения платформ и имена файлов сохраняют совместимость с загрузчиками, +но не определяют использованный компилятор. Windows-пакеты сохраняют прежние +имена с `msvc`, а библиотеки этой сборки собраны GNU/LLVM. +`native-package-manifest.json` содержит фактический target, идентификатор исходников +и хеши notices каждой библиотеки. + +Полные third-party notices и необходимые оригинальные лицензионные материалы +и исходники сохранены отдельно в `third_party/napi/` и `third_party/cabi/`. +Корневые `LICENSE-MIT` и `LICENSE-APACHE` относятся к собственному коду проекта; +для включённых сторонних материалов сохраняются исходные условия. diff --git a/npm/darwin-arm64/README.zh.md b/npm/darwin-arm64/README.zh.md index f06ede7..4bc6358 100644 --- a/npm/darwin-arm64/README.zh.md +++ b/npm/darwin-arm64/README.zh.md @@ -1,5 +1,13 @@ # `@ktav-lang/js-darwin-arm64` 平台二进制包 -此包包含用于 `aarch64-apple-darwin` 的预构建 N-API 和 C ABI 库。它是 -[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -的可选依赖,通常会自动安装;使用 JavaScript API 时请安装主包。 +此包包含兼容平台 `aarch64-apple-darwin` 的预构建 N-API 和 C ABI 库。它是 +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) 的可选依赖, +通常会自动安装;使用 JavaScript API 时请安装主包。 + +平台标识和文件名用于保持加载器兼容性,不代表实际使用的编译器。Windows 包保留 +含 `msvc` 的旧名称,而本次构建中的库使用 GNU/LLVM。 +`native-package-manifest.json` 记录每个库的实际 target、源代码标识及 notices 哈希。 + +完整的第三方 notices 及所需的原始法律和源代码材料分别保存在 +`third_party/napi/` 和 `third_party/cabi/` 中。根目录中的 `LICENSE-MIT` 和 +`LICENSE-APACHE` 适用于项目自身代码;捆绑的第三方材料保留其原始条款。 diff --git a/npm/darwin-x64/README.md b/npm/darwin-x64/README.md index d250738..8c5baa0 100644 --- a/npm/darwin-x64/README.md +++ b/npm/darwin-x64/README.md @@ -1,6 +1,16 @@ # `@ktav-lang/js-darwin-x64` platform binaries -This package contains the prebuilt N-API and C ABI libraries for -`x86_64-apple-darwin`. It is an optional dependency of [`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -and is normally installed automatically; install the main package to -use the JavaScript API. +This package contains the prebuilt N-API and C ABI libraries for the +compatibility platform `x86_64-apple-darwin`. It is an optional dependency of +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) and is normally +installed automatically; install the main package to use the JavaScript API. + +Platform identifiers and filenames preserve loader compatibility; they do not +identify the compiler used. Windows packages retain their legacy `msvc` names, +while the libraries in this build use GNU/LLVM. `native-package-manifest.json` +records the actual target, source identity and notice hashes for each library. + +Complete third-party notices and required original legal/source materials are +kept separately under `third_party/napi/` and `third_party/cabi/`. The root +`LICENSE-MIT` and `LICENSE-APACHE` files cover the project's own code; the bundled +third-party materials retain their original terms. diff --git a/npm/darwin-x64/README.ru.md b/npm/darwin-x64/README.ru.md index f71cef1..ba71dc3 100644 --- a/npm/darwin-x64/README.ru.md +++ b/npm/darwin-x64/README.ru.md @@ -1,7 +1,17 @@ # Платформенные бинарники `@ktav-lang/js-darwin-x64` -Этот пакет содержит готовые библиотеки N-API и C ABI для +Этот пакет содержит готовые библиотеки N-API и C ABI для платформы совместимости `x86_64-apple-darwin`. Он является необязательной зависимостью -[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -и обычно устанавливается автоматически. Для JavaScript API установите -основной пакет. +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) и обычно +устанавливается автоматически. Для JavaScript API установите основной пакет. + +Обозначения платформ и имена файлов сохраняют совместимость с загрузчиками, +но не определяют использованный компилятор. Windows-пакеты сохраняют прежние +имена с `msvc`, а библиотеки этой сборки собраны GNU/LLVM. +`native-package-manifest.json` содержит фактический target, идентификатор исходников +и хеши notices каждой библиотеки. + +Полные third-party notices и необходимые оригинальные лицензионные материалы +и исходники сохранены отдельно в `third_party/napi/` и `third_party/cabi/`. +Корневые `LICENSE-MIT` и `LICENSE-APACHE` относятся к собственному коду проекта; +для включённых сторонних материалов сохраняются исходные условия. diff --git a/npm/darwin-x64/README.zh.md b/npm/darwin-x64/README.zh.md index 8e4b283..0fd0393 100644 --- a/npm/darwin-x64/README.zh.md +++ b/npm/darwin-x64/README.zh.md @@ -1,5 +1,13 @@ # `@ktav-lang/js-darwin-x64` 平台二进制包 -此包包含用于 `x86_64-apple-darwin` 的预构建 N-API 和 C ABI 库。它是 -[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -的可选依赖,通常会自动安装;使用 JavaScript API 时请安装主包。 +此包包含兼容平台 `x86_64-apple-darwin` 的预构建 N-API 和 C ABI 库。它是 +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) 的可选依赖, +通常会自动安装;使用 JavaScript API 时请安装主包。 + +平台标识和文件名用于保持加载器兼容性,不代表实际使用的编译器。Windows 包保留 +含 `msvc` 的旧名称,而本次构建中的库使用 GNU/LLVM。 +`native-package-manifest.json` 记录每个库的实际 target、源代码标识及 notices 哈希。 + +完整的第三方 notices 及所需的原始法律和源代码材料分别保存在 +`third_party/napi/` 和 `third_party/cabi/` 中。根目录中的 `LICENSE-MIT` 和 +`LICENSE-APACHE` 适用于项目自身代码;捆绑的第三方材料保留其原始条款。 diff --git a/npm/linux-arm64-gnu/README.md b/npm/linux-arm64-gnu/README.md index 0212d0f..59597e6 100644 --- a/npm/linux-arm64-gnu/README.md +++ b/npm/linux-arm64-gnu/README.md @@ -1,6 +1,16 @@ # `@ktav-lang/js-linux-arm64-gnu` platform binaries -This package contains the prebuilt N-API and C ABI libraries for -`aarch64-unknown-linux-gnu`. It is an optional dependency of [`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -and is normally installed automatically; install the main package to -use the JavaScript API. +This package contains the prebuilt N-API and C ABI libraries for the +compatibility platform `aarch64-unknown-linux-gnu`. It is an optional dependency of +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) and is normally +installed automatically; install the main package to use the JavaScript API. + +Platform identifiers and filenames preserve loader compatibility; they do not +identify the compiler used. Windows packages retain their legacy `msvc` names, +while the libraries in this build use GNU/LLVM. `native-package-manifest.json` +records the actual target, source identity and notice hashes for each library. + +Complete third-party notices and required original legal/source materials are +kept separately under `third_party/napi/` and `third_party/cabi/`. The root +`LICENSE-MIT` and `LICENSE-APACHE` files cover the project's own code; the bundled +third-party materials retain their original terms. diff --git a/npm/linux-arm64-gnu/README.ru.md b/npm/linux-arm64-gnu/README.ru.md index 8926965..916e834 100644 --- a/npm/linux-arm64-gnu/README.ru.md +++ b/npm/linux-arm64-gnu/README.ru.md @@ -1,7 +1,17 @@ # Платформенные бинарники `@ktav-lang/js-linux-arm64-gnu` -Этот пакет содержит готовые библиотеки N-API и C ABI для +Этот пакет содержит готовые библиотеки N-API и C ABI для платформы совместимости `aarch64-unknown-linux-gnu`. Он является необязательной зависимостью -[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -и обычно устанавливается автоматически. Для JavaScript API установите -основной пакет. +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) и обычно +устанавливается автоматически. Для JavaScript API установите основной пакет. + +Обозначения платформ и имена файлов сохраняют совместимость с загрузчиками, +но не определяют использованный компилятор. Windows-пакеты сохраняют прежние +имена с `msvc`, а библиотеки этой сборки собраны GNU/LLVM. +`native-package-manifest.json` содержит фактический target, идентификатор исходников +и хеши notices каждой библиотеки. + +Полные third-party notices и необходимые оригинальные лицензионные материалы +и исходники сохранены отдельно в `third_party/napi/` и `third_party/cabi/`. +Корневые `LICENSE-MIT` и `LICENSE-APACHE` относятся к собственному коду проекта; +для включённых сторонних материалов сохраняются исходные условия. diff --git a/npm/linux-arm64-gnu/README.zh.md b/npm/linux-arm64-gnu/README.zh.md index ec68350..167f5fc 100644 --- a/npm/linux-arm64-gnu/README.zh.md +++ b/npm/linux-arm64-gnu/README.zh.md @@ -1,5 +1,13 @@ # `@ktav-lang/js-linux-arm64-gnu` 平台二进制包 -此包包含用于 `aarch64-unknown-linux-gnu` 的预构建 N-API 和 C ABI 库。它是 -[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -的可选依赖,通常会自动安装;使用 JavaScript API 时请安装主包。 +此包包含兼容平台 `aarch64-unknown-linux-gnu` 的预构建 N-API 和 C ABI 库。它是 +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) 的可选依赖, +通常会自动安装;使用 JavaScript API 时请安装主包。 + +平台标识和文件名用于保持加载器兼容性,不代表实际使用的编译器。Windows 包保留 +含 `msvc` 的旧名称,而本次构建中的库使用 GNU/LLVM。 +`native-package-manifest.json` 记录每个库的实际 target、源代码标识及 notices 哈希。 + +完整的第三方 notices 及所需的原始法律和源代码材料分别保存在 +`third_party/napi/` 和 `third_party/cabi/` 中。根目录中的 `LICENSE-MIT` 和 +`LICENSE-APACHE` 适用于项目自身代码;捆绑的第三方材料保留其原始条款。 diff --git a/npm/linux-arm64-musl/README.md b/npm/linux-arm64-musl/README.md index 16a21df..47540e4 100644 --- a/npm/linux-arm64-musl/README.md +++ b/npm/linux-arm64-musl/README.md @@ -1,6 +1,16 @@ # `@ktav-lang/js-linux-arm64-musl` platform binaries -This package contains the prebuilt N-API and C ABI libraries for -`aarch64-unknown-linux-musl`. It is an optional dependency of [`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -and is normally installed automatically; install the main package to -use the JavaScript API. +This package contains the prebuilt N-API and C ABI libraries for the +compatibility platform `aarch64-unknown-linux-musl`. It is an optional dependency of +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) and is normally +installed automatically; install the main package to use the JavaScript API. + +Platform identifiers and filenames preserve loader compatibility; they do not +identify the compiler used. Windows packages retain their legacy `msvc` names, +while the libraries in this build use GNU/LLVM. `native-package-manifest.json` +records the actual target, source identity and notice hashes for each library. + +Complete third-party notices and required original legal/source materials are +kept separately under `third_party/napi/` and `third_party/cabi/`. The root +`LICENSE-MIT` and `LICENSE-APACHE` files cover the project's own code; the bundled +third-party materials retain their original terms. diff --git a/npm/linux-arm64-musl/README.ru.md b/npm/linux-arm64-musl/README.ru.md index 458cfd8..6973c15 100644 --- a/npm/linux-arm64-musl/README.ru.md +++ b/npm/linux-arm64-musl/README.ru.md @@ -1,7 +1,17 @@ # Платформенные бинарники `@ktav-lang/js-linux-arm64-musl` -Этот пакет содержит готовые библиотеки N-API и C ABI для +Этот пакет содержит готовые библиотеки N-API и C ABI для платформы совместимости `aarch64-unknown-linux-musl`. Он является необязательной зависимостью -[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -и обычно устанавливается автоматически. Для JavaScript API установите -основной пакет. +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) и обычно +устанавливается автоматически. Для JavaScript API установите основной пакет. + +Обозначения платформ и имена файлов сохраняют совместимость с загрузчиками, +но не определяют использованный компилятор. Windows-пакеты сохраняют прежние +имена с `msvc`, а библиотеки этой сборки собраны GNU/LLVM. +`native-package-manifest.json` содержит фактический target, идентификатор исходников +и хеши notices каждой библиотеки. + +Полные third-party notices и необходимые оригинальные лицензионные материалы +и исходники сохранены отдельно в `third_party/napi/` и `third_party/cabi/`. +Корневые `LICENSE-MIT` и `LICENSE-APACHE` относятся к собственному коду проекта; +для включённых сторонних материалов сохраняются исходные условия. diff --git a/npm/linux-arm64-musl/README.zh.md b/npm/linux-arm64-musl/README.zh.md index 01e7e5c..b31f6c7 100644 --- a/npm/linux-arm64-musl/README.zh.md +++ b/npm/linux-arm64-musl/README.zh.md @@ -1,5 +1,13 @@ # `@ktav-lang/js-linux-arm64-musl` 平台二进制包 -此包包含用于 `aarch64-unknown-linux-musl` 的预构建 N-API 和 C ABI 库。它是 -[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -的可选依赖,通常会自动安装;使用 JavaScript API 时请安装主包。 +此包包含兼容平台 `aarch64-unknown-linux-musl` 的预构建 N-API 和 C ABI 库。它是 +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) 的可选依赖, +通常会自动安装;使用 JavaScript API 时请安装主包。 + +平台标识和文件名用于保持加载器兼容性,不代表实际使用的编译器。Windows 包保留 +含 `msvc` 的旧名称,而本次构建中的库使用 GNU/LLVM。 +`native-package-manifest.json` 记录每个库的实际 target、源代码标识及 notices 哈希。 + +完整的第三方 notices 及所需的原始法律和源代码材料分别保存在 +`third_party/napi/` 和 `third_party/cabi/` 中。根目录中的 `LICENSE-MIT` 和 +`LICENSE-APACHE` 适用于项目自身代码;捆绑的第三方材料保留其原始条款。 diff --git a/npm/linux-x64-gnu/README.md b/npm/linux-x64-gnu/README.md index 2d8a824..0a85872 100644 --- a/npm/linux-x64-gnu/README.md +++ b/npm/linux-x64-gnu/README.md @@ -1,6 +1,16 @@ # `@ktav-lang/js-linux-x64-gnu` platform binaries -This package contains the prebuilt N-API and C ABI libraries for -`x86_64-unknown-linux-gnu`. It is an optional dependency of [`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -and is normally installed automatically; install the main package to -use the JavaScript API. +This package contains the prebuilt N-API and C ABI libraries for the +compatibility platform `x86_64-unknown-linux-gnu`. It is an optional dependency of +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) and is normally +installed automatically; install the main package to use the JavaScript API. + +Platform identifiers and filenames preserve loader compatibility; they do not +identify the compiler used. Windows packages retain their legacy `msvc` names, +while the libraries in this build use GNU/LLVM. `native-package-manifest.json` +records the actual target, source identity and notice hashes for each library. + +Complete third-party notices and required original legal/source materials are +kept separately under `third_party/napi/` and `third_party/cabi/`. The root +`LICENSE-MIT` and `LICENSE-APACHE` files cover the project's own code; the bundled +third-party materials retain their original terms. diff --git a/npm/linux-x64-gnu/README.ru.md b/npm/linux-x64-gnu/README.ru.md index 9d6b607..563333b 100644 --- a/npm/linux-x64-gnu/README.ru.md +++ b/npm/linux-x64-gnu/README.ru.md @@ -1,7 +1,17 @@ # Платформенные бинарники `@ktav-lang/js-linux-x64-gnu` -Этот пакет содержит готовые библиотеки N-API и C ABI для +Этот пакет содержит готовые библиотеки N-API и C ABI для платформы совместимости `x86_64-unknown-linux-gnu`. Он является необязательной зависимостью -[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -и обычно устанавливается автоматически. Для JavaScript API установите -основной пакет. +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) и обычно +устанавливается автоматически. Для JavaScript API установите основной пакет. + +Обозначения платформ и имена файлов сохраняют совместимость с загрузчиками, +но не определяют использованный компилятор. Windows-пакеты сохраняют прежние +имена с `msvc`, а библиотеки этой сборки собраны GNU/LLVM. +`native-package-manifest.json` содержит фактический target, идентификатор исходников +и хеши notices каждой библиотеки. + +Полные third-party notices и необходимые оригинальные лицензионные материалы +и исходники сохранены отдельно в `third_party/napi/` и `third_party/cabi/`. +Корневые `LICENSE-MIT` и `LICENSE-APACHE` относятся к собственному коду проекта; +для включённых сторонних материалов сохраняются исходные условия. diff --git a/npm/linux-x64-gnu/README.zh.md b/npm/linux-x64-gnu/README.zh.md index 0ef0551..75d45b7 100644 --- a/npm/linux-x64-gnu/README.zh.md +++ b/npm/linux-x64-gnu/README.zh.md @@ -1,5 +1,13 @@ # `@ktav-lang/js-linux-x64-gnu` 平台二进制包 -此包包含用于 `x86_64-unknown-linux-gnu` 的预构建 N-API 和 C ABI 库。它是 -[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -的可选依赖,通常会自动安装;使用 JavaScript API 时请安装主包。 +此包包含兼容平台 `x86_64-unknown-linux-gnu` 的预构建 N-API 和 C ABI 库。它是 +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) 的可选依赖, +通常会自动安装;使用 JavaScript API 时请安装主包。 + +平台标识和文件名用于保持加载器兼容性,不代表实际使用的编译器。Windows 包保留 +含 `msvc` 的旧名称,而本次构建中的库使用 GNU/LLVM。 +`native-package-manifest.json` 记录每个库的实际 target、源代码标识及 notices 哈希。 + +完整的第三方 notices 及所需的原始法律和源代码材料分别保存在 +`third_party/napi/` 和 `third_party/cabi/` 中。根目录中的 `LICENSE-MIT` 和 +`LICENSE-APACHE` 适用于项目自身代码;捆绑的第三方材料保留其原始条款。 diff --git a/npm/linux-x64-musl/README.md b/npm/linux-x64-musl/README.md index af9f7d2..e274413 100644 --- a/npm/linux-x64-musl/README.md +++ b/npm/linux-x64-musl/README.md @@ -1,6 +1,16 @@ # `@ktav-lang/js-linux-x64-musl` platform binaries -This package contains the prebuilt N-API and C ABI libraries for -`x86_64-unknown-linux-musl`. It is an optional dependency of [`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -and is normally installed automatically; install the main package to -use the JavaScript API. +This package contains the prebuilt N-API and C ABI libraries for the +compatibility platform `x86_64-unknown-linux-musl`. It is an optional dependency of +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) and is normally +installed automatically; install the main package to use the JavaScript API. + +Platform identifiers and filenames preserve loader compatibility; they do not +identify the compiler used. Windows packages retain their legacy `msvc` names, +while the libraries in this build use GNU/LLVM. `native-package-manifest.json` +records the actual target, source identity and notice hashes for each library. + +Complete third-party notices and required original legal/source materials are +kept separately under `third_party/napi/` and `third_party/cabi/`. The root +`LICENSE-MIT` and `LICENSE-APACHE` files cover the project's own code; the bundled +third-party materials retain their original terms. diff --git a/npm/linux-x64-musl/README.ru.md b/npm/linux-x64-musl/README.ru.md index a5f2ebd..4464e3f 100644 --- a/npm/linux-x64-musl/README.ru.md +++ b/npm/linux-x64-musl/README.ru.md @@ -1,7 +1,17 @@ # Платформенные бинарники `@ktav-lang/js-linux-x64-musl` -Этот пакет содержит готовые библиотеки N-API и C ABI для +Этот пакет содержит готовые библиотеки N-API и C ABI для платформы совместимости `x86_64-unknown-linux-musl`. Он является необязательной зависимостью -[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -и обычно устанавливается автоматически. Для JavaScript API установите -основной пакет. +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) и обычно +устанавливается автоматически. Для JavaScript API установите основной пакет. + +Обозначения платформ и имена файлов сохраняют совместимость с загрузчиками, +но не определяют использованный компилятор. Windows-пакеты сохраняют прежние +имена с `msvc`, а библиотеки этой сборки собраны GNU/LLVM. +`native-package-manifest.json` содержит фактический target, идентификатор исходников +и хеши notices каждой библиотеки. + +Полные third-party notices и необходимые оригинальные лицензионные материалы +и исходники сохранены отдельно в `third_party/napi/` и `third_party/cabi/`. +Корневые `LICENSE-MIT` и `LICENSE-APACHE` относятся к собственному коду проекта; +для включённых сторонних материалов сохраняются исходные условия. diff --git a/npm/linux-x64-musl/README.zh.md b/npm/linux-x64-musl/README.zh.md index 4f1de7f..447f494 100644 --- a/npm/linux-x64-musl/README.zh.md +++ b/npm/linux-x64-musl/README.zh.md @@ -1,5 +1,13 @@ # `@ktav-lang/js-linux-x64-musl` 平台二进制包 -此包包含用于 `x86_64-unknown-linux-musl` 的预构建 N-API 和 C ABI 库。它是 -[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -的可选依赖,通常会自动安装;使用 JavaScript API 时请安装主包。 +此包包含兼容平台 `x86_64-unknown-linux-musl` 的预构建 N-API 和 C ABI 库。它是 +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) 的可选依赖, +通常会自动安装;使用 JavaScript API 时请安装主包。 + +平台标识和文件名用于保持加载器兼容性,不代表实际使用的编译器。Windows 包保留 +含 `msvc` 的旧名称,而本次构建中的库使用 GNU/LLVM。 +`native-package-manifest.json` 记录每个库的实际 target、源代码标识及 notices 哈希。 + +完整的第三方 notices 及所需的原始法律和源代码材料分别保存在 +`third_party/napi/` 和 `third_party/cabi/` 中。根目录中的 `LICENSE-MIT` 和 +`LICENSE-APACHE` 适用于项目自身代码;捆绑的第三方材料保留其原始条款。 diff --git a/npm/win32-arm64-msvc/README.md b/npm/win32-arm64-msvc/README.md index c0deff0..ae0fed9 100644 --- a/npm/win32-arm64-msvc/README.md +++ b/npm/win32-arm64-msvc/README.md @@ -1,6 +1,16 @@ # `@ktav-lang/js-win32-arm64-msvc` platform binaries -This package contains the prebuilt N-API and C ABI libraries for -`aarch64-pc-windows-msvc`. It is an optional dependency of [`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -and is normally installed automatically; install the main package to -use the JavaScript API. +This package contains the prebuilt N-API and C ABI libraries for the +compatibility platform `aarch64-pc-windows-msvc`. It is an optional dependency of +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) and is normally +installed automatically; install the main package to use the JavaScript API. + +Platform identifiers and filenames preserve loader compatibility; they do not +identify the compiler used. Windows packages retain their legacy `msvc` names, +while the libraries in this build use GNU/LLVM. `native-package-manifest.json` +records the actual target, source identity and notice hashes for each library. + +Complete third-party notices and required original legal/source materials are +kept separately under `third_party/napi/` and `third_party/cabi/`. The root +`LICENSE-MIT` and `LICENSE-APACHE` files cover the project's own code; the bundled +third-party materials retain their original terms. diff --git a/npm/win32-arm64-msvc/README.ru.md b/npm/win32-arm64-msvc/README.ru.md index 8f27221..a19e23f 100644 --- a/npm/win32-arm64-msvc/README.ru.md +++ b/npm/win32-arm64-msvc/README.ru.md @@ -1,7 +1,17 @@ # Платформенные бинарники `@ktav-lang/js-win32-arm64-msvc` -Этот пакет содержит готовые библиотеки N-API и C ABI для +Этот пакет содержит готовые библиотеки N-API и C ABI для платформы совместимости `aarch64-pc-windows-msvc`. Он является необязательной зависимостью -[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -и обычно устанавливается автоматически. Для JavaScript API установите -основной пакет. +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) и обычно +устанавливается автоматически. Для JavaScript API установите основной пакет. + +Обозначения платформ и имена файлов сохраняют совместимость с загрузчиками, +но не определяют использованный компилятор. Windows-пакеты сохраняют прежние +имена с `msvc`, а библиотеки этой сборки собраны GNU/LLVM. +`native-package-manifest.json` содержит фактический target, идентификатор исходников +и хеши notices каждой библиотеки. + +Полные third-party notices и необходимые оригинальные лицензионные материалы +и исходники сохранены отдельно в `third_party/napi/` и `third_party/cabi/`. +Корневые `LICENSE-MIT` и `LICENSE-APACHE` относятся к собственному коду проекта; +для включённых сторонних материалов сохраняются исходные условия. diff --git a/npm/win32-arm64-msvc/README.zh.md b/npm/win32-arm64-msvc/README.zh.md index cfa45b7..acf8b0d 100644 --- a/npm/win32-arm64-msvc/README.zh.md +++ b/npm/win32-arm64-msvc/README.zh.md @@ -1,5 +1,13 @@ # `@ktav-lang/js-win32-arm64-msvc` 平台二进制包 -此包包含用于 `aarch64-pc-windows-msvc` 的预构建 N-API 和 C ABI 库。它是 -[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -的可选依赖,通常会自动安装;使用 JavaScript API 时请安装主包。 +此包包含兼容平台 `aarch64-pc-windows-msvc` 的预构建 N-API 和 C ABI 库。它是 +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) 的可选依赖, +通常会自动安装;使用 JavaScript API 时请安装主包。 + +平台标识和文件名用于保持加载器兼容性,不代表实际使用的编译器。Windows 包保留 +含 `msvc` 的旧名称,而本次构建中的库使用 GNU/LLVM。 +`native-package-manifest.json` 记录每个库的实际 target、源代码标识及 notices 哈希。 + +完整的第三方 notices 及所需的原始法律和源代码材料分别保存在 +`third_party/napi/` 和 `third_party/cabi/` 中。根目录中的 `LICENSE-MIT` 和 +`LICENSE-APACHE` 适用于项目自身代码;捆绑的第三方材料保留其原始条款。 diff --git a/npm/win32-x64-msvc/README.md b/npm/win32-x64-msvc/README.md index 07094d0..5dd2557 100644 --- a/npm/win32-x64-msvc/README.md +++ b/npm/win32-x64-msvc/README.md @@ -1,6 +1,16 @@ # `@ktav-lang/js-win32-x64-msvc` platform binaries -This package contains the prebuilt N-API and C ABI libraries for -`x86_64-pc-windows-msvc`. It is an optional dependency of [`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -and is normally installed automatically; install the main package to -use the JavaScript API. +This package contains the prebuilt N-API and C ABI libraries for the +compatibility platform `x86_64-pc-windows-msvc`. It is an optional dependency of +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) and is normally +installed automatically; install the main package to use the JavaScript API. + +Platform identifiers and filenames preserve loader compatibility; they do not +identify the compiler used. Windows packages retain their legacy `msvc` names, +while the libraries in this build use GNU/LLVM. `native-package-manifest.json` +records the actual target, source identity and notice hashes for each library. + +Complete third-party notices and required original legal/source materials are +kept separately under `third_party/napi/` and `third_party/cabi/`. The root +`LICENSE-MIT` and `LICENSE-APACHE` files cover the project's own code; the bundled +third-party materials retain their original terms. diff --git a/npm/win32-x64-msvc/README.ru.md b/npm/win32-x64-msvc/README.ru.md index 1308136..8a7b65c 100644 --- a/npm/win32-x64-msvc/README.ru.md +++ b/npm/win32-x64-msvc/README.ru.md @@ -1,7 +1,17 @@ # Платформенные бинарники `@ktav-lang/js-win32-x64-msvc` -Этот пакет содержит готовые библиотеки N-API и C ABI для +Этот пакет содержит готовые библиотеки N-API и C ABI для платформы совместимости `x86_64-pc-windows-msvc`. Он является необязательной зависимостью -[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -и обычно устанавливается автоматически. Для JavaScript API установите -основной пакет. +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) и обычно +устанавливается автоматически. Для JavaScript API установите основной пакет. + +Обозначения платформ и имена файлов сохраняют совместимость с загрузчиками, +но не определяют использованный компилятор. Windows-пакеты сохраняют прежние +имена с `msvc`, а библиотеки этой сборки собраны GNU/LLVM. +`native-package-manifest.json` содержит фактический target, идентификатор исходников +и хеши notices каждой библиотеки. + +Полные third-party notices и необходимые оригинальные лицензионные материалы +и исходники сохранены отдельно в `third_party/napi/` и `third_party/cabi/`. +Корневые `LICENSE-MIT` и `LICENSE-APACHE` относятся к собственному коду проекта; +для включённых сторонних материалов сохраняются исходные условия. diff --git a/npm/win32-x64-msvc/README.zh.md b/npm/win32-x64-msvc/README.zh.md index 5a6acd3..ab85280 100644 --- a/npm/win32-x64-msvc/README.zh.md +++ b/npm/win32-x64-msvc/README.zh.md @@ -1,5 +1,13 @@ # `@ktav-lang/js-win32-x64-msvc` 平台二进制包 -此包包含用于 `x86_64-pc-windows-msvc` 的预构建 N-API 和 C ABI 库。它是 -[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) -的可选依赖,通常会自动安装;使用 JavaScript API 时请安装主包。 +此包包含兼容平台 `x86_64-pc-windows-msvc` 的预构建 N-API 和 C ABI 库。它是 +[`@ktav-lang/ktav`](https://www.npmjs.com/package/@ktav-lang/ktav) 的可选依赖, +通常会自动安装;使用 JavaScript API 时请安装主包。 + +平台标识和文件名用于保持加载器兼容性,不代表实际使用的编译器。Windows 包保留 +含 `msvc` 的旧名称,而本次构建中的库使用 GNU/LLVM。 +`native-package-manifest.json` 记录每个库的实际 target、源代码标识及 notices 哈希。 + +完整的第三方 notices 及所需的原始法律和源代码材料分别保存在 +`third_party/napi/` 和 `third_party/cabi/` 中。根目录中的 `LICENSE-MIT` 和 +`LICENSE-APACHE` 适用于项目自身代码;捆绑的第三方材料保留其原始条款。 diff --git a/scripts/native_npm_payload.py b/scripts/native_npm_payload.py index 24d9d2c..d77fa38 100644 --- a/scripts/native_npm_payload.py +++ b/scripts/native_npm_payload.py @@ -97,7 +97,7 @@ def files(root): if len(result) >= 4096 or total > 256 * 1024 * 1024: raise ValueError('payload inventory exceeds bound') result.append({'path': name, 'bytes': len(raw), 'sha256': sha(raw)}) - return result + return sorted(result, key=lambda item: item['path']) def check_manifest(root, manifest_name): From b1ecc29f6364fbf6f18cd0e6665cc2f031176db9 Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sun, 1 Nov 2026 15:07:33 +0100 Subject: [PATCH 48/51] test(licenses): exercise installed native npm tarballs Run the verified main and matching platform archives on eight genuine CPU/libc combinations. Install only local tarballs offline with fresh caches and lifecycle scripts disabled; never invoke a build tool. Require the installed NAPI module in the actual runtime cache and exercise default C ABI package resolution without library-path or build-tree overrides. Reuse the original complete spec-0.8 runners inside the installed package, preserve every assertion and verify installed file hashes before and after the consumers. Use native Node/Bun/Deno hosts where supported, and the existing checksum-bound Alpine/Node/Bun tools for both musl CPUs. Record runtime architectures and exact binary/archive identities; claim no Deno-musl execution. Gate the shared release workflow on consumers, without dispatching any publication job or changing versions. Co-Authored-By: Claude Opus 5.5 --- .../workflows/native-npm-release-build.yml | 3 + .github/workflows/packed-npm-consumers.yml | 192 ++++++++++++++++++ scripts/consume_packed_native.mjs | 124 +++++++++++ 3 files changed, 319 insertions(+) create mode 100644 .github/workflows/packed-npm-consumers.yml create mode 100644 scripts/consume_packed_native.mjs diff --git a/.github/workflows/native-npm-release-build.yml b/.github/workflows/native-npm-release-build.yml index e3e688d..385903d 100644 --- a/.github/workflows/native-npm-release-build.yml +++ b/.github/workflows/native-npm-release-build.yml @@ -31,6 +31,9 @@ jobs: wasm: needs: contracts uses: ./.github/workflows/wasm-notice-check.yml + installed-consumers: + needs: assemble + uses: ./.github/workflows/packed-npm-consumers.yml assemble: name: Pack eight native packages and the main package needs: [gnu-napi, gnu-cabi, macos-native, musl-native, windows-cabi, windows-napi, wasm] diff --git a/.github/workflows/packed-npm-consumers.yml b/.github/workflows/packed-npm-consumers.yml new file mode 100644 index 0000000..bac8d9d --- /dev/null +++ b/.github/workflows/packed-npm-consumers.yml @@ -0,0 +1,192 @@ +name: Installed native npm consumers + +on: + workflow_call: + +permissions: + contents: read + +jobs: + native: + name: Packed consumers / ${{ matrix.rid }} + runs-on: ${{ matrix.runner }} + timeout-minutes: 25 + strategy: + fail-fast: false + matrix: + include: + - rid: linux-x64-gnu + runner: ubuntu-24.04 + arch: x64 + - rid: linux-arm64-gnu + runner: ubuntu-24.04-arm + arch: arm64 + - rid: darwin-x64 + runner: macos-15-intel + arch: x64 + - rid: darwin-arm64 + runner: macos-latest + arch: arm64 + - rid: win32-x64-msvc + runner: windows-latest + arch: x64 + - rid: win32-arm64-msvc + runner: windows-11-arm + arch: arm64 + steps: + - uses: actions/checkout@v4 + - name: Preserve only the installed-package consumer tooling + shell: python + run: | + import os + from pathlib import Path + import shutil + destination = Path(os.environ['RUNNER_TEMP']) / 'consume_packed_native.mjs' + if destination.exists(): + raise SystemExit('consumer tool staging must be new') + shutil.copyfile('scripts/consume_packed_native.mjs', destination) + - uses: actions/checkout@v4 + with: + ref: 562deb3fde092d63a78f359be095e5079929d0d1 + submodules: recursive + persist-credentials: false + - uses: actions/setup-node@v4 + with: + node-version: '24' + architecture: ${{ matrix.arch }} + - uses: oven-sh/setup-bun@v2 + with: + bun-version: '1.4.4' + - uses: denoland/setup-deno@v2 + with: + deno-version: 'v2.9.8' + - uses: actions/download-artifact@v4 + with: + name: native-npm-release-packages + path: ${{ runner.temp }}/packed-release + - name: Run default package locators and the original complete corpus + env: + PACKED_RID: ${{ matrix.rid }} + shell: python + run: | + import os + from pathlib import Path + import subprocess + root = Path(os.environ['RUNNER_TEMP']) + subprocess.run(['node', '--check', str(root / 'consume_packed_native.mjs')], check=True) + subprocess.run(['node', str(root / 'consume_packed_native.mjs'), str(root / 'packed-release'), str(Path.cwd()), str(root / 'ktav packed consumer'), os.environ['PACKED_RID']], check=True) + - uses: actions/upload-artifact@v4 + if: always() + with: + name: packed-consumer-${{ matrix.rid }} + path: ${{ runner.temp }}/ktav packed consumer/proof/ + if-no-files-found: warn + + musl: + name: Packed consumers / ${{ matrix.rid }} + runs-on: ${{ matrix.runner }} + timeout-minutes: 25 + strategy: + fail-fast: false + matrix: + include: + - rid: linux-x64-musl + runner: ubuntu-24.04 + platform: linux/amd64 + arch: x64 + machine: x86_64 + bun: bun-linux-x64-musl + bun_sha: a5a8ccc5e74dcb883fe974f125a7bdb3b41e5195ed1b870e73f17effd3eb2b2d + - rid: linux-arm64-musl + runner: ubuntu-24.04-arm + platform: linux/arm64 + arch: arm64 + machine: aarch64 + bun: bun-linux-aarch64-musl + bun_sha: 57f01b02ac7113c61c935f28f38c2eab849e3c970dab21f8b640a87b1ef65009 + steps: + - uses: actions/checkout@v4 + - name: Preserve the reviewed consumer tool + shell: python + run: | + import os + from pathlib import Path + import shutil + destination = Path(os.environ['RUNNER_TEMP']) / 'consume_packed_native.mjs' + if destination.exists(): + raise SystemExit('consumer tool staging must be new') + shutil.copyfile('scripts/consume_packed_native.mjs', destination) + - uses: actions/checkout@v4 + with: + ref: 562deb3fde092d63a78f359be095e5079929d0d1 + submodules: recursive + persist-credentials: false + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - uses: actions/download-artifact@v4 + with: + name: native-npm-release-packages + path: ${{ runner.temp }}/packed-release + - name: Run actual installed-tarball Node and Bun consumers in pinned Alpine + env: + PACKED_RID: ${{ matrix.rid }} + PACKED_PLATFORM: ${{ matrix.platform }} + PACKED_MACHINE: ${{ matrix.machine }} + PACKED_BUN: ${{ matrix.bun }} + PACKED_BUN_SHA: ${{ matrix.bun_sha }} + shell: python + run: | + import hashlib + import os + from pathlib import Path + import platform + import shutil + import stat + import subprocess + import urllib.request + import zipfile + if platform.machine() != os.environ['PACKED_MACHINE']: + raise SystemExit('native matching-CPU runner required; no emulation') + root = Path(os.environ['RUNNER_TEMP']) + downloaded = root / 'packed-consumer-bun-original' + downloaded.mkdir() + archive = downloaded / 'bun.zip' + url = 'https://github.com/oven-sh/bun/releases/download/bun-v1.4.4/' + os.environ['PACKED_BUN'] + '.zip' + digest = hashlib.sha256() + size = 0 + with urllib.request.urlopen(url, timeout=120) as source, archive.open('xb') as destination: + while chunk := source.read(1024 * 1024): + size += len(chunk) + if size > 128 * 1024 * 1024: + raise SystemExit('Bun archive bound') + digest.update(chunk) + destination.write(chunk) + if digest.hexdigest() != os.environ['PACKED_BUN_SHA']: + raise SystemExit('Bun tool archive differs from reviewed bytes') + tools = root / 'packed-consumer-tools' + tools.mkdir() + shutil.copyfile(root / 'consume_packed_native.mjs', tools / 'consume_packed_native.mjs') + with zipfile.ZipFile(archive) as source: + member = source.getinfo(os.environ['PACKED_BUN'] + '/bun') + if member.is_dir() or member.file_size > 256 * 1024 * 1024 or stat.S_ISLNK(member.external_attr >> 16): + raise SystemExit('invalid Bun tool executable member') + with source.open(member) as input_file, (tools / 'bun').open('xb') as destination: + shutil.copyfileobj(input_file, destination, 1024 * 1024) + (tools / 'bun').chmod(0o755) + work = root / 'packed-musl-work' + work.mkdir() + image = 'node@sha256:fe4f6d74e20370acb04ad889077d14d0f64a9c8ea6a42bc60cddf1e844699914' + subprocess.run(['docker', 'pull', '--platform', os.environ['PACKED_PLATFORM'], image], check=True) + result = subprocess.run(['docker', 'run', '--rm', '--platform', os.environ['PACKED_PLATFORM'], '--network', 'none', '--mount', 'type=bind,source=' + str(root / 'packed-release') + ',target=/artifacts,readonly', '--mount', 'type=bind,source=' + str(Path.cwd()) + ',target=/source,readonly', '--mount', 'type=bind,source=' + str(tools) + ',target=/tools,readonly', '--mount', 'type=bind,source=' + str(work) + ',target=/work', '--workdir', '/work', '--env', 'RUNNER_ARCH=' + os.environ['RUNNER_ARCH'], '--env', 'BUN_EXECUTABLE=/tools/bun', image, 'node', '/tools/consume_packed_native.mjs', '/artifacts', '/source', '/work/ktav packed consumer', os.environ['PACKED_RID']], capture_output=True) + import sys + sys.stdout.buffer.write(result.stdout) + sys.stderr.buffer.write(result.stderr) + if result.returncode: + raise SystemExit('actual offline musl packaged consumer failed') + - uses: actions/upload-artifact@v4 + if: always() + with: + name: packed-consumer-${{ matrix.rid }} + path: ${{ runner.temp }}/packed-musl-work/ktav packed consumer/proof/ + if-no-files-found: warn diff --git a/scripts/consume_packed_native.mjs b/scripts/consume_packed_native.mjs new file mode 100644 index 0000000..f0fb3ab --- /dev/null +++ b/scripts/consume_packed_native.mjs @@ -0,0 +1,124 @@ +import assert from "node:assert/strict"; +import { createHash } from "node:crypto"; +import { execFileSync, spawnSync } from "node:child_process"; +import { cpSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, writeFileSync } from "node:fs"; +import { dirname, join, resolve } from "node:path"; + +const [archivesArg, sourceArg, workArg, rid] = process.argv.slice(2); +const archives = resolve(archivesArg); +const source = resolve(sourceArg); +const work = resolve(workArg); +const manifest = JSON.parse(readFileSync(join(archives, "native-npm-release-manifest.json"), "utf8")); +const arch = rid?.split("-")[1]; +const os = rid?.split("-")[0]; +assert.equal(manifest.source_ref, "562deb3fde092d63a78f359be095e5079929d0d1"); +assert.equal(manifest.packages.length, 9); +assert.equal(process.arch, arch); +assert.equal(process.platform, os); +assert.equal(process.env.RUNNER_ARCH?.toLowerCase(), arch === "arm64" ? "arm64" : "x64"); +if (os === "linux") { + const glibc = process.report.getReport().header.glibcVersionRuntime; + assert.equal(typeof glibc === "string", rid.endsWith("-gnu")); + if (rid.endsWith("-musl")) { + assert.ok(existsSync(arch === "arm64" ? "/lib/ld-musl-aarch64.so.1" : "/lib/ld-musl-x86_64.so.1")); + } +} +const sha = bytes => createHash("sha256").update(bytes).digest("hex"); +const selected = manifest.packages.find(item => item.rid === rid); +const mainRecord = manifest.packages.find(item => item.package === "@ktav-lang/ktav"); +assert.ok(selected && mainRecord); +assert.equal(selected.package, `@ktav-lang/js-${rid}`); +for (const item of [selected, mainRecord]) { + const bytes = readFileSync(join(archives, item.archive)); + assert.equal(bytes.length, item.bytes); + assert.equal(sha(bytes), item.sha256); + assert.equal(item.version, "0.8.1"); +} +assert.ok(!existsSync(work), "consumer directory must be new"); +mkdirSync(work); +const proof = join(work, "proof"); +mkdirSync(proof); +const environment = { ...process.env }; +for (const name of ["KTAV_LIB_PATH", "CARGO_TARGET_DIR", "NODE_PATH", "NODE_OPTIONS", "BUN_OPTIONS", "GITHUB_TOKEN", "GH_TOKEN", "NPM_TOKEN", "NODE_AUTH_TOKEN"]) delete environment[name]; +environment.PATH = environment.PATH.split(process.platform === "win32" ? ";" : ":").filter(value => !/[.]cargo|[.]rustup|llvm|visual studio|(?:^|[/\\])zig(?:[/\\]|$)/i.test(value)).join(process.platform === "win32" ? ";" : ":"); +environment.DENO_DIR = join(work, "deno-cache"); +const npmCandidates = [join(dirname(process.execPath), "node_modules/npm/bin/npm-cli.js"), join(dirname(process.execPath), "../lib/node_modules/npm/bin/npm-cli.js")]; +const npm = npmCandidates.find(existsSync); +assert.ok(npm, "npm CLI beside the actual Node runtime is required"); +writeFileSync(join(work, "package.json"), JSON.stringify({ private: true, type: "module", dependencies: { "@ktav-lang/ktav": "0.8.1", [selected.package]: "0.8.1" } }, null, 2) + "\n"); +const install = spawnSync(process.execPath, [npm, "install", "--offline", "--ignore-scripts", "--no-save", "--no-package-lock", "--no-audit", "--no-fund", "--omit=dev", "--cache", join(work, "npm-cache"), join(archives, mainRecord.archive), join(archives, selected.archive)], { cwd: work, env: environment, encoding: "utf8" }); +writeFileSync(join(proof, "npm-install-stdout.txt"), install.stdout ?? ""); +writeFileSync(join(proof, "npm-install-stderr.txt"), install.stderr ?? ""); +assert.equal(install.status, 0, install.stderr || String(install.error)); +const main = join(work, "node_modules/@ktav-lang/ktav"); +const native = join(work, "node_modules", ...selected.package.split("/")); +assert.equal(JSON.parse(readFileSync(join(main, "package.json"), "utf8")).version, "0.8.1"); +assert.equal(JSON.parse(readFileSync(join(native, "package.json"), "utf8")).version, "0.8.1"); +const installedManifest = JSON.parse(readFileSync(join(native, "native-package-manifest.json"), "utf8")); +assert.equal(installedManifest.tooling_ref, manifest.tooling_ref); +assert.deepEqual(installedManifest.roles, selected.roles); +const verifyInstalled = () => { + for (const item of installedManifest.files) { + const bytes = readFileSync(join(native, item.path)); + assert.equal(bytes.length, item.bytes); + assert.equal(sha(bytes), item.sha256, `installed file changed: ${item.path}`); + } +}; +verifyInstalled(); +const snapshot = (root, prefix = "") => { + const result = []; + for (const name of readdirSync(join(root, prefix)).sort()) { + const relative = prefix ? `${prefix}/${name}` : name; + const path = join(root, relative); + const stat = lstatSync(path); + assert.ok(!stat.isSymbolicLink(), "installed package symlink is unexpected"); + if (stat.isDirectory()) result.push(...snapshot(root, relative)); + else { + assert.ok(stat.isFile()); + const bytes = readFileSync(path); + result.push({ path: relative, bytes: bytes.length, sha256: sha(bytes) }); + } + } + return result; +}; +const initial = snapshot(main); +writeFileSync(join(proof, "installed-main-initial-manifest.json"), JSON.stringify(initial, null, 2) + "\n"); +assert.ok(!existsSync(join(main, "target")), "no build-tree C ABI override may mask package lookup"); +assert.ok(!existsSync(join(main, "dist/native")), "no local NAPI fallback may mask the installed package"); +cpSync(join(source, "tests"), join(main, "tests"), { recursive: true, errorOnExist: true, force: false }); +mkdirSync(join(main, "spec/versions/0.8"), { recursive: true }); +cpSync(join(source, "spec/versions/0.8/tests"), join(main, "spec/versions/0.8/tests"), { recursive: true, errorOnExist: true, force: false }); +const napi = realpathSync(join(native, selected.roles.napi.package_binary)); +const cabi = realpathSync(join(native, selected.roles.cabi.package_binary)); +const childEnvironment = { ...environment, PACKED_MAIN: main, PACKED_NATIVE: native, PACKED_NAPI: napi, PACKED_CABI: cabi, EXPECTED_ARCH: arch, EXPECTED_RID: rid, PACKED_PROOF: proof }; +const nodeScript = `import assert from "node:assert/strict";import {createRequire} from "node:module";import {realpathSync,readFileSync,writeFileSync} from "node:fs";import {createHash} from "node:crypto";import {pathToFileURL} from "node:url";assert.equal(process.arch,process.env.EXPECTED_ARCH);const entry=import.meta.resolve("@ktav-lang/ktav");assert.equal(realpathSync(new URL(entry)),realpathSync(process.env.PACKED_MAIN+"/dist/ts/node.js"));await import("@ktav-lang/ktav");const require=createRequire(import.meta.url);assert.deepEqual(Object.keys(require.cache).filter(p=>p.endsWith(".node")),[realpathSync(process.env.PACKED_NAPI)]);writeFileSync(process.env.PACKED_PROOF+"/node-loaded.json",JSON.stringify({binary_sha256:createHash("sha256").update(readFileSync(process.env.PACKED_NAPI)).digest("hex"),loaded_installed_addon:true}));await import(pathToFileURL(process.env.PACKED_MAIN+"/tests/node/run-node-napi.mjs").href);`; +const ffiScript = runtime => `import assert from "node:assert/strict";import {createRequire} from "node:module";import {realpathSync,readFileSync,writeFileSync,existsSync} from "node:fs";import {createHash} from "node:crypto";import {pathToFileURL} from "node:url";const arch=${runtime === "bun" ? "process.arch" : '({x86_64:"x64",aarch64:"arm64"})[Deno.build.arch]'};assert.equal(arch,process.env.EXPECTED_ARCH);assert.ok(!process.env.KTAV_LIB_PATH);assert.ok(!process.env.CARGO_TARGET_DIR);assert.ok(!existsSync(process.env.PACKED_MAIN+"/target/release"));const entry=import.meta.resolve("@ktav-lang/ktav/ffi");assert.equal(realpathSync(new URL(entry)),realpathSync(process.env.PACKED_MAIN+"/dist/ts/ffi-${runtime}.js"));const require=createRequire(entry);const library=require.resolve("@ktav-lang/js-"+process.env.EXPECTED_RID+"/"+process.env.PACKED_CABI.split(/[\\\\/]/).at(-1));assert.equal(realpathSync(library),realpathSync(process.env.PACKED_CABI));const api=await import("@ktav-lang/ktav/ffi");assert.deepEqual(await api.loads("service: packed\\n"),{service:"packed"});writeFileSync(process.env.PACKED_PROOF+"/${runtime}-loaded.json",JSON.stringify({binary_sha256:createHash("sha256").update(readFileSync(library)).digest("hex"),default_package_locator:true}));await import(pathToFileURL(process.env.PACKED_MAIN+"/tests/${runtime}/run-${runtime}-ffi.${runtime === "bun" ? "mjs" : "ts"}").href);`; +const scripts = [["node", process.execPath, nodeScript]]; +scripts.push(["bun", process.env.BUN_EXECUTABLE || "bun", ffiScript("bun")]); +if (!rid.endsWith("-musl")) scripts.push(["deno", "deno", ffiScript("deno")]); +const results = []; +for (const [runtime, executable, script] of scripts) { + const path = join(work, `preflight-${runtime}.mjs`); + writeFileSync(path, script + "\n"); + const args = runtime === "deno" ? ["run", "--no-config", "--no-lock", "--cached-only", "--node-modules-dir=manual", "--allow-ffi", "--allow-env", "--allow-read", `--allow-write=${proof}`, path] : [path]; + const result = spawnSync(executable, args, { cwd: work, env: childEnvironment, encoding: "utf8" }); + writeFileSync(join(proof, `${runtime}-stdout.txt`), result.stdout ?? ""); + writeFileSync(join(proof, `${runtime}-stderr.txt`), result.stderr ?? ""); + process.stdout.write(result.stdout ?? ""); + process.stderr.write(result.stderr ?? ""); + assert.equal(result.status, 0, `${runtime}: ${result.stderr || result.error}`); + const label = runtime === "node" ? "node-napi" : `${runtime}-ffi`; + const summary = new RegExp(`\\[${label}\\] (\\d+)/(\\d+) passed`).exec(result.stdout); + assert.ok(summary && summary[1] === summary[2] && Number(summary[1]) > 0, `${runtime}: complete corpus summary required`); + assert.ok(!result.stdout.toLowerCase().includes("skipping")); + const loaded = JSON.parse(readFileSync(join(proof, `${runtime}-loaded.json`), "utf8")); + assert.equal(loaded.binary_sha256, selected.roles[runtime === "node" ? "napi" : "cabi"].binary_sha256); + results.push({ runtime, corpus_passed: Number(summary[1]), binary_sha256: loaded.binary_sha256, version: execFileSync(executable, ["--version"], { env: environment, encoding: "utf8" }).trim() }); +} +verifyInstalled(); +for (const item of initial) { + const bytes = readFileSync(join(main, item.path)); + assert.equal(bytes.length, item.bytes); + assert.equal(sha(bytes), item.sha256, `installed main file changed: ${item.path}`); +} +writeFileSync(join(proof, "consumer-verification.json"), JSON.stringify({ rid, host_arch: process.arch, runner_arch: process.env.RUNNER_ARCH, node_version: process.version, source_ref: manifest.source_ref, tooling_ref: manifest.tooling_ref, main_archive_sha256: mainRecord.sha256, platform_archive_sha256: selected.sha256, lifecycle_scripts_disabled: true, offline_local_tarballs: true, native_execution: true, default_package_locators: true, build_tree_override: false, results, scope: "Actual matching-CPU installed-tarball consumers. No registry publication or Deno-musl execution claim." }, null, 2) + "\n"); From b31fdadff90f668e33da4b912fae22e01bef43fc Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sun, 1 Nov 2026 15:37:34 +0100 Subject: [PATCH 49/51] fix(ffi): decode installed library URLs as filesystem paths Actual offline installed-tarball consumers reproduced failed C ABI lookup because URL.pathname retains percent-encoded spaces and is not a Windows filesystem path. Use the standard node:url conversion in both Bun and Deno adapters; add no runtime package dependency. Backport only those two checksum-bound edits to the original 0.8.1 source used for the packed main package. Record original/compiled source hashes, enforce them in build and archive verification, and preserve the parser, ABI, dependency graph and complete corpus tests. Add source-overlay and atomic-preparation regression coverage. Fix Windows consumer PATH lookup after copying process.env: preserve its actual case-insensitive key spelling. Keep spaces, offline local archives, lifecycle disabling, default locators and every assertion. Do not add a library-path override or skip a failing runtime. Co-Authored-By: Claude Opus 5.5 --- .../workflows/native-npm-release-build.yml | 2 +- .github/workflows/wasm-notice-check.yml | 15 +- ci/fixtures/ffi-package-urls/ffi-bun.ts.txt | 282 ++++++++++++++++++ ci/fixtures/ffi-package-urls/ffi-deno.ts.txt | 281 +++++++++++++++++ ci/test_ffi_package_urls.py | 82 +++++ scripts/check_release_npm.py | 2 + scripts/consume_packed_native.mjs | 4 +- scripts/pack_native_npm.py | 2 + scripts/patch_ffi_package_urls.py | 57 ++++ ts/ffi-bun.ts | 4 +- ts/ffi-deno.ts | 4 +- 11 files changed, 726 insertions(+), 9 deletions(-) create mode 100644 ci/fixtures/ffi-package-urls/ffi-bun.ts.txt create mode 100644 ci/fixtures/ffi-package-urls/ffi-deno.ts.txt create mode 100644 ci/test_ffi_package_urls.py create mode 100644 scripts/patch_ffi_package_urls.py diff --git a/.github/workflows/native-npm-release-build.yml b/.github/workflows/native-npm-release-build.yml index 385903d..f77d42c 100644 --- a/.github/workflows/native-npm-release-build.yml +++ b/.github/workflows/native-npm-release-build.yml @@ -49,7 +49,7 @@ jobs: import shutil stage = Path(os.environ['RUNNER_TEMP']) / 'native-npm-assembly-tools' stage.mkdir() - for name in ['scripts/native_npm_payload.py', 'scripts/assemble_native_npm.py', 'scripts/check_native_npm.py', 'scripts/check_release_npm.py', 'scripts/pack_native_npm.py', 'scripts/check_wasm_npm.py', 'scripts/check_embedded_notices.py', 'scripts/windows_gnu_napi_variant.py']: + for name in ['scripts/native_npm_payload.py', 'scripts/assemble_native_npm.py', 'scripts/check_native_npm.py', 'scripts/check_release_npm.py', 'scripts/pack_native_npm.py', 'scripts/patch_ffi_package_urls.py', 'scripts/check_wasm_npm.py', 'scripts/check_embedded_notices.py', 'scripts/windows_gnu_napi_variant.py']: destination = stage / name destination.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(name, destination) diff --git a/.github/workflows/wasm-notice-check.yml b/.github/workflows/wasm-notice-check.yml index df6e507..293a168 100644 --- a/.github/workflows/wasm-notice-check.yml +++ b/.github/workflows/wasm-notice-check.yml @@ -23,7 +23,7 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'wasm-notice-tools' stage.mkdir() - for name in ['root-docs/PLATFORM-README/overview/body-1.md', 'Cargo.lock', 'ci/js-build-lock.json', 'ci/test_js_build_lock.py', 'scripts/wasm-notice-resource.mjs', 'tests/wasm-notice-resource.test.mjs', 'tests/test_wasm_npm.py', 'scripts/prepare_js_notices.py', 'scripts/check_wasm_npm.py', 'scripts/check-npm-licenses.mjs', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/check_embedded_notices.py', 'ci/about.toml', 'scripts/source_license_supplements.py', 'ci/test_js_source_supplements.py', 'ci/licenses/js-source-supplements.json']: + for name in ['scripts/patch_ffi_package_urls.py', 'ci/test_ffi_package_urls.py', 'ci/fixtures/ffi-package-urls/ffi-bun.ts.txt', 'ci/fixtures/ffi-package-urls/ffi-deno.ts.txt', 'root-docs/PLATFORM-README/overview/body-1.md', 'Cargo.lock', 'ci/js-build-lock.json', 'ci/test_js_build_lock.py', 'scripts/wasm-notice-resource.mjs', 'tests/wasm-notice-resource.test.mjs', 'tests/test_wasm_npm.py', 'scripts/prepare_js_notices.py', 'scripts/check_wasm_npm.py', 'scripts/check-npm-licenses.mjs', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/check_embedded_notices.py', 'ci/about.toml', 'scripts/source_license_supplements.py', 'ci/test_js_source_supplements.py', 'ci/licenses/js-source-supplements.json']: target = stage / name target.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(name, target) @@ -32,7 +32,7 @@ jobs: ref: ${{ env.SOURCE_REF }} submodules: recursive persist-credentials: false - - name: Apply notice-only build overlay + - name: Apply reviewed resource, documentation and FFI URL compatibility overlays shell: python run: | import hashlib @@ -55,6 +55,8 @@ jobs: shutil.copyfile(path, target) if hashlib.sha256(document.read_bytes()).hexdigest() != '35f1387f0566eea501c65a7f378076afe1a6d9f17725fd8168bf5fc21fa58a58': raise SystemExit('reviewed platform documentation overlay differs') + import sys + ffi_overlays = json.loads(subprocess.check_output([sys.executable, '-I', 'scripts/patch_ffi_package_urls.py', '.'])) script = Path('scripts/build-wasm.mjs') original = script.read_bytes() anchor = b'buildWebInline();' @@ -67,10 +69,12 @@ jobs: packaged = shebang + bytes([10]) + b'import { addNoticeFile } from "./wasm-notice-resource.mjs";' + bytes([10]) + body.replace(anchor, hook + bytes([10, 10]) + anchor) script.write_bytes(packaged) record = {'source_ref': os.environ['SOURCE_REF'], 'tooling_ref': os.environ['GITHUB_SHA'], 'original_build_script_sha256': hashlib.sha256(original).hexdigest(), 'packaged_build_script_sha256': hashlib.sha256(packaged).hexdigest(), 'reviewed_lock_sha256': hashlib.sha256(Path('Cargo.lock').read_bytes()).hexdigest(), 'platform_documentation_overlay': {'path': 'root-docs/PLATFORM-README/overview/body-1.md', 'original_sha256': document_before, 'compiled_sha256': '35f1387f0566eea501c65a7f378076afe1a6d9f17725fd8168bf5fc21fa58a58'}, 'coverage': 'Audit-only Cargo/std prototype, not historical npm or non-Cargo runtime compliance.'} + record['ffi_url_overlays'] = ffi_overlays + record['coverage'] = 'Original 0.8.1 parser/ABI with explicit resource, documentation and file-URL compatibility overlays. Not historical dependency or blanket SDK evidence.' (Path(os.environ['RUNNER_TEMP']) / 'wasm-source-provenance.json').write_text(json.dumps(record, sort_keys=True, indent=2)) - changed = subprocess.check_output(['git', 'diff', '--name-only', '--', 'Cargo.toml', 'crates', 'tests/node', 'root-docs', 'package.json', 'package-lock.json'], text=True).splitlines() - if set(changed) != {'root-docs/PLATFORM-README/overview/body-1.md'}: - raise SystemExit('WASM source changed beyond the reviewed documentation unit') + changed = subprocess.check_output(['git', 'diff', '--name-only', '--', 'Cargo.toml', 'crates', 'ts', 'tests/node', 'root-docs', 'package.json', 'package-lock.json'], text=True).splitlines() + if set(changed) != {'root-docs/PLATFORM-README/overview/body-1.md', 'ts/ffi-bun.ts', 'ts/ffi-deno.ts'}: + raise SystemExit('WASM source changed beyond reviewed documentation/FFI URL overlays') - uses: actions/setup-node@v4 with: node-version: '24' @@ -89,6 +93,7 @@ jobs: python3 -I -m unittest discover -s tests -p test_wasm_npm.py -v python3 -I -m unittest discover -s ci -p test_js_source_supplements.py -v python3 -I -m unittest discover -s ci -p test_js_build_lock.py -v + python3 -I -m unittest discover -s ci -p test_ffi_package_urls.py -v - name: Prepare source-backed locked notices shell: bash run: | diff --git a/ci/fixtures/ffi-package-urls/ffi-bun.ts.txt b/ci/fixtures/ffi-package-urls/ffi-bun.ts.txt new file mode 100644 index 0000000..4e2ab3d --- /dev/null +++ b/ci/fixtures/ffi-package-urls/ffi-bun.ts.txt @@ -0,0 +1,282 @@ +// Bun FFI entrypoint — `bun:ffi` over the canonical ktav_cabi shared +// library. Same C ABI as the Java / Go / .NET / Deno bindings, exact +// same wire format. Bun does not require a permission flag. +// +// On Node, Deno, and the browser this module is unreachable: the +// package.json `exports` map routes those runtimes elsewhere. + +import { ktavMessageError, toKtavError } from "./internal/api.js"; +import type { Ktav, KtavInput, KtavValue } from "./internal/api.js"; +export type { KtavArray, KtavErrorEnvelope, KtavInput, KtavObject, KtavValue, Ktav } from "./internal/api.js"; +export { KtavError, toKtavError } from "./internal/api.js"; + +import { decode, encode } from "./internal/ffi-codec.js"; +import { resolveLibPath } from "./internal/ffi-loader.js"; +export { setLibraryPath } from "./internal/ffi-loader.js"; + +// `bun:ffi` is a Bun built-in — its types are not in @types/node and +// pulling in @types/bun for this single use site would inflate dev +// deps. We type the surface we actually use, and `@ts-expect-error` +// the dynamic import so tsc doesn't need a `declare module`. +interface BunFFI { + FFIType: { ptr: number; u64: number; i32: number; void: number }; + dlopen(path: string, symbols: Record): { + symbols: Record unknown>; + }; + /** Convert a native pointer (number on 64-bit) into an ArrayBuffer view. */ + toArrayBuffer(ptr: number, byteOffset?: number, byteLength?: number): ArrayBuffer; +} + +interface FFILib { + ffi: BunFFI; + symbols: Record unknown>; +} + +let cachedLib: FFILib | null = null; + +// Rust требует ненулевой указатель даже при длине 0. Буфер живёт весь вызов. +const EMPTY_SRC_PLACEHOLDER = new Uint8Array(1); + +async function getLib(): Promise { + if (cachedLib !== null) return cachedLib; + + // Indirect through a string variable so Node bundlers don't try to + // resolve `bun:ffi` at build time. + const modName = "bun:ffi"; + const ffi = (await import(modName)) as unknown as BunFFI; + + const archMap: Record = { x64: "x64", arm64: "arm64" }; + const plat = process.platform; + const arch = archMap[process.arch] ?? process.arch; + const path = await resolveLibPath({ + plat: plat as string, + archName: arch, + runtime: { + env: name => process.env[name], + resolveSubpackage: async (subpkg, file) => { + const resolved = (import.meta as unknown as { + resolve(spec: string): string; + }).resolve(`${subpkg}/${file}`); + return new URL(resolved).pathname; + }, + exists: async p => { + try { + const fs = await import("node:fs/promises"); + await fs.stat(p); + return true; + } catch { + return false; + } + }, + }, + }); + + const opened = ffi.dlopen(path, { + ktav_loads: { + args: [ffi.FFIType.ptr, ffi.FFIType.u64, ffi.FFIType.ptr, ffi.FFIType.ptr, ffi.FFIType.ptr, ffi.FFIType.ptr], + returns: ffi.FFIType.i32, + }, + ktav_loads_strict: { + args: [ffi.FFIType.ptr, ffi.FFIType.u64, ffi.FFIType.ptr, ffi.FFIType.ptr, ffi.FFIType.ptr, ffi.FFIType.ptr], + returns: ffi.FFIType.i32, + }, + ktav_dumps: { + args: [ffi.FFIType.ptr, ffi.FFIType.u64, ffi.FFIType.ptr, ffi.FFIType.ptr, ffi.FFIType.ptr, ffi.FFIType.ptr], + returns: ffi.FFIType.i32, + }, + ktav_dumps_force_strings: { + args: [ffi.FFIType.ptr, ffi.FFIType.u64, ffi.FFIType.ptr, ffi.FFIType.ptr, ffi.FFIType.ptr, ffi.FFIType.ptr], + returns: ffi.FFIType.i32, + }, + ktav_canonical_from_source: { + args: [ffi.FFIType.ptr, ffi.FFIType.u64, ffi.FFIType.ptr, ffi.FFIType.ptr, ffi.FFIType.ptr, ffi.FFIType.ptr], + returns: ffi.FFIType.i32, + }, + ktav_format: { + args: [ffi.FFIType.ptr, ffi.FFIType.u64, ffi.FFIType.ptr, ffi.FFIType.ptr, ffi.FFIType.ptr, ffi.FFIType.ptr], + returns: ffi.FFIType.i32, + }, + ktav_emit_canonical: { + args: [ffi.FFIType.ptr, ffi.FFIType.u64, ffi.FFIType.ptr, ffi.FFIType.ptr, ffi.FFIType.ptr, ffi.FFIType.ptr], + returns: ffi.FFIType.i32, + }, + ktav_free: { + args: [ffi.FFIType.ptr, ffi.FFIType.u64], + returns: ffi.FFIType.void, + }, + ktav_version: { + args: [], + returns: ffi.FFIType.ptr, + }, + }); + cachedLib = { ffi, symbols: opened.symbols }; + return cachedLib; +} + +async function callNative( + op: "loads" | "loads_strict" | "dumps" | "dumps_force_strings" | "format" | "emit_canonical" | "canonical_from_source", + input: Uint8Array, +): Promise { + const { ffi, symbols } = await getLib(); + const symbolName = ( + op === "loads" ? "ktav_loads" + : op === "loads_strict" ? "ktav_loads_strict" + : op === "dumps" ? "ktav_dumps" + : op === "dumps_force_strings" ? "ktav_dumps_force_strings" + : op === "format" ? "ktav_format" + : op === "canonical_from_source" ? "ktav_canonical_from_source" + : "ktav_emit_canonical" + ); + const sym = symbols[symbolName] as (...args: unknown[]) => number; + + // Bun FFI sweet-spot: pass TypedArrays / Buffers directly for + // `FFIType.ptr` args — Bun pins the ArrayBuffer and forwards the + // address. Wrapping in `ffi.ptr()` returns a plain number that + // Bun then refuses to convert back to a pointer ("Unable to + // convert N to a pointer"). The current code hits the auto-pin + // path on every supported platform. + // + // Out-pointers / size_t out-params: `BigUint64Array(1)` gives us + // an 8-byte ArrayBuffer view; we read [0] as bigint after the + // call, then `Number(...)` it down to a JS number for + // `toArrayBuffer` and `ktav_free`. + const outBuf = new BigUint64Array(1); + const outLen = new BigUint64Array(1); + const outErr = new BigUint64Array(1); + const outErrLen = new BigUint64Array(1); + + const rc = sym( + input.length === 0 ? EMPTY_SRC_PLACEHOLDER : input, + BigInt(input.length), + outBuf, + outLen, + outErr, + outErrLen, + ); + + const ktavFree = symbols.ktav_free as (ptr: number, len: bigint) => void; + + const readPtr = (b: BigUint64Array): number => Number(b[0]); + const readLen = (b: BigUint64Array): number => Number(b[0]); + + if (rc !== 0) { + const errPtr = readPtr(outErr); + const errLen = readLen(outErrLen); + let msg = `native call failed with code ${rc}`; + if (errPtr !== 0 && errLen > 0) { + const buf = ffi.toArrayBuffer(errPtr, 0, errLen); + msg = new TextDecoder().decode(new Uint8Array(buf)); + ktavFree(errPtr, BigInt(errLen)); + } + const okPtr = readPtr(outBuf); + const okLen = readLen(outLen); + if (okPtr !== 0 && okLen > 0) ktavFree(okPtr, BigInt(okLen)); + throw toKtavError(new Error(msg)); + } + + const okPtr = readPtr(outBuf); + const okLen = readLen(outLen); + if (okPtr === 0 || okLen === 0) return new Uint8Array(0); + const buf = ffi.toArrayBuffer(okPtr, 0, okLen); + const copy = new Uint8Array(buf.slice(0)); + ktavFree(okPtr, BigInt(okLen)); + return copy; +} + +// ── Public API ─────────────────────────────────────────────────────── + +export async function loads(src: string): Promise { + const bytes = new TextEncoder().encode(src); + const result = await callNative("loads", bytes); + return decode(result) as T; +} +export async function loadsStrict(src: string): Promise { + const bytes = new TextEncoder().encode(src); + const result = await callNative("loads_strict", bytes); + return decode(result) as T; +} + +/** + * Raw-byte entry (spec 0.8 § 3.1/§ 6.15): parse a Uint8Array of Ktav + * source text WITHOUT any TextEncoder round-trip, so the exact bytes + * reach the native parser. `ktav_loads` itself validates UTF-8 at the + * ABI boundary (rust/src/cabi/ops.rs `loads` → `not_utf8_envelope`), + * so invalid bytes throw a `KtavError` with `error === "InvalidUtf8"`, + * a byte-exact span and a raw-bytes line number — before any grammar + * diagnosis. This is the only path that can honestly exercise the + * invalid_utf8/ conformance fixtures. + */ +export async function loadsBytes(bytes: Uint8Array): Promise { + // Копируем до await: Rust не заимствует изменяемый или shared-буфер вызывающего. + const owned = new Uint8Array(bytes.length); + owned.set(bytes); + const result = await callNative("loads", owned); + return decode(result) as T; +} + +export async function dumps(value: T): Promise { + if (value === null || typeof value !== "object") { + throw ktavMessageError("top-level Ktav document must be an object or array"); + } + let input: Uint8Array; + try { + input = encode(value); + } catch (e) { + throw toKtavError(e); + } + const result = await callNative("dumps", input); + return new TextDecoder().decode(result); +} + +export async function stringifyForceStrings( + value: T, +): Promise { + if (value === null || typeof value !== "object") { + throw ktavMessageError("top-level Ktav document must be an object or array"); + } + let input: Uint8Array; + try { + input = encode(value); + } catch (e) { + throw toKtavError(e); + } + const result = await callNative("dumps_force_strings", input); + return new TextDecoder().decode(result); +} + +export async function format(src: string): Promise { + const bytes = new TextEncoder().encode(src); + const result = await callNative("format", bytes); + return new TextDecoder().decode(result); +} + +export async function emitCanonical(value: T): Promise { + if (value === null || typeof value !== "object") { + throw ktavMessageError("top-level Ktav document must be an object or array"); + } + let input: Uint8Array; + try { + input = encode(value); + } catch (e) { + throw toKtavError(e); + } + const result = await callNative("emit_canonical", input); + return new TextDecoder().decode(result); +} + +export async function canonicalFromSource(src: string): Promise { + const bytes = new TextEncoder().encode(src); + const result = await callNative("canonical_from_source", bytes); + return new TextDecoder().decode(result); +} + +export const ktav: Pick & { + loads: typeof loads; + loadsStrict: typeof loadsStrict; + loadsBytes: typeof loadsBytes; + dumps: typeof dumps; + stringifyForceStrings: typeof stringifyForceStrings; + format: typeof format; + emitCanonical: typeof emitCanonical; + canonicalFromSource: typeof canonicalFromSource; +} = { loads, loadsStrict, loadsBytes, dumps, stringifyForceStrings, format, emitCanonical, canonicalFromSource }; diff --git a/ci/fixtures/ffi-package-urls/ffi-deno.ts.txt b/ci/fixtures/ffi-package-urls/ffi-deno.ts.txt new file mode 100644 index 0000000..23f0920 --- /dev/null +++ b/ci/fixtures/ffi-package-urls/ffi-deno.ts.txt @@ -0,0 +1,281 @@ +// Deno FFI entrypoint — `Deno.dlopen` over the canonical ktav_cabi +// shared library. Same C ABI as the Java / Go / .NET bindings, exact +// same wire format, much faster than the WASM path on +// parse-and-render of large documents. +// +// Permission: requires `--allow-ffi` (ideally narrowed to the cabi +// path, e.g. `--allow-ffi=$(deno cache --reload deno.land/x/ktav)`). +// Without it Deno throws PermissionDenied at `Deno.dlopen` and we +// don't try to recover — that defeats the security model. +// +// On Node and the browser this module is unreachable: the package.json +// `exports` map routes those runtimes to `./ffi-error.js`. + +import { ktavMessageError, toKtavError } from "./internal/api.js"; +import type { Ktav, KtavInput, KtavValue } from "./internal/api.js"; +export type { KtavArray, KtavErrorEnvelope, KtavInput, KtavObject, KtavValue, Ktav } from "./internal/api.js"; +export { KtavError, toKtavError } from "./internal/api.js"; + +import { decode, encode } from "./internal/ffi-codec.js"; +import { resolveLibPath } from "./internal/ffi-loader.js"; +export { setLibraryPath } from "./internal/ffi-loader.js"; + +// Deno-specific globals. Declared inline so this module can be +// type-checked against `@types/node` without pulling in `@types/deno`. +declare const Deno: { + env: { get(name: string): string | undefined }; + build: { os: string; arch: string }; + stat(path: string): Promise; + readFileSync(path: string): Uint8Array; + UnsafePointer: { + of(value: ArrayBufferView): bigint | null; + create(value: bigint): bigint | null; + value(p: unknown): bigint; + }; + UnsafePointerView: new (p: unknown) => { + getArrayBuffer(byteLength: number): ArrayBuffer; + }; + dlopen(path: string, symbols: S): { symbols: Record unknown> }; +}; + +const FFI_SYMBOLS = { + ktav_loads: { + parameters: ["pointer", "usize", "pointer", "pointer", "pointer", "pointer"], + result: "i32", + }, + ktav_loads_strict: { + parameters: ["pointer", "usize", "pointer", "pointer", "pointer", "pointer"], + result: "i32", + }, + ktav_dumps: { + parameters: ["pointer", "usize", "pointer", "pointer", "pointer", "pointer"], + result: "i32", + }, + ktav_dumps_force_strings: { + parameters: ["pointer", "usize", "pointer", "pointer", "pointer", "pointer"], + result: "i32", + }, + ktav_canonical_from_source: { + parameters: ["pointer", "usize", "pointer", "pointer", "pointer", "pointer"], + result: "i32", + }, + ktav_format: { + parameters: ["pointer", "usize", "pointer", "pointer", "pointer", "pointer"], + result: "i32", + }, + ktav_emit_canonical: { + parameters: ["pointer", "usize", "pointer", "pointer", "pointer", "pointer"], + result: "i32", + }, + ktav_free: { + parameters: ["pointer", "usize"], + result: "void", + }, + ktav_version: { + parameters: [], + result: "pointer", + }, +} as const; + +let cachedLib: { symbols: Record unknown> } | null = null; + +// Rust требует ненулевой указатель даже при длине 0. Буфер живёт весь вызов. +const EMPTY_SRC_PLACEHOLDER = new Uint8Array(1); + +async function getLib() { + if (cachedLib) return cachedLib; + const archMap: Record = { x86_64: "x64", aarch64: "arm64" }; + const plat = Deno.build.os; // "linux" | "darwin" | "windows" + const arch = archMap[Deno.build.arch] ?? Deno.build.arch; + const path = await resolveLibPath({ + plat: plat === "windows" ? "win32" : plat, + archName: arch, + runtime: { + env: name => Deno.env.get(name), + resolveSubpackage: async (subpkg, file) => { + // Deno honours `npm:` specifiers and the standard + // `node_modules//` layout. We use the + // latter — works for any deno project that runs + // `npm install @ktav-lang/ktav` first. + const url = await import.meta.resolve(`${subpkg}/${file}`); + return new URL(url).pathname; + }, + exists: async p => { + try { await Deno.stat(p); return true; } catch { return false; } + }, + }, + }); + cachedLib = Deno.dlopen(path, FFI_SYMBOLS); + return cachedLib; +} + +// ── FFI plumbing ───────────────────────────────────────────────────── + +async function callNative( + op: "loads" | "loads_strict" | "dumps" | "dumps_force_strings" | "format" | "emit_canonical" | "canonical_from_source", + input: Uint8Array, +): Promise { + const lib = await getLib(); + const symbolName = ( + op === "loads" ? "ktav_loads" + : op === "loads_strict" ? "ktav_loads_strict" + : op === "dumps" ? "ktav_dumps" + : op === "dumps_force_strings" ? "ktav_dumps_force_strings" + : op === "format" ? "ktav_format" + : op === "canonical_from_source" ? "ktav_canonical_from_source" + : "ktav_emit_canonical" + ); + const sym = lib.symbols[symbolName] as (...args: unknown[]) => number; + const ktavFree = lib.symbols.ktav_free as (ptr: bigint, len: bigint) => void; + + const outBuf = new BigUint64Array(1); + const outLen = new BigUint64Array(1); + const outErr = new BigUint64Array(1); + const outErrLen = new BigUint64Array(1); + + const srcPtr = input.length === 0 + ? Deno.UnsafePointer.of(EMPTY_SRC_PLACEHOLDER) + : Deno.UnsafePointer.of(input); + + const rc = sym( + srcPtr, + BigInt(input.length), + Deno.UnsafePointer.of(outBuf), + Deno.UnsafePointer.of(outLen), + Deno.UnsafePointer.of(outErr), + Deno.UnsafePointer.of(outErrLen), + ); + + if (rc !== 0) { + const errPtrRaw = outErr[0]; + const errLen = Number(outErrLen[0]); + let msg = `native call failed with code ${rc}`; + if (errPtrRaw && errLen > 0) { + const errPtr = Deno.UnsafePointer.create(errPtrRaw); + if (errPtr) { + const view = new Deno.UnsafePointerView(errPtr); + msg = new TextDecoder().decode(new Uint8Array(view.getArrayBuffer(errLen))); + ktavFree(errPtr as unknown as bigint, BigInt(errLen)); + } + } + // Drain success buffer too (defence in depth). + const okPtrRaw = outBuf[0]; + const okLen = Number(outLen[0]); + if (okPtrRaw && okLen > 0) { + const okPtr = Deno.UnsafePointer.create(okPtrRaw); + if (okPtr) ktavFree(okPtr as unknown as bigint, BigInt(okLen)); + } + throw toKtavError(new Error(msg)); + } + + const okPtrRaw = outBuf[0]; + const okLen = Number(outLen[0]); + if (!okPtrRaw || okLen === 0) return new Uint8Array(0); + const okPtr = Deno.UnsafePointer.create(okPtrRaw); + if (!okPtr) return new Uint8Array(0); + const view = new Deno.UnsafePointerView(okPtr); + const copy = new Uint8Array(view.getArrayBuffer(okLen)).slice(0); + ktavFree(okPtr as unknown as bigint, BigInt(okLen)); + return copy; +} + +// ── Public API ─────────────────────────────────────────────────────── + +export async function loads(src: string): Promise { + const bytes = new TextEncoder().encode(src); + const result = await callNative("loads", bytes); + return decode(result) as T; +} + +export async function loadsStrict(src: string): Promise { + const bytes = new TextEncoder().encode(src); + const result = await callNative("loads_strict", bytes); + return decode(result) as T; +} + +/** + * Raw-byte entry (spec 0.8 § 3.1/§ 6.15): parse a Uint8Array of Ktav + * source text WITHOUT any TextEncoder round-trip, so the exact bytes + * reach the native parser. `ktav_loads` itself validates UTF-8 at the + * ABI boundary (rust/src/cabi/ops.rs `loads` → `not_utf8_envelope`), + * so invalid bytes throw a `KtavError` with `error === "InvalidUtf8"`, + * a byte-exact span and a raw-bytes line number — before any grammar + * diagnosis. This is the only path that can honestly exercise the + * invalid_utf8/ conformance fixtures. + */ +export async function loadsBytes(bytes: Uint8Array): Promise { + // Копируем до await: Rust не заимствует изменяемый или shared-буфер вызывающего. + const owned = new Uint8Array(bytes.length); + owned.set(bytes); + const result = await callNative("loads", owned); + return decode(result) as T; +} + +export async function dumps(value: T): Promise { + if (value === null || typeof value !== "object") { + throw ktavMessageError("top-level Ktav document must be an object or array"); + } + let input: Uint8Array; + try { + input = encode(value); + } catch (e) { + throw toKtavError(e); + } + const result = await callNative("dumps", input); + return new TextDecoder().decode(result); +} + +export async function stringifyForceStrings( + value: T, +): Promise { + if (value === null || typeof value !== "object") { + throw ktavMessageError("top-level Ktav document must be an object or array"); + } + let input: Uint8Array; + try { + input = encode(value); + } catch (e) { + throw toKtavError(e); + } + const result = await callNative("dumps_force_strings", input); + return new TextDecoder().decode(result); +} + +export async function format(src: string): Promise { + const bytes = new TextEncoder().encode(src); + const result = await callNative("format", bytes); + return new TextDecoder().decode(result); +} + +export async function emitCanonical(value: T): Promise { + if (value === null || typeof value !== "object") { + throw ktavMessageError("top-level Ktav document must be an object or array"); + } + let input: Uint8Array; + try { + input = encode(value); + } catch (e) { + throw toKtavError(e); + } + const result = await callNative("emit_canonical", input); + return new TextDecoder().decode(result); +} + + +export async function canonicalFromSource(src: string): Promise { + const bytes = new TextEncoder().encode(src); + const result = await callNative("canonical_from_source", bytes); + return new TextDecoder().decode(result); +} + +/** Convenience facade matching the synchronous Ktav interface. */ +export const ktav: Pick & { + loads: typeof loads; + loadsStrict: typeof loadsStrict; + loadsBytes: typeof loadsBytes; + dumps: typeof dumps; + stringifyForceStrings: typeof stringifyForceStrings; + format: typeof format; + emitCanonical: typeof emitCanonical; + canonicalFromSource: typeof canonicalFromSource; +} = { loads, loadsStrict, loadsBytes, dumps, stringifyForceStrings, format, emitCanonical, canonicalFromSource }; diff --git a/ci/test_ffi_package_urls.py b/ci/test_ffi_package_urls.py new file mode 100644 index 0000000..a0615ef --- /dev/null +++ b/ci/test_ffi_package_urls.py @@ -0,0 +1,82 @@ +"""Проверить узкие original-source URI overlays без выполнения runtime code.""" + +from pathlib import Path +import sys +import tempfile +import unittest +from unittest.mock import patch as mock_patch + +ROOT = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(ROOT / 'scripts')) +import patch_ffi_package_urls as OVERLAY + + +class FfiUrlOverlayTests(unittest.TestCase): + def original(self, runtime): + return (ROOT / ('ci/fixtures/ffi-package-urls/ffi-' + runtime + '.ts.txt')).read_bytes() + + def test_only_standard_import_and_uri_conversion_change(self): + for runtime in ['bun', 'deno']: + raw = self.original(runtime) + variable = b'resolved' if runtime == 'bun' else b'url' + changed = OVERLAY.patch(raw, runtime) + prefix = b'import { fileURLToPath } from "node:url";\n\n' + expression = b'return fileURLToPath(' + variable + b');' + self.assertEqual(changed.count(prefix), 1) + self.assertEqual(changed.count(expression), 1) + restored = changed.replace(prefix, b'').replace(expression, b'return new URL(' + variable + b').pathname;') + self.assertEqual(restored, raw) + + def test_unknown_or_already_modified_source_is_rejected(self): + for runtime in ['bun', 'deno']: + raw = self.original(runtime) + for wrong in [raw + b'changed', OVERLAY.patch(raw, runtime)]: + with self.assertRaisesRegex(ValueError, 'unreviewed'): + OVERLAY.patch(wrong, runtime) + with self.assertRaisesRegex(ValueError, 'unreviewed'): + OVERLAY.patch(self.original('bun'), 'unknown-runtime') + + def test_complete_two_file_overlay_records_original_and_compiled_hashes(self): + with tempfile.TemporaryDirectory() as temporary: + root = Path(temporary) + (root / 'ts').mkdir() + for runtime in OVERLAY.PINS: + (root / ('ts/ffi-' + runtime + '.ts')).write_bytes(self.original(runtime)) + with mock_patch.object(OVERLAY.subprocess, 'check_output', return_value=OVERLAY.SOURCE + '\n'): + records = OVERLAY.apply(root) + self.assertEqual({item['path'] for item in records}, {'ts/ffi-bun.ts', 'ts/ffi-deno.ts'}) + for item in records: + runtime = Path(item['path']).stem.removeprefix('ffi-') + self.assertEqual(item['original_sha256'], OVERLAY.PINS[runtime]) + self.assertEqual(item['compiled_sha256'], OVERLAY.sha((root / item['path']).read_bytes())) + + def test_bad_second_input_does_not_partially_change_first(self): + with tempfile.TemporaryDirectory() as temporary: + root = Path(temporary) + (root / 'ts').mkdir() + before = self.original('bun') + (root / 'ts/ffi-bun.ts').write_bytes(before) + (root / 'ts/ffi-deno.ts').write_bytes(b'changed') + with mock_patch.object(OVERLAY.subprocess, 'check_output', return_value=OVERLAY.SOURCE + '\n'), self.assertRaisesRegex(ValueError, 'unreviewed'): + OVERLAY.apply(root) + self.assertEqual((root / 'ts/ffi-bun.ts').read_bytes(), before) + + def test_overlay_provenance_drift_is_rejected(self): + records = [{'path': 'ts/ffi-' + runtime + '.ts', 'original_sha256': OVERLAY.PINS[runtime], 'compiled_sha256': OVERLAY.COMPILED[runtime]} for runtime in OVERLAY.PINS] + OVERLAY.verify_records(records) + for key in ['path', 'original_sha256', 'compiled_sha256']: + changed = [dict(item) for item in records] + changed[0][key] = 'unknown' + with self.assertRaisesRegex(ValueError, 'provenance differs'): + OVERLAY.verify_records(changed) + with self.assertRaisesRegex(ValueError, 'provenance differs'): + OVERLAY.verify_records(records[:1]) + + def test_wrong_project_revision_is_rejected(self): + with tempfile.TemporaryDirectory() as temporary: + with mock_patch.object(OVERLAY.subprocess, 'check_output', return_value='0' * 40 + '\n'), self.assertRaisesRegex(ValueError, 'original 0.8.1'): + OVERLAY.apply(Path(temporary)) + + +if __name__ == '__main__': + unittest.main() diff --git a/scripts/check_release_npm.py b/scripts/check_release_npm.py index fa60f74..bb80175 100644 --- a/scripts/check_release_npm.py +++ b/scripts/check_release_npm.py @@ -10,6 +10,7 @@ from check_wasm_npm import verify as verify_wasm from native_npm_payload import LICENSES, LOCK, SOURCE, TARGETS, read, sha from pack_native_npm import DOC_SHA +from patch_ffi_package_urls import verify_records as verify_ffi_overlays def verify(root): @@ -40,6 +41,7 @@ def verify(root): report = verify_wasm(archive, evidence, package) provenance = json.loads(read(evidence / 'source-provenance.json')) notice = json.loads(read(evidence / 'NOTICE.json')) + verify_ffi_overlays(provenance['ffi_url_overlays']) if report['wasm'] != item['wasm'] or report['package_sha256'] != item['sha256'] or provenance['source_ref'] != SOURCE or provenance['tooling_ref'] != manifest['tooling_ref'] or provenance['platform_documentation_overlay']['compiled_sha256'] != DOC_SHA or sha(read(evidence / 'Cargo.lock', 4 * 1024 * 1024)) != LOCK or notice['cargo_lock_sha256'] != LOCK: raise ValueError('main package actual source/resource/lock identity differs') copyright_report = read(evidence / 'COPYRIGHT-library.html') diff --git a/scripts/consume_packed_native.mjs b/scripts/consume_packed_native.mjs index f0fb3ab..4ab6cfc 100644 --- a/scripts/consume_packed_native.mjs +++ b/scripts/consume_packed_native.mjs @@ -40,7 +40,9 @@ const proof = join(work, "proof"); mkdirSync(proof); const environment = { ...process.env }; for (const name of ["KTAV_LIB_PATH", "CARGO_TARGET_DIR", "NODE_PATH", "NODE_OPTIONS", "BUN_OPTIONS", "GITHUB_TOKEN", "GH_TOKEN", "NPM_TOKEN", "NODE_AUTH_TOKEN"]) delete environment[name]; -environment.PATH = environment.PATH.split(process.platform === "win32" ? ";" : ":").filter(value => !/[.]cargo|[.]rustup|llvm|visual studio|(?:^|[/\\])zig(?:[/\\]|$)/i.test(value)).join(process.platform === "win32" ? ";" : ":"); +const pathKey = Object.keys(environment).find(name => name.toUpperCase() === "PATH"); +assert.ok(pathKey, "runtime search path is required"); +environment[pathKey] = environment[pathKey].split(process.platform === "win32" ? ";" : ":").filter(value => !/[.]cargo|[.]rustup|llvm|visual studio|(?:^|[/\\])zig(?:[/\\]|$)/i.test(value)).join(process.platform === "win32" ? ";" : ":"); environment.DENO_DIR = join(work, "deno-cache"); const npmCandidates = [join(dirname(process.execPath), "node_modules/npm/bin/npm-cli.js"), join(dirname(process.execPath), "../lib/node_modules/npm/bin/npm-cli.js")]; const npm = npmCandidates.find(existsSync); diff --git a/scripts/pack_native_npm.py b/scripts/pack_native_npm.py index 1adbd25..b1d3d2a 100644 --- a/scripts/pack_native_npm.py +++ b/scripts/pack_native_npm.py @@ -12,6 +12,7 @@ from check_native_npm import unpack, verify as verify_native from check_wasm_npm import verify as verify_wasm from native_npm_payload import LICENSES, LOCK, SOURCE, TARGETS, files, read, relative, sha +from patch_ffi_package_urls import verify_records as verify_ffi_overlays DOC_UNIT = 'root-docs/PLATFORM-README/overview/body-1.md' DOC_SHA = '35f1387f0566eea501c65a7f378076afe1a6d9f17725fd8168bf5fc21fa58a58' @@ -48,6 +49,7 @@ def verify_main(root, tooling): provenance = json.loads(read(root / 'source-provenance.json')) if sha(lock) != LOCK or provenance['source_ref'] != SOURCE or provenance['tooling_ref'] != tooling or provenance['platform_documentation_overlay']['compiled_sha256'] != DOC_SHA: raise ValueError('main package source/lock/documentation binding differs') + verify_ffi_overlays(provenance['ffi_url_overlays']) archive = root / name original = json.loads(read(root / 'npm-verification.json')) with tempfile.TemporaryDirectory(prefix='ktav-packed-main-') as temporary: diff --git a/scripts/patch_ffi_package_urls.py b/scripts/patch_ffi_package_urls.py new file mode 100644 index 0000000..26efaf5 --- /dev/null +++ b/scripts/patch_ffi_package_urls.py @@ -0,0 +1,57 @@ +"""Применить только checksum-bound filesystem URL fix к original 0.8.1 FFI adapters.""" + +import hashlib +import json +from pathlib import Path +import subprocess +import sys + +SOURCE = '562deb3fde092d63a78f359be095e5079929d0d1' +PINS = {'bun': '7ebb12ce7ccd4a9b3ccfc54783527354377405bf8ff1ce82e04d22f70f0ee77e', 'deno': '2defa121c8623a89b97805f4c2d9711d0cbe2f7a4e5a96729d84ce8cd5358cef'} +IMPORT = b'import { ktavMessageError, toKtavError } from "./internal/api.js";' +COMPILED = {'bun': '39c08412abcc4710f3db9578bd39e0a323e2e8c6bc718b824cc908eaf40334a9', 'deno': '6e7c0013ad64e85ce7a46e479fd6cddec0ec3bd1ffb0a51c901b00581e96bd0e'} + + +def verify_records(records): + expected = {('ts/ffi-' + runtime + '.ts', PINS[runtime], COMPILED[runtime]) for runtime in PINS} + if len(records) != 2 or {(item['path'], item['original_sha256'], item['compiled_sha256']) for item in records} != expected: + raise ValueError('FFI URL source overlay provenance differs') + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def patch(raw, runtime): + if runtime not in PINS or sha(raw) != PINS[runtime]: + raise ValueError('unreviewed original FFI adapter') + expression = b'return new URL(' + (b'resolved' if runtime == 'bun' else b'url') + b').pathname;' + replacement = b'return fileURLToPath(' + (b'resolved' if runtime == 'bun' else b'url') + b');' + if raw.count(IMPORT) != 1 or raw.count(expression) != 1 or b'fileURLToPath' in raw: + raise ValueError('original FFI URL anchors differ') + return raw.replace(IMPORT, b'import { fileURLToPath } from "node:url";\n\n' + IMPORT).replace(expression, replacement) + + +def apply(root): + if subprocess.check_output(['git', '-C', str(root), 'rev-parse', 'HEAD'], text=True).strip() != SOURCE: + raise ValueError('FFI compatibility overlay requires original 0.8.1 source') + rows = [] + prepared = [] + for runtime in PINS: + path = root / ('ts/ffi-' + runtime + '.ts') + if path.is_symlink() or not path.is_file() or path.stat().st_size > 1024 * 1024: + raise ValueError('invalid FFI overlay source file') + raw = path.read_bytes() + changed = patch(raw, runtime) + prepared.append((path, changed)) + rows.append({'path': path.relative_to(root).as_posix(), 'original_sha256': sha(raw), 'compiled_sha256': sha(changed), 'scope': 'Standard fileURLToPath conversion only; no parser, public API or dependency change.'}) + verify_records(rows) + for path, changed in prepared: + path.write_bytes(changed) + return rows + + +if __name__ == '__main__': + if len(sys.argv) != 2: + raise SystemExit('usage: patch_ffi_package_urls.py ORIGINAL_SOURCE_ROOT') + print(json.dumps(apply(Path(sys.argv[1]).resolve()), sort_keys=True)) diff --git a/ts/ffi-bun.ts b/ts/ffi-bun.ts index fc7edb1..340264c 100644 --- a/ts/ffi-bun.ts +++ b/ts/ffi-bun.ts @@ -5,6 +5,8 @@ // On Node, Deno, and the browser this module is unreachable: the // package.json `exports` map routes those runtimes elsewhere. +import { fileURLToPath } from "node:url"; + import { ktavMessageError, toKtavError } from "./internal/api.js"; import type { Ktav, KtavInput, KtavValue } from "./internal/api.js"; export type { KtavArray, KtavErrorEnvelope, KtavInput, KtavObject, KtavValue, Ktav } from "./internal/api.js"; @@ -74,7 +76,7 @@ async function getLib(): Promise { const resolved = (import.meta as unknown as { resolve(spec: string): string; }).resolve(`${subpkg}/${file}`); - return new URL(resolved).pathname; + return fileURLToPath(resolved); }, exists: async p => { try { diff --git a/ts/ffi-deno.ts b/ts/ffi-deno.ts index 9a99a80..a3bf4e0 100644 --- a/ts/ffi-deno.ts +++ b/ts/ffi-deno.ts @@ -11,6 +11,8 @@ // On Node and the browser this module is unreachable: the package.json // `exports` map routes those runtimes to `./ffi-error.js`. +import { fileURLToPath } from "node:url"; + import { ktavMessageError, toKtavError } from "./internal/api.js"; import type { Ktav, KtavInput, KtavValue } from "./internal/api.js"; export type { KtavArray, KtavErrorEnvelope, KtavInput, KtavObject, KtavValue, Ktav } from "./internal/api.js"; @@ -106,7 +108,7 @@ async function getLib() { // latter — works for any deno project that runs // `npm install @ktav-lang/ktav` first. const url = await import.meta.resolve(`${subpkg}/${file}`); - return new URL(url).pathname; + return fileURLToPath(url); }, exists: async p => { try { await Deno.stat(p); return true; } catch { return false; } From 5b1b43b107c11362322c9c6a34804b7f8f7aea11 Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sun, 1 Nov 2026 15:53:18 +0100 Subject: [PATCH 50/51] fix(ci): run original Deno corpus outside node_modules Deno rejects TypeScript type stripping for a test runner copied under node_modules. The installed JavaScript FFI entry and default library lookup already succeed, so do not change the package or any assertion. Copy the unchanged original tests and spec-0.8 fixtures to the consumer workspace. Link dist to the actual installed package, verify the same real path, and point only the Deno corpus import at the external tests. Keep Node/Bun behavior, packed binary/file hashes, fresh offline install, spaces and default locator checks unchanged. Use a Windows directory junction without requiring symbolic-link privileges. Co-Authored-By: Claude Opus 5.5 --- scripts/consume_packed_native.mjs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/consume_packed_native.mjs b/scripts/consume_packed_native.mjs index 4ab6cfc..5bbdedb 100644 --- a/scripts/consume_packed_native.mjs +++ b/scripts/consume_packed_native.mjs @@ -1,7 +1,7 @@ import assert from "node:assert/strict"; import { createHash } from "node:crypto"; import { execFileSync, spawnSync } from "node:child_process"; -import { cpSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, writeFileSync } from "node:fs"; +import { cpSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, symlinkSync, writeFileSync } from "node:fs"; import { dirname, join, resolve } from "node:path"; const [archivesArg, sourceArg, workArg, rid] = process.argv.slice(2); @@ -90,11 +90,18 @@ assert.ok(!existsSync(join(main, "dist/native")), "no local NAPI fallback may ma cpSync(join(source, "tests"), join(main, "tests"), { recursive: true, errorOnExist: true, force: false }); mkdirSync(join(main, "spec/versions/0.8"), { recursive: true }); cpSync(join(source, "spec/versions/0.8/tests"), join(main, "spec/versions/0.8/tests"), { recursive: true, errorOnExist: true, force: false }); +if (!rid.endsWith("-musl")) { + cpSync(join(source, "tests"), join(work, "tests"), { recursive: true, errorOnExist: true, force: false }); + mkdirSync(join(work, "spec/versions/0.8"), { recursive: true }); + cpSync(join(source, "spec/versions/0.8/tests"), join(work, "spec/versions/0.8/tests"), { recursive: true, errorOnExist: true, force: false }); + symlinkSync(join(main, "dist"), join(work, "dist"), process.platform === "win32" ? "junction" : "dir"); + assert.equal(realpathSync(join(work, "dist")), realpathSync(join(main, "dist"))); +} const napi = realpathSync(join(native, selected.roles.napi.package_binary)); const cabi = realpathSync(join(native, selected.roles.cabi.package_binary)); const childEnvironment = { ...environment, PACKED_MAIN: main, PACKED_NATIVE: native, PACKED_NAPI: napi, PACKED_CABI: cabi, EXPECTED_ARCH: arch, EXPECTED_RID: rid, PACKED_PROOF: proof }; const nodeScript = `import assert from "node:assert/strict";import {createRequire} from "node:module";import {realpathSync,readFileSync,writeFileSync} from "node:fs";import {createHash} from "node:crypto";import {pathToFileURL} from "node:url";assert.equal(process.arch,process.env.EXPECTED_ARCH);const entry=import.meta.resolve("@ktav-lang/ktav");assert.equal(realpathSync(new URL(entry)),realpathSync(process.env.PACKED_MAIN+"/dist/ts/node.js"));await import("@ktav-lang/ktav");const require=createRequire(import.meta.url);assert.deepEqual(Object.keys(require.cache).filter(p=>p.endsWith(".node")),[realpathSync(process.env.PACKED_NAPI)]);writeFileSync(process.env.PACKED_PROOF+"/node-loaded.json",JSON.stringify({binary_sha256:createHash("sha256").update(readFileSync(process.env.PACKED_NAPI)).digest("hex"),loaded_installed_addon:true}));await import(pathToFileURL(process.env.PACKED_MAIN+"/tests/node/run-node-napi.mjs").href);`; -const ffiScript = runtime => `import assert from "node:assert/strict";import {createRequire} from "node:module";import {realpathSync,readFileSync,writeFileSync,existsSync} from "node:fs";import {createHash} from "node:crypto";import {pathToFileURL} from "node:url";const arch=${runtime === "bun" ? "process.arch" : '({x86_64:"x64",aarch64:"arm64"})[Deno.build.arch]'};assert.equal(arch,process.env.EXPECTED_ARCH);assert.ok(!process.env.KTAV_LIB_PATH);assert.ok(!process.env.CARGO_TARGET_DIR);assert.ok(!existsSync(process.env.PACKED_MAIN+"/target/release"));const entry=import.meta.resolve("@ktav-lang/ktav/ffi");assert.equal(realpathSync(new URL(entry)),realpathSync(process.env.PACKED_MAIN+"/dist/ts/ffi-${runtime}.js"));const require=createRequire(entry);const library=require.resolve("@ktav-lang/js-"+process.env.EXPECTED_RID+"/"+process.env.PACKED_CABI.split(/[\\\\/]/).at(-1));assert.equal(realpathSync(library),realpathSync(process.env.PACKED_CABI));const api=await import("@ktav-lang/ktav/ffi");assert.deepEqual(await api.loads("service: packed\\n"),{service:"packed"});writeFileSync(process.env.PACKED_PROOF+"/${runtime}-loaded.json",JSON.stringify({binary_sha256:createHash("sha256").update(readFileSync(library)).digest("hex"),default_package_locator:true}));await import(pathToFileURL(process.env.PACKED_MAIN+"/tests/${runtime}/run-${runtime}-ffi.${runtime === "bun" ? "mjs" : "ts"}").href);`; +const ffiScript = runtime => `import assert from "node:assert/strict";import {createRequire} from "node:module";import {realpathSync,readFileSync,writeFileSync,existsSync} from "node:fs";import {createHash} from "node:crypto";import {pathToFileURL} from "node:url";const arch=${runtime === "bun" ? "process.arch" : '({x86_64:"x64",aarch64:"arm64"})[Deno.build.arch]'};assert.equal(arch,process.env.EXPECTED_ARCH);assert.ok(!process.env.KTAV_LIB_PATH);assert.ok(!process.env.CARGO_TARGET_DIR);assert.ok(!existsSync(process.env.PACKED_MAIN+"/target/release"));const entry=import.meta.resolve("@ktav-lang/ktav/ffi");assert.equal(realpathSync(new URL(entry)),realpathSync(process.env.PACKED_MAIN+"/dist/ts/ffi-${runtime}.js"));const require=createRequire(entry);const library=require.resolve("@ktav-lang/js-"+process.env.EXPECTED_RID+"/"+process.env.PACKED_CABI.split(/[\\\\/]/).at(-1));assert.equal(realpathSync(library),realpathSync(process.env.PACKED_CABI));const api=await import("@ktav-lang/ktav/ffi");assert.deepEqual(await api.loads("service: packed\\n"),{service:"packed"});writeFileSync(process.env.PACKED_PROOF+"/${runtime}-loaded.json",JSON.stringify({binary_sha256:createHash("sha256").update(readFileSync(library)).digest("hex"),default_package_locator:true}));await import(pathToFileURL(process.env.PACKED_TEST_ROOT+"/tests/${runtime}/run-${runtime}-ffi.${runtime === "bun" ? "mjs" : "ts"}").href);`; const scripts = [["node", process.execPath, nodeScript]]; scripts.push(["bun", process.env.BUN_EXECUTABLE || "bun", ffiScript("bun")]); if (!rid.endsWith("-musl")) scripts.push(["deno", "deno", ffiScript("deno")]); @@ -103,7 +110,8 @@ for (const [runtime, executable, script] of scripts) { const path = join(work, `preflight-${runtime}.mjs`); writeFileSync(path, script + "\n"); const args = runtime === "deno" ? ["run", "--no-config", "--no-lock", "--cached-only", "--node-modules-dir=manual", "--allow-ffi", "--allow-env", "--allow-read", `--allow-write=${proof}`, path] : [path]; - const result = spawnSync(executable, args, { cwd: work, env: childEnvironment, encoding: "utf8" }); + const runtimeEnvironment = { ...childEnvironment, PACKED_TEST_ROOT: runtime === "deno" ? work : main }; + const result = spawnSync(executable, args, { cwd: work, env: runtimeEnvironment, encoding: "utf8" }); writeFileSync(join(proof, `${runtime}-stdout.txt`), result.stdout ?? ""); writeFileSync(join(proof, `${runtime}-stderr.txt`), result.stderr ?? ""); process.stdout.write(result.stdout ?? ""); From 5e93ff179859c4e24e59905017adc23dc582d137 Mon Sep 17 00:00:00 2001 From: Arch-AI-tech Date: Sun, 1 Nov 2026 16:48:34 +0100 Subject: [PATCH 51/51] ci(licenses): bind common JS compiler grants to exact source Reuse the already reviewed Rust 1.99.1 compiler-builtins, LLVM and libm collection for all common native and WASM notice preparation. Preserve complete original legal and source texts, exact version and Git identities, and the composite compiler-builtins AND expression. Keep target-specific retained-input/runtime grant policies unchanged. Carry the source profile and fourteen original materials through every native role, packed main/WASM output and archive verification. Reject missing or changed compiler source roles even with rewritten manifests. Stage tooling in all seven common-preparer workflows, including the separate MSVC diagnostic, without changing compiler or project versions. This conservative compiler-source collection is not a linked-code inventory or a violation inferred from missing names in an LTO map. Keep the generic Cargo assembler, parser APIs, dependency graph, SDK/consumer gates and all pre-existing legal roles intact. No publication job is dispatched; historical assets remain unchanged. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/gnu-cabi-notice-check.yml | 2 +- .../workflows/macos-native-notice-check.yml | 2 +- .../workflows/musl-native-notice-check.yml | 2 +- .github/workflows/napi-msvc-input-check.yml | 2 +- .github/workflows/napi-notice-check.yml | 2 +- .../workflows/native-npm-release-build.yml | 2 +- .github/workflows/wasm-notice-check.yml | 7 +- .../workflows/windows-cabi-gnullvm-check.yml | 2 +- ci/test_js_compiler_materials.py | 77 +++++++++++++++++++ ci/test_native_npm_payload.py | 10 ++- scripts/check_release_npm.py | 3 + scripts/native_npm_payload.py | 17 ++-- scripts/pack_native_npm.py | 10 ++- scripts/prepare_js_notices.py | 18 +++++ 14 files changed, 135 insertions(+), 21 deletions(-) create mode 100644 ci/test_js_compiler_materials.py diff --git a/.github/workflows/gnu-cabi-notice-check.yml b/.github/workflows/gnu-cabi-notice-check.yml index 9f0391c..374df40 100644 --- a/.github/workflows/gnu-cabi-notice-check.yml +++ b/.github/workflows/gnu-cabi-notice-check.yml @@ -31,7 +31,7 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'gnu-cabi-tools' stage.mkdir() - names = ['scripts/native_npm_payload.py', 'scripts/windows_gnu_napi_variant.py', 'Cargo.lock', 'ci/js-build-lock.json', 'crates/cabi/build.rs', 'scripts/patch_cabi_notice_source.py', 'ci/test_cabi_notice_overlay.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json', 'scripts/zig_runtime_notices.py', 'scripts/capture-zig-link.sh', 'scripts/check_gnu_cabi_evidence.py', 'ci/zig-runtime-catalog.json', 'ci/test_gnu_cabi_notices.py'] + names = ['scripts/rust_compiler_notices.py', 'ci/rust-compiler-notices.json', 'ci/test_js_compiler_materials.py', 'ci/licenses/rust-compiler-originals/compiler-builtins-LICENSE.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-Cargo.toml.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-build.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-aarch64.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-aarch64-outline-atomics.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-rt-aarch64-lse.S.txt', 'ci/licenses/rust-compiler-originals/compiler-rt-aarch64-cpu-model.c.txt', 'ci/licenses/rust-compiler-originals/compiler-rt-LICENSE.TXT', 'ci/licenses/rust-compiler-originals/compiler-rt-CREDITS.TXT', 'ci/licenses/rust-compiler-originals/compiler-builtins-math-mod.rs.txt', 'ci/licenses/rust-compiler-originals/libm-trunc.rs.txt', 'ci/licenses/rust-compiler-originals/libm-LICENSE.txt', 'ci/licenses/rust-compiler-originals/libm-generic-trunc.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-float-conv.rs.txt', 'scripts/native_npm_payload.py', 'scripts/windows_gnu_napi_variant.py', 'Cargo.lock', 'ci/js-build-lock.json', 'crates/cabi/build.rs', 'scripts/patch_cabi_notice_source.py', 'ci/test_cabi_notice_overlay.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json', 'scripts/zig_runtime_notices.py', 'scripts/capture-zig-link.sh', 'scripts/check_gnu_cabi_evidence.py', 'ci/zig-runtime-catalog.json', 'ci/test_gnu_cabi_notices.py'] for name in names: path = stage / name path.parent.mkdir(parents=True, exist_ok=True) diff --git a/.github/workflows/macos-native-notice-check.yml b/.github/workflows/macos-native-notice-check.yml index 40f6974..db5ccab 100644 --- a/.github/workflows/macos-native-notice-check.yml +++ b/.github/workflows/macos-native-notice-check.yml @@ -34,7 +34,7 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'macos-native-tools' stage.mkdir() - names = ['scripts/native_npm_payload.py', 'scripts/windows_gnu_napi_variant.py', 'Cargo.lock', 'ci/js-build-lock.json', 'crates/napi/build.rs', 'crates/cabi/build.rs', 'scripts/patch_napi_notice_source.py', 'scripts/patch_cabi_notice_source.py', 'ci/test_cabi_notice_overlay.py', 'scripts/macos_native_evidence.py', 'ci/test_macos_native_evidence.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json'] + names = ['scripts/rust_compiler_notices.py', 'ci/rust-compiler-notices.json', 'ci/test_js_compiler_materials.py', 'ci/licenses/rust-compiler-originals/compiler-builtins-LICENSE.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-Cargo.toml.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-build.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-aarch64.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-aarch64-outline-atomics.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-rt-aarch64-lse.S.txt', 'ci/licenses/rust-compiler-originals/compiler-rt-aarch64-cpu-model.c.txt', 'ci/licenses/rust-compiler-originals/compiler-rt-LICENSE.TXT', 'ci/licenses/rust-compiler-originals/compiler-rt-CREDITS.TXT', 'ci/licenses/rust-compiler-originals/compiler-builtins-math-mod.rs.txt', 'ci/licenses/rust-compiler-originals/libm-trunc.rs.txt', 'ci/licenses/rust-compiler-originals/libm-LICENSE.txt', 'ci/licenses/rust-compiler-originals/libm-generic-trunc.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-float-conv.rs.txt', 'scripts/native_npm_payload.py', 'scripts/windows_gnu_napi_variant.py', 'Cargo.lock', 'ci/js-build-lock.json', 'crates/napi/build.rs', 'crates/cabi/build.rs', 'scripts/patch_napi_notice_source.py', 'scripts/patch_cabi_notice_source.py', 'ci/test_cabi_notice_overlay.py', 'scripts/macos_native_evidence.py', 'ci/test_macos_native_evidence.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json'] for name in names: destination = stage / name destination.parent.mkdir(parents=True, exist_ok=True) diff --git a/.github/workflows/musl-native-notice-check.yml b/.github/workflows/musl-native-notice-check.yml index 14ea405..3291f28 100644 --- a/.github/workflows/musl-native-notice-check.yml +++ b/.github/workflows/musl-native-notice-check.yml @@ -53,7 +53,7 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'musl-notice-tools' stage.mkdir() - names = ['scripts/native_npm_payload.py', 'scripts/windows_gnu_napi_variant.py', 'Cargo.lock', 'ci/js-build-lock.json', 'crates/napi/build.rs', 'crates/cabi/build.rs', 'scripts/patch_napi_notice_source.py', 'scripts/patch_cabi_notice_source.py', 'ci/test_cabi_notice_overlay.py', 'ci/test_napi_notice_overlay.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json', 'scripts/capture-zig-link.sh', 'scripts/musl_native_evidence.py', 'ci/musl-runtime-catalog.json', 'ci/test_musl_native_evidence.py'] + names = ['scripts/rust_compiler_notices.py', 'ci/rust-compiler-notices.json', 'ci/test_js_compiler_materials.py', 'ci/licenses/rust-compiler-originals/compiler-builtins-LICENSE.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-Cargo.toml.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-build.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-aarch64.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-aarch64-outline-atomics.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-rt-aarch64-lse.S.txt', 'ci/licenses/rust-compiler-originals/compiler-rt-aarch64-cpu-model.c.txt', 'ci/licenses/rust-compiler-originals/compiler-rt-LICENSE.TXT', 'ci/licenses/rust-compiler-originals/compiler-rt-CREDITS.TXT', 'ci/licenses/rust-compiler-originals/compiler-builtins-math-mod.rs.txt', 'ci/licenses/rust-compiler-originals/libm-trunc.rs.txt', 'ci/licenses/rust-compiler-originals/libm-LICENSE.txt', 'ci/licenses/rust-compiler-originals/libm-generic-trunc.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-float-conv.rs.txt', 'scripts/native_npm_payload.py', 'scripts/windows_gnu_napi_variant.py', 'Cargo.lock', 'ci/js-build-lock.json', 'crates/napi/build.rs', 'crates/cabi/build.rs', 'scripts/patch_napi_notice_source.py', 'scripts/patch_cabi_notice_source.py', 'ci/test_cabi_notice_overlay.py', 'ci/test_napi_notice_overlay.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json', 'scripts/capture-zig-link.sh', 'scripts/musl_native_evidence.py', 'ci/musl-runtime-catalog.json', 'ci/test_musl_native_evidence.py'] retained = Path('ci/musl-retained-runtime.json').read_bytes() if hashlib.sha256(retained).hexdigest() != 'ed6146168bd64b5022037c7a4ff30e71a21da74b07c697aa848799520166c1b5': raise SystemExit('unreviewed retained musl source profile') diff --git a/.github/workflows/napi-msvc-input-check.yml b/.github/workflows/napi-msvc-input-check.yml index 0a2acfc..5d5e211 100644 --- a/.github/workflows/napi-msvc-input-check.yml +++ b/.github/workflows/napi-msvc-input-check.yml @@ -37,7 +37,7 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'napi-msvc-tools' stage.mkdir() - names = ['Cargo.lock', 'ci/js-build-lock.json', 'crates/napi/build.rs', 'scripts/patch_napi_notice_source.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'scripts/collect_msvc_napi_evidence.py', 'ci/test_msvc_napi_evidence.py', 'ci/about.toml', 'ci/licenses/js-source-supplements.json'] + names = ['scripts/rust_compiler_notices.py', 'ci/rust-compiler-notices.json', 'ci/test_js_compiler_materials.py', 'ci/licenses/rust-compiler-originals/compiler-builtins-LICENSE.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-Cargo.toml.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-build.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-aarch64.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-aarch64-outline-atomics.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-rt-aarch64-lse.S.txt', 'ci/licenses/rust-compiler-originals/compiler-rt-aarch64-cpu-model.c.txt', 'ci/licenses/rust-compiler-originals/compiler-rt-LICENSE.TXT', 'ci/licenses/rust-compiler-originals/compiler-rt-CREDITS.TXT', 'ci/licenses/rust-compiler-originals/compiler-builtins-math-mod.rs.txt', 'ci/licenses/rust-compiler-originals/libm-trunc.rs.txt', 'ci/licenses/rust-compiler-originals/libm-LICENSE.txt', 'ci/licenses/rust-compiler-originals/libm-generic-trunc.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-float-conv.rs.txt', 'Cargo.lock', 'ci/js-build-lock.json', 'crates/napi/build.rs', 'scripts/patch_napi_notice_source.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'scripts/collect_msvc_napi_evidence.py', 'ci/test_msvc_napi_evidence.py', 'ci/about.toml', 'ci/licenses/js-source-supplements.json'] for name in names: path = stage / name path.parent.mkdir(parents=True, exist_ok=True) diff --git a/.github/workflows/napi-notice-check.yml b/.github/workflows/napi-notice-check.yml index bb97171..28348fc 100644 --- a/.github/workflows/napi-notice-check.yml +++ b/.github/workflows/napi-notice-check.yml @@ -31,7 +31,7 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'napi-notice-tools' stage.mkdir() - for name in ['scripts/native_npm_payload.py', 'scripts/windows_gnu_napi_variant.py', 'ci/napi-gnu-rust-builtins.json', *[str(path) for path in Path('ci/licenses/musl-rust-originals').glob('*.txt')], 'crates/napi/build.rs', 'scripts/patch_napi_notice_source.py', 'ci/test_napi_notice_overlay.py', 'scripts/check_embedded_notices.py', 'Cargo.lock', 'ci/js-build-lock.json', 'ci/test_js_build_lock.py', 'scripts/capture_napi_cross_link.py', 'scripts/collect_napi_link_evidence.py', 'ci/test_napi_cross_link.py', 'ci/napi-gnu-sdk-inputs.json', 'ci/licenses/napi-gnu-runtime.json', 'ci/test_napi_gnu_runtime_notices.py', 'scripts/napi_gnu_runtime_notices.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json']: + for name in ['scripts/rust_compiler_notices.py', 'ci/rust-compiler-notices.json', 'ci/test_js_compiler_materials.py', 'ci/licenses/rust-compiler-originals/compiler-builtins-LICENSE.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-Cargo.toml.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-build.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-aarch64.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-aarch64-outline-atomics.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-rt-aarch64-lse.S.txt', 'ci/licenses/rust-compiler-originals/compiler-rt-aarch64-cpu-model.c.txt', 'ci/licenses/rust-compiler-originals/compiler-rt-LICENSE.TXT', 'ci/licenses/rust-compiler-originals/compiler-rt-CREDITS.TXT', 'ci/licenses/rust-compiler-originals/compiler-builtins-math-mod.rs.txt', 'ci/licenses/rust-compiler-originals/libm-trunc.rs.txt', 'ci/licenses/rust-compiler-originals/libm-LICENSE.txt', 'ci/licenses/rust-compiler-originals/libm-generic-trunc.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-float-conv.rs.txt', 'scripts/native_npm_payload.py', 'scripts/windows_gnu_napi_variant.py', 'ci/napi-gnu-rust-builtins.json', *[str(path) for path in Path('ci/licenses/musl-rust-originals').glob('*.txt')], 'crates/napi/build.rs', 'scripts/patch_napi_notice_source.py', 'ci/test_napi_notice_overlay.py', 'scripts/check_embedded_notices.py', 'Cargo.lock', 'ci/js-build-lock.json', 'ci/test_js_build_lock.py', 'scripts/capture_napi_cross_link.py', 'scripts/collect_napi_link_evidence.py', 'ci/test_napi_cross_link.py', 'ci/napi-gnu-sdk-inputs.json', 'ci/licenses/napi-gnu-runtime.json', 'ci/test_napi_gnu_runtime_notices.py', 'scripts/napi_gnu_runtime_notices.py', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'scripts/check-npm-licenses.mjs', 'ci/about.toml', 'ci/licenses/js-source-supplements.json']: target = stage / name target.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(name, target) diff --git a/.github/workflows/native-npm-release-build.yml b/.github/workflows/native-npm-release-build.yml index f77d42c..dc5834a 100644 --- a/.github/workflows/native-npm-release-build.yml +++ b/.github/workflows/native-npm-release-build.yml @@ -49,7 +49,7 @@ jobs: import shutil stage = Path(os.environ['RUNNER_TEMP']) / 'native-npm-assembly-tools' stage.mkdir() - for name in ['scripts/native_npm_payload.py', 'scripts/assemble_native_npm.py', 'scripts/check_native_npm.py', 'scripts/check_release_npm.py', 'scripts/pack_native_npm.py', 'scripts/patch_ffi_package_urls.py', 'scripts/check_wasm_npm.py', 'scripts/check_embedded_notices.py', 'scripts/windows_gnu_napi_variant.py']: + for name in ['scripts/rust_compiler_notices.py', 'scripts/native_npm_payload.py', 'scripts/assemble_native_npm.py', 'scripts/check_native_npm.py', 'scripts/check_release_npm.py', 'scripts/pack_native_npm.py', 'scripts/patch_ffi_package_urls.py', 'scripts/check_wasm_npm.py', 'scripts/check_embedded_notices.py', 'scripts/windows_gnu_napi_variant.py']: destination = stage / name destination.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(name, destination) diff --git a/.github/workflows/wasm-notice-check.yml b/.github/workflows/wasm-notice-check.yml index 293a168..2ed4575 100644 --- a/.github/workflows/wasm-notice-check.yml +++ b/.github/workflows/wasm-notice-check.yml @@ -23,7 +23,7 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'wasm-notice-tools' stage.mkdir() - for name in ['scripts/patch_ffi_package_urls.py', 'ci/test_ffi_package_urls.py', 'ci/fixtures/ffi-package-urls/ffi-bun.ts.txt', 'ci/fixtures/ffi-package-urls/ffi-deno.ts.txt', 'root-docs/PLATFORM-README/overview/body-1.md', 'Cargo.lock', 'ci/js-build-lock.json', 'ci/test_js_build_lock.py', 'scripts/wasm-notice-resource.mjs', 'tests/wasm-notice-resource.test.mjs', 'tests/test_wasm_npm.py', 'scripts/prepare_js_notices.py', 'scripts/check_wasm_npm.py', 'scripts/check-npm-licenses.mjs', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/check_embedded_notices.py', 'ci/about.toml', 'scripts/source_license_supplements.py', 'ci/test_js_source_supplements.py', 'ci/licenses/js-source-supplements.json']: + for name in ['scripts/rust_compiler_notices.py', 'ci/rust-compiler-notices.json', 'ci/test_js_compiler_materials.py', 'ci/licenses/rust-compiler-originals/compiler-builtins-LICENSE.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-Cargo.toml.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-build.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-aarch64.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-aarch64-outline-atomics.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-rt-aarch64-lse.S.txt', 'ci/licenses/rust-compiler-originals/compiler-rt-aarch64-cpu-model.c.txt', 'ci/licenses/rust-compiler-originals/compiler-rt-LICENSE.TXT', 'ci/licenses/rust-compiler-originals/compiler-rt-CREDITS.TXT', 'ci/licenses/rust-compiler-originals/compiler-builtins-math-mod.rs.txt', 'ci/licenses/rust-compiler-originals/libm-trunc.rs.txt', 'ci/licenses/rust-compiler-originals/libm-LICENSE.txt', 'ci/licenses/rust-compiler-originals/libm-generic-trunc.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-float-conv.rs.txt', 'scripts/patch_ffi_package_urls.py', 'ci/test_ffi_package_urls.py', 'ci/fixtures/ffi-package-urls/ffi-bun.ts.txt', 'ci/fixtures/ffi-package-urls/ffi-deno.ts.txt', 'root-docs/PLATFORM-README/overview/body-1.md', 'Cargo.lock', 'ci/js-build-lock.json', 'ci/test_js_build_lock.py', 'scripts/wasm-notice-resource.mjs', 'tests/wasm-notice-resource.test.mjs', 'tests/test_wasm_npm.py', 'scripts/prepare_js_notices.py', 'scripts/check_wasm_npm.py', 'scripts/check-npm-licenses.mjs', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/check_embedded_notices.py', 'ci/about.toml', 'scripts/source_license_supplements.py', 'ci/test_js_source_supplements.py', 'ci/licenses/js-source-supplements.json']: target = stage / name target.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(name, target) @@ -94,6 +94,7 @@ jobs: python3 -I -m unittest discover -s ci -p test_js_source_supplements.py -v python3 -I -m unittest discover -s ci -p test_js_build_lock.py -v python3 -I -m unittest discover -s ci -p test_ffi_package_urls.py -v + python3 -I -m unittest discover -s ci -p test_js_compiler_materials.py -v - name: Prepare source-backed locked notices shell: bash run: | @@ -159,6 +160,7 @@ jobs: for name in NOTICE.json Cargo.lock COPYRIGHT-library.html source-provenance.json; do cp "$RUNNER_TEMP/wasm-notices/$name" "dist/wasm/$name" done + cp -R "$RUNNER_TEMP/wasm-notices/ci" dist/wasm/ci - run: npm run build:ts - name: Verify host WASM consumer run: npm run test:node-wasm @@ -190,7 +192,8 @@ jobs: shutil.copyfile(archive, stage / archive.name) for name in ['NOTICE.json', 'Cargo.lock', 'COPYRIGHT-library.html', 'source-provenance.json', 'npm-verification.json']: shutil.copyfile(evidence / name, stage / name) - rows = [{'path': path.name, 'bytes': path.stat().st_size, 'sha256': hashlib.sha256(path.read_bytes()).hexdigest()} for path in sorted(stage.iterdir())] + shutil.copytree(evidence / 'ci', stage / 'ci') + rows = [{'path': path.relative_to(stage).as_posix(), 'bytes': path.stat().st_size, 'sha256': hashlib.sha256(path.read_bytes()).hexdigest()} for path in sorted(stage.rglob('*'), key=lambda path: path.relative_to(stage).as_posix()) if path.is_file()] record = {'package': '@ktav-lang/ktav', 'version': '0.8.1', 'source_ref': os.environ['SOURCE_REF'], 'tooling_ref': os.environ['GITHUB_SHA'], 'archive': archive.name, 'files': rows} (stage / 'main-package-manifest.json').write_text(json.dumps(record, sort_keys=True, indent=2) + '\n', encoding='utf-8') - uses: actions/upload-artifact@v4 diff --git a/.github/workflows/windows-cabi-gnullvm-check.yml b/.github/workflows/windows-cabi-gnullvm-check.yml index 5b4c5a7..d335910 100644 --- a/.github/workflows/windows-cabi-gnullvm-check.yml +++ b/.github/workflows/windows-cabi-gnullvm-check.yml @@ -38,7 +38,7 @@ jobs: from pathlib import Path stage = Path(os.environ['RUNNER_TEMP']) / 'cabi-gnullvm-tools' stage.mkdir() - for name in ['scripts/native_npm_payload.py', 'scripts/windows_gnu_napi_variant.py', 'Cargo.lock', 'ci/js-build-lock.json', 'crates/cabi/build.rs', 'scripts/patch_cabi_notice_source.py', 'ci/test_cabi_notice_overlay.py', 'scripts/cabi_gnullvm_notices.py', 'ci/test_cabi_gnullvm_notices.py', 'ci/licenses/cabi-gnullvm-runtime.json', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'ci/about.toml', 'ci/licenses/js-source-supplements.json']: + for name in ['scripts/rust_compiler_notices.py', 'ci/rust-compiler-notices.json', 'ci/test_js_compiler_materials.py', 'ci/licenses/rust-compiler-originals/compiler-builtins-LICENSE.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-Cargo.toml.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-build.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-aarch64.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-aarch64-outline-atomics.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-rt-aarch64-lse.S.txt', 'ci/licenses/rust-compiler-originals/compiler-rt-aarch64-cpu-model.c.txt', 'ci/licenses/rust-compiler-originals/compiler-rt-LICENSE.TXT', 'ci/licenses/rust-compiler-originals/compiler-rt-CREDITS.TXT', 'ci/licenses/rust-compiler-originals/compiler-builtins-math-mod.rs.txt', 'ci/licenses/rust-compiler-originals/libm-trunc.rs.txt', 'ci/licenses/rust-compiler-originals/libm-LICENSE.txt', 'ci/licenses/rust-compiler-originals/libm-generic-trunc.rs.txt', 'ci/licenses/rust-compiler-originals/compiler-builtins-float-conv.rs.txt', 'scripts/native_npm_payload.py', 'scripts/windows_gnu_napi_variant.py', 'Cargo.lock', 'ci/js-build-lock.json', 'crates/cabi/build.rs', 'scripts/patch_cabi_notice_source.py', 'ci/test_cabi_notice_overlay.py', 'scripts/cabi_gnullvm_notices.py', 'ci/test_cabi_gnullvm_notices.py', 'ci/licenses/cabi-gnullvm-runtime.json', 'scripts/check_embedded_notices.py', 'scripts/check-npm-licenses.mjs', 'scripts/prepare_js_notices.py', 'scripts/cargo_notice_bundle.py', 'scripts/collect_cargo_notices.py', 'scripts/source_license_supplements.py', 'ci/about.toml', 'ci/licenses/js-source-supplements.json']: path = stage / name path.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(name, path) diff --git a/ci/test_js_compiler_materials.py b/ci/test_js_compiler_materials.py new file mode 100644 index 0000000..4fcda45 --- /dev/null +++ b/ci/test_js_compiler_materials.py @@ -0,0 +1,77 @@ +"""Проверить exact compiler collection и полные originals без toolchain execution.""" + +import hashlib +import json +from pathlib import Path +import sys +import tempfile +import unittest + +ROOT = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(ROOT / 'scripts')) +from prepare_js_notices import stage_compiler +from rust_compiler_notices import collect, RUST_REVISION, PROFILE_SHA256 + +RUSTC = 'rustc 1.99.1 (fixture)\ncommit-hash: ' + RUST_REVISION + '\nrelease: 1.99.1\nLLVM version: 23.1.1\n' + + +class CompilerMaterialsTests(unittest.TestCase): + def test_complete_collection_and_source_sidecars_match(self): + with tempfile.TemporaryDirectory() as temporary: + evidence = Path(temporary) + collection = stage_compiler(ROOT, evidence, RUSTC) + self.assertEqual(collection, collect(evidence, RUSTC)) + self.assertEqual(collection['profile_sha256'], PROFILE_SHA256) + self.assertEqual(collection['compiler_builtins_license'], 'MIT AND Apache-2.0 WITH LLVM-exception') + self.assertEqual(collection['libm_license'], 'MIT') + self.assertEqual(len(collection['materials']), 14) + self.assertEqual(sum(item['legal_document'] for item in collection['materials']), 4) + for item in collection['materials']: + raw = (evidence / item['path']).read_bytes() + self.assertEqual(raw, item['text'].encode('utf-8')) + self.assertEqual(len(raw), item['bytes']) + self.assertEqual(hashlib.sha256(raw).hexdigest(), item['sha256']) + self.assertEqual(hashlib.sha1(b'blob ' + str(len(raw)).encode() + bytes([0]) + raw).hexdigest(), item['git_blob']) + + def test_unknown_compiler_cannot_reuse_the_reviewed_materials(self): + for text in [RUSTC.replace('1.99.1', '1.88.0'), RUSTC.replace(RUST_REVISION, '0' * 40)]: + with tempfile.TemporaryDirectory() as temporary: + root = Path(temporary) + with self.assertRaisesRegex(ValueError, 'unreviewed Rust compiler'): + stage_compiler(ROOT, root, text) + self.assertFalse((root / 'ci').exists()) + + def test_modified_original_source_is_rejected(self): + with tempfile.TemporaryDirectory() as temporary: + evidence = Path(temporary) + collection = stage_compiler(ROOT, evidence, RUSTC) + original = evidence / collection['materials'][0]['path'] + original.write_bytes(original.read_bytes() + b'changed') + with self.assertRaisesRegex(ValueError, 'original identity differs'): + collect(evidence, RUSTC) + + def test_changed_or_missing_profile_is_rejected(self): + for missing in [False, True]: + with tempfile.TemporaryDirectory() as temporary: + evidence = Path(temporary) + stage_compiler(ROOT, evidence, RUSTC) + path = evidence / 'ci/rust-compiler-notices.json' + if missing: + path.unlink() + else: + path.write_bytes(b'{}') + with self.assertRaisesRegex(ValueError, 'missing or symlinked|profile differs'): + collect(evidence, RUSTC) + + def test_original_legal_documents_are_kept_unmodified(self): + collection = collect(ROOT, RUSTC) + documents = {item['role']: item['text'] for item in collection['materials'] if item['legal_document']} + self.assertIn('Permission is hereby granted', documents['libm-LICENSE.txt']) + self.assertIn('Jorge Aparicio', documents['libm-LICENSE.txt']) + self.assertIn('musl', documents['libm-LICENSE.txt']) + self.assertIn('LLVM', documents['compiler-builtins-LICENSE.txt']) + self.assertIn('compiler-rt-CREDITS.TXT', documents) + + +if __name__ == '__main__': + unittest.main() diff --git a/ci/test_native_npm_payload.py b/ci/test_native_npm_payload.py index 63a63b8..b71f9bf 100644 --- a/ci/test_native_npm_payload.py +++ b/ci/test_native_npm_payload.py @@ -18,6 +18,7 @@ import native_npm_payload as PAYLOAD import assemble_native_npm as ASSEMBLY import check_native_npm as PACKED +from prepare_js_notices import stage_compiler @contextlib.contextmanager @@ -38,7 +39,9 @@ def fixture(self, temporary, role='napi'): for name in PAYLOAD.LICENSES: (root / name).write_bytes((ROOT / name).read_bytes()) lock = ('version = 3\n\n[[package]]\nname = "ktav"\nversion = "0.8.1"\nchecksum = "' + PAYLOAD.CORE + '"\n').encode() - notice = (json.dumps({'schema_version': 1, 'cargo_lock_sha256': PAYLOAD.sha(lock)}) + '\n').encode() + rustc = 'rustc 1.99.1 (fixture)\ncommit-hash: 58cf8f9c35b355199727627d07ae34a4e2846d67\nrelease: 1.99.1\nLLVM version: 23.1.1\n' + compiler = stage_compiler(ROOT, evidence, rustc) + notice = (json.dumps({'schema_version': 1, 'cargo_lock_sha256': PAYLOAD.sha(lock), 'rustc': rustc, 'rust_compiler_builtins': compiler}) + '\n').encode() compressed = gzip.compress(notice, mtime=0) raw = bytearray(32) raw[:4] = bytes.fromhex('cffaedfe') @@ -50,7 +53,7 @@ def fixture(self, temporary, role='napi'): 'NOTICE.json.gz': compressed, 'Cargo.lock': lock, 'COPYRIGHT-library.html': b'fixture standard library grant', - 'rustc.txt': b'fixture compiler identity', + 'rustc.txt': rustc.encode(), 'source-provenance.json': json.dumps({'source_ref': PAYLOAD.SOURCE, 'tooling_ref': 'a' * 40}).encode(), role + '-macos-verification.json': json.dumps({'target': 'x86_64-apple-darwin', 'role': role, 'binary_sha256': PAYLOAD.sha(binary)}).encode(), role + '-embedded-verification.json': b'{}', @@ -83,7 +86,8 @@ def test_complete_payload_retains_bytes_and_only_explicit_roles(self): self.assertEqual(document['package_binary'], 'ktav.darwin-x64.node') self.assertEqual((output / 'legal/NOTICE.json').read_bytes(), (evidence / 'NOTICE.json').read_bytes()) self.assertFalse((output / 'legal/unrelated.json').exists()) - self.assertEqual(len(document['files']), 12) + self.assertEqual(len(document['files']), 27) + self.assertEqual(len(list((output / 'legal/ci/licenses/rust-compiler-originals').iterdir())), 14) def test_missing_legal_role_rejected_even_with_rehashed_manifest(self): with tempfile.TemporaryDirectory() as temporary: diff --git a/scripts/check_release_npm.py b/scripts/check_release_npm.py index bb80175..da6c78a 100644 --- a/scripts/check_release_npm.py +++ b/scripts/check_release_npm.py @@ -11,6 +11,7 @@ from native_npm_payload import LICENSES, LOCK, SOURCE, TARGETS, read, sha from pack_native_npm import DOC_SHA from patch_ffi_package_urls import verify_records as verify_ffi_overlays +from rust_compiler_notices import collect as compiler_notices def verify(root): @@ -42,6 +43,8 @@ def verify(root): provenance = json.loads(read(evidence / 'source-provenance.json')) notice = json.loads(read(evidence / 'NOTICE.json')) verify_ffi_overlays(provenance['ffi_url_overlays']) + if notice['rust_compiler_builtins'] != compiler_notices(evidence, notice['rustc']): + raise ValueError('packed main exact compiler collection differs') if report['wasm'] != item['wasm'] or report['package_sha256'] != item['sha256'] or provenance['source_ref'] != SOURCE or provenance['tooling_ref'] != manifest['tooling_ref'] or provenance['platform_documentation_overlay']['compiled_sha256'] != DOC_SHA or sha(read(evidence / 'Cargo.lock', 4 * 1024 * 1024)) != LOCK or notice['cargo_lock_sha256'] != LOCK: raise ValueError('main package actual source/resource/lock identity differs') copyright_report = read(evidence / 'COPYRIGHT-library.html') diff --git a/scripts/native_npm_payload.py b/scripts/native_npm_payload.py index d77fa38..d7c07e8 100644 --- a/scripts/native_npm_payload.py +++ b/scripts/native_npm_payload.py @@ -11,6 +11,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parent)) from check_embedded_notices import MARKER, _extract from windows_gnu_napi_variant import verify_lock +from rust_compiler_notices import collect as compiler_notices SOURCE = '562deb3fde092d63a78f359be095e5079929d0d1' LOCK = 'c09c21c421fda8a5411f756f5df5718de41d4cf92ad237150592011f9f785932' @@ -26,7 +27,7 @@ 'win32-x64-msvc': 'x86_64-pc-windows-gnullvm', 'win32-arm64-msvc': 'aarch64-pc-windows-gnullvm', } -COMMON = ['NOTICE.json', 'NOTICE.json.gz', 'Cargo.lock', 'COPYRIGHT-library.html', 'rustc.txt', 'source-provenance.json'] +COMMON = ['NOTICE.json', 'NOTICE.json.gz', 'Cargo.lock', 'COPYRIGHT-library.html', 'rustc.txt', 'source-provenance.json', 'ci/rust-compiler-notices.json'] GNU_NAPI = ['GNU-RUNTIME-NOTICE.json', 'GNU-RUNTIME-NOTICE.txt', 'napi-gnu-sdk-inputs.json', 'sdk-notice-files.json', 'gnu-runtime-verification.json', 'rust-builtins-verification.json', 'native-link.map', 'native-link-inputs.json', 'native-link-command.json'] GNU_CABI = ['NOTICE.cargo-std.json', 'NOTICE.zig-runtime.txt', 'zig-runtime-catalog.json', 'zig-runtime-members.json', 'native-gnu-verification.json', 'native-link.map', 'native-link-command.json'] WINDOWS_CABI = ['NOTICE.cargo-std.json', 'NOTICE.windows-runtime.txt', 'cabi-gnullvm-runtime.json', 'native-runtime-verification.json', 'native-verification.json', 'link-input-fingerprints.json', 'native-link.map', 'sdk-legal.json'] @@ -127,7 +128,7 @@ def contract(root, rid, role): if sha(read(root / name, 64 * 1024)) != expected: raise ValueError('original first-party license differs') required = set(COMMON) - trees = {} + trees = {} if target.endswith('-gnullvm') and role == 'napi' else {'ci/licenses/rust-compiler-originals': 14} if target.endswith('-gnullvm') and role == 'napi': original = json.loads(read(root / 'legal/native-payload-manifest.json', 4 * 1024 * 1024)) original_paths = {item['path'] for item in original['files']} @@ -145,10 +146,10 @@ def contract(root, rid, role): elif target.endswith('-musl'): required.update(MUSL) required.update(role + '/' + name for name in ['Cargo.lock', 'NOTICE.json', 'NOTICE.json.gz', 'NOTICE.cargo-std.json', 'NOTICE.musl-runtime.txt', 'musl-runtime-catalog.json', 'source-provenance.json', 'native-verification.json', 'retained-runtime-verification.json', 'embedded-verification.json', 'native-link-command.json', 'native-link.map']) - trees = {'runtime-rust-originals': 13} + trees['runtime-rust-originals'] = 13 elif target.endswith('-gnullvm'): required.update(WINDOWS_CABI) - trees = {'runtime-originals': 64} + trees['runtime-originals'] = 64 else: required.update(GNU_NAPI if role == 'napi' else GNU_CABI) actual = {item['path'] for item in document['files']} @@ -167,6 +168,8 @@ def contract(root, rid, role): windows_napi = target.endswith('-gnullvm') and role == 'napi' if not windows_napi and sha(lock) != LOCK: raise ValueError('original reviewed native lock differs') + if not windows_napi and bundle['rust_compiler_builtins'] != compiler_notices(root / 'legal', bundle['rustc']): + raise ValueError('complete exact compiler grant collection differs') provenance = json.loads(read(root / 'legal' / ('source-variant.json' if windows_napi else 'source-provenance.json'))) if windows_napi: original_lock = read(root / 'legal/Cargo.original.lock', 4 * 1024 * 1024) @@ -206,7 +209,7 @@ def stage(evidence, output, rid, role): if len(cores) != 1 or cores[0]['version'] != '0.8.1' or cores[0].get('checksum') != CORE: raise ValueError('native resource registry core differs') selected = list(COMMON) - trees = [] + trees = [] if windows_napi else ['ci/licenses/rust-compiler-originals'] if windows_napi: producer = check_manifest(evidence, 'native-payload-manifest.json') if producer['target'] != target or producer['source_ref'] != SOURCE or producer['binary_sha256'] != sha(raw) or producer['notice_sha256'] != sha(notice): @@ -225,14 +228,14 @@ def stage(evidence, output, rid, role): proof = json.loads(read(evidence / (role + '-macos-verification.json'))) elif target.endswith('-musl'): selected += MUSL - trees = ['runtime-rust-originals'] + trees.append('runtime-rust-originals') selected += [role + '/' + name for name in ['Cargo.lock', 'NOTICE.json', 'NOTICE.json.gz', 'NOTICE.cargo-std.json', 'NOTICE.musl-runtime.txt', 'musl-runtime-catalog.json', 'source-provenance.json', 'native-verification.json', 'retained-runtime-verification.json', 'embedded-verification.json', 'native-link-command.json', 'native-link.map']] proof = json.loads(read(evidence / role / 'retained-runtime-verification.json')) if read(evidence / role / 'NOTICE.json') != notice: raise ValueError('musl role notice differs from complete source collection') elif target.endswith('-gnullvm'): selected += WINDOWS_CABI - trees = ['runtime-originals'] + trees.append('runtime-originals') proof = json.loads(read(evidence / 'native-runtime-verification.json')) elif role == 'napi': selected += GNU_NAPI diff --git a/scripts/pack_native_npm.py b/scripts/pack_native_npm.py index b1d3d2a..c47d941 100644 --- a/scripts/pack_native_npm.py +++ b/scripts/pack_native_npm.py @@ -13,6 +13,7 @@ from check_wasm_npm import verify as verify_wasm from native_npm_payload import LICENSES, LOCK, SOURCE, TARGETS, files, read, relative, sha from patch_ffi_package_urls import verify_records as verify_ffi_overlays +from rust_compiler_notices import collect as compiler_notices DOC_UNIT = 'root-docs/PLATFORM-README/overview/body-1.md' DOC_SHA = '35f1387f0566eea501c65a7f378076afe1a6d9f17725fd8168bf5fc21fa58a58' @@ -42,7 +43,12 @@ def verify_main(root, tooling): if Path(name).name != name or name != 'ktav-lang-ktav-0.8.1.tgz' or manifest['package'] != '@ktav-lang/ktav' or manifest['version'] != '0.8.1' or manifest['source_ref'] != SOURCE or manifest['tooling_ref'] != tooling: raise ValueError('main package producer identity differs') rows = manifest['files'] - expected = {name, 'NOTICE.json', 'Cargo.lock', 'COPYRIGHT-library.html', 'source-provenance.json', 'npm-verification.json'} + bundle = json.loads(read(root / 'NOTICE.json')) + compiler = compiler_notices(root, bundle['rustc']) + if bundle['rust_compiler_builtins'] != compiler: + raise ValueError('main package compiler collection differs') + compiler_paths = {'ci/rust-compiler-notices.json', *[item['path'] for item in compiler['materials']]} + expected = {name, 'NOTICE.json', 'Cargo.lock', 'COPYRIGHT-library.html', 'source-provenance.json', 'npm-verification.json'} | compiler_paths if len(rows) != len(expected) or {item['path'] for item in rows} != expected or sorted(rows, key=lambda item: item['path']) != [item for item in files(root) if item['path'] != 'main-package-manifest.json']: raise ValueError('complete main package producer role set differs') lock = read(root / 'Cargo.lock', 4 * 1024 * 1024) @@ -59,7 +65,7 @@ def verify_main(root, tooling): for key in ['package_sha256', 'notice_sha256', 'wasm', 'inline_matches_web']: if actual[key] != original[key]: raise ValueError('packed main package differs from producer verification') - for filename in ['NOTICE.json', 'Cargo.lock', 'COPYRIGHT-library.html', 'source-provenance.json']: + for filename in ['NOTICE.json', 'Cargo.lock', 'COPYRIGHT-library.html', 'source-provenance.json', *sorted(compiler_paths)]: if read(package / 'dist/wasm' / filename) != read(root / filename): raise ValueError('packed main source/legal role differs') for filename, expected_sha in LICENSES.items(): diff --git a/scripts/prepare_js_notices.py b/scripts/prepare_js_notices.py index 6f8461a..871110c 100644 --- a/scripts/prepare_js_notices.py +++ b/scripts/prepare_js_notices.py @@ -11,6 +11,23 @@ from cargo_notice_bundle import _build from source_license_supplements import supplement_fallbacks +from rust_compiler_notices import collect as compiler_notices + + +def stage_compiler(root, evidence, rustc): + collection = compiler_notices(root, rustc) + profile = root / 'ci/rust-compiler-notices.json' + raw = profile.read_bytes() + if hashlib.sha256(raw).hexdigest() != collection['profile_sha256']: + raise ValueError('compiler profile changed after collection') + destination = evidence / 'ci/rust-compiler-notices.json' + destination.parent.mkdir(parents=True) + destination.write_bytes(raw) + for item in collection['materials']: + destination = evidence / item['path'] + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(item['text'].encode('utf-8')) + return collection def reviewed_lock(root): @@ -68,6 +85,7 @@ def prepare(evidence): combined['source_license_supplements'] = provenance (evidence / 'licenses.json').write_text(json.dumps(combined, ensure_ascii=False, indent=2) + '\n', encoding='utf-8') bundle = json.loads(_build(evidence)) + bundle['rust_compiler_builtins'] = stage_compiler(root, evidence, bundle['rustc']) bundle['source_license_supplements'] = provenance bundle['resolution_origin'] = 'Pinned reviewed CI build graph for JS source 0.8.1; not historical published dependency evidence.' bundle['reviewed_build_lock'] = lock_provenance