public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Don't compile some opcodes files when bfd is 32-bit only
@ 2021-11-12  8:37 Alan Modra
  2021-11-26 18:01 ` Mike Frysinger
  0 siblings, 1 reply; 9+ messages in thread
From: Alan Modra @ 2021-11-12  8:37 UTC (permalink / raw)
  To: binutils

	* Makefile.am (TARGET_LIBOPCODES_CFILES): Split into..
	(TARGET64_LIBOPCODES_CFILES): ..this and..
	(TARGET32_LIBOPCODES_CFILES): ..this.
	(ALL_MACHINES): Likewise split to
	(ALL64_MACHINES, ALL32_MACHINES): ..this.
	* disassemble.c: Define some ARCH_* when ARCH_all only if BFD64.
	* configure.ac (BFD_MACHINES): Defined depending on BFD_ARCH_SIZE.
	* Makefile.in: Regenerate.
	* configure: Regenerate.

diff --git a/opcodes/Makefile.am b/opcodes/Makefile.am
index e07e360d842..ab7072c0249 100644
--- a/opcodes/Makefile.am
+++ b/opcodes/Makefile.am
@@ -88,7 +88,7 @@ HFILES = \
 
 # C source files that correspond to .o's ending up in libopcodes
 # for all machines.
-TARGET_LIBOPCODES_CFILES = \
+TARGET64_LIBOPCODES_CFILES = \
 	aarch64-asm.c \
 	aarch64-asm-2.c \
 	aarch64-dis.c \
@@ -97,6 +97,27 @@ TARGET_LIBOPCODES_CFILES = \
 	aarch64-opc-2.c \
 	alpha-dis.c \
 	alpha-opc.c \
+	bpf-asm.c \
+	bpf-desc.c \
+	bpf-dis.c \
+	bpf-ibld.c \
+	bpf-opc.c \
+	ia64-dis.c \
+	ia64-opc.c \
+	loongarch-opc.c \
+	loongarch-dis.c \
+	loongarch-coder.c \
+	mips-dis.c \
+	mips-opc.c \
+	mips16-opc.c \
+	micromips-opc.c \
+	mmix-dis.c \
+	mmix-opc.c \
+	nfp-dis.c \
+	riscv-dis.c \
+	riscv-opc.c
+
+TARGET32_LIBOPCODES_CFILES = \
 	arc-dis.c \
 	arc-ext.c \
 	arc-opc.c \
@@ -120,11 +141,6 @@ TARGET_LIBOPCODES_CFILES = \
 	d30v-dis.c \
 	d30v-opc.c \
 	dlx-dis.c \
-	bpf-asm.c \
-	bpf-desc.c \
-	bpf-dis.c \
-	bpf-ibld.c \
-	bpf-opc.c \
 	epiphany-asm.c \
 	epiphany-desc.c \
 	epiphany-dis.c \
@@ -146,8 +162,6 @@ TARGET_LIBOPCODES_CFILES = \
 	hppa-dis.c \
 	i386-dis.c \
 	i386-opc.c \
-	ia64-dis.c \
-	ia64-opc.c \
 	ip2k-asm.c \
 	ip2k-desc.c \
 	ip2k-dis.c \
@@ -164,9 +178,6 @@ TARGET_LIBOPCODES_CFILES = \
 	lm32-ibld.c \
 	lm32-opc.c \
 	lm32-opinst.c \
-	loongarch-opc.c \
-	loongarch-dis.c \
-	loongarch-coder.c \
 	m10200-dis.c \
 	m10200-opc.c \
 	m10300-dis.c \
@@ -196,12 +207,6 @@ TARGET_LIBOPCODES_CFILES = \
 	mep-opc.c \
 	metag-dis.c \
 	microblaze-dis.c \
-	micromips-opc.c \
-	mips-dis.c \
-	mips-opc.c \
-	mips16-opc.c \
-	mmix-dis.c \
-	mmix-opc.c \
 	moxie-dis.c \
 	moxie-opc.c \
 	msp430-decode.c \
@@ -213,7 +218,6 @@ TARGET_LIBOPCODES_CFILES = \
 	mt-opc.c \
 	nds32-asm.c \
 	nds32-dis.c \
-	nfp-dis.c \
 	nios2-dis.c \
 	nios2-opc.c \
 	ns32k-dis.c \
@@ -230,8 +234,6 @@ TARGET_LIBOPCODES_CFILES = \
 	ppc-opc.c \
 	pru-dis.c \
 	pru-opc.c \
-	riscv-dis.c \
-	riscv-opc.c \
 	rl78-decode.c \
 	rl78-dis.c \
 	rx-decode.c \
@@ -278,7 +280,8 @@ TARGET_LIBOPCODES_CFILES = \
 
 # C source files that correspond to .o's ending up in libopcodes.
 LIBOPCODES_CFILES = \
-	$(TARGET_LIBOPCODES_CFILES) \
+	$(TARGET32_LIBOPCODES_CFILES) \
+	$(TARGET64_LIBOPCODES_CFILES) \
 	dis-buf.c \
 	dis-init.c \
 	disassemble.c
@@ -299,7 +302,8 @@ CFILES = \
 	s390-mkopc.c \
 	z8kgen.c
 
-ALL_MACHINES = $(TARGET_LIBOPCODES_CFILES:.c=.lo)
+ALL32_MACHINES = $(TARGET32_LIBOPCODES_CFILES:.c=.lo)
+ALL64_MACHINES = $(TARGET64_LIBOPCODES_CFILES:.c=.lo)
 
 OFILES = @BFD_MACHINES@
 
diff --git a/opcodes/Makefile.in b/opcodes/Makefile.in
index 942737106ab..59ed0d2c81f 100644
--- a/opcodes/Makefile.in
+++ b/opcodes/Makefile.in
@@ -479,7 +479,7 @@ HFILES = \
 
 # C source files that correspond to .o's ending up in libopcodes
 # for all machines.
-TARGET_LIBOPCODES_CFILES = \
+TARGET64_LIBOPCODES_CFILES = \
 	aarch64-asm.c \
 	aarch64-asm-2.c \
 	aarch64-dis.c \
@@ -488,6 +488,27 @@ TARGET_LIBOPCODES_CFILES = \
 	aarch64-opc-2.c \
 	alpha-dis.c \
 	alpha-opc.c \
+	bpf-asm.c \
+	bpf-desc.c \
+	bpf-dis.c \
+	bpf-ibld.c \
+	bpf-opc.c \
+	ia64-dis.c \
+	ia64-opc.c \
+	loongarch-opc.c \
+	loongarch-dis.c \
+	loongarch-coder.c \
+	mips-dis.c \
+	mips-opc.c \
+	mips16-opc.c \
+	micromips-opc.c \
+	mmix-dis.c \
+	mmix-opc.c \
+	nfp-dis.c \
+	riscv-dis.c \
+	riscv-opc.c
+
+TARGET32_LIBOPCODES_CFILES = \
 	arc-dis.c \
 	arc-ext.c \
 	arc-opc.c \
@@ -511,11 +532,6 @@ TARGET_LIBOPCODES_CFILES = \
 	d30v-dis.c \
 	d30v-opc.c \
 	dlx-dis.c \
-	bpf-asm.c \
-	bpf-desc.c \
-	bpf-dis.c \
-	bpf-ibld.c \
-	bpf-opc.c \
 	epiphany-asm.c \
 	epiphany-desc.c \
 	epiphany-dis.c \
@@ -537,8 +553,6 @@ TARGET_LIBOPCODES_CFILES = \
 	hppa-dis.c \
 	i386-dis.c \
 	i386-opc.c \
-	ia64-dis.c \
-	ia64-opc.c \
 	ip2k-asm.c \
 	ip2k-desc.c \
 	ip2k-dis.c \
@@ -555,9 +569,6 @@ TARGET_LIBOPCODES_CFILES = \
 	lm32-ibld.c \
 	lm32-opc.c \
 	lm32-opinst.c \
-	loongarch-opc.c \
-	loongarch-dis.c \
-	loongarch-coder.c \
 	m10200-dis.c \
 	m10200-opc.c \
 	m10300-dis.c \
@@ -587,12 +598,6 @@ TARGET_LIBOPCODES_CFILES = \
 	mep-opc.c \
 	metag-dis.c \
 	microblaze-dis.c \
-	micromips-opc.c \
-	mips-dis.c \
-	mips-opc.c \
-	mips16-opc.c \
-	mmix-dis.c \
-	mmix-opc.c \
 	moxie-dis.c \
 	moxie-opc.c \
 	msp430-decode.c \
@@ -604,7 +609,6 @@ TARGET_LIBOPCODES_CFILES = \
 	mt-opc.c \
 	nds32-asm.c \
 	nds32-dis.c \
-	nfp-dis.c \
 	nios2-dis.c \
 	nios2-opc.c \
 	ns32k-dis.c \
@@ -621,8 +625,6 @@ TARGET_LIBOPCODES_CFILES = \
 	ppc-opc.c \
 	pru-dis.c \
 	pru-opc.c \
-	riscv-dis.c \
-	riscv-opc.c \
 	rl78-decode.c \
 	rl78-dis.c \
 	rx-decode.c \
@@ -670,7 +672,8 @@ TARGET_LIBOPCODES_CFILES = \
 
 # C source files that correspond to .o's ending up in libopcodes.
 LIBOPCODES_CFILES = \
-	$(TARGET_LIBOPCODES_CFILES) \
+	$(TARGET32_LIBOPCODES_CFILES) \
+	$(TARGET64_LIBOPCODES_CFILES) \
 	dis-buf.c \
 	dis-init.c \
 	disassemble.c
@@ -692,7 +695,8 @@ CFILES = \
 	s390-mkopc.c \
 	z8kgen.c
 
-ALL_MACHINES = $(TARGET_LIBOPCODES_CFILES:.c=.lo)
+ALL32_MACHINES = $(TARGET32_LIBOPCODES_CFILES:.c=.lo)
+ALL64_MACHINES = $(TARGET64_LIBOPCODES_CFILES:.c=.lo)
 OFILES = @BFD_MACHINES@
 
 # development.sh is used to determine -Werror default.
diff --git a/opcodes/configure b/opcodes/configure
index acfbdd6ec6f..6672c368082 100755
--- a/opcodes/configure
+++ b/opcodes/configure
@@ -12319,7 +12319,11 @@ if test x${all_targets} = xfalse ; then
 
 else	# all_targets is true
     archdefs=-DARCH_all
-    BFD_MACHINES='$(ALL_MACHINES)'
+    if grep '#define BFD_ARCH_SIZE 64' ../bfd/bfd-in3.h > /dev/null; then
+	BFD_MACHINES='$(ALL32_MACHINES) $(ALL64_MACHINES)'
+    else
+	BFD_MACHINES='$(ALL32_MACHINES)'
+    fi
 fi
 
 
diff --git a/opcodes/configure.ac b/opcodes/configure.ac
index 757ce10fbe2..03433157c08 100644
--- a/opcodes/configure.ac
+++ b/opcodes/configure.ac
@@ -379,7 +379,11 @@ if test x${all_targets} = xfalse ; then
 
 else	# all_targets is true
     archdefs=-DARCH_all
-    BFD_MACHINES='$(ALL_MACHINES)'
+    if grep '#define BFD_ARCH_SIZE 64' ../bfd/bfd-in3.h > /dev/null; then
+	BFD_MACHINES='$(ALL32_MACHINES) $(ALL64_MACHINES)'
+    else
+	BFD_MACHINES='$(ALL32_MACHINES)'
+    fi
 fi
 
 AC_SUBST(archdefs)
diff --git a/opcodes/disassemble.c b/opcodes/disassemble.c
index 61e666c1822..21d894f57d4 100644
--- a/opcodes/disassemble.c
+++ b/opcodes/disassemble.c
@@ -24,20 +24,30 @@
 #include "opintl.h"
 
 #ifdef ARCH_all
+#ifdef BFD64
 #define ARCH_aarch64
 #define ARCH_alpha
+#define ARCH_bpf
+#define ARCH_cris
+#define ARCH_ia64
+#define ARCH_loongarch
+#define ARCH_mips
+#define ARCH_mmix
+#define ARCH_nfp
+#define ARCH_riscv
+#define ARCH_score
+#define ARCH_tilegx
+#endif
 #define ARCH_arc
 #define ARCH_arm
 #define ARCH_avr
 #define ARCH_bfin
 #define ARCH_cr16
-#define ARCH_cris
 #define ARCH_crx
 #define ARCH_csky
 #define ARCH_d10v
 #define ARCH_d30v
 #define ARCH_dlx
-#define ARCH_bpf
 #define ARCH_epiphany
 #define ARCH_fr30
 #define ARCH_frv
@@ -45,11 +55,9 @@
 #define ARCH_h8300
 #define ARCH_hppa
 #define ARCH_i386
-#define ARCH_ia64
 #define ARCH_ip2k
 #define ARCH_iq2000
 #define ARCH_lm32
-#define ARCH_loongarch
 #define ARCH_m32c
 #define ARCH_m32r
 #define ARCH_m68hc11
@@ -59,15 +67,12 @@
 #define ARCH_mep
 #define ARCH_metag
 #define ARCH_microblaze
-#define ARCH_mips
-#define ARCH_mmix
 #define ARCH_mn10200
 #define ARCH_mn10300
 #define ARCH_moxie
 #define ARCH_mt
 #define ARCH_msp430
 #define ARCH_nds32
-#define ARCH_nfp
 #define ARCH_nios2
 #define ARCH_ns32k
 #define ARCH_or1k
@@ -75,13 +80,11 @@
 #define ARCH_pj
 #define ARCH_powerpc
 #define ARCH_pru
-#define ARCH_riscv
 #define ARCH_rs6000
 #define ARCH_rl78
 #define ARCH_rx
 #define ARCH_s12z
 #define ARCH_s390
-#define ARCH_score
 #define ARCH_sh
 #define ARCH_sparc
 #define ARCH_spu
@@ -89,7 +92,6 @@
 #define ARCH_tic4x
 #define ARCH_tic54x
 #define ARCH_tic6x
-#define ARCH_tilegx
 #define ARCH_tilepro
 #define ARCH_v850
 #define ARCH_vax

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: Don't compile some opcodes files when bfd is 32-bit only
  2021-11-12  8:37 Don't compile some opcodes files when bfd is 32-bit only Alan Modra
@ 2021-11-26 18:01 ` Mike Frysinger
  2021-12-01 23:01   ` Alan Modra
  0 siblings, 1 reply; 9+ messages in thread
From: Mike Frysinger @ 2021-11-26 18:01 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils

[-- Attachment #1: Type: text/plain, Size: 1923 bytes --]

On 12 Nov 2021 19:07, Alan Modra via Binutils wrote:
> 	* Makefile.am (TARGET_LIBOPCODES_CFILES): Split into..
> 	(TARGET64_LIBOPCODES_CFILES): ..this and..
> 	(TARGET32_LIBOPCODES_CFILES): ..this.
> 	(ALL_MACHINES): Likewise split to
> 	(ALL64_MACHINES, ALL32_MACHINES): ..this.
> 	* disassemble.c: Define some ARCH_* when ARCH_all only if BFD64.
> 	* configure.ac (BFD_MACHINES): Defined depending on BFD_ARCH_SIZE.
> 	* Makefile.in: Regenerate.
> 	* configure: Regenerate.
> 
> --- a/opcodes/Makefile.am
> +++ b/opcodes/Makefile.am
> @@ -88,7 +88,7 @@ HFILES = \
>  
>  # C source files that correspond to .o's ending up in libopcodes
>  # for all machines.
> -TARGET_LIBOPCODES_CFILES = \
> +TARGET64_LIBOPCODES_CFILES = \
>  	aarch64-asm.c \
>  	aarch64-asm-2.c \
>  	aarch64-dis.c \
> @@ -97,6 +97,27 @@ TARGET_LIBOPCODES_CFILES = \
>  	aarch64-opc-2.c \
>  	alpha-dis.c \
>  	alpha-opc.c \
> +	bpf-asm.c \
> +	bpf-desc.c \
> +	bpf-dis.c \
> +	bpf-ibld.c \
> +	bpf-opc.c \
> +	ia64-dis.c \
> +	ia64-opc.c \
> +	loongarch-opc.c \
> +	loongarch-dis.c \
> +	loongarch-coder.c \
> +	mips-dis.c \
> +	mips-opc.c \
> +	mips16-opc.c \
> +	micromips-opc.c \
> +	mmix-dis.c \
> +	mmix-opc.c \
> +	nfp-dis.c \
> +	riscv-dis.c \
> +	riscv-opc.c

riscv supports 32-bit & 64-bit.  this move is breaking 32-bit builds of
32-bit riscv sims.

testing with --host=i686-linux-gnu --enable-targets=all --enable-sim:
make[3]: Entering directory '.../sim/riscv'
  CCLD   run
...sim/riscv/sim-main.c:71: error: undefined reference to 'riscv_gpr_names_abi'
...sim/riscv/sim-main.c:153: error: undefined reference to 'riscv_gpr_names_abi'
...sim/riscv/sim-main.c:652: error: undefined reference to 'riscv_gpr_names_abi'
...sim/riscv/sim-main.c:800: error: undefined reference to 'riscv_gpr_names_abi'
...sim/riscv/sim-main.c:1108: error: undefined reference to 'riscv_opcodes'
-mike

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: Don't compile some opcodes files when bfd is 32-bit only
  2021-11-26 18:01 ` Mike Frysinger
@ 2021-12-01 23:01   ` Alan Modra
  2021-12-02  5:19     ` Mike Frysinger
  0 siblings, 1 reply; 9+ messages in thread
From: Alan Modra @ 2021-12-01 23:01 UTC (permalink / raw)
  To: binutils

On Fri, Nov 26, 2021 at 01:01:12PM -0500, Mike Frysinger wrote:
> On 12 Nov 2021 19:07, Alan Modra via Binutils wrote:
> > 	* Makefile.am (TARGET_LIBOPCODES_CFILES): Split into..
> > 	(TARGET64_LIBOPCODES_CFILES): ..this and..
> > 	(TARGET32_LIBOPCODES_CFILES): ..this.
> > 	(ALL_MACHINES): Likewise split to
> > 	(ALL64_MACHINES, ALL32_MACHINES): ..this.
> > 	* disassemble.c: Define some ARCH_* when ARCH_all only if BFD64.
> > 	* configure.ac (BFD_MACHINES): Defined depending on BFD_ARCH_SIZE.
> > 	* Makefile.in: Regenerate.
> > 	* configure: Regenerate.

> riscv supports 32-bit & 64-bit.  this move is breaking 32-bit builds of
> 32-bit riscv sims.
> 
> testing with --host=i686-linux-gnu --enable-targets=all --enable-sim:
> make[3]: Entering directory '.../sim/riscv'
>   CCLD   run
> ...sim/riscv/sim-main.c:71: error: undefined reference to 'riscv_gpr_names_abi'
> ...sim/riscv/sim-main.c:153: error: undefined reference to 'riscv_gpr_names_abi'
> ...sim/riscv/sim-main.c:652: error: undefined reference to 'riscv_gpr_names_abi'
> ...sim/riscv/sim-main.c:800: error: undefined reference to 'riscv_gpr_names_abi'
> ...sim/riscv/sim-main.c:1108: error: undefined reference to 'riscv_opcodes'
> -mike

Yes, I moved bpf back into TARGET32_LIBOPCODES_CFILES for a similar
problem with the bpf sim.  That might have been a mistake.  For the
binutils, bpf opcode support is useless without bpf bfd support,
because a 32-bit bfd can't load an ELF64 object file.  Not even as the
generic elf64-little or elf64-big targets.

I think it is also useless for sim.  On my 32-bit sim build:
$ ~/build/gas/bpf-none/gas/as-new -I ~/src/binutils-gdb/sim/testsuite/bpf ~/src/binutils-gdb/sim/testsuite/bpf/alu.s -o alu.o
$ ~/build/gas/bpf-none/ld/ld-new -Ttext=0 -o alu alu.o
$ ./run --memory-size=4Mb alu
run: "alu" is not an object file: file format not recognized

Doing the same on a 64-bit sim build results in:
$ ./run --memory-size=4Mb alu
pass
exit 0 (0x0)

Mike, I question your "working" statement here:
https://sourceware.org/pipermail/binutils/2021-November/118569.html

Obviously, moving riscv back into TARGET32_LIBOPCODES_CFILES won't fix
anything, since riscv was the reason for removing objects from
libopcodes.

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: Don't compile some opcodes files when bfd is 32-bit only
  2021-12-01 23:01   ` Alan Modra
@ 2021-12-02  5:19     ` Mike Frysinger
  2021-12-02  8:56       ` Alan Modra
  0 siblings, 1 reply; 9+ messages in thread
From: Mike Frysinger @ 2021-12-02  5:19 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils

[-- Attachment #1: Type: text/plain, Size: 2999 bytes --]

On 02 Dec 2021 09:31, Alan Modra wrote:
> On Fri, Nov 26, 2021 at 01:01:12PM -0500, Mike Frysinger wrote:
> > On 12 Nov 2021 19:07, Alan Modra via Binutils wrote:
> > > 	* Makefile.am (TARGET_LIBOPCODES_CFILES): Split into..
> > > 	(TARGET64_LIBOPCODES_CFILES): ..this and..
> > > 	(TARGET32_LIBOPCODES_CFILES): ..this.
> > > 	(ALL_MACHINES): Likewise split to
> > > 	(ALL64_MACHINES, ALL32_MACHINES): ..this.
> > > 	* disassemble.c: Define some ARCH_* when ARCH_all only if BFD64.
> > > 	* configure.ac (BFD_MACHINES): Defined depending on BFD_ARCH_SIZE.
> > > 	* Makefile.in: Regenerate.
> > > 	* configure: Regenerate.
> 
> > riscv supports 32-bit & 64-bit.  this move is breaking 32-bit builds of
> > 32-bit riscv sims.
> > 
> > testing with --host=i686-linux-gnu --enable-targets=all --enable-sim:
> > make[3]: Entering directory '.../sim/riscv'
> >   CCLD   run
> > ...sim/riscv/sim-main.c:71: error: undefined reference to 'riscv_gpr_names_abi'
> > ...sim/riscv/sim-main.c:153: error: undefined reference to 'riscv_gpr_names_abi'
> > ...sim/riscv/sim-main.c:652: error: undefined reference to 'riscv_gpr_names_abi'
> > ...sim/riscv/sim-main.c:800: error: undefined reference to 'riscv_gpr_names_abi'
> > ...sim/riscv/sim-main.c:1108: error: undefined reference to 'riscv_opcodes'
> 
> Yes, I moved bpf back into TARGET32_LIBOPCODES_CFILES for a similar
> problem with the bpf sim.  That might have been a mistake.  For the
> binutils, bpf opcode support is useless without bpf bfd support,
> because a 32-bit bfd can't load an ELF64 object file.  Not even as the
> generic elf64-little or elf64-big targets.
> 
> I think it is also useless for sim.  On my 32-bit sim build:
> $ ~/build/gas/bpf-none/gas/as-new -I ~/src/binutils-gdb/sim/testsuite/bpf ~/src/binutils-gdb/sim/testsuite/bpf/alu.s -o alu.o
> $ ~/build/gas/bpf-none/ld/ld-new -Ttext=0 -o alu alu.o
> $ ./run --memory-size=4Mb alu
> run: "alu" is not an object file: file format not recognized
> 
> Doing the same on a 64-bit sim build results in:
> $ ./run --memory-size=4Mb alu
> pass
> exit 0 (0x0)
> 
> Mike, I question your "working" statement here:
> https://sourceware.org/pipermail/binutils/2021-November/118569.html
> 
> Obviously, moving riscv back into TARGET32_LIBOPCODES_CFILES won't fix
> anything, since riscv was the reason for removing objects from
> libopcodes.

at that point i was defining "working" as "it built & linked fine".  i don't
have specific familiarity with the bpf port as i didn't author it.  i only
just finished overhauling the sim build & test logic to support testing in a
multitarget build so they can all (or most at this point) be tested at the
same time.  and i can see the same runtime error you see now too.  is the
64-bit bfd setting easy to detect in subdirs ?  if so, i think we can change
the sim to skip 64-bit-only ports if 64-bit bfd isn't available.

riscv i think is a bit diff in that it supports 32-bit & 64-bit.
-mike

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: Don't compile some opcodes files when bfd is 32-bit only
  2021-12-02  5:19     ` Mike Frysinger
@ 2021-12-02  8:56       ` Alan Modra
  2021-12-02 16:48         ` Mike Frysinger
  0 siblings, 1 reply; 9+ messages in thread
From: Alan Modra @ 2021-12-02  8:56 UTC (permalink / raw)
  To: binutils

On Thu, Dec 02, 2021 at 12:19:37AM -0500, Mike Frysinger wrote:
> On 02 Dec 2021 09:31, Alan Modra wrote:
> > On Fri, Nov 26, 2021 at 01:01:12PM -0500, Mike Frysinger wrote:
> > > On 12 Nov 2021 19:07, Alan Modra via Binutils wrote:
> > > > 	* Makefile.am (TARGET_LIBOPCODES_CFILES): Split into..
> > > > 	(TARGET64_LIBOPCODES_CFILES): ..this and..
> > > > 	(TARGET32_LIBOPCODES_CFILES): ..this.
> > > > 	(ALL_MACHINES): Likewise split to
> > > > 	(ALL64_MACHINES, ALL32_MACHINES): ..this.
> > > > 	* disassemble.c: Define some ARCH_* when ARCH_all only if BFD64.
> > > > 	* configure.ac (BFD_MACHINES): Defined depending on BFD_ARCH_SIZE.
> > > > 	* Makefile.in: Regenerate.
> > > > 	* configure: Regenerate.
> > 
> > > riscv supports 32-bit & 64-bit.  this move is breaking 32-bit builds of
> > > 32-bit riscv sims.
> > > 
> > > testing with --host=i686-linux-gnu --enable-targets=all --enable-sim:
> > > make[3]: Entering directory '.../sim/riscv'
> > >   CCLD   run
> > > ...sim/riscv/sim-main.c:71: error: undefined reference to 'riscv_gpr_names_abi'
> > > ...sim/riscv/sim-main.c:153: error: undefined reference to 'riscv_gpr_names_abi'
> > > ...sim/riscv/sim-main.c:652: error: undefined reference to 'riscv_gpr_names_abi'
> > > ...sim/riscv/sim-main.c:800: error: undefined reference to 'riscv_gpr_names_abi'
> > > ...sim/riscv/sim-main.c:1108: error: undefined reference to 'riscv_opcodes'
> > 
> > Yes, I moved bpf back into TARGET32_LIBOPCODES_CFILES for a similar
> > problem with the bpf sim.  That might have been a mistake.  For the
> > binutils, bpf opcode support is useless without bpf bfd support,
> > because a 32-bit bfd can't load an ELF64 object file.  Not even as the
> > generic elf64-little or elf64-big targets.
> > 
> > I think it is also useless for sim.  On my 32-bit sim build:
> > $ ~/build/gas/bpf-none/gas/as-new -I ~/src/binutils-gdb/sim/testsuite/bpf ~/src/binutils-gdb/sim/testsuite/bpf/alu.s -o alu.o
> > $ ~/build/gas/bpf-none/ld/ld-new -Ttext=0 -o alu alu.o
> > $ ./run --memory-size=4Mb alu
> > run: "alu" is not an object file: file format not recognized
> > 
> > Doing the same on a 64-bit sim build results in:
> > $ ./run --memory-size=4Mb alu
> > pass
> > exit 0 (0x0)
> > 
> > Mike, I question your "working" statement here:
> > https://sourceware.org/pipermail/binutils/2021-November/118569.html
> > 
> > Obviously, moving riscv back into TARGET32_LIBOPCODES_CFILES won't fix
> > anything, since riscv was the reason for removing objects from
> > libopcodes.
> 
> at that point i was defining "working" as "it built & linked fine".

Heh, OK I'm going to revert 7a53275579e7.

>  i don't
> have specific familiarity with the bpf port as i didn't author it.  i only
> just finished overhauling the sim build & test logic to support testing in a
> multitarget build so they can all (or most at this point) be tested at the
> same time.  and i can see the same runtime error you see now too.  is the
> 64-bit bfd setting easy to detect in subdirs ?

I used
    if grep '#define BFD_ARCH_SIZE 64' ../bfd/bfd-in3.h > /dev/null
in opcodes/configure.ac and made configure-opcodes depend on
configure-bfd in the top level Makefile.def.  bfd-in3.h is made during
bfd configure.

>  if so, i think we can change
> the sim to skip 64-bit-only ports if 64-bit bfd isn't available.

Yes, I think that is the right way to go for --enable-targets=all.

> riscv i think is a bit diff in that it supports 32-bit & 64-bit.

You can argue that with the riscv maintainers.  ;-)

Note that if a user specifically wants a riscv32 sim then using
--target=riscv32-elf or even --enable-targets=riscv32-elf will get
them a 64-bit bfd.

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: Don't compile some opcodes files when bfd is 32-bit only
  2021-12-02  8:56       ` Alan Modra
@ 2021-12-02 16:48         ` Mike Frysinger
  2021-12-02 22:02           ` Alan Modra
  0 siblings, 1 reply; 9+ messages in thread
From: Mike Frysinger @ 2021-12-02 16:48 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils

[-- Attachment #1: Type: text/plain, Size: 1769 bytes --]

On 02 Dec 2021 19:26, Alan Modra via Binutils wrote:
> On Thu, Dec 02, 2021 at 12:19:37AM -0500, Mike Frysinger wrote:
> >  i don't
> > have specific familiarity with the bpf port as i didn't author it.  i only
> > just finished overhauling the sim build & test logic to support testing in a
> > multitarget build so they can all (or most at this point) be tested at the
> > same time.  and i can see the same runtime error you see now too.  is the
> > 64-bit bfd setting easy to detect in subdirs ?
> 
> I used
>     if grep '#define BFD_ARCH_SIZE 64' ../bfd/bfd-in3.h > /dev/null
> in opcodes/configure.ac and made configure-opcodes depend on
> configure-bfd in the top level Makefile.def.  bfd-in3.h is made during
> bfd configure.

hmm, that seems messy.  gdb & ld have specific --enable-64-bit-bfd options
(albeit, copied & pasted from bfd/configure.ac).  should that instead be
refactored into e.g. config/bfd64.m4 and then all these subdirs get that
same configure logic ?

> >  if so, i think we can change
> > the sim to skip 64-bit-only ports if 64-bit bfd isn't available.
> 
> Yes, I think that is the right way to go for --enable-targets=all.
> 
> > riscv i think is a bit diff in that it supports 32-bit & 64-bit.
> 
> You can argue that with the riscv maintainers.  ;-)
> 
> Note that if a user specifically wants a riscv32 sim then using
> --target=riscv32-elf or even --enable-targets=riscv32-elf will get
> them a 64-bit bfd.

--enable-targets=all does not though, and riscv32 only needs a 32-bit bfd.
the symbols in question aren't tied to the bfd size.

tbh, i haven't been following what's been going on, i just raise my head
when the sim fails to link.  and it's failing to link now after this change.
-mike

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: Don't compile some opcodes files when bfd is 32-bit only
  2021-12-02 16:48         ` Mike Frysinger
@ 2021-12-02 22:02           ` Alan Modra
  2021-12-09 22:05             ` Jim Wilson
  0 siblings, 1 reply; 9+ messages in thread
From: Alan Modra @ 2021-12-02 22:02 UTC (permalink / raw)
  To: binutils

On Thu, Dec 02, 2021 at 11:48:50AM -0500, Mike Frysinger wrote:
> On 02 Dec 2021 19:26, Alan Modra via Binutils wrote:
> > On Thu, Dec 02, 2021 at 12:19:37AM -0500, Mike Frysinger wrote:
> > >  i don't
> > > have specific familiarity with the bpf port as i didn't author it.  i only
> > > just finished overhauling the sim build & test logic to support testing in a
> > > multitarget build so they can all (or most at this point) be tested at the
> > > same time.  and i can see the same runtime error you see now too.  is the
> > > 64-bit bfd setting easy to detect in subdirs ?
> > 
> > I used
> >     if grep '#define BFD_ARCH_SIZE 64' ../bfd/bfd-in3.h > /dev/null
> > in opcodes/configure.ac and made configure-opcodes depend on
> > configure-bfd in the top level Makefile.def.  bfd-in3.h is made during
> > bfd configure.
> 
> hmm, that seems messy.  gdb & ld have specific --enable-64-bit-bfd options
> (albeit, copied & pasted from bfd/configure.ac).  should that instead be
> refactored into e.g. config/bfd64.m4 and then all these subdirs get that
> same configure logic ?

You're right, it would be cleaner to do it that way.  What we have in
opcodes at the moment came about from me trying to automatically
choose the set of opcodes targets that need a 64-bit bfd by parsing
bfd config files.  I gave up on implementing that idea, but was then
in the mindset of depending on bfd config rather than depending on
top-level config options.

> > >  if so, i think we can change
> > > the sim to skip 64-bit-only ports if 64-bit bfd isn't available.
> > 
> > Yes, I think that is the right way to go for --enable-targets=all.
> > 
> > > riscv i think is a bit diff in that it supports 32-bit & 64-bit.
> > 
> > You can argue that with the riscv maintainers.  ;-)
> > 
> > Note that if a user specifically wants a riscv32 sim then using
> > --target=riscv32-elf or even --enable-targets=riscv32-elf will get
> > them a 64-bit bfd.
> 
> --enable-targets=all does not though, and riscv32 only needs a 32-bit bfd.
> the symbols in question aren't tied to the bfd size.
> 
> tbh, i haven't been following what's been going on, i just raise my head
> when the sim fails to link.  and it's failing to link now after this change.
> -mike

Reverting the opcodes Makefile changes will currently result in
opcodes failing to link.  The riscv opcodes objects now depend on
riscv bfd objects that are only compiled for a 64-bit bfd.

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: Don't compile some opcodes files when bfd is 32-bit only
  2021-12-02 22:02           ` Alan Modra
@ 2021-12-09 22:05             ` Jim Wilson
  2021-12-09 22:37               ` Alan Modra
  0 siblings, 1 reply; 9+ messages in thread
From: Jim Wilson @ 2021-12-09 22:05 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils

On Thu, Dec 2, 2021 at 2:02 PM Alan Modra via Binutils <
binutils@sourceware.org> wrote:

> Reverting the opcodes Makefile changes will currently result in
> opcodes failing to link.  The riscv opcodes objects now depend on
> riscv bfd objects that are only compiled for a 64-bit bfd.
>

Nelson Chu submitted a patch Nov 12 to fix 32-bit riscv32 builds, but at
the time the patch didn't seem necessary.  I think this should be
revisited.  I think this patch would fix some of these issues people are
having with 32-bit enable-targets=all builds.
https://sourceware.org/pipermail/binutils/2021-November/118498.html

Jim

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

* Re: Don't compile some opcodes files when bfd is 32-bit only
  2021-12-09 22:05             ` Jim Wilson
@ 2021-12-09 22:37               ` Alan Modra
  0 siblings, 0 replies; 9+ messages in thread
From: Alan Modra @ 2021-12-09 22:37 UTC (permalink / raw)
  To: Jim Wilson; +Cc: binutils

On Thu, Dec 09, 2021 at 02:05:54PM -0800, Jim Wilson wrote:
> On Thu, Dec 2, 2021 at 2:02 PM Alan Modra via Binutils <
> binutils@sourceware.org> wrote:
> 
> > Reverting the opcodes Makefile changes will currently result in
> > opcodes failing to link.  The riscv opcodes objects now depend on
> > riscv bfd objects that are only compiled for a 64-bit bfd.
> >
> 
> Nelson Chu submitted a patch Nov 12 to fix 32-bit riscv32 builds, but at
> the time the patch didn't seem necessary.  I think this should be
> revisited.  I think this patch would fix some of these issues people are
> having with 32-bit enable-targets=all builds.
> https://sourceware.org/pipermail/binutils/2021-November/118498.html

I am of course fine with a patch that makes it possible for a 32-bit
objdump to disassemble riscv object files.  What I'd like to avoid is
compiling useless code into libopcodes.  It's not just a matter of
being able to build binutils/sim but also for bfd to recognise and
opcodes to disassemble the target object files.  (I haven't tried out
Nelson's patch, this is a general comment not one specific to the
patch.)

-- 
Alan Modra
Australia Development Lab, IBM

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

end of thread, other threads:[~2021-12-09 22:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-12  8:37 Don't compile some opcodes files when bfd is 32-bit only Alan Modra
2021-11-26 18:01 ` Mike Frysinger
2021-12-01 23:01   ` Alan Modra
2021-12-02  5:19     ` Mike Frysinger
2021-12-02  8:56       ` Alan Modra
2021-12-02 16:48         ` Mike Frysinger
2021-12-02 22:02           ` Alan Modra
2021-12-09 22:05             ` Jim Wilson
2021-12-09 22:37               ` Alan Modra

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).