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

Linker error when compiling with clang-cl: undefined symbol: __udivti3 #1798

Closed
Kingcom opened this issue Jul 30, 2020 · 1 comment
Closed

Comments

@Kingcom
Copy link
Contributor

Kingcom commented Jul 30, 2020

This is very likely to be the fault of Clang, but perhaps something can be done to work around it.

I'm using the official Windows build of LLVM 10.0.0 from a Visual Studio 2017 x64 environment. Calling any formatting function (even something trivial like fmt::print("");) results in the linker error above. This seems to be because Clang mishandles 128 bit integers and incorrectly generates a call to a function not implemented by the Microsoft runtime.

I was able to work around the issue with the following patch:

diff --git a/include/fmt/format.h b/include/fmt/format.h
index 336d2c67..5e5b87dd 100644
--- a/include/fmt/format.h
+++ b/include/fmt/format.h
@@ -759,8 +759,7 @@ using uint32_or_64_or_128_t =
 // represent all values of T.
 template <typename T>
 using uint32_or_64_or_128_t = conditional_t<
-    num_bits<T>() <= 32, uint32_t,
-    conditional_t<num_bits<T>() <= 64, uint64_t, uint128_t>>;
+    num_bits<T>() <= 32, uint32_t, uint64_t>;
 #endif

I've tried defining FMT_REDUCE_INT_INSTANTIATIONS to 1, but with that it fails to compile due to an ambiguous call:

..\ext\fmt\include\fmt/format-inl.h(639,5): error: call to member function 'multiply' is ambiguous
    multiply(uint32_or_64_or_128_t<Int>(value));
    ^~~~~~~~
..\ext\fmt\include\fmt/format-inl.h(566,8): note: candidate function
  void multiply(uint32_t value) {
       ^
..\ext\fmt\include\fmt/format-inl.h(577,8): note: candidate function
  void multiply(uint64_t value) {
@vitaut
Copy link
Contributor

vitaut commented Jul 30, 2020

That's a clang issue but a PR with a workaround would be welcome.

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