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

Fix swig osx #3357

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
752f961
Revert "remove broken change"
junjieqi Mar 27, 2024
9b6f341
fix osx swig
junjieqi Apr 9, 2024
0da050e
remove unused change
junjieqi Apr 9, 2024
b1f5c17
fix sprintf
junjieqi Apr 9, 2024
74ae852
revert
junjieqi Apr 9, 2024
739e5a1
build_cmake
junjieqi Apr 9, 2024
609fc2c
snprintf
junjieqi Apr 9, 2024
f77336d
revert
junjieqi Apr 9, 2024
c3b7b98
revert
junjieqi Apr 9, 2024
e3244ce
change to conda
junjieqi Apr 9, 2024
38929fc
fix sprintf
junjieqi Apr 11, 2024
d5b7ab4
Merge branch 'main' into fix_swig_osx
junjieqi Apr 11, 2024
6fa55b0
force generate SWIGTYPE_p_*_long
junjieqi Apr 11, 2024
6c955e9
Merge branch 'main' into fix_swig_osx
junjieqi Apr 11, 2024
e3eb21c
revert some part
junjieqi Apr 11, 2024
8b4ffc3
reconstructure
junjieqi Apr 12, 2024
1b3bebc
Merge branch 'main' into fix_swig_osx
junjieqi Apr 12, 2024
deb576b
force long
junjieqi Apr 12, 2024
47244ca
remove unused flag
junjieqi Apr 13, 2024
fa8626f
Merge branch 'main' into fix_swig_osx
junjieqi Apr 24, 2024
736b4ee
convert int64 to long_long for osx
junjieqi Apr 24, 2024
a26c9c2
revert the comment
junjieqi Apr 24, 2024
f5e4649
use defined
junjieqi Apr 24, 2024
7c5d14f
add __MACH__
junjieqi Apr 24, 2024
32dd565
__APPLE__
junjieqi Apr 25, 2024
cf2d577
Merge branch 'main' into fix_swig_osx
junjieqi Apr 25, 2024
6d45822
add DSWIGWORDSIZE64
junjieqi Apr 25, 2024
7e4eeeb
Merge branch 'fix_swig_osx' of github.com:facebookresearch/faiss into…
junjieqi Apr 25, 2024
12658da
Merge branch 'fix_swig_osx' of github.com:facebookresearch/faiss into…
junjieqi Apr 25, 2024
83539de
Merge branch 'fix_swig_osx' of github.com:facebookresearch/faiss into…
junjieqi Apr 25, 2024
aab10ba
add size back
junjieqi Apr 25, 2024
bba54ac
remove osx for final check in
junjieqi Apr 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ workflows:
- build_conda:
name: Linux arm64 (conda)
exec: linux-arm64-cpu
- build_conda:
name: OSX arm64 (cmake)
exec: macosx-arm64-cpu
- build_conda:
name: Linux x86_64 packages
exec: linux-x86_64-cpu
Expand Down
5 changes: 0 additions & 5 deletions faiss/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ macro(configure_swigfaiss source)
CPLUSPLUS ON
USE_TARGET_INCLUDE_DIRECTORIES TRUE
)
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT WIN32)
set_source_files_properties(${source} PROPERTIES
SWIG_FLAGS -DSWIGWORDSIZE64
)
endif()
if(WIN32)
set_source_files_properties(${source} PROPERTIES
SWIG_FLAGS -DSWIGWIN
Expand Down
16 changes: 10 additions & 6 deletions faiss/python/swigfaiss.swig
Original file line number Diff line number Diff line change
Expand Up @@ -1022,14 +1022,17 @@ PyObject *swig_ptr (PyObject *a)
return SWIG_NewPointerObj(data, SWIGTYPE_p_bool, 0);
}
if(PyArray_TYPE(ao) == NPY_UINT64) {
#if (__SIZEOF_LONG__ == 8)
// Convert npy64 either long or long long and it depends on how compiler define int64_t.
// In the 64bit machine, typically the int64_t should be long but it is not hold for Apple osx.
// In this case, we want to convert npy64 to long_Long in osx
#if __SIZEOF_LONG__ == 8 && !(defined(__APPLE__) && defined(__MACH__))
return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0);
#else
return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0);
#endif
}
if(PyArray_TYPE(ao) == NPY_INT64) {
#if (__SIZEOF_LONG__ == 8)
#if __SIZEOF_LONG__ == 8 && !(defined(__APPLE__) && defined(__MACH__))
Copy link
Contributor

Choose a reason for hiding this comment

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

Here it is probably enough to test on

#ifndef __APPLE__

return SWIG_NewPointerObj(data, SWIGTYPE_p_long, 0);
#else
return SWIG_NewPointerObj(data, SWIGTYPE_p_long_long, 0);
Expand Down Expand Up @@ -1121,12 +1124,13 @@ int * cast_integer_to_int_ptr (int64_t x) {
void * cast_integer_to_void_ptr (int64_t x) {
return (void*)x;
}

%}




/*
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not necessary anymore I think

Force OSX to generate SWIGTYPE_p_long since OSX will generate SWIGTYPE_p_long_long when it meets int64 by default
*/
%types(unsigned long*);
%types(long*);



Expand Down