Skip to content

fix: build error on Apple Silicon due to ambiguous call to svwhilelt functions #260

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

Closed

Conversation

zebrapurring
Copy link

I'm using PostgreSQL 17 from Homebrew (brew install postgresql@17) and I ran the following steps to build VectorChord:

cargo install cargo-pgrx@"$(sed -n 's/.*pgrx = { version = "\(=.*\)",.*/\1/p' Cargo.toml)" --locked
cargo pgrx init --pg17=pg_config-17
cargo pgrx install --release --sudo --pg-config pg_config-17

However cargo pgrx install returns the following error:

[...]
warning: [email protected]: ./cshim/aarch64.c:88:21: error: call to 'svwhilelt_b16' is ambiguous
warning: [email protected]:    88 |     svbool_t mask = svwhilelt_b16(i, n);
warning: [email protected]:       |                     ^~~~~~~~~~~~~
warning: [email protected]: /Library/Developer/CommandLineTools/usr/lib/clang/16/include/arm_sve.h:28294:10: note: candidate function
warning: [email protected]:  28294 | svbool_t svwhilelt_b16(uint32_t, uint32_t);
warning: [email protected]:        |          ^
warning: [email protected]: /Library/Developer/CommandLineTools/usr/lib/clang/16/include/arm_sve.h:28302:10: note: candidate function
warning: [email protected]:  28302 | svbool_t svwhilelt_b16(uint64_t, uint64_t);
warning: [email protected]:        |          ^
warning: [email protected]: /Library/Developer/CommandLineTools/usr/lib/clang/16/include/arm_sve.h:28310:10: note: candidate function
warning: [email protected]:  28310 | svbool_t svwhilelt_b16(int32_t, int32_t);
warning: [email protected]:        |          ^
warning: [email protected]: /Library/Developer/CommandLineTools/usr/lib/clang/16/include/arm_sve.h:28318:10: note: candidate function
warning: [email protected]:  28318 | svbool_t svwhilelt_b16(int64_t, int64_t);
warning: [email protected]:        |          ^
[...]
error: failed to run custom build command for `simd v0.0.0 (/private/var/folders/jj/g3vtj8y11hq32pvps93f7d7c0000gn/T/vectorchord.Fvs7ZJ4EKr/crates/simd)`
[...]
  error occurred in cc-rs: command did not execute successfully (status code exit status: 1): env -u IPHONEOS_DEPLOYMENT_TARGET LC_ALL="C" "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "--target=arm64-apple-macosx" "-mmacosx-version-min=15.2" "-Wall" "-Wextra" "-o" "/private/var/folders/jj/g3vtj8y11hq32pvps93f7d7c0000gn/T/vectorchord.Fvs7ZJ4EKr/target/release/build/simd-eb45d325f597ce0a/out/bb6bfe1d2e603894-aarch64.o" "-c" "./cshim/aarch64.c"

This change fixes the error above and makes sure the correct function is picked by the compiler.

Copy link


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


zebrapurring seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@usamoi
Copy link
Contributor

usamoi commented May 24, 2025

There is no need to add the second commit. Flags are specified in https://github.com/tensorchord/VectorChord/blob/main/build.rs.

Can you add an email to the commit, sign the commit and the CLA?

@zebrapurring
Copy link
Author

zebrapurring commented May 24, 2025

There is no need to add the second commit. Flags are specified in https://github.com/tensorchord/VectorChord/blob/main/build.rs.

I saw them, but without specifying the linker flags in .cargo/config.toml I get:

          ld: warning: object file (/private/var/folders/jj/g3vtj8y11hq32pvps93f7d7c0000gn/T/vectorchord.ogYRTTuYTC/target/debug/deps/libpgrx_pg_sys-95af3d910705acbe.rlib[9](42134f58efbd7074-pgrx-cshim.o)) was built for newer 'macOS' version (15.2) than being linked (11.0)
          Undefined symbols for architecture arm64:
            "_AllocSetContextCreateInternal", referenced from:
                pgrx_pg_sys::include::pg17::AllocSetContextCreateInternal::_$u7b$$u7b$closure$u7d$$u7d$::hb4cc71a7332d426d in libpgrx-6eb16434c2ebdffc.rlib[4](pgrx-6eb16434c2ebdffc.pgrx.600eec7c2d3efab-cgu.01.rcgu.o)
            "_BufferBlocks", referenced from:
                pgrx_pg_sys::port::BufferGetBlock::h8dddcba8dbf53cf8 in libvchord.rlib[108](vchord.5y877zd66ppea78rnmkllncvx.rcgu.o)
                pgrx_pg_sys::port::BufferGetBlock::h8dddcba8dbf53cf8 in libvchord.rlib[108](vchord.5y877zd66ppea78rnmkllncvx.rcgu.o)
[...]

          ld: symbol(s) not found for architecture arm64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

With my update the library builds without errors, but cargo pgrx install fails to load PostgreSQL's dynamic library when running target/debug/pgrx_embed_vchord:

dyld[59986]: symbol not found in flat namespace '_BufferBlocks'

So something still seems to be missing... However I found that the built binary seems to work fine with Postgres.

@usamoi Have you been able to build and run the library on Apple Silicon?

@usamoi
Copy link
Contributor

usamoi commented May 25, 2025

With my update the library builds without errors, but cargo pgrx install fails to load PostgreSQL's dynamic library when running target/debug/pgrx_embed_vchord:

It's rust-lang/rust#139744, fixed in rust-lang/rust#139752. Please use a newer nightly compiler by changing toolchain.channel field in rust-toolchain.toml from nightly-2025-04-25 to nightly-2025-04-26.

@usamoi
Copy link
Contributor

usamoi commented May 25, 2025

Have you been able to build and run the library on Apple Silicon?

I don't have MacOS machines at hand right now, but I make CI work on MacOS. See https://github.com/usamoi/VectorChord/tree/fix-macos and https://github.com/usamoi/VectorChord/actions/runs/15236146848/job/42850260009.

@zebrapurring
Copy link
Author

Have you been able to build and run the library on Apple Silicon?

I don't have MacOS machines at hand right now, but I make CI work on MacOS. See https://github.com/usamoi/VectorChord/tree/fix-macos and https://github.com/usamoi/VectorChord/actions/runs/15236146848/job/42850260009.

Looks great! I tested your branch in my machine and the library builds without any errors. I'll close my PR then, feel free to integrate your branch instead.

Will you release next version's prebuilt binaries for macOS as well?

Thank you!

@usamoi
Copy link
Contributor

usamoi commented May 25, 2025

Will you release next version's prebuilt binaries for macOS as well?

I don't think so. I know little about macOS so I'm not sure what potential issues there might be with releasing precompiled binaries.

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.

2 participants