Path: csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: GCC vs Clang Date: Tue, 26 Jul 2016 08:20:52 -0700 Organization: None to speak of Lines: 36 Message-ID: References: <8eb73c92-0153-4763-87aa-3b1540738e5e@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="30083"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/nkB3ZIU3MvS0Vsmtd3jCR" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:fUFgQz3/+d68R70uxWLi5q7vfMw= sha1:XM2FfHaYaKFHbAzF/Jv/MOOVPIw= Xref: csiph.com comp.lang.c:91088 supercat@casperkitty.com writes: > On Monday, July 25, 2016 at 9:33:14 PM UTC-5, Keith Thompson wrote: >> supercat writes: >> > If the compiler statically links in parts of the library that are used >> > within a DLL, it can substitute simplified versions in cases where it can >> > make inferences about the arguments. For example, if a piece of code >> > never passes anything other than a literal format string to sprintf, a >> > compiler could replace sprintf with a collection of small functions that >> > are customized to support the formatting options the program actually >> > uses. >> >> A compiler can typically do that anyway. For example, gcc can replace >> printf("hello\n") by puts("hello"). > > It can only do that because there's a standard library routine that's a > direct replacement. If a program uses the %08X format specifier a lot > and no other, a compiler that's responsible for supplying the RTL could > bundle a "__sprintfHex8" function and replace printf("%08X", value)" with > a call to __sprintfHex8, but a compiler couldn't expect to find that > function in an externally-supplied library. A compiler can provide, as part of its installation package, its own library to supplement the one provided by the system or by another package (assuming, in this case, that optimizing "%08X" is worthwhile). Sure, there are some advantages to packaging a runtime library with a compiler. There are also advantages to managing them separately. One such advantage is that I can use gcc on systems that don't have glibc. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"