Bug 277492 - lang/ghc fails build/install gmake invalid option -- D
Summary: lang/ghc fails build/install gmake invalid option -- D
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-haskell (Nobody)
URL:
Keywords:
: 277599 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-03-04 23:56 UTC by alt2600
Modified: 2024-03-09 19:53 UTC (History)
5 users (show)

See Also:
arrowd: maintainer-feedback+


Attachments
patch (3.24 KB, patch)
2024-03-05 15:48 UTC, Tijl Coosemans
no flags Details | Diff
Example error message (5.27 KB, text/plain)
2024-03-06 02:30 UTC, Patrick McMunn
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description alt2600 2024-03-04 23:56:07 UTC
trying to update this on amd64 13.2p10 live system builds. Fails saying -D is not a valid option. haven't dug into this but not sure if others might be seeing this issue too.

****************************************************
Configuration done, ready to 'make install'
(see README and INSTALL files for more info.)
****************************************************
cd /usr/ports/lang/ghc/work/ghc-9.2.8-x86_64-portbld-freebsd && gmake PACKAGES='' install
: invalid option -- D
Usage: gmake [options] [target] ...
Options:
  -b, -m                      Ignored for compatibility.
  -B, --always-make           Unconditionally make all targets.
  -C DIRECTORY, --directory=DIRECTORY
                              Change to DIRECTORY before doing anything.
  -d                          Print lots of debugging information.
  --debug[=FLAGS]             Print various types of debugging information.
  -e, --environment-overrides
                              Environment variables override makefiles.
  -E STRING, --eval=STRING    Evaluate STRING as a makefile statement.
  -f FILE, --file=FILE, --makefile=FILE
                              Read FILE as a makefile.
  -h, --help                  Print this message and exit.
  -i, --ignore-errors         Ignore errors from recipes.
  -I DIRECTORY, --include-dir=DIRECTORY
                              Search DIRECTORY for included makefiles.
  -j [N], --jobs[=N]          Allow N jobs at once; infinite jobs with no arg.
  --jobserver-style=STYLE     Select the style of jobserver to use.
  -k, --keep-going            Keep going when some targets can't be made.
  -l [N], --load-average[=N], --max-load[=N]
                              Don't start multiple jobs unless load is below N.
  -L, --check-symlink-times   Use the latest mtime between symlinks and target.
  -n, --just-print, --dry-run, --recon
                              Don't actually run any recipe; just print them.
  -o FILE, --old-file=FILE, --assume-old=FILE
                              Consider FILE to be very old and don't remake it.
  -O[TYPE], --output-sync[=TYPE]
                              Synchronize output of parallel jobs by TYPE.
  -p, --print-data-base       Print make's internal database.
  -q, --question              Run no recipe; exit status says if up to date.
  -r, --no-builtin-rules      Disable the built-in implicit rules.
  -R, --no-builtin-variables  Disable the built-in variable settings.
  --shuffle[={SEED|random|reverse|none}]
                              Perform shuffle of prerequisites and goals.
  -s, --silent, --quiet       Don't echo recipes.
  --no-silent                 Echo recipes (disable --silent mode).
  -S, --no-keep-going, --stop
                              Turns off -k.
  -t, --touch                 Touch targets instead of remaking them.
  --trace                     Print tracing information.
  -v, --version               Print the version number of make and exit.
  -w, --print-directory       Print the current directory.
  --no-print-directory        Turn off -w, even if it was turned on implicitly.
  -W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE
                              Consider FILE to be infinitely new.
  --warn-undefined-variables  Warn when an undefined variable is referenced.

This program built for amd64-portbld-freebsd13.2
Report bugs to <bug-make@gnu.org>
*** Error code 2
Comment 1 Patrick McMunn 2024-03-05 00:46:30 UTC
Although I haven't yet run into this error with ghc, I've encountered this error with several other ports recently, so it may be something systemic. I even removed all the packages on my system and started from scratch in case there was some messed up dependency somewhere in the chain, but I still get the error with some ports.
Comment 2 Gleb Popov freebsd_committer freebsd_triage 2024-03-05 15:16:39 UTC
Tijl, could it be related to your recent work on SETENVI?
Comment 3 Tijl Coosemans freebsd_committer freebsd_triage 2024-03-05 15:48:36 UTC
Created attachment 248952 [details]
patch

It's gmake 4.4 being picky about things FreeBSD make puts into the MAKEFLAGS environment variable.  The solution is to run it with ${SETENVI} ${WRK_ENV}.  But I wonder where that -D flag is coming from.  Are you building the port with "make -DSOMETHING"?
Comment 4 alt2600 2024-03-06 00:01:15 UTC
(In reply to Tijl Coosemans from comment #3)

in testing a little bit more I'm finding some weirdness with portmaster it seems

portmaster -GDb ghc

is what I've been doing, tried

portmaster -Gb ghc

no difference, but just going into ports tree and doing

make clean stage

seems to be building just fine. I think somewhere maybe portmaster is tainting the build environment??? it doesn't seem to be coming from ports directly, least not on this port in particular. I'm going to file something on that and reference this PR.
Comment 5 alt2600 2024-03-06 00:59:08 UTC
(In reply to alt2600 from comment #4)

just completed manually updating things the hard way. this doesn't seem to actually be a ports issue or a ghc issue
Comment 6 Patrick McMunn 2024-03-06 01:53:44 UTC
I tested two other ports that have this problem: databases/postgresql15-client and shells/bash-completion and verified that simply going into the ports tree and typing "make install" works correctly. But trying to install the port using portmaster results in this error. So the problem appears to be an issue with portmaster that may not play well with the recent SETENVI work.
Comment 7 Patrick McMunn 2024-03-06 02:30:12 UTC
Created attachment 248960 [details]
Example error message

Well, it may not necessarily be portmaster, after all. Either that, or portmaster somehow leaves behind traces that can be picked up by make somehow. For example, if I go to ../multimedia/emby-server and type "make", everything goes fine until it reaches shells/bash-completion. Then I get *multiple* copies of the error instead of just one as with portmaster.
Comment 8 Ale 2024-03-06 05:04:29 UTC
(In reply to Patrick McMunn from comment #6)
I'm having the same problem trying to upgrade emulators/qemu.
As a workaround, assuming PWD is /usr/ports, you can continue the upgrade with:
# make -C emulators/qemu
and upgrade using portmaster with your usual flags (-DgB in my case) and the -C flag (prevents 'make clean' from being run before building):
# portmaster -DgB -C emulators/qemu
Comment 9 commit-hook freebsd_committer freebsd_triage 2024-03-06 20:25:41 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=830ec3717024e0060b2b48db4319a4eb060f8023

commit 830ec3717024e0060b2b48db4319a4eb060f8023
Author:     Tijl Coosemans <tijl@FreeBSD.org>
AuthorDate: 2024-03-06 19:13:39 +0000
Commit:     Tijl Coosemans <tijl@FreeBSD.org>
CommitDate: 2024-03-06 20:22:21 +0000

    Mk/Scripts/do-depends.sh: Avoid make -D flag

    Both FreeBSD make and GNU make pass command line flags to sub-makes
    through the MAKEFLAGS environment variable, but the flags aren't
    compatible and GNU make 4.4 exits with an error when it encounters
    flags it doesn't understand, e.g. -D.

    Avoid using the flag for now until ports run gmake with SETENVI.

    This fixes the case where a port is built using make directly and it
    recurses to build a dependency that uses gmake.  Poudriere does not
    use this feature of the ports tree to build dependencies so it's not
    affected.

    PR:             272216, 277492

 Mk/Scripts/do-depends.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 10 commit-hook freebsd_committer freebsd_triage 2024-03-06 20:46:48 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=755d190db121778a25b45950c397163325d8e797

commit 755d190db121778a25b45950c397163325d8e797
Author:     Tijl Coosemans <tijl@FreeBSD.org>
AuthorDate: 2024-03-06 20:38:58 +0000
Commit:     Tijl Coosemans <tijl@FreeBSD.org>
CommitDate: 2024-03-06 20:44:44 +0000

    ports-mgmt/portmaster: Avoid make -D flag

    Both FreeBSD make and GNU make pass command line flags to sub-makes
    through the MAKEFLAGS environment variable, but the flags aren't
    compatible and GNU make 4.4 exits with an error when it encounters
    flags it doesn't understand, e.g. -D.

    Avoid using the flag for now until ports run gmake with SETENVI.

    PR:             272216, 277492

 ports-mgmt/portmaster/Makefile                     |  2 +-
 ports-mgmt/portmaster/files/patch-portmaster (new) | 71 ++++++++++++++++++++++
 2 files changed, 72 insertions(+), 1 deletion(-)
Comment 11 Tijl Coosemans freebsd_committer freebsd_triage 2024-03-06 20:53:53 UTC
There are too many ports affected by this and it will take a while to fix them all so I've committed changes to the ports framework and portmaster to avoid the problem for now.
Comment 12 Patrick McMunn 2024-03-07 00:53:19 UTC
(In reply to Tijl Coosemans from comment #11)

So, to be clear, is the temporary solution to update the ports tree and upgrade portmaster?
Comment 13 Tijl Coosemans freebsd_committer freebsd_triage 2024-03-07 08:35:34 UTC
(In reply to Patrick McMunn from comment #12)
Yes, you need portmaster-3.29_2.
Comment 14 Gleb Popov freebsd_committer freebsd_triage 2024-03-07 15:53:40 UTC
Tijl, the lang/ghc port does not call gmake directly. Do you mean that it is Uses/gmake.mk that should be fixed?

Where exactly should I plug SETENVI in to fix this correctly for my port?
Comment 15 Tijl Coosemans freebsd_committer freebsd_triage 2024-03-07 16:50:06 UTC
(In reply to Gleb Popov from comment #14)
Grep for 'gmake|GMAKE|MAKE_CMD' to find suspicious lines.  These are the ones in lang/ghc/Makefile:

$ egrep -n 'gmake|GMAKE|MAKE_CMD' lang/ghc/Makefile
20:USES=			autoreconf compiler:c11 gmake \
215:	cd ${BOOT_DIR} && ${MAKE_CMD} PACKAGES='' install
276:		&& ${GMAKE} binary-dist TAR_COMP=xz \
295:		&& ${GMAKE} binary-dist TAR_COMP=xz \

It looks like 215 is the one from comment 0.  You can replace that line with:

	cd ${BOOT_DIR} && ${SETENVI} ${WRK_ENV} ${MAKE_CMD} PACKAGES='' install

Line 276 and 295 would become:

		&& ${SETENVI} ${WRK_ENV} ${GMAKE} binary-dist TAR_COMP=xz \

For testing you can put something like this in make.conf (/usr/local/etc/poudriere.d/make.conf):

.MAKEFLAGS+=	-D __GMAKE_TRAP__

If a port fails to build with this then there are more commands that need SETENVI.
Comment 16 O. Hartmann 2024-03-09 18:44:32 UTC
*** Bug 277599 has been marked as a duplicate of this bug. ***
Comment 17 commit-hook freebsd_committer freebsd_triage 2024-03-09 19:53:21 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=973a7aaf4838d29069505a49f9f6a8248b4f57d8

commit 973a7aaf4838d29069505a49f9f6a8248b4f57d8
Author:     Gleb Popov <arrowd@FreeBSD.org>
AuthorDate: 2024-03-09 19:50:49 +0000
Commit:     Gleb Popov <arrowd@FreeBSD.org>
CommitDate: 2024-03-09 19:51:30 +0000

    lang/ghc: Use SETENVI for gmake invocations

    PR:             277492

 lang/ghc/Makefile | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)