-
Notifications
You must be signed in to change notification settings - Fork 251
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
Add C++ compatibility with macOS #474
base: main
Are you sure you want to change the base?
Conversation
@darvg can you please add some CI tests for mac to validate the changes. |
@darvg - I'm going to give this a pull and see how close this gets us to a python release for macos too. thank you for this contribution |
I'm getting an error on build now: MacOS version: dax@cloudship DiskANN: $ sw_vers
ProductName: macOS
ProductVersion: 14.3
BuildVersion: 23D56 dax@cloudship DiskANN: $ cmake --build build
[ 0%] Building CXX object src/CMakeFiles/diskann.dir/abstract_data_store.cpp.o
[ 1%] Building CXX object src/CMakeFiles/diskann.dir/ann_exception.cpp.o
[ 2%] Building CXX object src/CMakeFiles/diskann.dir/apple_aligned_file_reader.cpp.o
In file included from /Users/dax/dev/DiskANN/src/apple_aligned_file_reader.cpp:1:
In file included from /Users/dax/dev/DiskANN/include/aligned_file_reader.h:84:
/Users/dax/dev/DiskANN/include/utils.h:39:9: fatal error: '_MM_HINT_T0' macro redefined [-Wmacro-redefined] git pull darvg
git checkout sid/apple
cmake -S . -B build
brew install boost clang-format libomp gperftools
cmake -S . -B build
cmake --build build Mine is an intel based macbook too, so I don't know if that has something to do with this or what. Imagine I've never built a cxx project on mac before, because that's exactly where I am at! |
@daxpryce I believe this error is popping up because |
I don't necessarily think that this PR needs to address it, but we should create an issue to support x86_64 macOS as well in the future. I'm not really able to pull this and test it out locally so I'm unsure I can really do a good code review - at least not any better than @rakri would do :) I guess if it looks sane and builds on the CI action runners (note to everyone else: picking the |
@daxpryce I added in a possible fix for compiling on Intel Machines (luckily, I think the only issue is the one you reported). The GitHub action didn't trigger, but I tried compiling it locally with Rosetta and it built, so hopefully there are no other errors. |
@darvg I'm getting a new build error: dax@cloudship DiskANN: $ cmake --build build
[ 0%] Building CXX object src/CMakeFiles/diskann.dir/abstract_data_store.cpp.o
[ 1%] Building CXX object src/CMakeFiles/diskann.dir/ann_exception.cpp.o
[ 2%] Building CXX object src/CMakeFiles/diskann.dir/apple_aligned_file_reader.cpp.o
In file included from /Users/dax/dev/DiskANN/src/apple_aligned_file_reader.cpp:1:
In file included from /Users/dax/dev/DiskANN/include/aligned_file_reader.h:84:
/Users/dax/dev/DiskANN/include/utils.h:46:51: fatal error: a type specifier is required for all declarations
static inline __attribute__((always_inline)) void _mm_prefetch(char const *p, int i)
^
/Library/Developer/CommandLineTools/usr/lib/clang/15.0.0/include/xmmintrin.h:2107:51: note: expanded from macro '_mm_prefetch'
#define _mm_prefetch(a, sel) (__builtin_prefetch((const void *)(a), \
^
1 error generated.
make[2]: *** [src/CMakeFiles/diskann.dir/apple_aligned_file_reader.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/diskann.dir/all] Error 2
make: *** [all] Error 2 I may not be reading this right, but is it saying that the xmmintrin header has added some inline code that is invalid with the version of g++ we're building with? Do we need to build with clang? I know enough to get myself into trouble and chase a lot of red herrings, so I hope you have a better idea than I do :) |
@daxpryce CMake should be using the built-in apple-clang for builds (setting up GCC or another version of LLVM is just too difficult). Regarding the error, I just pushed a possible fix. |
new errors, but it's looking closer:
I tried again after adding
|
@daxpryce, could you please verify that the following file exists for you? You might need to change the SDK version number depending on which one you're compiling against. There should be a definition for |
@darvg - apparently my version is MacOS13.3.sdk, and there definitely is a with line#'s from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers/clapack.h Note that MacOSX.sdk is a symlink to MacOSX14.2.sdk
So there's very clearly a typedef for it. I checked the CMakeLists.txt to see if we added an |
@daxpryce let me try updating my mac (it's currently on macOS 12) to see if I can reproduce the issue. In the meantime, maybe try reinstalling your xcode developer tools (or command line tools) and see if that fixes the issue? |
@darvg I'm like 99% sure I got it fully reinstalled, but got the same error. I know a coworker with a macbook too, so I can probably get him to give his environment a try on Tuesday (msft has a US holiday on Monday). I'll report back with that. If it does end up being this particular incarnation of my system, I have absolutely no qualms wiping my macbook disk and reinstalling. It's due, anyway. I'll keep you posted, and thanks for trying to work through this with me! |
Sure, sounds good. I updated my Mac to macOS 14 and I still haven't been able to reproduce the error, so I'm not entirely sure what's going on. It doesn't look like an Intel/ARM issue to me. For now, if you want to get to benchmarking, you can try replacing the typedef in utils.h with a regular int (which it seems to be anyways in a transitive sense). |
Reference Issues/PRs
What does this implement/fix? Briefly explain your changes.
Addresses a number of discrepancies preventing DiskANN from building on macOS (Mac-only changes):
uint64_t = unsigned long long
on macOS, whileuint64_t = unsigned long
on Ubuntu and Windows:uint64_t
andsize_t
are used interchangeably throughout the code because of the latter equivalence, which causes problems on macOSAny other comments?
I'm not very familiar with the CMake syntax, so in particular, checking those changes would be appreciated.