[Bug 267026] stable/13 toolchain regression in for native-xtools build, builds wrong target for nxb-bin compiler, breaking poudriere+qemu for cross-arch build

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 13 Oct 2022 20:06:28 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=267026

            Bug ID: 267026
           Summary: stable/13 toolchain regression in for native-xtools
                    build, builds wrong target for nxb-bin compiler,
                    breaking poudriere+qemu for cross-arch build
           Product: Base System
           Version: 13.1-STABLE
          Hardware: Any
                OS: Any
            Status: New
          Keywords: regression, toolchain
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: mandree@FreeBSD.org
                CC: bsdimp@FreeBSD.org, dim@FreeBSD.org,
                    kevans@freebsd.org

Created attachment 237276
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=237276&action=edit
Bourne sh script used as probe in git bisect run

I am trying to set up a FreeBSD 13.1+ poudriere builder that cross-builds on
amd64 targetting arm64.aarch64.

Observe that poudriere-devel installs the native-xtools toolchain into the
jail's nxb-bin directory unless this is suppressed with -X. This is, in my
case, an amd64 executable compiler targetting (generating) aarch64 code. Or
should be.

Symptom is that on the very first poudriere build, the pkg build bombs out
claiming that it cannot find a suitable compiler for bootstrapping jimsh0 as
tclsh surrogate, and that it failed to find one, having tried
/nxb-bin/usr/bin/cc and gcc.  13.1-amd64 doesn't bring gcc, so that must fail,
and /nxb-bin/usr/bin/cc fails because although it SHOULD target aarch64, it
does target amd64, so pkg's configure script rejects it and errors out.

kevans91 reported on IRC this got fixed in
https://cgit.freebsd.org/src/commit/Makefile.inc1?h=stable/13&id=3afe1c2e181712afd0120e14267f92050de434f7
and I can confirm that.

stable/13's tip when I started "git bisect" had gone bad again, and it was git
commit hash 6094749.

Now, this was easily detectable and scriptable, so I could do a 1-day-long git
bisect run, and it came up with:

----------
70c04943208fd5441024d0cf6e0486ea4bfb0f4e is the first bad commit

commit 70c04943208fd5441024d0cf6e0486ea4bfb0f4e
Author: Dimitry Andric <dim@FreeBSD.org>
Date:   Sun Aug 14 13:10:48 2022 +0200

    Avoid using TARGET_ARCH in llvm.build.mk

    Apparently the TARGET_ARCH macro is not supposed to be used outside of
    the top-level Makefiles. Directly use MACHINE_ARCH instead.

    Noticed by:     imp, jrtc27
    MFC after:      1 week

    (cherry picked from commit 8534e6be8110a8126268a38dc0557a2d15615ce9)

 lib/clang/llvm.build.mk | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
----------

This is the full git bisect log:

# Status: warte auf guten und schlechten Commit
# bad: [38b1cbc87b5faefec38a81c4487877fde778be20] usb(4): Make the enumeration
thread nice time a variable.
git bisect bad 38b1cbc87b5faefec38a81c4487877fde778be20
# Status: warte auf gute(n) Commit(s), schlechter Commit bekannt
# good: [d9da2f90cbec9b3c4777bd12671e2f837907ff5a] loader: Relax the check in
is_kernphys_relocatable()
git bisect good d9da2f90cbec9b3c4777bd12671e2f837907ff5a
# bad: [8d6d90d939950d0e0ec5e52f4883cac41d0e20dc] pkg(8): Remove a double word
in a source code comment
git bisect bad 8d6d90d939950d0e0ec5e52f4883cac41d0e20dc
# good: [a2acdcb602ddd69aa332c0b7ef41276c9e9b596b] find.1: Correct the markup
git bisect good a2acdcb602ddd69aa332c0b7ef41276c9e9b596b
# bad: [623220ac78e1733204de6859352aa968ca3615ab] sleepq_check_ast_sc_locked():
update comment
git bisect bad 623220ac78e1733204de6859352aa968ca3615ab
# good: [c9f9dc96d9089d250f4aba9bab4d2acea9b7acf2] installworld: improve
portability of ldd use
git bisect good c9f9dc96d9089d250f4aba9bab4d2acea9b7acf2
# bad: [94c282b1eff460c0c5d2275c84dafbd5322a9f23] Adjust function definition in
arm's dtrace_subr.c to avoid clang 15 warning
git bisect bad 94c282b1eff460c0c5d2275c84dafbd5322a9f23
# good: [f7cb47731675828d27ebd55c9fc46953ee168d48] contrib/tzdata: import
tzdata 2022b and 2022c
git bisect good f7cb47731675828d27ebd55c9fc46953ee168d48
# good: [d58ced88d39f0169a3fa08e8e626870131cee90f] prometheus_sysctl_exporter:
ignore ENOENT for mibs specified on the CLI
git bisect good d58ced88d39f0169a3fa08e8e626870131cee90f
# bad: [70c04943208fd5441024d0cf6e0486ea4bfb0f4e] Avoid using TARGET_ARCH in
llvm.build.mk
git bisect bad 70c04943208fd5441024d0cf6e0486ea4bfb0f4e
# good: [baa6a68cbe47b257c771e9b7f7254750df46bd3f] ip6(4): document
IP_ORIGDSTADDR
git bisect good baa6a68cbe47b257c771e9b7f7254750df46bd3f
# good: [3c87f145d4e82c26b8dd73274831f9ce6a9c7a16] pfctl: fix
FOM_ICMP/POM_STICKYADDRESS clash
git bisect good 3c87f145d4e82c26b8dd73274831f9ce6a9c7a16
# first bad commit: [70c04943208fd5441024d0cf6e0486ea4bfb0f4e] Avoid using
TARGET_ARCH in llvm.build.mk

(sorry that it had put the log down in German)

and the test script I used for git bisect run is attached, for posterity.

-- 
You are receiving this mail because:
You are the assignee for the bug.