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

Build Boost shared libraries and source for Raspberry Pi on Ubuntu #3

Open
terrisgit opened this issue Jul 26, 2019 · 14 comments
Open

Comments

@terrisgit
Copy link

terrisgit commented Jul 26, 2019

I am trying to build boost using this project and rules_foreign_cc. See bazel-contrib/rules_foreign_cc#297 .

I am using --config=pi.

On OSX I get the following error:

ERROR: /private/var/tmp/_bazel_terris/edf155d50c43cc61a3e8b69da84398f0/external/rpi_bazel/tools/cc_toolchain/BUILD:20:1: in cc_toolchain_suite rule @rpi_bazel//tools/cc_toolchain:toolchain: cc_toolchain_suite '@rpi_bazel//tools/cc_toolchain:toolchain' does not contain a toolchain for cpu 'armeabihf'
@jpieper
Copy link
Member

jpieper commented Jul 27, 2019

Yeah, unfortunately I wouldn't expect this to work on OS X at all. It is limited to Linux at this point.

@terrisgit
Copy link
Author

terrisgit commented Jul 27, 2019

I saw this in #2 - maybe add it to the README? So yep.. this works with the master branch:

bazel build --compiler=clang test
bazel build --config=pi --compiler=clang test

@terrisgit
Copy link
Author

terrisgit commented Jul 27, 2019

ERROR: /media/sf_smart/pe-compute/test/BUILD:1:1: Linking of rule '//test:test' failed (Exit 1) clang-clang failed: error executing command external/rpi_bazel/tools/cc_toolchain/wrapper/clang-clang -o bazel-out/armeabihf-fastbuild/bin/test/test '-Wl,-rpath,$ORIGIN/../_solib_armeabihf/' ... (remaining 19 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
ld.lld: error: bazel-out/armeabihf-fastbuild/bin/_solib_armeabihf/_U_S_Sboost_Clog___Uboost_Slog_Slib/libboost_atomic.so.1.65.0 is incompatible with armelf_linux_eabi

@terrisgit
Copy link
Author

terrisgit commented Jul 27, 2019

Using the "file" command, I determined the .so files are not built for ARM. So sadly the toolchain is not getting passed to Boost's b2 builder.

ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=0555073ad8791b8aeab0e746c6aa67d920194e3e, with debug_info, not stripped

@terrisgit terrisgit changed the title OSX: Does not contain a toolchain for cpu 'armeabihf' Build Boost and my source code for Raspberry Pi on Ubuntu Jul 27, 2019
@terrisgit terrisgit changed the title Build Boost and my source code for Raspberry Pi on Ubuntu Build Boost shared libraries and source code for Raspberry Pi on Ubuntu Jul 27, 2019
@jpieper
Copy link
Member

jpieper commented Jul 27, 2019

Are you using a system version of bazel or the 0.26.1 that is downloaded?

@terrisgit terrisgit changed the title Build Boost shared libraries and source code for Raspberry Pi on Ubuntu Build Boost shared libraries and C+ source for Raspberry Pi on Ubuntu Jul 27, 2019
@terrisgit
Copy link
Author

0.26.1 downloaded

@terrisgit
Copy link
Author

terrisgit commented Jul 27, 2019

The toolchain doesn't appear to work with CMake either.

The BUILD file is here: https://github.com/dev-guy/vsomeip-bazel/blob/master/vsomeip/BUILD

The key issue seems to be:

/tmp/tmp.X5xqrpaTj2/CMakeFiles/CMakeTmp/external/org_llvm_clang/bin/clang: No such file or directory

How to stop Bazel from deleting files in /tmp too early?

_____ BEGIN BUILD LOGS _____
Bazel external C/C++ Rules #0.0.8. Building library 'vsomeip'
Environment:______________EXT_BUILD_ROOT=/home/terris/.cache/bazel/_bazel_terris/0679beeba7657bf10887278727d0e849/sandbox/linux-sandbox/207/execroot/pecomp
INSTALLDIR=/home/terris/.cache/bazel/_bazel_terris/0679beeba7657bf10887278727d0e849/sandbox/linux-sandbox/207/execroot/pecomp/bazel-out/k8-fastbuild/bin/vsomeip/vsomeip
PWD=/home/terris/.cache/bazel/_bazel_terris/0679beeba7657bf10887278727d0e849/sandbox/linux-sandbox/207/execroot/pecomp
BUILD_TMPDIR=/tmp/tmp.X5xqrpaTj2
TMPDIR=/tmp
EXT_BUILD_DEPS=/home/terris/.cache/bazel/_bazel_terris/0679beeba7657bf10887278727d0e849/sandbox/linux-sandbox/207/execroot/pecomp/bazel_foreign_cc_deps_vsomeip
SHLVL=2
BUILD_LOG=bazel-out/k8-fastbuild/bin/vsomeip/vsomeip/logs/CMake.log
BUILD_SCRIPT=bazel-out/k8-fastbuild/bin/vsomeip/vsomeip/logs/CMake_script.sh
PATH=/home/terris/.cache/bazel/_bazel_terris/0679beeba7657bf10887278727d0e849/sandbox/linux-sandbox/207/execroot/pecomp:/home/terris/.pyenv/plugins/pyenv-virtualenv/shims:/home/terris/.pyenv/shims:/home/terris/.pyenv/bin:/home/terris/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/terris/.bazel/bin:/home/terris/bin
_=/usr/bin/env
__________________________-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: /home/terris/.cache/bazel/_bazel_terris/0679beeba7657bf10887278727d0e849/sandbox/linux-sandbox/207/execroot/pecomp/external/rpi_bazel/tools/cc_toolchain/wrapper/clang-clang
-- Check for working C compiler: /home/terris/.cache/bazel/_bazel_terris/0679beeba7657bf10887278727d0e849/sandbox/linux-sandbox/207/execroot/pecomp/external/rpi_bazel/tools/cc_toolchain/wrapper/clang-clang -- broken
CMake Error at /usr/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
  The C compiler

    "/home/terris/.cache/bazel/_bazel_terris/0679beeba7657bf10887278727d0e849/sandbox/linux-sandbox/207/execroot/pecomp/external/rpi_bazel/tools/cc_toolchain/wrapper/clang-clang"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /tmp/tmp.X5xqrpaTj2/CMakeFiles/CMakeTmp
    
    Run Build Command:"/usr/bin/make" "cmTC_eb9d2/fast"
    /usr/bin/make -f CMakeFiles/cmTC_eb9d2.dir/build.make CMakeFiles/cmTC_eb9d2.dir/build
    make[1]: Entering directory '/tmp/tmp.X5xqrpaTj2/CMakeFiles/CMakeTmp'
    Building C object CMakeFiles/cmTC_eb9d2.dir/testCCompiler.c.o
    /home/terris/.cache/bazel/_bazel_terris/0679beeba7657bf10887278727d0e849/sandbox/linux-sandbox/207/execroot/pecomp/external/rpi_bazel/tools/cc_toolchain/wrapper/clang-clang   -nostdinc++ -isystem /home/terris/.cache/bazel/_bazel_terris/0679beeba7657bf10887278727d0e849/sandbox/linux-sandbox/207/execroot/pecomp/external/org_llvm_libcxx/include -isystem /home/terris/.cache/bazel/_bazel_terris/0679beeba7657bf10887278727d0e849/sandbox/linux-sandbox/207/execroot/pecomp/external/org_llvm_libcxxabi/include -Wno-builtin-macro-redefined -D__DATE__="redacted" -D__TIMESTAMP__="redacted" -D__TIME__="redacted" -fPIE -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -fstack-protector -Wall -fno-omit-frame-pointer -no-canonical-prefixes    -o CMakeFiles/cmTC_eb9d2.dir/testCCompiler.c.o   -c /tmp/tmp.X5xqrpaTj2/CMakeFiles/CMakeTmp/testCCompiler.c
    /home/terris/.cache/bazel/_bazel_terris/0679beeba7657bf10887278727d0e849/sandbox/linux-sandbox/207/execroot/pecomp/external/rpi_bazel/tools/cc_toolchain/wrapper/clang-clang: line 17: /tmp/tmp.X5xqrpaTj2/CMakeFiles/CMakeTmp/external/org_llvm_clang/bin/clang: No such file or directory
    CMakeFiles/cmTC_eb9d2.dir/build.make:65: recipe for target 'CMakeFiles/cmTC_eb9d2.dir/testCCompiler.c.o' failed
    make[1]: *** [CMakeFiles/cmTC_eb9d2.dir/testCCompiler.c.o] Error 127
    make[1]: Leaving directory '/tmp/tmp.X5xqrpaTj2/CMakeFiles/CMakeTmp'
    Makefile:126: recipe for target 'cmTC_eb9d2/fast' failed
    make: *** [cmTC_eb9d2/fast] Error 2

@terrisgit terrisgit changed the title Build Boost shared libraries and C+ source for Raspberry Pi on Ubuntu Build Boost shared libraries and source for Raspberry Pi on Ubuntu Jul 27, 2019
@terrisgit
Copy link
Author

In case you want to help https://github.com/dev-guy/pi-bazel-boost-vsomeip

@terrisgit
Copy link
Author

terrisgit commented Jul 29, 2019

If you have a moment, could you please verify .bazelrc and WORKSPACE are OK? They are brief. I'm not sure I have things in the correct order.

@jpieper
Copy link
Member

jpieper commented Jul 30, 2019

I didn't see anything obviously wrong with your WORKSPACE, but I admit to not really having any experience with merging the more hermetic approach that mjbots/rpi_bazel and mjbots/bazel_deps takes with rules_foreign_cc. I'd recommend just making a simple BUILD.bazel file for your library and not messing with cmake at all. There are plenty of examples in https://github.com/mjbots/bazel_deps to choose from.

@terrisgit
Copy link
Author

terrisgit commented Jul 30, 2019

My goal, which will probably fail, is for Bazel to integrate with cmake and b2 projects until they see the light and convert to Bazel, which is unlikely until Bazel embraces my goal (yes it’s a little recursive). I do not seek a work around. As far as practicality goes, we abandoned Bazel just for raspberry pi builds. It was inevitable. IMX is much worse.

@terrisgit
Copy link
Author

terrisgit commented Aug 2, 2019

Also, if you want to convert GENIVI/vsomeip , I would have one less reason to use cmake. I'm skeptical that you can use boost and avoid b2, but I'm willing to go along. I have managed to use a lot of open source projects like spdlog in Bazel without resorting to calling out to cmake but vsomeip has been particularly troublesome because it depends on boost and I just don't know enough about Bazel yet.

@jpieper
Copy link
Member

jpieper commented Aug 2, 2019

For all the complexity in GENIVI/vsomeip's CMakelist.txt, it looks like the bazel-ification could boil down to just listing the right glob for *.cpp and *.h, and possibly a bit of include path munging. My brief skim didn't show any more complex build steps like pre-processing. For these purposes, you don't care about documentation or tests.

@terrisgit
Copy link
Author

terrisgit commented Aug 3, 2019

Thanks! I am working on converting my project and will then try to get vsomeip working. Thanks for the other projects that are dependencies of my app and in some cases vsomeip. I’m not sure how vsomeip will find the boost include files but that’s my general ignorance of Bazel...

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

2 participants