-
Notifications
You must be signed in to change notification settings - Fork 3.8k
golang: split src into separate packages #28445
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
base: master
Are you sure you want to change the base?
golang: split src into separate packages #28445
Conversation
|
What happens if you run Are you sure the src package is the same across all architectures? |
It returns Same as on my Fedora without tests installed. Do you think it makes sense to package tests at all? That is have a separate test package as other distros do. I'm somewhat skeptical if people are actually using target Go to begin with, let alone the test part.
I'm trying to model this after bigger distributions where src is noarch, like Fedora: If it's not fully noarch now, then it still needs work. I looked at the packaged files and I couldn't immediately spot anything, but source, scripts, and some docs. And of course it's beside the point, as AFAICT all packages are built and pulled per arch despite being marked as noarch, i.e. there's no all/noarch target. |
Yes I do - On normal desktop systems, if the user doesn't like how Go is packaged by their distro, it is fairly easy for them to compile their own Go from source. On OpenWrt devices with constrained CPU/RAM, it would be very difficult to compile Go from source. That's why my intention was to keep the target package as stock as possible, including having access to tests and test data.
It's not - if you diff the package contents from different architectures you will find that usr/share/go-1.XX/src/internal/buildcfg/zbootstrap.go is architecture (actually target) specific. This file specifies the default values for various packages/lang/golang/golang-version.mk Lines 174 to 181 in b19c784
and the file updated during build: packages/lang/golang/golang-version.mk Lines 229 to 237 in b19c784
You could move that file from the src package to the main binary package (like in Debian/Ubuntu), then the src package can be marked as architecture-independent (there are more generated files and Debian includes all of them in the binary package, but I believe the rest are identical across architectures). Or you could combine the binary and src packages into one package (like Arch Linux), since the source files are required anyway. I think I kept hoping the src package can be made optional one day, but more likely is I didn't think it was worth the effort to make more changes. Some things I found while looking into this:
|
1f4c34c to
931aba4
Compare
|
Thanks for the detailed answer, as usual. I split tests into a separate package. Turns out it's a bit more complicated than it seems as there are more files that need to be packaged. And it took me a minute to figure out that some tests kept crashing due to OOM in the VM. I fixed the issues that you brought up as well (even though they are OOS for this PR). I also fixed stripping so now main binaries are stripped, but not the other packages. With tests installed, the target test suite produces the same output as on my desktop. Edit: actually some OS-related tests like TestGroupCleanupUserNamespace seems to fail, as they expect a different command output. There are more version-related changes that have been overlooked in the past, e.g. OS/arch combos and checks, that I'm leaving for a separate PR. |
931aba4 to
4eff0fb
Compare
Replace Makefile variables in comments to avoid expanding them unnecessarily. Link: openwrt#28445 Signed-off-by: George Sapkin <[email protected]>
Don't set GO_LDSO as it's determined automatically at link time. Link: golang/go#54197 Link: openwrt#28445 Suggested-by: Jeffery To <[email protected]> Signed-off-by: George Sapkin <[email protected]>
Fix setting architecture-specific defaults in zbootstrap.go. Fixes: b211946 ("golang: Update to 1.24.0") Link: golang/go@cce90c1 Link: openwrt#28445 Suggested-by: Jeffery To <[email protected]> Signed-off-by: George Sapkin <[email protected]>
Add libraries used in test data to extra_provides to pass dependency checks in package-pack. Remove unnecessary dependencies. Fixes: openwrt#27633 Fixes: b211946 ("golang: Update to 1.24.0") Link: openwrt#28445 Signed-off-by: George Sapkin <[email protected]>
Installing into share and symlinking to lib breaks tests:
--- FAIL: TestAllDependencies (0.01s)
moddeps_test.go:49: findGorootModules didn't find the well-known module "std"
--- FAIL: TestDependencyVersionsConsistent (0.00s)
moddeps_test.go:356: findGorootModules didn't find the well-known module "std"
Install into lib directly instead.
Fixes: c137c38 ("golang: new packages")
Link: openwrt#28445
Signed-off-by: George Sapkin <[email protected]>
4eff0fb to
f05deee
Compare
Split misc sources and test data into separate packages. Reduces target src package size by a third. Move architecture-dependent generated source from src to the main package. Mark doc, misc, src and tests packages with PKGARCH:=all as they don't have any architecture-specific files. Fix stripping and strip compiler only. Fixes: c137c38 ("golang: new packages") Link: openwrt#28445 Suggested-by: Jeffery To <[email protected]> Signed-off-by: George Sapkin <[email protected]>
|
I changed the install path for both host and target go to be under Looks like these tests can't deal with symlinks. The only remaining failing test is syscall-related: |
Split misc sources and test data into separate packages. Reduces target src package size by a third. Move architecture-dependent generated source from src to the main package. Mark doc, misc, src and tests packages with PKGARCH:=all as they don't have any architecture-specific files. Fix stripping and strip compiler only. Fixes: c137c38 ("golang: new packages") Link: openwrt#28445 Suggested-by: Jeffery To <[email protected]> Signed-off-by: George Sapkin <[email protected]>
f05deee to
3195a58
Compare
Split misc sources and test data into separate packages. Reduces target src package size by a third. Move architecture-dependent generated source from src to the main package. Mark doc, misc, src and tests packages with PKGARCH:=all as they don't have any architecture-specific files. Fix stripping and strip compiler only. Fixes: c137c38 ("golang: new packages") Link: openwrt#28445 Suggested-by: Jeffery To <[email protected]> Signed-off-by: George Sapkin <[email protected]>
3195a58 to
2a809cf
Compare
📦 Package Details
Maintainer: me
Description:
Split misc sources and test data into separate packages. Reduces target src package size by a third.
Move architecture-dependent generated source from src to the main package.
Mark doc, misc, src and tests packages with
PKGARCH:=allas they don't have any architecture-specific files.Installing into share and symlinking to lib breaks tests:
Install into lib directly instead.
Fix stripping and strip compiler only.
Add libraries used in test data to
extra_providesto pass dependency checks in package-pack.Remove unnecessary dependencies.
Fix setting architecture-specific defaults in
zbootstrap.go.Don't set
GO_LDSOas it's determined automatically at link time.Replace Makefile variables in comments to avoid expanding them unnecessarily.
Fixes: c137c38 ("golang: new packages")
Fixes: b211946 ("golang: Update to 1.24.0")
Fixes: #27633
Link: golang/go@cce90c1
Link: golang/go#54197
🧪 Run Testing Details
Tested:
go tool dist teston target with tests installed. TestGroupCleanupUserNamespace fails.✅ Formalities