From patchwork Tue Mar 28 08:23:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 66991 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DE36F3858407 for ; Tue, 28 Mar 2023 08:24:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DE36F3858407 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1679991859; bh=WasjPFyCyno3wsORP3hQbO4Zklsi3VDd5xzFrw7ABx4=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=oSFvE1EcVukhhikhAqSaQkAohfJl2tFZv9OPooQYc0ssbGDhD5ygN8QgF3hB85XYm 9nxVPsFtbgJx0KIJ7489sFZYHAUBBkU52p7wt68Ws9/bQx/B/B2ugQJ6lsQNc8CDDN f/5No4sh0Gl+/jtT5V5mFlZjyHujsA1oA7DTSDdw= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id E69713858296 for ; Tue, 28 Mar 2023 08:23:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E69713858296 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 2C1BC1F8A6 for ; Tue, 28 Mar 2023 08:23:12 +0000 (UTC) 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 1892C1390D for ; Tue, 28 Mar 2023 08:23:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id YNPRBPCjImSAIAAAMHmgww (envelope-from ) for ; Tue, 28 Mar 2023 08:23:12 +0000 To: gdb-patches@sourceware.org Subject: [pushed 2/3] [gdb/testsuite] Add can_compile rust Date: Tue, 28 Mar 2023 10:23:12 +0200 Message-Id: <20230328082313.19529-2-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230328082313.19529-1-tdevries@suse.de> References: <20230328082313.19529-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, 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.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tom de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" If I deinstall the rust compiler, I get: ... gdb compile failed, default_target_compile: Can't find rustc --color never. UNTESTED: gdb.rust/watch.exp: failed to prepare ... Fix this by adding can_compile rust, and using it in allow_rust_tests, such that we have instead: ... UNSUPPORTED: gdb.rust/watch.exp: require failed: allow_rust_tests ... Since the rest of the code in allow_rust_tests is also about availability of the rust compiler, move it to can_compile. Tested on x86_64-linux. --- gdb/testsuite/lib/gdb.exp | 65 +++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 0d064017f09..769bb28c356 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -2470,31 +2470,43 @@ gdb_caching_proc can_compile { lang } { return [gdb_can_simple_compile can_compile_$lang $src executable {d}] } + if { $lang == "rust" } { + if { ![isnative] } { + return 0 + } + + if { [is_remote host] } { + # Proc find_rustc returns "" for remote host. + return 0 + } + + # The rust compiler does not support "-m32", skip. + global board board_info + set board [target_info name] + if {[board_info $board exists multilib_flags]} { + foreach flag [board_info $board multilib_flags] { + if { $flag == "-m32" } { + return 0 + } + } + } + + set src { fn main() {} } + # Drop nowarnings in default_compile_flags, it translates to -w which + # rustc doesn't support. + return [gdb_can_simple_compile can_compile_$lang $src executable \ + {rust} {debug quiet}] + } + error "can_compile doesn't support lang: $lang" } # Return 1 to try Rust tests, 0 to skip them. proc allow_rust_tests {} { - if { ![isnative] } { + if { ![can_compile rust] } { return 0 } - if { [is_remote host] } { - # Proc find_rustc returns "" for remote host. - return 0 - } - - # The rust compiler does not support "-m32", skip. - global board board_info - set board [target_info name] - if {[board_info $board exists multilib_flags]} { - foreach flag [board_info $board multilib_flags] { - if { $flag == "-m32" } { - return 0 - } - } - } - return 1 } @@ -4620,11 +4632,12 @@ gdb_caching_proc universal_compile_options {} { } # Compile the code in $code to a file based on $name, using the flags -# $compile_flag as well as debug, nowarning and quiet. +# $compile_flag as well as debug, nowarning and quiet (unless otherwise +# specified in default_compile_flags). # Return 1 if code can be compiled # Leave the file name of the resulting object in the upvar object. -proc gdb_simple_compile {name code {type object} {compile_flags {}} {object obj}} { +proc gdb_simple_compile {name code {type object} {compile_flags {}} {object obj} {default_compile_flags {}}} { upvar $object obj switch -regexp -- $type { @@ -4658,7 +4671,11 @@ proc gdb_simple_compile {name code {type object} {compile_flags {}} {object obj} } set src [standard_temp_file $name.$ext] set obj [standard_temp_file $name.$postfix] - set compile_flags [concat $compile_flags {debug nowarnings quiet}] + if { $default_compile_flags == "" } { + set compile_flags [concat $compile_flags {debug nowarnings quiet}] + } else { + set compile_flags [concat $compile_flags $default_compile_flags] + } gdb_produce_source $src $code @@ -4675,12 +4692,14 @@ proc gdb_simple_compile {name code {type object} {compile_flags {}} {object obj} } # Compile the code in $code to a file based on $name, using the flags -# $compile_flag as well as debug, nowarning and quiet. +# $compile_flag as well as debug, nowarning and quiet (unless otherwise +# specified in default_compile_flags). # Return 1 if code can be compiled # Delete all created files and objects. -proc gdb_can_simple_compile {name code {type object} {compile_flags ""}} { - set ret [gdb_simple_compile $name $code $type $compile_flags temp_obj] +proc gdb_can_simple_compile {name code {type object} {compile_flags ""} {default_compile_flags ""}} { + set ret [gdb_simple_compile $name $code $type $compile_flags temp_obj \ + $default_compile_flags] file delete $temp_obj return $ret }