rules_foreign_cc
rules_foreign_cc copied to clipboard
meson rule doesn't copy out files correctly
We are trying to use recently added meson rule to build glib and libffi, just as shown in the example
While it worked on my local (debian/buster) but fails on the following error in our CI (docker container in EC2 also debian buster) repro:
testuser@ip-x-x-x-x:~$ git clone https://github.com/bazelbuild/rules_foreign_cc.git
...
testuser@ip-x-x-x-x:~/rules_foreign_cc$ curl -L https://github.com/bazelbuild/bazelisk/releases/download/v1.17.0/bazelisk-linux-amd64 -o /tmp/bazelisk
...
testuser@ip-x-x-x-x:~/rules_foreign_cc$ cd rules_foreign_cc/examples/third_party
testuser@ip-x-x-x-x:~/rules_foreign_cc/examples/third_party$ /tmp/bazelisk build @libffi --sandbox_debug -s
INFO: Analyzed target @libffi//:libffi (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
...
ERROR: /home/testuser/.cache/bazel/_bazel_testuser/.../external/libffi/BUILD.bazel:10:6: output 'external/libffi/libffi/lib/x86_64-linux-gnu/libffi.so.7.1.0' was not created
ERROR: /home/testuser/.cache/bazel/_bazel_testuser/.../external/libffi/BUILD.bazel:10:6: Foreign Cc - Meson: Building libffi failed: not all outputs were created or valid
Target @libffi//:libffi failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 3.123s, Critical Path: 2.89s
INFO: 2 processes: 1 internal, 1 linux-sandbox.
FAILED: Build did NOT complete successfully
However, I can find the file in the workspace's copy_ folder
testuser@ip-x-x-x-x:~/rules_foreign_cc/examples/third_party$ find /home/testuser/.cache/bazel/_bazel_testuser/.../execroot/ | grep libffi.so.7.1.0
/home/testuser/.cache/bazel/_bazel_testuser/.../execroot/rules_foreign_cc_examples_third_party/bazel-out/k8-fastbuild/bin/external/libffi/copy_libffi/libffi/lib/libffi.so.7.1.0
as well as Meson.log
testuser@ip-x-x-x-x:~/rules_foreign_cc/examples/third_party$ tail -n 5 bazel-out/k8-fastbuild/bin/external/libffi/libffi_foreign_cc/Meson.log
...
Installing symlink pointing to libffi.so.7.1.0 to /home/testuser/.cache/bazel/_bazel_testuser/c58a3a196ee30570ef2b2b5639e5691c/sandbox/linux-sandbox/13/execroot/rules_foreign_cc_examples_third_party/bazel-out/k8-fastbuild/bin/external/libffi/libffi/lib/libffi.so.7
Installing symlink pointing to libffi.so.7 to /home/testuser/.cache/bazel/_bazel_testuser/c58a3a196ee30570ef2b2b5639e5691c/sandbox/linux-sandbox/13/execroot/rules_foreign_cc_examples_third_party/bazel-out/k8-fastbuild/bin/external/libffi/libffi/lib/libffi.so
testuser@ip-10-205-16-143:~/rules_foreign_cc/examples/third_party$ ls -lh /home/testuser/.cache/bazel/_bazel_testuser/c58a3a196ee30570ef2b2b5639e5691c/sandbox/linux-sandbox/13/execroot/rules_foreign_cc_examples_third_party/bazel-out/k8-fastbuild/bin/external/libffi/libffi/lib/libffi.so.7
lrwxrwxrwx 1 testuser testuser 15 Jul 13 20:21 /home/testuser/.cache/bazel/_bazel_testuser/c58a3a196ee30570ef2b2b5639e5691c/sandbox/linux-sandbox/13/execroot/rules_foreign_cc_examples_third_party/bazel-out/k8-fastbuild/bin/external/libffi/libffi/lib/libffi.so.7 -> libffi.so.7.1.0
This also happens for configure_make rule
testuser@ip-x-x-x-x:~/rules_foreign_cc/examples/third_party$ /tmp/bazelisk build @gettext --sandbox_debug -s
...
ERROR: /home/testuser/.cache/bazel/_bazel_testuser/.../external/gettext/BUILD.bazel:13:15: output 'external/gettext/gettext/lib/gettext.a' was not created
ERROR: /home/testuser/.cache/bazel/_bazel_testuser/.../external/gettext/BUILD.bazel:13:15: Foreign Cc - Configure: Building gettext failed: not all outputs were created or valid
Target @gettext//:gettext failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 197.812s, Critical Path: 195.50s
INFO: 4 processes: 3 internal, 1 linux-sandbox.
FAILED: Build did NOT complete successfully
despite that gettext.a is not even in the out list
Configure.log seems to stop halfway
testuser@ip-x-x-x-x:~/rules_foreign_cc/examples/third_party/bazel-out/k8-fastbuild/bin/external/gettext/gettext_f
oreign_cc$ tail -n 5 Configure.log
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/home/testuser/.cache/bazel/_bazel_testuser/.../sandbox/linux-sandbox/12/execroot/rules_foreign_cc_examples_third_party/bazel-out/k8-fastbuild/bin/external/gettext/gettext.build_tmpdir'
make[2]: Leaving directory '/home/testuser/.cache/bazel/_bazel_testuser/.../sandbox/linux-sandbox/12/execroot/rules_foreign_cc_examples_third_party/bazel-out/k8-fastbuild/bin/external/gettext/gettext.build_tmpdir'
make[1]: Leaving directory '/home/testuser/.cache/bazel/_bazel_testuser/.../sandbox/linux-sandbox/12/execroot/rules_foreign_cc_examples_third_party/bazel-out/k8-fastbuild/bin/external/gettext/gettext.build_tmpdir'
+ set +x
any pointers I can look into? cc @jheaff1
testuser@ip-x-x-x-x:~/rules_foreign_cc/examples/third_party$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
The libffi issue is that the build target defined in the rules_foreign_cc examples expects the .so file to have the path lib/x86_64-linux-gnu/libffi.so.7.1.0. Yet in your build, the generated so file path has no x86_64-linux-gnu segment. It seems meson adds this segment for Ubuntu (used by rules_foreign_cc CI builds) and not Debian
simply remove “/x86_64-linux-gnu” from the libffi BUILD file.
The gettext issue is because for Linux, there are no output shared libs specified in the BUILD file. Rules_foreign_cc expects the build to generate lib
Also, it shouldn’t be necessary to build gettext for Linux as it is built into gcc. This is why the BUILD file for gettext is not complete for all platforms, as rules_foreign_cc only needs to build it for macOS
@jheaff1 thanks a lot for your reply.
remove “/x86_64-linux-gnu” this did help. However, my dev box is debian, and it does generate x86_64-linux-gnu segment.
dev environment -- removing “/x86_64-linux-gnu” fails
➜ glib-meson_foreign_cc_failing cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
...
output 'external/libffi/libffi/lib/libffi.a' was not created
on our CI, removing that said dir works
testuser@ip-x-x-x-x:/go-code$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"