Repository navigation
src: Port Go build wrapper from Shell to Python & support externaly defined build options - #1031
martymichal wants to merge 5 commits into
Conversation
debarshiray
left a comment
There was a problem hiding this comment.
Yes, this will be good to have. I once thought of it, but the shell script started giving me nightmares.
Maybe this is be a good time to add some tests to sanity check the built binary?
The go-build-wrapper script encapsulates a lot of subtle, but crucial, details and we don't want to regress anything. eg., the path to the dynamic linker, the rpath, etc.. Ideally we would add the test first to test the old script, and then introduce the new script -- that way we can trivially verify (through git bisect, etc.) that everything is good.
| output_dir = sys.argv[2] | ||
| version = sys.argv[3] | ||
| cc = sys.argv[4] | ||
| dyn_linker = sys.argv[5] |
There was a problem hiding this comment.
Would be better to use terms like dynamic_linker, dynamic-linker everywhere. They are easier to grep for (eg., searching for dynamic will get you better results), and can defend against typos by making them stand out.
|
Build failed.
|
531cf4b to
a29ac02
Compare
|
Build failed.
|
Toolbx requires some binary-level adjustments to accomplish its job. Potential regressions in the wrapper build script need to be caught to prevent breakage.
a29ac02 to
74cb8e7
Compare
|
Build failed.
|
74cb8e7 to
704e1d0
Compare
Some downstreams (e.g., Fedora) set additional flags while building software in their repositories. This also applies to software written in Go. This work removes the need for manually patching the 'go build' wrapper script, needed for integrating 'go build' into Meson, to add the desired build options. This introduces a new build option 'go_build_flags'.
704e1d0 to
d0b7a84
Compare
|
Build succeeded.
|
| package binary | ||
|
|
||
| import ( | ||
| "debug/elf" |
There was a problem hiding this comment.
How does Go's debug/elf compare with other implementations like GNU Binutils, in terms of architecture support and the ability to handle a diverse variety of ELFs?
There was a problem hiding this comment.
Overall I'd say the support is lower than of readelf from GNU Binutils. From what I understood though, debug/elf supports both 32-bit and 64-bit architectures and recognizes many machine types and many OS ABIs. Though, am not sure how the last two parts translate into "architecture support". Most likely didn't answer your question in full.
Probably is noteworthy that the tool is for checking the Toolbx binary and not an arbitrary binary. My presumption is that whether Go is capable of producing a binary on a certain architecture, the created binary also has to be processable by the debug/elf package.
There was a problem hiding this comment.
Probably is noteworthy that the tool is for checking the Toolbx binary and not an arbitrary binary. My presumption is that whether Go is capable of producing a binary on a certain architecture, the created binary also has to be processable by the debug/elf package.
This is a good point!
|
|
||
| if bash_completion.found() | ||
| bash_comp_dir = bash_completion.get_pkgconfig_variable('completionsdir') | ||
| bash_comp_dir = bash_completion.get_variable(pkgconfig: 'completionsdir') |
There was a problem hiding this comment.
Oops! This was done a few months after this pull request was submitted in commit 1567d207c6c6317c or #1096. Sorry about that.
|
|
||
| if fish.found() | ||
| fish_comp_dir = fish.get_pkgconfig_variable('completionsdir') | ||
| fish_comp_dir = fish.get_variable(pkgconfig: 'completionsdir') |
| go, | ||
| args: ['test', '-v', './...'], | ||
| depends: toolbox, | ||
| workdir: meson.current_source_dir() |
There was a problem hiding this comment.
Is it really necessary to make the Go unit tests depend on the toolbox(1) binary? They seem to be independent, as far as I can tell. If it's really needed then it will be good to add the reason to the Git commit message.
| rpath="/run/host$libc_dir_canonical_dirname" | ||
|
|
||
| # Write overriden binary values to a file for testing | ||
| echo "${dynamic_linker} ${rpath}" > "$2/go-build-overrides" |
There was a problem hiding this comment.
I wonder if we can pass these values straight to the test through go test ... -args ... <dynamic-linker> <rpath> instead of inventing an intermediate file. If nothing else ...
| os.Exit(1) | ||
| } | ||
| dynamicLinker = buildOverrides[0] | ||
| runpath = buildOverrides[1] |
There was a problem hiding this comment.
... we won't have to do all of the above to parse the file.
No description provided.