Git Product home page Git Product logo

rpi_bazel's People

Contributors

jpieper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rpi_bazel's Issues

bazel.rc

WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files: tools/bazel.rc
ERROR: Config value 'pi' is not defined in any .rc file

using bazel 5.1.1

Build Boost shared libraries and source for Raspberry Pi on Ubuntu

I am trying to build boost using this project and rules_foreign_cc. See bazelbuild/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'

Problem with linking libraries

Hey, I think this tool is awesome, and I would love to use it.

But I have a small problem, so I have this moderately big c++ project and using this to compile all of my individual libraries works, but when I try to link everything to the main binary I get over 100x undefined symbol errors,

e.g:

ld.lld: error: undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string()

Do you have any clue what could be the cause of this? and how to adress it?

cc_toolchain_suite does not contain a toolchain for cpu 'k8'

I'm getting the following error when attempting to build envoy with rpi_bazel:

ERROR: ~/.cache/bazel/_bazel_my_usr_name/05c2e2981e4691f39b198a95ef8b9a7c/external/rpi_bazel/tools/cc_toolchain/BUILD:5: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 'k8'
ERROR: Analysis of target '//source/exe:envoy-static' failed; build aborted: Analysis of target '@rpi_bazel//tools/cc_toolchain:toolchain' failed; build aborted

I verified that I could build envoy with bazel normally on my machine before attempting to cross compile for rpi. I'm guessing the error has something to do with the toolchain definitions in the BUILD or CROSSTOOL file in tools/cc_toolchain, but the error doesn't make much sense to me since in the CROSSTOOL file the default toolchain for k8 clearly points to the clang x86_64 toolchain. I will keep trying to figure it out, but any help would be appreciated.

Some system info in case that's relevant:
Operating System: Linux Mint 19 Kernel: Linux 4.15.0-34-generic Architecture: x86-64

Bazel info:

Build label: 0.23.2
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Mon Mar 11 16:47:03 2019 (1552322823)
Build timestamp: 1552322823
Build timestamp as int: 1552322823

What to enter for sha256 field?

I'm sure this is a stupid question, but I can't seem to figure it out:
What should I replace the X's with for the line sha256 = "XXX" in repository.bzl?
I'm assuming you would fill in the commit hash for the first line i.e. commit = "6079a21" , but I'm not sure about the next one. I tried the longer hash (sha256 = "6079a215f431c8f1b86c2b315fb2ab7e410b64b4"), but when attempting to build I got Invalid SHA256 checksum.

I'm hoping that this repo may be able to help me build envoy so that I can run a gRPC backend on my pi and communicate with it from a web interface, but I'm in pretty over my head trying to deal with these complex build processes. Anyway, thanks for creating this repo- even if it can't help in my particular case I'm sure it will be really useful for getting other C++ code running on raspberry pi.

external/org_llvm_libcxx/include/__config:219:12: fatal error: 'features.h' file not found

Hello,

When I try to use this library

INFO: Build option --compiler has changed, discarding analysis cache.
INFO: Analyzed 5 targets (0 packages loaded, 3459 targets configured).
INFO: Found 5 targets...
ERROR: /rpicar/platform/BUILD:1:1: C++ compilation of rule '//platform:platform' failed (Exit 1) clang-clang failed: error executing command external/rpi_bazel/tools/cc_toolchain/wrapper/clang-clang -MD -MF bazel-out/armeabihf-fastbuild/bin/platform/_objs/platform/main.pic.d ... (remaining 34 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
In file included from platform/src/main.cc:5:
In file included from ./platform/include/rpi_gpio.h:6:
In file included from ./holster/include/error.h:9:
In file included from external/org_llvm_libcxx/include/optional:149:
external/org_llvm_libcxx/include/__config:219:12: fatal error: 'features.h' file not found
#  include <features.h>
           ^~~~~~~~~~~~
1 error generated.
INFO: Elapsed time: 0.905s, Critical Path: 0.52s
INFO: 0 processes.
FAILED: Build did NOT complete successfully

The above code happens. features.h is present on the system however

root@cjds:/# find . -name features.h
./usr/include/features.h
./usr/include/c++/8/parallel/features.h
./usr/include/c++/9/parallel/features.h
./usr/include/c++/10/parallel/features.h
./usr/arm-linux-gnueabi/include/features.h
./usr/arm-linux-gnueabi/include/c++/9/parallel/features.h
./root/.cache/bazel/_bazel_root/a24326a56432a033218a21510efea07d/external/raspberry_pi/sysroot/usr/include/features.h
./root/.cache/bazel/_bazel_root/a24326a56432a033218a21510efea07d/external/raspberry_pi/sysroot/usr/include/c++/6.3.0/parallel/features.h
./root/.cache/bazel/_bazel_root/a24326a56432a033218a21510efea07d/external/raspberry_pi/sysroot/usr/include/c++/6/parallel/features.h

I'm using clang-10 in Docker of Ubuntu 18.04

RPI Bazel having issue while trying to compile boost

When trying to compile the following code,

#include <iostream>
#include <boost/iostreams/device/mapped_file.hpp>
class MmapStateMachine
{
public:
    explicit MmapStateMachine(boost::iostreams::mapped_file_source& file)
    {
      
    }

    ~MmapStateMachine()
    {
      file_.close();
    }
  private:
    boost::iostreams::mapped_file_source file_;
    std::string error_;
};

I'm getting a linker error

DEBUG: Rule 'com_github_nelhage_rules_boost' indicated that a canonical reproducible form can be obtained>>> referenced by ostream:741 (external/org_llvm_libcxx/include/ostream:741)
>>>               bazel-out/armeabihf-dbg/bin/holster/_objs/platform/main.pic.o:(std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned int))
>>> referenced by ostream:741 (external/org_llvm_libcxx/include/ostream:741)
>>>               bazel-out/armeabihf-dbg/bin/holster/_objs/platform/main.pic.o:(std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned int))
>>> referenced by main.cc
>>>               bazel-out/armeabihf-dbg/bin/holster/_objs/platform/main.pic.o:(__clang_call_terminate)

ld.lld: error: undefined symbol: std::__1::ios_base::__set_badbit_and_consider_rethrow()
>>> referenced by ostream:744 (external/org_llvm_libcxx/include/ostream:744)
>>>               bazel-out/armeabihf-dbg/bin/holster/_objs/platform/main.pic.o:(std::__1::basic_ostream<>>> referenced by ostream:745 (external/org_llvm_libcxx/include/ostream:745)
>>>               bazel-out/armeabihf-dbg/bin/holster/_objs/platform/main.pic.o:(std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned int))
>>> referenced by ostream:745 (external/org_llvm_libcxx/include/ostream:745)
>>>               bazel-out/armeabihf-dbg/bin/holster/_objs/platform/main.pic.o:(std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned int))

>>> referenced by ostream:741 (external/org_llvm_libcxx/include/ostream:741)
>>>               bazel-out/armeabihf-dbg/bin/holster/_objs/platform/main.pic.o:(std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned int))
char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned int))
 >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned int))
>>> referenced by main.cc
>>>               bazel-out/armeabihf-dbg/bin/holster/_objs/platform/main.pic.o:(__clang_call_terminate)
>>>               bazel-out/armeabihf-dbg/bin/holster/_objs/platform/main.pic.o:(std::__1::basic_ostream<>>> referenced by ostream:741 (external/org_llvm_libcxx/include/ostream:741)
>>>               bazel-out/armeabihf-dbg/bin/holster/_objs/platform/main.pic.o:(std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned int))
>>> referenced by ostream:741 (external/org_llvm_libcxx/include/ostream:741)
>>>               bazel-out/armeabihf-dbg/bin/holster/_objs/platform/main.pic.o:(std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned int))

ld.lld: error: undefined symbol: __cxa_begin_catch
>>> referenced by ostream:741 (external/org_llvm_libcxx/include/ostream:741)
>>>               bazel-out/armeabihf-dbg/bin/holster/_objs/platform/main.pic.o:(std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned int))
>>> referenced by main.cc
>>>               bazel-out/armeabihf-dbg/bin/holster/_objs/platform/main.pic.o:(__clang_call_terminate)

ld.lld: error: undefined symbol: std::__1::ios_base::__set_badbit_and_consider_rethrow()
>>> referenced by ostream:744 (external/org_llvm_libcxx/include/ostream:744)
>>>               bazel-out/armeabihf-dbg/bin/holster/_objs/platform/main.pic.o:(std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned int))

ld.lld: error: undefined symbol: __cxa_end_catch
>>> referenced by ostream:745 (external/org_llvm_libcxx/include/ostream:745)
>>>               bazel-out/armeabihf-dbg/bin/holster/_objs/platform/main.pic.o:(std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned int))
>>> referenced by ostream:745 (external/org_llvm_libcxx/include/ostream:745)
>>>               bazel-out/armeabihf-dbg/bin/holster/_objs/platform/main.pic.o:(std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned int))

ld.lld: error: undefined symbol: std::terminate()
>>> referenced by main.cc
>>>               bazel-out/armeabihf-dbg/bin/holster/_objs/platform/main.pic.o:(__clang_call_terminate)

This is what the reference to boost looks like in the WORKSPACE

workspace(name = 'rpicar')

BAZEL_VERSION = "3.0.0"
BAZEL_VERSION_SHA = "3efb903ef885339a271445a9940642df704f97297fbe268f131d4fe36b02ea80"

load("//build-tools/workspace:default.bzl", "add_default_repositories")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

add_default_repositories()

load("@rpi_bazel//tools/workspace:default.bzl",
     rpi_bazel_add = "add_default_repositories")
rpi_bazel_add()


load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
    name = "com_github_nelhage_rules_boost",
    commit = "ccc90b00c2fae7267cc25b77199fb992acd5e799",
    remote = "https://github.com/nelhage/rules_boost",
)

load("@com_github_nelhage_rules_boost//:boost/boost.bzl", "boost_deps")
boost_deps()

"C compiler cannot create executables" when trying to cross compile a simple library built with CMake

I am getting C compiler cannot create executables error when trying to cross compile a simple library built with CMake using this repo.

# .bazelrc
build:pi --crosstool_top=@rpi_bazel//tools/cc_toolchain:toolchain
build:pi --cpu=aarch64
build:pi --compiler=clang
# WORKSPACE

# ...

http_archive(
    name = "rpi_bazel",
    url = "https://github.com/mjbots/rpi_bazel/archive/964b6feb8bb14b2a58876b406f17266538794c3a.zip",
    sha256 = "ef22526864f46d4bc42b09b421050697ebc1970f279f196b8f855048df6f3e3e",
    strip_prefix = "rpi_bazel-964b6feb8bb14b2a58876b406f17266538794c3a",
)

load("@rpi_bazel//tools/workspace:default.bzl",
    rpi_bazel_deps = "add_default_repositories")
rpi_bazel_deps()

# ...

http_archive(
    name = "com_github_the_tcpdump_group_libpcap",
    build_file = "//:bazel/cpp/libpcap/BUILD.libpcap.bzl",
    # Here you can use e.g. sha256sum cli utility to compute the sha sum.
    sha256 = "1783ff39f2a6eb99a7625c7ea471782614c94965ea934b6b22ac6eb38db266bc",
    strip_prefix = "libpcap-libpcap-1.10.4",
    url = "https://github.com/the-tcpdump-group/libpcap/archive/refs/tags/libpcap-1.10.4.tar.gz",
)
# bazel/cpp/libpcap/BUILD.libpcap.bzl

load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")

filegroup(
    name = "all_srcs",
    srcs = glob(["**"]),
)

cmake(
    name = "libpcap",
    cache_entries = {
        "CMAKE_C_FLAGS": "-fPIC",
    },
    lib_source = ":all_srcs",
    out_shared_libs = ["libpcap.so"],
    visibility = ["//visibility:public"],
)

Running:

bazel build --config=pi @com_github_the_tcpdump_group_libpcap//:libpcap

I get this output from rules_foreign_cc:

_____ BEGIN BUILD LOGS _____
+ AR=/home/henrik/.cache/bazel/.../external/rpi_bazel/tools/cc_toolchain/wrapper/clang-ar
+ ARFLAGS=rcsD
+ CC=/home/henrik/.cache/bazel/.../external/rpi_bazel/tools/cc_toolchain/wrapper/clang-clang
+ CFLAGS='-nostdinc++ -isystem /home/henrik/.cache/bazel/.../external/org_llvm_libcxx/include -isystem /home/henrik/.cache/bazel/.../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 -DNDEBUG -O2 -ffunction-sections -fdata-sections -fno-limit-debug-info -g0'
+ LD=/home/henrik/.cache/bazel/.../external/rpi_bazel/tools/cc_toolchain/wrapper/clang-clang
+ LDFLAGS='-lm -lpthread -ldl -lrt -Wl,-no-as-needed -pie -Wl,-z,relro,-z,now -Wl,--build-id=md5 -Wl,--hash-style=gnu -no-canonical-prefixes -B -Wl,--gc-sections -fuse-ld=lld -fno-limit-debug-info'
+ ./configure --without-guile --with-guile=no --disable-dependency-tracking --prefix=/home/henrik/.cache/bazel/.../bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_foreign_cc/toolchains/make
checking for a BSD-compatible install... /bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports the include directive... yes (GNU style)
checking for gcc... /home/henrik/.cache/bazel/.../external/rpi_bazel/tools/cc_toolchain/wrapper/clang-clang
checking whether the C compiler works... no
configure: error: in `/home/henrik/.cache/bazel/.../bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_foreign_cc/toolchains/make.build_tmpdir':
configure: error: C compiler cannot create executables
See `config.log' for more details
_____ END BUILD LOGS _____

Is there a way to use system cmake instead?

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.