November 12, 2013
thanks Kai

I have used your new patch (win64eh_all_20131112.diff).
but the same problem generated.

Unknown frame setup opcode!
UNREACHABLE executed at C:\LDC\llvm\lib\Target\X86\X86MCInstLower.cpp:855!

I compiled with a Visual Studio 2012.
I think that the cause of this problem is related with a X64 Prolog and
Epliog RSP register realignment.

Visual Studio 2012 does over allocates and realigns RSP

How to resolve it?
Would you upate the patch ^^;;;


Regards, Kai






On Tuesday, 12 November 2013 at 10:50:35 UTC, Kai Nacke wrote:
> On Tuesday, 12 November 2013 at 06:07:16 UTC, tae hoo wrote:
>> Hey Kai
>>
>> I noticed that, too.
>> Would you send me the llvm SRC files which can be used with
>> a win64eh_all_20131021.diff file.
>>
>> Thanks you.
>
> Hi tae,
>
> I have updated the patch in the wiki. Just use the new version.
>
> Regards,
> Kai

November 12, 2013
Hi tae,

On Tuesday, 12 November 2013 at 16:24:26 UTC, tae hoo wrote:
> I have used your new patch (win64eh_all_20131112.diff).
> but the same problem generated.
>
> Unknown frame setup opcode!
> UNREACHABLE executed at C:\LDC\llvm\lib\Target\X86\X86MCInstLower.cpp:855!
>
> I compiled with a Visual Studio 2012.
> I think that the cause of this problem is related with a X64 Prolog and
> Epliog RSP register realignment.
>
> Visual Studio 2012 does over allocates and realigns RSP
>
> How to resolve it?

That is PR16779 (http://llvm.org/bugs/show_bug.cgi?id=16779).
To fix it, you have to change the generation of prolog and epliog code (located in file lib/Target/X86/X86FrameLowering.cpp).

> Would you upate the patch ^^;;;

I tried to solve the mentioned PR but so far I have no solution for it. Sorry.

Currently, I am working on the next release (merge of 2.064), therefore there is no time to fix this. Volunteers are welcome. :-)

Regards,
Kai
November 13, 2013
<test.d>
module test;
void poo()
{
    wchar[4096] buffW;
}

ldc2 --output-o -c -IC:/LDC/ldc/runtime/druntime/src -IC:/LDC/ldc/runtime/druntime/src/gc test.d -oftest.obj -w -d -O0 -release -IC:/LDC/ldc/runtime/phobos

if you compile the above test.d, same error message generated
>> Unknown frame setup opcode!
>> UNREACHABLE executed at C:\LDC\llvm\lib\Target\X86\X86MCInstLower.cpp:855!


But, if reduce the stack variable size to below 2000,
error message not generated.

<test.d>
module test;
void poo()
{
    wchar[2000] buffW;
}


It seems to be a BUG of ldc2 compiler not stack alingment problem.







On Tuesday, 12 November 2013 at 17:14:59 UTC, Kai Nacke wrote:
> Hi tae,
>
> On Tuesday, 12 November 2013 at 16:24:26 UTC, tae hoo wrote:
>> I have used your new patch (win64eh_all_20131112.diff).
>> but the same problem generated.
>>
>> Unknown frame setup opcode!
>> UNREACHABLE executed at C:\LDC\llvm\lib\Target\X86\X86MCInstLower.cpp:855!
>>
>> I compiled with a Visual Studio 2012.
>> I think that the cause of this problem is related with a X64 Prolog and
>> Epliog RSP register realignment.
>>
>> Visual Studio 2012 does over allocates and realigns RSP
>>
>> How to resolve it?
>
> That is PR16779 (http://llvm.org/bugs/show_bug.cgi?id=16779).
> To fix it, you have to change the generation of prolog and epliog code (located in file lib/Target/X86/X86FrameLowering.cpp).
>
>> Would you upate the patch ^^;;;
>
> I tried to solve the mentioned PR but so far I have no solution for it. Sorry.
>
> Currently, I am working on the next release (merge of 2.064), therefore there is no time to fix this. Volunteers are welcome. :-)
>
> Regards,
> Kai

November 13, 2013
Hi tae!

On Wednesday, 13 November 2013 at 03:42:27 UTC, tae hoo wrote:
> <test.d>
> module test;
> void poo()
> {
>     wchar[4096] buffW;
> }
>
> ldc2 --output-o -c -IC:/LDC/ldc/runtime/druntime/src -IC:/LDC/ldc/runtime/druntime/src/gc test.d -oftest.obj -w -d -O0 -release -IC:/LDC/ldc/runtime/phobos
>
> if you compile the above test.d, same error message generated
>>> Unknown frame setup opcode!
>>> UNREACHABLE executed at C:\LDC\llvm\lib\Target\X86\X86MCInstLower.cpp:855!
>
>
> But, if reduce the stack variable size to below 2000,
> error message not generated.
>
> <test.d>
> module test;
> void poo()
> {
>     wchar[2000] buffW;
> }

Yes, you are right. It is a bug! The sub instruction after a call to __chkstk was not regarded as valid. I already updated the patch. Please retry.

And thanks for the report. :-)

> It seems to be a BUG of ldc2 compiler not stack alingment problem.

A wouldn't call a problem caused by a LLVM patch a bug of ldc2, even if the author of the patch happens to be a maintainer of the ldc project. ;-)

Regards,
Kai
November 15, 2013
Hi tae!

On Wednesday, 13 November 2013 at 19:34:32 UTC, Kai Nacke wrote:
> And thanks for the report. :-)

Your report was really inspiring. I found yet another bug and fixed it. New version of the patch (for the first time with a test case!) is already linked to the wiki page.

Regards,
Kai
November 17, 2013
Hi Kai !

I patched llvm and succefully build druntime & phobos lib without
visual studio 2012 link warning messages. (...set1.. set2..
set3... etc)

but at final link time, the following errors generated.

D:\LDC\LDC64\lib>ldc2 test.d
phobos-ldc.lib(math.obj) : error LNK2019: unresolved external
symbol _D3std4math
4exp2FNaNbNeeZe referenced in function _D3std4math3sinFNaNbNfcZc
phobos-ldc.lib(math.obj) : error LNK2019: unresolved external
symbol _D3std4math
5expm1FNaNbNeeZe referenced in function _D3std4math3sinFNaNbNfcZc
phobos-ldc.lib(math.obj) : error LNK2019: unresolved external
symbol _D3std4math
5atan2FNaNbNeeeZe referenced in function
_D3std4math4acosFNaNbNfeZe
phobos-ldc.lib(math.obj) : error LNK2019: unresolved external
symbol _D3std4math
5truncFNbNeeZe referenced in function _D3std4math4modfFNbNeeKeZe
phobos-ldc.lib(math.obj) : error LNK2019: unresolved external
symbol _D3std4math
20FloatingPointControl15setControlStateFNbNetZv referenced in
function _D3std4ma
th5roundFNbNeeZe
phobos-ldc.lib(thread.obj) : error LNK2019: unresolved external
symbol _D4core6t
hread14getStackBottomFZPv referenced in function thread_entryPoint
phobos-ldc.lib(thread.obj) : error LNK2019: unresolved external
symbol fiber_swi
tchContext referenced in function fiber_entryPoint
phobos-ldc.lib(threadaux.obj) : error LNK2019: unresolved
external symbol _D4cor
e3sys7windows9threadaux10thread_aux6getTEBFNbZPPv referenced in
function _D4core
3sys7windows9threadaux10thread_aux18impersonate_threadFkMDFZvZv
test.exe : fatal error LNK1120: 8 unresolved externals
Error: C:\Program Files (x86)\Microsoft Visual Studio
11.0\VC\BIN\x86_amd64\link
.exe failed with status: 1120

it seems to be someting wrong at druntime & phobos library build
CMake file
which related with compilation.

How to resolve it?






On Friday, 15 November 2013 at 06:39:53 UTC, Kai Nacke wrote:
> Hi tae!
>
> On Wednesday, 13 November 2013 at 19:34:32 UTC, Kai Nacke wrote:
>> And thanks for the report. :-)
>
> Your report was really inspiring. I found yet another bug and fixed it. New version of the patch (for the first time with a test case!) is already linked to the wiki page.
>
> Regards,
> Kai
November 17, 2013
Hi tae!

On Sunday, 17 November 2013 at 14:20:23 UTC, tae hoo wrote:
> Hi Kai !
>
> I patched llvm and succefully build druntime & phobos lib without
> visual studio 2012 link warning messages. (...set1.. set2..
> set3... etc)

How do you avoid the link warnings? I opened bug PR17967  (http://llvm.org/bugs/show_bug.cgi?id=17967) because the temporary labels are public!

>
> but at final link time, the following errors generated.
>
> D:\LDC\LDC64\lib>ldc2 test.d
> phobos-ldc.lib(math.obj) : error LNK2019: unresolved external
> symbol _D3std4math
> 4exp2FNaNbNeeZe referenced in function _D3std4math3sinFNaNbNfcZc
> phobos-ldc.lib(math.obj) : error LNK2019: unresolved external
> symbol _D3std4math
> 5expm1FNaNbNeeZe referenced in function _D3std4math3sinFNaNbNfcZc
> phobos-ldc.lib(math.obj) : error LNK2019: unresolved external
> symbol _D3std4math
> 5atan2FNaNbNeeeZe referenced in function
> _D3std4math4acosFNaNbNfeZe
> phobos-ldc.lib(math.obj) : error LNK2019: unresolved external
> symbol _D3std4math
> 5truncFNbNeeZe referenced in function _D3std4math4modfFNbNeeKeZe
> phobos-ldc.lib(math.obj) : error LNK2019: unresolved external
> symbol _D3std4math
> 20FloatingPointControl15setControlStateFNbNetZv referenced in
> function _D3std4ma
> th5roundFNbNeeZe
> phobos-ldc.lib(thread.obj) : error LNK2019: unresolved external
> symbol _D4core6t
> hread14getStackBottomFZPv referenced in function thread_entryPoint
> phobos-ldc.lib(thread.obj) : error LNK2019: unresolved external
> symbol fiber_swi
> tchContext referenced in function fiber_entryPoint
> phobos-ldc.lib(threadaux.obj) : error LNK2019: unresolved
> external symbol _D4cor
> e3sys7windows9threadaux10thread_aux6getTEBFNbZPPv referenced in
> function _D4core
> 3sys7windows9threadaux10thread_aux18impersonate_threadFkMDFZvZv
> test.exe : fatal error LNK1120: 8 unresolved externals
> Error: C:\Program Files (x86)\Microsoft Visual Studio
> 11.0\VC\BIN\x86_amd64\link
> .exe failed with status: 1120
>
> it seems to be someting wrong at druntime & phobos library build
> CMake file
> which related with compilation.
>
> How to resolve it?

No idea yet. I have to check it.

Regards,
Kai
November 17, 2013
Hi Kai !

LLVM does generates incompatible with MS tool(case jmp table lable , seh lable
etc)

the problem is 'set directive'

do patch llvm, HasSetDirective from true to false.

<llvm/lib/MC/MCAsmInfo.cpp>

  GPRel64Directive = 0;
  GPRel32Directive = 0;
  GlobalDirective = "\t.globl\t";
  HasSetDirective = false;//true;      <---- this, line number 74,
  HasAggressiveSymbolFolding = true;
  COMMDirectiveAlignmentIsInBytes = true;
  LCOMMDirectiveAlignmentType = LCOMM::NoAlignment;



I used <git clone http://llvm.org/git/llvm.git llvm> version.

but final link error genarated.

which version is required for avoiding this phobos link problem?





> How do you avoid the link warnings? I opened bug PR17967  (http://llvm.org/bugs/show_bug.cgi?id=17967) because the temporary labels are public!
>
>>
>> but at final link time, the following errors generated.
>>
>> D:\LDC\LDC64\lib>ldc2 test.d
>> phobos-ldc.lib(math.obj) : error LNK2019: unresolved external
>> symbol _D3std4math
>> 4exp2FNaNbNeeZe referenced in function _D3std4math3sinFNaNbNfcZc
>> phobos-ldc.lib(math.obj) : error LNK2019: unresolved external
>> symbol _D3std4math
>> 5expm1FNaNbNeeZe referenced in function _D3std4math3sinFNaNbNfcZc
>> phobos-ldc.lib(math.obj) : error LNK2019: unresolved external
>> symbol _D3std4math
>> 5atan2FNaNbNeeeZe referenced in function
>> _D3std4math4acosFNaNbNfeZe
>> phobos-ldc.lib(math.obj) : error LNK2019: unresolved external
>> symbol _D3std4math
>> 5truncFNbNeeZe referenced in function _D3std4math4modfFNbNeeKeZe
>> phobos-ldc.lib(math.obj) : error LNK2019: unresolved external
>> symbol _D3std4math
>> 20FloatingPointControl15setControlStateFNbNetZv referenced in
>> function _D3std4ma
>> th5roundFNbNeeZe
>> phobos-ldc.lib(thread.obj) : error LNK2019: unresolved external
>> symbol _D4core6t
>> hread14getStackBottomFZPv referenced in function thread_entryPoint
>> phobos-ldc.lib(thread.obj) : error LNK2019: unresolved external
>> symbol fiber_swi
>> tchContext referenced in function fiber_entryPoint
>> phobos-ldc.lib(threadaux.obj) : error LNK2019: unresolved
>> external symbol _D4cor
>> e3sys7windows9threadaux10thread_aux6getTEBFNbZPPv referenced in
>> function _D4core
>> 3sys7windows9threadaux10thread_aux18impersonate_threadFkMDFZvZv
>> test.exe : fatal error LNK1120: 8 unresolved externals
>> Error: C:\Program Files (x86)\Microsoft Visual Studio
>> 11.0\VC\BIN\x86_amd64\link
>> .exe failed with status: 1120
>>
>> it seems to be someting wrong at druntime & phobos library build
>> CMake file
>> which related with compilation.
>>
>> How to resolve it?
>
> No idea yet. I have to check it.
>
> Regards,
> Kai

November 17, 2013
Hi Kai !

Sorry, I am poor at english ^^;;;

LVM does generates incompatible with MS tool(case jmp table
lable , seh lable
etc)

the problem is 'set directive'

do patch llvm, HasSetDirective from true to false.

<llvm/lib/MC/MCAsmInfo.cpp>

  GPRel64Directive = 0;
  GPRel32Directive = 0;
  GlobalDirective = "\t.globl\t";
  HasSetDirective = false;//true;      <---- this, line number 74,
  HasAggressiveSymbolFolding = true;
  COMMDirectiveAlignmentIsInBytes = true;
  LCOMMDirectiveAlignmentType = LCOMM::NoAlignment;


I used <git clone --recursive https://github.com/ldc-developers/ldc.git> version.

but final link error genarated.

which version is required to avoide this phobos link problem?





>> How do you avoid the link warnings? I opened bug PR17967  (http://llvm.org/bugs/show_bug.cgi?id=17967) because the temporary labels are public!
>>
>>>
>>> but at final link time, the following errors generated.
>>>
>>> D:\LDC\LDC64\lib>ldc2 test.d
>>> phobos-ldc.lib(math.obj) : error LNK2019: unresolved external
>>> symbol _D3std4math
>>> 4exp2FNaNbNeeZe referenced in function _D3std4math3sinFNaNbNfcZc
>>> phobos-ldc.lib(math.obj) : error LNK2019: unresolved external
>>> symbol _D3std4math
>>> 5expm1FNaNbNeeZe referenced in function _D3std4math3sinFNaNbNfcZc
>>> phobos-ldc.lib(math.obj) : error LNK2019: unresolved external
>>> symbol _D3std4math
>>> 5atan2FNaNbNeeeZe referenced in function
>>> _D3std4math4acosFNaNbNfeZe
>>> phobos-ldc.lib(math.obj) : error LNK2019: unresolved external
>>> symbol _D3std4math
>>> 5truncFNbNeeZe referenced in function _D3std4math4modfFNbNeeKeZe
>>> phobos-ldc.lib(math.obj) : error LNK2019: unresolved external
>>> symbol _D3std4math
>>> 20FloatingPointControl15setControlStateFNbNetZv referenced in
>>> function _D3std4ma
>>> th5roundFNbNeeZe
>>> phobos-ldc.lib(thread.obj) : error LNK2019: unresolved external
>>> symbol _D4core6t
>>> hread14getStackBottomFZPv referenced in function thread_entryPoint
>>> phobos-ldc.lib(thread.obj) : error LNK2019: unresolved external
>>> symbol fiber_swi
>>> tchContext referenced in function fiber_entryPoint
>>> phobos-ldc.lib(threadaux.obj) : error LNK2019: unresolved
>>> external symbol _D4cor
>>> e3sys7windows9threadaux10thread_aux6getTEBFNbZPPv referenced in
>>> function _D4core
>>> 3sys7windows9threadaux10thread_aux18impersonate_threadFkMDFZvZv
>>> test.exe : fatal error LNK1120: 8 unresolved externals
>>> Error: C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\BIN\x86_amd64\link
>>> .exe failed with status: 1120
>>>
>>> it seems to be someting wrong at druntime & phobos library build
>>> CMake file
>>> which related with compilation.
>>>
>>> How to resolve it?
>>
>> No idea yet. I have to check it.
>>
>> Regards,
>> Kai

November 18, 2013
Hi tae!

On Sunday, 17 November 2013 at 19:17:02 UTC, tae hoo wrote:
> Hi Kai !
>
> Sorry, I am poor at english ^^;;;

No problem at all. I am also no native speaker.

> LVM does generates incompatible with MS tool(case jmp table
> lable , seh lable
> etc)
>
> the problem is 'set directive'
>
> do patch llvm, HasSetDirective from true to false.
>
> <llvm/lib/MC/MCAsmInfo.cpp>
>
>   GPRel64Directive = 0;
>   GPRel32Directive = 0;
>   GlobalDirective = "\t.globl\t";
>   HasSetDirective = false;//true;      <---- this, line number 74,
>   HasAggressiveSymbolFolding = true;
>   COMMDirectiveAlignmentIsInBytes = true;
>   LCOMMDirectiveAlignmentType = LCOMM::NoAlignment;

Great information. :-) I think it is a bit to generic. I set HasSetDirective = false; in class X86MCAsmInfoMicrosoft and it works, too. I added this piece of information to the PR.

>
> I used <git clone --recursive https://github.com/ldc-developers/ldc.git> version.
>
> but final link error genarated.
>
> which version is required to avoide this phobos link problem?

I am still investigating. There might simply something missing - I was/am busy with a lot of other issues, too.

Regards,
Kai