LayerTwo-Labs / ethereum-sidechain

Ethereum sidechain implementation based on geth.
GNU Lesser General Public License v3.0
3 stars 3 forks source link

build: add windows support #8

Closed torkelrogstad closed 8 months ago

torkelrogstad commented 10 months ago

Turns out there's more differences in cgo bindings between macOS, Linux and Windows. Instead of mucking around and trying to decipher the madness, we shove all differentiating cgo calls into separate calls for each platform.

Notes for getting Windows to build:

  1. libdl.a is not present on Windows by default, and this is needed for the Rust code to be used.
  2. There's an implementation of this available here: https://github.com/dlfcn-win32/dlfcn-win32
  3. This needs to be compiled and placed onto a place where ld can find it.
  4. WARNING: I have no idea what I'm doing here, I'm not a Windows guy. Might be a strange way of handling this.
  5. Clone the repo
  6. Open up a bash shell (NOT through WSL, but a native Windows bash)
  7. ./configure --prefix=/ --libdir=$PWD/libdir --incdir=$PWD/incdir && make
  8. This results in the file ./libdir/libdl.a. Place this file in a place ld can find it.
  9. For me, a path that worked was C:\ProgramData\mingw64\mingw64\lib
torkelrogstad commented 10 months ago

Suffixing a file is like an implicit build constraint. It's mentioned in the docs you linked:

If a file's name, after stripping the extension and a possible _test suffix, matches any of the following patterns:

_GOOS _GOARCH *_GOOS_GOARCH

(example: source_windows_amd64.go) where GOOS and GOARCH represent any known operating system and architecture values respectively, then the file is considered to have an implicit build constraint requiring those terms (in addition to any explicit constraints in the file).