``` mkdir -p $WORK/b346/exe/ cd . GOROOT_FINAL='go' /usr/lib/go/pkg/tool/linux_amd64/link -o $WORK/b346/exe/a.out -importcfg $WORK/b346/importcfg.link -buildmode=exe -buildid=6TbY8p-lnZpGwoX-Tt74/oY8sv373gvSSR8xPJpr0/GdJjVqSt8O3-5BdJquIx/6TbY8p-lnZpGwoX-Tt74 -w -X github.com/syncthing/syncthing/lib/build.Version=v1.18.6 -X github.com/syncthing/syncthing/lib/build.Stamp=1642053544 -X github.com/syncthing/syncthing/lib/build.User=portage -X github.com/syncthing/syncthing/lib/build.Host=localhost -X github.com/syncthing/syncthing/lib/build.Tags=purego,noupgrade -extld=x86_64-pc-linux-gnu-gcc $WORK/b346/_pkg_.a /usr/lib/go/pkg/tool/linux_amd64/buildid -w $WORK/b346/exe/a.out # internal mv: cannot stat 'syncthing': No such file or directory * ERROR: net-p2p/syncthing-1.18.6::gentoo failed (compile phase): * (no error message) * * Call stack: * ebuild.sh, line 127: Called src_compile * environment, line 3327: Called die * The specific snippet of code: * mv "${PN}$(go env GOEXE)" bin/ || die ``` `go build` command discards the resulting objects when compiling multiple packages, can be confirmed by `go help build`. Reproducible: Always
To satisfy PR(https://github.com/gentoo/gentoo/pull/23693), I create a PR(https://github.com/syncthing/syncthing/pull/8109) to add the '-o' option to the build target of `build.go`, I hope it can be approved. And, it's easy to modify this ebuild with patch: ``` diff --git a/syncthing-1.18.6.ebuild b/syncthing-1.18.6.ebuild index 6df6124..6fb5f07 100644 --- a/syncthing-1.18.6.ebuild +++ b/syncthing-1.18.6.ebuild @@ -828,10 +828,8 @@ src_prepare() { } src_compile() { - go run build.go -version "v${PV}" -no-upgrade build \ + go run build.go -version "v${PV}" -no-upgrade -o "${S}/bin/" build \ $(usex tools "all" "") || die "build failed" - mkdir bin || die - mv "${PN}$(go env GOEXE)" bin/ || die } src_test() { ``` to solve this problem with the above patch in PR(https://github.com/syncthing/syncthing/pull/8109)
sorry for the mistake of the above comment, it's not ``` go run build.go -version "v${PV}" -no-upgrade -o "${S}/bin/" build \ ``` it's ``` go run build.go -version "v${PV}" -no-upgrade -build-out "${S}/bin/" build \ ```
Good catch, thanks - somehow I have failed to run USE=tools build tests this time. Unfortunately neither of your proposed solution works for me - both result in "flag provided but not defined".
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c8c1f5c254e2d89e7a4fa854cf1f31be4fc25bb0 commit c8c1f5c254e2d89e7a4fa854cf1f31be4fc25bb0 Author: Marek Szuba <marecki@gentoo.org> AuthorDate: 2022-01-13 10:43:21 +0000 Commit: Marek Szuba <marecki@gentoo.org> CommitDate: 2022-01-13 10:53:50 +0000 net-p2p/syncthing: Revert "support cross compilation" Turns out this breaks USE=tools. This reverts commit 743f726479d8f20dc7e13f6d54f83bab4d71c70f. Closes: https://bugs.gentoo.org/831099 Signed-off-by: Marek Szuba <marecki@gentoo.org> net-p2p/syncthing/syncthing-1.18.5.ebuild | 4 +--- net-p2p/syncthing/syncthing-1.18.6.ebuild | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-)
The build.go patch(https://patch-diff.githubusercontent.com/raw/syncthing/syncthing/pull/8109.diff) should be applied with this ebuild pacth. But I don't know how to test it with cross compilation. A global 'GOARCH=arm' env will make the build.go file be built under the arm64 architecture and causes 'exec format error'.
(In reply to Ryan Qian from comment #5) > The build.go > patch(https://patch-diff.githubusercontent.com/raw/syncthing/syncthing/pull/ > 8109.diff) should be applied with this ebuild pacth. Ehh, I fail at reading today... Somehow I thought this had already been included in .6. Anyway, I guess Alex can now follow up on this and resubmit the cross-compilation fix once everything has been confirmed to work.
Okay I totally bungled this. Sorry! I issued a new pull request on GitHub: - 1.18.5 includes the patch for the -build-out Flag; 1.18.6 should already include it (right?) - I found that src_compile needs 'mkdir bin || die' before 'go run build.go' or else the Go compiler complains that it can't write "multiple packages to non-directory bin" - src_compile hides GOARCH from 'go run' to address Ryan Qian's comment #5 - if GOARCH is set, src_compile passes it as -goarch="${GOARCH}"
The new PR is at https://github.com/gentoo/gentoo/pull/23778
(In reply to Alexandra Parker from comment #7) > - 1.18.5 includes the patch for the -build-out Flag; 1.18.6 should already > include it (right?) neither 1.18.5 nor 1.18.6 include the patch for -build-out flag. This patch would be include in 1.18.7, I think. > - I found that src_compile needs 'mkdir bin || die' before 'go run build.go' > or else the Go compiler complains that it can't write "multiple packages to > non-directory bin" As `go help build` documented: ``` The -o flag forces build to write the resulting executable or object to the named output file or directory, instead of the default behavior described in the last two paragraphs. If the named output is an existing directory or ends with a slash or backslash, then any resulting executables will be written to that directory. ``` You need to set the output path to a value with a slash suffix.
I updated the pull request. I think everything's right now. It seems to work for all combos of native/cross build and USE=tools/USE=-tools.