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 C93203858D35 for ; Wed, 4 Jan 2023 17:02:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C93203858D35 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=1672851736; 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: in-reply-to:in-reply-to:references:references; bh=JXpu7+M+oM/EeQONGB5KMhACg4T1YpvwOvcILWVZQkw=; b=O1kNa9wdk/bSYdaEItLio3YhXU/aMMHNN4Wkfqcwl0ft8P8HoIjFF5xgxBjF5/5KkXFu3A AW37pSP3siBDWP2BdaDp0x607evvST2X3d10pj7SANs0EKEl0kW3db6a7rADZ+P3SpiM1g GnOt8bnnrYV5zMQxj7rY1JiIeTqBWb4= Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-204-Tno60Ak2MwaR3ogZ0BpEZw-1; Wed, 04 Jan 2023 12:02:12 -0500 X-MC-Unique: Tno60Ak2MwaR3ogZ0BpEZw-1 Received: by mail-lj1-f197.google.com with SMTP id s12-20020a2eb8cc000000b0027f6f40eeb3so8040453ljp.2 for ; Wed, 04 Jan 2023 09:02:12 -0800 (PST) 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:subject:date:message-id :reply-to; bh=JXpu7+M+oM/EeQONGB5KMhACg4T1YpvwOvcILWVZQkw=; b=WuiN1h9I3syO44QGT3ZUEAfCE9jIEV3ZNTU+G30ihR04GU1F3SDNIP0L8B8hH3FLH3 HdW8PjNe+big16YPlupcUbAHblERBC6tei8piKhmVylq5HdvaHfnxzS3AA+WOwDlgvJ1 35l/9NfiD/lEjol1rsnixkrMy33s9E0Os7RLvX/6TLrDDofJHQ67+ghVHyctzuYd1l7C uiHsvk0VOAxfskB/Mu1LAQarJlp4sGEc/eTGwsnNaWq8Nix0Dkqk+55jGxZTpaoBw7DI lVnOZqcG4ZmWIdW5ZRjo/JCK4OCKPmTRf+bsSaXC5Cjto4uFDdNRkuezLEl00JZyA4cv fDVw== X-Gm-Message-State: AFqh2koA4I+2nZao8MvTfJcKyNJIWhzGYbQRO/sj+DdpJoP44Y2eGqaf wzEb17ZHliikf5TgK2RhP7aiSjhAISheM7GaeKVX1OaFZ2wWS1ekr+oyk7OH3SGdN7GlTfICB06 YcfsOTO0bKc0NXn9+wtvL/vWZyYR4cJY= X-Received: by 2002:a05:6512:3772:b0:4b5:aa1c:4d12 with SMTP id z18-20020a056512377200b004b5aa1c4d12mr2254085lft.481.1672851731515; Wed, 04 Jan 2023 09:02:11 -0800 (PST) X-Google-Smtp-Source: AMrXdXspwh8670Y9XKgn5wzo6Pqdmdsy+7/V6EIDvX1Hmb7W00goxDUdI8Js7vTvLdPoU9G/I1DnkSm+6k8cEYJi2jY= X-Received: by 2002:a05:6512:3772:b0:4b5:aa1c:4d12 with SMTP id z18-20020a056512377200b004b5aa1c4d12mr2254082lft.481.1672851731276; Wed, 04 Jan 2023 09:02:11 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Wed, 4 Jan 2023 17:02:00 +0000 Message-ID: Subject: Re: Re: [committed] libstdc++: Allow Clang to use before C++23 To: Alexander Hans Cc: "libstdc++" X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=no 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 Wed, 4 Jan 2023 at 16:57, Jonathan Wakely wrote: > > On Wed, 4 Jan 2023 at 16:31, Alexander Hans wrote: > > > > Hi Jonathan, > > Hi, > > > I'm trying to integrate gcc 12.2.0 in a Bazel build and have an issue > > compiling some C code that includes stdatomic.h. Instead of using the C > > stdatomic.h, it includes the C++23 one, which there does nothing. Your > > It should be impossible for C code to include that header. > > > > patch mentioned in the subject seems to address a similar issue. > > However, in my case, it doesn't fix the issue, because when using gcc, > > #if __clang__ is not true. When I change the line to be an > > unconditional #else instead of the #else if, things work as expected. > > > > Why did you put the if __clang__? I can imagine you wanted to address > > this one usecase when people use clang++, but wouldn't the same issue > > occur for g++? > > With Clang, including the C version of actually works, > because clang++ supports the _Atomic qualifier even in C++ code. So > there is non-portable C++17 and C++20 code out there already which > includes and expects it to work (as long as it's only > compiled with Clang). > > My change to the libstdc++ allows that code to keep > compiling when using Clang. Such code never compiled with g++ at any > time, so there is no need to support it. It never worked anyway. > > > I suppose in a usual system-installation, the C++23 > > file is not part of the builtin include paths when compiling C code. > > Right. Not just a system-installation. In any GCC installation, the > libstdc++ headers are in a C++-specific directory that the C compiler > never looks in. > > > However, when having the toolchain managed by Bazel, I can only give > > a single set of include directories [1]: > > > > > cxx_builtin_include_directories > > > [...] > > > We currently use the C++ paths also for C compilation, which is > > > safe as long as there are no name clashes between C++ and C header > > > files. > > > > I can work around this by patching my local version of C++23's > > stdatomic.h, but I suppose other Bazel users will face that issue as > > well, since the assumption of no name clashes is not true anymore. > > Then Bazel is broken. The assumption that "there are no name clashes > between C++ and C header files" has never been true. Why does Bazel even need to know those directories? It should not be adding them for compiling C code nor for compiling C++ code, because GCC does that automatically (and gets it right). > > I suppose we could support that silliness like this: > > --- a/libstdc++-v3/include/c_compatibility/stdatomic.h > +++ b/libstdc++-v3/include/c_compatibility/stdatomic.h > @@ -124,7 +124,7 @@ using std::atomic_flag_clear_explicit; > using std::atomic_thread_fence; > using std::atomic_signal_fence; > > -#elif defined __clang__ > +#elif defined __clang__ || !defined __cplusplus > # include_next > #endif // C++23 > #endif // _GLIBCXX_STDATOMIC_H > > But I don't really like having to patch libstdc++ to support broken tools. > > > > > I wasn't sure if posting to the mailing list was appropriate. Feel > > free to CC to the list! > > Yes, this should be on the mailing list, CC'd. > > > > > > > > Thanks and cheers! > > > > Alex > > > > > > [1] https://bazel.build/rules/lib/cc_common#create_cc_toolchain_config_info > >