From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) by sourceware.org (Postfix) with ESMTPS id BB6263858024 for ; Fri, 26 Mar 2021 11:41:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BB6263858024 Received: by mail-qv1-xf31.google.com with SMTP id by2so2712370qvb.11 for ; Fri, 26 Mar 2021 04:41:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=TAB4EW8XWXOOyEbOFlasbr7SEdUPLIiKD7JmjhrRTVs=; b=rjRo+MpLQ2ztuYyikB8/m1CDEmA9j6aoUSS9eVbB0V/CuHpo91+SphLKxLEPiT9TWi v5rk+2XUehPfNcehXvucg5FmOtyN8/ID6LYW3FGGsdzNFSe1nopbzdtvWajn8lGgLGdS jxNUtgQCqVA0D5SMOdXTqS4mXib9O9NLmKh3W2SVgomO+BlcvSk1sOW03RImHQIE27YV MQkuCu4ifRi4gVYAajI1YuKfLZWi0isB6ylER+anX0mmpjYVhmd+4gKCZF9f4AOC00Mr JV/7R0U5EAXeO/FAquj1g0wpjVUQNv1Wa7Yp7FM7oHsWp8vWPVUZ9LKwFQeP2hTuFuPW yxsg== X-Gm-Message-State: AOAM533ffbmZQlopURSUjAXGDVTZB/Q30A22//a8U3yu8VuKPXMXHTE8 +1HwPJRqPW4OK5lw/xwWehWEge8OIWlOeA== X-Google-Smtp-Source: ABdhPJy7BIN2yHG/Sb9l6wkGHsvzE7xc2+59W3JxgJqBk+1SokCakrW7w+u4dmCDHfPCrbeS9mMvcg== X-Received: by 2002:a05:6214:19c4:: with SMTP id j4mr5242991qvc.27.1616758907305; Fri, 26 Mar 2021 04:41:47 -0700 (PDT) Received: from ?IPv6:2804:7f0:4841:2841:9c7b:60f4:124f:3c69? ([2804:7f0:4841:2841:9c7b:60f4:124f:3c69]) by smtp.gmail.com with ESMTPSA id f26sm5548990qtq.29.2021.03.26.04.41.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 26 Mar 2021 04:41:46 -0700 (PDT) Subject: Re: [PATCH] [compile] Don't pass empty options to GCC To: Andrew Burgess Cc: gdb-patches@sourceware.org References: <20210324145959.1322599-1-luis.machado@linaro.org> <20210324185300.GM5520@embecosm.com> From: Luis Machado Message-ID: Date: Fri, 26 Mar 2021 08:41:44 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210324185300.GM5520@embecosm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Mar 2021 11:41:49 -0000 Hi Andrew, On 3/24/21 3:53 PM, Andrew Burgess wrote: > * Luis Machado via Gdb-patches [2021-03-24 11:59:59 -0300]: > >> On aarch64-linux, I noticed the compile command didn't work at all. It >> always gave the following error: >> >> aarch64-linux-gnu-g++: error: : No such file or directory >> >> Turns out we're passing an empty argv entry to GCC (because aarch64 doesn't >> have a -m64 option), and GCC's behavior is to think that is a file it needs >> to open. One can reproduce it like so: >> >> gcc "" "" "" "" >> gcc: error: : No such file or directory >> gcc: error: : No such file or directory >> gcc: error: : No such file or directory >> gcc: error: : No such file or directory >> gcc: fatal error: no input files >> compilation terminated. >> >> The solution is to check for an empty string and skip adding that to argv. >> >> Regression-tested on aarch64-linux/Ubuntu 18.04/20.04. >> >> gdb/ChangeLog: >> >> YYYY-MM-DD Luis Machado >> >> * compile/compile.c (get_args): Don't add empty argv entries. >> --- >> gdb/compile/compile.c | 6 +++++- >> 1 file changed, 5 insertions(+), 1 deletion(-) >> >> diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c >> index d9c99bf4328..32f522a7aba 100644 >> --- a/gdb/compile/compile.c >> +++ b/gdb/compile/compile.c >> @@ -600,8 +600,12 @@ static gdb_argv >> get_args (const compile_instance *compiler, struct gdbarch *gdbarch) >> { >> const char *cs_producer_options; >> + gdb_argv result; >> >> - gdb_argv result (gdbarch_gcc_target_options (gdbarch).c_str ()); >> + /* Make sure we have a non-empty set of options, otherwise GCC will >> + error out trying to look for a filename that is an empty string. */ >> + if (!gdbarch_gcc_target_options (gdbarch).empty ()) >> + result.append (gdb_argv (gdbarch_gcc_target_options (gdbarch).c_str ())); > > It might be nicer to place the return value of > gdbarch_gcc_target_options into a temporary, rather than calling the > function twice. Indeed. I've made that change and will push this later. Thanks! > > Otherwise, looks good to me. > > Thanks, > Andrew > >> >> cs_producer_options = get_selected_pc_producer_options (); >> if (cs_producer_options != NULL) >> -- >> 2.25.1 >>