From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id 1DAC83858C20 for ; Sat, 29 Oct 2022 04:51:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1DAC83858C20 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=google.com Received: by mail-pf1-x433.google.com with SMTP id m6so6458691pfb.0 for ; Fri, 28 Oct 2022 21:51:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=qPbuISLlyBkvTZwxd5LWpKo7+kymVjxUi6iCV51a2dE=; b=M6qOZBV3X3U9hjcd/518N6DYWSYDMS+RZxhI+NMc9tRZzVosrXEcKS7z0c7g3+3glw KRR5tnOCz4vfRjnMMNvmFIzfd7UNSaT++TFDmMQT+zktQ7aWKoGFKSMiMqdGQTHIMz9y pEcAtvnicAwzXTZKf5urxURCM+RB580bolwMt0h7UPxqDehpYpEQ/vzXnHhhr153H4da cBwP02s//i3qFqQpjfJJ2UN+F1T1a7UQdzRngCZH7QRVaBqB1nV3P6S6JnCGEGZvfaDm +ebbaNO7ZKjXRDVbTg7qd20kKnrfI31YgOOmC8x6/8Dj0va52SRghTH4jOngqCZkvlAR TqdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qPbuISLlyBkvTZwxd5LWpKo7+kymVjxUi6iCV51a2dE=; b=7t+BD8Ap5Lg0FEEIuGgW8uivjV2bpoqbhjNYyiQ+wGH4obJZxPgxFiaZmkb6Jwbdmf JobOMaI6UKJkMf48VEqwqrr6Q4WnSfgm6IdTzymzWxY49j5tBthHFrND0za82/kr/hjB siWtul0lcfD6KKGTagZOEBGe6/pLhNpfHJNWKGVFcl64JSmYJys9AVFOH2iXfX8NXOnk 7xFoWeotX4RszQMO70Vlov2HriDqSj02J+vVtSTQz+FHwGoK1judbh1ug/AEKj3SKrtr P5TEYPtdIGXzp3kD2D0U3w4n+tSC1cYZXjtCajvfg8Tv+m6HaE4mJCxDGO72dfIV996+ +WwQ== X-Gm-Message-State: ACrzQf1PhwPCrcKOrEDxinEo95F6T8efcxJ/VIfXbhWglMH9kincDU6c XjT1DHLncDEUxzM9IGmzIlPsYP2X73cOAA== X-Google-Smtp-Source: AMsMyM4Bkc6uwYI2xrD6jEFs31s4wjgIQGyy0Cd+IDuIUvmLwQrb3s4I4TPnfaGnFsDju5+27ewZ2g== X-Received: by 2002:a63:5b48:0:b0:458:1e98:c862 with SMTP id l8-20020a635b48000000b004581e98c862mr2587532pgm.568.1667019114944; Fri, 28 Oct 2022 21:51:54 -0700 (PDT) Received: from google.com ([2620:15c:2ce:200:8981:f21e:b257:256]) by smtp.gmail.com with ESMTPSA id j8-20020a170902758800b00178acc7ef16sm298462pll.253.2022.10.28.21.51.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 21:51:53 -0700 (PDT) Date: Fri, 28 Oct 2022 21:51:50 -0700 From: Fangrui Song To: Adhemerval Zanella Cc: libc-alpha@sourceware.org Subject: Re: [PATCH 11/11] nptl: Fix pthread_create.c build with clang Message-ID: <20221029045150.6in65puyr7ev4oop@google.com> References: <20221028173532.876027-1-adhemerval.zanella@linaro.org> <20221028173532.876027-12-adhemerval.zanella@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20221028173532.876027-12-adhemerval.zanella@linaro.org> X-Spam-Status: No, score=-26.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,ENV_AND_HDR_SPF_MATCH,GIT_PATCH_0,KAM_INFOUSMEBIZ,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 2022-10-28, Adhemerval Zanella via Libc-alpha wrote: >clang complains that libc_hidden_data_def (__nptl_threads_events) >creates an invalid alias: > > pthread_create.c:50:1: error: alias must point to a defined variable or function > libc_hidden_data_def (__nptl_threads_events) > ^ > ../include/libc-symbols.h:621:37: note: expanded from macro > 'libc_hidden_data_def' > >It seems that clang requires that a proper prototype is defined prior >the hidden alias creation. I investigated the issue last year: https://maskray.me/blog/2021-10-10-when-can-glibc-be-built-with-clang#aliasing-an-asm-label The issue is that when the alias target (__GI___nptl_threads_events) is the asm label name of a declaration, Clang cannot tell the alias target is actually defined. It conservatively (you may call it wrong) reports an error. Reviewed-by: Fangrui Song >--- > nptl/pthread_create.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > >diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c >index 32ae2f4b2f..34a41a0fdf 100644 >--- a/nptl/pthread_create.c >+++ b/nptl/pthread_create.c >@@ -45,13 +45,15 @@ > > > /* Globally enabled events. */ >-td_thr_events_t __nptl_threads_events; >+extern td_thr_events_t __nptl_threads_events; > libc_hidden_proto (__nptl_threads_events) >+td_thr_events_t __nptl_threads_events; > libc_hidden_data_def (__nptl_threads_events) > > /* Pointer to descriptor with the last event. */ >-struct pthread *__nptl_last_event; >+extern struct pthread *__nptl_last_event; > libc_hidden_proto (__nptl_last_event) >+struct pthread *__nptl_last_event; > libc_hidden_data_def (__nptl_last_event) > > #ifdef SHARED >-- >2.34.1 >