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

build.go: add an option to specify '-o' option when build #8109

Merged
merged 1 commit into from
Jan 13, 2022

Conversation

bekcpear
Copy link
Contributor

@bekcpear bekcpear commented Jan 13, 2022

When GOBIN is set, 'go install' cannot install cross-compilied binaries.
To satisfy cross-compilation, it's necessary to add the '-o' to build
target, otherwise 'go build' will discarding the resulting objects when
compiling multiple packages.

Purpose

To satisfy cross-compilation.
To satisfy cross-compilation for 'all' target.

When GOBIN is set, 'go install' cannot install cross-compilied binaries.
To satisfy cross-compilation, it's necessary to add the '-o' to build
target, otherwise 'go build' will discarding the resulting objects when
compiling multiple packages.

Signed-off-by: bekcpear <i@bitbili.net>
@calmh
Copy link
Member

calmh commented Jan 13, 2022

But the option you're adding is for the build subcommand, not install, which already handles cross compilation? I mean, it's how we cross compile.

@bekcpear
Copy link
Contributor Author

But if I run

go run build.go -goarch arm64 install

An error go install: cannot install cross-compiled binaries when GOBIN is set occured, unless unset the GOBIN env.

@calmh
Copy link
Member

calmh commented Jan 13, 2022

go run build.go -goarch arm64 build

Builds just the named target, or syncthing by default, to the current directory. Use this when cross compiling, with parameters for what to cross compile to: go run build.go -goos linux -goarch 386 build.

(https://docs.syncthing.net/dev/building.html)

@bekcpear
Copy link
Contributor Author

bekcpear commented Jan 13, 2022

Yes, this command is okay, but as I said:

'go build' will discarding the resulting objects when compiling multiple packages.

command

go run build.go -goarch arm64 build all

takes no effect, unless '-o' option specified.

@calmh
Copy link
Member

calmh commented Jan 13, 2022

Right, that seems like it could be legit useful

@calmh calmh merged commit 40bb52f into syncthing:main Jan 13, 2022
@bekcpear bekcpear deleted the build-out-option branch January 13, 2022 08:58
@calmh calmh added this to the v1.19.0 milestone Jan 18, 2022
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Mar 10, 2023
@syncthing syncthing locked and limited conversation to collaborators Mar 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants