From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id AF403385EC4E for ; Tue, 1 Sep 2020 11:20:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org AF403385EC4E Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-158-uK6lG0fENXahQX1THCehTQ-1; Tue, 01 Sep 2020 07:20:19 -0400 X-MC-Unique: uK6lG0fENXahQX1THCehTQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AD130420E9; Tue, 1 Sep 2020 11:20:18 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-113-228.ams2.redhat.com [10.36.113.228]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0724678B54; Tue, 1 Sep 2020 11:20:17 +0000 (UTC) From: Florian Weimer To: James Y Knight via Gnu-gabi Subject: Re: [RFC] Proposal for new ELF extension - "Symbol meta-information" References: <20200831115859.mwcruabbzoj3x4w7@jozef-acer-manjaro> <875z8zj95u.fsf@oldenburg2.str.redhat.com> Date: Tue, 01 Sep 2020 13:20:16 +0200 In-Reply-To: (James Y. Knight via Gnu-gabi's message of "Mon, 31 Aug 2020 09:45:36 -0400") Message-ID: <87sgc1u4jz.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gnu-gabi@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gnu-gabi mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2020 11:20:22 -0000 * James Y. Knight via Gnu-gabi: > On Mon, Aug 31, 2020 at 8:24 AM Florian Weimer via Gnu-gabi < > gnu-gabi@sourceware.org> wrote: > >> > 3.3.3 SMT_PRINTF_FMT use case >> >> Can this achieved in C++ with a library-only solution? So that >> printf ("%s", str); >> and >> printf ("%f", num); >> resolve to different printf symbols externally? >> > > The LLVM backend optimizer already does this automatically for XCore, TCE, > and Emscripten targets, without interrogating the format string, or adding > anything to the object format. > > On all three: if there are no floating-point arguments to the call, it will > translate {s,f,}printf -> i{s,f,}printf. Otherwise, on emscripten only, if > there are no 128-bit float arguments, it will translate {s,f,}printf -> > small_{s,f,}printf It's not what I had in mind with my C++ comment (I thought about using a constexpr construct to parse the format strings), but it's simpler to just look at the types. I think we could guide this by some attribute machinery for C, especially if it is completely type-dependent. If the symbol choice is determined by that, it is not necessary to maintain the symbol selection in very different places (the library implementation *and* the linker). This is main thing I do not like about SMT_PRINTF_FMT: it needs very library-specific code in the link editor. Thanks, Florian