digitalmars.D - Possible bug in the D compiler w.r.t x86_64 ABI calling convention
- Sandeep Datta (17/17) May 19 2012 Hi,
- David Nadlinger (4/6) May 19 2012 x86_64 struct ABI differences are a known problem and being
- Sandeep Datta (4/10) May 19 2012 Hmm, are there any known work arounds? I am in a fix as I need to
- Sandeep Datta (3/15) May 19 2012 Oops...hit send a little too early...I guess building with -m32
- Jacob Carlborg (4/6) May 20 2012 Yes that will fix the problem.
- Jacob Carlborg (7/10) May 20 2012 There are bindings that are more up to date in my DStep project. It also...
- Sandeep Datta (4/14) May 20 2012 Thanks but will your bindings work in 64bit mode? It seems to me
- Jacob Carlborg (8/11) May 20 2012 The bindings will work for both 32 and 64bit. It's impossible to change
Hi, I seem to have discovered a bug in the D compiler which is causing it to emit incompatible code with gcc on Ubuntu 11.04 x86_64. I have minimised the code required to reproduce this problem and uploaded it to github, here is the link https://github.com/SDX2000/CFromDTest1. Once you have downloaded it run build to generate the executables. You'll see that the output produced by the d program is different from the output produced by the equivalent c code. I have spent some time on analysing the generated assembly. You'll find annotated assembly code main.d etc highlighting the problem. Basically the problem is that dmd generates code which is not compatible with gcc when a C function returns a struct. Please do let me know if this is a legitimate bug and if I need to file a bug report. Regards, Sandeep Datta.
May 19 2012
On Saturday, 19 May 2012 at 18:31:45 UTC, Sandeep Datta wrote:Please do let me know if this is a legitimate bug and if I need to file a bug report.x86_64 struct ABI differences are a known problem and being worked on, a fix will likely be included with the next release. David
May 19 2012
On Saturday, 19 May 2012 at 18:37:20 UTC, David Nadlinger wrote:On Saturday, 19 May 2012 at 18:31:45 UTC, Sandeep Datta wrote:Hmm, are there any known work arounds? I am in a fix as I need to use the demios/libclang wrapper but it has several functions which return structs.Please do let me know if this is a legitimate bug and if I need to file a bug report.x86_64 struct ABI differences are a known problem and being worked on, a fix will likely be included with the next release. David
May 19 2012
On Saturday, 19 May 2012 at 18:41:28 UTC, Sandeep Datta wrote:On Saturday, 19 May 2012 at 18:37:20 UTC, David Nadlinger wrote:Oops...hit send a little too early...I guess building with -m32 should fix this problem, no?On Saturday, 19 May 2012 at 18:31:45 UTC, Sandeep Datta wrote:Hmm, are there any known work arounds? I am in a fix as I need to use the demios/libclang wrapper but it has several functions which return structs.Please do let me know if this is a legitimate bug and if I need to file a bug report.x86_64 struct ABI differences are a known problem and being worked on, a fix will likely be included with the next release. David
May 19 2012
On 2012-05-19 20:42, Sandeep Datta wrote:Oops...hit send a little too early...I guess building with -m32 should fix this problem, no?Yes that will fix the problem. -- /Jacob Carlborg
May 20 2012
On 2012-05-19 20:41, Sandeep Datta wrote:Hmm, are there any known work arounds? I am in a fix as I need to use the demios/libclang wrapper but it has several functions which return structs.There are bindings that are more up to date in my DStep project. It also contains some useful wrappers: https://github.com/jacob-carlborg/dstep/tree/master/clang The bindings are in the "c" directory. -- /Jacob Carlborg
May 20 2012
On Sunday, 20 May 2012 at 11:40:35 UTC, Jacob Carlborg wrote:On 2012-05-19 20:41, Sandeep Datta wrote:Thanks but will your bindings work in 64bit mode? It seems to me some functions are still returning a struct. I think I will have to rebuild llvm+clang in 32bit, right?Hmm, are there any known work arounds? I am in a fix as I need to use the demios/libclang wrapper but it has several functions which return structs.There are bindings that are more up to date in my DStep project. It also contains some useful wrappers: https://github.com/jacob-carlborg/dstep/tree/master/clang The bindings are in the "c" directory.
May 20 2012
On 2012-05-20 19:00, Sandeep Datta wrote:Thanks but will your bindings work in 64bit mode? It seems to me some functions are still returning a struct. I think I will have to rebuild llvm+clang in 32bit, right?The bindings will work for both 32 and 64bit. It's impossible to change the bindings in any way to have it work on 64bit. The bug is with DMD, not the bindings. Yes you need to rebuild LLVM and Clang in 32bit mode. When the DMD bug is fixed my bindings should work in 64bit as well. -- /Jacob Carlborg
May 20 2012