<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Tue, 21 Aug 2018 at 17:09, Manoj Gupta via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I am looking for some help regarding a clang crash  when building opencflite. The root cause of the crash is because clang tries to create a GlobalValue "__CFConstantStringClassReference"  but a variable of same name is also present in the source file.</div><div><br></div><div>Crash location:</div><div><div><a href="https://github.com/llvm-mirror/clang/blob/master/lib/CodeGen/CodeGenModule.cpp#L4058" target="_blank">https://github.com/llvm-mirror/clang/blob/master/lib/CodeGen/CodeGenModule.cpp#L4058</a></div><div><br></div><div><div>  // If we don't already have it, get __CFConstantStringClassReference.</div><div>  if (!CFConstantStringClassRef) {</div><div>    llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy);</div><div>    Ty = llvm::ArrayType::get(Ty, 0);</div><div>    llvm::GlobalValue *GV = cast<llvm::GlobalValue>(</div><div>        CreateRuntimeVariable(Ty, "__CFConstantStringClassReference")); // Crashes here</div></div></div><div><br></div><div>Opencflite also declares __CFConstantStringClassReference as a variable, <a href="https://github.com/nevali/opencflite/blob/03999700cf3b79975ae2f2e5f4100ea7096acb3a/CFInternal.h#L364" target="_blank">https://github.com/nevali/opencflite/blob/03999700cf3b79975ae2f2e5f4100ea7096acb3a/CFInternal.h#L364</a> :</div><div><br></div><div>extern int __CFConstantStringClassReference[];</div><div><br></div><div>I do not know the semantics of the name __CFConstantStringClassReference. Is this a reserved name and should opencflite not be declaring this variable ?</div></div></blockquote><div><br></div><div>Yes, this is a reserved identifier and should generally not be declared by user code. (In this case, though, it looks like the code is attempting to find the variable introduced by Clang, and maybe we want to allow that?) In any case, Clang shouldn't crash :)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>If so, appreciate any advice on how to fix the offending code. </div><div><br></div><div>Or is this a  bug in clang?<br></div><div><br></div><div>For reference, r327993 (<a href="https://reviews.llvm.org/rL327993" target="_blank">https://reviews.llvm.org/rL327993</a>)  introduced this code.</div><div><div><br></div><div>Author:     Rafael Espindola <<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>><br></div><div>AuthorDate: Tue Mar 20 15:48:00 2018 +0000</div><div><br></div><div>    Set dso_local for CFConstantStringClassReference.</div><div>    </div><div>    This one cannot use setGVProperties since it has special logic for</div><div>    when it is dllimport or not.</div></div><div><div>    git-svn-id: <a href="https://llvm.org/svn/llvm-project/cfe/trunk@" target="_blank">https://llvm.org/svn/llvm-project/cfe/trunk@</a><b>327993</b> 91177308-0d34-0410-b5e6-96231b3b80d8</div></div><div><br></div><div>Thanks,</div><div>Manoj</div></div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div></div>