Open yurivict opened 1 year ago
We do have a clang-12 build in the CI (sample build here: https://github.com/chipsalliance/verible/actions/runs/4602833394/jobs/8132234894)
We need to check whether the failure you see is caused by newer clang, freebsd or a combination of factors.
It generally depends on compiler + c++ library combination.
We do have the needed c++17 flags in the .bazelrc, but it is separated by platforms, as Windows requires its own sets of fields; here it is explicitly set for 'common:linux' https://github.com/chipsalliance/verible/blob/master/.bazelrc#L11
I suspect there might be something like 'common:bsd' or similar where this can can be made work ? Ideally, maybe a more generic term such as common:unix
would be good. Something to extract from the bazel documentation and then fixed in the .bazelrc.
We do have the needed c++17 flags in the .bazelrc, but it is separated by platforms [...]
They shouldn't be separated by platform. This makes it error prone. The build tool configuration should support setting C++ standard.
In cmake it works like this:
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
This link suggests that BAZEL_CXXOPTS="-std=c++14"
should set the C++ standard but this doesn't work in verible
.
I wonder why do you need to use Bazel. Bazel only makes it very difficult to build the project, and this hurts project's distribution, because people simply can't build it.
Can you try again from head ? Settings should now work for freebsd and openbsd.
The previous error is gone.
But now it breaks later:
ld: error: undefined symbol: ceilf
>>> referenced by time_zone_impl.cc
On FreeBSD (and probably other BSDs) math functions are in libm.so, so -lm
is needed.
I added --linkopt="-lm"
to bazel's command line, but this doesn't propagate for some reason.
Can you also add --host_linkopt=-lm
?
Adding --linkopt=-lm --host_linkopt=-lm
helped - now it finishes successfully.
Alright, can you try again compiling from head ?
It builds now, thank you.
However, it downloads files during build. This isn't allowed from the package builder.
Particularly, it downloads more files from bazel scripts in the protobuf tarball. Do you know if there is a way to use pre-installed protobuf instead?
yes, I am sorry, the vendored dependencies in bazel are a common headache while packaging, as bazel insists on fetching it themselve.
I think there is a way to do the vendored dependencies from local places, but I have not explored that too much.
There is a way to separate the 'fetching dependencies' (which needs internet access) and 'building' (which does not). The following illustrates how that can work.
It is not optimal, but it can be a starting point for the packaging
#!/usr/bin/env bash
# Use BASE_DIR if set, otherwise TMPDIR
export TMPDIR=${TMPDIR:-/tmp}
BASE_DIR=${BASE_DIR:-$TMPDIR}
# Use local flex and bison
ADDITIONAL_BAZEL_OPTIONS="--//bazel:use_local_flex_bison"
# Where we want the final installation to be
PREFIX=${PREFIX:-${BASE_DIR}/install}
# Packaging directory: contains the source and all dependencies
PACKAGE_DIR="${BASE_DIR}/verible-package"
mkdir -p "${PACKAGE_DIR}"
git clone https://github.com/chipsalliance/verible "${PACKAGE_DIR}/src"
cd "${PACKAGE_DIR}/src"
# Force fetching all the dependencies. This should work with
# bazel fetch //..., but because of
# https://github.com/bazelbuild/bazel/issues/13847 this is not working yet.
# But the trick forcing to fetch everything by querying the deps works:
bazel --output_base="${PACKAGE_DIR}/bazel" cquery ${ADDITIONAL_BAZEL_OPTIONS} "deps(//...)" > /dev/null
########################################################
#----- Internet needed above, but not below anymore ---
########################################################
cd "${PACKAGE_DIR}/src"
bazel --output_base="${PACKAGE_DIR}/bazel" build ${ADDITIONAL_BAZEL_OPTIONS} -c opt --fetch=false :install-binaries
# Install binaries using the install tool. I think that might use some
# gnu-install flags, so hopefully it also works on BSD; if not, please report,
# then let's fix that.
bazel --output_base="${PACKAGE_DIR}/bazel" run ${ADDITIONAL_BAZEL_OPTIONS} -c opt --fetch=false :install -- "${PREFIX}/bin"
echo "Binaries are now in ${PREFIX}/bin"
ls -l "${PREFIX}/bin"
Describe the bug
Build fails with this error:
The C++20 option helps:
bazel build -c opt //... --cxxopt=-std=c++20
This needs to be part of the build scripts.Is there any way to build with cmake?
clang-14 bazel-5.3.0 FreeBSD 13.1