Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade musl and follow recommendation. #114

Merged
merged 4 commits into from
Oct 29, 2024
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
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
java-version: ['22', '21', '17', '20', 'dev']
java-version: ['23', '21', '17', '20', 'dev']
distribution: ['graalvm', 'graalvm-community']
os: [
ubuntu-latest,
macos-latest, # macOS on Apple silicon
macos-12, # macOS on Intel
macos-13, # macOS on Intel
windows-latest
]
set-gds-token: [false]
Expand All @@ -39,7 +39,7 @@ jobs:
- java-version: 'latest-ea'
distribution: 'graalvm'
os: ubuntu-latest
- java-version: '23-ea'
- java-version: '24-ea'
distribution: 'graalvm'
os: ubuntu-latest
- java-version: '21'
Expand Down Expand Up @@ -119,7 +119,7 @@ jobs:
- version: '22.3.1'
java-version: '11' # for JDK 11 notification
components: 'native-image'
os: macos-12
os: macos-13
- version: '22.3.1'
java-version: '17'
components: 'native-image'
Expand Down
2 changes: 1 addition & 1 deletion dist/cleanup/index.js

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

41 changes: 27 additions & 14 deletions dist/main/index.js

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

4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "setup-graalvm",
"version": "1.2.4",
"version": "1.2.5",
"private": true,
"description": "GitHub Action for GraalVM",
"main": "lib/main.js",
Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as otypes from '@octokit/types'

export const ACTION_VERSION = '1.2.4'
export const ACTION_VERSION = '1.2.5'

export const INPUT_VERSION = 'version'
export const INPUT_GDS_TOKEN = 'gds-token'
Expand Down
52 changes: 37 additions & 15 deletions src/features/musl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ import * as core from '@actions/core'
import * as tc from '@actions/tool-cache'
import {exec} from '../utils'
import {join} from 'path'
import {homedir} from 'os'
import {promises as fs} from 'fs'

const MUSL_NAME = 'x86_64-linux-musl-native'
fniephaus marked this conversation as resolved.
Show resolved Hide resolved
const MUSL_VERSION = '10.2.1'
const MUSL_NAME = 'musl-gcc'
const MUSL_VERSION = '1.2.4'
const ZLIB_VERSION = '1.2.13'

// Build instructions: https://github.com/oracle/graal/blob/6dab549194b85252f88bda4ee825762d8b02c687/docs/reference-manual/native-image/guides/build-static-and-mostly-static-executable.md?plain=1#L38-L67

export async function setUpNativeImageMusl(): Promise<void> {
if (!c.IS_LINUX) {
Expand All @@ -14,38 +19,55 @@ export async function setUpNativeImageMusl(): Promise<void> {
}
let toolPath = tc.find(MUSL_NAME, MUSL_VERSION)
if (toolPath) {
core.info(`Found ${MUSL_NAME} ${MUSL_VERSION} in tool-cache @ ${toolPath}`)
fniephaus marked this conversation as resolved.
Show resolved Hide resolved
core.info(`Found musl ${MUSL_VERSION} in tool-cache @ ${toolPath}`)
} else {
core.startGroup(`Setting up musl for GraalVM Native Image...`)
core.startGroup(`Building musl with zlib for GraalVM Native Image...`)
// Build musl
const muslHome = join(homedir(), 'musl-toolchain')
const muslDownloadPath = await tc.downloadTool(
`https://github.com/graalvm/setup-graalvm/releases/download/x86_64-linux-musl-${MUSL_VERSION}/${MUSL_NAME}.tgz`
`https://musl.libc.org/releases/musl-${MUSL_VERSION}.tar.gz`
)
const muslExtractPath = await tc.extractTar(muslDownloadPath)
const muslPath = join(muslExtractPath, MUSL_NAME)

const zlibCommit = 'ec3df00224d4b396e2ac6586ab5d25f673caa4c2'
const muslPath = join(muslExtractPath, `musl-${MUSL_VERSION}`)
const muslBuildOptions = {cwd: muslPath}
await exec(
'./configure',
[`--prefix=${muslHome}`, '--static'],
muslBuildOptions
)
await exec('make', [], muslBuildOptions)
await exec('make', ['install'], muslBuildOptions)
const muslGCC = join(muslHome, 'bin', MUSL_NAME)
await fs.symlink(
muslGCC,
join(muslHome, 'bin', 'x86_64-linux-musl-gcc'),
fniephaus marked this conversation as resolved.
Show resolved Hide resolved
'file'
)
// Build zlib
const zlibDownloadPath = await tc.downloadTool(
`https://github.com/madler/zlib/archive/${zlibCommit}.tar.gz`
`https://zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz`
)
const zlibExtractPath = await tc.extractTar(zlibDownloadPath)
const zlibPath = join(zlibExtractPath, `zlib-${zlibCommit}`)
const zlibPath = join(zlibExtractPath, `zlib-${ZLIB_VERSION}`)
const zlibBuildOptions = {
cwd: zlibPath,
env: {
...process.env,
CC: join(muslPath, 'bin', 'gcc')
CC: muslGCC
}
}
await exec(
'./configure',
[`--prefix=${muslPath}`, '--static'],
[`--prefix=${muslHome}`, '--static'],
zlibBuildOptions
)
await exec('make', [], zlibBuildOptions)
await exec('make', ['install'], {cwd: zlibPath})

core.info(`Adding ${MUSL_NAME} ${MUSL_VERSION} to tool-cache ...`)
toolPath = await tc.cacheDir(muslPath, MUSL_NAME, MUSL_VERSION)
// Store in cache
core.info(
`Adding musl ${MUSL_VERSION} with zlib ${ZLIB_VERSION} to tool-cache ...`
)
toolPath = await tc.cacheDir(muslHome, MUSL_NAME, MUSL_VERSION)
core.endGroup()
}
core.addPath(join(toolPath, 'bin'))
Expand Down
Loading