From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A077CE79AD for ; Wed, 20 Sep 2023 06:52:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233468AbjITGwI (ORCPT ); Wed, 20 Sep 2023 02:52:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233462AbjITGwH (ORCPT ); Wed, 20 Sep 2023 02:52:07 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E77FD3; Tue, 19 Sep 2023 23:51:59 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 443211F385; Wed, 20 Sep 2023 06:51:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1695192718; h=from:from:reply-to: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=j9BV2FsReo3bjFArOmq56b9nQaunFJcbl9Kf+vMrcew=; b=mxDDWZC5pQ85391QKVOI6L/APZo86pstKE8SYQtSqPsEY0oH78XR62ugA+TRGvjZE1m4Di K/v1N4ACSf0I3nIdyJl8ItrqbjTC/abIk3iIjoTWRhCGl1KOlPLz6G7G6nwJQRhbX0oI0W wvVuRf/2GHrrX/Es17yZOZ53LFLrmYM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1695192718; h=from:from:reply-to: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=j9BV2FsReo3bjFArOmq56b9nQaunFJcbl9Kf+vMrcew=; b=1pSxjxGHqSr4xqiz8ATQRyZo+WqHFi9jEUhz1YCyVeOQyAaT8/99LU9TySlqb53ysOW9vF Dv8w3toVZG1FRACw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 06FB51333E; Wed, 20 Sep 2023 06:51:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 352+AI6WCmX4HwAAMHmgww (envelope-from ); Wed, 20 Sep 2023 06:51:58 +0000 Date: Wed, 20 Sep 2023 08:51:57 +0200 Message-ID: <874jjpwd4i.wl-tiwai@suse.de> From: Takashi Iwai To: Nick Desaulniers Cc: Richard Fitzgerald , tiwai@suse.com, alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , linux-acpi@vger.kernel.org Subject: Re: [PATCH 2/2] ALSA: hda: cirrus_scodec: Add KUnit test In-Reply-To: References: <20230918095129.440-1-rf@opensource.cirrus.com> <20230918095129.440-3-rf@opensource.cirrus.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org On Tue, 19 Sep 2023 22:44:28 +0200, Nick Desaulniers wrote: > > On Mon, Sep 18, 2023 at 10:51:29AM +0100, Richard Fitzgerald wrote: (snip) > > +static void cirrus_scodec_test_set_gpio_ref_arg(struct software_node_ref_args *arg, > > + int gpio_num) > > +{ > > + struct software_node_ref_args template = > > + SOFTWARE_NODE_REFERENCE(&cirrus_scodec_test_gpio_swnode, gpio_num, 0); > > I'm observing the following error when building with: > > $ make LLVM=1 -j128 allmodconfig sound/pci/hda/cirrus_scodec_test.o > > sound/pci/hda/cirrus_scodec_test.c:151:60: error: initializer element is not a compile-time constant > 151 | SOFTWARE_NODE_REFERENCE(&cirrus_scodec_test_gpio_swnode, gpio_num, 0); > | ^~~~~~~~ > /builds/linux/include/linux/property.h:291:37: note: expanded from macro 'SOFTWARE_NODE_REFERENCE' > 291 | .nargs = ARRAY_SIZE(((u64[]){ 0, ##__VA_ARGS__ })) - 1, \ > | ^~~~~~~~~~~ > /builds/linux/include/linux/kernel.h:57:75: note: expanded from macro 'ARRAY_SIZE' > 57 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) > | ^~~ > /builds/linux/include/linux/compiler.h:228:59: note: expanded from macro '__must_be_array' > 228 | #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) > | ^ > /builds/linux/include/linux/compiler_types.h:366:63: note: expanded from macro '__same_type' > 366 | #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) > | ^ > /builds/linux/include/linux/build_bug.h:16:62: note: expanded from macro 'BUILD_BUG_ON_ZERO' > 16 | #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); }))) > | ^ Hm, this looks like some inconsistent handling of the temporary array passed to ARRAY_SIZE() in the SOFTWARE_NODE_REFERENCE macro. LLVM can't treat it if it contains a variable in the given array, while GCC doesn't care. A hackish workaround would be the patch like below, but it's really ugly. Ideally speaking, it should be fixed in linux/properties.h, but I have no idea how to fix there for LLVM. Adding more relevant people to Cc. thanks, Takashi --- a/sound/pci/hda/cirrus_scodec_test.c +++ b/sound/pci/hda/cirrus_scodec_test.c @@ -148,8 +148,9 @@ static void cirrus_scodec_test_set_gpio_ref_arg(struct software_node_ref_args *a int gpio_num) { struct software_node_ref_args template = - SOFTWARE_NODE_REFERENCE(&cirrus_scodec_test_gpio_swnode, gpio_num, 0); + SOFTWARE_NODE_REFERENCE(&cirrus_scodec_test_gpio_swnode, 0, 0); + template.args[0] = gpio_num; *arg = template; }