0

I am currently trying to build Google's V8 engine, following its official documents.

And I get some errors here:

  1. Need a newer glibc
    python ../../tools/run.py ./bytecode_builtins_list_generator gen/builtins-generated/bytecodes-builtins-list.h
    ./bytecode_builtins_list_generator: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./bytecode_builtins_list_generator)
    Return code is 1
    [115/1639] CXX obj/torque_base/torque-parser.o
    
  2. Some C++14 grammar Such as in include/v8-internal.h, there is a std::remove_cv_t
    template <class T>
    V8_INLINE void PerformCastCheck(T* data) {
      CastCheck<std::is_base_of<Data, T>::value &&
                !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
    }
    

When looking into its building procedure, I find it actually uses third_party/llvm-build/Release+Asserts/bin/clang++ with a -std=c++14 flag.

So I am wondering if I can build a V8 engine with some old gcc, like gcc 4.4.6/4.8.5?

calvin
  • 2,125
  • 2
  • 21
  • 38
  • The first error is just some precompiled utility that was built on a newer version of Linux – Alan Birtles Nov 10 '20 at 13:20
  • why do you need to work with such ancient gcc versions? – phuclv Nov 10 '20 at 15:17
  • @phuclv Because I need to embed v8 into a old project which compiles with such old gcc – calvin Nov 11 '20 at 02:20
  • @calvin people stick to old GCC usually because the new libc isn't available on the target. So you can try to compile with new gcc and link the libc statically, or distribute the new libc's .so files – phuclv Nov 11 '20 at 02:24

2 Answers2

2

Yes, V8 currently requires C++14.

Expect future changes to be in the direction of requiring C++17 (though there's no timeline for that yet), rather than going back to older C++ standards.

jmrk
  • 34,271
  • 7
  • 59
  • 74
  • So if I can only use gcc 4.8.5/4.4.6, I can only compile some old version of v8? How can I identify with version compacts with my gcc? – calvin Nov 10 '20 at 13:19
  • I don't know how to switch to a certain branch of v8, should I simply run `git checkout`? – calvin Nov 10 '20 at 13:34
  • 3
    Yes, you can use `git checkout` to check out old versions. You'll probably have to run `gclient sync` afterwards. Obligatory warning: old versions typically contain known bugs, including exploitable security bugs, so you should not use them to execute code you haven't written yourself. I don't know what the last version was that compiled with GCC 4.x, sorry. – jmrk Nov 10 '20 at 14:03
  • It is possible that I can `git bisect` the whole `master` branch? – calvin Nov 11 '20 at 02:19
  • Hi, when I look into old versions of V8, I find it has different build process, for example, it provides a Makefile, rather than currently ninja. However, I still can't find a way to build v8's statis library `v8_monolith`. – calvin Nov 11 '20 at 03:29
  • 1
    Yes, you can `git bisect` the entire history of V8; though as you already noticed, some things have changed over time. The official docs you linked indicate that the 7.1 branch (~2 years old) still compiled with GCC 4.8, so you can start the bisection there. I don't think the build system has changed much since then. As an alternative, you can simply use the bundled Clang, or spend your time on updating your GCC instead. – jmrk Nov 11 '20 at 13:35
  • I tried with branch 2558, after modified some gyp files I can now compile with gcc 4.8. Moreover, I don't know if it still compiles with gcc 4.4.6, because V8's document at that moment has not guarantee so. My question is, if branch 2558 not works, can I try to find an older branch, or V8 just can't compile wieh gcc before 4.8, and I don't need to waste time here? – calvin Nov 12 '20 at 02:30
  • There are certainly old V8 versions that can be compiled with GCC 4.4. That was the default GCC in Ubuntu Trusty/14.04 after all, so V8 versions from around 2014-2016 probably compile fine with it. As I said before, I don't recommend using such old versions though; updating your toolchain is probably a better investment of your time. – jmrk Nov 12 '20 at 13:29
1

Unfortunately, you can't build C++14 code with older gcc.

As here shown, you can build C++14 with gcc 5.0, which is C++14 compliant.

EDIT: Actually it would be easier to download gcc 5.0 on your platform and compile it with your current gcc version and then compile V8 with this newer compiler.

madduci
  • 2,635
  • 1
  • 32
  • 51
  • 1
    My question is if I can build V8 with my old gcc, for example, if there exists some compile flags that disable all c++14 codes. – calvin Nov 10 '20 at 13:18
  • unfortunately not, but if you have the code, you can modify it by yourself with the #ifdef guards in the parts where you want to deactivate it. The _cplusplus macro has value 201402L for C++14. – madduci Nov 12 '20 at 04:32
  • So, is there any js engine you know that supports g++4.4.6? – calvin Nov 12 '20 at 07:34
  • unfortunately no – madduci Nov 13 '20 at 14:20