Skip to content

Don't bundle alsa lib#1

Open
jonaski wants to merge 1 commit into
masterfrom
alsa
Open

Don't bundle alsa lib#1
jonaski wants to merge 1 commit into
masterfrom
alsa

Conversation

@jonaski

@jonaski jonaski commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Bug Fixes

    • Improved ALSA compatibility by using the host system’s ALSA libraries, plugins, configuration, and profiles instead of bundling them.
    • Added startup handling to preload the matching host ALSA library when available.
    • Prevented ALSA components from being copied into deployed application bundles.
  • Documentation

    • Updated deployment documentation to clarify that ALSA is never bundled.

@jonaski
jonaski requested a review from Copilot July 25, 2026 22:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

ALSA host-resolution flow

Layer / File(s) Summary
Dependency pruning
src/dependencywalker.h, src/dependencywalker.cpp
Adds an API that removes registered ELF paths matching a filename prefix without changing library locations.
ALSA deployment exclusion
src/miscdeploy.*, src/appimagedeploy.h, README.md
HandleAlsa removes libasound.so* from bundled dependencies, and documentation describes ALSA as host-resolved.
Runtime ALSA preload
data/apprun.sh
AppRun selects an existing host libasound.so.2, appends it to LD_PRELOAD, and prints the resulting value.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MiscDeploy
  participant DependencyWalker
  participant AppDir
  participant AppRun
  participant HostALSA
  participant MainBinary
  MiscDeploy->>DependencyWalker: Remove libasound.so* entries
  DependencyWalker->>AppDir: Exclude bundled ALSA libraries
  AppRun->>HostALSA: Find host libasound.so.2
  AppRun->>MainBinary: Launch with host ALSA in LD_PRELOAD
Loading

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: ALSA is no longer bundled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch alsa

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with 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.

Inline comments:
In `@data/apprun.sh`:
- Around line 75-80: Update the AppRun preload loop at data/apprun.sh:75-80 to
discover libasound.so.2 using the host architecture’s library paths, and warn or
fail explicitly when none is found. Review the related dependency handling at
src/dependencywalker.h:52-54, src/miscdeploy.cpp:173-175, and
src/miscdeploy.h:45-46; make no direct changes there unless needed to keep the
dependency behavior consistent. Update the “always resolves” claim in
README.md:33 to reflect the architecture-aware lookup and missing-library
behavior.

In `@README.md`:
- Line 33: Update the ALSA entry in README.md to remove the unconditional
“always resolves” claim and accurately describe the behavior of data/apprun.sh:
libasound.so.2 is preloaded only from its configured fixed paths, while other
host installations may not be resolved by that mechanism.

In `@src/dependencywalker.h`:
- Around line 52-54: Update the documentation for RemoveElfsByFilenamePrefix()
to clarify that it only removes the bundled ELF and does not guarantee host
resolution. State that AppRun must explicitly preload a compatible host library
for libraries requiring system resolution, and remove the implication that
generic dynamic-linker fallback is sufficient.

In `@src/miscdeploy.h`:
- Around line 45-46: Update the ALSA runtime contract around HandleAlsa so it
explicitly documents that AppRun must locate and LD_PRELOAD the host
libasound.so.2 using the supported fixed path list, or broaden that lookup to
cover every intended host layout if the guarantee is meant literally. Keep the
dependency-walker behavior unchanged unless expanding the lookup is required.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d176b5ca-e7e2-451d-b759-15a399f09e3f

📥 Commits

Reviewing files that changed from the base of the PR and between f558317 and c2c6699.

📒 Files selected for processing (7)
  • README.md
  • data/apprun.sh
  • src/appimagedeploy.h
  • src/dependencywalker.cpp
  • src/dependencywalker.h
  • src/miscdeploy.cpp
  • src/miscdeploy.h

Comment thread data/apprun.sh
Comment on lines +75 to +80
for ALSA_LIB in /usr/lib/x86_64-linux-gnu/libasound.so.2 /usr/lib/aarch64-linux-gnu/libasound.so.2 /usr/lib64/libasound.so.2 /usr/lib/libasound.so.2 /lib/x86_64-linux-gnu/libasound.so.2; do
if [ -e "${ALSA_LIB}" ]; then
export LD_PRELOAD="${LD_PRELOAD:+${LD_PRELOAD}:}${ALSA_LIB}"
break
fi
done

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 | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '--- data/apprun.sh ---\n'
nl -ba data/apprun.sh | sed -n '1,160p'

printf '\n--- src/dependencywalker.h ---\n'
nl -ba src/dependencywalker.h | sed -n '1,140p'

printf '\n--- src/miscdeploy.cpp ---\n'
nl -ba src/miscdeploy.cpp | sed -n '1,260p'

printf '\n--- src/miscdeploy.h ---\n'
nl -ba src/miscdeploy.h | sed -n '1,120p'

printf '\n--- README.md ---\n'
nl -ba README.md | sed -n '1,120p'

printf '\n--- ALSA search ---\n'
rg -n "libasound|ALSA|alsa-lib|AppRun|LD_PRELOAD" data src README.md

Repository: jonaski/appimagetools

Length of output: 250


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- data/apprun.sh ---'
nl -ba data/apprun.sh | sed -n '1,160p'

echo
echo '--- src/dependencywalker.h ---'
nl -ba src/dependencywalker.h | sed -n '1,140p'

echo
echo '--- src/miscdeploy.cpp ---'
nl -ba src/miscdeploy.cpp | sed -n '1,260p'

echo
echo '--- src/miscdeploy.h ---'
nl -ba src/miscdeploy.h | sed -n '1,120p'

echo
echo '--- README.md ---'
nl -ba README.md | sed -n '1,120p'

echo
echo '--- ALSA search ---'
rg -n "libasound|ALSA|alsa-lib|AppRun|LD_PRELOAD" data src README.md

Repository: jonaski/appimagetools

Length of output: 222


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- data/apprun.sh ---'
sed -n '1,160p' data/apprun.sh | cat -n

echo
echo '--- src/dependencywalker.h ---'
sed -n '1,140p' src/dependencywalker.h | cat -n

echo
echo '--- src/miscdeploy.cpp ---'
sed -n '1,260p' src/miscdeploy.cpp | cat -n

echo
echo '--- src/miscdeploy.h ---'
sed -n '1,120p' src/miscdeploy.h | cat -n

echo
echo '--- README.md ---'
sed -n '1,120p' README.md | cat -n

echo
echo '--- ALSA search ---'
rg -n "libasound|ALSA|alsa-lib|AppRun|LD_PRELOAD" data src README.md

Repository: jonaski/appimagetools

Length of output: 50379


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- arch/support search ---'
rg -n "x86_64|aarch64|armhf|arm64|riscv64|ppc64le|supported architectures|architecture" README.md src data | head -n 200

echo
echo '--- libasound search ---'
rg -n "libasound|ALSA" src data README.md

echo
echo '--- AppRun template source ---'
sed -n '40,90p' src/appimagedeploy.cpp | cat -n

Repository: jonaski/appimagetools

Length of output: 7088


AppRun only preloads ALSA from a fixed path list, so the “always resolves” guarantee is too strong. That misses at least armhf/i686 host layouts, leaving LD_PRELOAD unset and ALSA unavailable even though the bundled copy is removed. Add architecture-aware lookup or warn/fail when no host libasound.so.2 is found.

📍 Affects 5 files
  • data/apprun.sh#L75-L80 (this comment)
  • src/dependencywalker.h#L52-L54
  • src/miscdeploy.cpp#L173-L175
  • src/miscdeploy.h#L45-L46
  • README.md#L33-L33
🤖 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 `@data/apprun.sh` around lines 75 - 80, Update the AppRun preload loop at
data/apprun.sh:75-80 to discover libasound.so.2 using the host architecture’s
library paths, and warn or fail explicitly when none is found. Review the
related dependency handling at src/dependencywalker.h:52-54,
src/miscdeploy.cpp:173-175, and src/miscdeploy.h:45-46; make no direct changes
there unless needed to keep the dependency behavior consistent. Update the
“always resolves” claim in README.md:33 to reflect the architecture-aware lookup
and missing-library behavior.

Comment thread README.md
| Gdk-Pixbuf | `libgdk_pixbuf` | Pixbuf loaders + a patched `loaders.cache` |
| GTK 2/3/4 | `libgtk-<2\|3\|4>` | The matching GTK module directory, default theme (GTK ≤ 3), and a patched `immodules.cache` (GTK ≤ 3) |
| ALSA | `libasound` | The `alsa-lib` plugin directory |
| ALSA | `libasound` | **Never bundled** - `libasound.so*` is removed from the dependency set so it always resolves against the running system's alsa-lib (plugins, config, and hardware UCM profiles are versioned together and bundling them breaks device access on a mismatched host) |

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:

#!/bin/bash
set -euo pipefail

printf '== README excerpt ==\n'
nl -ba README.md | sed -n '25,40p'

printf '\n== data/apprun.sh outline ==\n'
ast-grep outline data/apprun.sh --view expanded

printf '\n== resolver-related matches ==\n'
rg -n "libasound|alsa|LD_LIBRARY_PATH|rpath|resolve|library|dlopen|ldconfig|/usr/lib|/lib" data/apprun.sh README.md

Repository: jonaski/appimagetools

Length of output: 220


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '== data/apprun.sh full relevant sections ==\n'
nl -ba data/apprun.sh | sed -n '1,260p'

Repository: jonaski/appimagetools

Length of output: 243


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '== README excerpt ==\n'
cat -n README.md | sed -n '25,40p'

printf '\n== data/apprun.sh status ==\n'
if [ -f data/apprun.sh ]; then
  printf 'exists\n'
  printf '\n== data/apprun.sh excerpt ==\n'
  cat -n data/apprun.sh | sed -n '1,260p'
else
  printf 'missing\n'
fi

printf '\n== search for ALSA-related logic ==\n'
rg -n "libasound|alsa|LD_LIBRARY_PATH|rpath|resolve|library|dlopen|ldconfig|/usr/lib|/lib" README.md data || true

Repository: jonaski/appimagetools

Length of output: 13645


Avoid claiming unconditional ALSA resolutiondata/apprun.sh only preloads libasound.so.2 from a fixed set of paths, so hosts that install ALSA elsewhere won’t get that guarantee.

🤖 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 `@README.md` at line 33, Update the ALSA entry in README.md to remove the
unconditional “always resolves” claim and accurately describe the behavior of
data/apprun.sh: libasound.so.2 is preloaded only from its configured fixed
paths, while other host installations may not be resolved by that mechanism.

Comment thread src/dependencywalker.h
Comment on lines +52 to +54
// Removes every already-registered ELF whose filename starts with `filename_prefix` from all_elfs(), so it is never copied into the AppDir. library_locations() is left untouched - a stale search directory is harmless. For libraries that must always be resolved against the running system rather than bundled (e.g. ALSA): once removed here, the dynamic linker falls through the AppDir rpath (now empty for this name) to the host's own copy at runtime, same as for any other unbundled system library.
void RemoveElfsByFilenamePrefix(const QString &filename_prefix);

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

Document the preload requirement. RemoveElfsByFilenamePrefix() only removes the bundled copy; it doesn’t guarantee host resolution. Update the comment to say AppRun must explicitly preload a compatible host library instead of implying generic dynamic-linker fallback.

🤖 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 `@src/dependencywalker.h` around lines 52 - 54, Update the documentation for
RemoveElfsByFilenamePrefix() to clarify that it only removes the bundled ELF and
does not guarantee host resolution. State that AppRun must explicitly preload a
compatible host library for libraries requiring system resolution, and remove
the implication that generic dynamic-linker fallback is sufficient.

Comment thread src/miscdeploy.h
Comment on lines +45 to 46
// Removes libasound.so* from the dependency set if present, so ALSA is always resolved against the running system's alsa-lib rather than bundled: its plugin modules, /usr/share/alsa config, and hardware UCM profiles are versioned together by the host and bundling them breaks device access on any host whose alsa-lib/UCM data doesn't exactly match the build host's (see miscdeploy.cpp for the failure mode this avoids).
void HandleAlsa(DependencyWalker &dependency_walker);

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:

#!/bin/bash
set -euo pipefail

printf '\n== files ==\n'
git ls-files | rg '(^|/)(src/miscdeploy\.h|src/miscdeploy\.cpp|README|readme|AppRun|app-run|desktop).*'

printf '\n== outline miscdeploy.h ==\n'
ast-grep outline src/miscdeploy.h --view expanded || true

printf '\n== outline miscdeploy.cpp ==\n'
ast-grep outline src/miscdeploy.cpp --view expanded || true

printf '\n== relevant text search ==\n'
rg -n --hidden -S 'HandleAlsa|libasound|ALSA|AppRun|preload|LD_LIBRARY_PATH|rpath|run.*system|bundled' src README* .github 2>/dev/null || true

Repository: jonaski/appimagetools

Length of output: 19964


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '1,140p' src/miscdeploy.h
printf '\n---\n'
sed -n '1,260p' src/miscdeploy.cpp

Repository: jonaski/appimagetools

Length of output: 15967


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show the exact implementation around ALSA handling.
sed -n '1,220p' src/miscdeploy.h
printf '\n--- miscdeploy.cpp ---\n'
sed -n '1,260p' src/miscdeploy.cpp

printf '\n--- matches for AppRun / library resolution ---\n'
rg -n -S 'AppRun|LD_LIBRARY_PATH|libasound|ALSA|HandleAlsa|dependency_walker|bundled' . --glob '!**/.git/**' --glob '!**/node_modules/**' || true

Repository: jonaski/appimagetools

Length of output: 43840


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '60,90p' data/apprun.sh
printf '\n---\n'
sed -n '28,38p' README.md

Repository: jonaski/appimagetools

Length of output: 3833


Qualify the ALSA runtime contract. HandleAlsa() only removes libasound.so*; AppRun still has to find and LD_PRELOAD a host libasound.so.2 from a fixed path list. Document that host-layout dependency, or broaden the lookup if “always” is meant literally.

🤖 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 `@src/miscdeploy.h` around lines 45 - 46, Update the ALSA runtime contract
around HandleAlsa so it explicitly documents that AppRun must locate and
LD_PRELOAD the host libasound.so.2 using the supported fixed path list, or
broaden that lookup to cover every intended host layout if the guarantee is
meant literally. Keep the dependency-walker behavior unchanged unless expanding
the lookup is required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants