Giter Club home page Giter Club logo

Comments (28)

rdnetto avatar rdnetto commented on June 15, 2024 1

Success! It turns out that libc++abi was a red herring - the real issue is that the LLVM release tarball for Ubuntu/Linux was compiled against libstdc++, and the static libraries (*.a) from it were being linked into the same .so as the libc++ code. (libc++ and libstdc++ have different ABIs, and use different symbols to prevent runtime crashes if accidentally mixed, as was the case here.) The solution is therefore to compile LLVM from source so that it uses libc++ as well.

It might not be a bad idea to add an option to the build system to automatically download and compile LLVM from source with the same compiler and flags as color_coded, as it would be much more robust than the current approach. It wouldn't have to be the default, but it would be a useful go-to option for people having issues getting the plugin working. LLVM has separate releases for Ubuntu, Fedora, and OpenSuse, so it seems likely that users of the latter two might run into issues.

At the very least, adding a stage to the build process to ensure that lua can load the module would make this problem more obvious to those affected by it, since currently the vimscript doesn't differentiate between not finding color_coded.so and failing to load it.

Instructions for compiling using clang

  1. Install clang and libc++ (sys-libs/libcxx under Gentoo).

  2. Apply this patch to /usr/include/c++/v1/cstddef. If you do not do this, you will get the error Allocator.h:421:65: error: 'S' does not refer to a value when compiling LLVM.

  3. Download and compile LLVM. Note that we only compile the part actually used by color_coded. This will require about 1 GB of free space.

    cd /tmp
    wget http://llvm.org/releases/3.6.0/llvm-3.6.0.src.tar.xz
    tar axf llvm-3.6.0.src.tar.xz
    mkdir llvm_build && cd llvm_build
    cmake ../llvm-3.6.0.src -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS="-stdlib=libc++" 
    nice make -j6 -C lib
    
  4. Compile color_coded

    cd ..
    mkdir cc_build && cd cc_build
    cmake ~/.vim/bundle/color_coded -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCUSTOM_CLANG=1 -DLLVM_ROOT_PATH=../llvm_build
    make -j6
    
  5. Test the library and install it

    echo 'print("Success")' | lua -l color_coded
    make install
    
  6. Cleanup

    cd ..
    rm -r llvm-3.6.0.src.tar.xz llvm-3.6.0.src llvm_build cc_build
    

from color_coded.

jeaye avatar jeaye commented on June 15, 2024

Will you please try the cmake branch? color_coded is currently in the process of porting to cmake for more stability across platforms. It should be stable, but hasn't yet been merged.

As a minor aside, what is the reason for requiring GCC 4.9 (if not using clang)?

color_coded uses C++14. I realize that more platforms would be supported if I chose, say, C++03, or even C++11. Still, on every supported platform (so far), C++14/1y has only been a few commands away if it's not already present. So this hasn't been a big issue.

from color_coded.

rdnetto avatar rdnetto commented on June 15, 2024

Without any options, cmake succeeds (despite using GCC 4.8), but the build fails. Pretty sure cmake should be failing instead.

-- Found 64bit system
-- Performing Test COMPILER_SUPPORTS_CXX14
-- Performing Test COMPILER_SUPPORTS_CXX14 - Failed
-- Performing Test COMPILER_SUPPORTS_CXX1Y
-- Performing Test COMPILER_SUPPORTS_CXX1Y - Success
-- Looking for Lua 5.2
-- Looking for Lua 5.1
-- Found Lua
-- Found Curses: /usr/lib64/libcurses.so  
-- Found ZLIB: /usr/lib64/libz.so (found version "1.2.8") 
-- Locating trusted Clang/LLVM 3.6.0
-- Found clang+llvm-3.6.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz
-- Extracting Clang/LLVM 3.6.0
-- Generating sources
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/mnt/build

Compilation also fails when using Clang:

Configure output:

$ cmake ../color_coded -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
-- The C compiler identification is Clang 3.5.0
-- The CXX compiler identification is Clang 3.5.0
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found 64bit system
-- Performing Test COMPILER_SUPPORTS_CXX14
-- Performing Test COMPILER_SUPPORTS_CXX14 - Success
-- Performing Test COMPILER_SUPPORTS_CXX1Y
-- Performing Test COMPILER_SUPPORTS_CXX1Y - Success
-- Looking for Lua 5.2
-- Looking for Lua 5.1
-- Found Lua
-- Found Curses: /usr/lib64/libcurses.so  
-- Found ZLIB: /usr/lib64/libz.so (found version "1.2.8") 
-- Locating trusted Clang/LLVM 3.6.0
-- Found clang+llvm-3.6.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz
-- Extracting Clang/LLVM 3.6.0
-- Generating sources
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/mnt/build

Compiler output:

[ 11%] Building CXX object CMakeFiles/color_coded_boost.dir/lib/boost/filesystem/src/codecvt_error_category.cpp.o
In file included from /tmp/mnt/color_coded/lib/boost/filesystem/src/codecvt_error_category.cpp:23:
In file included from /tmp/mnt/color_coded/lib/boost/filesystem/include/boost/filesystem/path_traits.hpp:23:
In file included from /tmp/mnt/color_coded/lib/boost/system/include/boost/system/error_code.hpp:19:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/ostream:38:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/ios:42:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/bits/ios_base.h:41:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/bits/locale_classes.h:40:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/string:52:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/bits/basic_string.h:2815:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/ext/string_conversions.h:43:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/cstdio:120:11: error: no member named 'gets' in the global namespace
  using ::gets;
    ~~^
1 error generated.
CMakeFiles/color_coded_boost.dir/build.make:54: recipe for target 'CMakeFiles/color_coded_boost.dir/lib/boost/filesystem/src/codecvt_error_category.cpp.o' failed
make[2]: *** [CMakeFiles/color_coded_boost.dir/lib/boost/filesystem/src/codecvt_error_category.cpp.o] Error 1
CMakeFiles/Makefile2:96: recipe for target 'CMakeFiles/color_coded_boost.dir/all' failed
make[1]: *** [CMakeFiles/color_coded_boost.dir/all] Error 2
Makefile:117: recipe for target 'all' failed
make: *** [all] Error 2

The error message is in colour, so it looks like Clang is using GCC's headers. (Not sure if that's supposed to happen or not.)

from color_coded.

jeaye avatar jeaye commented on June 15, 2024
  • Do you also get compilation errors using GCC?

The error message is in colour, so it looks like Clang is using GCC's headers.

  • What if you supply CXXFLAGS=-stdlib=libc++ when you invoke make?

from color_coded.

rdnetto avatar rdnetto commented on June 15, 2024

Do you also get compilation errors using GCC?

Yes, with GCC 4.8 I get the following errors:

$ make -j6
Scanning dependencies of target color_coded_track_api
Scanning dependencies of target color_coded_boost
Tracking API changes ...
[  0%] Built target color_coded_track_api
[ 11%] [ 22%] [ 33%] [ 44%] [ 55%] [ 66%] Building CXX object CMakeFiles/color_coded_boost.dir/lib/boost/filesystem/src/codecvt_error_category.cpp.o
Building CXX object CMakeFiles/color_coded_boost.dir/lib/boost/filesystem/src/path_traits.cpp.o
Building CXX object CMakeFiles/color_coded_boost.dir/lib/boost/filesystem/src/unique_path.cpp.o
Building CXX object CMakeFiles/color_coded_boost.dir/lib/boost/filesystem/src/operations.cpp.o
Building CXX object CMakeFiles/color_coded_boost.dir/lib/boost/filesystem/src/path.cpp.o
Building CXX object CMakeFiles/color_coded_boost.dir/lib/boost/filesystem/src/portability.cpp.o
[ 77%] [ 88%] Building CXX object CMakeFiles/color_coded_boost.dir/lib/boost/filesystem/src/utf8_codecvt_facet.cpp.o
Building CXX object CMakeFiles/color_coded_boost.dir/lib/boost/system/src/error_code.cpp.o
Linking CXX static library libcolor_coded_boost.a
[ 88%] Built target color_coded_boost
Scanning dependencies of target color_coded
[100%] Building CXX object CMakeFiles/color_coded.dir/src/main.cpp.o
In file included from /tmp/mnt/color_coded/include/clang/translation_unit.hpp:6:0,
         from /tmp/mnt/color_coded/include/clang/token_pack.hpp:5,
         from /tmp/mnt/color_coded/include/core.hpp:4,
         from /tmp/mnt/color_coded/include/events.hpp:3,
         from /tmp/mnt/color_coded/src/main.cpp:8:
/tmp/mnt/color_coded/include/detail/util.hpp:11:16: error: ‘decay_t’ is not a member of ‘std’
 std::array<std::decay_t<T>, sizeof...(Ts) + 1> constexpr
        ^
/tmp/mnt/color_coded/include/detail/util.hpp:11:16: error: ‘decay_t’ is not a member of ‘std’
/tmp/mnt/color_coded/include/detail/util.hpp:11:30: error: wrong number of template arguments (1, should be 2)
 std::array<std::decay_t<T>, sizeof...(Ts) + 1> constexpr
              ^
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/tuple:39:0,
         from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/functional:55,
         from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/bits/stl_algo.h:66,
         from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/algorithm:62,
         from /tmp/mnt/color_coded/include/clang/string.hpp:3,
         from /tmp/mnt/color_coded/include/core.hpp:3,
         from /tmp/mnt/color_coded/include/events.hpp:3,
         from /tmp/mnt/color_coded/src/main.cpp:8:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/array:81:12: error: provided for ‘template<class _Tp, long unsigned int _Nm> struct std::array’
 struct array
    ^
In file included from /tmp/mnt/color_coded/include/clang/translation_unit.hpp:6:0,
         from /tmp/mnt/color_coded/include/clang/token_pack.hpp:5,
         from /tmp/mnt/color_coded/include/core.hpp:4,
         from /tmp/mnt/color_coded/include/events.hpp:3,
         from /tmp/mnt/color_coded/src/main.cpp:8:
/tmp/mnt/color_coded/include/detail/util.hpp:11:31: error: expected unqualified-id before ‘,’ token
 std::array<std::decay_t<T>, sizeof...(Ts) + 1> constexpr
               ^
In file included from /tmp/mnt/color_coded/include/clang/translation_unit.hpp:7:0,
         from /tmp/mnt/color_coded/include/clang/token_pack.hpp:5,
         from /tmp/mnt/color_coded/include/core.hpp:4,
         from /tmp/mnt/color_coded/include/events.hpp:3,
         from /tmp/mnt/color_coded/src/main.cpp:8:
/tmp/mnt/color_coded/include/conf/args_view.hpp: In constructor ‘color_coded::conf::args_view::args_view(const args_t&)’:
/tmp/mnt/color_coded/include/conf/args_view.hpp:23:68: error: parameter declared ‘auto’
              std::back_inserter(view_), [](auto const &s)
                                ^
/tmp/mnt/color_coded/include/conf/args_view.hpp: In lambda function:
/tmp/mnt/color_coded/include/conf/args_view.hpp:24:35: error: ‘s’ was not declared in this scope
              { return s.c_str(); });
                   ^
In file included from /tmp/mnt/color_coded/include/core.hpp:4:0,
         from /tmp/mnt/color_coded/include/events.hpp:3,
         from /tmp/mnt/color_coded/src/main.cpp:8:
/tmp/mnt/color_coded/include/clang/token_pack.hpp: In constructor ‘color_coded::clang::token_pack::token_pack(const color_coded::clang::translation_unit&, const source_range_t&)’:
/tmp/mnt/color_coded/include/clang/token_pack.hpp:22:27: warning: a temporary bound to ‘color_coded::clang::token_pack::tu_’ only persists until the constructor exits [-Wextra]
       , range_{ range }
               ^
/tmp/mnt/color_coded/include/clang/token_pack.hpp:22:27: error: invalid initialization of reference of type ‘const source_range_t& {aka const CXSourceRange&}’ from expression of type ‘<brace-enclosed initializer list>’
In file included from /tmp/mnt/color_coded/include/clang/string.hpp:6:0,
         from /tmp/mnt/color_coded/include/core.hpp:3,
         from /tmp/mnt/color_coded/include/events.hpp:3,
         from /tmp/mnt/color_coded/src/main.cpp:8:
/tmp/mnt/color_coded/include/clang/resource.hpp: In constructor ‘color_coded::clang::resource<T>::resource() [with T = CXString]’:
/tmp/mnt/color_coded/include/clang/resource.hpp:29:9: error: no matching function for call to ‘color_coded::detail::resource<CXString>::resource(<brace-enclosed initializer list>)’
     resource() = default;
     ^
/tmp/mnt/color_coded/include/clang/resource.hpp:29:9: note: candidates are:
In file included from /tmp/mnt/color_coded/include/clang/resource.hpp:6:0,
         from /tmp/mnt/color_coded/include/clang/string.hpp:6,
         from /tmp/mnt/color_coded/include/core.hpp:3,
         from /tmp/mnt/color_coded/include/events.hpp:3,
         from /tmp/mnt/color_coded/src/main.cpp:8:
/tmp/mnt/color_coded/include/detail/resource.hpp:23:9: note: color_coded::detail::resource<T>::resource(T&&, const dtor_t&) [with T = CXString; color_coded::detail::resource<T>::dtor_t = std::function<void(CXString&)>]
     resource(T &&t, dtor_t const &dtor)
     ^
/tmp/mnt/color_coded/include/detail/resource.hpp:23:9: note:   candidate expects 2 arguments, 1 provided
/tmp/mnt/color_coded/include/detail/resource.hpp:22:9: note: color_coded::detail::resource<T>::resource(color_coded::detail::resource<T>&&) [with T = CXString]
     resource(resource &&) = default;
     ^
/tmp/mnt/color_coded/include/detail/resource.hpp:22:9: note:   no known conversion for argument 1 from ‘void (*)(CXString&)’ to ‘color_coded::detail::resource<CXString>&&’
/tmp/mnt/color_coded/include/detail/resource.hpp:18:9: note: color_coded::detail::resource<T>::resource(const dtor_t&) [with T = CXString; color_coded::detail::resource<T>::dtor_t = std::function<void(CXString&)>]
     resource(dtor_t const &dtor)
     ^
In file included from /tmp/mnt/color_coded/include/vim/highlight.hpp:13:0,
         from /tmp/mnt/color_coded/include/vim/buffer.hpp:5,
         from /tmp/mnt/color_coded/include/core.hpp:13,
         from /tmp/mnt/color_coded/include/events.hpp:3,
         from /tmp/mnt/color_coded/src/main.cpp:8:
/tmp/mnt/color_coded/include/clang/location.hpp: At global scope:
/tmp/mnt/color_coded/include/clang/location.hpp:13:30: note: synthesized method ‘color_coded::clang::resource<T>::resource() [with T = CXString]’ first required here 
   clang::string filename{};
              ^
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/algorithm:62:0,
         from /tmp/mnt/color_coded/include/clang/string.hpp:3,
         from /tmp/mnt/color_coded/include/core.hpp:3,
         from /tmp/mnt/color_coded/include/events.hpp:3,
         from /tmp/mnt/color_coded/src/main.cpp:8:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/bits/stl_algo.h: In instantiation of ‘_OIter std::transform(_IIter, _IIter, _OIter, _UnaryOperation) [with _IIter = __gnu_cxx::__normal_iterator<const std::basic_string<char>*, std::vector<std::basic_string<char> > >; _OIter = std::back_insert_iterator<std::vector<const char*> >; _UnaryOperation = color_coded::conf::args_view::args_view(const args_t&)::__lambda0]’:
/tmp/mnt/color_coded/include/conf/args_view.hpp:24:47:   required from here
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/bits/stl_algo.h:4926:33: error: no match for call to ‘(color_coded::conf::args_view::args_view(const args_t&)::__lambda0) (const std::basic_string<char>&)’
  *__result = __unary_op(*__first);
                 ^
In file included from /tmp/mnt/color_coded/include/clang/translation_unit.hpp:7:0,
         from /tmp/mnt/color_coded/include/clang/token_pack.hpp:5,
         from /tmp/mnt/color_coded/include/core.hpp:4,
         from /tmp/mnt/color_coded/include/events.hpp:3,
         from /tmp/mnt/color_coded/src/main.cpp:8:
/tmp/mnt/color_coded/include/conf/args_view.hpp:23:54: note: candidates are:
              std::back_inserter(view_), [](auto const &s)
                          ^
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/algorithm:62:0,
         from /tmp/mnt/color_coded/include/clang/string.hpp:3,
         from /tmp/mnt/color_coded/include/core.hpp:3,
         from /tmp/mnt/color_coded/include/events.hpp:3,
         from /tmp/mnt/color_coded/src/main.cpp:8:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/bits/stl_algo.h:4926:33: note: void (*)() <conversion>
  *__result = __unary_op(*__first);
                 ^
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/bits/stl_algo.h:4926:33: note:   candidate expects 1 argument, 2 provided
In file included from /tmp/mnt/color_coded/include/clang/translation_unit.hpp:7:0,
         from /tmp/mnt/color_coded/include/clang/token_pack.hpp:5,
         from /tmp/mnt/color_coded/include/core.hpp:4,
         from /tmp/mnt/color_coded/include/events.hpp:3,
         from /tmp/mnt/color_coded/src/main.cpp:8:
/tmp/mnt/color_coded/include/conf/args_view.hpp:23:69: note: color_coded::conf::args_view::args_view(const args_t&)::__lambda0
              std::back_inserter(view_), [](auto const &s)
                                 ^
/tmp/mnt/color_coded/include/conf/args_view.hpp:23:69: note:   candidate expects 0 arguments, 1 provided
In file included from /tmp/mnt/color_coded/lib/boost/filesystem/include/boost/filesystem/path_traits.hpp:23:0,
         from /tmp/mnt/color_coded/lib/boost/filesystem/include/boost/filesystem/path.hpp:25,
         from /tmp/mnt/color_coded/lib/boost/filesystem/include/boost/filesystem.hpp:16,
         from /tmp/mnt/color_coded/include/conf/load.hpp:9,
         from /tmp/mnt/color_coded/include/conf/args_view.hpp:5,
         from /tmp/mnt/color_coded/include/clang/translation_unit.hpp:7,
         from /tmp/mnt/color_coded/include/clang/token_pack.hpp:5,
         from /tmp/mnt/color_coded/include/core.hpp:4,
         from /tmp/mnt/color_coded/include/events.hpp:3,
         from /tmp/mnt/color_coded/src/main.cpp:8:
/tmp/mnt/color_coded/lib/boost/system/include/boost/system/error_code.hpp:221:36: warning: ‘boost::system::posix_category’ defined but not used [-Wunused-variable]
 static const error_category &  posix_category = generic_category();
                ^
/tmp/mnt/color_coded/lib/boost/system/include/boost/system/error_code.hpp:222:36: warning: ‘boost::system::errno_ecat’ defined but not used [-Wunused-variable]
 static const error_category &  errno_ecat     = generic_category();
                ^
/tmp/mnt/color_coded/lib/boost/system/include/boost/system/error_code.hpp:223:36: warning: ‘boost::system::native_ecat’ defined but not used [-Wunused-variable]
 static const error_category &  native_ecat    = system_category();
                ^
CMakeFiles/color_coded.dir/build.make:54: recipe for target 'CMakeFiles/color_coded.dir/src/main.cpp.o' failed
make[2]: *** [CMakeFiles/color_coded.dir/src/main.cpp.o] Error 1
CMakeFiles/Makefile2:61: recipe for target 'CMakeFiles/color_coded.dir/all' failed
make[1]: *** [CMakeFiles/color_coded.dir/all] Error 2
Makefile:117: recipe for target 'all' failed
make: *** [all] Error 2

What if you supply CXXFLAGS=-stdlib=libc++ when you invoke make?

That doesn't seem to do anything, even if set to --help. A quick grep indicates that there is a variable called CXX_FLAGS though, which appears to be the correct one to use. Setting it to "-stdlib=libc++" produces the original error regarding cstddef.

from color_coded.

jeaye avatar jeaye commented on June 15, 2024

Your GCC fails to compile since it doesn't meet the dependencies: GCC 4.9

Your clang fails to compile for an unknown reason. You can try adding -stdlib=libc++ to line 63 of CMakeLists.txt in the root of the project and the building again, using clang.

I'm looking into how to please clang. Right now, your best bet is using GCC 4.9, if the small patch I suggested above doesn't work. I'm surprised, as a Gentoo user, that you're not running GCC 4.9. :P

from color_coded.

rdnetto avatar rdnetto commented on June 15, 2024

Your clang fails to compile for an unknown reason. You can try adding -stdlib=libc++ to line 63 of CMakeLists.txt in the root of the project and the building again, using clang.

That doesn't seem to make a difference - I still have to specify it when calling make in order to get the cstddef error.

I'm looking into how to please clang. Right now, your best bet is using GCC 4.9, if the small patch I suggested above doesn't work. I'm surprised, as a Gentoo user, that you're not running GCC 4.9. :P

It's because I'm using Sabayon that I'm not using GCC 4.9. Sabayon uses a binary package manager by default (which only has GCC 4.8). You can then augment that with packages from Gentoo, but that runs the risk of breaking things since it's not officially supported. (Not to mention waiting a few hours for GCC to compile is kind of a pain, and GCC is right next to libc on the list of things that cause all sorts of pain when broken.)

At any rate, I'll emerge GCC 4.9 and let you know how that goes.

from color_coded.

rdnetto avatar rdnetto commented on June 15, 2024

OK, looks like GCC 4.9 did the trick. :)

There was a minor issue where vim-qt doesn't recognize the color DarkYellow, but that was fixed easily enough. (I'll open a pull request for it.)

from color_coded.

jeaye avatar jeaye commented on June 15, 2024

There was a minor issue where vim-qt doesn't recognize the color DarkYellow, but that was fixed easily enough.

Hm, that's odd. You can override any of the colors in your own color scheme just by setting them again.

from color_coded.

jeaye avatar jeaye commented on June 15, 2024

Also, let's get back to your clang issue. What if you supply -DCMAKE_CXX_FLAGS=-stdlib=libc++ to your cmake command? You may also need to specify -lc++abi for linking to succeed.

from color_coded.

jeaye avatar jeaye commented on June 15, 2024

I have verified that building with clang on Arch Linux, but I also have issues with it on Ubuntu. For now, I've update the README to say that GCC 4.9 is preferred and clang has mixed success on anything but OS X. Sorry for the inconvenience.

from color_coded.

oblitum avatar oblitum commented on June 15, 2024

@jeaye are you getting issues buiding it with clang on Ubuntu/Arch? I have the two and may proof-check that. Don't recall issues the last time I tried.

from color_coded.

jeaye avatar jeaye commented on June 15, 2024

@oblitum Arch works fine with GCC and clang. Ubuntu didn't like clang and I wasn't able to easily coerce it. For now, I think it's simpler to narrow the scope into just GCC 4.9 outside of OS X. If someone wants to use clang and it works, that's great. I have other platform-specific concerns beyond people wanting to use their favorite compiler though. :(

from color_coded.

oblitum avatar oblitum commented on June 15, 2024

hah ok. ah but then... I just compile with clang trunk so, won't help for release information, I don't have any installed...

from color_coded.

rdnetto avatar rdnetto commented on June 15, 2024

Also, let's get back to your clang issue. What if you supply -DCMAKE_CXX_FLAGS=-stdlib=libc++ to your cmake command? You may also need to specify -lc++abi for linking to succeed.

Using libc++ seems to break cmake, with or without the linker flag.

$ cmake ../color_coded -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS="-stdlib=libstdc++ -lc++abi"
-- The C compiler identification is Clang 3.5.0
-- The CXX compiler identification is Clang 3.5.0
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ -- broken
CMake Error at /usr/share/cmake/Modules/CMakeTestCXXCompiler.cmake:54 (message):
  The C++ compiler "/usr/bin/clang++" is not able to compile a simple test
  program.

  It fails with the following output:

   Change Dir: /tmp/mnt/build/CMakeFiles/CMakeTmp



  Run Build Command:"/usr/bin/gmake" "cmTryCompileExec1915165044/fast"

  /usr/bin/gmake -f CMakeFiles/cmTryCompileExec1915165044.dir/build.make
  CMakeFiles/cmTryCompileExec1915165044.dir/build

  gmake[1]: Entering directory '/tmp/mnt/build/CMakeFiles/CMakeTmp'

  /usr/bin/cmake -E cmake_progress_report
  /tmp/mnt/build/CMakeFiles/CMakeTmp/CMakeFiles 1

  Building CXX object
  CMakeFiles/cmTryCompileExec1915165044.dir/testCXXCompiler.cxx.o

  /usr/bin/clang++ -stdlib=libstdc++ -lc++abi -o
  CMakeFiles/cmTryCompileExec1915165044.dir/testCXXCompiler.cxx.o -c
  /tmp/mnt/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx

  x86_64-pc-linux-gnu-clang-3.5.0: warning: -lc++abi: 'linker' input unused

  Linking CXX executable cmTryCompileExec1915165044

  /usr/bin/cmake -E cmake_link_script
  CMakeFiles/cmTryCompileExec1915165044.dir/link.txt --verbose=1

  /usr/bin/clang++ -stdlib=libstdc++ -lc++abi
  CMakeFiles/cmTryCompileExec1915165044.dir/testCXXCompiler.cxx.o -o
  cmTryCompileExec1915165044 -rdynamic

  /usr/bin/x86_64-pc-linux-gnu-ld: cannot find -lc++abi

  x86_64-pc-linux-gnu-clang-3.5.0: error: linker command failed with exit
  code 1 (use -v to see invocation)

  CMakeFiles/cmTryCompileExec1915165044.dir/build.make:88: recipe for target
  'cmTryCompileExec1915165044' failed

  gmake[1]: Leaving directory '/tmp/mnt/build/CMakeFiles/CMakeTmp'

  gmake[1]: *** [cmTryCompileExec1915165044] Error 1

  Makefile:118: recipe for target 'cmTryCompileExec1915165044/fast' failed

  gmake: *** [cmTryCompileExec1915165044/fast] Error 2





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:3 (project)


-- Configuring incomplete, errors occurred!
See also "/tmp/mnt/build/CMakeFiles/CMakeOutput.log".
See also "/tmp/mnt/build/CMakeFiles/CMakeError.log".

I'm going to try with Clang 3.6 for completeness, but if that doesn't work I'll probably just give up (since it works fine with GCC 4.9).

from color_coded.

jeaye avatar jeaye commented on June 15, 2024

No problem. Thanks for trying (please let me know of the 3.6 results). For now, I haven't heard anyone say GCC 4.9 didn't work, so we'll stick with that as far as what's stable.

from color_coded.

jeaye avatar jeaye commented on June 15, 2024

Closing now. I'd love to hear about the 3.6 results, but this ticket doesn't need to be open for that.

from color_coded.

rdnetto avatar rdnetto commented on June 15, 2024

Upgrading to Clang 3.6 didn't work. However, I did manage to find out the root cause:
gets() is not part of C11, and as a result of that glibc doesn't provide it in C++1y mode.

Furthermore, libc++ is not installed in Gentoo by default, which is why the build was failing. (The relevant ebuild is sys-libs/libcxx). Guess I just assumed that it would be there since it's a standard library. Users of other distros can check if it's installed by looking for /usr/lib64/libc++.so.

Once installed, color_coded compiles with both clang 3.5 and 3.6 with the following:
cmake ../color_coded -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS="-stdlib=libc++"
make -j6
make install

The compiled library doesn't seem to work though... (color_coded doesn't seem to think it's there - the require call is failing)

from color_coded.

jeaye avatar jeaye commented on June 15, 2024

@rdnetto That would be due to linking issues. Adjacent to color_coded.so, you can run

lua -l color_coded

and see what errors are reported.

from color_coded.

rdnetto avatar rdnetto commented on June 15, 2024

Well, this is just weird. Both the gcc and clang versions fail to load, even though Vim can load the gcc version fine:

$ lua -l color_coded-gcc
lua: error loading module 'color_coded-gcc' from file './color_coded-gcc.so':
    ./color_coded-gcc.so: undefined symbol: luaopen_gcc
stack traceback:
    [C]: ?
    [C]: ?
    [C]: ?


$ lua: error loading module 'color_coded-clang.so' from file './color_coded-clang.so':
    ./color_coded-clang.so: undefined symbol: _ZNSt14error_categoryD2Ev
stack traceback:
    [C]: ?
    [C]: ?
    [C]: ?

_ZNSt14error_categoryD2Ev demangles to std::error_category::~error_category(). This symbol is present in libstdc++, but the closest libc++ has is std::__1::error_category::~error_category (_ZNSt3__114error_categoryD2Ev).
I'm not sure, but it looks like this might be a libc++ bug? (I'm using version 0.0_p20140322)

EDIT: it's not a bug, it's a feature...

Apparently the ``__1` is because libc++ has a different ABI to libstdc++, and can only be resolved by recompiling Boost. I'm not even going to try to do that, given the likelihood of breaking my system.

IMO, it looks like libc++ isn't ready for mainstream usage yet, at least on Linux where stdlibc++ is the norm. (Most of the libc++ questions I found when Googling were for OS X systems). (This probably explains why there's no stable version in Gentoo yet.) There's an interesting discussion of their relationship here if you're interested. At any rate, recommending libc++ for non-OS X users seems like a bad idea, which means that Clang support on Linux is basically dead in the water for now.

At any rate, GCC 4.9 works, and users of systems without it can always compile the library on a different system and copy it across. The only practical means of supporting Clang in the short term would be to forego (or patch around the lack of) C++14 features as discussed in #27, but I'm not sure it's worth the effort, at least at this point in time anyway.

from color_coded.

jeaye avatar jeaye commented on June 15, 2024

On Wed, Apr 15, 2015 at 12:31:40AM -0700, rdnetto wrote:

Well, this is just weird. Both the gcc and clang versions fail to load,
even though Vim can load the gcc version fine:

When using libc++ on Linux, you should link with -lc++abi

from color_coded.

rdnetto avatar rdnetto commented on June 15, 2024

Ah, so that's what that flag is for. Guess my analysis was a bit premature. :P

...and it just clicked that _lib_c++abi is a library in its own right which I don't have installed. After a bit more research, it's currently only supported on Darwin. libc++ supports using libc++abi, libcxxrt, or libsupc++.[1] Gentoo uses libc++rt, which is why -lc++abi never worked for me. libcxxrt is already linked in the Clang version though, which means it should just be working. libcxxrt doesn't seem to contain any symbols related to error_category though...

[1] http://libcxx.llvm.org/

from color_coded.

oblitum avatar oblitum commented on June 15, 2024

@rdnetto libc++abi is working fine on linux for some time already. libcxxrt is still an option, but since libc++abi is part of the LLVM project, it's preferred.

from color_coded.

oblitum avatar oblitum commented on June 15, 2024

It didn't work for a long time, but it has been officially supported on linux for some months or recent years.

from color_coded.

rdnetto avatar rdnetto commented on June 15, 2024

Hmm, I guess I'll just have to write an ebuild for it then. Odd that libcxxrt isn't working though.

from color_coded.

rdnetto avatar rdnetto commented on June 15, 2024

Ok, so after finally getting libc++abi working under Gentoo, it looks like it makes no difference whatsoever. Ebuild is here if anyone is interested in taking it further.

from color_coded.

jeaye avatar jeaye commented on June 15, 2024

@rdnetto Thanks for following up.

from color_coded.

rdnetto avatar rdnetto commented on June 15, 2024

@jeaye No problem. :)

from color_coded.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.