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

Cannot compile to Mac #10

Open
fujihara opened this issue Oct 25, 2016 · 3 comments
Open

Cannot compile to Mac #10

fujihara opened this issue Oct 25, 2016 · 3 comments

Comments

@fujihara
Copy link

Building scripts failing cause repository for gyp are no more available at http://gyp.googlecode.com/svn/.

Using other repository for gyp (as listed here https://github.com/Homebrew/homebrew-versions/issues/1275#issuecomment-227253831) generate several compiler errors.

@pauldotknopf
Copy link
Owner

What compiler errors are you seeing? Are they with V8, or the interop bindings?

@fujihara
Copy link
Author

Hi Paul, let list it step-by-step.

## 1. My working path
fujihara@Fujiharas-iMac:~/Development/src$ pwd
/Users/fujihara/Development/src

## 2. Get a supported version of V8
git clone https://github.com/v8/v8.git v8-3.17
cd v8-3.17
git checkout tags/3.17.16.2

## 3. Build V8
make dependencies

At this point I get a svn error because http://gyp.googlecode.com/svn/trunk repository was taken offline.

As work around I got the source from an alternative repository as listed on here.

# Clone GYP from alternative repository
git clone https://chromium.googlesource.com/external/gyp.git build/gyp
cd build/gyp
git checkout f7bc250ccc4d619a1cf238db87e5979f89ff36d7
cd ../..

Now I should have the equivalent of revision 1501 of original gyp svn repository.

# Continue to build V8
make native werror=no library=shared soname_version=3.17.16.2 -j4

It output the follow error:

fujihara@Fujiharas-iMac:~/Development/src/v8-3.17$ make native werror=no library=shared soname_version=3.17.16.2 -j4
  CXX(target) /Users/fujihara/Development/src/v8-3.17/out/native/obj.target/preparser_lib/src/cached-powers.o
  CXX(target) /Users/fujihara/Development/src/v8-3.17/out/native/obj.target/preparser_lib/src/conversions.o
  CXX(target) /Users/fujihara/Development/src/v8-3.17/out/native/obj.target/preparser_lib/src/fast-dtoa.o
  CXX(target) /Users/fujihara/Development/src/v8-3.17/out/native/obj.target/preparser_lib/src/fixed-dtoa.o
../src/cached-powers.cc:136:18: error: unused variable 'kCachedPowersLength' [-Werror,-Wunused-const-variable]
static const int kCachedPowersLength = ARRAY_SIZE(kCachedPowers);
                 ^
1 error generated.
make[1]: *** [/Users/fujihara/Development/src/v8-3.17/out/native/obj.target/preparser_lib/src/cached-powers.o] Error 1
make[1]: *** Waiting for unfinished jobs....
In file included from ../src/conversions.cc:32:
In file included from ../src/conversions-inl.h:43:
../src/scanner.h:445:5: error: unused typedef '__StaticAssertTypedef__445' [-Werror,-Wunused-local-typedef]
    STATIC_ASSERT(kCharacterLookaheadBufferSize == 1);
    ^
../src/checks.h:283:30: note: expanded from macro 'STATIC_ASSERT'
#define STATIC_ASSERT(test)  STATIC_CHECK(test)
                             ^
../src/checks.h:251:5: note: expanded from macro 'STATIC_CHECK'
    SEMI_STATIC_JOIN(__StaticAssertTypedef__, __LINE__)
    ^
../src/checks.h:240:32: note: expanded from macro 'SEMI_STATIC_JOIN'
#define SEMI_STATIC_JOIN(a, b) SEMI_STATIC_JOIN_HELPER(a, b)
                               ^
../src/checks.h:241:39: note: expanded from macro 'SEMI_STATIC_JOIN_HELPER'
#define SEMI_STATIC_JOIN_HELPER(a, b) a##b
                                      ^
<scratch space>:56:1: note: expanded from here
__StaticAssertTypedef__445
^
1 error generated.
make[1]: *** [/Users/fujihara/Development/src/v8-3.17/out/native/obj.target/preparser_lib/src/conversions.o] Error 1
make: *** [native] Error 2

To ignore the error unused variable error I edited build/standalone.gypi and set WARNING_CFLAGS

# Edit build/standalone.gypi and set WARNING_CFLAGS at line 206

      'WARNING_CFLAGS': [
        '-Wall',
        '-Wendif-labels',
        '-W',
        '-Wno-unused-parameter',
        '-Wnon-virtual-dtor',
        '-Wno-unused-const-variable',
        '-Wno-unused-local-typedef',
        '-Wno-shift-negative-value',
        '-Wno-tautological-undefined-compare',
        '-Wno-unneeded-internal-declaration',
        '-Wno-unused-function',
      ],

# Run make command again. It will compile with a few warnings. 
make native werror=no library=shared soname_version=3.17.16.2 -j4

#  note that out/native/lib.target/ is not present
cp out/native/libv8.so.3.17.16.2 /usr/local/lib/

## 4. Get VroomJs's version of libvroomjs
cd /Users/$USER/Development/src
git clone https://github.com/pauldotknopf/vroomjs-core.git
cd vroomjs-core
cd native/libVroomJs/

## 5. Build libvroomjs
g++ jscontext.cpp jsengine.cpp managedref.cpp bridge.cpp jsscript.cpp -o libVroomJsNative.so -shared -L /Users/$USER/Development/src/v8-3.17/out/native/ -I /Users/$USER/Development/src/v8-3.17/include/ -fPIC -Wl,--no-as-needed -l:/usr/local/lib/libv8.so.3.17.16.2

It generate several warnings and a link error:

...
/Users/fujihara/Development/src/v8-3.17/include/v8.h:406:22: note: 'Dispose' has been explicitly marked deprecated here
  V8_DEPRECATED(void Dispose());
                     ^
7 warnings generated.
ld: unknown option: --no-as-needed
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Removing --no-as-needed from command line do not solve the problem.

g++ jscontext.cpp jsengine.cpp managedref.cpp bridge.cpp jsscript.cpp -o libVroomJsNative.so -shared -L /Users/$USER/Development/src/v8-3.17/out/native/ -I /Users/$USER/Development/src/v8-3.17/include/ -fPIC -Wl -l:/usr/local/lib/libv8.so.3.17.16.2

...
8 warnings generated.
ld: library not found for -l:/usr/local/lib/libv8.so.3.17.16.2
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Despite the library not found error, the file can be found on the correct location.

fujihara@Fujiharas-iMac:~/Development/src/vroomjs-core/native/libVroomJs$ ll /usr/local/lib/libv8.so.3.17.16.2
-rwxr-xr-x  1 fujihara  admin   7.6M Oct 26 10:12 /usr/local/lib/libv8.so.3.17.16.2*

I got stuck at this point. Can you help me with this issue?

@holmesconan
Copy link

@fujihara Thank you for your method of add options to WARNING_CFLAGS. After successfully build v8 engine, you could create a soft link named libv8.dylib to the libv8.so.xxxx. after that, the libVroomJSNative.so will be successfully created. But I still could not manage the React.NET to load this dynamic library.

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

No branches or pull requests

3 participants