Skip to content

Commit 80077f5

Browse files
Remove --split-debug mode
The split-out DWARF can't be used anyway because wasm-opt invalidates it during optimization.
1 parent e52cb5d commit 80077f5

File tree

5 files changed

+16
-314
lines changed

5 files changed

+16
-314
lines changed

Diff for: Plugins/PackageToJS/Sources/PackageToJS.swift

+8-12
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ struct PackageToJS {
1717
struct BuildOptions {
1818
/// Product to build (default: executable target if there's only one)
1919
var product: String?
20-
/// Whether to split debug information into a separate file (default: false)
21-
var splitDebug: Bool
2220
/// Whether to apply wasm-opt optimizations in release mode (default: true)
2321
var noOptimize: Bool
2422
/// The options for packaging
@@ -390,7 +388,7 @@ struct PackagingPlanner {
390388
buildOptions: PackageToJS.BuildOptions
391389
) throws -> MiniMake.TaskKey {
392390
let (allTasks, _, _, _) = try planBuildInternal(
393-
make: &make, splitDebug: buildOptions.splitDebug, noOptimize: buildOptions.noOptimize
391+
make: &make, noOptimize: buildOptions.noOptimize
394392
)
395393
return make.addTask(
396394
inputTasks: allTasks, output: BuildPath(phony: "all"), attributes: [.phony, .silent]
@@ -399,7 +397,7 @@ struct PackagingPlanner {
399397

400398
private func planBuildInternal(
401399
make: inout MiniMake,
402-
splitDebug: Bool, noOptimize: Bool
400+
noOptimize: Bool
403401
) throws -> (
404402
allTasks: [MiniMake.TaskKey],
405403
outputDirTask: MiniMake.TaskKey,
@@ -435,25 +433,23 @@ struct PackagingPlanner {
435433

436434
if shouldOptimize {
437435
// Optimize the wasm in release mode
438-
// If splitDebug is true, we need to place the DWARF-stripped wasm file (but "name" section remains)
439-
// in the output directory.
440-
let stripWasmPath = (splitDebug ? outputDir : intermediatesDir).appending(path: wasmFilename + ".debug")
436+
let wasmWithoutDwarfPath = intermediatesDir.appending(path: wasmFilename + ".no-dwarf")
441437

442438
// First, strip DWARF sections as their existence enables DWARF preserving mode in wasm-opt
443-
let stripWasm = make.addTask(
439+
let wasmWithoutDwarf = make.addTask(
444440
inputFiles: [selfPath, wasmProductArtifact], inputTasks: [outputDirTask, intermediatesDirTask],
445-
output: stripWasmPath
441+
output: wasmWithoutDwarfPath
446442
) {
447443
print("Stripping DWARF debug info...")
448444
try system.wasmOpt(["--strip-dwarf", "--debuginfo"], input: $1.resolve(path: wasmProductArtifact).path, output: $1.resolve(path: $0.output).path)
449445
}
450446
// Then, run wasm-opt with all optimizations
451447
wasm = make.addTask(
452-
inputFiles: [selfPath, stripWasmPath], inputTasks: [outputDirTask, stripWasm],
448+
inputFiles: [selfPath, wasmWithoutDwarfPath], inputTasks: [outputDirTask, wasmWithoutDwarf],
453449
output: finalWasmPath
454450
) {
455451
print("Optimizing the wasm file...")
456-
try system.wasmOpt(["-Os"], input: $1.resolve(path: stripWasmPath).path, output: $1.resolve(path: $0.output).path)
452+
try system.wasmOpt(["-Os", "--debuginfo"], input: $1.resolve(path: wasmWithoutDwarfPath).path, output: $1.resolve(path: $0.output).path)
457453
}
458454
} else {
459455
// Copy the wasm product artifact
@@ -522,7 +518,7 @@ struct PackagingPlanner {
522518
make: inout MiniMake
523519
) throws -> (rootTask: MiniMake.TaskKey, binDir: BuildPath) {
524520
var (allTasks, outputDirTask, intermediatesDirTask, packageJsonTask) = try planBuildInternal(
525-
make: &make, splitDebug: false, noOptimize: false
521+
make: &make, noOptimize: false
526522
)
527523

528524
// Install npm dependencies used in the test harness

Diff for: Plugins/PackageToJS/Sources/PackageToJSPlugin.swift

+1-3
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,9 @@ extension PackageToJS.PackageOptions {
294294
extension PackageToJS.BuildOptions {
295295
static func parse(from extractor: inout ArgumentExtractor) -> PackageToJS.BuildOptions {
296296
let product = extractor.extractOption(named: "product").last
297-
let splitDebug = extractor.extractFlag(named: "split-debug")
298297
let noOptimize = extractor.extractFlag(named: "no-optimize")
299298
let packageOptions = PackageToJS.PackageOptions.parse(from: &extractor)
300-
return PackageToJS.BuildOptions(product: product, splitDebug: splitDebug != 0, noOptimize: noOptimize != 0, packageOptions: packageOptions)
299+
return PackageToJS.BuildOptions(product: product, noOptimize: noOptimize != 0, packageOptions: packageOptions)
301300
}
302301

303302
static func help() -> String {
@@ -311,7 +310,6 @@ extension PackageToJS.BuildOptions {
311310
--output <path> Path to the output directory (default: .build/plugins/PackageToJS/outputs/Package)
312311
--package-name <name> Name of the package (default: lowercased Package.swift name)
313312
--explain Whether to explain the build plan (default: false)
314-
--split-debug Whether to split debug information into a separate .wasm.debug file (default: false)
315313
--no-optimize Whether to disable wasm-opt optimization (default: false)
316314
--use-cdn Whether to use CDN for dependency packages (default: false)
317315
--enable-code-coverage Whether to enable code coverage collection (default: false)

Diff for: Plugins/PackageToJS/Tests/PackagingPlannerTests.swift

+4-6
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,11 @@ import Testing
3535
}
3636

3737
@Test(arguments: [
38-
(variant: "debug", configuration: "debug", splitDebug: false, noOptimize: false),
39-
(variant: "release", configuration: "release", splitDebug: false, noOptimize: false),
40-
(variant: "release_split_debug", configuration: "release", splitDebug: true, noOptimize: false),
41-
(variant: "release_no_optimize", configuration: "release", splitDebug: false, noOptimize: true),
38+
(variant: "debug", configuration: "debug", noOptimize: false),
39+
(variant: "release", configuration: "release", noOptimize: false),
40+
(variant: "release_no_optimize", configuration: "release", noOptimize: true),
4241
])
43-
func planBuild(variant: String, configuration: String, splitDebug: Bool, noOptimize: Bool) throws {
42+
func planBuild(variant: String, configuration: String, noOptimize: Bool) throws {
4443
let options = PackageToJS.PackageOptions()
4544
let system = TestPackagingSystem()
4645
let planner = PackagingPlanner(
@@ -60,7 +59,6 @@ import Testing
6059
make: &make,
6160
buildOptions: PackageToJS.BuildOptions(
6261
product: "test",
63-
splitDebug: splitDebug,
6462
noOptimize: noOptimize,
6563
packageOptions: options
6664
)

Diff for: Plugins/PackageToJS/Tests/__Snapshots__/PackagingPlannerTests/planBuild_release.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"$PLANNER_SOURCE_PATH",
2020
"$WASM_PRODUCT_ARTIFACT"
2121
],
22-
"output" : "$INTERMEDIATES\/main.wasm.debug",
22+
"output" : "$INTERMEDIATES\/main.wasm.no-dwarf",
2323
"wants" : [
2424
"$OUTPUT",
2525
"$INTERMEDIATES"
@@ -126,12 +126,12 @@
126126
],
127127
"inputs" : [
128128
"$PLANNER_SOURCE_PATH",
129-
"$INTERMEDIATES\/main.wasm.debug"
129+
"$INTERMEDIATES\/main.wasm.no-dwarf"
130130
],
131131
"output" : "$OUTPUT\/main.wasm",
132132
"wants" : [
133133
"$OUTPUT",
134-
"$INTERMEDIATES\/main.wasm.debug"
134+
"$INTERMEDIATES\/main.wasm.no-dwarf"
135135
]
136136
},
137137
{

0 commit comments

Comments
 (0)