Skip to content
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

Support compiling with newer v8 #17

Closed
srakitnican opened this issue Mar 8, 2017 · 19 comments
Closed

Support compiling with newer v8 #17

srakitnican opened this issue Mar 8, 2017 · 19 comments

Comments

@srakitnican
Copy link

srakitnican commented Mar 8, 2017

Edit: This ticket is about supporting newer v8 versions.

scons: Configure: Checking for C++ header file v8.h... 
.sconf_temp/conftest_23.cpp <-
  |
  |#include "v8.h"
  |
  |
g++ -o .sconf_temp/conftest_23.o -c -std=gnu++98 -O3 -funroll-loops -DNDEBUG -D_REENTRANT -DHAVE_PTHREADS -DHAVE_LIBSQLITE -DHAVE_OPENSSL .sconf_temp/conftest_23.cpp
In file included from .sconf_temp/conftest_23.cpp:2:0:
/usr/include/v8.h:345:1: error: expected unqualified-id before 'using'
 using Handle = Local<T>;
 ^~~~~
/usr/include/v8.h: In constructor 'v8::MaybeLocal<T>::MaybeLocal()':
/usr/include/v8.h:362:33: error: 'nullptr' was not declared in this scope
   V8_INLINE MaybeLocal() : val_(nullptr) {}
                                 ^~~~~~~
/usr/include/v8.h: In member function 'bool v8::MaybeLocal<T>::IsEmpty() const':
/usr/include/v8.h:369:51: error: 'nullptr' was not declared in this scope
   V8_INLINE bool IsEmpty() const { return val_ == nullptr; }
                                                   ^~~~~~~
/usr/include/v8.h: In member function 'bool v8::MaybeLocal<T>::ToLocal(v8::Local<S>*) const':
/usr/include/v8.h:373:29: error: 'nullptr' was not declared in this scope
     out->val_ = IsEmpty() ? nullptr : this->val_;
                             ^~~~~~~
/usr/include/v8.h: In member function 'bool v8::WeakCallbackInfo<T>::IsFirstPass() const':
/usr/include/v8.h:441:25: error: 'nullptr' was not declared in this scope
     return callback_ != nullptr;
                         ^~~~~~~
/usr/include/v8.h: At global scope:
/usr/include/v8.h:809:26: error: expected ',' or '...' before '&&' token
   V8_INLINE Global(Global&& other) : PersistentBase<T>(other.val_) {  // NOLINT
                          ^~
/usr/include/v8.h:809:34: error: invalid constructor; you probably meant 'v8::Global<T> (const v8::Global<T>&)'
   V8_INLINE Global(Global&& other) : PersistentBase<T>(other.val_) {  // NOLINT
                                  ^
/usr/include/v8.h:817:40: error: expected ',' or '...' before '&&' token
   V8_INLINE Global& operator=(Global<S>&& rhs) {  // NOLINT
                                        ^~
/usr/include/v8.h: In constructor 'v8::Global<T>::Global()':
/usr/include/v8.h:785:42: error: 'nullptr' was not declared in this scope
   V8_INLINE Global() : PersistentBase<T>(nullptr) {}
                                          ^~~~~~~
/usr/include/v8.h: In member function 'v8::Global<T>& v8::Global<T>::operator=(v8::Global<S>)':
/usr/include/v8.h:819:18: error: 'rhs' was not declared in this scope
     if (this != &rhs) {
                  ^~~
/usr/include/v8.h:822:18: error: 'nullptr' was not declared in this scope
       rhs.val_ = nullptr;
                  ^~~~~~~
/usr/include/v8.h: In member function 'v8::Global<T> v8::Global<T>::Pass()':
/usr/include/v8.h:829:44: error: expected '>' before '&&' token
   Global Pass() { return static_cast<Global&&>(*this); }  // NOLINT
                                            ^~
/usr/include/v8.h:829:44: error: expected '(' before '&&' token
/usr/include/v8.h:829:46: error: expected identifier before '>' token
   Global Pass() { return static_cast<Global&&>(*this); }  // NOLINT
                                              ^
/usr/include/v8.h:829:54: error: expected ')' before ';' token
   Global Pass() { return static_cast<Global&&>(*this); }  // NOLINT
                                                      ^
/usr/include/v8.h: At global scope:
/usr/include/v8.h:847:1: error: expected unqualified-id before 'using'
 using UniquePersistent = Global<T>;
 ^~~~~
In file included from /usr/include/v8.h:25:0,
                 from .sconf_temp/conftest_23.cpp:2:
/usr/include/v8.h:1084:10: error: 'nullptr' was not declared in this scope
   static V8_DEPRECATE_SOON(
          ^
In file included from .sconf_temp/conftest_23.cpp:2:0:
/usr/include/v8.h:1090:30: error: 'nullptr' was not declared in this scope
       ScriptOrigin* origin = nullptr);
                              ^~~~~~~
/usr/include/v8.h:2291:42: error: 'v8::NewStringType' is not a class or namespace
     kNormalString = static_cast<int>(v8::NewStringType::kNormal),
                                          ^~~~~~~~~~~~~
/usr/include/v8.h:2292:48: error: 'v8::NewStringType' is not a class or namespace
     kInternalizedString = static_cast<int>(v8::NewStringType::kInternalized)
                                                ^~~~~~~~~~~~~
/usr/include/v8.h: In member function 'v8::MaybeLocal<v8::Object> v8::Function::NewInstance(v8::Local<v8::Context>) const':
/usr/include/v8.h:3261:36: error: 'nullptr' was not declared in this scope
     return NewInstance(context, 0, nullptr);
                                    ^~~~~~~
/usr/include/v8.h: At global scope:
/usr/include/v8.h:3523:38: error: 'ArrayBufferCreationMode' is not a class or namespace
       ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized);
                                      ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/v8.h:3886:38: error: 'ArrayBufferCreationMode' is not a class or namespace
       ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized);
                                      ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/v8.h:4482:57: error: 'nullptr' was not declared in this scope
       experimental::FastAccessorBuilder* fast_handler = nullptr,
                                                         ^~~~~~~
/usr/include/v8.h:4498:57: error: 'nullptr' was not declared in this scope
       experimental::FastAccessorBuilder* fast_handler = nullptr);
                                                         ^~~~~~~
/usr/include/v8.h:4590:36: error: 'PropertyHandlerFlags' is not a class or namespace
       PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
                                    ^~~~~~~~~~~~~~~~~~~~
/usr/include/v8.h:4618:36: error: 'PropertyHandlerFlags' is not a class or namespace
       PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
                                    ^~~~~~~~~~~~~~~~~~~~
/usr/include/v8.h: In member function 'void v8::ObjectTemplate::SetIndexedPropertyHandler(v8::IndexedPropertyGetterCallback, v8::IndexedPropertySetterCallback, v8::IndexedPropertyQueryCallback, v8::IndexedPropertyDeleterCallback, v8::IndexedPropertyEnumeratorCallback, v8::Local<v8::Value>)':
/usr/include/v8.h:4750:77: error: call to 'v8::IndexedPropertyHandlerConfiguration::IndexedPropertyHandlerConfiguration(v8::IndexedPropertyGetterCallback, v8::IndexedPropertySetterCallback, v8::IndexedPropertyQueryCallback, v8::IndexedPropertyDeleterCallback, v8::IndexedPropertyEnumeratorCallback, v8::Local<v8::Value>, v8::PropertyHandlerFlags)' uses the default argument for parameter 7, which is not yet defined
                                                    deleter, enumerator, data));
                                                                             ^
In file included from /usr/include/v8.h:25:0,
                 from .sconf_temp/conftest_23.cpp:2:
/usr/include/v8.h: In member function 'v8::Local<T> v8::MaybeLocal<T>::ToLocalChecked()':
/usr/include/v8.h:7522:7: error: 'nullptr' was not declared in this scope
   if (V8_UNLIKELY(val_ == nullptr)) V8::ToLocalEmpty();
       ^
In file included from .sconf_temp/conftest_23.cpp:2:0:
/usr/include/v8.h: In member function 'void v8::Template::Set(v8::Isolate*, const char*, v8::Local<v8::Data>)':
/usr/include/v8.h:7961:46: error: 'NewStringType' is not a class or namespace
   Set(v8::String::NewFromUtf8(isolate, name, NewStringType::kNormal)
                                              ^~~~~~~~~~~~~
/usr/include/v8.h: In member function 'v8::Local<v8::Value> v8::Object::GetInternalField(int)':
/usr/include/v8.h:7975:8: error: 'instance_type' does not name a type
   auto instance_type = I::GetInstanceType(obj);
        ^~~~~~~~~~~~~
/usr/include/v8.h:7976:7: error: 'instance_type' was not declared in this scope
   if (instance_type == I::kJSObjectType ||
       ^~~~~~~~~~~~~
/usr/include/v8.h: In member function 'void* v8::Object::GetAlignedPointerFromInternalField(int)':
/usr/include/v8.h:7995:8: error: 'instance_type' does not name a type
   auto instance_type = I::GetInstanceType(obj);
        ^~~~~~~~~~~~~
In file included from /usr/include/v8.h:25:0,
                 from .sconf_temp/conftest_23.cpp:2:
/usr/include/v8.h:7996:7: error: 'instance_type' was not declared in this scope
   if (V8_LIKELY(instance_type == I::kJSObjectType ||
       ^
scons: Configure: no

scons: Configure: Need C++ header v8.h
scons: Configure: (cached) error: no result

v8-devel-5.2.258-7.fc25.x86_64

@srakitnican
Copy link
Author

srakitnican commented Mar 8, 2017

It seems that with v8-314-devel could work, but it is not able to find it since it installs into its own sub-directory in /usr/include/. Any way of telling it to search into sub-directory? Such as passing arguments to compiler, e.g. "-I/usr/include/v8-3.14"

EDIT: So I've managed to make it find it by modifying source code:

sed -i 's|v8\.h|v8-3\.14/v8\.h|' config/v8/__init__.py
sed -i 's|v8\.h|v8-3\.14/v8\.h|' src/cbang/v8/V8.h

@jcoffland
Copy link
Member

This this v8: https://github.com/CauldronDevelopmentLLC/v8-3.14.5/ and set V8_HOME rather than installing v8.

The errors in your first message, such as: error: 'nullptr' was not declared in this scope are caused by using a newer v8 which needs C++ 11 support. C++ 11 can be enabled by adding cxxstd=c++11 to your scons command line.

@srakitnican
Copy link
Author

cxxstd=c++11 or cxxstd=gnu++11 solves original issue, but then there is another issue when compiling with newer version, libcbang-gnu++11-c++11.txt.

I would prefer to use distribution version if possible. So I've figured I can also specify CXXFLAGS on scons command line by using ccflags="-I/usr/include/v8-3.14/".

This issue may be closed as far as I am concerned, unless you want to make it work with newer V8 library which would be nice.

@jcoffland jcoffland changed the title Unable to verify v8.h Support compiling with newer v8 Mar 9, 2017
@jcoffland
Copy link
Member

I did have it working with newer versions of v8 at one point but the API is quite different and I still need to support the older versions because that's what is on Debian and the older versions are much easier to compile on Windows.

@l29ah
Copy link

l29ah commented Mar 29, 2018

Are you going to rebase your recent work on top of the newer-v8 branch?

@jcoffland
Copy link
Member

Google has really made a mess of the v8 build system. They don't seem to care if they make things difficult for projects which depend on v8 as long as it works well within Chrome's monstrous build system. There aren't any major advantages to moving to the newer v8 for cbang or CAMotics so at this point. No plans to move to the newer v8.

@l29ah
Copy link

l29ah commented Mar 29, 2018

Gentoo's security advisories tell that the v8 version used atm contains multiple vulnerabilities. Not sure if v8 handles any potentially hostile data in CAMotics, tho.

@jcoffland
Copy link
Member

CAMotics is not exposed to the Web so we don't have the same security concerns. The only time CAMoitcs executes JavaScript is when you run a TPL program. These programs are not intended to be sandboxed in the way JavaScript is sandboxed on the Web. It's more like running a Python program locally.

@hpmachining
Copy link
Contributor

The last time I built the latest cbang was almost a year ago and I was using V8 6.8. That isn't working anymore. What version of V8 are you using now?

@jcoffland
Copy link
Member

I'm using the version that comes with libnode-dev because that's what's packaged on Debian. It's currently version 7.8.

jcoffland added a commit that referenced this issue Jan 27, 2021
jcoffland added a commit that referenced this issue Jan 27, 2021
@jcoffland
Copy link
Member

@hpmachining I added an ifdef that should allow cbang to build with v8 version 6.x too.

@hpmachining
Copy link
Contributor

Thanks. I still have an error with 6.8.

src/cbang/js/v8/Value.h:138:61: error: no matching function for call to ‘v8::String::Utf8Length(v8::Isolate*)’
  138 |         return v8::String::Cast(*value)->Utf8Length(getIso());
      |                                                             ^
In file included from src/cbang/js/v8/V8.h:43,
                 from src/cbang/js/v8/Value.h:35,
                 from src/cbang/js/v8/ValueRef.h:35,
                 from src/cbang/js/v8/JSImpl.h:35,
                 from src/cbang/js/Javascript.cpp:40:
/usr/include/v8.h:2675:7: note: candidate: ‘int v8::String::Utf8Length() const’
 2675 |   int Utf8Length() const;
      |       ^~~~~~~~~~
/usr/include/v8.h:2675:7: note:   candidate expects 0 arguments, 1 provided

I'll look into building 7.8 when I get some time. Thanks again!

@jcoffland
Copy link
Member

Is that the only error? It could easily be ifdefd around. Could you try manually changing that line of code to this?:

return v8::String::Cast(*value)->Utf8Length();

If there were just a few of these it might be worth supporting the older version.

@hpmachining
Copy link
Contributor

That worked! Thanks.

@hpmachining
Copy link
Contributor

I've been working on building with the current v8 (9.0) because I was having issues rebuilding the older v8 against the latest icu (68.2). I was able to build cbang by adding cxxstd=c++14 when invoking scons. Without that, cbang didn't recognize the v8 installation.
However, I am not able to build the latest camotics with this build. Should I create an issue in the camotics repository or should I just post the details here? I was hoping you may have some ideas on how to fix.

@jcoffland
Copy link
Member

Create an issue in CAMotics with the build errors. I think I was able to build CAMotics with cxxstd=c++14 at one point.

@hpmachining
Copy link
Contributor

It looks like an API change is coming in V8 version 10. See this link: V8 API changes - Ongoing and Planned Changes

I am getting this error trying to build against it:

src/cbang/js/v8/Context.cpp:53:34: error: no matching function for call to ‘v8::ScriptOrigin::ScriptOrigin(v8::Local<v8::String>&)’
   53 |   v8::ScriptOrigin sOrigin(origin);
      |                                  ^
In file included from /usr/include/v8-script.h:17,
                 from /usr/include/v8-debug.h:10,
                 from /usr/include/v8.h:29,
                 from src/cbang/js/v8/V8.h:45,
                 from src/cbang/js/v8/Value.h:35,
                 from src/cbang/js/v8/Context.h:35,
                 from src/cbang/js/v8/Context.cpp:33:
/usr/include/v8-message.h:64:13: note: candidate: ‘v8::ScriptOrigin::ScriptOrigin(v8::Isolate*, v8::Local<v8::Value>, int, int, bool, int, v8::Local<v8::Value>, bool, bool, bool, v8::Local<v8::Data>)’
   64 |   V8_INLINE ScriptOrigin(Isolate* isolate, Local<Value> resource_name,
      |             ^~~~~~~~~~~~
/usr/include/v8-message.h:64:13: note:   candidate expects 11 arguments, 1 provided

I think an Isolate* needs to be added to the call before origin. Do you think you can help me out with a patch for this for testing? I don't know if there are other issues until I get past this error.

jcoffland added a commit that referenced this issue Mar 27, 2022
jcoffland added a commit that referenced this issue Mar 27, 2022
@jcoffland
Copy link
Member

Does the commit I just made work?

@hpmachining
Copy link
Contributor

hpmachining commented Mar 27, 2022

Yes, that worked. Thank you. It builds complete without error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants