New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android/AArch64 betterC putting out unreferenced __init symbol #2876
Comments
Why would that be a bug? The init symbol is emitted into the object file containing the struct/class declaration (i.e., druntime's |
Btw the reason it's not zero-initialized (and thus only failing for Android/AArch64) is the chars array. Chars are initialized with |
This is an |
I'm not sure what a fwd-declared struct would be (an opaque declaration |
I would have thought all such default initialization is turned off for |
To be consistent with the other structs/unions a few lines down (and C |
@joakim-noah since only functions and global variables have linkage, @kinke semantically
struct S_ubyte { int x; ubyte[16] y; }
struct S_void { int x; void[16] y; }
void main()
{
import std.experimental.all;
static foreach (S; AliasSeq!(S_ubyte, S_void))
{{
S s;
writeln(S.stringof, Fields!S.stringof);
writeln("T.init: ", (cast(ubyte*)&s)[0 .. S.sizeof]);
writeln("__traits(isZeroInit, S): ", __traits(isZeroInit, S));
writeln("__traits(getPointerBitmap, S): ", __traits(getPointerBitmap, S));
writeln();
}}
} (Compile with DMD git master) |
Thx for the reminder about the GC scanning difference, which makes sense. |
https://issues.dlang.org/show_bug.cgi?id=17968 probably related |
This specific issue (and quite a bunch of similar structs with previously default-initialized |
This is likely a long-standing dmd bug, but it's consistently reproducible with this Android/AArch64 example that a user recently reported on the forum. I was able to reproduce with the following sample code and the latest 1.12 release cross-compiling for Android from linux/x64:
Compiling with
./ldc2-1.12.0-linux-x86_64/bin/ldc2 -betterC -mtriple=aarch64-none-linux-android -c foo.d
, I see the following symbol emitted:Compile with
-mtriple=armv7-none-linux-android
and the symbol's gone. I see it dumped in the IR too, so this is likely coming from the DMD frontend.Linking this file on Android/AArch64 fails, because
betterC
doesn't link against druntime and so can't find the symbol.JacobKagamin's void-initialization workaround mentioned in the linked forum thread avoids the problem.The text was updated successfully, but these errors were encountered: