On 29/10/2019 09:28, Luc Van Oostenryck wrote: > On Tue, Oct 29, 2019 at 02:32:15AM +0000, Ramsay Jones wrote: >>> + static const struct arch { >>> + const char *name; >>> + int mach; >>> + int bits; >>> + } archs[] = { >>> + { "aarch64", MACH_ARM64, 64 }, >>> + { "arm64", MACH_ARM64, 64 }, >>> + { "arm", MACH_ARM, 32 }, >>> + { "i386", MACH_I386, 32 }, >>> + { "m68k", MACH_M68K, 32 }, >>> + { "mips", MACH_MIPS64 }, >>> + { "powerpc", MACH_PPC64 }, >>> + { "ppc", MACH_PPC64 }, >>> + { "riscv", MACH_RISCV64 }, >> >> I would rather these were explicitly set to 0. > > Hmm ... To me, the difference pop out better like so. > The absence of a value is supposed to mean "there is not > a known size for this, it needs to be calculated/guessed". > I find that an explicit 0 conveys this les well. OK, authors choice! ;-) > >>> + { "s390", MACH_S390X, 64 }, >>> + { "s390x", MACH_S390X, 64 }, >>> + { "sparc", MACH_MIPS64 }, >> >> Er, I suppose this should be MACH_SPARC64, right? (also 0 init). > > Ooops, yes, thank you. Bad copy-paste, bad. > >>> + if (bits == 0) { >>> + // guess the size of the architecture >>> + if (!strcmp(suf, "")) { >>> + if (arch_m64 == ARCH_LP32) >>> + bits = 32; >>> + else >>> + bits = 64; >> >> So, this is a 50-50 bet. ;-) > > No, not really. > The -m32/-m64 flags are still taken in account, before the > --arch and after it too. If no -m32/-m64 is given at all > then the used size is the one of the native arch (because > arch_m64 is initialized so). heh, yes, I just meant that (if -m32/-m64 has _not_ been given) then you have a 50/50 chance that you are cross-compiling to a system that has the same 'bit-ness' as your current platform. (well, actually, I suppose both are likely to be 64-bit these days - so, maybe not 50/50! ;-) ). > I think it's quite natural to > use but it lacks some error checking (e.g.: --arch=arm -m64 > will purposely *not* select arm64, aka aarach64, but no > warnings will be issued). Thanks! ATB, Ramsay Jones