Bug 236565

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

Description rozhuk.im 2019-03-16 01:37:43 UTC
Created attachment 202895 [details]

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

-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:
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 rozhuk.im 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 rozhuk.im 2019-03-16 05:27:19 UTC
(In reply to Tatsuki Makino from comment #2)
Comment 4 Mathieu Arnold freebsd_committer 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 rozhuk.im 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
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:
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 2019-04-19 18:17:32 UTC
I see no problem related to make.conf in the ports tree.
Comment 7 rozhuk.im 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 rozhuk.im 2020-04-16 07:53:05 UTC
maintainer timeout