Skip to content
Open
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
34 changes: 34 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions lib/installer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,21 @@ export async function installTool(
os: OS,
arch: Arch
): Promise<void> {
// GHC < 9.6 bindists ship an hsc2hs wrapper with a hardcoded
// "--lflag=-fuse-ld=gold", so ld.gold has to be present whenever hsc2hs
// runs, even if GHC itself is already installed (preinstalled or cached).
// Hence, do this before the isInstalled check.
// “version” may not be a semantic version (e.g. “latest-nightly”),
// so guard “compareVersions” with “validate”.
if (
os === 'linux' &&
tool === 'ghc' &&
validate(version) &&
compareVersions(version, '9.6') < 0 // meaning version < 9.6
) {
await aptBinutilsGold();
}

if (await isInstalled(tool, version, os, arch)) return;
warn(tool, version);

Expand Down Expand Up @@ -281,6 +296,35 @@ async function aptBuildEssential(): Promise<boolean> {
return returnCode === 0;
}

async function aptBinutilsGold(): Promise<boolean> {
// Up to ubuntu-24.04, ld.gold is part of binutils. Since binutils 2.44
// deprecated gold, ubuntu-25.10 and later ship it in a separate
// binutils-gold package instead.
if (await which('ld.gold', false)) {
core.debug('ld.gold is already installed');
return true;
}
if (!(await which('apt-get', false))) {
core.warning(
'ld.gold not found and apt-get is unavailable; hsc2hs of ghc < 9.6 may fail to link'
);
return false;
}

core.info(`Installing binutils-gold using apt-get (for ghc < 9.6)`);
// exec throws (instead of returning non-zero) if e.g. sudo is not
// available; this must not fail the action, as hsc2hs may not be needed.
const returnCode = await exec(
`sudo -- sh -c "apt-get update && apt-get -y install binutils-gold"`
).catch(() => -1);
if (returnCode !== 0) {
core.warning(
'Failed to install binutils-gold; hsc2hs of ghc < 9.6 may fail to link'
);
}
return returnCode === 0;
}

async function aptLibNCurses5(): Promise<boolean> {
core.info(
`Installing libcurses5 and libtinfo5 using apt-get (for ghc < 8.3)`
Expand Down
Loading