Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# The English locale is historically CRLF. Keep Git's whitespace checker
# strict while treating the carriage return at its line ending as intentional.
locales/en.yml whitespace=cr-at-eol
# Keep repository text LF-only on every development host, including Windows.
* text=auto eol=lf

# The vendored Flatpak generator is verified byte-for-byte at build time.
build-aux/flatpak/flatpak-cargo-generator.py text eol=lf
Expand Down
116 changes: 59 additions & 57 deletions .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,59 @@
name: Fuzz
on:
schedule:
# Run weekly on Sunday at 04:00 UTC.
- cron: '0 4 * * 0'
workflow_dispatch:
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
fuzz:
name: Fuzz Targets
runs-on: ubuntu-24.04
# The fuzz crate depends on the full `tributary` library, so this builds
# and ASAN-instruments the entire dependency tree (GTK4, GStreamer,
# SeaORM, aws-lc-sys, ...) with codegen-units=1 from a cold cache before
# the 5-minute fuzz run. Allow generous headroom for that compile.
timeout-minutes: 60
container:
image: fedora:44
steps:
- name: Install system dependencies
run: |
dnf install -y gcc gcc-c++ gtk4-devel libadwaita-devel \
dbus-devel \
gstreamer1-devel gstreamer1-plugins-base-devel \
pkgconf-pkg-config git curl
- uses: actions/checkout@v7
- name: Cache Cargo registry
uses: actions/cache@v6
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: fuzz-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: fuzz-cargo-
- name: Cache fuzz corpus
uses: actions/cache@v6
with:
path: fuzz/corpus
key: fuzz-corpus-${{ github.run_id }}
restore-keys: fuzz-corpus-
- name: Install Rust nightly (required for cargo-fuzz)
uses: dtolnay/rust-toolchain@nightly
- name: Install cargo-fuzz
run: cargo install cargo-fuzz
- name: Fuzz DMAP parser (5 minutes)
run: cargo fuzz run fuzz_dmap -- -max_total_time=300
- name: Upload crash artifacts
if: always()
uses: actions/upload-artifact@v7
with:
name: fuzz-artifacts
path: fuzz/artifacts/
if-no-files-found: ignore
name: Fuzz
on:
schedule:
# Run weekly on Sunday at 04:00 UTC.
- cron: '0 4 * * 0'
workflow_dispatch:
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
fuzz:
name: Fuzz Targets
runs-on: ubuntu-24.04
# The fuzz crate depends on the full `tributary` library, so this builds
# and ASAN-instruments the entire dependency tree (GTK4, GStreamer,
# SeaORM, aws-lc-sys, ...) with codegen-units=1 from a cold cache before
# the 5-minute fuzz run. Allow generous headroom for that compile.
timeout-minutes: 60
container:
image: fedora:44
steps:
- name: Install system dependencies
run: |
dnf install -y gcc gcc-c++ gtk4-devel libadwaita-devel \
dbus-devel \
gstreamer1-devel gstreamer1-plugins-base-devel \
pkgconf-pkg-config git curl
- uses: actions/checkout@v7
Comment thread
coderabbitai[bot] marked this conversation as resolved.
with:
persist-credentials: false
- name: Cache Cargo registry
uses: actions/cache@v6
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
key: fuzz-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: fuzz-cargo-
- name: Cache fuzz corpus
uses: actions/cache@v6
with:
path: fuzz/corpus
key: fuzz-corpus-${{ github.run_id }}
restore-keys: fuzz-corpus-
- name: Install Rust nightly (required for cargo-fuzz)
uses: dtolnay/rust-toolchain@nightly
- name: Install cargo-fuzz
run: cargo install cargo-fuzz
- name: Fuzz DMAP parser (5 minutes)
run: cargo fuzz run fuzz_dmap -- -max_total_time=300
- name: Upload crash artifacts
if: always()
uses: actions/upload-artifact@v7
with:
name: fuzz-artifacts
path: fuzz/artifacts/
if-no-files-found: ignore
46 changes: 23 additions & 23 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
[package]
name = "tributary-fuzz"
version = "0.0.0"
publish = false
edition = "2021"
[package.metadata]
cargo-fuzz = true
[dependencies]
libfuzzer-sys = "0.4"
[dependencies.tributary]
path = ".."
# Prevent this from interfering with workspaces
[workspace]
members = ["."]
[[bin]]
name = "fuzz_dmap"
path = "fuzz_targets/fuzz_dmap.rs"
doc = false
[package]
name = "tributary-fuzz"
version = "0.0.0"
publish = false
edition = "2021"

[package.metadata]
cargo-fuzz = true

[dependencies]
libfuzzer-sys = "0.4"

[dependencies.tributary]
path = ".."

# Prevent this from interfering with workspaces
[workspace]
members = ["."]

[[bin]]
name = "fuzz_dmap"
path = "fuzz_targets/fuzz_dmap.rs"
doc = false
18 changes: 9 additions & 9 deletions fuzz/fuzz_targets/fuzz_dmap.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![no_main]
use libfuzzer_sys::fuzz_target;
fuzz_target!(|data: &[u8]| {
// Exercise the DMAP binary parser with arbitrary input.
// The parser should never panic — only return Ok or Err.
let _ = tributary::daap::dmap::parse_dmap(data);
});
#![no_main]

use libfuzzer_sys::fuzz_target;

fuzz_target!(|data: &[u8]| {
// Exercise the DMAP binary parser with arbitrary input.
// The parser should never panic — only return Ok or Err.
let _ = tributary::daap::dmap::parse_dmap(data);
});
74 changes: 38 additions & 36 deletions hooks/pre-commit
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
#!/bin/sh
#
# Git pre-commit hook for Tributary.
#
# Runs `cargo fmt --check` and aborts the commit if formatting issues
# are found. To enable this hook after cloning:
#
# git config core.hooksPath hooks
#
# To format your code before committing:
#
# cargo fmt
# # or on Windows via PowerShell:
# .\scripts\build-windows.ps1 -Fmt
#

set -e

echo "[pre-commit] Checking code formatting..."

if ! cargo fmt --check 2>/dev/null; then
echo ""
echo "╔══════════════════════════════════════════════════════════╗"
echo "║ Commit blocked: code formatting issues detected. ║"
echo "║ ║"
echo "║ Run one of the following to fix: ║"
echo "║ cargo fmt ║"
echo "║ ./scripts/build-windows.ps1 -Fmt (Windows) ║"
echo "║ ║"
echo "║ Then stage the changes and try again. ║"
echo "╚══════════════════════════════════════════════════════════╝"
echo ""
exit 1
fi

echo "[pre-commit] Formatting OK."
#!/bin/sh

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/sh
mode="$(git ls-files --stage -- hooks/pre-commit | awk '{print $1}')"
test "$mode" = 100755

Repository: jm2/tributary

Length of output: 151


🏁 Script executed:

#!/bin/sh
printf '%s\n' 'Tracked index entry:'
git ls-files --stage -- hooks/pre-commit
printf '%s\n' 'Working-tree mode:'
stat -c '%a %n' hooks/pre-commit 2>/dev/null || true
printf '%s\n' 'Tracked files matching hook path:'
git ls-files --stage | grep -E '(^|/)hooks/pre-commit$' || true

Repository: jm2/tributary

Length of output: 292


Set hooks/pre-commit to mode 100755.

Git records the hook as 100644, so Unix-like clients will not run it.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@hooks/pre-commit` at line 1, Change the executable mode of the
hooks/pre-commit file from 100644 to 100755 so Git records it as executable and
Unix-like clients can run it.

#
# Git pre-commit hook for Tributary.
#
# Runs `cargo fmt --check` and aborts the commit if formatting issues
# are found. To enable this hook after cloning:
#
# git config core.hooksPath hooks
#
# To format your code before committing:
#
# cargo fmt
# # or on Windows via PowerShell:
# .\scripts\build-windows.ps1 -Fmt
#

set -e

echo "[pre-commit] Checking code formatting..."

if ! cargo fmt --check 2>/dev/null ||
! cargo fmt --manifest-path fuzz/Cargo.toml --package tributary-fuzz -- --check 2>/dev/null; then
echo ""
echo "╔══════════════════════════════════════════════════════════╗"
echo "║ Commit blocked: code formatting issues detected. ║"
echo "║ ║"
echo "║ Run one of the following to fix: ║"
echo "║ cargo fmt ║"
echo "║ cargo fmt --manifest-path fuzz/Cargo.toml ║"
echo "║ ./scripts/build-windows.ps1 -Fmt (Windows) ║"
echo "║ ║"
echo "║ Then stage the changes and try again. ║"
echo "╚══════════════════════════════════════════════════════════╝"
echo ""
exit 1
fi

echo "[pre-commit] Formatting OK."
22 changes: 13 additions & 9 deletions scripts/build-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1391,18 +1391,22 @@ $env:PKG_CONFIG_PATH = $pkgConfigPath
$env:PKG_CONFIG_ALLOW_CROSS = "1"
$env:PATH = "$MsysPath\bin;" + $env:PATH

# Force Cargo to use MSYS2 tools instead of Rustup's incomplete bundled toolchain.
# Force target build scripts to use MSYS2 tools without overriding the native
# compiler used by host build dependencies. Generic CC/CXX/AR variables also
# apply to MSVC-hosted build scripts (for example `vswhom-sys`) and make them
# invoke the MinGW compiler without the Visual Studio include environment.
$ToolEnvTarget = $RustTarget.Replace("-", "_").Replace(".", "_")
if ($MsysEnv -match "clang") {
$env:DLLTOOL = Join-Path $MsysPath "bin\llvm-dlltool.exe"
$env:CC = Join-Path $MsysPath "bin\clang.exe"
$env:CXX = Join-Path $MsysPath "bin\clang++.exe"
$env:AR = Join-Path $MsysPath "bin\llvm-ar.exe"
[Environment]::SetEnvironmentVariable("DLLTOOL_$ToolEnvTarget", (Join-Path $MsysPath "bin\llvm-dlltool.exe"), "Process")
[Environment]::SetEnvironmentVariable("CC_$ToolEnvTarget", (Join-Path $MsysPath "bin\clang.exe"), "Process")
[Environment]::SetEnvironmentVariable("CXX_$ToolEnvTarget", (Join-Path $MsysPath "bin\clang++.exe"), "Process")
[Environment]::SetEnvironmentVariable("AR_$ToolEnvTarget", (Join-Path $MsysPath "bin\llvm-ar.exe"), "Process")
}
else {
$env:DLLTOOL = Join-Path $MsysPath "bin\dlltool.exe"
$env:CC = Join-Path $MsysPath "bin\gcc.exe"
$env:CXX = Join-Path $MsysPath "bin\g++.exe"
$env:AR = Join-Path $MsysPath "bin\ar.exe"
[Environment]::SetEnvironmentVariable("DLLTOOL_$ToolEnvTarget", (Join-Path $MsysPath "bin\dlltool.exe"), "Process")
[Environment]::SetEnvironmentVariable("CC_$ToolEnvTarget", (Join-Path $MsysPath "bin\gcc.exe"), "Process")
[Environment]::SetEnvironmentVariable("CXX_$ToolEnvTarget", (Join-Path $MsysPath "bin\g++.exe"), "Process")
[Environment]::SetEnvironmentVariable("AR_$ToolEnvTarget", (Join-Path $MsysPath "bin\ar.exe"), "Process")
Comment on lines +1394 to +1409

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

rg -n -C 4 'DLLTOOL|CC|CXX|AR|cc::Build|vswhom|dlltool' .

Repository: jm2/tributary

Length of output: 50370


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- Windows build script references ---'
rg -n -C 5 'DLLTOOL|CC_|CXX_|AR_|SetEnvironmentVariable|RustTarget|MsysEnv|vswhom' scripts/build-windows.ps1

printf '%s\n' '--- Rust manifests and build-related dependencies ---'
rg -n -C 3 '(^|\s)(cc|vswhom|bindgen|cmake|build-dependencies|target\.)' --glob 'Cargo.toml' --glob 'Cargo.lock' .

printf '%s\n' '--- Build scripts and native-tool consumers ---'
git ls-files | rg '(^|/)(build\.rs|.*build.*\.(rs|toml|ps1|sh)|.*sys.*\.rs)$' | head -200
rg -n -C 3 'env::var|var_os|DLLTOOL|CC|CXX|AR|cc::Build|cc::Tool|dlltool|clang|gcc' --glob '*.rs' --glob 'build.rs' --glob '*.toml' --glob '*.ps1' --glob '*.sh' . | head -500

Repository: jm2/tributary

Length of output: 6958


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- Focused files ---'
fd -i 'build-windows.ps1|Cargo.toml|Cargo.lock|build.rs' . | sort

printf '%s\n' '--- Relevant script sections ---'
sed -n '1360,1435p' scripts/build-windows.ps1

printf '%s\n' '--- Dependency declarations ---'
rg -n -C 5 'cc|vswhom|bindgen|cmake|build-dependencies' --glob 'Cargo.toml' --glob 'Cargo.lock' .

printf '%s\n' '--- Repository-owned native build consumers ---'
rg -l 'DLLTOOL|CC_|CXX_|AR_|cc::Build|cc::Tool|dlltool|vswhom' --glob '*.rs' --glob 'build.rs' --glob '*.toml' --glob '*.ps1' --glob '*.sh' . | sort

Repository: jm2/tributary

Length of output: 50370


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
for p in Path('.').rglob('Cargo.toml'):
    text = p.read_text(errors='replace')
    if any(x in text for x in ('cc', 'vswhom', 'bindgen', 'cmake')):
        print(f'--- {p} ---')
        for i, line in enumerate(text.splitlines(), 1):
            if any(x in line for x in ('cc', 'vswhom', 'bindgen', 'cmake', 'build-dependencies')):
                print(f'{i}: {line}')
PY

printf '%s\n' '--- Environment assignments in the PowerShell script ---'
rg -n -C 8 'SetEnvironmentVariable|RemoveItem Env:|Env:' scripts/build-windows.ps1

Repository: jm2/tributary

Length of output: 1896


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- Root manifest and build script ---'
sed -n '1,175p' Cargo.toml
cat -n build.rs

printf '%s\n' '--- Relevant lockfile package records ---'
python3 - <<'PY'
from pathlib import Path
text = Path('Cargo.lock').read_text()
for name in ('name = "cc"', 'name = "embed-resource"', 'name = "vswhom"', 'name = "winresource"'):
    pos = 0
    while True:
        pos = text.find(name, pos)
        if pos < 0:
            break
        start = text.rfind('[[package]]', 0, pos)
        end = text.find('[[package]]', pos + len(name))
        print(text[start:end if end >= 0 else None].rstrip())
        pos += len(name)
PY

printf '%s\n' '--- All repository references to native variables ---'
rg -n 'DLLTOOL|CC_|CXX_|AR_|cc::|embed_resource|winresource|vswhom' --glob '!fuzz/Cargo.lock' --glob '!Cargo.lock' --glob '*.rs' --glob '*.toml' --glob '*.ps1' .

Repository: jm2/tributary

Length of output: 13801


🌐 Web query:

cc-rs target-qualified CC CXX AR environment variables DLLTOOL embed-resource vswhom source

💡 Result:

The cc-rs crate uses various environment variables to configure the C/C++ build process, allowing for target-specific overrides and flexible integration with external tools. Environment Variables and Target Qualification The cc-rs crate supports target-qualified environment variables to allow granular control when building for specific architectures or platforms [1][2][3]. For any configuration variable (e.g., CC, CXX, AR, CFLAGS), you can provide versions prefixed or suffixed by the target triple [1][2]. The search order for these variables is as follows [1][2][3]: 1. : e.g., CC_x86_64-unknown-linux-gnu [1][2] 2. <TARGET_WITH_UNDERSCORES>: e.g., CC_x86_64_unknown_linux_gnu (where periods and dashes are replaced by underscores) [1][2] 3. <BUILD_KIND>: e.g., HOST_CC or TARGET_CFLAGS [1][2] 4. : The plain variable (e.g., CC, AR) [1][2] Core Configuration Variables - CC / CXX: Specifies the C or C++ compiler [2][4]. These can also be used to specify compiler wrappers like sccache by setting CC="sccache cc" [2][4]. - AR: Specifies the archiver executable used for static libraries [1][2]. - DLLTOOL: Used in specific cross-compilation contexts (often associated with mingw-w64 toolchains) to generate import libraries for DLLs. - CRATE_CC_NO_DEFAULTS: If set, disables the generation of default compiler flags, which can be useful to avoid conflicts in complex cross-compilation setups [2][4]. Related Tools and Integration - embed-resource: This crate is commonly used for Windows resource compilation [5]. It interacts with cc-rs to find MSVC tools and include directories [5][6]. Specifically, it uses environment variables like RC$TARGET or RC to override the default resource compiler [5]. When using LLVM-RC, it often relies on the cc-rs crate to provide the correct preprocessor configuration and environment (such as INCLUDE paths) [5][6]. - vswhom: This is an internal or related utility often used by these crates (via cc::windows_registry) to locate the MSVC toolchain on Windows, including the compiler (cl.exe), linker, and other build tools [5][6]. For programmatic configuration, the Build struct provides methods like env to set variables for child processes and try_flags_from_environment to dynamically inject flags from user-defined environment variables [1][7].

Citations:


🌐 Web query:

docs.rs embed-resource DLLTOOL CC target environment variables vswhom-sys

💡 Result:

The embed-resource crate is a tool for compiling and linking Windows resource files (.rc) into Rust executables via build.rs scripts [1][2]. The vswhom-sys crate provides low-level FFI bindings to a C-based discovery script (originally by Jon Blow) designed to locate Visual Studio and Windows SDK installations, which helps other tools find necessary compilers, linkers, and libraries when building C/C++ code on Windows [3][4][5]. Regarding the specific technical environment variables and interactions you mentioned: Environment Variable Overrides for embed-resource: When building for Windows, embed-resource defaults to using x86_64-w64-mingw32-windres for *-pc-windows-gnu targets and llvm-rc for *-pc-windows-msvc targets [1][6]. These defaults can be overridden by setting the RC_$TARGET, RC_${TARGET//-/_}, or RC environment variables [1][6]. Role of C Compilers and Discovery: - When using llvm-rc to compile resource files, an external C compiler is employed to preprocess the resource [1][6]. This process is pre-configured using settings from the cc crate [1][6]. - While embed-resource can attempt to find Windows SDK tools like RC.EXE or MIDL.EXE [1][7][8], it often leverages cc or vswhom (and by extension vswhom-sys) for more robust discovery of the Visual Studio environment, including compiler and linker locations [3][8][5]. - vswhom-sys specifically aids in finding paths for Visual Studio libraries (e.g., libvcruntime.lib) and executables (e.g., link.exe), as well as Windows SDK libraries (e.g., kernel32.lib) [3][5]. Note on vswhom-sys: The vswhom-sys crate is a pure FFI wrapper. Users should be aware that the underlying native code has been documented to cause memory corruption in some cases [4][9]. Most users typically interact with the higher-level vswhom crate rather than the -sys binding directly [8].

Citations:


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

# Inspect only the lockfile records that can introduce native build consumers.
python3 - <<'PY'
from pathlib import Path
for filename in ('Cargo.lock', 'fuzz/Cargo.lock'):
    text = Path(filename).read_text()
    print(f'--- {filename} ---')
    records = text.split('[[package]]')
    for record in records:
        if any(f'name = "{n}"' in record for n in ('cc', 'embed-resource', 'vswhom', 'winresource')):
            print('[[package]]' + record.rstrip())
PY

printf '%s\n' '--- Build script behavior ---'
cat -n build.rs

Repository: jm2/tributary

Length of output: 4144


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

python3 - <<'PY'
import json, urllib.request

urls = {
    'embed-resource Cargo.toml':
        'https://raw.githubusercontent.com/nabijaczleweli/rust-embed-resource/v3.0.11/Cargo.toml',
    'embed-resource src/lib.rs':
        'https://raw.githubusercontent.com/nabijaczleweli/rust-embed-resource/v3.0.11/src/lib.rs',
    'cc 1.2.64 src/lib.rs':
        'https://raw.githubusercontent.com/rust-lang/cc-rs/cc-1.2.64/src/lib.rs',
}
for label, url in urls.items():
    print(f'--- {label} ---')
    try:
        text = urllib.request.urlopen(url, timeout=10).read().decode()
    except Exception as e:
        print(f'FETCH ERROR: {e}')
        continue
    lines = text.splitlines()
    needles = ('DLLTOOL', 'RC_', 'CC_', 'CXX_', 'AR_', 'windows_registry',
               'env::var', 'var_os', 'Build::new', 'Tool::with_features')
    for i, line in enumerate(lines, 1):
        if any(n in line for n in needles):
            lo, hi = max(1, i-3), min(len(lines), i+5)
            print(f'[{lo}-{hi}]')
            for j in range(lo, hi+1):
                print(f'{j}: {lines[j-1]}')
PY

Repository: jm2/tributary

Length of output: 692


🌐 Web query:

site:github.com/nabijaczleweli/rust-embed-resource "DLLTOOL" "compile_for"

💡 Result:

The term "compile_for" refers to a function provided by the rust-embed-resource Rust crate, rather than a standard option or command for the binutils tool "dlltool" [1][2]. In the context of the rust-embed-resource crate, which is used to compile and include Windows resources (like icons or version information) in Rust projects, the compile_for function is used to associate a specific resource file with one or more designated binaries or targets [1][2]. Syntax and Usage: The function typically takes the path to the resource file, a list of binaries for which the resource should be compiled, and any additional configuration parameters [1][2]. Example: embed_resource::compile_for("assets/poke-a-mango.rc", &["poke-a-mango", "poke-a-mango-installer"], &["VERSION="0.5.0""]).manifest_required.unwrap; This allows developers to manage different resource files for different parts of a project, such as assigning a specific icon to an installer binary versus the main application binary [1][2]. If you were searching for a "compile for" option related to dlltool, no such parameter exists in the standard GNU binutils dlltool implementation.

Citations:


🌐 Web query:

site:github.com/nabijaczleweli/rust-embed-resource "CC_" "RC_" src

💡 Result:

In technical contexts, particularly within Rust build scripts and software development for Windows, CC_, RC_, and src are typically related to build configuration and environment variables: 1. CC_: Often refers to the C compiler (e.g., set via the CC environment variable). In many build systems, including those using the 'cc' crate in Rust, this variable defines the path to the C compiler executable [1]. 2. RC_: Frequently refers to the Resource Compiler (e.g., rc.exe or windres). In Windows development, the resource compiler is used to compile.rc files into.res files, which are then linked into the final executable. Build tools often look for an environment variable named RC or RC_ to locate the correct resource compiler for a specific target architecture [2][3][1]. 3. src: This is a standard convention for a directory name, typically standing for "source," which contains the source code files for a project. In Rust, it is standard for crates to have a src/ directory containing lib.rs or main.rs [4][2]. These terms often appear together in the context of build automation where a build script needs to locate compilers (CC for C code, RC for Windows resources) to process files found in the project's source directory (src) [4][2][3].

Citations:


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

python3 - <<'PY'
import io, tarfile, urllib.request

for crate, version in [('embed-resource', '3.0.11'), ('cc', '1.2.64')]:
    url = f'https://crates.io/api/v1/crates/{crate}/{version}/download'
    print(f'--- {crate} {version} ---')
    try:
        data = urllib.request.urlopen(url, timeout=20).read()
        archive = tarfile.open(fileobj=io.BytesIO(data), mode='r:gz')
    except Exception as e:
        print(f'FETCH ERROR: {e}')
        continue
    for member in archive.getmembers():
        if not member.isfile() or not member.name.endswith(('.rs', '.toml')):
            continue
        text = archive.extractfile(member).read().decode(errors='replace')
        lines = text.splitlines()
        if any(token in text for token in ('DLLTOOL', 'RC_', 'CC_', 'CXX_', 'AR_',
                                           'windows_registry', 'Build::new')):
            print(f'### {member.name}')
            for i, line in enumerate(lines, 1):
                if any(token in line for token in ('DLLTOOL', 'RC_', 'CC_', 'CXX_', 'AR_',
                                                   'windows_registry', 'Build::new')):
                    for j in range(max(1, i-3), min(len(lines), i+5)+1):
                        print(f'{j}: {lines[j-1]}')
                    print()
PY

Repository: jm2/tributary

Length of output: 495


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

python3 - <<'PY'
import io, tarfile, subprocess

for crate, version in [('embed-resource', '3.0.11'), ('cc', '1.2.64')]:
    url = f'https://crates.io/api/v1/crates/{crate}/{version}/download'
    print(f'--- {crate} {version} ---')
    data = subprocess.check_output(['curl', '-fsSLk', url])
    archive = tarfile.open(fileobj=io.BytesIO(data), mode='r:gz')
    for member in archive.getmembers():
        if not member.isfile() or not member.name.endswith(('.rs', '.toml')):
            continue
        text = archive.extractfile(member).read().decode(errors='replace')
        lines = text.splitlines()
        tokens = ('DLLTOOL', 'RC_', 'CC_', 'CXX_', 'AR_', 'windows_registry',
                  'Build::new', 'env::var')
        if any(token in text for token in tokens):
            print(f'### {member.name}')
            shown = set()
            for i, line in enumerate(lines, 1):
                if any(token in line for token in tokens):
                    lo, hi = max(1, i-3), min(len(lines), i+5)
                    if (lo, hi) in shown:
                        continue
                    shown.add((lo, hi))
                    for j in range(lo, hi+1):
                        print(f'{j}: {lines[j-1]}')
                    print()
PY

Repository: jm2/tributary

Length of output: 768


🌐 Web query:

embed-resource 3.0.11 source RC_TARGET cc Build target gnullvm DLLTOOL

💡 Result:

The query relates to the behavior of the rust-embed-resource crate (version 3.0.11), which is a library used in Rust build scripts to handle the compilation and inclusion of Windows resources [1][2]. When building for Windows targets, especially the *-windows-gnullvm target family (e.g., aarch64-pc-windows-gnullvm), the library uses specific environmental configurations and toolchains to invoke resource compilers [3][4]. Key technical points regarding your query: 1. Resource Compilation: For *-windows-gnullvm targets, which rely on LLVM-based tools rather than the traditional GNU binutils (like windres and dlltool), the crate is designed to use compatible tools [4][5]. Specifically, llvm-rc is preferred and used for these targets [3][6]. 2. Environment Variable Overrides: The library allows users to override the default tool selection by setting environment variables such as RC_$TARGET, RC_${TARGET//-/_}, or RC [3]. 3. Interaction with cc: When using LLVM-RC, an external C compiler is employed to preprocess the resource file, using configurations derived from the cc crate [3]. Recent developments in the ecosystem have addressed issues where invalid target triples (containing the -gnullvm suffix) were passed to Clang by the cc crate; fixes involve stripping the llvm suffix to produce a valid target string (e.g., converting aarch64-pc-windows-gnullvm to aarch64-pc-windows-gnu for the compiler invocation) [7][8]. 4. dlltool: The gnullvm target architecture intentionally moves away from reliance on GNU dlltool [4]. Efforts within the Rust ecosystem have sought to further reduce reliance on dlltool for creating DLL import libraries to improve compatibility and reduce complexity [5]. In summary, the specific combination of build targets and tools you mentioned is part of the orchestration required to manage Windows resource embedding using modern LLVM-based toolchains on Rust platforms [3][4]. Version 3.0.11 of embed-resource includes refinements to these tool selection processes, such as improved support for llvm-rc on gnullvm targets [9][6].

Citations:


🌐 Web query:

cc-rs 1.2.64 source target qualified environment variable DLLTOOL

💡 Result:

The cc-rs crate does not have a dedicated environment variable named DLLTOOL. Environment variables supported by cc-rs are used to configure compilers and their flags [1][2]. While cc-rs supports target-qualified environment variables for tools like CC, CXX, and AR (e.g., CC_x86_64-unknown-linux-gnu) [1][2], the specific tool dlltool is not typically managed through cc-rs environment variables. Instead, the -Cdlltool option is a rustc codegen option used to specify the path to the dlltool executable, particularly for Windows cross-compilation targets using the raw-dylib feature [3][4][5]. This option is passed to the Rust compiler (e.g., via RUSTFLAGS) rather than the cc-rs crate's configuration mechanism [5]. Projects encountering issues with dlltool may sometimes use RUSTFLAGS to explicitly set the path to the correct dlltool binary to work around host/target environment discrepancies [5].

Citations:


Set RC_$ToolEnvTarget for embed-resource.

embed-resource selects the Windows resource compiler through RC_<target> or RC. DLLTOOL_<target> does not configure this path. Set RC_$ToolEnvTarget to the MSYS2 llvm-rc.exe for both default *-windows-gnullvm targets.

🧰 Tools
🪛 PSScriptAnalyzer (1.25.0)

[warning] Missing BOM encoding for non-ASCII encoded file 'build-windows.ps1'

(PSUseBOMForUnicodeEncodedFile)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/build-windows.ps1` around lines 1394 - 1409, In the target tool
environment setup around $ToolEnvTarget, set RC_$ToolEnvTarget to the MSYS2
llvm-rc.exe path in both the clang and non-clang branches. Keep the existing
DLLTOOL, CC, CXX, and AR assignments unchanged, using the same target-specific
environment-variable mechanism.

}

Write-Info "PKG_CONFIG_PATH set to $pkgConfigPath"
Expand Down
Loading
Loading