Bug 13508

Summary: Meson detects googletest installed on system
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Martin <marejde>
Component: devtools / tool chainAssignee: Ross Burton <ross.burton>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: alex.kanavin, meta.mr.watcher, meta.watcher, randy.macleod, ross.burton, sgw, tgamblin
Version: unspecified   
Target Milestone: Future   
Hardware: x86   
OS: Multiple   
Whiteboard: backport 3.1
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Martin 2019-09-10 08:29:59 UTC
The googletest dependency in Meson looks for files in /usr/src/gtest if no pkg-config file or prebuilt libraries can be found. See:

https://github.com/mesonbuild/meson/blob/d5026f13dedd91e3bf88a72c5be83217d94e3254/mesonbuild/dependencies/dev.py#L46

This will cause compilation errors when building a component that has automatic detection of googletest in it and does not have it as a dependency in its recipe or if building with an SDK that does not have googletest in it:

$ ninja -C build
...
arm-pelux-linux-gnueabi-g++ -march=armv7ve -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/home/martin/Downloads/pelux-rpi-sdk/sysroots/cortexa7t2hf-neon-vfpv4-pelux-linux-gnueabi -Isrc/common/unit_tests/src@common@unit_tests@@common-unit_tests@exe -Isrc/common/unit_tests -I../src/common/unit_tests -Isrc -I../src -I/home/martin/Downloads/pelux-rpi-sdk/sysroots/cortexa7t2hf-neon-vfpv4-pelux-linux-gnueabi/usr/include/glibmm-2.4 -I/home/martin/Downloads/pelux-rpi-sdk/sysroots/cortexa7t2hf-neon-vfpv4-pelux-linux-gnueabi/usr/lib/glibmm-2.4/include -I/home/martin/Downloads/pelux-rpi-sdk/sysroots/cortexa7t2hf-neon-vfpv4-pelux-linux-gnueabi/usr/include/glib-2.0 -I/home/martin/Downloads/pelux-rpi-sdk/sysroots/cortexa7t2hf-neon-vfpv4-pelux-linux-gnueabi/usr/lib/glib-2.0/include -I/home/martin/Downloads/pelux-rpi-sdk/sysroots/cortexa7t2hf-neon-vfpv4-pelux-linux-gnueabi/usr/include/sigc++-2.0 -I/home/martin/Downloads/pelux-rpi-sdk/sysroots/cortexa7t2hf-neon-vfpv4-pelux-linux-gnueabi/usr/lib/sigc++-2.0/include -I/usr/src/gtest -I/usr/src/gtest/include -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Wpedantic -std=c++17 -O0 -g -Wformat=2 -Woverloaded-virtual -Wshadow -Wsuggest-override -pthread  -MD -MQ 'src/common/unit_tests/src@common@unit_tests@@common-unit_tests@exe/gtest-all.cc.o' -MF 'src/common/unit_tests/src@common@unit_tests@@common-unit_tests@exe/gtest-all.cc.o.d' -o 'src/common/unit_tests/src@common@unit_tests@@common-unit_tests@exe/gtest-all.cc.o' -c /usr/src/gtest/src/gtest-all.cc
/usr/src/gtest/src/gtest-all.cc:38:10: fatal error: gtest/gtest.h: No such file or directory
 #include "gtest/gtest.h"
Comment 1 Ross Burton 2019-09-12 14:43:53 UTC
I'd say:
1) Change the self.src_dirs assignment to [] in our recipe
2) File upstream bug, maybe use $prefix instead of /usr?
Comment 2 Alexander Kanavin 2019-09-12 16:34:56 UTC
I am reluctant to make patches or submit bug reports for something I cannot reproduce. I'd suggest the original submitter should create and send a patch, and report the issue upstream, or at least share a recipe where the issue can be observed.
Comment 3 Martin 2019-09-12 17:09:59 UTC
(In reply to comment #1)
> I'd say:
> 1) Change the self.src_dirs assignment to [] in our recipe
> 2) File upstream bug, maybe use $prefix instead of /usr?

Thank you Ross, I sent a patch for using sys.prefix here https://github.com/mesonbuild/meson/pull/5919 . Should do the right thing when building in Yocto or with a Yocto generated SDK, I think.

(In reply to comment #2)
> I am reluctant to make patches or submit bug reports for something I cannot
> reproduce. I'd suggest the original submitter should create and send a
> patch, and report the issue upstream, or at least share a recipe where the
> issue can be observed.

Any component built with meson that has gtest as a dep in meson.build and does not have it as a dependency in its recipe should be a problem when building on a system that installs gtest source in /usr/src.
Comment 4 Martin 2019-09-12 17:20:28 UTC
Posted a comment in upstream pr about whether it makes sense for Meson or if it is something that needs to be patched in Yocto.
Comment 5 Randy MacLeod 2020-03-19 16:08:06 UTC
Hongxu is no longer working on YP so unassign defect.
Comment 6 Randy MacLeod 2020-10-27 08:06:46 UTC
Hongxu, I'd like to see this fix sooner than M4 so I've moved it to M2.
Comment 7 Randy MacLeod 2023-07-26 21:29:36 UTC
Bulk move to 4.3 M3.
Comment 8 Trevor Gamblin 2023-09-14 16:55:24 UTC
Moved to M4.
Comment 9 Saul Wold 2023-12-27 23:11:30 UTC
It appears that the request to patch upstream meson was denied according to the pull request against the Meson Source. So a patch should be created for the YP Meson recipe.

@martin, can you provide a reproducer? It would be required to correctly test the patch.
Comment 10 Ross Burton 2024-01-03 13:58:01 UTC
I just filed a new bug with meson to prod this further: https://github.com/mesonbuild/meson/issues/12690.
Comment 11 Stephen K Jolley 2024-02-15 16:02:49 UTC
Moved out of NEEDINFO
Comment 12 Ross Burton 2024-11-21 14:56:44 UTC
Posted 'meson: don't look on the host for GTest when cross-compiling' to the list.
Comment 13 Ross Burton 2024-12-13 17:44:25 UTC
Merged in feb9a58814720a4382d3f02467dcecb276f58040.