Open mering opened 1 month ago
I've also run into this, while trying to build ffmpeg with rules_foreign_cc
I'm able to get a successful build by letting bazel just select the local c compiler but ideally I would like to use a hermetic llvm + sysroot.
my build fails with errors like this:
gcc: error: unrecognized command line option '--target=x86_64-unknown-linux-gnu'
gcc: error: unrecognized command line option '-fcolor-diagnostics'
gcc: error: unrecognized command line option '-Wthread-safety'
gcc: error: unrecognized command line option '-Wself-assign'
in config.log
Seems like this bug is probably related: https://trac.ffmpeg.org/ticket/9310
Adding "--cc=$$EXT_BUILD_ROOT/$(CC)"
to configure_options
fixed my build. I suspect that might work for this PR as well.
Adding
"--cc=$$EXT_BUILD_ROOT/$(CC)"
toconfigure_options
fixed my build. I suspect that might work for this PR as well.
@voxeljorge We have already been setting the --cc
option but I like using the CC
environment variable instead of the hard-coded path. I updated my example accordingly.
Unfortunately, the build still doesn't work (see PR description for instructions on how to reproduce the different errors).
The error for building ffmpeg
is Host compiler lacks C11 support
, even when setting --host-cc=$$EXT_BUILD_ROOT/$(CC)
.
I found that I had similar errors because not only is configure not using CC
, it is also not using CFLAGS
or any of the other env vars. I ended up writing a wrapper configure_wrapper
which would read the env vars and set --cc
, --extral-cflags
etc
I found that I had similar errors because not only is configure not using
CC
, it is also not usingCFLAGS
or any of the other env vars. I ended up writing a wrapperconfigure_wrapper
which would read the env vars and set--cc
,--extral-cflags
etc
@voxeljorge Could you share your wrapper?
I noticed that my build was missing the --sysroot
as CFLAGS
. I updated my branch accordingly but the hardcoded paths are ugly. Is this available in some makevar or similar?
libvpx
and libdav1d
are still not building in my branch. Do these codec libraries build for you?
I created two fixes for libdav1d
with meson
: #1302 #1303
I don't build libvpx or libdav1d at all. The configure wrapper is trivial:
#!/bin/bash
# ffmpeg ignores flags like CC/CXX and CFLAGS: https://trac.ffmpeg.org/ticket/9310
# so we have a wrapper which assigns them correctly
exec "$(dirname "$0")"/configure \
--cc="$CC" \
--cxx="$CXX" \
--extra-cflags="$CFLAGS" \
--extra-cxxflags="$CXXFLAGS" \
--extra-ldflags="$LDFLAGS" \
"$@"
The wrapper can be installed a couple of ways, you could inject it during the repository creation time what I did was copy the sources with something like this:
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
copy_to_directory(
name = "src",
srcs = [
"configure_wrapper",
"@ffmpeg_7_0_sources",
],
include_external_repositories = ["ffmpeg_7_0_sources"],
)
configure_make(
name = "ffmpeg",
lib_source = "//third_party/ffmpeg:src",
configure_command = "src/configure_wrapper",
)
I do have ffmpeg building with a limited set of codecs currently, even with a modern llvm and sysroot.
This does not build with the configured hermetic toolchain.
Instructions
(Optional) Run in container
Create container:
Setup container:
Build