Bug 254319 - MAKE_CONF and SRC_CONF affect release chroot build
Summary: MAKE_CONF and SRC_CONF affect release chroot build
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Glen Barber
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-15 21:48 UTC by Don Lewis
Modified: 2021-04-29 15:58 UTC (History)
2 users (show)

See Also:


Attachments
release.sh patch to prevent MAKE_CONF and SRC_CONF settings in release.conf from affecting chroot build (1.15 KB, patch)
2021-03-15 21:52 UTC, Don Lewis
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Don Lewis freebsd_committer freebsd_triage 2021-03-15 21:48:59 UTC
The release(7) man page states:
     MAKE_CONF        The make.conf(5) to use for the release build.  Defaults
                      to /dev/null to prevent polluting the release with local
                      system changes.

     SRC_CONF         The src.conf(5) to use for the release build.  Defaults
                      to /dev/null to prevent polluting the release with local
                      system changes.

but these settings also affect the chroot build.  This is not surprising since these settings are included in ${CONF_FILES}, which is included in ${CHROOT_WMAKEFLAGS}, ${CHROOT_IMAKEFLAGS}, and ${CHROOT_DMAKEFLAGS}.  This problem becomes apparent when the make.conf file sets TARGET_CPUTYPE to a value that is incompatible with the host arch.
Comment 1 Don Lewis freebsd_committer freebsd_triage 2021-03-15 21:52:40 UTC
Created attachment 223309 [details]
release.sh patch to prevent MAKE_CONF and SRC_CONF settings in release.conf from affecting chroot build
Comment 2 Glen Barber freebsd_committer freebsd_triage 2021-03-15 22:08:54 UTC
Could you please elaborate on what it is you are trying to accomplish?  Your patch, as-is, forces SRC_CONf and MAKE_CONF to /dev/null, which invalidates the purpose of being able to set SRC_CONF=/my/local/src.conf, etc., which I do not agree with.

I also do not understand the purpose of forcefully setting TARGET_CPUTYPE, as that should be determined based on the values of TARGET, TARGET_ARCH, and KERNCONF of the build.  If this is not the case, you are trying to solve the wrong problem, IMHO.
Comment 3 Don Lewis freebsd_committer freebsd_triage 2021-03-15 23:23:09 UTC
I'm trying to build a custom FreeBSD i386 release with arch-specific CPU optimization and a bunch of stuff omitted from userland.  If I set TARGET_CPUTYPE in the make.conf for my i386 machine, the chroot build on an amd64 host fails because that compiler option is not valid on amd64.  I can get it to work by also setting TARGET=i386 and TARGET_ARCH=i386 in the make.conf file, but this has the side effect of building the chroot as i386.

My patch causes the chroot build to ignore the *_CONF settings, but the conf files are still used to build the release.  The RELEASE_*MAKEFLAGS still get the specified *_CONF settings.

Something else that I want to do at some point is to include the specified make.conf and src.conf files in the release, so that a rebuild from source on the target machine, or by freebsd-update-server would reproduce what was generated by the release.  I can think of a number of ways to do this, but haven't yet explored it and haven't though about whether this should be automatic or opt-in via some sort of knob.
Comment 4 Don Lewis freebsd_committer freebsd_triage 2021-03-15 23:30:56 UTC
My src.conf specifies WITHOUT_AT=true along with a bunch of other stuff.

at is present in the chroot:
%ls /scratch/usr/bin/a*
/scratch/usr/bin/addftinfo	/scratch/usr/bin/as
/scratch/usr/bin/addr2line	/scratch/usr/bin/asa
/scratch/usr/bin/afmtodit	/scratch/usr/bin/asn1_compile
/scratch/usr/bin/alias		/scratch/usr/bin/at
/scratch/usr/bin/apply		/scratch/usr/bin/atq
/scratch/usr/bin/apropos	/scratch/usr/bin/atrm
/scratch/usr/bin/ar		/scratch/usr/bin/awk

but not the release:
%ls /scratch/usr/obj/usr/src/i386.i386/release/dist/base/usr/bin/a*
/scratch/usr/obj/usr/src/i386.i386/release/dist/base/usr/bin/addr2line
/scratch/usr/obj/usr/src/i386.i386/release/dist/base/usr/bin/alias
/scratch/usr/obj/usr/src/i386.i386/release/dist/base/usr/bin/apply
/scratch/usr/obj/usr/src/i386.i386/release/dist/base/usr/bin/apropos
/scratch/usr/obj/usr/src/i386.i386/release/dist/base/usr/bin/ar
/scratch/usr/obj/usr/src/i386.i386/release/dist/base/usr/bin/asa
/scratch/usr/obj/usr/src/i386.i386/release/dist/base/usr/bin/awk
Comment 5 Don Lewis freebsd_committer freebsd_triage 2021-03-15 23:43:22 UTC
I'm setting TARGET_CPU to try to get the most optimal code for my particular flavor of CPU. This setting affects the instructions chosen and code sequences generated by the compiler.  I don't know what the default is for i386 these days, probably i586 or i686.  In this particular case I'm choosing c3-2.  On my laptop, where I build natively, I set it to pentium-m.
Comment 6 Mark Millard 2021-03-16 03:58:35 UTC
(In reply to Glen Barber from comment #2)

I would word it that Don is trying to allow build
distinctions (that are currently not supported)
between (CHROOT_?MAKEFLAGS use):

        if [ -z "${CHROOTBUILD_SKIP}" ]; then
                cd ${CHROOTDIR}/usr/src
                env ${CHROOT_MAKEENV} make ${CHROOT_WMAKEFLAGS} buildworld
                env ${CHROOT_MAKEENV} make ${CHROOT_IMAKEFLAGS} installworld \
                        DESTDIR=${CHROOTDIR}
                env ${CHROOT_MAKEENV} make ${CHROOT_DMAKEFLAGS} distribution \
                        DESTDIR=${CHROOTDIR}
        fi

and (RELEASE_?MAKEFLAGS use):

chroot_build_target() {
        load_target_env
        if [ ! -z "${EMBEDDEDBUILD}" ]; then
                RELEASE_WMAKEFLAGS="${RELEASE_WMAKEFLAGS} \
                        TARGET=${EMBEDDED_TARGET} \
                        TARGET_ARCH=${EMBEDDED_TARGET_ARCH}"
                RELEASE_KMAKEFLAGS="${RELEASE_KMAKEFLAGS} \
                        TARGET=${EMBEDDED_TARGET} \
                        TARGET_ARCH=${EMBEDDED_TARGET_ARCH}"
        fi
        eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_WMAKEFLAGS} buildworld
        eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_KMAKEFLAGS} buildkernel

        return 0
} # chroot_build_target

(I'm not trying to advocate for a specific answer.)

One could even imagine using distinct make.conf and src.conf
like files for the two types of context, for example.
Comment 7 Mark Millard 2021-03-16 04:19:59 UTC
(In reply to Mark Millard from comment #6)

I should also have listed chroot_build_release and
its RELEASE_RMAKEFLAGS use for the 2nd case. I'll
not give the full text here, just mention that I
intended to span it.
Comment 8 Glen Barber freebsd_committer freebsd_triage 2021-03-16 16:02:10 UTC
Thank you for clarifying.
Comment 9 commit-hook freebsd_committer freebsd_triage 2021-03-16 16:02:33 UTC
A commit in branch main references this bug:

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

commit 0af8a2db34cff008d4f48f357da48b7379b18893
Author:     Glen Barber <gjb@FreeBSD.org>
AuthorDate: 2021-03-16 16:01:48 +0000
Commit:     Glen Barber <gjb@FreeBSD.org>
CommitDate: 2021-03-16 16:01:48 +0000

    release: do not set __MAKE_CONF and SRCCONF for the chroot build

    PR:             254319
    Submitted by:   truckman
    MFC after:      1 week
    Sponsored by:   Rubicon Communications, LLC ("Netgate")

 release/release.sh | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
Comment 10 commit-hook freebsd_committer freebsd_triage 2021-04-29 15:57:15 UTC
A commit in branch stable/13 references this bug:

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

commit 5a3548f2e28a7240138ea714e31ae9089f8a80be
Author:     Glen Barber <gjb@FreeBSD.org>
AuthorDate: 2021-03-16 16:01:48 +0000
Commit:     Glen Barber <gjb@FreeBSD.org>
CommitDate: 2021-04-29 15:45:46 +0000

    release: do not set __MAKE_CONF and SRCCONF for the chroot build

    PR:             254319
    Submitted by:   truckman
    Sponsored by:   Rubicon Communications, LLC ("Netgate")

    (cherry picked from commit 0af8a2db34cff008d4f48f357da48b7379b18893)

 release/release.sh | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)