<div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Feb 19, 2019 at 6:14 PM James Y Knight <<a href="mailto:jyknight@google.com">jyknight@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">On Tue, Feb 19, 2019 at 5:22 PM Reid Kleckner via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">My (possibly not fully informed) understanding of the situation is basically what this commenter said:<div><a href="https://pagure.io/fesco/issue/2020#comment-545782" target="_blank">https://pagure.io/fesco/issue/2020#comment-545782</a><br></div><div>> (llvm doesn't implement e.g. _D_FORTIFY_SOURCE=2 properly)</div><div><br></div><div>As a clang developer, the way I see the issue is that -D_FORTIFY_SOURCE=2 liberally uses GCC extensions. Many changes could be made upstream in glibc to make fortify source work better with clang. Implementing the extensions needed in clang is a bit heroic.</div><div><br></div><div>I just want to push back on the narrative that we "haven't implemented" _FORTIFY_SOURCE. Clang hasn't implemented some collection of hard-to-implement GCC extensions, and </div><div>_FORTIFY_SOURCE happens to depend on them. Many of these extensions are borderline incompatible with fundamental LLVM and Clang design decisions (__builtin_va_arg_pack_len, see <a href="https://clang.llvm.org/docs/UsersManual.html#gcc-extensions-not-implemented-yet" target="_blank">https://clang.llvm.org/docs/UsersManual.html#gcc-extensions-not-implemented-yet</a>), and relaxing them isn't fun or easy.</div></div></div></div></div></div></div></blockquote><div><br></div><div>Exactly -- _FORTIFY_SOURCE is a *libc* feature, not a clang feature. Here we're talking about the implementation in glibc -- which was developed for GCC, and nobody in the glibc community has yet been bothered to implement proper support in clang.</div></div></div></blockquote><div><br></div><div>For clarity here, let me just restate that:</div><div><div>I meant to say "proper support <i>with</i> clang", not <i>"in</i> clang".</div></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div><br></div><div>But I'm fairly sure that Clang _does have_ all of the functionality necessary to implement all of the fortifications enabled by _FORTIFY_SOURCE=2 in glibc, because it has been implemented in Bionic libc -- using an entirely different set of compiler extensions which are supported only in Clang.</div><div><br></div><div>If someone wishes to contribute support to glibc to better support these fortifications with clang, it should be pretty easy. Simply look at how FORTIFY_SOURCE is implemented in the Bionic libc, and do something similar to that (with appropriate ifdeffery, because that version is not going to work in GCC).</div><div><br></div><div><br></div></div></div>
</blockquote></div></div></div>