Build failures on 32-bit archs: int overflows
- Dominant language
- Go
- Stars
- 17.2k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
- [x] The issue is present in the latest release: 0.11.4
- [x] I have searched the [issues](https://github.com/ent/ent/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](https://github.com/ent/ent/files/10098437/0003-avoid-overflows-on-32-bit-systems.patch.txt)
Contributor guide
Assessment
This issue has not been assessed yet.