LDC lto generate wrong dll export table

Test123 test123 at gmail.com
Sun May 22 17:50:49 UTC 2022


On Sunday, 22 May 2022 at 17:27:28 UTC, Test123 wrote:
> Use ldc2 without LTO always give the same result like clang.


confirm with LDC 1.28.1, 1.30.0-beta1.

When you have one short export symbol LDC unlikely generate wrong 
result, when there is more than one export it never generate 
right result.


```c
#include <windows.h>
__declspec(dllexport) int test1(){
	return 0;
}

__declspec(dllexport) int test2(){
         return 0;
}
```

clang wlways generate correct test.dll.

LDC give wrong result when more than one export is used with LTO:


```d
import ldc.attributes : assumeUsed;

export extern(C) int test1() @assumeUsed {
         return 0;
}

export extern(C) int test2() @assumeUsed {
         return 0;
}
```

remove test1 or test2 will give you right result with LTO.


but if you use a long function name like test111242342343243243, 
ldc will alway give wrong result with LTO.


More information about the digitalmars-d-ldc mailing list