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
Summary: stable/13 toolchain regression in for native-xtools build, builds wrong targe...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 13.1-STABLE
Hardware: Any Any
: --- Affects Some People
Assignee: Kyle Evans
URL: https://reviews.freebsd.org/D36981
Keywords: regression, toolchain
Depends on:
Blocks:
 
Reported: 2022-10-13 20:06 UTC by Matthias Andree
Modified: 2022-10-17 16:00 UTC (History)
5 users (show)

See Also:
kevans: mfc-stable13+
kevans: mfc-stable12+


Attachments
Bourne sh script used as probe in git bisect run (512 bytes, text/plain)
2022-10-13 20:06 UTC, Matthias Andree
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Andree freebsd_committer freebsd_triage 2022-10-13 20:06:28 UTC
Created attachment 237276 [details]
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.
Comment 1 Matthias Andree freebsd_committer freebsd_triage 2022-10-13 20:13:31 UTC
linearly listing history since release/13.1.0:

broken in 0001  * 08523c8c63b 2022-03-09 | Rename stable/13 to -STABLE now that releng/13.1 has branched [Glen Barber]

fixed in  1031  * | 3afe1c2e181 2021-10-13 | native-xtools: avoid libllvm while populating the sysroot [Kyle Evans]

regressed 2379  * | 70c04943208 2022-08-14 | Avoid using TARGET_ARCH in llvm.build.mk [Dimitry Andric]
Comment 2 commit-hook freebsd_committer freebsd_triage 2022-10-14 03:05:27 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=ed7910fbac07ee39d10528994e49ada2d0f2d754

commit ed7910fbac07ee39d10528994e49ada2d0f2d754
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2022-10-14 03:04:47 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2022-10-14 03:04:47 +0000

    Revert "Avoid using TARGET_ARCH in llvm.build.mk"

    This reverts commit 8534e6be8110a8126268a38dc0557a2d15615ce9, and adds
    a cautionary note that there are dragons about that should be considered
    when changing it.

    PR:             267026
    Reviewed by:    dim, imp
    MFC after:      3 days
    Differential Revision:  https://reviews.freebsd.org/D36981

 lib/clang/llvm.build.mk | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2022-10-17 15:41:33 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=63d9ad6e46d28c5310def9f5db954debf3d1c569

commit 63d9ad6e46d28c5310def9f5db954debf3d1c569
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2022-10-14 03:04:47 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2022-10-17 15:38:46 +0000

    Revert "Avoid using TARGET_ARCH in llvm.build.mk"

    This reverts commit 8534e6be8110a8126268a38dc0557a2d15615ce9, and adds
    a cautionary note that there are dragons about that should be considered
    when changing it.

    PR:             267026
    Reviewed by:    dim, imp
    MFC after:      3 days
    Differential Revision:  https://reviews.freebsd.org/D36981

    (cherry picked from commit ed7910fbac07ee39d10528994e49ada2d0f2d754)

 lib/clang/llvm.build.mk | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2022-10-17 15:41:35 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=e2f3e8c5e89c745429968220a12e2de9e79b4a07

commit e2f3e8c5e89c745429968220a12e2de9e79b4a07
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2022-10-14 03:04:47 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2022-10-17 15:40:17 +0000

    Revert "Avoid using TARGET_ARCH in llvm.build.mk"

    This reverts commit 8534e6be8110a8126268a38dc0557a2d15615ce9, and adds
    a cautionary note that there are dragons about that should be considered
    when changing it.

    PR:             267026
    Reviewed by:    dim, imp
    MFC after:      3 days
    Differential Revision:  https://reviews.freebsd.org/D36981

    (cherry picked from commit ed7910fbac07ee39d10528994e49ada2d0f2d754)

 lib/clang/llvm.build.mk | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
Comment 5 Kyle Evans freebsd_committer freebsd_triage 2022-10-17 16:00:08 UTC
Fixed, thanks!