Repository navigation
Add C++ toolchain for portable Linux builds - #16173
Conversation
|
gunan@ asked me to test if TensorFlow pip package built with this clang crosstool on Ubuntu 16 will run correctly on Ubuntu 14. Working on testing that now. |
|
Oh by the way @case540, here are some notes I took on building Clang from source: # Install CMake (to build Clang snapshot)
sudo apt-get purge 'cmake*'
wget https://cmake.org/files/v3.10/cmake-3.10.1.tar.gz
tar xvzf cmake-3.10.1.tar.gz
pushd cmake-3.10.1
CFLAGS='-O2 -march=native' CXXFLAGS='-O2 -march=native' ./bootstrap --prefix=/usr --parallel=96
make CFLAGS='-O2 -march=native' CXXFLAGS='-O2 -march=native' -j96
sudo make install
popd
# Install Ninja
git clone git://github.com/ninja-build/ninja.git
pushd ninja
git checkout release
CC=clang-6.0 CXX=clang++-6.0 CFLAGS='-O2 -march=native' CXXFLAGS='-O2 -march=native' ./configure.py --bootstrap
sudo cp ninja /usr/bin
popd
# Install Clang 7.0
svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
cd llvm/tools
svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
cd clang/tools # llvm/tools/clang/tools
svn co http://llvm.org/svn/llvm-project/clang-tools-extra/trunk extra
cd ../.. # llvm/tools
svn co http://llvm.org/svn/llvm-project/lld/trunk lld
svn co http://llvm.org/svn/llvm-project/polly/trunk polly
cd ../projects # llvm/projects
svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
svn co http://llvm.org/svn/llvm-project/openmp/trunk openmp
svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx
svn co http://llvm.org/svn/llvm-project/libcxxabi/trunk libcxxabi
cd .. # llvm
# Note: Build Clang using GCC 4.8.2+ (rather than Clang)
llvm_build_opts=(
-DBUILD_SHARED_LIBS=On
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_CXX_FLAGS=-march=native
-DCMAKE_C_FLAGS=-march=native
-DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=gold
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly
-DLLVM_OPTIMIZED_TABLEGEN=On
-DLLVM_PARALLEL_COMPILE_JOBS=100
-DLLVM_PARALLEL_LINK_JOBS=50
)
mkdir _build
cd _build
cmake -G Ninja .. "${llvm_build_opts[@]}"
ninja
sudo cmake -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm-7.0 -P cmake_install.cmakeI was experimenting to see if Clang 7.0 unstable would be a better choice, but it seemed a little… unstable, and didn't have some of the bleeding edge features out of the box I was hoping it'd have. So if you end up needing to build from source, hopefully those notes will save you time. |
|
I tried building using this crosstool on Ubuntu 16 and ran into some issues. I made the following modifications to the crosstool file...
The build makes it a good bit of the way through but then I ran into this error. Any idea what the issue could be? Have you seen this before? ERROR: /home/mikecase/.cache/bazel/_bazel_mikecase/c22aed87a372cfab86407106f2bbe57d/external/protobuf_archive/BUILD:271:1: Executing genrule @protobuf_archive//:generate_js_well_known_types_embed failed (Segmentation fault): bash failed: error executing command |
|
@jart please resolve conflicts so we can merge this. |
|
I built using the clang6 toolchain on ubuntu 16. I modified the crosstool with the following versions (to what was installed by default on the machine)... Unfortunately, I still hit the same error... ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.20' not found ...when running this pip package on Ubuntu 14. Anything else I should try? |
|
@case540 I can't remember, did we use |
|
I did not use those flags when building. Is that something I should try out? |
|
@case540 Yes absolutely give them a try. |
|
I wouldn't be surprised if you could manually extract old versions of libc, libstdc++, libgcc, etc. into hard-coded folders and Clang and then finagle Clang 6.0 on Ubuntu 16 to just ignore what's on the system and use only those highly specific paths you've specified. |
|
Talked to someone from one of the compiler teams. Sounds like it might be possible to compile against glibc libraries extracted from Ubuntu 14 on Ubuntu 16. But he did not recommend doing so. Will give it a try when I have some spare time and see how bad it is. |
|
That's a sane default recommendation. It's just that, based on what I've been told, not making this heroic hack work means your team might have no choice but to own a monolithic megacore Debian 8 buildbox, which honestly, IMHO ain't so bad. |
See #15777