Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Add -gcflags option for statically compiling binary #518

Open
Bertie690 opened this issue Feb 8, 2025 · 0 comments
Open

Enhancement: Add -gcflags option for statically compiling binary #518

Bertie690 opened this issue Feb 8, 2025 · 0 comments

Comments

@Bertie690
Copy link

Describe the feature
Currently, there is an -ldflags argument that passes arguments directly to go build during compilation. This would aim to add a parallel for the gcflags build flags setting as well.

What problem does this feature address?
While there are probably other uses out there that I don't know about, the once instance of this that stands out to me is removing compiler optimizations from built code for debugging. Currently, trying to launch a compiled magefile binary using dlv results in often subpar information due to compiler optimizations, and the means of removing said optimizations require passing gcflags arguments.

Additional context
While a separate flag could be made to disable compiler optimizations, this would be a more general-purpose solution.
Another option would be adding a general "build" flag that passes on its arguments directly to go build, though that might pose backwards compatibility issues.

For the record, the debug setup I am using simply has mage handle compiling the binary and dlv run the finished product afterwards.

mage -compile ./magefile-debug
dlv exec magefiles/magefile-debug

In the event this already exists, I will be very sad.

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

No branches or pull requests

1 participant