-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Clang-cl generates a call to an undefined symbol __udivti3 #25679
Comments
assigned to @amccarth-google |
mode(TI) is a gcc extension. Therefore you need to link with libgcc / compiler_rt. |
Is this true under Windows as well? The default installation of LLVM (through the installer provided at llvm.org/builds) doesn't seem to supply either libgcc or compiler_rt. From a user standpoint there doesn't seem to be anything I can link against under Windows to resolve this. |
Very rarely do you need compiler-rt. I think you can trigger the reference a different way, something like this with -fms-extensions: __int128 mydiv(__int128 a, __int128 b) { I bet we still generate the call to compiler-rt. If the MSVC CRT has a reliably available libcall (going back to VC 6.0 in MSVCRT.dll), then we could call it instead of the libgcc version. If not, I'd recommend building compiler-rt. It isn't normally required. |
But even with projects/compiler-rt built (alongside llvm itself and tools/clang), |
I'm currently hitting this exact same bug while compiling the a project that makes use of libTomMath v0.41 |
Hello there, As far as I can tell, running strings on "C:\Program Files\LLVM\lib\clang\6.0.1\lib\windows\clang_rt.builtins-x86_64.lib" seems to indicate udivti3 should be linked in from udivti3.c.obj. However, running DUMPBIN /SYMBOLS on the said file only lists the udivsi3 function. What's the proper way to request the 128b variants are linked are not optimized out or compiled out of clang_rt.builtins-x86_64.lib ? Thank you |
Per conversation with @rnk, I'll see if the driver can be convinced to include the right compiler-rt files. |
This has come up again in llvm/llvm-bugzilla-archive#28629 . I think Renato's comment here is highly relevant: ClangBuiltLinux/linux#1438 (comment). |
We'll want to do something similar to this list of commits: llvm/llvm-bugzilla-archive#28629 #c23. |
Its a quite a bit more complicated than that. We need to generate a inline division implementation, but that requires loops that SelectionDAG can't create. We likely need a pre-SelectionDAG IR pass that expands the unsupported division. |
mentioned in issue #48113 |
Looking at the status of this, I think it's worth noting that the last update was actually in #26142 (Should clang-cl require compiler-rt?), where @rnk said:
Any update on this effort? I'm hitting this issue while trying to build flang on windows. |
Specifically, I think we ought to implement this by emitting Separately, folks have been talking about teaching lld-link to find clang runtime libraries by searching relative to |
+@tru for that. It would be amazing to finally get this fixed. |
Yes - I have started working on this! Stay tuned. |
Fixes build with clang-cl on Windows. This is a workaround for llvm/llvm-project#25679 Change-Id: I6dc8b045376101d8b8cc26fe5db3e7bf87a6a8f4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Hi @tru @h-vetinari, are there any updates on this issue? I encountered it when attempting to build |
@h-vetinari It appears it's not yet fixed as of commit cfc6dbe9. I'm using the following commands, though I pieced them together from various Github comments so they might not be correct:
The very last ninja task fails:
On my machine, cmake is using Edit: If my understanding is correct, I've just realized this might not apply to this ticket, as it's not about Edit 2: All good with |
I believe we haven't done anything systematic to simplify linking clang_rt.builtins into applications build with clang-cl, so I believe this issue is still open and active. I may find time to work on this in the new year. |
Extended Description
While attempting to build a (very) old version of libtomcrypt with Clang-cl (64-bit r250698), it appears a call to an undefined function is being generated:
main-ff9827.obj : error LNK2019: unresolved external symbol __udivti3 referenced in function main
I've attached a minimal reproduce case. This appears to be due to the "attribute((mode(TI)))" on the typedef.
The text was updated successfully, but these errors were encountered: