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

128-bit arithmetic is missing in Clang-cl for libbf #14

Closed
stevefan1999-personal opened this issue Oct 3, 2020 · 1 comment
Closed

Comments

@stevefan1999-personal
Copy link

stevefan1999-personal commented Oct 3, 2020

Clang-Cl does not yet have total 128-bit arithmetic support available for MSVC backend. You are likely going to see one of these linker error if you tried to compile libbf:

E:\Git\github.com\stevefan1999-personal\quickjspp\out\build\x64-RelWithDebInfo\lld-link : error : undefined symbol: __udivti3
  >>> referenced by E:\Git\github.com\stevefan1999-personal\quickjspp\quickjs\libbf.c:1292
  >>>               lto.tmp:(mp_divnorm)
  >>> referenced by E:\Git\github.com\stevefan1999-personal\quickjspp\quickjs\libbf.c:1318
  >>>               lto.tmp:(mp_divnorm)
  >>> referenced by E:\Git\github.com\stevefan1999-personal\quickjspp\quickjs\libbf.c:1252
  >>>               lto.tmp:(mp_div1norm)
  >>> referenced by E:\Git\github.com\stevefan1999-personal\quickjspp\quickjs\libbf.c:1260
  >>>               lto.tmp:(mp_div1norm)
  >>> referenced by E:\Git\github.com\stevefan1999-personal\quickjspp\quickjs\libbf.c:1955
  >>>               lto.tmp:(mp_sqrtrem2)
  >>> referenced by E:\Git\github.com\stevefan1999-personal\quickjspp\quickjs\libbf.c:3393
  >>>               lto.tmp:(bf_integer_to_radix_rec)
  >>> referenced by E:\Git\github.com\stevefan1999-personal\quickjspp\quickjs\libbf.c:3396
  >>>               lto.tmp:(bf_integer_to_radix_rec)
  >>> referenced by E:\Git\github.com\stevefan1999-personal\quickjspp\quickjs\libbf.c:8267
  >>>               lto.tmp:(ntt_static_init)
  >>> referenced by E:\Git\github.com\stevefan1999-personal\quickjspp\quickjs\libbf.c:8277
  >>>               lto.tmp:(ntt_static_init)
  >>> referenced by E:\Git\github.com\stevefan1999-personal\quickjspp\quickjs\libbf.c:8285
  >>>               lto.tmp:(ntt_static_init)
  >>> referenced 1 more times

The bug has not been resolved for 5 years now.

To workaround the problem, you can simply patch the file to use 64-bit double limb rather than 128-bit or even not use BigNum at all.

index 6749b35..5a502ff 100644
--- a/libbf.h
+++ b/libbf.h
@@ -27,7 +27,7 @@
 #include <stddef.h>
 #include <stdint.h>

-#if defined(__x86_64__)
+#if defined(__x86_64__) && !defined(_WIN32)
 #define LIMB_LOG2_BITS 6
 #else
 #define LIMB_LOG2_BITS 5

Using 64-bit double limb is fine even on 64-bit platform, but it will probably suffer some performance loss of up to 2x due to lack of AVX/vectorization. I didn't really benchmarked it but as an educated guess I think🤷‍♂️.

@bellard
Copy link
Owner

bellard commented Nov 8, 2020

this is a compiler issue, not a QuickJS issue.

@bellard bellard closed this as completed Nov 8, 2020
GerHobbelt pushed a commit to GerHobbelt/quickjs that referenced this issue May 6, 2022
cykoder pushed a commit to cykoder/quickjs that referenced this issue Sep 1, 2023
fix: add dynamic function case for test_line_column
GerHobbelt pushed a commit to GerHobbelt/quickjs that referenced this issue Oct 17, 2023
* add support for running the event loop allow running of promise/async code

* moved loop to interface file+docs+return value

* fix

* prettier

* prettier test file

* removed RESERVED_FUNCTIONS
TooTallNate pushed a commit to TooTallNate/quickjs that referenced this issue Dec 18, 2023
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

No branches or pull requests

2 participants