From patchwork Tue Mar 11 00:07:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 107618 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 03ED43858405 for ; Tue, 11 Mar 2025 00:08:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 03ED43858405 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=hGWToU/4 X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id 81FC83858D20 for ; Tue, 11 Mar 2025 00:07:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 81FC83858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 81FC83858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741651640; cv=none; b=NEbhfh5CygClPtxDbLJpyJK6/AKYRJTZLRvh1j3HRFeZ7Jp4TGkq4aPSN8sKIXhrndzJU7ESFd3MKBkuqxJSI8yBIeZId4rrEUsZ6UH4XFksc1jk9hmM/Jr486jeH4eMWIndBs/Od6htXStvafuqzWO308DNWXqnPTd5O50pyzM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741651640; c=relaxed/simple; bh=8sS5vvvvJ5ZZ1cOgWZncbazr2k4kOpgV+THGEcPJpSQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=vSo0UcedVkOV6F0YP7AyrAnXht2JBI0kHdCX5MV8ySB65zpV7wYNfUnEhG+c7R0fLn7fGtmz7I3wIJ+Lv6ADC0BA3Uo9goRMikX45Un/9DoqFTQ4OxRby4Ok9HNLemUTNcSwQOUMV+8yqwAdjKk9UA8HPKOytVE/tKKc5ZrY5gI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 81FC83858D20 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-224191d92e4so83862795ad.3 for ; Mon, 10 Mar 2025 17:07:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741651639; x=1742256439; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=EndpixuHc7DL+NHbqMEgQNu+mU/GjbASQ1mUJa4vpTs=; b=hGWToU/43VcE0sZLsoCbx89h4rdBgzeR+Cn984cgu1xR2OnXZn8y3epEbn0Xw0z+wh tGfHJ/UoZREHaIsqfyvdVJviZ+h8FigIGmW19dwLap2PpT8f1TUDbwTAONNTRWLYeny1 3GZD/xhT2lI5y6oVKPN2MAneZiQuk8FdzMzPL86aoh7CJw7sBz38Qn+eUUbsT5r+1owT NIE/nqaM21yTxsA97TpEjKkMXV8iG0u/G5v4rAwWVPk8HEnf+xz2LqW4LS1K0Oq5mqal aJU4xK4+jtmCzY+WxKoqiAQAAmOsT25i6yyGU65SQSbduPqauXFXpUuYnD4XGxz4td3Z rSig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741651639; x=1742256439; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=EndpixuHc7DL+NHbqMEgQNu+mU/GjbASQ1mUJa4vpTs=; b=Ntmi5YFgwdyN3DegWN68j+ZTGhXkTP+/u1coUMoJcOEiLnwUCxo0ZIkK1WxadQdYlo /g1YdvE1Buq+tZlb0+I/kXfxSGVgwWhM837gcD8qHU0TjboGh95xa66BQTECWFqixULF owI7mdD/OafC/a0h0O74Q30gSHls3M5iUrADhEKHPQPa4p/nrCEnc6HglrvXpopGqIsa lPLGajlzJLQb2KIHdAIjthWPNh8/2CirJqC9oXQmXvr3No3qUNm33vecQuI0yg5X8zXt rvPMLAfiKiMm03R1wWtCJh87/OYTnQ3R4WcZgFIt6A38BajT1BgeEhmdjdr6QIH2tzyx 7BhA== X-Gm-Message-State: AOJu0Yw4j0HYMy5Glam9dD85+vnbgVNBNbmmwhOU3k5U02+82kvZtm8P dqm3KKRSKgpAwfqWRKYQ7TX23FnW+nZgGCj22EcsvIZUKuo4TiCpu7TlIg== X-Gm-Gg: ASbGncuLUrRijpzjakFH1VjegeMFTsxiM8oECldY6ywnsNhpidGe9veKWxVzrnjvvXA 2ey3MiIDBzzT438uL3NPaODKS5FGTYmZKKKENm9OfUc9lVQDUM9zfYvxKUEHfHUYHP59wsbjjd8 ryLBL6idRlqSIfoh2GkLYsnjjlYDJ1/+SysyAAPWDjDcb0UuEFf0VGKcUmOxKQkfsPXmGXN7aTI qLoZMMfnU2SqNoD27bDFXg1N8pk3Tu0k8yEuhukeZd+qtGJsZA5IO5k0NLz+7GpKuLRr8YVandF toCSmAbwKPfxnHnBQmy8bOkkh7VGh6/f16y0mUWgwfy3fRpnBENsnvu1vCIT X-Google-Smtp-Source: AGHT+IFQqJssFPjLWifvmbZVgn/KuzJTsqIu30m5c8lmCa80f3lXkX249wFIDoTRwIHNWQKhqrRUYg== X-Received: by 2002:a05:6a00:218f:b0:736:62a8:e52d with SMTP id d2e1a72fcca58-736aaa1b77bmr21621930b3a.12.1741651638920; Mon, 10 Mar 2025 17:07:18 -0700 (PDT) Received: from gnu-cfl-3.localdomain ([172.59.160.65]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-736d75d5eb8sm2968764b3a.142.2025.03.10.17.07.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Mar 2025 17:07:18 -0700 (PDT) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id 2B1E174023C for ; Mon, 10 Mar 2025 17:07:16 -0700 (PDT) From: "H.J. Lu" To: binutils@sourceware.org Subject: [PATCH] Adjust testsuites for -flto and without -g Date: Mon, 10 Mar 2025 17:07:16 -0700 Message-ID: <20250311000716.14184-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3018.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org Adjust testsuites for binutils built with -flto and without -g: 1. Pass -fno-lto to objcopy tests which don't work with LTO. 2. Update gprof testsuite to avoid LTO and compile with -g for line number info checked by tst-gmon-gprof-l.sh. 3. Append $NOLTO_CFLAGS in ctf.exp. 4. For libctf, filter out -flto in CFLAGS for "make check" and also prune lto-wrapper warnings. binutils/ PR binutils/32773 * testsuite/binutils-all/objcopy.exp (no_lto_flags): New. (strip_test): Pass $no_lto_flags to target_compile. (strip_test_with_saving_a_symbol): Likewise. (objcopy_test_without_global_symbol): Likewise. gprof/ PR binutils/32773 PR gprof/32779 * testsuite/Makefile.am (GPROF_FLAGS): Add -g. (COMPILE): Set to "$(CC) $(AM_CFLAGS) $(GPROF_FLAGS)". (LINK) Set to "$(CC) $(AM_CFLAGS) $(GPROF_FLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@". * testsuite/Makefile.in: Regenerated. ld/ PR binutils/32773 * testsuite/ld-ctf/ctf.exp (old_CFLAGS): New. (CFLAGS_FOR_TARGET): Append $NOLTO_CFLAGS. libctf/ PR binutils/32773 * Makefile.am (check-DEJAGNU): Filter out -flto in CFLAGS. * Makefile.in: Regenerated. * testsuite/lib/ctf-lib.exp (prune_warnings_lto): New. (run_lookup_test): Replace prune_warnings with prune_warnings_lto. (run_lookup_test): Likewise. Signed-off-by: H.J. Lu --- binutils/testsuite/binutils-all/objcopy.exp | 14 +++++++++++--- gprof/testsuite/Makefile.am | 10 +++++----- gprof/testsuite/Makefile.in | 12 +++++------- ld/testsuite/ld-ctf/ctf.exp | 5 +++++ libctf/Makefile.am | 3 ++- libctf/Makefile.in | 3 ++- libctf/testsuite/lib/ctf-lib.exp | 14 ++++++++++++-- 7 files changed, 42 insertions(+), 19 deletions(-) diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp index a706efbba18..42a29927a5d 100644 --- a/binutils/testsuite/binutils-all/objcopy.exp +++ b/binutils/testsuite/binutils-all/objcopy.exp @@ -36,6 +36,11 @@ if ![is_remote host] { set copyfile copy } +set no_lto_flags "additional_flags=-fno-lto" +if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog.o object $no_lto_flags] != "" } { + set no_lto_flags "" +} + # Test that objcopy does not modify a file when copying it. # "object" or "executable" values for type are supported. @@ -516,10 +521,11 @@ proc strip_test { } { global srcdir global subdir global READELF + global no_lto_flags set test "strip" - if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog.o object debug] != "" } { + if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog.o object "debug $no_lto_flags"] != "" } { untested $test return } @@ -628,10 +634,11 @@ proc strip_test_with_saving_a_symbol { } { global NMFLAGS global srcdir global subdir + global no_lto_flags set test "strip with saving a symbol" - if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog.o object debug] != "" } { + if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog.o object "debug $no_lto_flags"] != "" } { untested $test return } @@ -1381,10 +1388,11 @@ proc objcopy_test_without_global_symbol { } { global OBJDUMPFLAGS global srcdir global subdir + global no_lto_flags set test "strip without global symbol " - if { [target_compile $srcdir/$subdir/pr19547.c tmpdir/pr19547.o object debug] != "" } { + if { [target_compile $srcdir/$subdir/pr19547.c tmpdir/pr19547.o object "debug $no_lto_flags"] != "" } { untested $test return } diff --git a/gprof/testsuite/Makefile.am b/gprof/testsuite/Makefile.am index c4d6c41fcf4..0c80b12e6e4 100644 --- a/gprof/testsuite/Makefile.am +++ b/gprof/testsuite/Makefile.am @@ -6,12 +6,12 @@ GPROF = ../gprof$(EXEEXT) # NB: -O2 -fno-omit-frame-pointer is needed for expected call graph. See # https://sourceware.org/bugzilla/show_bug.cgi?id=32768 -GPROF_FLAGS = -O2 -fno-omit-frame-pointer -pg +# -g is needed for line number info checked by tst-gmon-gprof-l.sh. See +# https://sourceware.org/bugzilla/show_bug.cgi?id=32779 +GPROF_FLAGS = -O2 -fno-omit-frame-pointer -pg -g -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(GPROF_FLAGS) -LINK = $(CC) $(AM_CFLAGS) $(CFLAGS) $(OPT_NO_PLUGINS) $(GPROF_FLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ +COMPILE = $(CC) $(AM_CFLAGS) $(GPROF_FLAGS) +LINK = $(CC) $(AM_CFLAGS) $(GPROF_FLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ # We will add to these later, for each individual test. Note # that we add each test under check_SCRIPTS; diff --git a/gprof/testsuite/Makefile.in b/gprof/testsuite/Makefile.in index 008f6be879e..2ac5f241012 100644 --- a/gprof/testsuite/Makefile.in +++ b/gprof/testsuite/Makefile.in @@ -496,13 +496,11 @@ GPROF = ../gprof$(EXEEXT) # NB: -O2 -fno-omit-frame-pointer is needed for expected call graph. See # https://sourceware.org/bugzilla/show_bug.cgi?id=32768 -GPROF_FLAGS = -O2 -fno-omit-frame-pointer -pg -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(GPROF_FLAGS) - -LINK = $(CC) $(AM_CFLAGS) $(CFLAGS) $(OPT_NO_PLUGINS) $(GPROF_FLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ - +# -g is needed for line number info checked by tst-gmon-gprof-l.sh. See +# https://sourceware.org/bugzilla/show_bug.cgi?id=32779 +GPROF_FLAGS = -O2 -fno-omit-frame-pointer -pg -g +COMPILE = $(CC) $(AM_CFLAGS) $(GPROF_FLAGS) +LINK = $(CC) $(AM_CFLAGS) $(GPROF_FLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ # We will add to these later, for each individual test. Note # that we add each test under check_SCRIPTS; diff --git a/ld/testsuite/ld-ctf/ctf.exp b/ld/testsuite/ld-ctf/ctf.exp index c314f2995af..08b47d2db18 100644 --- a/ld/testsuite/ld-ctf/ctf.exp +++ b/ld/testsuite/ld-ctf/ctf.exp @@ -33,6 +33,9 @@ if ![check_shared_lib_support] { return 0 } +set old_CFLAGS "$CFLAGS_FOR_TARGET" +append CFLAGS_FOR_TARGET " $NOLTO_CFLAGS" + if {[info exists env(LC_ALL)]} { set old_lc_all $env(LC_ALL) } @@ -55,3 +58,5 @@ if {[info exists old_lc_all]} { } else { unset env(LC_ALL) } + +set CFLAGS_FOR_TARGET "$old_CFLAGS" diff --git a/libctf/Makefile.am b/libctf/Makefile.am index 6e136220497..bf214d8a000 100644 --- a/libctf/Makefile.am +++ b/libctf/Makefile.am @@ -102,11 +102,12 @@ check-DEJAGNU: site.exp development.exp else \ TEST_CROSS=yes; \ fi; \ + TEST_CFLAGS=`echo "$(CFLAGS)" | sed -e "s/-flto[^ \t]*//"`; \ runtest=$(RUNTEST); \ if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ $$runtest --tool $(DEJATOOL) --srcdir $${srcroot}/testsuite \ CC="$(CC)" CC_FOR_TARGET="$(CC_FOR_TARGET)" TEST_CROSS="$${TEST_CROSS}" \ - CFLAGS="$(CFLAGS) -I$(INCDIR) -I$(srcdir) -I$(builddir) -I$(builddir)/../bfd $(ZLIBINC)" \ + CFLAGS="$$TEST_CFLAGS -I$(INCDIR) -I$(srcdir) -I$(builddir) -I$(builddir)/../bfd $(ZLIBINC)" \ LIBS="$(libctf_nobfd_la_LIBADD) $(LIBS)" $(RUNTESTFLAGS); \ else echo "WARNING: could not find \`runtest'" 1>&2; :;\ fi diff --git a/libctf/Makefile.in b/libctf/Makefile.in index 5d9587766dc..e5bb94c681b 100644 --- a/libctf/Makefile.in +++ b/libctf/Makefile.in @@ -1819,11 +1819,12 @@ check-DEJAGNU: site.exp development.exp else \ TEST_CROSS=yes; \ fi; \ + TEST_CFLAGS=`echo "$(CFLAGS)" | sed -e "s/-flto[^ \t]*//"`; \ runtest=$(RUNTEST); \ if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ $$runtest --tool $(DEJATOOL) --srcdir $${srcroot}/testsuite \ CC="$(CC)" CC_FOR_TARGET="$(CC_FOR_TARGET)" TEST_CROSS="$${TEST_CROSS}" \ - CFLAGS="$(CFLAGS) -I$(INCDIR) -I$(srcdir) -I$(builddir) -I$(builddir)/../bfd $(ZLIBINC)" \ + CFLAGS="$$TEST_CFLAGS -I$(INCDIR) -I$(srcdir) -I$(builddir) -I$(builddir)/../bfd $(ZLIBINC)" \ LIBS="$(libctf_nobfd_la_LIBADD) $(LIBS)" $(RUNTESTFLAGS); \ else echo "WARNING: could not find \`runtest'" 1>&2; :;\ fi diff --git a/libctf/testsuite/lib/ctf-lib.exp b/libctf/testsuite/lib/ctf-lib.exp index 64d2a40ad9f..6d3b75e22a2 100644 --- a/libctf/testsuite/lib/ctf-lib.exp +++ b/libctf/testsuite/lib/ctf-lib.exp @@ -54,6 +54,16 @@ proc compile_link_one_host_cc { src output additional_args } { return [run_native_host_cmd "./libtool --quiet --tag=CC --mode=link $CC $CFLAGS $src -o $output $additional_args" ] } +# Also prune lto-wrapper warnings, like +# lto-wrapper: warning: using serial compilation of 16 LTRANS jobs +# lto-wrapper: note: see the '-flto' option documentation for more information +# +proc prune_warnings_lto { msg } { + set msgx "lto-wrapper: (?:warning\:\[^\n\r\]+|note\:\[^\n\r\]+)" + regsub -all "$msgx\[\n\r\]*" $msg {} msg + return [prune_warnings $msg] +} + # run_lookup_test FILE # # Compile with the host compiler and link a .c file into a "lookup" binary, then @@ -208,7 +218,7 @@ proc run_lookup_test { name } { set testname $file4log # Compile and link the lookup program. - set comp_output [prune_warnings [compile_link_one_host_cc $opts(lookup) "tmpdir/lookup" "libctf.la $opts(lookup_link)"]] + set comp_output [prune_warnings_lto [compile_link_one_host_cc $opts(lookup) "tmpdir/lookup" "libctf.la $opts(lookup_link)"]] if { $comp_output != ""} { send_log "compilation of lookup program $opts(lookup) failed with <$comp_output>" @@ -244,7 +254,7 @@ proc run_lookup_test { name } { } } - set comp_output [prune_warnings [run_host_cmd "$CC_FOR_TARGET" "$CFLAGS_FOR_TARGET $lookup_flags [concat $src] -o $lookup_output"]] + set comp_output [prune_warnings_lto [run_host_cmd "$CC_FOR_TARGET" "$CFLAGS_FOR_TARGET $lookup_flags [concat $src] -o $lookup_output"]] if { $comp_output != ""} { send_log "compilation of CTF program [concat $src] failed with <$comp_output>"