public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] configure: arrange to use appropriate objcopy
@ 2022-06-02 15:32 Jan Beulich
  2022-06-03  6:44 ` Alexandre Oliva
  2022-06-04  8:32 ` Jakub Jelinek
  0 siblings, 2 replies; 6+ messages in thread
From: Jan Beulich @ 2022-06-02 15:32 UTC (permalink / raw)
  To: gcc-patches; +Cc: bonzini, neroden, aoliva, Ralf.Wildenhues

Using the system objcopy is wrong when other configure checks have
probed a different set of binutils (I've noticed the problem on a system
where the base objcopy can't deal with compressed debug sections).
Arrange for the matching one to be picked up, first and foremost if an
"in tree" one is available, by mirroring respective logic already
present for nm.

gcc/

	* Makefile.in (ORIGINAL_OBJCOPY_FOR_TARGET): New.
	* configure.ac: Check for objcopy, producing
	ORIGINAL_OBJCOPY_FOR_TARGET.
	* configure: Update accordingly.
	* exec-tool.in (ORIGINAL_OBJCOPY_FOR_TARGET): New.
	Handle objcopy.

--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -499,6 +499,7 @@ RANLIB_FOR_TARGET := $(shell \
 ORIGINAL_LD_FOR_TARGET = @ORIGINAL_LD_FOR_TARGET@
 ORIGINAL_NM_FOR_TARGET = @ORIGINAL_NM_FOR_TARGET@
 NM_FOR_TARGET = ./nm
+ORIGINAL_OBJCOPY_FOR_TARGET = @ORIGINAL_OBJCOPY_FOR_TARGET@
 STRIP_FOR_TARGET := $(shell \
   if [ -f $(objdir)/../binutils/strip-new ] ; then \
     echo $(objdir)/../binutils/strip-new ; \
--- a/gcc/configure
+++ b/gcc/configure
@@ -733,6 +733,8 @@ gcc_cv_readelf
 gcc_cv_objdump
 ORIGINAL_NM_FOR_TARGET
 gcc_cv_nm
+ORIGINAL_OBJCOPY_FOR_TARGET
+gcc_cv_objcopy
 ORIGINAL_LD_GOLD_FOR_TARGET
 ORIGINAL_LD_BFD_FOR_TARGET
 ORIGINAL_LD_FOR_TARGET
@@ -23436,6 +23438,83 @@ case "$ORIGINAL_NM_FOR_TARGET" in
  ;;
 esac
 
+# Figure out what objcopy we will be using.
+if ${gcc_cv_objcopy+:} false; then :
+
+else
+
+if test -f $gcc_cv_binutils_srcdir/configure.ac \
+     && test -f ../binutils/Makefile \
+     && test x$build = x$host; then
+	gcc_cv_objcopy=../binutils/objcopy$build_exeext
+elif test -x objcopy$build_exeext; then
+	gcc_cv_objcopy=./objcopy$build_exeext
+elif ( set dummy $OBJCOPY_FOR_TARGET; test -x $2 ); then
+        gcc_cv_objcopy="$OBJCOPY_FOR_TARGET"
+else
+        # Extract the first word of "$OBJCOPY_FOR_TARGET", so it can be a program name with args.
+set dummy $OBJCOPY_FOR_TARGET; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_gcc_cv_objcopy+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $gcc_cv_objcopy in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_gcc_cv_objcopy="$gcc_cv_objcopy" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_gcc_cv_objcopy="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+gcc_cv_objcopy=$ac_cv_path_gcc_cv_objcopy
+if test -n "$gcc_cv_objcopy"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_objcopy" >&5
+$as_echo "$gcc_cv_objcopy" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking what objcopy to use" >&5
+$as_echo_n "checking what objcopy to use... " >&6; }
+if test "$gcc_cv_objcopy" = ../binutils/objcopy$build_exeext; then
+	# Single tree build which includes binutils.
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: newly built objcopy" >&5
+$as_echo "newly built objcopy" >&6; }
+	in_tree_objcopy=yes
+else
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_objcopy" >&5
+$as_echo "$gcc_cv_objcopy" >&6; }
+	in_tree_objcopy=no
+fi
+
+ORIGINAL_OBJCOPY_FOR_TARGET=$gcc_cv_objcopy
+
+case "$ORIGINAL_OBJCOPY_FOR_TARGET" in
+  ./objcopy | ./objcopy$build_exeext) ;;
+  *) ac_config_files="$ac_config_files objcopy:exec-tool.in"
+ ;;
+esac
 
 # Figure out what objdump we will be using.
 if ${gcc_cv_objdump+:} false; then :
@@ -33176,6 +33255,7 @@ do
     "as") CONFIG_FILES="$CONFIG_FILES as:exec-tool.in" ;;
     "collect-ld") CONFIG_FILES="$CONFIG_FILES collect-ld:exec-tool.in" ;;
     "nm") CONFIG_FILES="$CONFIG_FILES nm:exec-tool.in" ;;
+    "objcopy") CONFIG_FILES="$CONFIG_FILES objcopy:exec-tool.in" ;;
     "dsymutil") CONFIG_FILES="$CONFIG_FILES dsymutil:exec-tool.in" ;;
     "clearcap.map") CONFIG_LINKS="$CONFIG_LINKS clearcap.map:${srcdir}/config/$clearcap_map" ;;
     "$all_outputs") CONFIG_FILES="$CONFIG_FILES $all_outputs" ;;
@@ -33811,6 +33891,7 @@ $as_echo "$as_me: executing $ac_file com
     "as":F) chmod +x as ;;
     "collect-ld":F) chmod +x collect-ld ;;
     "nm":F) chmod +x nm ;;
+    "objcopy":F) chmod +x objcopy ;;
     "dsymutil":F) chmod +x dsymutil ;;
     "default":C)
 case ${CONFIG_HEADERS} in
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -2815,6 +2815,36 @@ case "$ORIGINAL_NM_FOR_TARGET" in
   *) AC_CONFIG_FILES(nm:exec-tool.in, [chmod +x nm]) ;;
 esac
 
+# Figure out what objcopy we will be using.
+AS_VAR_SET_IF(gcc_cv_objcopy,, [
+if test -f $gcc_cv_binutils_srcdir/configure.ac \
+     && test -f ../binutils/Makefile \
+     && test x$build = x$host; then
+	gcc_cv_objcopy=../binutils/objcopy$build_exeext
+elif test -x objcopy$build_exeext; then
+	gcc_cv_objcopy=./objcopy$build_exeext
+elif ( set dummy $OBJCOPY_FOR_TARGET; test -x $[2] ); then
+        gcc_cv_objcopy="$OBJCOPY_FOR_TARGET"
+else
+        AC_PATH_PROG(gcc_cv_objcopy, $OBJCOPY_FOR_TARGET)
+fi])
+
+AC_MSG_CHECKING(what objcopy to use)
+if test "$gcc_cv_objcopy" = ../binutils/objcopy$build_exeext; then
+	# Single tree build which includes binutils.
+	AC_MSG_RESULT(newly built objcopy)
+	in_tree_objcopy=yes
+else
+	AC_MSG_RESULT($gcc_cv_objcopy)
+	in_tree_objcopy=no
+fi
+
+ORIGINAL_OBJCOPY_FOR_TARGET=$gcc_cv_objcopy
+AC_SUBST(ORIGINAL_OBJCOPY_FOR_TARGET)
+case "$ORIGINAL_OBJCOPY_FOR_TARGET" in
+  ./objcopy | ./objcopy$build_exeext) ;;
+  *) AC_CONFIG_FILES(objcopy:exec-tool.in, [chmod +x objcopy]) ;;
+esac
 
 # Figure out what objdump we will be using.
 AS_VAR_SET_IF(gcc_cv_objdump,, [
--- a/gcc/exec-tool.in
+++ b/gcc/exec-tool.in
@@ -17,7 +17,7 @@
 # along with GCC; see the file COPYING3.  If not see
 # <http://www.gnu.org/licenses/>.
 
-# Invoke as, ld or nm from the build tree.
+# Invoke as, ld, nm, or objcopy from the build tree.
 
 ORIGINAL_AS_FOR_TARGET="@ORIGINAL_AS_FOR_TARGET@"
 ORIGINAL_LD_FOR_TARGET="@ORIGINAL_LD_FOR_TARGET@"
@@ -25,6 +25,7 @@ ORIGINAL_LD_BFD_FOR_TARGET="@ORIGINAL_LD
 ORIGINAL_LD_GOLD_FOR_TARGET="@ORIGINAL_LD_GOLD_FOR_TARGET@"
 ORIGINAL_PLUGIN_LD_FOR_TARGET="@ORIGINAL_PLUGIN_LD_FOR_TARGET@"
 ORIGINAL_NM_FOR_TARGET="@ORIGINAL_NM_FOR_TARGET@"
+ORIGINAL_OBJCOPY_FOR_TARGET="@ORIGINAL_OBJCOPY_FOR_TARGET@"
 ORIGINAL_DSYMUTIL_FOR_TARGET="@ORIGINAL_DSYMUTIL_FOR_TARGET@"
 exeext=@host_exeext@
 fast_install=@enable_fast_install@
@@ -72,6 +73,11 @@ case "$invoked" in
     prog=nm-new$exeext
     dir=binutils
     ;;
+  objcopy)
+    original=$ORIGINAL_OBJCOPY_FOR_TARGET
+    prog=objcopy$exeext
+    dir=binutils
+    ;;
   dsymutil)
     original=$ORIGINAL_DSYMUTIL_FOR_TARGET
     # We do not build this in tree - but still want to be able to execute


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] configure: arrange to use appropriate objcopy
  2022-06-02 15:32 [PATCH] configure: arrange to use appropriate objcopy Jan Beulich
@ 2022-06-03  6:44 ` Alexandre Oliva
  2022-06-04  8:32 ` Jakub Jelinek
  1 sibling, 0 replies; 6+ messages in thread
From: Alexandre Oliva @ 2022-06-03  6:44 UTC (permalink / raw)
  To: Jan Beulich via Gcc-patches; +Cc: Jan Beulich, bonzini, neroden

On Jun  2, 2022, Jan Beulich via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:

> 	* Makefile.in (ORIGINAL_OBJCOPY_FOR_TARGET): New.
> 	* configure.ac: Check for objcopy, producing
> 	ORIGINAL_OBJCOPY_FOR_TARGET.
> 	* configure: Update accordingly.
> 	* exec-tool.in (ORIGINAL_OBJCOPY_FOR_TARGET): New.
> 	Handle objcopy.

Ok, thanks

-- 
Alexandre Oliva, happy hacker                https://FSFLA.org/blogs/lxo/
   Free Software Activist                       GNU Toolchain Engineer
Disinformation flourishes because many people care deeply about injustice
but very few check the facts.  Ask me about <https://stallmansupport.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] configure: arrange to use appropriate objcopy
  2022-06-02 15:32 [PATCH] configure: arrange to use appropriate objcopy Jan Beulich
  2022-06-03  6:44 ` Alexandre Oliva
@ 2022-06-04  8:32 ` Jakub Jelinek
  2022-06-07  6:12   ` Jan Beulich
  1 sibling, 1 reply; 6+ messages in thread
From: Jakub Jelinek @ 2022-06-04  8:32 UTC (permalink / raw)
  To: Jan Beulich; +Cc: gcc-patches, bonzini, aoliva, neroden

On Thu, Jun 02, 2022 at 05:32:10PM +0200, Jan Beulich via Gcc-patches wrote:
> Using the system objcopy is wrong when other configure checks have
> probed a different set of binutils (I've noticed the problem on a system
> where the base objcopy can't deal with compressed debug sections).
> Arrange for the matching one to be picked up, first and foremost if an
> "in tree" one is available, by mirroring respective logic already
> present for nm.
> 
> gcc/
> 
> 	* Makefile.in (ORIGINAL_OBJCOPY_FOR_TARGET): New.
> 	* configure.ac: Check for objcopy, producing
> 	ORIGINAL_OBJCOPY_FOR_TARGET.
> 	* configure: Update accordingly.
> 	* exec-tool.in (ORIGINAL_OBJCOPY_FOR_TARGET): New.
> 	Handle objcopy.

This regressed
Executing on host: /home/jakub/src/gcc/obj44/gcc/xgcc -B/home/jakub/src/gcc/obj44/gcc/     -fdiagnostics-plain-output   -flto -g -gsplit-dwarf   -c -o c_lto_pr83719_0.o /home/jakub/src/gcc/gcc/testsuite/gcc.dg/lto/pr83719_0.c    (timeout = 300)
spawn -ignore SIGHUP /home/jakub/src/gcc/obj44/gcc/xgcc -B/home/jakub/src/gcc/obj44/gcc/ -fdiagnostics-plain-output -flto -g -gsplit-dwarf -c -o c_lto_pr83719_0.o /home/jakub/src/gcc/gcc/testsuite/gcc.dg/lto/pr83719_0.c
cc1: note: '-gsplit-dwarf' is not supported with LTO, disabling
/home/jakub/src/gcc/obj44/gcc/objcopy: line 120: exec: --: invalid option
exec: usage: exec [-cl] [-a name] [command [argument ...]] [redirection ...]
compiler exited with status 1
FAIL: gcc.dg/lto/pr83719 c_lto_pr83719_0.o assemble,  -flto -g -gsplit-dwarf 
for me, both on x86_64-linux and i686-linux.
For some reason, I have
grep OBJCOPY *gcc/Makefile
gcc/Makefile:ORIGINAL_OBJCOPY_FOR_TARGET = 
prev-gcc/Makefile:ORIGINAL_OBJCOPY_FOR_TARGET = 
stage1-gcc/Makefile:ORIGINAL_OBJCOPY_FOR_TARGET = 

	Jakub


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] configure: arrange to use appropriate objcopy
  2022-06-04  8:32 ` Jakub Jelinek
@ 2022-06-07  6:12   ` Jan Beulich
  2022-06-07  7:41     ` Jakub Jelinek
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Beulich @ 2022-06-07  6:12 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches, bonzini, aoliva, neroden

On 04.06.2022 10:32, Jakub Jelinek wrote:
> On Thu, Jun 02, 2022 at 05:32:10PM +0200, Jan Beulich via Gcc-patches wrote:
>> Using the system objcopy is wrong when other configure checks have
>> probed a different set of binutils (I've noticed the problem on a system
>> where the base objcopy can't deal with compressed debug sections).
>> Arrange for the matching one to be picked up, first and foremost if an
>> "in tree" one is available, by mirroring respective logic already
>> present for nm.
>>
>> gcc/
>>
>> 	* Makefile.in (ORIGINAL_OBJCOPY_FOR_TARGET): New.
>> 	* configure.ac: Check for objcopy, producing
>> 	ORIGINAL_OBJCOPY_FOR_TARGET.
>> 	* configure: Update accordingly.
>> 	* exec-tool.in (ORIGINAL_OBJCOPY_FOR_TARGET): New.
>> 	Handle objcopy.
> 
> This regressed
> Executing on host: /home/jakub/src/gcc/obj44/gcc/xgcc -B/home/jakub/src/gcc/obj44/gcc/     -fdiagnostics-plain-output   -flto -g -gsplit-dwarf   -c -o c_lto_pr83719_0.o /home/jakub/src/gcc/gcc/testsuite/gcc.dg/lto/pr83719_0.c    (timeout = 300)
> spawn -ignore SIGHUP /home/jakub/src/gcc/obj44/gcc/xgcc -B/home/jakub/src/gcc/obj44/gcc/ -fdiagnostics-plain-output -flto -g -gsplit-dwarf -c -o c_lto_pr83719_0.o /home/jakub/src/gcc/gcc/testsuite/gcc.dg/lto/pr83719_0.c
> cc1: note: '-gsplit-dwarf' is not supported with LTO, disabling
> /home/jakub/src/gcc/obj44/gcc/objcopy: line 120: exec: --: invalid option
> exec: usage: exec [-cl] [-a name] [command [argument ...]] [redirection ...]
> compiler exited with status 1
> FAIL: gcc.dg/lto/pr83719 c_lto_pr83719_0.o assemble,  -flto -g -gsplit-dwarf 
> for me, both on x86_64-linux and i686-linux.

Hmm, it surely worked for me for both, with and without in-tree binutils
(you don't say which variant you saw the failure with).

> For some reason, I have
> grep OBJCOPY *gcc/Makefile
> gcc/Makefile:ORIGINAL_OBJCOPY_FOR_TARGET = 
> prev-gcc/Makefile:ORIGINAL_OBJCOPY_FOR_TARGET = 
> stage1-gcc/Makefile:ORIGINAL_OBJCOPY_FOR_TARGET = 

What about the corresponding ORIGINAL_NM_FOR_TARGET? And could you provide
one of the config.log instances? 

Jan


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] configure: arrange to use appropriate objcopy
  2022-06-07  6:12   ` Jan Beulich
@ 2022-06-07  7:41     ` Jakub Jelinek
  2022-06-07  8:13       ` Jan Beulich
  0 siblings, 1 reply; 6+ messages in thread
From: Jakub Jelinek @ 2022-06-07  7:41 UTC (permalink / raw)
  To: Jan Beulich; +Cc: bonzini, neroden, gcc-patches, aoliva

On Tue, Jun 07, 2022 at 08:12:26AM +0200, Jan Beulich via Gcc-patches wrote:
> > This regressed
> > Executing on host: /home/jakub/src/gcc/obj44/gcc/xgcc -B/home/jakub/src/gcc/obj44/gcc/     -fdiagnostics-plain-output   -flto -g -gsplit-dwarf   -c -o c_lto_pr83719_0.o /home/jakub/src/gcc/gcc/testsuite/gcc.dg/lto/pr83719_0.c    (timeout = 300)
> > spawn -ignore SIGHUP /home/jakub/src/gcc/obj44/gcc/xgcc -B/home/jakub/src/gcc/obj44/gcc/ -fdiagnostics-plain-output -flto -g -gsplit-dwarf -c -o c_lto_pr83719_0.o /home/jakub/src/gcc/gcc/testsuite/gcc.dg/lto/pr83719_0.c
> > cc1: note: '-gsplit-dwarf' is not supported with LTO, disabling
> > /home/jakub/src/gcc/obj44/gcc/objcopy: line 120: exec: --: invalid option
> > exec: usage: exec [-cl] [-a name] [command [argument ...]] [redirection ...]
> > compiler exited with status 1
> > FAIL: gcc.dg/lto/pr83719 c_lto_pr83719_0.o assemble,  -flto -g -gsplit-dwarf 
> > for me, both on x86_64-linux and i686-linux.
> 
> Hmm, it surely worked for me for both, with and without in-tree binutils
> (you don't say which variant you saw the failure with).

System binutils.
grep ORIGINAL_ gcc/Makefile 
ORIGINAL_AS_FOR_TARGET = /usr/bin/as
ORIGINAL_LD_FOR_TARGET = /usr/bin/ld
ORIGINAL_NM_FOR_TARGET = /usr/bin/nm
ORIGINAL_OBJCOPY_FOR_TARGET = 
ls -l /usr/bin/{as,ld,nm,objcopy}
-rwxr-xr-x. 1 root root 439192 Mar 10 12:51 /usr/bin/as
lrwxrwxrwx. 1 root root     20 May 20 13:28 /usr/bin/ld -> /etc/alternatives/ld
-rwxr-xr-x. 1 root root  47928 Mar 10 12:51 /usr/bin/nm
-rwxr-xr-x. 1 root root 184304 Mar 10 12:51 /usr/bin/objcopy
(but ditto grep ORIGINAL_ stage1-gcc/Makefile
or grep ORIGINAL_ prev-gcc/Makefile).

> > For some reason, I have
> > grep OBJCOPY *gcc/Makefile
> > gcc/Makefile:ORIGINAL_OBJCOPY_FOR_TARGET = 
> > prev-gcc/Makefile:ORIGINAL_OBJCOPY_FOR_TARGET = 
> > stage1-gcc/Makefile:ORIGINAL_OBJCOPY_FOR_TARGET = 
> 
> What about the corresponding ORIGINAL_NM_FOR_TARGET? And could you provide
> one of the config.log instances? 

config.log has:
configure:23317: checking what linker to use
configure:23351: result: /usr/bin/ld
configure:23379: checking for nm
configure:23397: found /usr/bin/nm
configure:23409: result: /usr/bin/nm
configure:23420: checking what nm to use
configure:23428: result: /usr/bin/nm
configure:23498: checking what objcopy to use
configure:23506: result:
configure:23536: checking for objdump
configure:23554: found /usr/bin/objdump
configure:23566: result: /usr/bin/objdump
configure:23577: checking what objdump to use
configure:23587: result: /usr/bin/objdump

It is a bootstrapped compiler:
../configure --enable-languages=default,obj-c++,lto,go,d --enable-checking=yes,rtl,extra --enable-libstdcxx-backtrace=yes && make -j32 bootstrap > LOG 2>&1
on Fedora 36 x86_64-linux (ada left out because it is currently broken).

Comparing the toplevel Makefile, I see some differences:
grep NM_FOR_TARGET Makefile 
	NM_FOR_TARGET="$(NM_FOR_TARGET)"; export NM_FOR_TARGET; \
	NM="$(COMPILER_NM_FOR_TARGET)"; export NM; \
NM_FOR_TARGET=$(NM)
COMPILER_NM_FOR_TARGET=$$r/$(HOST_SUBDIR)/gcc/nm
	"NM_FOR_TARGET=$(NM_FOR_TARGET)" \
	'NM=$(COMPILER_NM_FOR_TARGET)' \
grep OBJCOPY_FOR_TARGET Makefile 
	OBJCOPY_FOR_TARGET="$(OBJCOPY_FOR_TARGET)"; export OBJCOPY_FOR_TARGET; \
	OBJCOPY="$(OBJCOPY_FOR_TARGET)"; export OBJCOPY; \
OBJCOPY_FOR_TARGET=$(OBJCOPY)
	"OBJCOPY_FOR_TARGET=$(OBJCOPY_FOR_TARGET)" \
	'OBJCOPY=$$(OBJCOPY_FOR_TARGET)' \
E.g. the COMPILER_*_FOR_TARGET line is missing completely for OBJCOPY
and the last line is different too.
Also:
grep ^NM[[:space:]]*= Makefile; echo end
NM = nm
end
grep ^OBJCOPY[[:space:]]*= Makefile; echo end
end

Note, I see
S["OBJDUMP"]="objdump"
S["OBJCOPY"]="objcopy"
S["WINDMC"]="windmc"
S["WINDRES"]="windres"
S["STRIP"]="strip"
S["RANLIB"]="ranlib"
S["NM"]="nm"
in toplevel status, it is just that toplevel:
grep ^NM Makefile.tpl 
NM_FOR_BUILD = @NM_FOR_BUILD@
NM = @NM@
NM_FOR_TARGET=@NM_FOR_TARGET@
grep ^OBJCOPY Makefile.tpl 
OBJCOPY_FOR_TARGET=@OBJCOPY_FOR_TARGET@
doesn't have the OBJCOPY = @OBJCOPY@ line, and perhaps the
COMPILER_OBJCOPY_FOR_TARGET stuff.

	Jakub


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] configure: arrange to use appropriate objcopy
  2022-06-07  7:41     ` Jakub Jelinek
@ 2022-06-07  8:13       ` Jan Beulich
  0 siblings, 0 replies; 6+ messages in thread
From: Jan Beulich @ 2022-06-07  8:13 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: bonzini, neroden, gcc-patches, aoliva

On 07.06.2022 09:41, Jakub Jelinek wrote:
> On Tue, Jun 07, 2022 at 08:12:26AM +0200, Jan Beulich via Gcc-patches wrote:
>>> This regressed
>>> Executing on host: /home/jakub/src/gcc/obj44/gcc/xgcc -B/home/jakub/src/gcc/obj44/gcc/     -fdiagnostics-plain-output   -flto -g -gsplit-dwarf   -c -o c_lto_pr83719_0.o /home/jakub/src/gcc/gcc/testsuite/gcc.dg/lto/pr83719_0.c    (timeout = 300)
>>> spawn -ignore SIGHUP /home/jakub/src/gcc/obj44/gcc/xgcc -B/home/jakub/src/gcc/obj44/gcc/ -fdiagnostics-plain-output -flto -g -gsplit-dwarf -c -o c_lto_pr83719_0.o /home/jakub/src/gcc/gcc/testsuite/gcc.dg/lto/pr83719_0.c
>>> cc1: note: '-gsplit-dwarf' is not supported with LTO, disabling
>>> /home/jakub/src/gcc/obj44/gcc/objcopy: line 120: exec: --: invalid option
>>> exec: usage: exec [-cl] [-a name] [command [argument ...]] [redirection ...]
>>> compiler exited with status 1
>>> FAIL: gcc.dg/lto/pr83719 c_lto_pr83719_0.o assemble,  -flto -g -gsplit-dwarf 
>>> for me, both on x86_64-linux and i686-linux.
>>
>> Hmm, it surely worked for me for both, with and without in-tree binutils
>> (you don't say which variant you saw the failure with).
> 
> System binutils.
> grep ORIGINAL_ gcc/Makefile 
> ORIGINAL_AS_FOR_TARGET = /usr/bin/as
> ORIGINAL_LD_FOR_TARGET = /usr/bin/ld
> ORIGINAL_NM_FOR_TARGET = /usr/bin/nm
> ORIGINAL_OBJCOPY_FOR_TARGET = 
> ls -l /usr/bin/{as,ld,nm,objcopy}
> -rwxr-xr-x. 1 root root 439192 Mar 10 12:51 /usr/bin/as
> lrwxrwxrwx. 1 root root     20 May 20 13:28 /usr/bin/ld -> /etc/alternatives/ld
> -rwxr-xr-x. 1 root root  47928 Mar 10 12:51 /usr/bin/nm
> -rwxr-xr-x. 1 root root 184304 Mar 10 12:51 /usr/bin/objcopy
> (but ditto grep ORIGINAL_ stage1-gcc/Makefile
> or grep ORIGINAL_ prev-gcc/Makefile).
> 
>>> For some reason, I have
>>> grep OBJCOPY *gcc/Makefile
>>> gcc/Makefile:ORIGINAL_OBJCOPY_FOR_TARGET = 
>>> prev-gcc/Makefile:ORIGINAL_OBJCOPY_FOR_TARGET = 
>>> stage1-gcc/Makefile:ORIGINAL_OBJCOPY_FOR_TARGET = 
>>
>> What about the corresponding ORIGINAL_NM_FOR_TARGET? And could you provide
>> one of the config.log instances? 
> 
> config.log has:
> configure:23317: checking what linker to use
> configure:23351: result: /usr/bin/ld
> configure:23379: checking for nm
> configure:23397: found /usr/bin/nm
> configure:23409: result: /usr/bin/nm
> configure:23420: checking what nm to use
> configure:23428: result: /usr/bin/nm
> configure:23498: checking what objcopy to use
> configure:23506: result:
> configure:23536: checking for objdump
> configure:23554: found /usr/bin/objdump
> configure:23566: result: /usr/bin/objdump
> configure:23577: checking what objdump to use
> configure:23587: result: /usr/bin/objdump
> 
> It is a bootstrapped compiler:
> ../configure --enable-languages=default,obj-c++,lto,go,d --enable-checking=yes,rtl,extra --enable-libstdcxx-backtrace=yes && make -j32 bootstrap > LOG 2>&1
> on Fedora 36 x86_64-linux (ada left out because it is currently broken).
> 
> Comparing the toplevel Makefile, I see some differences:
> grep NM_FOR_TARGET Makefile 
> 	NM_FOR_TARGET="$(NM_FOR_TARGET)"; export NM_FOR_TARGET; \
> 	NM="$(COMPILER_NM_FOR_TARGET)"; export NM; \
> NM_FOR_TARGET=$(NM)
> COMPILER_NM_FOR_TARGET=$$r/$(HOST_SUBDIR)/gcc/nm
> 	"NM_FOR_TARGET=$(NM_FOR_TARGET)" \
> 	'NM=$(COMPILER_NM_FOR_TARGET)' \
> grep OBJCOPY_FOR_TARGET Makefile 
> 	OBJCOPY_FOR_TARGET="$(OBJCOPY_FOR_TARGET)"; export OBJCOPY_FOR_TARGET; \
> 	OBJCOPY="$(OBJCOPY_FOR_TARGET)"; export OBJCOPY; \
> OBJCOPY_FOR_TARGET=$(OBJCOPY)
> 	"OBJCOPY_FOR_TARGET=$(OBJCOPY_FOR_TARGET)" \
> 	'OBJCOPY=$$(OBJCOPY_FOR_TARGET)' \
> E.g. the COMPILER_*_FOR_TARGET line is missing completely for OBJCOPY
> and the last line is different too.
> Also:
> grep ^NM[[:space:]]*= Makefile; echo end
> NM = nm
> end
> grep ^OBJCOPY[[:space:]]*= Makefile; echo end
> end
> 
> Note, I see
> S["OBJDUMP"]="objdump"
> S["OBJCOPY"]="objcopy"
> S["WINDMC"]="windmc"
> S["WINDRES"]="windres"
> S["STRIP"]="strip"
> S["RANLIB"]="ranlib"
> S["NM"]="nm"
> in toplevel status, it is just that toplevel:
> grep ^NM Makefile.tpl 
> NM_FOR_BUILD = @NM_FOR_BUILD@
> NM = @NM@
> NM_FOR_TARGET=@NM_FOR_TARGET@
> grep ^OBJCOPY Makefile.tpl 
> OBJCOPY_FOR_TARGET=@OBJCOPY_FOR_TARGET@
> doesn't have the OBJCOPY = @OBJCOPY@ line, and perhaps the
> COMPILER_OBJCOPY_FOR_TARGET stuff.

Let me revert the change - I've just realized that I only thought I would
have tested this with system binutils as well. I'm sorry for the breakage.

Jan


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-06-07  8:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-02 15:32 [PATCH] configure: arrange to use appropriate objcopy Jan Beulich
2022-06-03  6:44 ` Alexandre Oliva
2022-06-04  8:32 ` Jakub Jelinek
2022-06-07  6:12   ` Jan Beulich
2022-06-07  7:41     ` Jakub Jelinek
2022-06-07  8:13       ` Jan Beulich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).