Bug 236565

Summary: [PATCH] Mk/bsd.port.mk: /etc/make.conf included twice by FreeBSD make
Product: Ports & Packages Reporter: Ivan Rozhuk <rozhuk.im>
Component: Ports FrameworkAssignee: freebsd-ports-bugs (Nobody) <ports-bugs>
Status: Open ---    
Severity: Affects Many People CC: pi, ports-bugs, rozhuk.im, tatsuki_makino
Priority: --- Keywords: needs-qa, patch
Version: LatestFlags: rozhuk.im: maintainer-feedback-
Hardware: Any   
OS: Any   
Attachments:
Description Flags
patch
none
unbreak portmaster rozhuk.im: maintainer-approval?

Description Ivan Rozhuk 2019-03-16 01:37:43 UTC
Created attachment 202895 [details]
patch

I spent some time while debugging math/mprime build, then build:
...
cc -O2 -pipe -O2 -DSTRIP_FBSDID -pipe -D_FORTIFY_SOURCE=2 -mretpoline  -fstack-protector-all -fno-strict-aliasing  -O2 -DSTRIP_FBSDID -pipe -D_FORTIFY_SOURCE=2 -mretpoline -I.. -I../sqlite-amalgamation-3180000 -DX86_64 -c gwnum.c
...

where:
-O2 -pipe - from /usr/share/mk/sys.mk
-O2 -DSTRIP_FBSDID -pipe -D_FORTIFY_SOURCE=2 -mretpoline - mine /etc/make.conf
-fstack-protector-all -fno-strict-aliasing - from /usr/ports/Mk/bsd.port.mk, /usr/ports/Mk/bsd.ssp.mk
-I.. -I../sqlite-amalgamation-3180000 -DX86_64 -c gwnum.c - port makefile

this options added twice:
-O2 -DSTRIP_FBSDID -pipe -D_FORTIFY_SOURCE=2 -mretpoline

first time then you call make to on make file in ports tree,
second then ports trying to build port.
If use gmake to build port then this not happen.

This can be problem, because ports build system does not control
CFLAGS and other staff that in /etc/make.conf.
For example if you try build mprime using gcc - it fail, because
gcc does not support -mretpoline.
/usr/ports/Mk/bsd.gcc.mk - handle this and remove first -mretpoline,
but second -mretpoline added after run MAKE_CMD.

To prevent second include /etc/make.conf this must be done:
__MAKE_CONF=/dev/null
It can be added to /etc/make.conf, /usr/ports/Mk/bsd.port.mk or
port Makefile.

Some ports already done this.
I add to /etc/make.conf and buld dozen ports without isses.
Comment 1 Ivan Rozhuk 2019-03-16 01:59:02 UTC
Created attachment 202896 [details]
unbreak portmaster
Comment 2 Tatsuki Makino 2019-03-16 05:17:34 UTC
Do all CFLAGS lines in your /etc/make.conf have `+='?
Comment 3 Ivan Rozhuk 2019-03-16 05:27:19 UTC
(In reply to Tatsuki Makino from comment #2)
Yes.
Comment 4 Mathieu Arnold freebsd_committer freebsd_triage 2019-04-18 14:26:30 UTC
Looks like more a base system problem, all this happens before the ports framework comes into play.
Comment 5 Ivan Rozhuk 2019-04-19 00:02:34 UTC
(In reply to Mathieu Arnold from comment #4)

I play with /usr/src/share/mk/sys.mk / /usr/share/mk/sys.mk
__MAKE_CONF=/dev/null
must be placed before make called if you already set CFLAGS and other staff.
Ports build system prepare all env variables and nothink to load from make.conf at this point.

If I put:
__MAKE_CONF=/dev/null
to /etc/make.conf or in /usr/share/mk/sys.mk after
.include "${__MAKE_CONF}"
- this does nothing, because importing already done here, and new import will be started after make executed.

If I also add:
.export __MAKE_CONF / .export-env __MAKE_CONF
then this breaks PORTS_MODULES modules build, because they does not load make.conf and have no varibles from parent process.

So this must be done only in ports framework to fix ports build.
Possible this also should be added to some points in base system to fix doubling CFLAGS during system build.
Comment 6 Antoine Brodin freebsd_committer freebsd_triage 2019-04-19 18:17:32 UTC
I see no problem related to make.conf in the ports tree.
Comment 7 Ivan Rozhuk 2019-04-19 20:03:42 UTC
You should look better.

archivers/libcabinet/Makefile:MAKE_ENV=	WITHOUT_PROFILE=yes __MAKE_CONF=/dev/null SRCCONF=/dev/null
devel/libpdel/Makefile:MAKE_ENV=	WITHOUT_PROFILE=yes __MAKE_CONF=/dev/null SRCCONF=/dev/null
devel/libshhmsg/Makefile:MAKE_ENV=	WITHOUT_PROFILE=yes __MAKE_CONF=/dev/null SRCCONF=/dev/null
devel/libxalloc/Makefile:MAKE_ENV=	WITHOUT_PROFILE=yes __MAKE_CONF=/dev/null SRCCONF=/dev/null
emulators/vmw/Makefile:MAKE_ENV+=	__MAKE_CONF=/dev/null ASFLAGS="${ASFLAGS}"
finance/libstocks/Makefile:MAKE_ENV=	WITHOUT_PROFILE=yes __MAKE_CONF=/dev/null SRCCONF=/dev/null
games/libshhcards/Makefile:MAKE_ENV=	WITHOUT_PROFILE=yes __MAKE_CONF=/dev/null SRCCONF=/dev/null
japanese/ming/Makefile:MAKE_ENV=	WITHOUT_PROFILE=yes __MAKE_CONF=/dev/null SRCCONF=/dev/null
java/bootstrap-openjdk6/Makefile.update:BUILD_ENV=	__MAKE_CONF=/dev/null PATH="${PATH}"
java/bootstrap-openjdk8/Makefile.update:BUILD_ENV=	__MAKE_CONF=/dev/null PATH="${PATH}"
lang/lua51/Makefile:# Overriding __MAKE_CONF makes sure that we don't re-parse
lang/lua51/Makefile:MAKE_ARGS=	__MAKE_CONF=${NONEXISTENT}
lang/lua52/Makefile:# Overriding __MAKE_CONF makes sure that we don't re-parse
lang/lua52/Makefile:MAKE_ARGS=	__MAKE_CONF=${NONEXISTENT}
lang/lua53/Makefile:# Overriding __MAKE_CONF makes sure that we don't re-parse
lang/lua53/Makefile:MAKE_ARGS=	__MAKE_CONF=${NONEXISTENT}
mail/dma/Makefile:MAKE_ENV=	__MAKE_CONF=/dev/null SRCCONF=/dev/null NO_WERROR=defined \
mail/spamilter/Makefile:MAKE_ENV+=	__MAKE_CONF=/dev/null
math/libmissing/Makefile:		SRCCONF=/dev/null SRCS="${SRCS}" __MAKE_CONF=/dev/null
math/linpack/Makefile:MAKE_ENV=	WITHOUT_PROFILE=yes __MAKE_CONF=/dev/null SRCCONF=/dev/null
ports-mgmt/dialog4ports/Makefile:MAKE_ENV+=	__MAKE_CONF=/dev/null SRCCONF=/dev/null
sysutils/dirdiff/Makefile:# it with MAKE_ENV+=  __MAKE_CONF=/dev/null to avoid sourcing make.conf twice.
sysutils/pfstat/Makefile:MAKE_ENV+=	__MAKE_CONF=/dev/null
sysutils/pftop/Makefile:MAKE_ENV+=	__MAKE_CONF=/dev/null
Comment 8 Ivan Rozhuk 2020-04-16 07:53:05 UTC
maintainer timeout
Comment 9 Ivan Rozhuk 2022-05-28 00:13:22 UTC
actual:

/usr/ports/Tools/scripts/tindex:export __MAKE_CONF=/dev/null
/usr/ports/archivers/libcabinet/Makefile:MAKE_ENV=	WITHOUT_PROFILE=yes __MAKE_CONF=/dev/null SRCCONF=/dev/null
/usr/ports/devel/libpdel/Makefile:MAKE_ENV=	WITHOUT_PROFILE=yes __MAKE_CONF=/dev/null SRCCONF=/dev/null
/usr/ports/devel/libshhmsg/Makefile:MAKE_ENV=	WITHOUT_PROFILE=yes __MAKE_CONF=/dev/null SRCCONF=/dev/null
/usr/ports/devel/libxalloc/Makefile:MAKE_ENV=	WITHOUT_PROFILE=yes __MAKE_CONF=/dev/null SRCCONF=/dev/null
/usr/ports/devel/linux_libusb/Makefile:MAKE_ARGS+=	__MAKE_CONF=""
/usr/ports/emulators/vmw/Makefile:MAKE_ENV+=	__MAKE_CONF=/dev/null ASFLAGS="${ASFLAGS}"
/usr/ports/finance/libstocks/Makefile:MAKE_ENV=	WITHOUT_PROFILE=yes __MAKE_CONF=/dev/null SRCCONF=/dev/null
/usr/ports/games/libshhcards/Makefile:MAKE_ENV=	WITHOUT_PROFILE=yes __MAKE_CONF=/dev/null SRCCONF=/dev/null
/usr/ports/java/bootstrap-openjdk6/Makefile.update:BUILD_ENV=	__MAKE_CONF=/dev/null PATH="${PATH}"
/usr/ports/java/bootstrap-openjdk8/Makefile.update:BUILD_ENV=	__MAKE_CONF=/dev/null PATH="${PATH}"
/usr/ports/lang/lua51/Makefile:# Overriding __MAKE_CONF makes sure that we don't re-parse
/usr/ports/lang/lua51/Makefile:MAKE_ARGS=	__MAKE_CONF=${NONEXISTENT}
/usr/ports/lang/lua52/Makefile:# Overriding __MAKE_CONF makes sure that we don't re-parse
/usr/ports/lang/lua52/Makefile:MAKE_ARGS=	__MAKE_CONF=${NONEXISTENT}
/usr/ports/lang/lua53/Makefile:# Overriding __MAKE_CONF makes sure that we don't re-parse
/usr/ports/lang/lua53/Makefile:MAKE_ARGS=	__MAKE_CONF=${NONEXISTENT}
/usr/ports/lang/lua54/Makefile:# Overriding __MAKE_CONF makes sure that we don't re-parse
/usr/ports/lang/lua54/Makefile:MAKE_ARGS=	__MAKE_CONF=${NONEXISTENT}
/usr/ports/mail/dma/Makefile:MAKE_ENV=	__MAKE_CONF=/dev/null \
/usr/ports/mail/spamilter/Makefile:MAKE_ENV+=	__MAKE_CONF=/dev/null
/usr/ports/math/libmissing/Makefile:		SRCCONF=/dev/null SRCS="${SRCS}" __MAKE_CONF=/dev/null
/usr/ports/math/linpack/Makefile:MAKE_ENV=	WITHOUT_PROFILE=yes __MAKE_CONF=/dev/null SRCCONF=/dev/null
/usr/ports/ports-mgmt/dialog4ports/Makefile:MAKE_ENV+=	__MAKE_CONF=/dev/null SRCCONF=/dev/null
/usr/ports/sysutils/dirdiff/Makefile:# it with MAKE_ENV+=  __MAKE_CONF=/dev/null to avoid sourcing make.conf twice.
/usr/ports/sysutils/pfstat/Makefile:MAKE_ENV+=	__MAKE_CONF=/dev/null
/usr/ports/sysutils/pftop/Makefile:MAKE_ENV+=	__MAKE_CONF=/dev/null
Comment 10 Ivan Rozhuk 2022-05-28 00:15:08 UTC
I use attached patch 3+ year, no issues.
You may ask listed ports maintainers for extra motivation to include __MAKE_CONF=/dev/null.
Comment 11 Graham Perrin freebsd_committer freebsd_triage 2022-10-17 12:35:33 UTC
Keyword: 

    patch
or  patch-ready

– in lieu of summary line prefix: 

    [patch]

* bulk change for the keyword
* summary lines may be edited manually (not in bulk). 

Keyword descriptions and search interface: 

    <https://bugs.freebsd.org/bugzilla/describekeywords.cgi>