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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failures on 32-bit archs: int overflows #3125

Open
2 tasks done
CyrilBrulebois opened this issue Nov 27, 2022 · 2 comments
Open
2 tasks done

Build failures on 32-bit archs: int overflows #3125

CyrilBrulebois opened this issue Nov 27, 2022 · 2 comments

Comments

@CyrilBrulebois
Copy link
Contributor

  • The issue is present in the latest release: 0.11.4
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 馃槸

ent doesn't build on 32-bit architectures (e.g. armel, armhf, and i386 exhibit the issue, as seen with autopkgtest runs on https://ci.debian.net/), due to a few overflows/type issues:

# entgo.io/ent/dialect/gremlin/encoding/graphson [entgo.io/ent/dialect/gremlin/encoding/graphson.test]
src/entgo.io/ent/dialect/gremlin/encoding/graphson/native_test.go:96:13: cannot convert 9876543210 (untyped int constant) to type uint
# entgo.io/ent/dialect/sql/schema [entgo.io/ent/dialect/sql/schema.test]
src/entgo.io/ent/dialect/sql/schema/migrate_test.go:286:82: cannot use 1 << 32 (untyped int constant 4294967296) as int value in argument to fmt.Sprintf (overflows)
src/entgo.io/ent/dialect/sql/schema/migrate_test.go:302:82: cannot use 2 << 32 (untyped int constant 8589934592) as int value in argument to fmt.Sprintf (overflows)
src/entgo.io/ent/dialect/sql/schema/sqlite_test.go:390:25: cannot use 1 << 32 (untyped int constant 4294967296) as int value in argument to mock.ExpectExec(escape("INSERT INTO `sqlite_sequence` (`name`, `seq`) VALUES (?, ?)")).WithArgs (overflows)
src/entgo.io/ent/dialect/sql/schema/sqlite_test.go:429:25: cannot use 1 << 32 (untyped int constant 4294967296) as int value in argument to mock.ExpectExec(escape("INSERT INTO `sqlite_sequence` (`name`, `seq`) VALUES (?, ?)")).WithArgs (overflows)

Expected Behavior 馃

It should build.

Steps to Reproduce 馃暪

Build ent in a 32-bit environment. This is easily achieved by setting up an i386 chroot on an amd64 machine.

On Debian/Ubuntu systems, this can be done by throwing the current source package in unstable at cowbuilder, which automates setting up a build chroot, installing build dependencies in it, and cleaning up after a build (successful or not).

Steps:

  1. dget https://deb.debian.org/debian/pool/main/g/golang-entgo-ent/golang-entgo-ent_0.11.3-3.dsc
  2. sudo cowbuilder --create --distribution unstable --architecture i386 --basepath /var/cache/pbuilder/unstable-i386-base.cow
  3. sudo cowbuilder --build golang-entgo-ent_0.11.3-3.dsc --basepath /var/cache/pbuilder/unstable-i386-base.cow

Your Environment 馃寧

Debian unstable, any 32-bit architecture.

Tech Version
Go 1.19.3
Ent 0.11.4

With the attached patch, the build succeeds, but then runtime tests fail. I'll file a companion ticket for those.

0003-avoid-overflows-on-32-bit-systems.patch.txt

@a8m
Copy link
Member

a8m commented Nov 27, 2022

Thanks for opening this, @CyrilBrulebois. Can you elaborate on the use case, where you use it, etc?

Because until now, we have never had a use case where we needed to support Ent in 32-bit architecture, as most servers or developer workstations are 64-bit.

@CyrilBrulebois
Copy link
Contributor Author

Traditionally, Linux distributions have built and made available packages on all the architectures they support.

On Debian, and presumably Ubuntu, golang-* packages are usually built on amd64, and the resulting -dev package (golang-entgo-ent-dev for Ent) contains the source code and is marked as Architecture: all, and can be used as a build dependency on any architecture (amd64, i386, arm*).

That being said, we have autopkgtest runs on various archs (via https://ci.debian.net/), which ensures we run go build and go test on more than just amd64, which might help spot bugs down the road; for example, CrowdSec leverages Ent, and is built for each target architecture.

I agree that 32-bit architectures are getting phased out nowadays, but historical i386 systems or small computers (Raspberry Pi and the like) can still be deployed using 32-bit ARM architectures (armel or armhf, as opposed to arm64).

Regarding the companion #3126's closure, I agree that it's the same topic; I opened two different issues initially to have a build-time vs. run-time granularity. I could fix (or work around) the first one via the patch I attached here, I can't do the same for the second one.

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

No branches or pull requests

2 participants