Skip to content

fix(v2): strip debug symbols from wailsbindings binary for Go 1.25 compat#5220

Open
leaanthony wants to merge 1 commit intomasterfrom
fix/4551-go125-compat
Open

fix(v2): strip debug symbols from wailsbindings binary for Go 1.25 compat#5220
leaanthony wants to merge 1 commit intomasterfrom
fix/4551-go125-compat

Conversation

@leaanthony
Copy link
Copy Markdown
Member

@leaanthony leaanthony commented Apr 23, 2026

Summary

  • Adds -ldflags "-s -w" to the wailsbindings build command in v2/pkg/commands/bindings/bindings.go
  • Go 1.25 defaults to DWARF5 debug format, which when combined with CGO produces malformed Windows PE binaries (golang/go#75077)
  • The wailsbindings binary is a temporary throwaway helper used only for TypeScript binding generation, so stripping symbols is safe
  • This was already done for production builds (-w -s in base.go) but was missing from the bindings helper

Test plan

  • Test in v2/test/4551/bindings_test.go verifies the ldflags are present in the build command
  • Windows users with Go 1.25+ should now be able to run wails dev and wails build without the "not a valid Win32 application" error

Also fixes #4605, #4831

Fixes #4551

Summary by CodeRabbit

  • Chores

    • Applied build optimization to bindings generation.
  • Tests

    • Added test to verify bindings build configuration.

…mpat

Go 1.25 defaults to DWARF5, which combined with CGO produces
malformed Windows PE binaries (golang/go#75077). The wailsbindings
binary is a temporary throwaway helper used only for binding
generation, so stripping symbols with -ldflags -s -w is safe and
avoids the bug entirely.

Also fixes #4605, #4831

Fixes #4551
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 23, 2026

Walkthrough

The PR adds Go linker flags -s -w to the bindings generation build command to strip symbols from the compiled executable, and introduces a test to verify this behavior is present in the build invocation.

Changes

Cohort / File(s) Summary
Bindings Generation Update
v2/pkg/commands/bindings/bindings.go
Added -ldflags "-s -w" to the go build command that generates bindings, enabling symbol stripping.
Test Verification
v2/test/4551/bindings_test.go
New test function TestGenerateBindingsUsesStrippedSymbols verifies the bindings build command includes the -ldflags -s -w flags.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

Windows

Poem

🐰 A symbol or two caught the Windows bug,
So -s -w gives the exe a snug hug,
With bindings now stripped of their bloated grace,
This rabbit hops faster across platform space! 🏃‍♂️✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding Go linker flags to strip debug symbols from the wailsbindings binary for Go 1.25 compatibility.
Description check ✅ Passed The description is well-structured, includes issue references (Fixes #4551, #4605, #4831), explains the rationale, technical context, and test plan, though some checklist items are not explicitly addressed.
Linked Issues check ✅ Passed The PR directly addresses the coding objectives from linked issues #4551 and #4605 by implementing the fix (adding -ldflags -s -w) and includes a test to verify the implementation.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the linked issues: the bindings build modification and corresponding test are both necessary to resolve the Go 1.25 compatibility problem.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/4551-go125-compat

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.11.4)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@leaanthony leaanthony marked this pull request as ready for review April 29, 2026 22:14
Copilot AI review requested due to automatic review settings April 29, 2026 22:14
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@v2/test/4551/bindings_test.go`:
- Around line 13-15: Replace the silent skip with a hard failure: in
v2/test/4551/bindings_test.go where the code checks "if err != nil {
t.Skipf(...)" change it to "t.Fatalf(...)" (or t.Fatalf with the same formatted
message) so that when the bindings source cannot be read the test fails
(preserve the "%v" error interpolation on the existing err variable).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7963e7f3-345c-409b-bbed-b000b5591109

📥 Commits

Reviewing files that changed from the base of the PR and between b618f81 and 756400f.

📒 Files selected for processing (2)
  • v2/pkg/commands/bindings/bindings.go
  • v2/test/4551/bindings_test.go

Comment on lines +13 to +15
if err != nil {
t.Skipf("could not read bindings source: %v", err)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fail instead of skip when the source file cannot be read.

At Line [14], t.Skipf can silently bypass this regression test if the path/setup breaks. This should be a hard failure so CI still protects the fix.

Suggested patch
 	data, err := os.ReadFile(sourceFile)
 	if err != nil {
-		t.Skipf("could not read bindings source: %v", err)
+		t.Fatalf("could not read bindings source: %v", err)
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if err != nil {
t.Skipf("could not read bindings source: %v", err)
}
data, err := os.ReadFile(sourceFile)
if err != nil {
t.Fatalf("could not read bindings source: %v", err)
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@v2/test/4551/bindings_test.go` around lines 13 - 15, Replace the silent skip
with a hard failure: in v2/test/4551/bindings_test.go where the code checks "if
err != nil { t.Skipf(...)" change it to "t.Fatalf(...)" (or t.Fatalf with the
same formatted message) so that when the bindings source cannot be read the test
fails (preserve the "%v" error interpolation on the existing err variable).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the v2 bindings-generation helper (wailsbindings) build to strip debug symbols via -ldflags "-s -w", mitigating the Go 1.25 DWARF5+CGO malformed Windows PE issue during TypeScript binding generation, and adds a regression test to ensure the flag remains present.

Changes:

  • Add -ldflags "-s -w" to the go build invocation used to compile the temporary wailsbindings helper binary.
  • Add a regression test that asserts the bindings helper build command includes the strip-symbol ldflags.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
v2/pkg/commands/bindings/bindings.go Adds -ldflags "-s -w" to the wailsbindings build command.
v2/test/4551/bindings_test.go Adds a test asserting the presence of the ldflags in the bindings helper build command.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

envBuild = shell.RemoveEnv(envBuild, "CC")

stdout, stderr, err = shell.RunCommandWithEnv(envBuild, workingDirectory, options.Compiler, "build", "-buildvcs=false", "-tags", tagString, "-o", filename)
stdout, stderr, err = shell.RunCommandWithEnv(envBuild, workingDirectory, options.Compiler, "build", "-buildvcs=false", "-tags", tagString, "-ldflags", "-s -w", "-o", filename)
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The -ldflags value is hardcoded here even though production builds already add strip flags in v2/pkg/commands/build/base.go. To avoid these drifting out of sync (order/extra flags like -H windowsgui), consider factoring the strip-symbol ldflags into a shared helper/constant and reusing it for both the app build and the wailsbindings helper build.

Copilot uses AI. Check for mistakes.
sourceFile := filepath.Join("..", "..", "pkg", "commands", "bindings", "bindings.go")
data, err := os.ReadFile(sourceFile)
if err != nil {
t.Skipf("could not read bindings source: %v", err)
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test skips when it can't read the source file. In CI/repo tests, failing to locate bindings.go should be a hard failure (otherwise the test can silently pass even if the path is wrong or the file moves). Prefer t.Fatalf(...) (or t.Fatal(...)) here instead of t.Skipf(...).

Suggested change
t.Skipf("could not read bindings source: %v", err)
t.Fatalf("could not read bindings source: %v", err)

Copilot uses AI. Check for mistakes.
}

source := string(data)
if !strings.Contains(source, `"-ldflags", "-s -w"`) {
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assertion depends on an exact source-code substring (including whitespace/formatting). A gofmt reflow of the RunCommandWithEnv(...) call could break this test without changing behavior. Consider making the check tolerant to formatting (e.g., search separately for "-ldflags" and "-s -w", or strip whitespace, or parse the file with go/parser and inspect the call args).

Suggested change
if !strings.Contains(source, `"-ldflags", "-s -w"`) {
if !strings.Contains(source, `"-ldflags"`) || !strings.Contains(source, `"-s -w"`) {

Copilot uses AI. Check for mistakes.
@leaanthony
Copy link
Copy Markdown
Member Author

🤖 PR Triage Review

Accepted

Strips debug symbols from wailsbindings binary for Go 1.25 compatibility (v2 CLI). Important compatibility fix.

Platform: All (v2, CLI)

Next Steps: Dispatching for testing on all platforms.


Reviewed by Wails PR Reviewer Bot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bindings Fail to Generate wails 2.10.2 not support golang1.25.0

2 participants