From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id zV92CagbB2ZMWRsAWB0awg (envelope-from ) for ; Fri, 29 Mar 2024 15:51:04 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VMHAFPgv; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 1390C1E0C0; Fri, 29 Mar 2024 15:51:04 -0400 (EDT) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C92751E08C for ; Fri, 29 Mar 2024 15:51:01 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 363DD3858404 for ; Fri, 29 Mar 2024 19:51:01 +0000 (GMT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id DC0163858D20 for ; Fri, 29 Mar 2024 19:50:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DC0163858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DC0163858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711741842; cv=none; b=OEeYZ0GE57HV+16s4azC/n+kLJc1X9IRcOe2vjsagTiNkwvW27tZaG02er/cIYQ9oL9i2qXsvsJFo0Cq+Z6QfbEZpRAVzRAo2p0WJPI1x2UtMKsQlV5hhKqnLGHyIltDjF/xz4y+GQjIL/C737otGD3o5445kclnOZ9gNMdc7dI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711741842; c=relaxed/simple; bh=RPv8/pmLE5HZsGZdA+9WQnj5xkFTb4eaCKhNjWAyotI=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=GU/7u1cPYhK1Cj+m9OI6/z39K5AW2YGkiCWeexNdSlIiXeLjFEhJOnFe0TvgaPns7RXqZ+AULz5v7e+ImhR+hrn9oBg/vwfs2nDtIijE33J8+T9v6Jl2DJv9zqbIxgUKe+0iBsGMximqiHaAJsF+CSZCG2C3tkviEgNUB32ecyw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711741840; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6AZG80Zj1tB+DZtiDYBCwnt7dkx5u2G7UoGtKEsbsYw=; b=VMHAFPgv4KxYKt1v8KXjJgPWpMGxckHqcfaLX0gEBQsZZZ68w2Id8rctU/Og1opZfSygip 1iHhQMFWXcDjqg8iL5qe4DIcGkrGrA4iXpVTdjtdWhcm8rDdf8u9rv2f9XYpEsrOKokPV+ eAH81TESyKvemHx49k49E+Y/rgcy0LM= Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-443-8OllJb3_PMWXVIwKebGYVw-1; Fri, 29 Mar 2024 15:50:39 -0400 X-MC-Unique: 8OllJb3_PMWXVIwKebGYVw-1 Received: by mail-pf1-f198.google.com with SMTP id d2e1a72fcca58-6e70785d542so2099810b3a.0 for ; Fri, 29 Mar 2024 12:50:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711741838; x=1712346638; h=content-transfer-encoding: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=6AZG80Zj1tB+DZtiDYBCwnt7dkx5u2G7UoGtKEsbsYw=; b=Z+OMgFCUDhhK+9SwB1OJy7HVr2qaBAQb8YxjugVvTjiVJ4FNbJ/3YlRhQ0Q9tIl/UI rwENlTwm43vHf9SZd/f6NoEb+zNvyq4ZMXZMTnMc1WF/fBRmW7VL7UJzU8DpSQnjYlxx osjLd03fzRdOk/dvbXQVVBCK8KT4zt/NM7PFgObbyTZn38T9h3acm5ay91QFPGKNZJpD X12IO5xhDe20nQkE+9nwC2xs3oQWnj9QIt+bQqjmmu2+IavDlzxoWOLE5j0reLgo3GxA hi3rPse7/G9NmiprkIoT6qoEzIFWRj/6jMcc1OwsmAFJKN4LKRhLDZuHzZqQol7aMy6b hn8w== X-Forwarded-Encrypted: i=1; AJvYcCXT7vGWH05o1Q5HWK2gtCzigzqNAlmIOTp/W7fiPHU1/qGWWSP8/jPmq5TkSTx1rJfi65mVHuKlGzl5f73LHtRyCoLlWCGd+kWg1Q== X-Gm-Message-State: AOJu0Yx8b5XqhAqDP5T2DYzoRrSRyZTYROsVnQvG2X12LTDIQO8CJm3N Zv/leqIOQ3V9KDCaOQ6kT2xLVzqFV/CFQngn3c+Me8551WBaIvhjcbkiBjhF2qvUb53uZ+zJkRq efTQEzG4Ifd9tnvmw3v4MiH2E40vqvp5Q41d8LiTOfMc2GAlJSoq8HXKiFfI= X-Received: by 2002:a05:6a00:2e22:b0:6e6:fb9a:fb45 with SMTP id fc34-20020a056a002e2200b006e6fb9afb45mr4740939pfb.1.1711741837964; Fri, 29 Mar 2024 12:50:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF+ukgBauezKxcVKD+jXRgLxrFWDwE4AUFWIugmSfXP7kGTTRXbKIZjtFIKudMgk7UMFwFCbQ== X-Received: by 2002:a05:6a00:2e22:b0:6e6:fb9a:fb45 with SMTP id fc34-20020a056a002e2200b006e6fb9afb45mr4740920pfb.1.1711741837530; Fri, 29 Mar 2024 12:50:37 -0700 (PDT) Received: from [150.1.200.12] ([71.212.146.31]) by smtp.gmail.com with ESMTPSA id ld11-20020a056a004f8b00b006e6c81b6055sm3367505pfb.6.2024.03.29.12.50.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Mar 2024 12:50:37 -0700 (PDT) Message-ID: Date: Fri, 29 Mar 2024 12:50:36 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/1] gdb, testsuite: Handle unused compiler option fdiagnostics-color=never. To: Abdul Basit Ijaz , gdb-patches@sourceware.org Cc: christina.schimpe@intel.com, felix.willgerodt@intel.com References: <20240322135505.23230-1-abdul.b.ijaz@intel.com> From: Keith Seitz In-Reply-To: <20240322135505.23230-1-abdul.b.ijaz@intel.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Hi, Thanks for the patch! More clang compatibility is always good. On 3/22/24 06:55, Abdul Basit Ijaz wrote: > From: "Ijaz, Abdul B" > > The 'univeral_compile_options' in gdb.exp file only verifies the support > of '-fdiagnostics-color=never' for the "C" source file. So while running > tests with assembly source file (.s), many of them are not able to run > on icx/clang compilers because '-fdiagnostics-color=never' option is not > supported. After this change, this function is split into multiple > functions to check the support for different type of sources individually. I like this approach. > Before this change, in the case of clang and ICX compiler, this error is > shown for assembly source files: > > ''' > icx -fdiagnostics-color=never -Wno-unknown-warning-option -fno-pie -c -O0 -o > amd64-entry-value0.o gdb/testsuite/gdb.arch/amd64-entry-value.s (timeout = 300) > > icx: warning: argument unused during compilation: '-fdiagnostics-color=never' > [-Wunused-command-line-argument] > > gdb compile failed, icx: warning: argument unused during compilation: > '-fdiagnostics-color=never' [-Wunused-command-line-argument] > > UNTESTED: gdb.arch/amd64-entry-value.exp: failed to prepare > ''' > > Similarly this error is shown for the clang compiler: > > ''' > clang -fdiagnostics-color=never -Wno-unknown-warning-option -fno-pie -c -O0 > -o amd64-entry-value0.o gdb/testsuite/gdb.arch/amd64-entry-value.s > > clang: warning: argument unused during compilation: > '-fdiagnostics-color=never' [-Wunused-command-line-argument] > ''' > > 2024-03-22 Ijaz, Abdul B _ Was this (apparently) stray line the start of a ChangeLog entry? [We don't require those anymore.] > --- > gdb/testsuite/lib/gdb.exp | 48 +++++++++++++++++++++++++++++++-------- > 1 file changed, 38 insertions(+), 10 deletions(-) > > diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp > index a0c4855ffc5..4f19162b3ce 100644 > --- a/gdb/testsuite/lib/gdb.exp > +++ b/gdb/testsuite/lib/gdb.exp > @@ -5018,17 +5018,9 @@ proc gdb_wrapper_init { args } { > } > > # Determine options that we always want to pass to the compiler. > -gdb_caching_proc universal_compile_options {} { > - set me "universal_compile_options" > +proc universal_compile_options {src obj} { > set options {} > > - set src [standard_temp_file ccopts.c] > - set obj [standard_temp_file ccopts.o] > - > - gdb_produce_source $src { > - int foo(void) { return 0; } > - } > - > # Try an option for disabling colored diagnostics. Some compilers > # yield colored diagnostics by default (when run from a tty) unless > # such an option is specified. > @@ -5038,6 +5030,23 @@ gdb_caching_proc universal_compile_options {} { > # Seems to have worked; use the option. > lappend options $opt > } > + > + return $options > +} > + > +# Determine options that we always want to pass to the C compiler. > +gdb_caching_proc universal_compile_options_c {} { > + set me "universal_compile_options_c" > + > + set src [standard_temp_file ccopts.c] > + set obj [standard_temp_file ccopts.o] > + > + gdb_produce_source $src { > + int foo(void) { int arr[100]={0}; return 0; } This patch changes this from "int foo(void) { return 0; }". I don't see that documented why that was necessary? > + } > + > + set options [universal_compile_options $src $obj] > + > file delete $src > file delete $obj > > @@ -5045,6 +5054,21 @@ gdb_caching_proc universal_compile_options {} { > return $options > } > > +# Determine options that we always want to pass to the compiler for > +# assembly source files with the extension ".s". > +gdb_caching_proc universal_compile_options_assembly {} { > + set me "universal_compile_options_assembly" > + > + set obj [standard_temp_file csymbol.o] > + set src "$::srcdir/gdb.arch/amd64-entry-value.s" I don't think this is going to work anywhere except on x86. In fact, I tried this on aarch64, and (with below issue fixed), the log contains a bunch of errors (with "-v -v" verbosity to DejaGNU): Executing on host: clang -fdiagnostics-color=never -c -o /root/test-fsf-master/gdb/build-aarch64-redhat-linux-gnu/gdb/testsuite/temp/69953/csymbol.o /root/test-fsf-master/gdb/build-aarch64-redhat-linux-gnu/gdb/testsuite/../../../gdb/testsuite/gdb.arch/amd64-entry-value.s (timeout = 300) builtin_spawn -ignore SIGHUP clang -fdiagnostics-color=never -c -o /root/test-fsf-master/gdb/build-aarch64-redhat-linux-gnu/gdb/testsuite/temp/69953/csymbol.o /root/test-fsf-master/gdb/build-aarch64-redhat-linux-gnu/gdb/testsuite/../../../gdb/testsuite/gdb.arch/amd64-entry-value.s pid is 70084 -70084 clang: warning: argument unused during compilation: '-fdiagnostics-color=never' [-Wunused-command-line-argument] /root/test-fsf-master/gdb/build-aarch64-redhat-linux-gnu/gdb/testsuite/../../../gdb/testsuite/gdb.arch/amd64-entry-value.s:37:16: error: unexpected token in argument list movl $0, _ZL1v(%rip) ^ /root/test-fsf-master/gdb/build-aarch64-redhat-linux-gnu/gdb/testsuite/../../../gdb/testsuite/gdb.arch/amd64-entry-value.s:57:12: error: unexpected token in argument list addsd .LC0(%rip), %xmm0 ^ [8000+ lines deleted] [I note that the output contained a bunch of terminal escape codes (which I've deleted for clarity).] I think something more along the lines of using gdb_produce_source is needed, where we attempt to output really generic asm (if possible?). I wonder if we could do something along the lines of gdb_produce_source $src { .text .globl main .type main, @function main: nop } Warning: untested. This does compile with both gcc and clang on aarch64 and x86_64 (with -z noexecstack), but that's all I've attempted to verify. Failing that, there is a relatively simple fallback for checking for clang specifically: "test_compiler_info {clang-*}". That might be safer than trying to write some generic asm code? > + > + set options [universal_compile_options $src $obj] > + file delete $obj > + > + verbose "$me: returning $options" 2 > + return $options I really appreciate the verbose statements. Helped me understand several of the questions I have! > +} > + > # Compile the code in $code to a file based on $name, using the flags > # $compile_flag as well as debug, nowarning and quiet (unless otherwise > # specified in default_compile_flags). > @@ -5224,7 +5248,11 @@ proc gdb_compile {source dest type options} { > if {[lsearch -exact $options rust] != -1} { > # -fdiagnostics-color is not a rustcc option. > } else { > - set new_options [universal_compile_options] > + if {[string match *.s $source] != 0} { I don't think this is sufficient. A bunch of test cases use ".S", such as every aarch64 test using assembler. Perhaps add "-nocase"? > + set new_options [universal_compile_options_assembly] > + } else { > + set new_options [universal_compile_options_c] > + } > } > > # C/C++ specific settings. Thanks again for the patch! Keith