@@ -3,14 +3,9 @@ import * as core from '@actions/core'
3
3
import * as tc from '@actions/tool-cache'
4
4
import { exec } from '../utils'
5
5
import { join } from 'path'
6
- import { homedir } from 'os'
7
- import { promises as fs } from 'fs'
8
6
9
- const MUSL_NAME = 'musl-gcc'
10
- const MUSL_VERSION = '1.2.4'
11
- const ZLIB_VERSION = '1.2.13'
12
-
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
7
+ const MUSL_NAME = 'x86_64-linux-musl-native'
8
+ const MUSL_VERSION = '10.2.1'
14
9
15
10
export async function setUpNativeImageMusl ( ) : Promise < void > {
16
11
if ( ! c . IS_LINUX ) {
@@ -19,55 +14,38 @@ export async function setUpNativeImageMusl(): Promise<void> {
19
14
}
20
15
let toolPath = tc . find ( MUSL_NAME , MUSL_VERSION )
21
16
if ( toolPath ) {
22
- core . info ( `Found musl ${ MUSL_VERSION } in tool-cache @ ${ toolPath } ` )
17
+ core . info ( `Found ${ MUSL_NAME } ${ MUSL_VERSION } in tool-cache @ ${ toolPath } ` )
23
18
} else {
24
- core . startGroup ( `Building musl with zlib for GraalVM Native Image...` )
25
- // Build musl
26
- const muslHome = join ( homedir ( ) , 'musl-toolchain' )
19
+ core . startGroup ( `Setting up musl for GraalVM Native Image...` )
27
20
const muslDownloadPath = await tc . downloadTool (
28
- `https://musl.libc.org/ releases/musl-${ MUSL_VERSION } .tar.gz `
21
+ `https://github.com/graalvm/setup-graalvm/ releases/download/x86_64-linux- musl-${ MUSL_VERSION } / ${ MUSL_NAME } .tgz `
29
22
)
30
23
const muslExtractPath = await tc . extractTar ( muslDownloadPath )
31
- const muslPath = join ( muslExtractPath , `musl-${ MUSL_VERSION } ` )
32
- const muslBuildOptions = { cwd : muslPath }
33
- await exec (
34
- './configure' ,
35
- [ `--prefix=${ muslHome } ` , '--static' ] ,
36
- muslBuildOptions
37
- )
38
- await exec ( 'make' , [ ] , muslBuildOptions )
39
- await exec ( 'make' , [ 'install' ] , muslBuildOptions )
40
- const muslGCC = join ( muslHome , 'bin' , MUSL_NAME )
41
- await fs . symlink (
42
- muslGCC ,
43
- join ( muslHome , 'bin' , 'x86_64-linux-musl-gcc' ) ,
44
- 'file'
45
- )
46
- // Build zlib
24
+ const muslPath = join ( muslExtractPath , MUSL_NAME )
25
+
26
+ const zlibCommit = 'ec3df00224d4b396e2ac6586ab5d25f673caa4c2'
47
27
const zlibDownloadPath = await tc . downloadTool (
48
- `https://zlib.net/fossils /zlib- ${ ZLIB_VERSION } .tar.gz`
28
+ `https://github.com/madler /zlib/archive/ ${ zlibCommit } .tar.gz`
49
29
)
50
30
const zlibExtractPath = await tc . extractTar ( zlibDownloadPath )
51
- const zlibPath = join ( zlibExtractPath , `zlib-${ ZLIB_VERSION } ` )
31
+ const zlibPath = join ( zlibExtractPath , `zlib-${ zlibCommit } ` )
52
32
const zlibBuildOptions = {
53
33
cwd : zlibPath ,
54
34
env : {
55
35
...process . env ,
56
- CC : muslGCC
36
+ CC : join ( muslPath , 'bin' , 'gcc' )
57
37
}
58
38
}
59
39
await exec (
60
40
'./configure' ,
61
- [ `--prefix=${ muslHome } ` , '--static' ] ,
41
+ [ `--prefix=${ muslPath } ` , '--static' ] ,
62
42
zlibBuildOptions
63
43
)
64
44
await exec ( 'make' , [ ] , zlibBuildOptions )
65
45
await exec ( 'make' , [ 'install' ] , { cwd : zlibPath } )
66
- // Store in cache
67
- core . info (
68
- `Adding musl ${ MUSL_VERSION } with zlib ${ ZLIB_VERSION } to tool-cache ...`
69
- )
70
- toolPath = await tc . cacheDir ( muslHome , MUSL_NAME , MUSL_VERSION )
46
+
47
+ core . info ( `Adding ${ MUSL_NAME } ${ MUSL_VERSION } to tool-cache ...` )
48
+ toolPath = await tc . cacheDir ( muslPath , MUSL_NAME , MUSL_VERSION )
71
49
core . endGroup ( )
72
50
}
73
51
core . addPath ( join ( toolPath , 'bin' ) )
0 commit comments