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 79E85C43334 for ; Wed, 8 Jun 2022 08:16:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229731AbiFHIQ1 convert rfc822-to-8bit (ORCPT ); Wed, 8 Jun 2022 04:16:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230014AbiFHIPH (ORCPT ); Wed, 8 Jun 2022 04:15:07 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 75987353B34 for ; Wed, 8 Jun 2022 00:43:49 -0700 (PDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-40-KvQNsg_GNi2gAmxjzgy3lw-1; Wed, 08 Jun 2022 08:43:47 +0100 X-MC-Unique: KvQNsg_GNi2gAmxjzgy3lw-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.36; Wed, 8 Jun 2022 08:43:45 +0100 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.036; Wed, 8 Jun 2022 08:43:45 +0100 From: David Laight To: 'Kevin Locke' , Masahiro Yamada , "linux-kbuild@vger.kernel.org" CC: "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] kbuild: avoid regex RS for POSIX awk Thread-Topic: [PATCH] kbuild: avoid regex RS for POSIX awk Thread-Index: AQHYehnE8MyxlCD7vU+9QFA+5sTsgK1FIDcA Date: Wed, 8 Jun 2022 07:43:45 +0000 Message-ID: <05f8480125584a9caea029b9c3111ef4@AcuMS.aculab.com> References: <368129160298161a9eb40ad4f489458be6be3b6f.1654569774.git.kevin@kevinlocke.name> In-Reply-To: <368129160298161a9eb40ad4f489458be6be3b6f.1654569774.git.kevin@kevinlocke.name> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kevin Locke > Sent: 07 June 2022 03:43 > > In 22f26f21774f8 awk was added to deduplicate *.mod files. Can't this be done with gmake's $(sort) function? $(sort list) Sorts the words of list in lexical order, removing duplicate words. The output is a list of words separated by single spaces. ... > # To make this rule robust against "Argument list too long" error, > # ensure to add $(obj)/ prefix by a shell command. > -cmd_mod = echo $(call real-search, $*.o, .o, -objs -y -m) | \ > - $(AWK) -v RS='( |\n)' '!x[$$0]++ { print("$(obj)/"$$0) }' > $@ > +cmd_mod = printf '%s\n' $(call real-search, $*.o, .o, -objs -y -m) | \ > + $(AWK) '!x[$$0]++ { print("$(obj)/"$$0) }' > $@ I think the above only works because 'printf' is (usually) a shell builtin - so the kernel's argv[] limit doesn't apply. So the comment isn't really right. But I think: cmd_mod = $(addprefix $(obj)/,$(sort $(call real-search, $*.o, .o, -objs -y -m))) >$@ will have the required effect. Without forking and execing multiple processes. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)