-
Notifications
You must be signed in to change notification settings - Fork 762
Makefile: Add the DEBUG flag to build binaries with debug information for use by dlv exec.
#4044
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
Makefile: Add the DEBUG flag to build binaries with debug information for use by dlv exec.
#4044
Conversation
There was a problem hiding this 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 adds a DEBUG flag to the Makefile that enables building binaries with debug information for use with dlv exec on macOS Tahoe 26.0. This addresses a compatibility issue where dlv dap cannot use certain entitlements on the new macOS version, but dlv exec with precompiled binaries can.
- Introduces conditional debug build support via
DEBUG=1 - Adds GCFLAGS configuration for debug builds to disable optimizations and preserve debugging symbols
- Updates build variable extraction to handle the new GCFLAGS parameter
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
I also made a review request to copilot by mistake. |
| @echo | ||
| @echo '- PREFIX (directory) : Installation prefix (default: /usr/local)' | ||
| @echo '- KEEP_SYMBOLS (1 or 0) : Whether to keep symbols (default: 0)' | ||
| @echo '- DEBUG (1 or 0) : Whether to build with debug information (default: 0)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably this should be documented in https://lima-vm.io/docs/dev/ ? Maybe create the /docs/dev/debug page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I were to write a document on debugging in Visual Studio Code, I’d like to improve how ha.pid is handled to reduce the need for preLaunchTask and postDebugTask.
aac904a to
6c44513
Compare
…tion for use by `dlv exec`. macOS Tahoe 26.0 does not allow the debug target of `dlv dap` to use the `com.apple.security.virtualization` entitlement. See: lima-vm#2651 (comment) But macOS Tahoe 26.0 allows the precompiled binary target of `dlv exec` to use the entitlement. This adds the `DEBUG` flag to build binaries with debug information for use by `dlv exec`. ### Configuration files for VSCode working on macOS Tahoe 26.0 `launch.json`: ```jsonc { "version": "0.2.0", "configurations": [ { "name": "exec hostagent for input instance", "type": "go", "request": "launch", "mode": "exec", // Use integratedTerminal to stop using ctrl+C "console": "integratedTerminal", "program": "${workspaceFolder}/_output/bin/limactl", "env": { "LIMA_SSH_OVER_VSOCK": "false", "LIMA_SSH_PORT_FORWARDER": "true", }, "cwd": "${userHome}/.lima/${input:targetInstance}", "args": [ "--debug", "hostagent", "--pidfile", "ha.pid", "--socket", "ha.sock", "--guestagent", "${workspaceFolder}/_output/share/lima/lima-guestagent.Linux-aarch64", "--progress", "${input:targetInstance}" ], "preLaunchTask": "prepare launching hostagent for target instance", "postDebugTask": "clean up after stopping hostagent for target instance", }, ], "inputs": [ { "id": "targetInstance", "type": "promptString", "description": "Input target instance parameter for `limactl` command", } ] } ``` `tasks.json`: ```jsonc { "version": "2.0.0", "tasks": [ { "label": "prepare launching hostagent for target instance", "dependsOn":[ "execute: make CONFIG_GUESTAGENT_COMPRESS=n DEBUG=1", "execute: rm -f ${userHome}/.lima/${input:targetInstance}/ha.pid", ] }, { "label": "clean up after stopping hostagent for target instance", "dependsOn":[ "execute: rm -f ${userHome}/.lima/${input:targetInstance}/ha.pid", ] }, { "label": "execute: make CONFIG_GUESTAGENT_COMPRESS=n DEBUG=1", "type": "shell", "command": "make CONFIG_GUESTAGENT_COMPRESS=n DEBUG=1", "presentation": { "close": true, "reveal": "always" }, }, { "label": "execute: rm -f ${userHome}/.lima/${input:targetInstance}/ha.pid", "type": "shell", "command": "rm -f ${userHome}/.lima/${input:targetInstance}/ha.pid", "presentation": { "close": true, "reveal": "silent" }, } ], "inputs": [ { "id": "targetInstance", "type": "promptString", "description": "Input <instance> for `rm -f <LIMA_HOME>/<instance>/ha.pid`", } ] } ``` Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
6c44513 to
4b7f04c
Compare
AkihiroSuda
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
…ha.pid` Sometimes, after the `limactl hostagent` process stops (e.g., due to a SIGKILL), the `ha.pid` file remains. This change checks if the process with the given PID is still running. If not, the `ha.pid` file is ignored, simplifying debugging by reducing cleanup steps to remove `ha.pid`. see: lima-vm#4044 (comment) Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
|
Thanks! 🙏🏻 |
|
I found a better solution than using
By using this, the I'll open a PR that adding the script |
opened #4052 |
macOS Tahoe 26.0 does not allow the debug target of
dlv dapto use thecom.apple.security.virtualizationentitlement. See: #2651 (comment)But macOS Tahoe 26.0 allows the precompiled binary target of
dlv execto use the entitlement. This adds theDEBUGflag to build binaries with debug information for use bydlv exec.Configuration files for VSCode working on macOS Tahoe 26.0
launch.json:{ "version": "0.2.0", "configurations": [ { "name": "exec hostagent for input instance", "type": "go", "request": "launch", "mode": "exec", // Use integratedTerminal to stop using ctrl+C "console": "integratedTerminal", "program": "${workspaceFolder}/_output/bin/limactl", "env": { "LIMA_SSH_OVER_VSOCK": "false", "LIMA_SSH_PORT_FORWARDER": "true", }, "cwd": "${userHome}/.lima/${input:targetInstance}", "args": [ "--debug", "hostagent", "--pidfile", "ha.pid", "--socket", "ha.sock", "--guestagent", "${workspaceFolder}/_output/share/lima/lima-guestagent.Linux-aarch64", "--progress", "${input:targetInstance}" ], "preLaunchTask": "prepare launching hostagent for target instance", "postDebugTask": "clean up after stopping hostagent for target instance", }, ], "inputs": [ { "id": "targetInstance", "type": "promptString", "description": "Input target instance parameter for `limactl` command", } ] }tasks.json:{ "version": "2.0.0", "tasks": [ { "label": "prepare launching hostagent for target instance", "dependsOn":[ "execute: make CONFIG_GUESTAGENT_COMPRESS=n DEBUG=1", "execute: rm -f ${userHome}/.lima/${input:targetInstance}/ha.pid", ] }, { "label": "clean up after stopping hostagent for target instance", "dependsOn":[ "execute: rm -f ${userHome}/.lima/${input:targetInstance}/ha.pid", ] }, { "label": "execute: make CONFIG_GUESTAGENT_COMPRESS=n DEBUG=1", "type": "shell", "command": "make CONFIG_GUESTAGENT_COMPRESS=n DEBUG=1", "presentation": { "close": true, "reveal": "always" }, }, { "label": "execute: rm -f ${userHome}/.lima/${input:targetInstance}/ha.pid", "type": "shell", "command": "rm -f ${userHome}/.lima/${input:targetInstance}/ha.pid", "presentation": { "close": true, "reveal": "silent" }, } ], "inputs": [ { "id": "targetInstance", "type": "promptString", "description": "Input <instance> for `rm -f <LIMA_HOME>/<instance>/ha.pid`", } ] }