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 459DD3858401 for ; Wed, 23 Aug 2023 19:30:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 459DD3858401 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=1692819000; 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=bVn713CPz+vLtm738V5pgxSG/2RjVcwVP9ZSgH5lKkY=; b=VhoH0Nq9HKPK5TIkAr43+oWkdAWntLEL0rGxCaETI3XCLh558bYKdjO3TsNlJkruhFrbpn B30aAsOmemcey6GkkjXxLIb7SPlp/+z0USYJnKOKk7NmnCIC8OdrOAdG1T/lacM4gGpbvD N9oUvXvCJUdtZj7WUYGAziy8kb7e1xE= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-294-mOursqxBNAesBRhaQ5qcpw-1; Wed, 23 Aug 2023 15:29:59 -0400 X-MC-Unique: mOursqxBNAesBRhaQ5qcpw-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-410ad750b7fso13593031cf.1 for ; Wed, 23 Aug 2023 12:29:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692818999; x=1693423799; h=in-reply-to:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=XumadK+Og8bUdaAhhLkJNuPr9+rCUVymjcSgUaMbhCs=; b=AqccFP0kKOEQFk88Yy09U38E8mAOIyj4wG2Zewjy6Fx+Qnq2nZ881QkcVbQab8TXLg mnNL0EV0OiVQWLImd4zsQWau8zyQSB9ZRkft5Lxy9fWgSNmWaOrsXUrfyw+fYh6FFyh6 xLDNrV3FOOBBOkpE34BSVMV1PMMGaWVxNIvaFNHqIOWVv9oVMIVBz9RVmLGRFxTDW2bU B/24gJ2BvmV1M8X6WT+cWQm+srb/iN0tBH0RnBIF+jftbtoErJJdXEfYvc/X1fS0aMmV dlSzZsw9Rv3NUlLHr/yVTZPIBRjlYRhR9AHyCi3bLpKGM6U2ZKMhhbw+5OkMYg/BZ0Yq f/1A== X-Gm-Message-State: AOJu0YyKHLc0QEX1vAMRxSzl3Bz8ca4MPn2Pl2mHRWWEVaIzKBmfavpY r+VpfH7McCRXfy8fmpGESiKWrMMPTizpQF7K07nf2dMfDgnYkeT/QJhglSolPevtMPQXicNWlHY Fv33fLWdcT8NUwdUQDAliKHKW9Q== X-Received: by 2002:a05:622a:1ba2:b0:3fd:e37c:edea with SMTP id bp34-20020a05622a1ba200b003fde37cedeamr16800127qtb.45.1692818998838; Wed, 23 Aug 2023 12:29:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHm17VtPP8XdkcVOGGJPK47BQahZZlhuEWRg2c48YhHAlYx5Yle3HJY1VWRLZ8SKFblX6+//w== X-Received: by 2002:a05:622a:1ba2:b0:3fd:e37c:edea with SMTP id bp34-20020a05622a1ba200b003fde37cedeamr16800119qtb.45.1692818998545; Wed, 23 Aug 2023 12:29:58 -0700 (PDT) Received: from [192.168.1.108] (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id x2-20020ac80182000000b004109928c607sm2277194qtf.43.2023.08.23.12.29.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 23 Aug 2023 12:29:57 -0700 (PDT) Message-ID: <9b95d843-94dd-658d-f420-49ea61365e6c@redhat.com> Date: Wed, 23 Aug 2023 15:29:56 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [PATCH v7 1/4] driver: add a spec function to join arguments To: Ben Boeckel , gcc-patches@gcc.gnu.org, "Joseph S. Myers" Cc: brad.king@kitware.com References: <20230702163211.3396210-1-ben.boeckel@kitware.com> <20230702163211.3396210-2-ben.boeckel@kitware.com> From: Jason Merrill In-Reply-To: <20230702163211.3396210-2-ben.boeckel@kitware.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="------------XKujGITOW3Ads0rujp1Illbd" Content-Language: en-US X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP 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: This is a multi-part message in MIME format. --------------XKujGITOW3Ads0rujp1Illbd Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 7/2/23 12:32, Ben Boeckel wrote: > When passing `-o` flags to other options, the typical `-o foo` spelling > leaves a leading whitespace when replacing elsewhere. This ends up > creating flags spelled as `-some-option-with-arg= foo.ext` which doesn't > parse properly. When attempting to make a spec function to just remove > the leading whitespace, the argument splitting ends up masking the > whitespace. However, the intended extension *also* ends up being its own > argument. Odd. I looked into this to figure out what was going on, and now I understand: when process_brace_body handles e.g. %{o*:-fjoined=%.x%*}, first it replaces $* with the rest of the flag, i.e. "", resulting in -fjoined=, and then adds the argument as a separate argument to the result of substitution. This seems strange, but works fine for the existing uses that build one Separate switch from another. The other oddity you mention comes from > /* End of string. If we are processing a spec function, we need to > end any pending argument. */ > if (processing_spec_function) > end_going_arg (); so that when give_switch calls do_spec_1 twice for the basename and suffix, they end up as separate arguments to the spec function. I don't know the purpose of this code; it doesn't seem to have been necessary for the if-exists spec function that was added in the same patch (r59241). Removing this doesn't seem to break anything for me. The join function works around both of these issues. But I notice that the use of reconcat is a memory leak, and since we have the obstack available I've tweaked the function to use it. I also added some documentation. Joseph, any thoughts on these issues or the workaround? Jason --------------XKujGITOW3Ads0rujp1Illbd Content-Type: text/x-patch; charset=UTF-8; name="0001-driver-add-a-spec-function-to-join-arguments.patch" Content-Disposition: attachment; filename="0001-driver-add-a-spec-function-to-join-arguments.patch" Content-Transfer-Encoding: base64 RnJvbSBjYTdjNzZjNWI0NGU3NmU4NTk2YmY4ZGI2OGQ2MjEwZmQ5ZGRmMTEzIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBCZW4gQm9lY2tlbCA8YmVuLmJvZWNrZWxAa2l0d2FyZS5jb20+ CkRhdGU6IFN1biwgMiBKdWwgMjAyMyAxMjozMjowOCAtMDQwMApTdWJqZWN0OiBbUEFUQ0hdIGRy aXZlcjogYWRkIGEgc3BlYyBmdW5jdGlvbiB0byBqb2luIGFyZ3VtZW50cwpUbzogZ2NjLXBhdGNo ZXNAZ2NjLmdudS5vcmcKCldoZW4gcGFzc2luZyBgLW9gIGZsYWdzIHRvIG90aGVyIG9wdGlvbnMs IHRoZSB0eXBpY2FsIGAtbyBmb29gIHNwZWxsaW5nCmxlYXZlcyBhIGxlYWRpbmcgd2hpdGVzcGFj ZSB3aGVuIHJlcGxhY2luZyBlbHNld2hlcmUuIFRoaXMgZW5kcyB1cApjcmVhdGluZyBmbGFncyBz cGVsbGVkIGFzIGAtc29tZS1vcHRpb24td2l0aC1hcmc9IGZvby5leHRgIHdoaWNoIGRvZXNuJ3QK cGFyc2U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