<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class="">On Aug 24, 2018, at 5:17 PM, Richard Smith via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div class="gmail_quote"><div dir="ltr" class="">On Tue, 21 Aug 2018 at 17:09, Manoj Gupta via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr" class="">Hi,<div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">Crash location:</div><div class=""><div class=""><a href="https://github.com/llvm-mirror/clang/blob/master/lib/CodeGen/CodeGenModule.cpp#L4058" target="_blank" class="">https://github.com/llvm-mirror/clang/blob/master/lib/CodeGen/CodeGenModule.cpp#L4058</a></div><div class=""><br class=""></div><div class=""><div class=""> <span class="Apple-converted-space"> </span>// If we don't already have it, get __CFConstantStringClassReference.</div><div class=""> <span class="Apple-converted-space"> </span>if (!CFConstantStringClassRef) {</div><div class=""> <span class="Apple-converted-space"> </span>llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy);</div><div class=""> <span class="Apple-converted-space"> </span>Ty = llvm::ArrayType::get(Ty, 0);</div><div class=""> <span class="Apple-converted-space"> </span>llvm::GlobalValue *GV = cast<llvm::GlobalValue>(</div><div class=""> <span class="Apple-converted-space"> </span>CreateRuntimeVariable(Ty, "__CFConstantStringClassReference")); // Crashes here</div></div></div><div class=""><br class=""></div><div class="">Opencflite also declares __CFConstantStringClassReference as a variable,<span class="Apple-converted-space"> </span><a href="https://github.com/nevali/opencflite/blob/03999700cf3b79975ae2f2e5f4100ea7096acb3a/CFInternal.h#L364" target="_blank" class="">https://github.com/nevali/opencflite/blob/03999700cf3b79975ae2f2e5f4100ea7096acb3a/CFInternal.h#L364</a><span class="Apple-converted-space"> </span>:</div><div class=""><br class=""></div><div class="">extern int __CFConstantStringClassReference[];</div><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">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></div></blockquote><div><br class=""></div>Well, it's supposed to be an external reference to a symbol defined in the Objective-C library. In this case, I think opencflite is acting as the Objective-C library that defines that symbol, so it's not illegitimate. I don't know what's different about Apple's library that it doesn't have this problem — maybe it just doesn't have any CF string literals in the equivalent to this file.</div><div><br class=""></div><div>John.</div><div><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div class="gmail_quote"><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr" class=""><div class="">If so, appreciate any advice on how to fix the offending code. </div><div class=""><br class=""></div><div class="">Or is this a bug in clang?<br class=""></div><div class=""><br class=""></div><div class="">For reference, r327993 (<a href="https://reviews.llvm.org/rL327993" target="_blank" class="">https://reviews.llvm.org/rL327993</a>) introduced this code.</div><div class=""><div class=""><br class=""></div><div class="">Author: Rafael Espindola <<a href="mailto:rafael.espindola@gmail.com" target="_blank" class="">rafael.espindola@gmail.com</a>><br class=""></div><div class="">AuthorDate: Tue Mar 20 15:48:00 2018 +0000</div><div class=""><br class=""></div><div class=""> <span class="Apple-converted-space"> </span>Set dso_local for CFConstantStringClassReference.</div><div class=""> </div><div class=""> <span class="Apple-converted-space"> </span>This one cannot use setGVProperties since it has special logic for</div><div class=""> <span class="Apple-converted-space"> </span>when it is dllimport or not.</div></div><div class=""><div class=""> <span class="Apple-converted-space"> </span>git-svn-id:<span class="Apple-converted-space"> </span><a href="https://llvm.org/svn/llvm-project/cfe/trunk@" target="_blank" class="">https://llvm.org/svn/llvm-project/cfe/trunk@</a><b class="">327993</b><span class="Apple-converted-space"> </span>91177308-0d34-0410-b5e6-96231b3b80d8</div></div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Manoj</div></div>_______________________________________________<br class="">cfe-dev mailing list<br class=""><a href="mailto:cfe-dev@lists.llvm.org" target="_blank" class="">cfe-dev@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br class=""></blockquote></div></div><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">_______________________________________________</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">cfe-dev mailing list</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><a href="mailto:cfe-dev@lists.llvm.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">cfe-dev@lists.llvm.org</a><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a></div></blockquote></div><br class=""></body></html>