Skip to content

Commit

Permalink
Support MSYS2 MinGW64 builds (#46)
Browse files Browse the repository at this point in the history
* Support MSYS2 MinGW64 builds

* Update README.md to include instructions for setting up
Windows dev environments

* Update README.md

Co-authored-by: Roger Chapman <[email protected]>

* Switch up #cgo flags to match master

* Use correct syntax for #cgo constraints

Co-authored-by: neptoess <[email protected]>
Co-authored-by: Roger Chapman <[email protected]>
  • Loading branch information
3 people authored Dec 17, 2020
1 parent 0a50c71 commit 2a13784
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ are included for Linux and OSX ie. you *should not* require to build V8 yourself

V8 requires 64-bit, therefore will not work on 32-bit systems.

## Windows
While no prebuilt static V8 library is included for Windows, MSYS2 provides a package containing
a dynamically linked V8 library that works.

To set this up:
1. Install MSYS2 (https://www.msys2.org/)
2. Add the Mingw-w64 bin to your PATH environment variable (`C:\msys64\mingw64\bin` by default)
3. Open MSYS2 MSYS and execute `pacman -S mingw-w64-x86_64-toolchain mingw-w64-x86_64-v8`
4. This will allow building projects that depend on `v8go`, but, in order to actually run them,
you will need to copy the `snapshot_blob.bin` file from the Mingw-w64 bin folder to your program's
working directory (which is typically wherever `main.go` is)

---

V8 Gopher image based on original artwork from the amazing [Renee French](http://reneefrench.blogspot.com).
4 changes: 3 additions & 1 deletion cgo.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package v8go

// #cgo CXXFLAGS: -fno-rtti -fpic -std=c++14 -I${SRCDIR}/deps/include -DV8_COMPRESS_POINTERS -DV8_31BIT_SMIS_ON_64BIT_ARCH
// #cgo CXXFLAGS: -fno-rtti -fpic -std=c++14 -DV8_COMPRESS_POINTERS -DV8_31BIT_SMIS_ON_64BIT_ARCH
// #cgo darwin linux CXXFLAGS: -I${SRCDIR}/deps/include
// #cgo LDFLAGS: -pthread -lv8
// #cgo windows LDFLAGS: -lv8_libplatform
// #cgo darwin LDFLAGS: -L${SRCDIR}/deps/darwin-x86_64
// #cgo linux LDFLAGS: -L${SRCDIR}/deps/linux-x86_64
import "C"
3 changes: 3 additions & 0 deletions v8go.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ extern "C"
/********** Isolate **********/

void Init() {
#ifdef _WIN32
V8::InitializeExternalStartupData(".");
#endif
V8::InitializePlatform(default_platform.get());
V8::Initialize();
return;
Expand Down

0 comments on commit 2a13784

Please sign in to comment.