Skip to content

Conversation

@PierreZ
Copy link
Contributor

@PierreZ PierreZ commented Aug 2, 2021

This PR is related to #5218.

The goal of this PR is to add CMake's options to choose which bindings you want to build at compile time.
It introduces one CMake option(defaulting to ON) per binding:

  • BUILD_C_BINDING
  • BUILD_JAVA_BINDING
  • BUILD_PYTHON_BINDING
  • BUILD_DOCUMENTATION
  • BUILD_GO_BINDING
  • BUILD_RUBY_BINDING

Code-Reviewer Section

The general guidelines can be found here.

Please check each of the following things and check all boxes before accepting a PR.

  • The PR has a description, explaining both the problem and the solution.
  • The description mentions which forms of testing were done and the testing seems reasonable.
  • Every function/class/actor that was touched is reasonably well documented.

For Release-Branches

If this PR is made against a release-branch, please also check the following:

  • This change/bugfix is a cherry-pick from the next younger branch (younger release-branch or master if this is the youngest branch)
  • There is a good reason why this PR needs to go into a release branch and this reason is documented (either in the description above or in a linked GitHub issue)

@foundationdb-ci
Copy link
Contributor

AWS CodeBuild CI Report

  • CodeBuild project: foundationdb-pull-request-build
  • Commit ID: 0cd7b79
  • Result: SUCCEEDED
  • Build Logs (available for 7 days)

Copy link
Collaborator

@sfc-gh-mpilman sfc-gh-mpilman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dependencies with bindings (especially python) is sadly quite complex...

Apart from the comments I left, I am also not sure whether the output at the end will be correct (not sure whether it was before either, so I won't insist on this getting fixed in this PR). For example: If the C bindings are not build but go bindings is enabled, the output will tell a user that the go bindings will be built (even though there's a dependency).

So I think the logic has to be:

  1. Python not found -> don't build any bindings
  2. C bindings are disabled -> don't build any bindings
  3. If Python is found and the C bindings are enabled, all other bindings can be disabled/enabled individually (if their dependencies are found).

Also, I would prefer if cmake wouldn't change the option. Instead, cmake should use the option to initialize some other variable, but optimally an option would be only read-only.

CMakeLists.txt Outdated
if(WITH_PYTHON)
add_subdirectory(bindings)
endif()
add_subdirectory(bindings)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All bindings depend on python. We use a python script to generate some assembly code that is required for the C bindings

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the tips 👍

else()
#message(FATAL_ERROR "Could not found a suitable python interpreter")
option(BUILD_PYTHON_BINDING "build python binding" ON)
if(NOT BUILD_PYTHON_BINDING)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple things in the build system (at least the C bindings and the documentation) depend on python. So I think you need to run find_package(Python COMPONENTS Interpreter) even if you don't want to build the python bindings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the tips 👍

@PierreZ PierreZ force-pushed the cmake/options branch 2 times, most recently from bd75251 to 3692d99 Compare August 5, 2021 13:54
@PierreZ
Copy link
Contributor Author

PierreZ commented Aug 5, 2021

I should have taken all your comments into consideration, PTAL 😄

@foundationdb-ci
Copy link
Contributor

AWS CodeBuild CI Report

  • CodeBuild project: foundationdb-pull-request-build
  • Commit ID: bd75251
  • Result: FAILED
  • Build Logs (available for 7 days)

@foundationdb-ci
Copy link
Contributor

AWS CodeBuild CI Report

  • CodeBuild project: foundationdb-pull-request-build-macos
  • Commit ID: bd75251
  • Result: FAILED
  • Build Logs (available for 7 days)

@foundationdb-ci
Copy link
Contributor

AWS CodeBuild CI Report

  • CodeBuild project: foundationdb-pull-request-build
  • Commit ID: 3692d99
  • Result: FAILED
  • Build Logs (available for 7 days)

@foundationdb-ci
Copy link
Contributor

AWS CodeBuild CI Report

  • CodeBuild project: foundationdb-pull-request-build
  • Commit ID: e52fc41
  • Result: FAILED
  • Build Logs (available for 7 days)

@foundationdb-ci
Copy link
Contributor

AWS CodeBuild CI Report

  • CodeBuild project: foundationdb-pull-request-build-macos
  • Commit ID: e52fc41
  • Result: FAILED
  • Build Logs (available for 7 days)

Copy link
Collaborator

@sfc-gh-mpilman sfc-gh-mpilman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but breaks the documentation build

Comment on lines 110 to 111
option(BUILD_DOCUMENTATION "build documentation" ON)
if (BUILD_DOCUMENTATION AND WITH_PYTHON)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use ${Python3_EXECUTABLE} in documentation/CMakeLists.txt. Removing the call to find_package(Python3) will make this then fail (so the documentation doesn't build anymore.

The easiest solution would be to reintroduce that call, though that is not pretty. Alternatively you could do the following:

  1. Replace ${Python3_EXECUTABLE}
  2. Only set WITH_PYTHON to ON if Python_VERSION_MAJOR is 3 or:
Suggested change
option(BUILD_DOCUMENTATION "build documentation" ON)
if (BUILD_DOCUMENTATION AND WITH_PYTHON)
option(BUILD_DOCUMENTATION "build documentation" ON)
if (BUILD_DOCUMENTATION AND WITH_PYTHON AND Python_VERSION_MAJOR EQUAL 3)

@PierreZ
Copy link
Contributor Author

PierreZ commented Aug 5, 2021

Should be better now, thanks! I tried downloading the log archives from the build, but they were empty, do you know why?

@foundationdb-ci
Copy link
Contributor

AWS CodeBuild CI Report

  • CodeBuild project: foundationdb-pull-request-build
  • Commit ID: 415bf2a
  • Result: SUCCEEDED
  • Build Logs (available for 7 days)

@sfc-gh-mpilman
Copy link
Collaborator

I tried downloading the log archives from the build, but they were empty, do you know why?

The build logs are only available for a very short amount of time (the "available for 7 days" message is not accurate). They usually get deleted within hours -- but sometimes even within minutes. But the Linux build succeeded, macOS CI is not ready yet and the result can be ignored.

@sfc-gh-mpilman sfc-gh-mpilman merged commit eb90854 into apple:master Aug 6, 2021
@PierreZ
Copy link
Contributor Author

PierreZ commented Aug 9, 2021

The build logs are only available for a very short amount of time (the "available for 7 days" message is not accurate). They usually get deleted within hours -- but sometimes even within minutes. But the Linux build succeeded, macOS CI is not ready yet and the result can be ignored.

Thanks for your help @sfc-gh-mpilman 👍 Do you have any policy/rules regarding cherry-pick for release-7.0 ?

@sfc-gh-mpilman
Copy link
Collaborator

Do you have any policy/rules regarding cherry-pick for release-7.0 ?

Typically cherry-picks have to either be strict bug fixes or changes that are required for a business reason (very loosely defined as "we need this change in order to fix an imminent problem with a production system"). Cherry-picks also are not allowed to cause any behavior-change and need to go through more testing and they require two review-approvals.

I think this change is ok to back port to 7.0. But the following will be needed:

  1. Link to this PR in the description of the cherry-pick PR
  2. Describe the testing that you've done. I think for a cherry-pick you would need to test this on macOS and on Linux. Something like "verified manually X, Y, and Z" would be sufficient -- there's no hard rules, you just need to convince the reviewers ;) I would assume that this won't require a lot of testing though.
  3. Provide a reason why you want to cherry-pick (or rather why waiting for 7.1 would be a problem).

@PierreZ
Copy link
Contributor Author

PierreZ commented Aug 11, 2021

I think this change is ok to back port to 7.0. But the following will be needed:

1. Link to this PR in the description of the cherry-pick PR

2. Describe the testing that you've done. I think for a cherry-pick you would need to test this on macOS and on Linux. Something like "verified manually X, Y, and Z" would be sufficient -- there's no hard rules, you just need to convince the reviewers ;) I would assume that this won't require a lot of testing though.

3. Provide a reason why you want to cherry-pick (or rather why waiting for 7.1 would be a problem).

Thanks for all the information. I cherry-picked my commit against release-7.0 for testing. For now, I cannot verify my commit:

  • using my source-based distribution, with release-7.0, I'm having an issue where:
    • boost is not detected anymore (was detected on tag 6.3.X),
    • then boost needs to be downloaded and compiled, triggering a compile error,
  • using the official Docker image foundationdb/build:centos7-latest, I cannot build any branch, even master, because of an C compiler does not support c11 atomics. I created a dummy Github action that can reproduce the issue.

I will dig in both of them.

@sfc-gh-mpilman
Copy link
Collaborator

The official docker image is based on CentOS 7 which comes with a very old version of gcc. You either have to use devtoolset or clang (clang is probably better, as compilation times are much lower). A relatively recent version of clang is installed in the official docker image

@PierreZ
Copy link
Contributor Author

PierreZ commented Aug 11, 2021

The official docker image is based on CentOS 7 which comes with a very old version of gcc. You either have to use devtoolset or clang (clang is probably better, as compilation times are much lower). A relatively recent version of clang is installed in the official docker image

Thanks, GH action is working properly thanks to your devtoolset advice 🚀 I will try clang later, I will dig into my boost error:

*** argument error
* rule path.root ( path root )
* called with: (  )
* missing argument root

Thanks again for all your help @sfc-gh-mpilman !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants