On Tue, Mar 17, 2026 at 11:21:43AM -0700, Song Liu wrote: > On Tue, Mar 17, 2026 at 10:52 AM Josh Poimboeuf <[email protected]> wrote: > [...] > > > > > > Yeah, I think that would be a good idea. Will do that for v2. > > > > So, in general ARCH is complicated. For example: > > > > - ARCH=arm64 would never match "uname -m" (aarch64) > > - ARCH=i386 would use the same gcc binary (no cross-compiler needed) > > - I'm sure there are many other edge cases... > > Agreed. I haven't worked with i386 for a long time, but I did notice > the arm64 vs. aarch64 difference. > > > Instead of a manual error, it may be simpler to just let the build fail > > naturally if the user doesn't set the right ARCH. > > > > Though, I think the check can be improved slightly, as ARCH is a > > reasonably good indicator that cross-compiling is happening. So I can > > at least add an ARCH check at the beginning like so? > > > > cross_compile_init() { > > if [[ ! -v ARCH ]]; then > > OBJCOPY=objcopy > > return 0 > > fi > > > > if [[ -v LLVM ]]; then > > OBJCOPY=llvm-objcopy > > else > > OBJCOPY="${CROSS_COMPILE:-}objcopy" > > fi > > } > > Do we need ARCH when CROSS_COMPILE is set? I was > under the impression that CROSS_COMPILE doesn't require > ARCH.
If CROSS_COMPILE is used without ARCH, it will just try to use the host arch. I'm not sure if that's considered cross-compiling? I suppose it should use the CROSS_COMPILE version of objcopy in that case? Though in practice it probably doesn't matter. I guess the original version of the function is probably fine and we don't need to complicate matters. -- Josh

