From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by sourceware.org (Postfix) with ESMTPS id 095C9385801C for ; Wed, 10 Aug 2022 22:16:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 095C9385801C Received: by mail-lf1-x131.google.com with SMTP id f20so23099272lfc.10 for ; Wed, 10 Aug 2022 15:16:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=T7aaIAk5wKWREHeg3onmdp9/ijh4QIDuoDoQG8FUEOE=; b=F4qLiKO8S5OWq1YfPCDkPPAxfQmqze0ll8wSICBJ+qyPgeyFAM03SO8dO92mXM66uh 0ugtoToxP79Eja5a8o6khkQMDnWea64VoRYhJQemvwG+ol7/UiMwgImnnGNNCwAkSUcn c+Ng7fLi2sTMAjgfL0BaAgU96Jsqlp8M0AXK0Hp4ingb1E2bCjQY2KA97A0mROCHBZ3W 3qU9IOEsK0ml04lNtF8NJEqoOUInB3QylnlvmEtKFmK0iZ1zIgZZHoKzbvvJGmbJhz7+ 2gydFkwwthPPgyfCEYvPOMH1e/DQm+yZmPjOShHSe/Np8v995arwClLXomgmESlph/2C Q5yQ== X-Gm-Message-State: ACgBeo274MFyFss1z/PfSwUFjV39Mw7YBVwU3/eymUFOwXSBubCK6gHn vpp5IskdVc0ZjuPSZjPPYocA5mjOm3/HM8GniSc= X-Google-Smtp-Source: AA6agR5EGmWNJlbuUnpaOmBvRO1ydMd4AC+ePg+GrMSlRM8fJcUCwyFlrLcyla/IRZ7/kJ9GqQw7sYx2pUwWgPsD2so= X-Received: by 2002:a05:6512:22c7:b0:48b:38f3:79a8 with SMTP id g7-20020a05651222c700b0048b38f379a8mr10146315lfu.530.1660169795348; Wed, 10 Aug 2022 15:16:35 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Luca Bacci Date: Thu, 11 Aug 2022 00:16:23 +0200 Message-ID: Subject: Re: Checking for built-in functions from build systems To: Jonathan Wakely Cc: "gcc@gcc.gnu.org" X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Aug 2022 22:16:39 -0000 Thank you very much, Jonathan. That's very helpful! This test program: int main() { void *a = alloca(10); return 0; } Compiles fine with: gcc -o test test.c But then fails with: gcc -o test test.c -fno-builtin That's on an Arch Linux system (based on glibc) The issue is that what happens when built-ins are not inlined is not well defined. The libc may not implement the routine, or it's not clear which dependency should provide it. Thanks, Luca Bacci Il giorno mer 10 ago 2022 alle ore 23:27 Jonathan Wakely < jwakely.gcc@gmail.com> ha scritto: > > > On Wed, 10 Aug 2022, 23:12 Luca Bacci via Gcc, wrote: > >> >> 1. Is inlining of built-ins dependant only on the target architecture and >> command-line arguments? >> > > No, I think it can depend on the arguments to the built-in as well. > > > 2. If the answer to 1 is yes, could a __is_builtin_inlined (func) macro be >> added to GCC? It should tell whether func is going to be substituted >> inline >> for the given compiler invocation > > > I don't think that can work for some built-ins, e.g. in a single > translation unit memcmp can be inlined for constant arguments of small > size, and not inlined for other calls. > > > >