Switching the default Xcode compiler to "apple-gcc42"? (especially for perl Javascript::V8)

728 views Asked by At

Starting points:

  • using Macports for all packages on OS x but perl (e.g. have installed the v8 Macports package)
  • for perl - using perlbrew
  • Javascript::V8 has a known bug - it didn't compiles with the newest Xcode compiler
  • the bugreport mentioning about the working apple-gcc42
  • i have installed from the Macports the "apple-gcc42" package

The question is: what i need to do, for using the compiler contained in "apple-gcc42" Macports package for manually compiling the "Javascript::V8" perl Module?

Now perl Makefile.PL, make using the default g++ what is in /usr/bin - the standard Xcode compiler - so, probably need:

  • somehow switch the compiler to "apple-gcc42" (probably need setup some symlinks, but don't know how/where/what)
  • and/or - change somehow the Makefile.PL
  • will need recompile everything (the perl itself and all other perl modules) with the "apple-gcc42"?

and/or

  • based on @amon's comment - how to switch the OS X to using the "apple-gcc42" as a default compiler for all things, e.g. for the Macport's itself (because the v8 is from the Macports) and for the perlbrew too.

Any idea how to get an working Javascript::V8 perl module on OS X Mavericks and perlbrew?


EDIT

For @Oleg-G - Adding the error output

~/Downloads/javascript-v8-master$ perl Makefile.PL 
Generating a GNU-style Makefile
Writing Makefile for JavaScript::V8
Writing MYMETA.yml and MYMETA.json
~/Downloads/javascript-v8-master$ make
cp lib/JavaScript/V8/Context.pm blib/lib/JavaScript/V8/Context.pm
cp lib/JavaScript/V8.pm blib/lib/JavaScript/V8.pm
g++ -c  -I. -fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/opt/local/include -O3   -DVERSION=\"0.07\" -DXS_VERSION=\"0.07\"  "-I/Users/jm/perl5/perlbrew/perls/perl-5.16.3/lib/5.16.3/darwin-2level/CORE"   V8Context.cpp
V8Context.cpp:132:61: warning: inequality comparison result unused [-Wunused-comparison]
    for (sv_map::const_iterator it = objects.find(hash); it != objects.end(), it->first == hash; it++)
                                                         ~~~^~~~~~~~~~~~~~~~
V8Context.cpp:132:61: note: use '|=' to turn this inequality comparison into an or-assignment
    for (sv_map::const_iterator it = objects.find(hash); it != objects.end(), it->first == hash; it++)
                                                            ^~
                                                            |=
V8Context.cpp:141:34: error: 'New' is a private member of 'v8::PersistentBase<v8::Object>'
    , object(Persistent<Object>::New(object_))
                                 ^
/opt/local/include/v8.h:595:23: note: declared private here
  V8_INLINE static T* New(Isolate* isolate, T* that);
                      ^
V8Context.cpp:141:45: error: too few arguments to function call, expected 2, have 1
    , object(Persistent<Object>::New(object_))
             ~~~~~~~~~~~~~~~~~~~~~~~        ^
/opt/local/include/v8.h:595:3: note: 'New' declared here
  V8_INLINE static T* New(Isolate* isolate, T* that);
  ^
/opt/local/include/v8config.h:305:20: note: expanded from macro 'V8_INLINE'
# define V8_INLINE inline __attribute__((always_inline))
                   ^
V8Context.cpp:167:12: error: no matching member function for call to 'MakeWeak'
    object.MakeWeak(this, PerlObjectData::destroy);
    ~~~~~~~^~~~~~~~
/opt/local/include/v8.h:733:22: note: candidate function [with P = PerlObjectData] not viable: no known conversion from
      'void (Persistent<v8::Value>, void *)' to 'typename WeakReferenceCallbacks<Object, PerlObjectData>::Revivable' (aka 'void
      (*)(v8::Isolate *, Persistent<v8::Object, v8::NonCopyablePersistentTraits<v8::Object> > *, PerlObjectData *)') for 2nd
      argument
      V8_INLINE void MakeWeak(
                     ^
/opt/local/include/v8config.h:336:45: note: expanded from macro 'V8_DEPRECATED'
# define V8_DEPRECATED(message, declarator) declarator
                                            ^
/opt/local/include/v8.h:726:22: note: candidate template ignored: couldn't infer template argument 'S'
      V8_INLINE void MakeWeak(
                     ^
/opt/local/include/v8config.h:336:45: note: expanded from macro 'V8_DEPRECATED'
# define V8_DEPRECATED(message, declarator) declarator
                                            ^
V8Context.cpp:229:40: error: unknown type name 'Arguments'; did you mean 'v8::internal::Arguments'?
    virtual Handle<Value> invoke(const Arguments& args);
                                       ^~~~~~~~~
                                       v8::internal::Arguments
/opt/local/include/v8.h:145:7: note: 'v8::internal::Arguments' declared here
class Arguments;
      ^
V8Context.cpp:252:41: error: unknown type name 'Arguments'; did you mean 'v8::internal::Arguments'?
    static Handle<Value> v8invoke(const Arguments& args) {
                                        ^~~~~~~~~
                                        v8::internal::Arguments
/opt/local/include/v8.h:145:7: note: 'v8::internal::Arguments' declared here
class Arguments;
      ^
V8Context.cpp:237:42: error: member reference type 'Persistent<v8::Function>' is not a pointer
                  context_->make_function->Call(
                  ~~~~~~~~~~~~~~~~~~~~~~~^
V8Context.cpp:253:75: error: no member named 'Unwrap' in 'v8::External'
        PerlFunctionData* data = static_cast<PerlFunctionData*>(External::Unwrap(args[0]));
                                                                ~~~~~~~~~~^
V8Context.cpp:268:32: error: unknown type name 'Arguments'; did you mean 'v8::internal::Arguments'?
PerlFunctionData::invoke(const Arguments& args) {
                               ^~~~~~~~~
                               v8::internal::Arguments
/opt/local/include/v8.h:145:7: note: 'v8::internal::Arguments' declared here
class Arguments;
      ^
V8Context.cpp:277:40: error: unknown type name 'Arguments'; did you mean 'v8::internal::Arguments'?
    virtual Handle<Value> invoke(const Arguments& args);
                                       ^~~~~~~~~
                                       v8::internal::Arguments
/opt/local/include/v8.h:145:7: note: 'v8::internal::Arguments' declared here
class Arguments;
      ^
V8Context.cpp:288:30: error: unknown type name 'Arguments'; did you mean 'v8::internal::Arguments'?
PerlMethodData::invoke(const Arguments& args) {
                             ^~~~~~~~~
                             v8::internal::Arguments
/opt/local/include/v8.h:145:7: note: 'v8::internal::Arguments' declared here
class Arguments;
      ^
V8Context.cpp:311:28: error: too few arguments to function call, at least argument 'isolate' must be specified
    context = Context::New();
              ~~~~~~~~~~~~ ^
/opt/local/include/v8.h:5206:3: note: 'New' declared here
  static Local<Context> New(
  ^
V8Context.cpp:313:20: error: no matching constructor for initialization of 'Context::Scope'
    Context::Scope context_scope(context);
                   ^             ~~~~~~~
/opt/local/include/v8.h:5317:9: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from
      'Persistent<v8::Context>' to 'const v8::Context::Scope' for 1st argument
  class Scope {
        ^
/opt/local/include/v8.h:5319:24: note: candidate constructor not viable: no known conversion from 'Persistent<v8::Context>' to
      'Handle<v8::Context>' for 1st argument
    explicit V8_INLINE Scope(Handle<Context> context) : context_(context) {
                       ^
/opt/local/include/v8.h:5324:19: note: candidate constructor not viable: requires 2 arguments, but 1 was provided
        V8_INLINE Scope(Isolate* isolate, Persistent<Context>& context)) // NOLINT
                  ^
/opt/local/include/v8config.h:336:45: note: expanded from macro 'V8_DEPRECATED'
# define V8_DEPRECATED(message, declarator) declarator
                                            ^
V8Context.cpp:314:17: error: calling a private constructor of class 'v8::HandleScope'
    HandleScope handle_scope;
                ^
/opt/local/include/v8.h:874:13: note: declared private here
  V8_INLINE HandleScope() {}
            ^
V8Context.cpp:317:12: error: member reference type 'Persistent<v8::Context>' is not a pointer
    context->Global()->Set(
    ~~~~~~~^
V8Context.cpp:333:43: error: 'New' is a private member of 'v8::PersistentBase<v8::Function>'
    make_function = Persistent<Function>::New(Handle<Function>::Cast(script->Run()));
                                          ^
/opt/local/include/v8.h:595:23: note: declared private here
  V8_INLINE static T* New(Isolate* isolate, T* that);
                      ^
V8Context.cpp:333:84: error: too few arguments to function call, expected 2, have 1
    make_function = Persistent<Function>::New(Handle<Function>::Cast(script->Run()));
                    ~~~~~~~~~~~~~~~~~~~~~~~~~                                      ^
/opt/local/include/v8.h:595:3: note: 'New' declared here
  V8_INLINE static T* New(Isolate* isolate, T* that);
  ^
/opt/local/include/v8config.h:305:20: note: expanded from macro 'V8_INLINE'
# define V8_INLINE inline __attribute__((always_inline))
                   ^
V8Context.cpp:335:39: error: 'New' is a private member of 'v8::PersistentBase<v8::String>'
    string_wrap = Persistent<String>::New(String::New("wrap"));
                                      ^
/opt/local/include/v8.h:595:23: note: declared private here
  V8_INLINE static T* New(Isolate* isolate, T* that);
                      ^
V8Context.cpp:335:62: error: too few arguments to function call, expected 2, have 1
    string_wrap = Persistent<String>::New(String::New("wrap"));
                  ~~~~~~~~~~~~~~~~~~~~~~~                    ^
/opt/local/include/v8.h:595:3: note: 'New' declared here
  V8_INLINE static T* New(Isolate* isolate, T* that);
  ^
/opt/local/include/v8config.h:305:20: note: expanded from macro 'V8_INLINE'
# define V8_INLINE inline __attribute__((always_inline))
                   ^
V8Context.cpp:342:17: error: member reference type 'Persistent<v8::Object>' is not a pointer
    data->object->SetHiddenValue(string_wrap, External::Wrap(data));
    ~~~~~~~~~~~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
1 warning and 20 errors generated.
make: *** [V8Context.o] Error 1
~/Downloads/javascript-v8-master$ 

about g++

~/Downloads/javascript-v8-master$ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix

my perl

~/Downloads/javascript-v8-master$ perl -V
Summary of my perl5 (revision 5 version 16 subversion 3) configuration:

  Platform:
    osname=darwin, osvers=12.3.0, archname=darwin-2level
    uname='darwin jonatan.local 12.3.0 darwin kernel version 12.3.0: sun jan 6 22:37:10 pst 2013; root:xnu-2050.22.13~1release_x86_64 x86_64 '
    config_args='-de -Dprefix=/Users/jm/perl5/perlbrew/perls/perl-5.16.3 -Aeval:scriptdir=/Users/jm/perl5/perlbrew/perls/perl-5.16.3/bin'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/opt/local/include',
    optimize='-O3',
    cppflags='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/opt/local/include'
    ccversion='', gccversion='4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector -L/usr/local/lib -L/opt/local/lib'
    libpth=/usr/local/lib /opt/local/lib /usr/lib
    libs=-lgdbm -ldbm -ldl -lm -lutil -lc
    perllibs=-ldl -lm -lutil -lc
    libc=, so=dylib, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -L/opt/local/lib -fstack-protector'


Characteristics of this binary (from libperl): 
  Compile-time options: HAS_TIMES PERLIO_LAYERS PERL_DONT_CREATE_GVSV
                        PERL_MALLOC_WRAP PERL_PRESERVE_IVUV USE_64_BIT_ALL
                        USE_64_BIT_INT USE_LARGE_FILES USE_LOCALE
                        USE_LOCALE_COLLATE USE_LOCALE_CTYPE
                        USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF
  Built under darwin
  Compiled at Jun  1 2013 23:48:00
  %ENV:
    PERLBREW_BASHRC_VERSION="0.63"
    PERLBREW_HOME="/Users/jm/.perlbrew"
    PERLBREW_MANPATH="/Users/jm/perl5/perlbrew/perls/perl-5.16.3/man"
    PERLBREW_PATH="/Users/jm/perl5/perlbrew/bin:/Users/jm/perl5/perlbrew/perls/perl-5.16.3/bin"
    PERLBREW_PERL="perl-5.16.3"
    PERLBREW_ROOT="/Users/jm/perl5/perlbrew"
    PERLBREW_VERSION="0.63"
  @INC:
    /Users/jm/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/darwin-2level
    /Users/jm/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3
    /Users/jm/perl5/perlbrew/perls/perl-5.16.3/lib/5.16.3/darwin-2level
    /Users/jm/perl5/perlbrew/perls/perl-5.16.3/lib/5.16.3
    .
~/Downloads/javascript-v8-master$ 

the v8 is from Macports

~/Downloads/javascript-v8-master$ v8
V8 version 3.23.15 [console: dumb]
d8> 

~/Downloads/javascript-v8-master$ port contents v8
Port v8 contains:
  /opt/local/bin/v8
  /opt/local/include/v8-debug.h
  /opt/local/include/v8-platform.h
  /opt/local/include/v8-profiler.h
  /opt/local/include/v8-testing.h
  /opt/local/include/v8.h
  /opt/local/include/v8config.h
  /opt/local/include/v8stdint.h
  /opt/local/lib/libv8.dylib
  /opt/local/share/doc/v8/AUTHORS
  /opt/local/share/doc/v8/ChangeLog
  /opt/local/share/doc/v8/LICENSE
  /opt/local/share/doc/v8/LICENSE.strongtalk
  /opt/local/share/doc/v8/LICENSE.v8
  /opt/local/share/doc/v8/LICENSE.valgrind
~/Downloads/javascript-v8-master$ 
1

There are 1 answers

6
Oleg G On

Try version from this repo: https://github.com/olegwtf/javascript-v8

It should compile with your OS X compiler