Skip to content

Commit 1675073

Browse files
authored
build(scripts/pack-next): Add support for compressing debuginfo with zlib (vercel#74662)
On Linux we must either compress or strip debuginfo, otherwise the debug tarball will be >2GiB, and pnpm (it's actually a node/libuv bug) has issues with files larger than 2GiB. As far as I can tell Rust can generate line numbers for backtraces with zlib-compressed debuginfo, but not with newer zstd-compressed debuginfo.
1 parent d0be1d2 commit 1675073

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

scripts/pack-next.cjs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,16 @@ async function main() {
101101
await packWithTar(packagePath, NEXT_SWC_TARBALL)
102102
break
103103
case 'objcopy-zstd':
104+
case 'objcopy-zlib':
104105
if (process.platform !== 'linux') {
105-
throw new Error('objcopy-zstd is only supported on Linux')
106+
throw new Error('objcopy-{zstd,zlib} is only supported on Linux')
106107
}
108+
const format = PACK_NEXT_COMPRESS == 'objcopy-zstd' ? 'zstd' : 'zlib'
107109
await Promise.all(
108110
(await nextSwcBinaries()).map((bin) =>
109111
execAsyncWithOutput(
110112
'Compressing debug symbols in next-swc native binary',
111-
['objcopy', '--compress-debug-sections=zstd', '--', bin]
113+
['objcopy', `--compress-debug-sections=${format}`, '--', bin]
112114
)
113115
)
114116
)
@@ -119,7 +121,8 @@ async function main() {
119121
break
120122
default:
121123
throw new Error(
122-
"PACK_NEXT_COMPRESS must be one of 'strip', 'objcopy-zstd', or 'none'"
124+
"PACK_NEXT_COMPRESS must be one of 'strip', 'objcopy-zstd', " +
125+
"'objcopy-zlib', or 'none'"
123126
)
124127
}
125128
}

0 commit comments

Comments
 (0)