I (with my raspbian maintainer hat on) reported this to ldc upstream at 
https://github.com/ldc-developers/ldc/issues/2848 and some digging has been 
done. The short version is that we know what commit caused the build failures. 
However that commit was a fix for mis compilation, so I don't think we should 
just back it out. The proper fix is in llvm itself though a workaround may be 
possible in ldc.

The long version as I understand it.

ldc generates "thunks", these thunks adjust the "this" pointer before calling 
the original function. I understand they are related to multiple inheritance.

It was discovered that "thunks" for variadic functions were being miscompiled 
https://github.com/ldc-developers/ldc/issues/2613 , the variadic arguments were not being 
passed on correctly to the original function. It turns out that variadic functions can 
only be passed on correctly in a tail call (most ABIs don't pass on any meta-information 
about the number of variadics, so there is no real way to copy the variadics).

The fix was to make ldc specify "musttail" (which is an order) rather than 
"tail" (which is a hint) when generating thunks for variadic functions 
https://github.com/kinke/ldc/commit/1dda15a76272cdb3963754fa815d96bacc989852.

Unfortunately it seems that llvm sometimes fails to compile such thunks on arm, 
I did some playing around with different parameter lists and it seems that it 
fails to compile them if a non-variadic structure parameter overflows on to the 
stack.

So what are our options.

1. Back out the upstream fix, this would fix the build but would almost 
certainly result in miscompiled code, I don't think that is acceptable.
2. Get the issue fixed in llvm, I have filed a bug report ( 
https://bugs.llvm.org/show_bug.cgi?id=38931 ) but I don't know when and if it 
will be actioned.
3. Hack ldc to generate variadic thunks in native assembler on arm, the thunks 
are trivial to express in native arm asm, but i'm not sure what calls to the 
llvm api are needed to insert a procedure written in native asm.
4. Simply get libundead removed on armhf/raspbian. libundead seems to only have 
two reverse build-dependencies neither of which has ever successfully built on 
armhf. libbiod previously failed with a testsuite failure (probablly related to 
the miscompilation discussed above) and now fails with the same error that 
libundead does. sambamba is blocked by a dependency on libbiod

Reply via email to