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

Bug: sz_dispatch_table didn't initialize in rust binding on Windows #178

Closed
2 of 3 tasks
CrazyboyQCD opened this issue Oct 16, 2024 · 9 comments · Fixed by #180
Closed
2 of 3 tasks

Bug: sz_dispatch_table didn't initialize in rust binding on Windows #178

CrazyboyQCD opened this issue Oct 16, 2024 · 9 comments · Fixed by #180
Labels
bug Something isn't working

Comments

@CrazyboyQCD
Copy link
Contributor

CrazyboyQCD commented Oct 16, 2024

Describe the bug

When debugging test suite in rust binding, I found sz_dispatch_table didn't initialize.
image

Build output:

[stringzilla 3.10.1] TARGET = Some("x86_64-pc-windows-msvc")
[stringzilla 3.10.1] OPT_LEVEL = Some("3")
[stringzilla 3.10.1] HOST = Some("x86_64-pc-windows-msvc")
[stringzilla 3.10.1] cargo:rerun-if-env-changed=CC_x86_64-pc-windows-msvc
[stringzilla 3.10.1] CC_x86_64-pc-windows-msvc = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=CC_x86_64_pc_windows_msvc
[stringzilla 3.10.1] CC_x86_64_pc_windows_msvc = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=HOST_CC
[stringzilla 3.10.1] HOST_CC = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=CC
[stringzilla 3.10.1] CC = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
[stringzilla 3.10.1] CRATE_CC_NO_DEFAULTS = None
[stringzilla 3.10.1] CARGO_CFG_TARGET_FEATURE = Some("cmpxchg16b,fxsr,lahfsahf,sse,sse2,sse3")
[stringzilla 3.10.1] DEBUG = Some("false")
[stringzilla 3.10.1] cargo:rerun-if-env-changed=CFLAGS_x86_64-pc-windows-msvc
[stringzilla 3.10.1] CFLAGS_x86_64-pc-windows-msvc = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=CFLAGS_x86_64_pc_windows_msvc
[stringzilla 3.10.1] CFLAGS_x86_64_pc_windows_msvc = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=HOST_CFLAGS
[stringzilla 3.10.1] HOST_CFLAGS = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=CFLAGS
[stringzilla 3.10.1] CFLAGS = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=CC_x86_64-pc-windows-msvc
[stringzilla 3.10.1] CC_x86_64-pc-windows-msvc = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=CC_x86_64_pc_windows_msvc
[stringzilla 3.10.1] CC_x86_64_pc_windows_msvc = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=HOST_CC
[stringzilla 3.10.1] HOST_CC = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=CC
[stringzilla 3.10.1] CC = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
[stringzilla 3.10.1] CRATE_CC_NO_DEFAULTS = None
[stringzilla 3.10.1] CARGO_CFG_TARGET_FEATURE = Some("cmpxchg16b,fxsr,lahfsahf,sse,sse2,sse3")
[stringzilla 3.10.1] cargo:rerun-if-env-changed=CFLAGS_x86_64-pc-windows-msvc
[stringzilla 3.10.1] CFLAGS_x86_64-pc-windows-msvc = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=CFLAGS_x86_64_pc_windows_msvc
[stringzilla 3.10.1] CFLAGS_x86_64_pc_windows_msvc = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=HOST_CFLAGS
[stringzilla 3.10.1] HOST_CFLAGS = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=CFLAGS
[stringzilla 3.10.1] CFLAGS = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=CC_x86_64-pc-windows-msvc
[stringzilla 3.10.1] CC_x86_64-pc-windows-msvc = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=CC_x86_64_pc_windows_msvc
[stringzilla 3.10.1] CC_x86_64_pc_windows_msvc = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=HOST_CC
[stringzilla 3.10.1] HOST_CC = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=CC
[stringzilla 3.10.1] CC = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
[stringzilla 3.10.1] CRATE_CC_NO_DEFAULTS = None
[stringzilla 3.10.1] CARGO_CFG_TARGET_FEATURE = Some("cmpxchg16b,fxsr,lahfsahf,sse,sse2,sse3")
[stringzilla 3.10.1] cargo:rerun-if-env-changed=CFLAGS_x86_64-pc-windows-msvc
[stringzilla 3.10.1] CFLAGS_x86_64-pc-windows-msvc = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=CFLAGS_x86_64_pc_windows_msvc
[stringzilla 3.10.1] CFLAGS_x86_64_pc_windows_msvc = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=HOST_CFLAGS
[stringzilla 3.10.1] HOST_CFLAGS = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=CFLAGS
[stringzilla 3.10.1] CFLAGS = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
[stringzilla 3.10.1] cargo:rerun-if-env-changed=AR_x86_64-pc-windows-msvc
[stringzilla 3.10.1] AR_x86_64-pc-windows-msvc = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=AR_x86_64_pc_windows_msvc
[stringzilla 3.10.1] AR_x86_64_pc_windows_msvc = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=HOST_AR
[stringzilla 3.10.1] HOST_AR = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=AR
[stringzilla 3.10.1] AR = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=ARFLAGS_x86_64-pc-windows-msvc
[stringzilla 3.10.1] ARFLAGS_x86_64-pc-windows-msvc = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=ARFLAGS_x86_64_pc_windows_msvc
[stringzilla 3.10.1] ARFLAGS_x86_64_pc_windows_msvc = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=HOST_ARFLAGS
[stringzilla 3.10.1] HOST_ARFLAGS = None
[stringzilla 3.10.1] cargo:rerun-if-env-changed=ARFLAGS
[stringzilla 3.10.1] ARFLAGS = None
[stringzilla 3.10.1] cargo:rustc-link-search=native=D:\VisualStudio\VisualStudio\VC\Tools\MSVC\14.37.32822\atlmfc\lib\x64
[stringzilla 3.10.1] cargo:rustc-link-lib=static=stringzilla
[stringzilla 3.10.1] cargo:rustc-link-search=native=D:\Rust\StringZilla\target\release\build\stringzilla-dd6b387b3407d0f8\out
[stringzilla 3.10.1] cargo:rerun-if-changed=c/lib.c
[stringzilla 3.10.1] cargo:rerun-if-changed=rust/lib.rs
[stringzilla 3.10.1] cargo:rerun-if-changed=include/stringzilla/stringzilla.h

StringZilla version

f195c50

Operating System

Windows 11

Hardware architecture

x86

Which interface are you using?

Rust binding

Contact Details

No response

Are you open to being tagged as a contributor?

  • I am open to being mentioned in the project .git history as a contributor

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct
@CrazyboyQCD CrazyboyQCD added the bug Something isn't working label Oct 16, 2024
@ashvardanian
Copy link
Owner

Thank you, @CrazyboyQCD! Any chance you could contribute? I rarely switch from Linux & MacOS boxes to Windows, so it may take me a while to find the issue.

@CrazyboyQCD
Copy link
Contributor Author

Simple debugging shows that sz_dispatch_table_init didn't get called, but I dont't know how to call it implicitly.

@ashvardanian
Copy link
Owner

@CrazyboyQCD, does it work if you define "SZ_AVOID_LIBC" equal to "1" in build.rs?

@ashvardanian
Copy link
Owner

I think this condition may not be needed.

@ashvardanian
Copy link
Owner

If those help, would appreciate a PR 🤗

@CrazyboyQCD
Copy link
Contributor Author

CrazyboyQCD commented Oct 16, 2024

DllMain and _DllMainCRTStartup are still not called after changes, it seems that they only get called in loadlibrary.

@CrazyboyQCD
Copy link
Contributor Author

CrazyboyQCD commented Oct 16, 2024

I replaced them with this and it works:

#pragma section(".CRT$XCU", read)
__declspec(allocate(".CRT$XCU")) void (*_sz_dispatch_table_init)() = sz_dispatch_table_init;

But I don't know if it will impact anything.
Anyway, all tests are passed.

@ashvardanian , how do you think?

@ashvardanian
Copy link
Owner

Perfect! Can you please open a PR?

@CrazyboyQCD
Copy link
Contributor Author

@ashvardanian
Done.

ashvardanian added a commit that referenced this issue Oct 17, 2024
Closes #178

---------

Co-authored-by: WX\shixi <shixi1@cnwxsoft.com>
Co-authored-by: CrazyboyQCD <53971641+CrazyboyQCD@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants