HouzuoGuo / tiedot

A rudimentary implementation of a basic document (NoSQL) database in Go
BSD 2-Clause "Simplified" License
2.73k stars 258 forks source link

Could not build for 32 bit windows from 64 bit #126

Closed vigneshr6 closed 7 years ago

vigneshr6 commented 7 years ago

Hi, When I try to build my app for 32 bit machine from 64 bit machine,I am getting this error

F:\GoPATH\src\github.com\HouzuoGuo\tiedot\data\collection64.go:6: COL_FILE_GROWTH redeclared in this block previous declaration at F:\GoPATH\src\github.com\HouzuoGuo\tiedot\data\collection32.go:6 F:\GoPATH\src\github.com\HouzuoGuo\tiedot\data\hash64.go:6: HT_FILE_GROWTH redeclared in this block previous declaration at F:\GoPATH\src\github.com\HouzuoGuo\tiedot\data\hash32.go:6 F:\GoPATH\src\github.com\HouzuoGuo\tiedot\data\hash64.go:7: HASH_BITS redeclared in this block previous declaration at F:\GoPATH\src\github.com\HouzuoGuo\tiedot\data\hash32.go:7 F:\GoPATH\src\github.com\HouzuoGuo\tiedot\data\hash64.go:8: INITIAL_BUCKETS redeclared in this block previous declaration at F:\GoPATH\src\github.com\HouzuoGuo\tiedot\data\hash32.go:8 F:\GoPATH\src\github.com\HouzuoGuo\tiedot\data\hash64.go:12: HashKey redeclared in this block previous declaration at F:\GoPATH\src\github.com\HouzuoGuo\tiedot\data\hash32.go:12 F:\GoPATH\src\github.com\HouzuoGuo\tiedot\data\hash64.go:15: constant 3735928559 overflows int

Could u give me a solution for this?

HouzuoGuo commented 7 years ago

just as a temporary workaround, try removing data/collection64.go along with data/hash64.go, does the problem disappear afterwards?

vigneshr6 commented 7 years ago

I think your solution will switch off 64 bit part.So It will work Is there any permanent solution? Because I have to build my app for Windows 32 bit,64 bit and linux 64 bit,32 bit machines. It is an automated process.

HouzuoGuo commented 7 years ago

@archey do you by any chance remember why the build constraint mentions ARM? wasn't it intended for working around 32-bit vs 64-bit integers only? https://github.com/HouzuoGuo/tiedot/blob/master/data/collection64.go#L1

archey commented 7 years ago

The buildconstraints was written so that if it wasnt 64 bit it would error and not build. We added the 32bit code to build on arm and i686 as we were having issues with uint code.

On Feb 28, 2017 2:59 AM, "Howard" notifications@github.com wrote:

@archey https://github.com/archey do you by any chance remember why the build constraint mentions ARM? wasn't it written only for working around 32-bit vs 64-bit integers? https://github.com/HouzuoGuo/tiedot/blob/master/data/collection64.go#L1

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/HouzuoGuo/tiedot/issues/126#issuecomment-282969118, or mute the thread https://github.com/notifications/unsubscribe-auth/AAklhko0aU8qYTE0GJq9OctzDYKc7t8Wks5rg9PqgaJpZM4MNBev .

archey commented 7 years ago

If you don't add !arm as well as !386 to this file it will try to compile this on both 386 and arm, which are both 32bit systems and the code will fail. This constraints allows it to build on x86_64 processors, but it seems to cause issues if they are trying to x-compile 32bit on x86_64.

HouzuoGuo commented 7 years ago

@archey aren't there 64-bit arm processors too? I suppose those systems won't have trouble with using the 64-bit definitions, is that right?

archey commented 7 years ago

@HouzuoGuo possibly, but I was under the impression that all arm was 32bit as their is not a 64bit kernel yet. Let me do some more testing locally and see if I can fix the cross-compile issues.

HouzuoGuo commented 7 years ago

many thanks!

archey commented 7 years ago

@HouzuoGuo in my testing this fixes the issue. @Vigneshr6 please try to rebuild from the latest git master

vigneshr6 commented 7 years ago

Hi @archey , Now it builds 32 bit.But It gives error for 64 bit.

github.com/HouzuoGuo/tiedot/data

F:\GoPATH\src\github.com\HouzuoGuo\tiedot\data\collection.go:39: undefined: COL_ FILE_GROWTH F:\GoPATH\src\github.com\HouzuoGuo\tiedot\data\hashtable.go:38: undefined: HT_FI LE_GROWTH F:\GoPATH\src\github.com\HouzuoGuo\tiedot\data\hashtable.go:48: undefined: INITI AL_BUCKETS F:\GoPATH\src\github.com\HouzuoGuo\tiedot\data\hashtable.go:49: undefined: INITI AL_BUCKETS F:\GoPATH\src\github.com\HouzuoGuo\tiedot\data\hashtable.go:75: undefined: INITI AL_BUCKETS F:\GoPATH\src\github.com\HouzuoGuo\tiedot\data\hashtable.go:114: undefined: Hash Key F:\GoPATH\src\github.com\HouzuoGuo\tiedot\data\hashtable.go:125: undefined: Hash Key F:\GoPATH\src\github.com\HouzuoGuo\tiedot\data\hashtable.go:140: undefined: Hash Key F:\GoPATH\src\github.com\HouzuoGuo\tiedot\data\hashtable.go:165: undefined: Hash Key F:\GoPATH\src\github.com\HouzuoGuo\tiedot\data\hashtable.go:188: undefined: INIT IAL_BUCKETS F:\GoPATH\src\github.com\HouzuoGuo\tiedot\data\hashtable.go:188: too many errors

HouzuoGuo commented 7 years ago

@archey does it make sense to simply use constraint "amd64" in _64 files, and write "!amd64" in _32 files?

archey commented 7 years ago

@HouzuoGuo I tried that and it fails as well, I'll keep testing this is a pain. My apologies for adding this issue to your code

HouzuoGuo commented 7 years ago

@archey no worries at all, I was the one who created the trouble initially.

HouzuoGuo commented 7 years ago

@Vigneshr6 since you have both 32bit and 64bit systems on hand, do you know a proper way to define build constraints so that _32.go files are only compiled on 32bit system, and _64.go files are compiled on 64bit system?

vigneshr6 commented 7 years ago

No @HouzuoGuo . I don't have 32 bit machine.After the latest commit.I can build 32 bit binary from 64 bit machine.But I can't build 64 bit binary from that same machine.

botherder commented 7 years ago

FWIW, I get these same issues when doing a go get with go 1.7.4 from a 64bit Debian.

HouzuoGuo commented 7 years ago

@Vigneshr6 @botherder OK, I am not quite sure how go build constraints work in cross compilation scenario, can anyone of you please educate me on this topic, and hopefully get those build constraints sorted out soonish?

HouzuoGuo commented 7 years ago

@Vigneshr6 @botherder please try again with the latest master at https://github.com/HouzuoGuo/tiedot/commit/96fa90b5e4620f677d2737bc5358329040942adb

vigneshr6 commented 7 years ago

@HouzuoGuo issue solved.Now I can build for win32,win64,linux64 and linux32 from a windows 64bit system. Thanks

HouzuoGuo commented 7 years ago

thanks for confirmation! @archey how does it look for you? are you builds running fine too?

archey commented 7 years ago

@HouzuoGuo works fine for me

HouzuoGuo commented 7 years ago

great, then this issue is resolved.