digitalmars.D.ldc - llvm 3.6 and x86 (32-bit) varargs bad stack adjust
- Dan Olson (10/10) Jul 12 2015 I haven't been paying attention, so perhaps this is old news. D varargs
- Kai Nacke (7/17) Jul 12 2015 Hi Dan!
- Dan Olson (2/2) Jul 13 2015 https://github.com/ldc-developers/ldc/issues/1000
- Dan Olson (6/9) Jul 13 2015 No, I have not tried 3.7 and I won't have time for a couple days.
- David Nadlinger (5/7) Jul 13 2015 The reasons are indeed mainly historic in so far as this is what
- Dan Olson (2/8) Jul 13 2015 Same problem with LLVM master 3.7.0svn.
- Kai Nacke (5/16) Jul 14 2015 stdcall conventions does not support variadic arguments. Or am I
- David Nadlinger (4/7) Jul 14 2015 So if this is really an LLVM bug that we cannot work around
I haven't been paying attention, so perhaps this is old news. D varargs is broken with LDC 0.15.2 and LLVM 3.6 releases. It looks like an incorrect stack adjust is being added by backend after the function call. I noticed when I ran unittests and std.outbuffer plus other unittests segv. I tried LLVM 3.6.0, 3.6.1, and latest version on release_36 branch. All fail same way. LLVM 3.5 seems ok. Is there an Issue on this yet? -- Dan
Jul 12 2015
On Sunday, 12 July 2015 at 07:09:33 UTC, Dan Olson wrote:I haven't been paying attention, so perhaps this is old news. D varargs is broken with LDC 0.15.2 and LLVM 3.6 releases. It looks like an incorrect stack adjust is being added by backend after the function call. I noticed when I ran unittests and std.outbuffer plus other unittests segv. I tried LLVM 3.6.0, 3.6.1, and latest version on release_36 branch. All fail same way. LLVM 3.5 seems ok. Is there an Issue on this yet? -- DanHi Dan! There is no ldc issue yet. Did you check with LLVM 3.7? If we can produce a LLVM bug report then we could try to set this as a release blocker. Branching for the 3.7 release is tomorrow. Regards, Kai
Jul 12 2015
https://github.com/ldc-developers/ldc/issues/1000 Do I win something for Issue 1000?
Jul 13 2015
"Kai Nacke" <kai redstar.de> writes:There is no ldc issue yet. Did you check with LLVM 3.7? If we can produce a LLVM bug report then we could try to set this as a release blocker. Branching for the 3.7 release is tomorrow.No, I have not tried 3.7 and I won't have time for a couple days. I don't understand the history of why LDC uses X86_StdCall for Posix. It says in LLVM docs that it is mostly used by Win32. Perhaps it is not well tested outside Windows. I don't think this new Issue is a problem on Windows.
Jul 13 2015
On Monday, 13 July 2015 at 17:04:55 UTC, Dan Olson wrote:I don't understand the history of why LDC uses X86_StdCall for Posix.The reasons are indeed mainly historic in so far as this is what DMD does, and we want to match DMD's calling convention as closely as possible for naked inline assembly. — David
Jul 13 2015
Dan Olson <gorox comcast.net> writes:"Kai Nacke" <kai redstar.de> writes:Same problem with LLVM master 3.7.0svn.There is no ldc issue yet. Did you check with LLVM 3.7? If we can produce a LLVM bug report then we could try to set this as a release blocker. Branching for the 3.7 release is tomorrow.No, I have not tried 3.7 and I won't have time for a couple days.
Jul 13 2015
On Monday, 13 July 2015 at 17:04:55 UTC, Dan Olson wrote:"Kai Nacke" <kai redstar.de> writes:stdcall conventions does not support variadic arguments. Or am I wrong? Regards, KaiThere is no ldc issue yet. Did you check with LLVM 3.7? If we can produce a LLVM bug report then we could try to set this as a release blocker. Branching for the 3.7 release is tomorrow.No, I have not tried 3.7 and I won't have time for a couple days. I don't understand the history of why LDC uses X86_StdCall for Posix. It says in LLVM docs that it is mostly used by Win32. Perhaps it is not well tested outside Windows. I don't think this new Issue is a problem on Windows.
Jul 14 2015
"Kai Nacke" <kai redstar.de> writes:On Monday, 13 July 2015 at 17:04:55 UTC, Dan Olson wrote:Yeah, I read that too. That is why I was curious about the history of using X86_StdCall. Didn't D-style variadics changed in 0.15.2 from a pointer to varags to a true variadic call. Could that be related? I decided to start looks at diffs in LLVM source from 3.5 to 3.6 to see what might have happened there too. Maybe LDC is just using X86_StdCall in a "non-Std" way."Kai Nacke" <kai redstar.de> writes:stdcall conventions does not support variadic arguments. Or am I wrong? Regards, KaiThere is no ldc issue yet. Did you check with LLVM 3.7? If we can produce a LLVM bug report then we could try to set this as a release blocker. Branching for the 3.7 release is tomorrow.No, I have not tried 3.7 and I won't have time for a couple days. I don't understand the history of why LDC uses X86_StdCall for Posix. It says in LLVM docs that it is mostly used by Win32. Perhaps it is not well tested outside Windows. I don't think this new Issue is a problem on Windows.
Jul 14 2015
On Wednesday, 15 July 2015 at 06:32:32 UTC, Dan Olson wrote:"Kai Nacke" <kai redstar.de> writes:Yes, that is the difference. With 0.15.1 there is no variadic call. I think we must change calling convention to cdecl for variadic D functions. Regards, KaiOn Monday, 13 July 2015 at 17:04:55 UTC, Dan Olson wrote:Yeah, I read that too. That is why I was curious about the history of using X86_StdCall. Didn't D-style variadics changed in 0.15.2 from a pointer to varags to a true variadic call. Could that be related? I decided to start looks at diffs in LLVM source from 3.5 to 3.6 to see what might have happened there too. Maybe LDC is just using X86_StdCall in a "non-Std" way."Kai Nacke" <kai redstar.de> writes:stdcall conventions does not support variadic arguments. Or am I wrong? Regards, KaiThere is no ldc issue yet. Did you check with LLVM 3.7? If we can produce a LLVM bug report then we could try to set this as a release blocker. Branching for the 3.7 release is tomorrow.No, I have not tried 3.7 and I won't have time for a couple days. I don't understand the history of why LDC uses X86_StdCall for Posix. It says in LLVM docs that it is mostly used by Win32. Perhaps it is not well tested outside Windows. I don't think this new Issue is a problem on Windows.
Jul 15 2015
On Monday, 13 July 2015 at 04:34:00 UTC, Kai Nacke wrote:There is no ldc issue yet. Did you check with LLVM 3.7? If we can produce a LLVM bug report then we could try to set this as a release blocker. Branching for the 3.7 release is tomorrow.So if this is really an LLVM bug that we cannot work around easily, what is our plan for the next LDC release(s)? — David
Jul 14 2015
On Tuesday, 14 July 2015 at 12:04:57 UTC, David Nadlinger wrote:On Monday, 13 July 2015 at 04:34:00 UTC, Kai Nacke wrote:I think now that it is not an LLVM bug because stdcall does not support variadic arguments. Solution is to use the C calling convention. DMD seems to do something similar. Regards, KaiThere is no ldc issue yet. Did you check with LLVM 3.7? If we can produce a LLVM bug report then we could try to set this as a release blocker. Branching for the 3.7 release is tomorrow.So if this is really an LLVM bug that we cannot work around easily, what is our plan for the next LDC release(s)? — David
Jul 15 2015
"Kai Nacke" <kai redstar.de> writes:I think now that it is not an LLVM bug because stdcall does not support variadic arguments. Solution is to use the C calling convention. DMD seems to do something similar.It is odd though that LLVM doesn't complain when varargs is used with CallingConv::X86_StdCall. With ARM when I upgraded to 0.15.2, it specifically told me: [ 5%] Generating src/core/demangle_arm64.o Calling convention does not support varargs or perfect forwarding! i32 (i8*, i64, i8*, ...)* snprintf LLVM ERROR: Broken module found, compilation aborted! make[3]: *** [runtime/src/core/demangle_arm64.o] Error 1 Then I knew to switch from Fast to C! -- Dan
Jul 16 2015