Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-37067: [C++] Install bundled GoogleTest #37483

Merged
merged 13 commits into from
Sep 6, 2023

Conversation

kou
Copy link
Member

@kou kou commented Aug 31, 2023

Rationale for this change

Because libarrow*_testing.so depend it. If we don't install bundled GoogleTest, users can't use libarrow*_testing.so.

What changes are included in this PR?

If we install bundled GoogleTest as-is, it may conflict existing GoogleTest. So this PR renames GoogleTest when we install GoogleTest:

  • lib{gtest,gtest_main,gmock,gmock_main}.so -> libarrow_{gtest,gtest_main,gmock,gmock_main}.so
  • ${PREFIX}/include/{gtest,gmock}/ -> ${PREFIX}/include/arrow-gtest/${gtest,gmock}/

Other CMake packages and .pc files aren't installed. ArrowTesting CMake package and arrow-testing.pc configures bundled GoogleTest instead.

Are these changes tested?

Yes.

Are there any user-facing changes?

Yes.

@kou kou force-pushed the cpp-gtest-bundled-install branch from a00e50a to 763a7e9 Compare August 31, 2023 01:48
@kou
Copy link
Member Author

kou commented Aug 31, 2023

@github-actions crossbow submit test-debian-11-* test-ubuntu-22.04-*

@github-actions

This comment was marked as outdated.

@kou kou force-pushed the cpp-gtest-bundled-install branch from c0d00c9 to 5e13c25 Compare August 31, 2023 04:53
@kou kou requested a review from kevingurney as a code owner August 31, 2023 04:53
@kou
Copy link
Member Author

kou commented Aug 31, 2023

@github-actions crossbow submit test-debian-11-* test-ubuntu-22.04-*

@github-actions
Copy link

Revision: 5e13c25

Submitted crossbow builds: ursacomputing/crossbow @ actions-311479b333

Task Status
test-debian-11-cpp-amd64 Github Actions
test-debian-11-cpp-i386 Github Actions
test-debian-11-go-1.17 Azure
test-debian-11-go-1.20 Azure
test-debian-11-python-3 Azure
test-ubuntu-22.04-cpp Github Actions
test-ubuntu-22.04-cpp-20 Github Actions
test-ubuntu-22.04-cpp-no-threading Github Actions
test-ubuntu-22.04-docs Github Actions
test-ubuntu-22.04-python-3 Github Actions

@kevingurney
Copy link
Member

Thanks for working on this @kou!

It seems that the C++ tests are failing for the macOS MATLAB build.

Unfortunately the reason for the failure isn't obvious from the build logs.

@sgilmore10 and I working on trying to reproduce this failure locally.

@kevingurney
Copy link
Member

kevingurney commented Aug 31, 2023

@sgilmore10 and I did manage to reproduce the test failures locally on macOS.

Here is the log output (note I replaced some personal information from the file paths with "..." ):

dyld[26962]: Library not loaded: libarrow_gtest.1.11.0.dylib

  Referenced from: <02638200-BA25-3D9D-AF66-D4C71F49AEFC> /System/Volumes/Data/.../arrow/matlab/build/placeholder_test

  Reason: tried: 'libarrow_gtest.1.11.0.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibarrow_gtest.1.11.0.dylib' (no such file), 'libarrow_gtest.1.11.0.dylib' (no such file), '/usr/local/lib/libarrow_gtest.1.11.0.dylib' (no such file), '/usr/lib/libarrow_gtest.1.11.0.dylib' (no such file, not in dyld cache), '/System/Volumes/Data/.../arrow/matlab/build/libarrow_gtest.1.11.0.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/System/Volumes/Data/.../arrow/matlab/build/libarrow_gtest.1.11.0.dylib' (no such file), '/System/Volumes/Data/.../arrow/matlab/build/libarrow_gtest.1.11.0.dylib' (no such file), '/usr/local/lib/libarrow_gtest.1.11.0.dylib' (no such file), '/usr/lib/libarrow_gtest.1.11.0.dylib' (no such file, not in dyld cache)

It appears that the linker is unable to find libarrow_gtest.1.11.0.dylib. However, we manually verified that ibarrow_gtest.1.11.0.dylib does appear under ${MATLAB_BUILD_DIR}/${ARROW_EP_PREFIX}/lib (e.g. .../matlab/build/arrow_ep-prefix/lib/) as expected.

It seems that the linker is not searching in .../matlab/build/arrow_ep-prefix/lib. We suspect this is the issue.

@kevingurney
Copy link
Member

It seems like this is some kind of rpath-related issue on macOS. There is an rpath warning in the build logs:

CMake Warning (dev):
  Policy CMP0042 is not set: MACOSX_RPATH is enabled by default.  Run "cmake
  --help-policy CMP0042" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

  MACOSX_RPATH is not specified for the following targets:

   gmock
   gmock_main
   gtest
   gtest_main

@sgilmore10
Copy link
Member

Hi @kou

@kevingurney and I spent some more time investigating this failure. Here's what we found:

  1. If you run the ldd command on the placeholder_test executable (with these changes), the names of the gtest and gtest_main libraries are specified as relative paths, while other library names are specified as absolute paths:
>> ldd placeholder_test
placeholder_test:
	libarrow_gtest.1.11.0.dylib (compatibility version 0.0.0, current version 1.11.0)
	libarrow_gtest_main.1.11.0.dylib (compatibility version 0.0.0, current version 1.11.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1300.36.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)
  1. However, if you run ldd on the placeholder_test executable built prior to these changes, the names for gtest and gtest_main are specified as absolute paths:
>> ldd placeholder_test
placeholder_test:
	</path/to/repo>/arrow/matlab/build/arrow_ep-build/googletest_ep-prefix/lib/libgtest.1.11.0.dylib (compatibility version 0.0.0, current version 1.11.0)
	</path/to/repo>/arrow/matlab/build/arrow_ep-build/googletest_ep-prefix/lib/libgtest_main.1.11.0.dylib (compatibility version 0.0.0, current version 1.11.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1300.36.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)

Note: I replaced some personal information with </path/to/repo>.

  1. We were able to run the placeholder_test executable successfully if we made the changes below:

    • Specify the MACOSX_RPATH property to TRUE for both targets gtest and gtest_main in arrow/cpp/cmake_modules/ThirdartyToolchain.cmake.
    • Specify the BUILD_RPATH property to "${CMAKE_CURRENT_BINARY_DIR}/arrow_ep-prefix/lib" for target placeholder_test in arrow/matlab/CMakeLists.txt.

With those changes, the executable runs as expected:

Internal ctest changing into directory: <path/to/repo>/arrow/matlab/build
Test project <path/to/repo>/arrow/matlab/build
    Start 1: PlaceholderTestTarget
1/1 Test #1: PlaceholderTestTarget ............   Passed    0.01 sec

100% tests passed, 0 tests failed out of 1

Total Test time (real) =   0.03 sec
  1. For reference, here's the output of ldd placeholder with these changes applied:
placeholder_test:
	@rpath/libarrow_gtest.1.11.0.dylib (compatibility version 0.0.0, current version 1.11.0)
	@rpath/libarrow_gtest_main.1.11.0.dylib (compatibility version 0.0.0, current version 1.11.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1300.36.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)

I'm not sure if this solution is the right one, but wanted to share with you what we found.

Best,
Sarah

@kou
Copy link
Member Author

kou commented Sep 1, 2023

@kevingurney @sgilmore10 Thanks for your help! It's very helpful. I'll use the MACOS_RPATH in cpp/ approach.

BTW, it seems that we can remove GoogleTest support from matlab/ because we can run all unit tests for MATLAB with the MATLAB's testing framework now.

@kou
Copy link
Member Author

kou commented Sep 1, 2023

Ah, do we need to set both of MACOSX_RPATH and BUILD_RPATH?

@sgilmore10
Copy link
Member

Ah, do we need to set both of MACOSX_RPATH and BUILD_RPATH?

Yes, I had to set both to get it to work.

@sgilmore10
Copy link
Member

@kevingurney @sgilmore10 Thanks for your help! It's very helpful. I'll use the MACOS_RPATH in cpp/ approach.

BTW, it seems that we can remove GoogleTest support from matlab/ because we can run all unit tests for MATLAB with the MATLAB's testing framework now.

I think we want to keep the GoogleTest support for now because we do plan on adding C++ unit tests. There are a few error-conditions that cannot be triggered from MATLAB for which we want to add C++ unit tests.

@kevingurney
Copy link
Member

kevingurney commented Sep 1, 2023

I agree with @sgilmore10. I don't think it would be ideal to completely remove GoogleTest because C++ tests would be beneficial for the MATLAB interface.

@kevingurney kevingurney closed this Sep 1, 2023
@kevingurney kevingurney reopened this Sep 1, 2023
@kevingurney
Copy link
Member

@kou - sorry! I accidentally hit the "Close with comment" button rather than the "Comment" button. I just reopened the pull request.

@kou
Copy link
Member Author

kou commented Sep 4, 2023

@sgilmore10 @kevingurney I see. I don't remove the GoogleTest support in matlab/ in this PR. But can we discuss it in #37532?

@kou
Copy link
Member Author

kou commented Sep 4, 2023

I'll merge this in this week if nobody objects this.

@kou
Copy link
Member Author

kou commented Sep 4, 2023

Ah, do we need to set both of MACOSX_RPATH and BUILD_RPATH?

Yes, I had to set both to get it to work.

Thanks! It worked by adding BUILD_RPATH too!

@kevingurney
Copy link
Member

kevingurney commented Sep 5, 2023

@kou - very sorry for the delayed response. I was out sick at the end of last week and am just getting caught up now.

These changes look good!

Thanks for bringing up the GoogleTest question and capturing it in #37532. After further consideration, we agree that it is worth thinking more about removing GoogleTest. As you suggested, we can discuss this in more detail on #37532.

Thank you!

@kevingurney
Copy link
Member

+1

@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting committer review Awaiting committer review labels Sep 5, 2023
@kou
Copy link
Member Author

kou commented Sep 6, 2023

No problem. I'm not in hurry. :-)

Thanks for your approvement. I merge this.

@kou kou merged commit ad7f6ef into apache:main Sep 6, 2023
34 checks passed
@kou kou deleted the cpp-gtest-bundled-install branch September 6, 2023 01:44
@kou kou removed the awaiting merge Awaiting merge label Sep 6, 2023
@conbench-apache-arrow
Copy link

After merging your PR, Conbench analyzed the 5 benchmarking runs that have been run so far on merge-commit ad7f6ef.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about possible false positives for unstable benchmarks that are known to sometimes produce them.

@danepitkin
Copy link
Member

@github-actions crossbow submit java-jars

@github-actions
Copy link

github-actions bot commented Oct 6, 2023

Revision: 52138c1

Submitted crossbow builds: ursacomputing/crossbow @ actions-e36e4f51b2

Task Status
java-jars Github Actions

loicalleyne pushed a commit to loicalleyne/arrow that referenced this pull request Nov 13, 2023
### Rationale for this change

Because `libarrow*_testing.so` depend it. If we don't install bundled GoogleTest, users can't use `libarrow*_testing.so`.

### What changes are included in this PR?

If we install bundled GoogleTest as-is, it may conflict existing GoogleTest. So this PR renames GoogleTest when we install GoogleTest:

* `lib{gtest,gtest_main,gmock,gmock_main}.so` -> `libarrow_{gtest,gtest_main,gmock,gmock_main}.so`
* `${PREFIX}/include/{gtest,gmock}/` -> `${PREFIX}/include/arrow-gtest/${gtest,gmock}/`

Other CMake packages and `.pc` files aren't installed. `ArrowTesting` CMake package and `arrow-testing.pc` configures bundled GoogleTest instead.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

Yes.
* Closes: apache#37067

Authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
dgreiss pushed a commit to dgreiss/arrow that referenced this pull request Feb 19, 2024
### Rationale for this change

Because `libarrow*_testing.so` depend it. If we don't install bundled GoogleTest, users can't use `libarrow*_testing.so`.

### What changes are included in this PR?

If we install bundled GoogleTest as-is, it may conflict existing GoogleTest. So this PR renames GoogleTest when we install GoogleTest:

* `lib{gtest,gtest_main,gmock,gmock_main}.so` -> `libarrow_{gtest,gtest_main,gmock,gmock_main}.so`
* `${PREFIX}/include/{gtest,gmock}/` -> `${PREFIX}/include/arrow-gtest/${gtest,gmock}/`

Other CMake packages and `.pc` files aren't installed. `ArrowTesting` CMake package and `arrow-testing.pc` configures bundled GoogleTest instead.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

Yes.
* Closes: apache#37067

Authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[C++][CI] Flight tests fail running on some configurations
4 participants