diff mbox series

[4/7] arch: change the arch when changing -m32/64

Message ID 20191030090333.3412-8-luc.vanoostenryck@gmail.com (mailing list archive)
State Superseded, archived
Headers show
Series improve cross-compiling usage | expand

Commit Message

Luc Van Oostenryck Oct. 30, 2019, 9:03 a.m. UTC
If the flag -m32 or -m64 is given in argument, we must insure
that the corresponding architecture is changed as well.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 target.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
diff mbox series

Patch

diff --git a/target.c b/target.c
index 7829e8f9a..90097818f 100644
--- a/target.c
+++ b/target.c
@@ -57,6 +57,27 @@  int enum_alignment = 4;
 
 void init_target(void)
 {
+	switch (arch_mach) {
+	case MACH_I386:
+	case MACH_MIPS32:
+	case MACH_PPC32:
+	case MACH_RISCV32:
+	case MACH_SPARC32:
+	case MACH_S390:
+		if (arch_m64 == ARCH_LP64)
+			arch_mach++;
+		break;
+	case MACH_X86_64:
+	case MACH_MIPS64:
+	case MACH_PPC64:
+	case MACH_RISCV64:
+	case MACH_SPARC64:
+	case MACH_S390X:
+		if (arch_m64 == ARCH_LP32)
+			arch_mach--;
+		break;
+	}
+
 	switch (arch_mach) {
 	case MACH_X86_64:
 		if (arch_m64 == ARCH_LP64)