bazel-contrib / bazel-contrib/rules_foreign_cc
meson rule doesn't copy out files correctly
- Dominant language
- Starlark
- Stars
- 737
- Forks
- 270
- PR merge metrics
- No merged PRs in 30d
Description
We are trying to use recently added `meson` rule to build glib and libffi, just as shown in [the example](https://sourcegraph.com/github.com/bazelbuild/rules_foreign_cc@main/-/blob/examples/third_party/glib/BUILD.libffi.bazel?L22:35)
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](https://sourcegraph.com/github.com/bazelbuild/rules_foreign_cc/-/blob/examples/third_party/glib/BUILD.gettext.bazel?L39-46)
`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/"
```
Contributor guide
Research direction
Start by reproducing the libffi and gettext builds from examples/third_party using the commands in the issue. Inspect BUILD.libffi.bazel, BUILD.gettext.bazel, the copy_ output, Meson.log, and Configure.log to trace why produced files are not recognized. Done means the Meson and configure_make builds succeed with their declared outputs created in the expected locations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- debian
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100