-
Notifications
You must be signed in to change notification settings - Fork 143
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
Fix build for macos #2397
Fix build for macos #2397
Conversation
auto load java home path on macos update to latest nmslib revision Signed-off-by: Samuel Herman <[email protected]>
Signed-off-by: Samuel Herman <[email protected]>
Signed-off-by: Samuel Herman <[email protected]>
Thank you for the issue. Will take a look within this week |
Is there a particular commit we are trying to pull in for nmslib? |
build.gradle
Outdated
@@ -327,13 +327,17 @@ task cmakeJniLib(type:Exec) { | |||
args.add("-DAVX512_ENABLED=${avx512_enabled}") | |||
args.add("-DCOMMIT_LIB_PATCHES=${commit_lib_patches}") | |||
args.add("-DAPPLY_LIB_PATCHES=${apply_lib_patches}") | |||
if (Os.isFamily(Os.FAMILY_MAC)) { | |||
args.add("-DJAVA_HOME=\$(/usr/libexec/java_home)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this going to work for MacOS? I guess concern is if some mac wont have this set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, MacOs should have this set when Java is installed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should avoid this and make it rely on user's environment variable when building.
Including myself, we should be able to run OS with several JDKs. (ex: JDK21, JDK17 etc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you setup your Java correctly on mac, /usr/libexec/java_home
this should always point to your local selected java home directory. Also if the home directory is not correct, cmake will ignore this parameter.
Generally speaking, you want the build to be smooth with as little manual overhead as possible to avoid confused developers.
For reference:
https://stackoverflow.com/a/31667558/29214278
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got your point, my bad. I thought you're overriding JAVA_HOME in CMake, but having it in build.gradle.
Yeah, this makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the second thought, this should be the actual Java home path that gradle is using.
Could you replace it with org.gradle.internal.jvm.Jvm.current().getJavaHome()
instead?
User may configure different JDK to run gradle, and we want to make sure that the same JDK to be used for building JNI and runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, will add the change.
if(CMAKE_C_COMPILER_ID MATCHES "Clang\$") | ||
set(OpenMP_C_FLAGS "-Xpreprocessor -fopenmp") | ||
set(OpenMP_C_LIB_NAMES "omp") | ||
set(OpenMP_omp_LIBRARY /opt/homebrew/opt/libomp/lib/libomp.dylib) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this also going to be system dependent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes this is system independent. Newer version of brew will use that path by default while the old ones use the old path that was hard coded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concern is more that users may not use brew to install omp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The guideline in the instructions right now for Mac is to use brew, if this guideline is followed the build will fail unless the above is set.
Yes, note that this issue is occurring on CLang 14+ |
Hi @sam-herman Could you also update DEVELOPER.md as well to say that user can build with a particular JDK they want by providing custom Java path in |
sounds good, I actually have an idea how we can avoid those issues going forward, but for now I can remove that and we can break into a different PR.
will do. |
Signed-off-by: Samuel Herman <[email protected]>
Signed-off-by: sam-herman <[email protected]>
Hi @0ctopus13prime @naveentatikonda thank you very much for reviewing and approving! looks like all the checks have passed, can one of you merge the PR? Unfortunately I don't have permissions to do so. |
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.x 2.x
# Navigate to the new working tree
cd .worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-2397-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 8374b8f165124d96bc4be398d84d35b18d4bf290
# Push it to GitHub
git push --set-upstream origin backport/backport-2397-to-2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.x Then, create a pull request where the |
@sam-herman looks like automated backport failed. Please do the manual backport. |
* fix paths for libomp on newer homebrew versions auto load java home path on macos update to latest nmslib revision Signed-off-by: Samuel Herman <[email protected]> * make it work for x86_64 mac as well Signed-off-by: Samuel Herman <[email protected]> * remove commented code Signed-off-by: Samuel Herman <[email protected]> * review comments Signed-off-by: Samuel Herman <[email protected]> --------- Signed-off-by: Samuel Herman <[email protected]> Signed-off-by: sam-herman <[email protected]> Co-authored-by: Samuel Herman <[email protected]> (cherry picked from commit 8374b8f)
@navneet1v created a backport PR |
* fix paths for libomp on newer homebrew versions auto load java home path on macos update to latest nmslib revision Signed-off-by: Samuel Herman <[email protected]>
* fix paths for libomp on newer homebrew versions auto load java home path on macos update to latest nmslib revision Signed-off-by: Samuel Herman <[email protected]> * make it work for x86_64 mac as well Signed-off-by: Samuel Herman <[email protected]> * remove commented code Signed-off-by: Samuel Herman <[email protected]> * review comments Signed-off-by: Samuel Herman <[email protected]> --------- Signed-off-by: Samuel Herman <[email protected]> Signed-off-by: sam-herman <[email protected]> Co-authored-by: Samuel Herman <[email protected]>
Description
This change fixes the build issues for the C++ portion of the codebase on MacOSX for both nmslib by upgrading to the latest version and for faiss by setting the correct flags and using the right dependencies and directory paths
Ideally with this fix we will not need to ask developers to manually run text replacement commands like there are currently in the
DEVELOPER.md
fileRelated Issues
Resolves #2272
Check List
--signoff
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.