Update build flags to make -trimpath
go flag configurable
#82
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context and Problem
While working on integrating the Streams API into k6 using xk6 extensions, I encountered a significant challenge in debugging with VSCode. Specifically, the debugger could not associate breakpoints with the correct file paths. This issue stems from the
-trimpath
argument in our build process, which removes file system paths from the executable, thus hindering the debugger's ability to function correctly.Solution
This PR modifies the build process for xk6 extensions. By adjusting where and how the
-trimpath
flag is applied, we allow extension developers to override this setting using theXK6_BUILD_FLAGS
environment variable. This change offers more flexibility in preserving debug symbols and optimizing the debugging experience in VSCode.For the history books: Debugging in VSCode using this fix
For those looking to debug xk6 extensions in VSCode, here's a guide based on my setup:
Build Task Configuration
Create a VSCode task to build the xk6 binary with the necessary flags for debugging. This task utilizes the changes introduced in this PR. Here's the configuration in
tasks.json
:Define a launch.json file in VSCode to run the above build task before starting the debugger. Here's the configuration:
References
ref #51
ref #43