Skip to content
This repository was archived by the owner on Nov 19, 2025. It is now read-only.

Commit 98fbbe2

Browse files
Merge branch 'master' into upgrade-yarn
# Conflicts: # .github/workflows/build.yml
2 parents 203fb35 + c3cbd58 commit 98fbbe2

File tree

3 files changed

+104
-68
lines changed

3 files changed

+104
-68
lines changed

.github/workflows/build.yml

Lines changed: 64 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ jobs:
3939
disk-cache: ${{ github.workflow }}
4040
# Share repository cache between workflows.
4141
repository-cache: true
42-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
42+
- name: Checkout repo
43+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
4344
with:
4445
submodules: recursive
4546
ref: ${{ inputs.release-tag || '' }}
@@ -84,25 +85,59 @@ jobs:
8485
env:
8586
NODE_VERSION: '20.x'
8687
FORCE_COLOR: '1'
88+
MUSL_HOME: ${{ github.workspace }}/musl-toolchain
8789
steps:
88-
- name: Setup Java
89-
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
90-
with:
91-
distribution: adopt-hotspot
92-
java-version: 21
93-
java-package: jdk
94-
architecture: x64
95-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
90+
- name: Checkout repo
91+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
9692
with:
9793
ref: ${{ inputs.release-tag || '' }}
94+
- name: Checkout musl
95+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
96+
with:
97+
repository: kraj/musl
98+
ref: c47ad25ea3b484e10326f933e927c0bc8cded3da # patched 1.2.5 version
99+
path: musl
100+
clean: false
101+
- name: Checkout zlib
102+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
103+
with:
104+
repository: madler/zlib
105+
ref: 04f42ceca40f73e2978b50e93806c2a18c1281fc # v1.2.13
106+
path: zlib
107+
clean: false
108+
- name: Build musl and zlib
109+
run: |
110+
# See https://www.graalvm.org/latest/reference-manual/native-image/guides/build-static-executables/
111+
# We have to build MUSL from source to ensure recent CVEs are patched
112+
113+
# Build musl from source
114+
pushd musl
115+
./configure --prefix=$MUSL_HOME --static
116+
sudo make && make install
117+
popd
118+
119+
# Install a symlink for use by native-image
120+
ln -s $MUSL_HOME/bin/musl-gcc $MUSL_HOME/bin/x86_64-linux-musl-gcc
121+
122+
# Extend the system path and confirm that musl is available by printing its version
123+
export PATH="$MUSL_HOME/bin:$PATH"
124+
echo "$path" >> $GITHUB_PATH
125+
x86_64-linux-musl-gcc --version
126+
127+
# Build zlib with musl from source and install into the MUSL_HOME directory
128+
pushd zlib
129+
CC=musl-gcc ./configure --prefix=$MUSL_HOME --static
130+
make && make install
131+
popd
98132
- name: Use Node.js ${{ env.NODE_VERSION }}
99133
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # 4.4.0
100134
with:
101135
node-version: ${{ env.NODE_VERSION }}
102136
cache: yarn
103-
- uses: graalvm/setup-graalvm@01ed653ac833fe80569f1ef9f25585ba2811baab # 1.3.3
137+
- name: Install GraalVM
138+
uses: graalvm/setup-graalvm@01ed653ac833fe80569f1ef9f25585ba2811baab # 1.3.3
104139
with:
105-
java-version: 21
140+
java-version: 24
106141
distribution: 'graalvm-community'
107142
github-token: ${{ secrets.GITHUB_TOKEN }}
108143
native-image-job-reports: 'true'
@@ -126,6 +161,7 @@ jobs:
126161
- name: Build image
127162
working-directory: packages/google-closure-compiler-linux
128163
run: |
164+
export PATH="$MUSL_HOME/bin:$PATH"
129165
cp ../google-closure-compiler-java/compiler.jar compiler.jar
130166
yarn run build
131167
- name: Tests
@@ -147,24 +183,19 @@ jobs:
147183
NODE_VERSION: '20.x'
148184
FORCE_COLOR: '1'
149185
steps:
150-
- name: Setup Java
151-
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
152-
with:
153-
distribution: adopt-hotspot
154-
java-version: 21
155-
java-package: jdk
156-
architecture: x64
157-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
186+
- name: Checkout repo
187+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
158188
with:
159189
ref: ${{ inputs.release-tag || '' }}
160190
- name: Use Node.js ${{ env.NODE_VERSION }}
161191
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # 4.4.0
162192
with:
163193
node-version: ${{ env.NODE_VERSION }}
164194
cache: yarn
165-
- uses: graalvm/setup-graalvm@01ed653ac833fe80569f1ef9f25585ba2811baab # 1.3.3
195+
- name: Setup GraalVM
196+
uses: graalvm/setup-graalvm@01ed653ac833fe80569f1ef9f25585ba2811baab # 1.3.3
166197
with:
167-
java-version: 21
198+
java-version: 24
168199
distribution: 'graalvm-community'
169200
github-token: ${{ secrets.GITHUB_TOKEN }}
170201
native-image-job-reports: 'true'
@@ -207,24 +238,19 @@ jobs:
207238
NODE_VERSION: '22.x'
208239
FORCE_COLOR: '1'
209240
steps:
210-
- name: Setup Java
211-
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
212-
with:
213-
distribution: adopt-hotspot
214-
java-version: 21
215-
java-package: jdk
216-
architecture: x64
217-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
241+
- name: Checkout repo
242+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
218243
with:
219244
ref: ${{ inputs.release-tag || '' }}
220245
- name: Use Node.js ${{ env.NODE_VERSION }}
221246
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # 4.4.0
222247
with:
223248
node-version: ${{ env.NODE_VERSION }}
224249
cache: yarn
225-
- uses: graalvm/setup-graalvm@01ed653ac833fe80569f1ef9f25585ba2811baab # 1.3.3
250+
- name: Setup GraalVM
251+
uses: graalvm/setup-graalvm@01ed653ac833fe80569f1ef9f25585ba2811baab # 1.3.3
226252
with:
227-
java-version: 21
253+
java-version: 24
228254
distribution: 'graalvm-community'
229255
github-token: ${{ secrets.GITHUB_TOKEN }}
230256
native-image-job-reports: 'true'
@@ -267,24 +293,19 @@ jobs:
267293
NODE_VERSION: '22.x'
268294
FORCE_COLOR: '1'
269295
steps:
270-
- name: Setup Java
271-
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
272-
with:
273-
distribution: adopt-hotspot
274-
java-version: 21
275-
java-package: jdk
276-
architecture: x64
277-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
296+
- name: Checkout repo
297+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
278298
with:
279299
ref: ${{ inputs.release-tag || '' }}
280300
- name: Use Node.js ${{ env.NODE_VERSION }}
281301
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # 4.4.0
282302
with:
283303
node-version: ${{ env.NODE_VERSION }}
284304
cache: yarn
285-
- uses: graalvm/setup-graalvm@01ed653ac833fe80569f1ef9f25585ba2811baab # 1.3.3
305+
- name: Setup GraalVM
306+
uses: graalvm/setup-graalvm@01ed653ac833fe80569f1ef9f25585ba2811baab # 1.3.3
286307
with:
287-
java-version: 21
308+
java-version: 24
288309
distribution: 'graalvm-community'
289310
github-token: ${{ secrets.GITHUB_TOKEN }}
290311
native-image-job-reports: 'true'
@@ -334,7 +355,8 @@ jobs:
334355
- build-macos
335356
- build-windows
336357
steps:
337-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
358+
- name: Checkout repo
359+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
338360
with:
339361
ref: ${{ inputs.release-tag || '' }}
340362
- name: Use Node.js ${{ env.NODE_VERSION }}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ node_modules
22
npm-debug.log
33
yarn-error.log
44
/lerna-debug.log
5+
/musl-toolchain
56
/packages/google-closure-compiler/contrib/
67
/packages/google-closure-compiler/externs/
78
/packages/google-closure-compiler-java/compiler.jar
@@ -12,8 +13,9 @@ yarn-error.log
1213
/packages/google-closure-compiler-macos/compiler.jar
1314
/packages/google-closure-compiler-macos/compiler
1415
/packages/google-closure-compiler-windows/compiler.*
15-
/temp
1616
/publish-log.txt
17+
/temp
18+
/zlib
1719
.npmrc
1820
.pnp.*
1921
.yarn/*

build-scripts/graal.js

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,32 +34,44 @@ process.on('unhandledRejection', error => {
3434
process.exit(1);
3535
});
3636

37-
const NATIVE_IMAGE_BUILD_ARGS = [
38-
'-H:+UnlockExperimentalVMOptions',
39-
'-H:IncludeResourceBundles=org.kohsuke.args4j.Messages',
40-
'-H:IncludeResourceBundles=org.kohsuke.args4j.spi.Messages',
41-
'-H:IncludeResourceBundles=com.google.javascript.jscomp.parsing.ParserConfig',
42-
'-H:+AllowIncompleteClasspath',
43-
`-H:ReflectionConfigurationFiles=${path.resolve(__dirname, 'reflection-config.json')}`,
44-
'-H:IncludeResources=externs\.zip',
45-
'-H:IncludeResources=.*\.typedast',
46-
'-H:IncludeResources=com/google/javascript/.*\.js',
47-
'-H:IncludeResources=com/google/javascript/.*\.txt',
48-
'-H:IncludeResources=lib/.*\.js',
49-
'-H:IncludeResources=META-INF/.*\.txt',
50-
'-H:+ReportExceptionStackTraces',
51-
// '-H:+GenerateEmbeddedResourcesFile', // Available on Graal JDK 24 and newer
52-
'--report-unsupported-elements-at-runtime',
53-
'--initialize-at-build-time',
54-
'--color=always',
55-
'-jar',
56-
path.resolve(process.cwd(), 'compiler.jar')
57-
];
37+
const flagsByPlatformAndArch = new Map([
38+
// Statically link libraries when supported. Allows usage on systems
39+
// which are missing or have incompatible versions of GLIBC.
40+
// Only linux x86 architectures can fully statically link
41+
// See https://www.graalvm.org/latest/reference-manual/native-image/guides/build-static-executables/
42+
['linux-x86', ['--static', '--libc=musl']],
43+
['linux-x64', ['--static', '--libc=musl']],
44+
['linux-arm64', ['--static-nolibc']],
45+
]);
5846

59-
const spawnOpts = {};
60-
if (process.platform === 'win32') {
61-
spawnOpts.shell = true;
62-
}
47+
const NATIVE_IMAGE_BUILD_ARGS = ['-H:+UnlockExperimentalVMOptions'].concat(
48+
flagsByPlatformAndArch.get(`${process.platform}-${process.arch}`) || [],
49+
[
50+
'-H:IncludeResourceBundles=org.kohsuke.args4j.Messages',
51+
'-H:IncludeResourceBundles=org.kohsuke.args4j.spi.Messages',
52+
'-H:IncludeResourceBundles=com.google.javascript.jscomp.parsing.ParserConfig',
53+
'-H:+AllowIncompleteClasspath',
54+
`-H:ReflectionConfigurationFiles=${path.resolve(__dirname, 'reflection-config.json')}`,
55+
'-H:IncludeResources=externs\.zip',
56+
'-H:IncludeResources=.*\.typedast',
57+
'-H:IncludeResources=com/google/javascript/.*\.js',
58+
'-H:IncludeResources=com/google/javascript/.*\.txt',
59+
'-H:IncludeResources=lib/.*\.js',
60+
'-H:IncludeResources=META-INF/.*\.txt',
61+
'-H:+ReportExceptionStackTraces',
62+
// '-H:+GenerateEmbeddedResourcesFile',
63+
'-J--sun-misc-unsafe-memory-access=allow', // See https://github.com/google/closure-compiler/issues/4229
64+
'--initialize-at-build-time',
65+
'-march=compatibility',
66+
'--color=always',
67+
'-jar',
68+
path.resolve(process.cwd(), 'compiler.jar'),
69+
],
70+
);
71+
72+
const spawnOpts = {
73+
...(process.platform === 'win32' ? { shell: true } : {}),
74+
};
6375

6476
runCommand(`native-image${process.platform === 'win32' ? '.cmd' : ''}`, NATIVE_IMAGE_BUILD_ARGS, spawnOpts)
6577
.catch(e => {

0 commit comments

Comments
 (0)