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.129.124]) by sourceware.org (Postfix) with ESMTPS id A4D223858D35 for ; Wed, 4 Jan 2023 16:58:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A4D223858D35 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=1672851485; 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=OA98U3Sf9YEs8TmCfNHlePywQw2lschi44Gw1KtmFn0=; b=InixU3TtIQADp0GBG/fVmGOEcZocdshujkBXa+yuGMUdwFJUOn6y4hRmgIvntBUqWa9gcE U2rZ9JGim6eVediOXexV23rBKufNhb0wo12Ad0nEWBCIgvOI9voR6GgCojmopPOlpVplR6 EKZsheUMsjANk4jMmvatvgRr+82V3As= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-279-yJGp-w8wMsmmyr2_QG8OwA-1; Wed, 04 Jan 2023 11:58:03 -0500 X-MC-Unique: yJGp-w8wMsmmyr2_QG8OwA-1 Received: by mail-lj1-f200.google.com with SMTP id a7-20020a2eb547000000b0027ff0f032efso2406750ljn.9 for ; Wed, 04 Jan 2023 08:58:03 -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=OA98U3Sf9YEs8TmCfNHlePywQw2lschi44Gw1KtmFn0=; b=oAx+o6N+0uU8y3Su+zIkRaCwAbaiiLE5FjQHLtHwrka5cJ8uJvW8Wssve1AS4EcJTk SQYw85Tn33oFMNs+VsHuXD9J46FJs1JHlNYfEYkuwRUv181cDd9uh1Gv4s5+ZyMm008f XsbDVVIyz9GtTxfZrHsjkF0VbQFls2NGnvRq25oa05K4fQ0zcWmU9VyMlhe5bFkYF85/ AmMErD+a1e7nw6TP9jHEnffHFl7NU/fmcjX+gROF1PCitgUOpqzbbeZdzvk2nU6mnZNJ BzOrMIqVAT7lMv2ArQWCST08RP4cEiMqklr9tTn0vfZDBLkbqRCBZ9BBLFIXRGeW8wXC nzUw== X-Gm-Message-State: AFqh2koBDWJrKa5yCuXdIvd5WvoMK6GqAnQ6wevRvk/VhDEzzz74TMKo uSgusdmrresEaLTAKqmH4v6ChYAQ0y3WKRj1WdtkzP7w6TOxaB6J9OAwlmrEcbAPNlrREyhS//j sLHL1FVMoMMyqIF6bDcCHgZintYjBfDA= X-Received: by 2002:ac2:5b41:0:b0:4b5:5f2b:ddf6 with SMTP id i1-20020ac25b41000000b004b55f2bddf6mr1794979lfp.17.1672851482452; Wed, 04 Jan 2023 08:58:02 -0800 (PST) X-Google-Smtp-Source: AMrXdXtXCtN+UllWIbZyFac86Dv2XezSB5K3krKCv2PYe+5sYmhvFL7RoyNgPs5UZb6H1T2OQPxy6Pwl72jb2XWIJRc= X-Received: by 2002:ac2:5b41:0:b0:4b5:5f2b:ddf6 with SMTP id i1-20020ac25b41000000b004b55f2bddf6mr1794977lfp.17.1672851482115; Wed, 04 Jan 2023 08:58:02 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Wed, 4 Jan 2023 16:57:50 +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: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. 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 >