forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch_loong64.patch
More file actions
547 lines (542 loc) · 18.3 KB
/
Copy pathpatch_loong64.patch
File metadata and controls
547 lines (542 loc) · 18.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
diff --git a/.cargo/config.toml b/.cargo/config.toml
index a20e20d2..1379d22f 100644
--- a/.cargo/config.toml
+++ b/.cargo/config.toml
@@ -58,6 +58,18 @@ rustflags = [
"-Clink-arg=-lgcc",
]
+[target.loongarch64-unknown-linux-musl]
+linker = "loongarch64-linux-musl-gcc"
+# Config need to be mirrowed to .github/workflows/build_and_deploy.yml
+rustflags = [
+ "--cfg",
+ "tokio_unstable",
+ "-Zshare-generics=y",
+ "-Csymbol-mangling-version=v0",
+ "-Ctarget-feature=-crt-static",
+ "-Clink-arg=-lgcc",
+]
+
[target.x86_64-unknown-linux-musl]
# Config need to be mirrowed to .github/workflows/build_and_deploy.yml
rustflags = [
diff --git a/crates/next-napi-bindings/npm/darwin-arm64/README.md b/crates/next-napi-bindings/npm/darwin-arm64/README.md
deleted file mode 100644
index 10a0ca93..00000000
--- a/crates/next-napi-bindings/npm/darwin-arm64/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# `@next/swc-darwin-arm64`
-
-This is the **aarch64-apple-darwin** binary for `@next/swc`
diff --git a/crates/next-napi-bindings/npm/darwin-arm64/package.json b/crates/next-napi-bindings/npm/darwin-arm64/package.json
deleted file mode 100644
index aa2782e9..00000000
--- a/crates/next-napi-bindings/npm/darwin-arm64/package.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "name": "@next/swc-darwin-arm64",
- "version": "0.0.0",
- "repository": {
- "type": "git",
- "url": "https://github.com/vercel/next.js",
- "directory": "crates/next-napi-bindings/npm/darwin-arm64"
- },
- "os": [
- "darwin"
- ],
- "cpu": [
- "arm64"
- ],
- "main": "next-swc.darwin-arm64.node",
- "files": [
- "next-swc.darwin-arm64.node"
- ],
- "license": "MIT",
- "engines": {
- "node": ">= 10"
- }
-}
diff --git a/crates/next-napi-bindings/npm/darwin-x64/README.md b/crates/next-napi-bindings/npm/darwin-x64/README.md
deleted file mode 100644
index a0d630dd..00000000
--- a/crates/next-napi-bindings/npm/darwin-x64/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# `@next/swc-darwin-x64`
-
-This is the **x86_64-apple-darwin** binary for `@next/swc`
diff --git a/crates/next-napi-bindings/npm/darwin-x64/package.json b/crates/next-napi-bindings/npm/darwin-x64/package.json
deleted file mode 100644
index b5fdcf58..00000000
--- a/crates/next-napi-bindings/npm/darwin-x64/package.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "name": "@next/swc-darwin-x64",
- "version": "0.0.0",
- "repository": {
- "type": "git",
- "url": "https://github.com/vercel/next.js",
- "directory": "crates/next-napi-bindings/npm/darwin-x64"
- },
- "os": [
- "darwin"
- ],
- "cpu": [
- "x64"
- ],
- "main": "next-swc.darwin-x64.node",
- "files": [
- "next-swc.darwin-x64.node"
- ],
- "license": "MIT",
- "engines": {
- "node": ">= 10"
- }
-}
diff --git a/crates/next-napi-bindings/npm/linux-loong64-gnu/README.md b/crates/next-napi-bindings/npm/linux-loong64-gnu/README.md
new file mode 100644
index 00000000..bc707ec2
--- /dev/null
+++ b/crates/next-napi-bindings/npm/linux-loong64-gnu/README.md
@@ -0,0 +1,3 @@
+# `@next/swc-linux-loong64-gnu`
+
+This is the **linux-loong64-gnu** binary for `@next/swc`
diff --git a/crates/next-napi-bindings/npm/linux-loong64-gnu/package.json b/crates/next-napi-bindings/npm/linux-loong64-gnu/package.json
new file mode 100644
index 00000000..c4ff7eb7
--- /dev/null
+++ b/crates/next-napi-bindings/npm/linux-loong64-gnu/package.json
@@ -0,0 +1,26 @@
+{
+ "name": "@next/swc-linux-loong64-gnu",
+ "version": "0.0.0",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/vercel/next.js",
+ "directory": "crates/next-napi-bindings/npm/linux-loong64-gnu"
+ },
+ "os": [
+ "linux"
+ ],
+ "cpu": [
+ "loong64"
+ ],
+ "libc": [
+ "glibc"
+ ],
+ "main": "next-swc.linux-loong64-gnu.node",
+ "files": [
+ "next-swc.linux-loong64-gnu.node"
+ ],
+ "license": "MIT",
+ "engines": {
+ "node": ">= 10"
+ }
+}
diff --git a/crates/next-napi-bindings/npm/linux-loong64-musl/README.md b/crates/next-napi-bindings/npm/linux-loong64-musl/README.md
new file mode 100644
index 00000000..8148b0c2
--- /dev/null
+++ b/crates/next-napi-bindings/npm/linux-loong64-musl/README.md
@@ -0,0 +1,3 @@
+# `@next/swc-linux-loong64-musl`
+
+This is the **linux-loong64-musl** binary for `@next/swc`
diff --git a/crates/next-napi-bindings/npm/linux-loong64-musl/package.json b/crates/next-napi-bindings/npm/linux-loong64-musl/package.json
new file mode 100644
index 00000000..e3e88e9d
--- /dev/null
+++ b/crates/next-napi-bindings/npm/linux-loong64-musl/package.json
@@ -0,0 +1,26 @@
+{
+ "name": "@next/swc-linux-loong64-musl",
+ "version": "0.0.0",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/vercel/next.js",
+ "directory": "crates/next-napi-bindings/npm/linux-loong64-musl"
+ },
+ "os": [
+ "linux"
+ ],
+ "cpu": [
+ "loong64"
+ ],
+ "libc": [
+ "musl"
+ ],
+ "main": "next-swc.linux-loong64-musl.node",
+ "files": [
+ "next-swc.linux-loong64-musl.node"
+ ],
+ "license": "MIT",
+ "engines": {
+ "node": ">= 10"
+ }
+}
diff --git a/crates/next-napi-bindings/npm/win32-arm64-msvc/README.md b/crates/next-napi-bindings/npm/win32-arm64-msvc/README.md
deleted file mode 100644
index 0b52c876..00000000
--- a/crates/next-napi-bindings/npm/win32-arm64-msvc/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# `@next/swc-win32-arm64-msvc`
-
-This is the **win32-arm64-msvc** binary for `@next/swc`
diff --git a/crates/next-napi-bindings/npm/win32-arm64-msvc/package.json b/crates/next-napi-bindings/npm/win32-arm64-msvc/package.json
deleted file mode 100644
index 29727176..00000000
--- a/crates/next-napi-bindings/npm/win32-arm64-msvc/package.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "name": "@next/swc-win32-arm64-msvc",
- "version": "0.0.0",
- "repository": {
- "type": "git",
- "url": "https://github.com/vercel/next.js",
- "directory": "crates/next-napi-bindings/npm/win32-arm64-msvc"
- },
- "os": [
- "win32"
- ],
- "cpu": [
- "arm64"
- ],
- "main": "next-swc.win32-arm64-msvc.node",
- "files": [
- "next-swc.win32-arm64-msvc.node"
- ],
- "license": "MIT",
- "engines": {
- "node": ">= 10"
- }
-}
diff --git a/crates/next-napi-bindings/npm/win32-x64-msvc/README.md b/crates/next-napi-bindings/npm/win32-x64-msvc/README.md
deleted file mode 100644
index 04e5bcab..00000000
--- a/crates/next-napi-bindings/npm/win32-x64-msvc/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# `@next/swc-win32-x64-msvc`
-
-This is the **x86_64-pc-windows-msvc** binary for `@next/swc`
diff --git a/crates/next-napi-bindings/npm/win32-x64-msvc/package.json b/crates/next-napi-bindings/npm/win32-x64-msvc/package.json
deleted file mode 100644
index d05f6e1c..00000000
--- a/crates/next-napi-bindings/npm/win32-x64-msvc/package.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "name": "@next/swc-win32-x64-msvc",
- "version": "0.0.0",
- "repository": {
- "type": "git",
- "url": "https://github.com/vercel/next.js",
- "directory": "crates/next-napi-bindings/npm/win32-x64-msvc"
- },
- "os": [
- "win32"
- ],
- "cpu": [
- "x64"
- ],
- "main": "next-swc.win32-x64-msvc.node",
- "files": [
- "next-swc.win32-x64-msvc.node"
- ],
- "license": "MIT",
- "engines": {
- "node": ">= 10"
- }
-}
diff --git a/packages/next-swc/package.json b/packages/next-swc/package.json
index a4fda628..c479d785 100644
--- a/packages/next-swc/package.json
+++ b/packages/next-swc/package.json
@@ -27,12 +27,12 @@
"triples": {
"defaults": true,
"additional": [
- "i686-pc-windows-msvc",
"aarch64-unknown-linux-gnu",
- "aarch64-apple-darwin",
- "x86_64-unknown-linux-musl",
"aarch64-unknown-linux-musl",
- "aarch64-pc-windows-msvc",
+ "loongarch64-unknown-linux-gnu",
+ "loongarch64-unknown-linux-musl",
+ "x86_64-unknown-linux-gnu",
+ "x86_64-unknown-linux-musl",
"wasm32-wasip1-threads"
]
}
diff --git a/packages/next/src/build/swc/index.ts b/packages/next/src/build/swc/index.ts
index 7e00ba74..81877a42 100644
--- a/packages/next/src/build/swc/index.ts
+++ b/packages/next/src/build/swc/index.ts
@@ -69,6 +69,22 @@ function infoLog(...args: any[]) {
* Based on napi-rs's target triples, returns triples that have corresponding next-swc binaries.
*/
export function getSupportedArchTriples(): Record<string, any> {
+ (platformArchTriples.linux as any).loong64 = [
+ {
+ platform: 'linux',
+ arch: 'loong64',
+ abi: 'musl',
+ platformArchABI: 'linux-loong64-musl',
+ raw: 'loongarch64-unknown-linux-musl',
+ },
+ {
+ platform: 'linux',
+ arch: 'loong64',
+ abi: 'gnu',
+ platformArchABI: 'linux-loong64-gnu',
+ raw: 'loongarch64-unknown-linux-gnu',
+ },
+ ];
const { darwin, win32, linux, freebsd, android } = platformArchTriples
return {
@@ -84,6 +100,7 @@ export function getSupportedArchTriples(): Record<string, any> {
arm64: linux.arm64,
// This target is being deprecated, however we keep it in `knownDefaultWasmFallbackTriples` for now
arm: linux.arm,
+ loong64: linux.loong64,
},
// Below targets are being deprecated, however we keep it in `knownDefaultWasmFallbackTriples` for now
freebsd: {
diff --git a/packages/next/src/build/webpack/plugins/telemetry-plugin/telemetry-plugin.ts b/packages/next/src/build/webpack/plugins/telemetry-plugin/telemetry-plugin.ts
index 95584eb2..2a4e12ed 100644
--- a/packages/next/src/build/webpack/plugins/telemetry-plugin/telemetry-plugin.ts
+++ b/packages/next/src/build/webpack/plugins/telemetry-plugin/telemetry-plugin.ts
@@ -17,10 +17,12 @@ export type SWC_TARGET_TRIPLE =
| 'aarch64-apple-darwin'
| 'aarch64-linux-android'
| 'arm-linux-androideabi'
+ | 'loongarch64-unknown-linux-gnu'
| 'x86_64-unknown-freebsd'
| 'x86_64-unknown-linux-musl'
| 'aarch64-unknown-linux-musl'
| 'aarch64-pc-windows-msvc'
+ | 'loongarch64-unknown-linux-musl'
export type Feature =
| 'next/image'
@@ -95,10 +97,12 @@ const BUILD_FEATURES: Array<Feature> = [
'swc/target/aarch64-apple-darwin',
'swc/target/aarch64-linux-android',
'swc/target/arm-linux-androideabi',
+ 'swc/target/loongarch64-unknown-linux-gnu',
'swc/target/x86_64-unknown-freebsd',
'swc/target/x86_64-unknown-linux-musl',
'swc/target/aarch64-unknown-linux-musl',
'swc/target/aarch64-pc-windows-msvc',
+ 'swc/target/loongarch64-unknown-linux-musl',
'turbotrace',
'transpilePackages',
'skipProxyUrlNormalize',
diff --git a/packages/next/src/cli/next-info.ts b/packages/next/src/cli/next-info.ts
index b04a5137..c974fdb7 100755
--- a/packages/next/src/cli/next-info.ts
+++ b/packages/next/src/cli/next-info.ts
@@ -391,6 +391,22 @@ async function printVerboseInfo() {
const { platformArchTriples } =
require('next/dist/compiled/@napi-rs/triples') as typeof import('next/dist/compiled/@napi-rs/triples')
+ (platformArchTriples.linux as any).loong64 = [
+ {
+ platform: 'linux',
+ arch: 'loong64',
+ abi: 'musl',
+ platformArchABI: 'linux-loong64-musl',
+ raw: 'loongarch64-unknown-linux-musl',
+ },
+ {
+ platform: 'linux',
+ arch: 'loong64',
+ abi: 'gnu',
+ platformArchABI: 'linux-loong64-gnu',
+ raw: 'loongarch64-unknown-linux-gnu',
+ },
+ ];
const triples = platformArchTriples[currentPlatform]?.[os.arch()]
if (!triples || triples.length === 0) {
diff --git a/rspack/crates/binding/index.js b/rspack/crates/binding/index.js
index 0973817c..cf33a806 100644
--- a/rspack/crates/binding/index.js
+++ b/rspack/crates/binding/index.js
@@ -278,6 +278,30 @@ function requireNative() {
loadErrors.push(e)
}
}
+ } else if (process.arch === 'loong64') {
+ if (isMusl()) {
+ try {
+ return require('./binding.linux-loong64-musl.node')
+ } catch (e) {
+ loadErrors.push(e)
+ }
+ try {
+ return require('@next/rspack-binding-linux-loong64-musl')
+ } catch (e) {
+ loadErrors.push(e)
+ }
+ } else {
+ try {
+ return require('./binding.linux-loong64-gnu.node')
+ } catch (e) {
+ loadErrors.push(e)
+ }
+ try {
+ return require('@next/rspack-binding-linux-loong64-gnu')
+ } catch (e) {
+ loadErrors.push(e)
+ }
+ }
} else if (process.arch === 'riscv64') {
if (isMusl()) {
try {
diff --git a/scripts/install-native.mjs b/scripts/install-native.mjs
index d1854530..adc00eb7 100644
--- a/scripts/install-native.mjs
+++ b/scripts/install-native.mjs
@@ -50,6 +50,8 @@ import fsp from 'fs/promises'
'@next/swc-darwin-x64': nextVersion,
'@next/swc-linux-arm64-gnu': nextVersion,
'@next/swc-linux-arm64-musl': nextVersion,
+ '@next/swc-linux-loong64-gnu': nextVersion,
+ '@next/swc-linux-loong64-musl': nextVersion,
'@next/swc-linux-x64-gnu': nextVersion,
'@next/swc-linux-x64-musl': nextVersion,
'@next/swc-win32-arm64-msvc': nextVersion,
diff --git a/scripts/publish-native.js b/scripts/publish-native.js
index 9d4dafbc..2d4aca76 100755
--- a/scripts/publish-native.js
+++ b/scripts/publish-native.js
@@ -43,7 +43,7 @@ const cwd = process.cwd()
const child = execa(
`npm`,
[
- `publish`,
+ `pack`,
`${path.join(nativePackagesDir, platform)}`,
`--access`,
`public`,
@@ -101,7 +101,7 @@ const cwd = process.cwd()
await execa(
`npm`,
[
- 'publish',
+ 'pack',
`${path.join(wasmDir, `pkg-${wasmTarget}`)}`,
'--access',
'public',
diff --git a/scripts/publish-release.js b/scripts/publish-release.js
index c33f6e0c..471b2999 100755
--- a/scripts/publish-release.js
+++ b/scripts/publish-release.js
@@ -86,7 +86,7 @@ const cwd = process.cwd()
const child = execa(
`npm`,
[
- 'publish',
+ 'pack',
`${path.join(packagesDir, pkg)}`,
'--access',
'public',
diff --git a/turbopack/crates/turbopack-core/src/target.rs b/turbopack/crates/turbopack-core/src/target.rs
index b70090fa..845321a6 100644
--- a/turbopack/crates/turbopack-core/src/target.rs
+++ b/turbopack/crates/turbopack-core/src/target.rs
@@ -99,6 +99,10 @@ impl CompileTarget {
{
return Arch::Arm64;
}
+ #[cfg(target_arch = "loongarch64")]
+ {
+ return Arch::Loong64;
+ }
#[cfg(target_arch = "mips")]
{
return Arch::Mips;
@@ -180,6 +184,7 @@ pub enum Arch {
Arm,
Arm64,
Ia32,
+ Loong64,
Mips,
Mipsel,
Ppc,
@@ -196,6 +201,7 @@ impl Arch {
Self::Arm => "arm",
Self::Arm64 => "arm64",
Self::Ia32 => "ia32",
+ Self::Loong64 => "loong64",
Self::Mips => "mips",
Self::Mipsel => "mipsel",
Self::Ppc => "ppc",
diff --git a/turbopack/crates/turbopack-ecmascript/tests/analyzer/graph/esbuild/graph-explained.snapshot b/turbopack/crates/turbopack-ecmascript/tests/analyzer/graph/esbuild/graph-explained.snapshot
index 05b20218..7fe0c1af 100644
--- a/turbopack/crates/turbopack-ecmascript/tests/analyzer/graph/esbuild/graph-explained.snapshot
+++ b/turbopack/crates/turbopack-ecmascript/tests/analyzer/graph/esbuild/graph-explained.snapshot
@@ -47,6 +47,7 @@ knownUnixlikePackages (const after eval) = {
"linux arm LE": "esbuild-linux-arm",
"linux arm64 LE": "esbuild-linux-arm64",
"linux ia32 LE": "esbuild-linux-32",
+ "linux loong64 LE": "esbuild-linux-loong64",
"linux mips64el LE": "esbuild-linux-mips64le",
"linux ppc64 LE": "esbuild-linux-ppc64le",
"linux s390x BE": "esbuild-linux-s390x",
diff --git a/turbopack/crates/turbopack-ecmascript/tests/analyzer/graph/esbuild/graph.snapshot b/turbopack/crates/turbopack-ecmascript/tests/analyzer/graph/esbuild/graph.snapshot
index 29a55d0c..87222e70 100644
--- a/turbopack/crates/turbopack-ecmascript/tests/analyzer/graph/esbuild/graph.snapshot
+++ b/turbopack/crates/turbopack-ecmascript/tests/analyzer/graph/esbuild/graph.snapshot
@@ -558,6 +558,22 @@
),
),
),
+ KeyValue(
+ Constant(
+ Str(
+ Atom(
+ "linux loong64 LE",
+ ),
+ ),
+ ),
+ Constant(
+ Str(
+ Atom(
+ "esbuild-linux-loong64",
+ ),
+ ),
+ ),
+ ),
KeyValue(
Constant(
Str(
diff --git a/turbopack/crates/turbopack-ecmascript/tests/analyzer/graph/esbuild/input.js b/turbopack/crates/turbopack-ecmascript/tests/analyzer/graph/esbuild/input.js
index bdd1e511..375605b1 100644
--- a/turbopack/crates/turbopack-ecmascript/tests/analyzer/graph/esbuild/input.js
+++ b/turbopack/crates/turbopack-ecmascript/tests/analyzer/graph/esbuild/input.js
@@ -16,6 +16,7 @@ var knownUnixlikePackages = {
"linux arm LE": "esbuild-linux-arm",
"linux arm64 LE": "esbuild-linux-arm64",
"linux ia32 LE": "esbuild-linux-32",
+ "linux loong64 LE": "esbuild-linux-loong64",
"linux mips64el LE": "esbuild-linux-mips64le",
"linux ppc64 LE": "esbuild-linux-ppc64le",
"linux s390x BE": "esbuild-linux-s390x",
diff --git a/turbopack/crates/turbopack-ecmascript/tests/analyzer/graph/esbuild/resolved-explained.snapshot b/turbopack/crates/turbopack-ecmascript/tests/analyzer/graph/esbuild/resolved-explained.snapshot
index 30fd8dec..ce700d64 100644
--- a/turbopack/crates/turbopack-ecmascript/tests/analyzer/graph/esbuild/resolved-explained.snapshot
+++ b/turbopack/crates/turbopack-ecmascript/tests/analyzer/graph/esbuild/resolved-explained.snapshot
@@ -138,6 +138,7 @@ knownUnixlikePackages = {
"linux arm LE": "esbuild-linux-arm",
"linux arm64 LE": "esbuild-linux-arm64",
"linux ia32 LE": "esbuild-linux-32",
+ "linux loong64 LE": "esbuild-linux-loong64",
"linux mips64el LE": "esbuild-linux-mips64le",
"linux ppc64 LE": "esbuild-linux-ppc64le",
"linux s390x BE": "esbuild-linux-s390x",