From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb2e.google.com (mail-yb1-xb2e.google.com [IPv6:2607:f8b0:4864:20::b2e]) by sourceware.org (Postfix) with ESMTPS id ECBC73858005 for ; Wed, 10 Aug 2022 21:11:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ECBC73858005 Received: by mail-yb1-xb2e.google.com with SMTP id g5so25262204ybg.11 for ; Wed, 10 Aug 2022 14:11:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc; bh=3/UpNs8OpiL5JAVa7Rq6uGW4n46gZp4oj4RtCangAz4=; b=lcEZhMqd+YfLS113mUd/KlZdIiRn96rPpQzRjFW2WKIcx6WfKzRjqXd7JQKvqiji1h xgDRoHxZTM7MHkSnBvaTSBcL7w6EkU5Gsy2zAhpAtmu0T6azQMK2S+GiJC+I8sG4of8j U5H2GHnN28+cMGIy8j5B+lmNPUatNRLomJbiU9231ahLgtzyK1X6vnmCOLzBeO+uatvG lR+mVjMWUpHsfGjrKjX77bS+44eJhBht3QHWilD1E36iXiLVqlRkjSs7iNu8VkMfU0Q6 8sI4nSKVKXlnSvlgKrlktPUZcs+nN45ERDKBX0MNW7mRfOFmBhYn4hS2ByNEy1boWTsJ 5Tyw== X-Gm-Message-State: ACgBeo2fvRkooRg5DqANm0ebrPkREU94u5v8JN9ua+1qh/4GcOC1F99t Rw+rBo9iKF0ykdkEFGa4LwNTQvcIufXsz0oXOymxlL4d X-Google-Smtp-Source: AA6agR4LEmzAfXtWmyn+5SVD/nlkKKsw2I5zbbs1D4v78h7AcJ6+DbDueK2/ynwMYJypG4mcJ90t2pcg+PRiZU82WVQ= X-Received: by 2002:a25:4dd7:0:b0:67b:97ea:1935 with SMTP id a206-20020a254dd7000000b0067b97ea1935mr21857973ybb.129.1660165886134; Wed, 10 Aug 2022 14:11:26 -0700 (PDT) MIME-Version: 1.0 From: Luca Bacci Date: Wed, 10 Aug 2022 23:11:13 +0200 Message-ID: Subject: Checking for built-in functions from build systems To: gcc@gcc.gnu.org X-Spam-Status: No, score=0.5 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 21:11:30 -0000 Hello dear GCC developers, I am working on an issue in Meson wrt GCC built-in functions, see https://github.com/mesonbuild/meson/issues/10641. As you already know, some built-ins are always inlined, while others are inlined only at times (e.g. depending on the target architecture) and resolve to a regular function call otherwise. The issue is about the latter's, i.e. those that may emit regular function calls. In fact, even though __has_builtin(func) evaluates to 1, func may not be present in libraries (libgcc, libc, libm), causing linking errors if not inlined. Because some of the GCC built-in functions are not part of the C standard (e.g. sincos), it's not worthwhile to require having implementations in libc. In addition, should generic implementations be added to libgcc, those would likely have sub-par performance or accuracy issues (being generic). As such, I think that a build system should check if an implementation of a conditionally-inlined built-in function is provided in the target libc. I have a few questions: 1. Is inlining of built-ins dependant only on the target architecture and command-line arguments? 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 3. Is it true that conditionally-inlined built-ins are exactly those that come in the two variants of '__builtin_func' and 'func'? Thanks, Luca Bacci