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

how add go build flags to compile our modules ? #74

Closed
wisperC4 opened this issue Jun 16, 2022 · 1 comment · Fixed by #80
Closed

how add go build flags to compile our modules ? #74

wisperC4 opened this issue Jun 16, 2022 · 1 comment · Fixed by #80

Comments

@wisperC4
Copy link

Hello,
at this time we are using : go build -ldflags "-X 'main.BuildTime=$(date)'" when we want to compile our prog.
Now we want to use gobusybox to assemble all our little program but we how reproduce the same ,
makebb -go-extra-args seems to be not working as we expected.

Regards,
Nicolas

@hugelgupf
Copy link
Member

Hi, you are correct, this was broken. Addressed in #80.

Just a side note: Since programs are rewritten by gobusybox as described in the README, if you have a command called -- say -- printbuildtime which is a package main and has a var BuildTime string global variable, then passing -X 'main.BuildTime=$(date)' will not work in this case. gobusybox will rewrite printbuildtime to be a package, so main.BuildTime won't refer to the correct symbol anymore.

You have to refer to the symbol with the full package path, e.g. if printbuildtime were in github.com/u-root/gobusybox/src/cmd/printbuildtime, here's my makebb invocation after #80:

makebb --go-extra-args="-ldflags" --go-extra-args="-X 'github.com/u-root/gobusybox/src/cmd/printbuildtime.BuildTime=$(date)'" ./cmd/printbuildtime

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

Successfully merging a pull request may close this issue.

2 participants