Bug 22083 – Error: function ldc.intrinsics.llvm_bswap!uint.llvm_bswap conflict with std.bitmanip.nativeToBigEndian!ushort.nativeToBigEndian
Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2021-06-25T00:13:51Z
Last change time
2022-09-08T06:48:12Z
Assigned to
No Owner
Creator
mw
Comments
Comment #0 by mingwu — 2021-06-25T00:13:51Z
kinke think this is a frontend bug, only showing in LDC:
https://github.com/ldc-developers/ldc/issues/3772
=================================================
Hi,
While building apache-thrift, LDC has build failure (DMD succeed):
/home/./.dub/packages/apache-thrift-0.14.1/apache-thrift/lib/d/src/thrift/transport/websocket.d(335,39): Error: function ldc.intrinsics.llvm_bswap!uint.llvm_bswap at /home/./project/ldc2-1.26.0-linux-x86_64/bin/../import/ldc/intrinsics.di(405,7) conflicts with function std.bitmanip.nativeToBigEndian!ushort.nativeToBigEndian at /home/./project/ldc2-1.26.0-linux-x86_64/bin/../import/std/bitmanip.d(2998,6)
While there is a work around by using fully qualified names: std.bitmanip.nativeToBigEndian, I think LDC compiler should be fixed.
$ ldc2 --version
LDC - the LLVM D compiler (1.26.0):
based on DMD v2.096.1 and LLVM 11.0.1
built with LDC - the LLVM D compiler (1.26.0)
Default target: x86_64-unknown-linux-gnu
Host CPU: znver1
http://dlang.org - http://wiki.dlang.org/LDC
This looks like a frontend bug - the conflict seems to be caused by https://github.com/ldc-developers/phobos/blob/16d1a9be59cb319961bd7bc0bcd1128151fc0a67/std/digest/sha.d#L124,
```
version (LittleEndian)
{
private alias nativeToBigEndian = bswap;
private alias bigEndianToNative = bswap;
}
```
which is a private alias, which - for LDC - aliases 2 other aliases:
https://github.com/ldc-developers/druntime/blob/8916695501005be33291f5a88e399b7eb1eb9e25/src/core/bitop.d#L657 and
```
version (LDC)
{
alias bswap = llvm_bswap!uint;
}
```
https://github.com/ldc-developers/druntime/blob/8916695501005be33291f5a88e399b7eb1eb9e25/src/core/bitop.d#L677
```
version (LDC)
{
alias bswap = llvm_bswap!ulong;
}
```
=================================
I wasn't able to reduce it to a smaller test case; maybe someone who is more familiar with the frontend code can do.