Page MenuHomeFreeBSD

Remove MAKEFLAGS and MAKESYSPATH from env passed to PORTS_MODULES
ClosedPublic

Authored by jah on Nov 12 2017, 3:34 AM.

Details

Summary

Background: I have a port (multimedia/cx88) that installs some kmods, which I
like to rebuild during the PORTS_MODULES step. That port also installs a userspace
utility that is built using bsd.prog.mk with libs specified in LDADD. As such,
rebuilding it during PORTS_MODULES has been broken since 11.0 because MAKESYSPATH/
MAKEFLAGS (-m) point to SRCROOT, which consumes src.libnames.mk and results in an
error like "These libraries should be LIBADD+=foo rather than DPADD/LDADD+=-lfoo".

I'm not at all an expert on the build system, so this change may be the wrong thing
to do for a variety of reasons. The real answer might just be something like
"split the port up" or "don't use LDADD there". But as long as bsd.kmod.mk remains
a thin wrapper that respects SYSDIR, it seems like this approach could allow
PORTS_MODULES to work for a broader variety of ports. It would result in kmods
building against the makefiles in the updated src tree through SYSDIR, while any
remaining piece of the port would build against the installed ports/build system,
which (I think?) is what one would want in an upgrade scenario.

So I thought I'd at least post it so you guys could poke holes in it:)

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jah created this revision.Nov 12 2017, 3:34 AM

I think removing MAKEFLAGS may be too much. I think we can just add MAKESYSPATH=/usr/share/mk to the environment and should also set _WITHOUT_SRCCONF=yes.

jah added a comment.Nov 14 2017, 6:03 AM

I think removing MAKEFLAGS may be too much. I think we can just add MAKESYSPATH=/usr/share/mk to the environment and should also set _WITHOUT_SRCCONF=yes.

I don't think that'll work: since src.libnames.mk is a .sinclude from bsd.libnames.mk, any presence of '-m ${SRCTOP}/share/mk' in MAKEFLAGS will cause it to be consumed, regardless of what else is in MAKEFLAGS or MAKESYSPATH. FWIW, here's what's in MAKEFLAGS during the PORTS_MODULES step on my machine (11-current):

"-m /usr/src/share/mk -m /usr/src/share/mk -D NO_MODULES_OBJ .MAKE.LEVEL.ENV=MAKELEVEL KERNEL=kernel TARGET=amd64 TARGET_ARCH=amd64"

As for _WITHOUT_SRCCONF, shouldn't we already be ok there? It's defined unconditionally by bsd.port.mk. Having it set in the env for the full PORTS_MODULES step seems like it would cause problems for any kmod or other steps of the port build that would need to consume src.conf. It definitely caused some strange errors when I tried it just now.

jah added a comment.Nov 14 2017, 6:32 PM

We could also kill off just the -m directives in MAKEFLAGS. A one-liner like this should do it:

${MAKEFLAGS:M*:tW:S/^-m /-m_/g:S/ -m / -m_/g:tw:N-m_*}

jah updated this revision to Diff 36122.Dec 2 2017, 8:48 PM

Remove only -m directives from MAKEFLAGS

bdrewery accepted this revision.Jan 24 2018, 8:44 PM
This revision is now accepted and ready to land.Jan 24 2018, 8:44 PM
This revision was automatically updated to reflect the committed changes.