Skip to content

[WRAPPER] Add wrapper for libmvec.so.1#3683

Merged
ptitSeb merged 1 commit intoptitSeb:mainfrom
runlevel5:wrap-libmvec
Mar 19, 2026
Merged

[WRAPPER] Add wrapper for libmvec.so.1#3683
ptitSeb merged 1 commit intoptitSeb:mainfrom
runlevel5:wrap-libmvec

Conversation

@runlevel5
Copy link
Contributor

@runlevel5 runlevel5 commented Mar 19, 2026

Wrap the SSE2 vectorized sin/cos functions from glibc libmvec using native scalar sin()/cos() from libm. The Broken Sword Reforged game happens to require these 2 functions.

ref: ptitSeb/box86-compatibility-list#549

@ptitSeb
Copy link
Owner

ptitSeb commented Mar 19, 2026

It's acceptable, but barely. You unwrap the verctorized sin/cos instead of using the mvec functions themselves.

Wrap the SSE2 vectorized sin/cos functions from glibc libmvec using
native scalar sin()/cos() from libm. Since libmvec.so.1 does not exist
as a native library on ppc64le, PRE_INIT uses dlopen(NULL) to obtain a
valid library handle.

All other ~270 libmvec symbols are listed as commented-out entries in
the private header and fall back to emulation.
@runlevel5
Copy link
Contributor Author

@ptitSeb I've just amended the PR, that is to only to fallback to scalar path for non-aarch64/x86_64


// Try to load the native libmvec.so.1 and resolve vectorized sin/cos.
// On aarch64 and x86_64: native libmvec exists in glibc, use it.
// On ppc64le and others: dlopen fails, fall back to scalar sin/cos.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hopefully one day https://sourceware.org/pipermail/glibc-cvs/2020q1/068984.html it would be upstreamed for ppc64

@ptitSeb ptitSeb merged commit 9401712 into ptitSeb:main Mar 19, 2026
28 checks passed
@runlevel5 runlevel5 deleted the wrap-libmvec branch March 20, 2026 07:10
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