SkylerLipthay / mini-v8

A minimal embedded V8 JavaScript engine wrapper for Rust
MIT License
106 stars 11 forks source link

Where to get pre-built V8? #1

Closed caracal7 closed 5 years ago

SkylerLipthay commented 5 years ago

Hi! I haven't yet settled upon an answer to this question. As I understand, the build process for V8 is notoriously complicated.

As I mentioned in the README, this project is heavily inspired by Ruby's MiniRacer gem, which depends on the libv8 gem that contains a pre-built V8. So I ran gem install libv8 and then I can run V8_PATH=/path/to/ruby/gems/libv8-7.3.492.27.1-x86_64-linux/vendor/v8 cargo run --release --example example.

This is silly of course and I hope to find a better alternative soon. Thank you for taking early interest in this crate. It is under active development and I hope to have a 0.1 release within a week or so. Please let me know if you have any thoughts or feedback!

caracal7 commented 5 years ago

I did the same but I manually unpacked gem located here https://rubygems.org/gems/libv8/versions/7.3.492.27.3beta1-x86_64-darwin-18 without install.

Now I tried your way and take the same result

   Compiling mini-v8 v0.1.0 (/Users/caracal/Desktop/mini-v8-master)
error: failed to run custom build command for `mini-v8 v0.1.0 (/Users/caracal/Desktop/mini-v8-master)`

Caused by:
  process didn't exit successfully: `/Users/caracal/Desktop/mini-v8-master/target/debug/build/mini-v8-0199365bb9539840/build-script-build` (exit code: 1)
--- stdout
cargo:rerun-if-changed=src/ffi.cc
cargo:rustc-link-search=native=/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/out.gn/libv8/obj
cargo:rustc-link-lib=static=v8_monolith
-isystem/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include
TARGET = Some("x86_64-apple-darwin")
OPT_LEVEL = Some("0")
HOST = Some("x86_64-apple-darwin")
CXX_x86_64-apple-darwin = None
CXX_x86_64_apple_darwin = None
HOST_CXX = None
CXX = None
CXXFLAGS_x86_64-apple-darwin = None
CXXFLAGS_x86_64_apple_darwin = None
HOST_CXXFLAGS = None
CXXFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
CARGO_CFG_TARGET_FEATURE = Some("cmpxchg16b,fxsr,mmx,sse,sse2,sse3,ssse3")
running: "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-isystem/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include" "-Wno-unused-result" "-pthread" "-L/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/out.gn/libv8/obj" "-lv8_monolith" "-o" "/Users/caracal/Desktop/mini-v8-master/target/debug/build/mini-v8-d2154928c00a31e1/out/src/ffi.o" "-c" "src/ffi.cc"
cargo:warning=clang: warning: -lv8_monolith: 'linker' input unused [-Wunused-command-line-argument]
cargo:warning=clang: warning: argument unused during compilation: '-L/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/out.gn/libv8/obj' [-Wunused-command-line-argument]
cargo:warning=In file included from src/ffi.cc:5:
cargo:warning=In file included from /Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include/libplatform/libplatform.h:9:
cargo:warning=/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include/libplatform/v8-tracing.h:240:3: error: exception specification of overriding function is more lax than base version
cargo:warning=  ~TracingController() override;
cargo:warning=  ^
cargo:warning=/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include/v8-platform.h:124:11: note: overridden virtual function is here
cargo:warning=  virtual ~TracingController() = default;
cargo:warning=          ^
cargo:warning=In file included from src/ffi.cc:5:
cargo:warning=/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include/libplatform/libplatform.h:19:12: error: ISO C++ forbids forward references to 'enum' types
cargo:warning=enum class MessageLoopBehavior : bool {
cargo:warning=           ^
cargo:warning=/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include/libplatform/libplatform.h:19:32: error: expected unqualified-id
cargo:warning=enum class MessageLoopBehavior : bool {
cargo:warning=                               ^
cargo:warning=/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include/libplatform/libplatform.h:42:65: error: expected expression
cargo:warning=    std::unique_ptr<v8::TracingController> tracing_controller = {});
cargo:warning=                                                                ^
cargo:warning=/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include/libplatform/libplatform.h:63:36: error: incomplete type 'v8::platform::MessageLoopBehavior' named in nested name specifier
cargo:warning=    MessageLoopBehavior behavior = MessageLoopBehavior::kDoNotWait);
cargo:warning=                                   ^~~~~~~~~~~~~~~~~~~~~
cargo:warning=In file included from src/ffi.cc:6:
cargo:warning=In file included from /Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include/v8.h:25:
cargo:warning=/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include/v8-internal.h:60:20: error: unknown type name 'constexpr'
cargo:warning=  V8_INLINE static constexpr bool IsValidSmi(intptr_t value) {
cargo:warning=                   ^
cargo:warning=/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include/v8-internal.h:60:30: error: expected member name or ';' after declaration specifiers
cargo:warning=  V8_INLINE static constexpr bool IsValidSmi(intptr_t value) {
cargo:warning=  ~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
cargo:warning=/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include/v8-internal.h:85:20: error: unknown type name 'constexpr'
cargo:warning=  V8_INLINE static constexpr bool IsValidSmi(intptr_t value) {
cargo:warning=                   ^
cargo:warning=/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include/v8-internal.h:85:30: error: expected member name or ';' after declaration specifiers
cargo:warning=  V8_INLINE static constexpr bool IsValidSmi(intptr_t value) {
cargo:warning=  ~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
cargo:warning=/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include/v8-internal.h:107:1: error: unknown type name 'constexpr'
cargo:warning=constexpr bool SmiValuesAre31Bits() { return kSmiValueSize == 31; }
cargo:warning=^
cargo:warning=/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include/v8-internal.h:107:11: error: expected unqualified-id
cargo:warning=constexpr bool SmiValuesAre31Bits() { return kSmiValueSize == 31; }
cargo:warning=          ^
cargo:warning=/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include/v8-internal.h:108:1: error: unknown type name 'constexpr'
cargo:warning=constexpr bool SmiValuesAre32Bits() { return kSmiValueSize == 32; }
cargo:warning=^
cargo:warning=/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include/v8-internal.h:108:11: error: expected unqualified-id
cargo:warning=constexpr bool SmiValuesAre32Bits() { return kSmiValueSize == 32; }
cargo:warning=          ^
cargo:warning=/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include/v8-internal.h:110:18: error: unknown type name 'constexpr'
cargo:warning=V8_INLINE static constexpr internal::Address IntToSmi(int value) {
cargo:warning=                 ^
cargo:warning=/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include/v8-internal.h:110:45: error: expected ';' after top level declarator
cargo:warning=V8_INLINE static constexpr internal::Address IntToSmi(int value) {
cargo:warning=                                            ^
cargo:warning=In file included from src/ffi.cc:6:
cargo:warning=/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include/v8.h:2518:10: error: unknown type name 'constexpr'
cargo:warning=  static constexpr int kMaxLength = internal::kApiTaggedSize == 4
cargo:warning=         ^
cargo:warning=/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include/v8.h:2518:20: error: expected member name or ';' after declaration specifiers
cargo:warning=  static constexpr int kMaxLength = internal::kApiTaggedSize == 4
cargo:warning=  ~~~~~~~~~~~~~~~~ ^
cargo:warning=/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include/v8.h:2681:5: error: exception specification of overriding function is more lax than base version
cargo:warning=    ~ExternalStringResource() override = default;
cargo:warning=    ^
cargo:warning=/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include/v8.h:2616:13: note: overridden virtual function is here
cargo:warning=    virtual ~ExternalStringResourceBase() = default;
cargo:warning=            ^
cargo:warning=/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include/v8.h:2714:5: error: exception specification of overriding function is more lax than base version
cargo:warning=    ~ExternalOneByteStringResource() override = default;
cargo:warning=    ^
cargo:warning=/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include/v8.h:2616:13: note: overridden virtual function is here
cargo:warning=    virtual ~ExternalStringResourceBase() = default;
cargo:warning=            ^
cargo:warning=fatal error: too many errors emitted, stopping now [-ferror-limit=]
cargo:warning=20 errors generated.
exit code: 1

--- stderr

error occurred: Command "c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-isystem/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/include" "-Wno-unused-result" "-pthread" "-L/Library/Ruby/Gems/2.3.0/gems/libv8-7.3.492.27.1-universal-darwin-17/vendor/v8/out.gn/libv8/obj" "-lv8_monolith" "-o" "/Users/caracal/Desktop/mini-v8-master/target/debug/build/mini-v8-d2154928c00a31e1/out/src/ffi.o" "-c" "src/ffi.cc" with args "c++" did not execute successfully (status code exit code: 1).

Maybe it is OSX only problem? Or problem with clang?

SkylerLipthay commented 5 years ago

Try pulling the latest commit (5c7d30a), which adds the -std=c++11 flag. I guess my compiler (gcc) didn't need this flag, but indeed V8 requires C++11 compatibility. I hope this helps, and feel free to play around with build.rs to configure the V8 build step to your environment's needs.

caracal7 commented 5 years ago

Yeeeeeee! You did it) Now I will try on Debian inside docker container