From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id BCE363858438 for ; Wed, 26 Jul 2023 20:26:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BCE363858438 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690403208; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p8CSMm/z3uttLrwP0m8hbxRgjYdimkPmV3jt9PjyeWs=; b=GYmVO1W/XLneXWChNI7z1td9nxcC4UtzKqiuw9QbatswxABMsfffU92GOvFwUc7NY44ASH lcPLFgOfocAw8oHjS8VsGWlziNsRrB1fL6S/cXQbRZ4AIZ4MPrgWwrfDLGxhhksXfvRvtk 1cUYQzT60/IV7d6l7fwrMZna8DkptaA= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-74-nx04FnyIPr2SJQqdRduZ0w-1; Wed, 26 Jul 2023 16:26:46 -0400 X-MC-Unique: nx04FnyIPr2SJQqdRduZ0w-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-63d0b65ae89so1627836d6.0 for ; Wed, 26 Jul 2023 13:26:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690403206; x=1691008006; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=p8CSMm/z3uttLrwP0m8hbxRgjYdimkPmV3jt9PjyeWs=; b=b/hTTVoeCH9NFxArrlYrVB3yGbbyr34+T1UdhtETW173EQlRvxXZiEHJYKxJrYm+7T rtMSNw7xoocIya6WA0wY83lrX6KbWKhqI+ngop7bipftleoMS/kggm23CHSncbWtxisL XTkmOQfy71L6fC4ywperLte7eDM/b0fvg6Eaptv0TxyelrLYlyl1jBGSP6L9plrAAq8m 0LT29a7MRnN+JlqdsYjWgs970n46BCb7t3XJn9JGOs8012TUP3zrAdk6DKkOJ22jUVUP jyum9/iNwsrH8Qxt5uR2FL80oUQJHsOk2vWBvYjm9UalqBrmyaGehIsPFQEc1CR6A1Sd xTTw== X-Gm-Message-State: ABy/qLbT++n9wJsR7hADR7N5UIVqfH4Ov1ext1/SkgP+ygJTGbZ7Uqqf Ewz3HBS2Le7K5FfkmRnn4rKXp5gNnMXL90qwP9qya5VHKtXjt0AAy4zVKOOAPVdZUV4FBPlg8Wd BussuvVNuteqcOGkmaQ== X-Received: by 2002:a0c:ca0e:0:b0:63d:30a:d9ea with SMTP id c14-20020a0cca0e000000b0063d030ad9eamr940484qvk.18.1690403206176; Wed, 26 Jul 2023 13:26:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlGmzKn52VHeZroFz0sN/WGBep74iAjlOnUNgLNKNaHwDzcT7wuOBSp2NeLtGaXJtue+hU9Svg== X-Received: by 2002:a0c:ca0e:0:b0:63d:30a:d9ea with SMTP id c14-20020a0cca0e000000b0063d030ad9eamr940467qvk.18.1690403205893; Wed, 26 Jul 2023 13:26:45 -0700 (PDT) Received: from [192.168.1.108] (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id j18-20020a0ce012000000b0063596878aaasm5387109qvk.18.2023.07.26.13.26.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 26 Jul 2023 13:26:45 -0700 (PDT) Message-ID: Date: Wed, 26 Jul 2023 16:26:43 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v2][RFC] c-family: Implement __has_feature and __has_extension [PR60512] To: Alex Coplan , gcc-patches@gcc.gnu.org Cc: Nathan Sidwell , Joseph Myers , Iain Sandoe References: From: Jason Merrill In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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 List-Id: On 6/28/23 06:35, Alex Coplan wrote: > Hi, > > This patch implements clang's __has_feature and __has_extension in GCC. > This is a v2 of the original RFC posted here: > > https://gcc.gnu.org/pipermail/gcc-patches/2023-May/617878.html > > Changes since v1: > - Follow the clang behaviour where -pedantic-errors means that > __has_extension behaves exactly like __has_feature. > - We're now more conservative with reporting C++ features as extensions > available in C++98. For features where we issue a pedwarn in C++98 > mode, we no longer report these as available extensions for C++98. > - Switch to using a hash_map to store the features. As well as ensuring > lookup is constant time, this allows us to dynamically register > features (right now based on frontend, but later we could allow the > target to register additional features). > - Also implement some Objective-C features, add a langhook to dispatch > to each frontend to allow it to register language-specific features. Hmm, it seems questionable to use a generic langhook for something that the generic code doesn't care about, only the c-family front ends. A common pattern in c-family is to declare a signature in c-common.h and define it differently for the various front-ends, i.e. in the *-lang.cc files. > There is an outstanding question around what to do with > cxx_binary_literals in the C frontend for C2x. Should we introduce a new > c_binary_literals feature that is a feature in C2x and an extension > below that, or should we just continue using the cxx_binary_literals > feature and mark that as a standard feature in C2x? See the comment in > c_feature_table in the patch. What does clang do here? > There is also some doubt over what to do with the undocumented "tls" > feature. In clang this is gated on whether the target supports TLS, but > in clang (unlike GCC) it is a hard error to use TLS when the target > doesn't support it. In GCC I believe you can always use TLS, you just > get emulated TLS in the case that the target doesn't support it > natively. So in this patch GCC always reports having the "tls" feature. > Would appreciate if anyone has feedback on this aspect. Hmm, I don't think GCC always supports TLS, given that the testsuite has a predicate to check for that support (and others to check for emulated or native support). But I think it's right to report having "tls" for emulated support. > I know Iain was concerned that it should be possible to have > target-specific features. Hopefully it is clear that the design in this > patch is more amenable in this. I think for Darwin it should be possible > to add a targetcm hook to register additional features (either passing > through a callback to allow the target code to add to the hash_map, or > exposing a separate langhook that the target can call to register > features). The design seems a bit complicated still, with putting a callback into the map. Do we need the callbacks? Do we expect the value of __has_feature to change at different points in compilation? Does that happen in clang? > Bootstrapped/regtested on aarch64-linux-gnu and x86_64-apple-darwin. Any > thoughts? Most of the patch needs more comments, particularly before various top-level definitions. Jason