-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Go runtime: Can not compile on 386 by constant overflows int error #2433
Comments
Same here |
@ziflex Is there any fixes? Have the same issue here expr-lang/expr#64 |
Any news on this issue? |
Worth noting that due to this it's impossible to build for armhf as well. |
@pboyer any news? I'm don't want to rewrite parser because of this error :( |
Pending resolution of these issues: - expr-lang/expr#64 - antlr/antlr4#2433
In the event that is helps the next person who reads this: I wrote a quick node script that changed the check from a bitwise check to a more naive one and just have it call it after building the parser code: const fs = require('fs')
const parserPath = ".../path/parser_parser.go"
const parserCode = fs.readFileSync(parserPath, 'utf-8')
const patchedCode = parserCode.replace(/(\(\(1<<uint\(_la\)\)&\([^{]+)/g, match => {
const parts = match.match(/<<([A-Z][^)]+)/g)
return '(' + parts.map(p => `_la == ${p.substr(2)}`).join(' || ') + ')'
})
fs.writeFileSync(parserPath, patchedCode) Seems this fixes the issue in my case. Hope it helps you out too. |
This was also an issue for me, fix for me was to explicitly set the type to int64 pth := `..\yourfilepath.go`
data, err := ioutil.ReadFile(pth)
if err != nil {
logger.Fatalf("Unable to read parser.go: %s", err)
}
str := string(data)
// Need to replace 1 with int64(1) to stop int overflows on 32 bit systems
fixed := strings.Replace(str, "(1<<", "(int64(1)<<", -1)
err = ioutil.WriteFile(pth, []byte(fixed), 0666)
if err != nil {
logger.Fatalf("Unable to save parser.go: %s", err)
} Hopefully that helps someone, it would be better of course to get it fixed in the source. |
Can this be fixed in master? |
Thanks @cubewise-tryan! Works like a charm! Here's the sed version of the workaround:
|
* Workaround to compile for 32bit This is a workaround based on [this comment](antlr/antlr4#2433 (comment)). It is not a pretty solution but it worked well on my test file. It runs once to compile, if make fails, then it apply the fix and try again, this is done so builds that don't need workaround don't use it and also because the workaround is done on top of downloaded files during ethe first compilation. * Update README to remove ARMv7 error comment
Following error is occured when building to GOARCH=386 on Golang runtime.
Source file is here.
Because int value is overflowed, it may fix if changing from int type to int64 type.
(It looks like
_la
variable is overflowed)The text was updated successfully, but these errors were encountered: