Bug 277527 - emulators/qemu: build fail
Summary: emulators/qemu: build fail
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: Muhammad Moinur Rahman
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-06 12:35 UTC by Ivan Rozhuk
Modified: 2024-03-09 13:44 UTC (History)
3 users (show)

See Also:
bugzilla: maintainer-feedback? (bofh)


Attachments
patch (927 bytes, patch)
2024-03-06 13:50 UTC, Ivan Rozhuk
bofh: maintainer-approval-
Details | Diff
gmake makeflags env variables (373 bytes, patch)
2024-03-06 18:54 UTC, David M.
bofh: maintainer-approval-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Rozhuk 2024-03-06 12:35:52 UTC
...
[6553/6553] Linking target qemu-system-xtensaeb
gmake[3]: Leaving directory '/tmp/ports/usr/ports/emulators/qemu/work-default/qemu-8.2.2/build'
gmake[2]: Leaving directory '/tmp/ports/usr/ports/emulators/qemu/work-default/qemu-8.2.2'
===>>> Building the port required 239 seconds
===>  Staging for qemu-8.2.2
===>   Generating temporary packing list
cd /tmp/ports/usr/ports/emulators/qemu/work-default/qemu-8.2.2 && /usr/bin/env DESTDIR=/tmp/ports/usr/ports/emulators/qemu/work-default/stage gmake install
: invalid option -- D
Usage: gmake [options] [target] ...
Options:
  -b, -m                      Ignored for compatibility.
  -B, --always-make           Unconditionally make all targets.
...
Comment 1 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2024-03-06 12:39:00 UTC
Which version of FreeBSD? Ports or poudriere?
Comment 2 Ivan Rozhuk 2024-03-06 12:42:26 UTC
FreeBSD 14/stable amd64, portmaster.
All fresh.
Comment 3 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2024-03-06 12:44:27 UTC
I do not have the resources to test this with ports but it builds fine in poudriere with both 13.2-RELEASE and 14.0-RELEASE:
https://pkg.bofh.network/data/latest-per-pkg/qemu/8.2.2/
Comment 4 Ivan Rozhuk 2024-03-06 13:50:34 UTC
Created attachment 248971 [details]
patch

I do not dig deeper, looks like portmaster set some env var that breaks build.
make -C /usr/ports/emulators/qemu - was not broken.

${SETENV} -i ${MAKE_ENV} - make build env is always identical.
Comment 5 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2024-03-06 13:53:40 UTC
(In reply to Ivan Rozhuk from comment #4)
Yes that is the biggest problem with both portmaster and portupgrade that is environment leak.

I will look into it during the weekend.
Comment 6 David M. 2024-03-06 18:54:59 UTC
Created attachment 248983 [details]
gmake makeflags env variables

I had the same problem with portmaster emulators/qemu@guestagent, it seems to be an issue with gmake 4.4 environment variables.
Comment 7 Tijl Coosemans freebsd_committer freebsd_triage 2024-03-06 21:00:56 UTC
Also see bug 277492.  I've committed a patch to portmaster to avoid the problem for now.
Comment 8 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2024-03-06 21:09:45 UTC
Based on comment #7 I think both of the patches are partially correct and partially wrong.

We need to utilize SETENVI in both cases of build and install.

And we are not supposed to silent the build or the install process at all. 

I will look into this with a cooler head during the weekend.
Comment 9 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2024-03-06 21:10:44 UTC
Comment on attachment 248971 [details]
patch

See comment #8
Comment 10 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2024-03-06 21:11:02 UTC
Comment on attachment 248983 [details]
gmake makeflags env variables

See comment #8.
Comment 11 Tijl Coosemans freebsd_committer freebsd_triage 2024-03-07 08:51:01 UTC
(In reply to Muhammad Moinur Rahman from comment #8)
I haven't tested it but I think you can remove do-build and do-install if you replace USES=ninja with USES=ninja:build.
Comment 12 Ivan Rozhuk 2024-03-07 18:35:10 UTC
(In reply to Tijl Coosemans from comment #11)
Found ninja-1.11.1 at /usr/local/bin/ninja
Running postconf script '/tmp/ports/usr/ports/emulators/qemu/work-default/qemu-8.2.2/build/pyvenv/bin/python3.9 /tmp/ports/usr/ports/emulators/qemu/work-default/qemu-8.2.2/scripts/symlink-install-tree.py'
===>  Building for qemu-8.2.2
Makefile:169: *** Please call configure before running make.  Stop.
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1
Comment 13 Ivan Rozhuk 2024-03-07 18:36:26 UTC
(In reply to Muhammad Moinur Rahman from comment #8)
> And we are not supposed to silent the build or the install process at all.

@ - only hide command line, all output from gmake is printed.
Comment 14 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2024-03-07 18:36:48 UTC
(In reply to Tijl Coosemans from comment #11)
Noops. This has adverse effects on powerpc and I have no clue on why.
Comment 15 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2024-03-07 18:41:16 UTC
(In reply to Ivan Rozhuk from comment #12)
With USES=ninja:build it will not work. You will need some additional changes which are in one of my ancient reviews which I do not intend to find now as at that point we figured out that it breaks the build with powerpc. Although I am not a big fan of powerpc or other ARCH at the moment but we will have to support it. So this is not the path we should be taking. The above patches are correct and we will just have to cook both of them together in a working situation.
Comment 16 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2024-03-07 18:44:19 UTC
(In reply to Ivan Rozhuk from comment #13)
That is due to the fact on how make/gmake works not how port infrastructure was made. In case you use '@' in any target with commands like REINPLACE_CMD or INSTALL* or any other commands it will entirely silent the output.
Comment 17 Ivan Rozhuk 2024-03-07 18:46:36 UTC
(In reply to Muhammad Moinur Rahman from comment #15)

It was reply to Tijl Coosemans, I test his suggestion with USES=ninja:build and show output with error :)
Comment 18 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2024-03-07 18:49:24 UTC
(In reply to Ivan Rozhuk from comment #17)
I know that it was on his reply but I wanted to say that with some other workarounds in the Makefile you can make that happen and even work for at non-POWERPC ARCHS. :D

But yeah just after seeing your reply I tried to recollect on why I have not thought about it and done it and then I remembered this corner case with powerpc.
Comment 19 Ivan Rozhuk 2024-03-07 18:53:20 UTC
(In reply to Muhammad Moinur Rahman from comment #16)
Nope.
With my patch that have @ output is:
...
[ 99% 6552/6553] Linking target qemu-system-ppc64
[ 99% 6552/6553] Compiling C object libqemu-riscv64-softmmu.fa.p/target_riscv_translate.c.o
[100% 6553/6553] Linking target qemu-system-riscv64
gmake[1]: Leaving directory '/tmp/ports/usr/ports/emulators/qemu/work-default/qemu-8.2.2/build'
gmake: Leaving directory '/tmp/ports/usr/ports/emulators/qemu/work-default/qemu-8.2.2'
===>  Staging for qemu-8.2.2
===>   qemu-8.2.2 depends on file: /usr/local/lib/libncurses.so.6 - found
===>   qemu-8.2.2 depends on file: /usr/local/libdata/pkgconfig/pixman-1.pc - found
===>   qemu-8.2.2 depends on file: /usr/local/libdata/pkgconfig/x11.pc - found
===>   Generating temporary packing list
gmake: Entering directory '/tmp/ports/usr/ports/emulators/qemu/work-default/qemu-8.2.2'
changing dir to build for gmake "install"...
gmake[1]: Entering directory '/tmp/ports/usr/ports/emulators/qemu/work-default/qemu-8.2.2/build'
[  1% 1/83] Generating qemu-version.h with a custom command (wrapped by meson to capture output)
[  5% 2/35] Generating tests/include/QAPI test (include) with a custom command
[ 66% 3/3] Installing files.
Installing trace/trace-events-all to /tmp/ports/usr/ports/emulators/qemu/work-default/stage/usr/local/share/qemu
Installing qemu-arm to /tmp/ports/usr/ports/emulators/qemu/work-default/stage/usr/local/bin
...
Comment 20 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2024-03-07 19:10:26 UTC
(In reply to Ivan Rozhuk from comment #19)
Ha Ha .. You clearly did not get my point here. That is because how make or gmake works and that is not because of the '@' at all. make/gmake or most of the make like build systems are built in a manner that the output does not silent by default unless explicitly mentioned in the Makefile.

Let me give you another example with one of my port databases/freetds:
# make -C databases/freetds clean
# make -C databases/freetds patch

Check the output then clean it. Then modify the Makefile and remove all the line that has @ in front specially in front of REINPLACE_CMD at the post-patch target. And then again run:
# make -C databases/freetds patch

You will see some additional lines being printed. I think this will let you understand on the actual way of how '@' works. And we tend to avoid using this on targets specifically related to build, install and stage. The problem in this case is this '@' or 'SILENT' is not powerful enough stop any Gmake system from spitting out the build informations(Our BSD Make is calling another make system which tends to be Gmake here). Try to Google around for the '.SILENT' keyword in Gmake history although no longer in use and has also been replaced with '@'.
Comment 21 commit-hook freebsd_committer freebsd_triage 2024-03-09 13:43:31 UTC
A commit in branch main references this bug:

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

commit a779acb15993d9f8d995495ead62f7b1deb20a7c
Author:     Muhammad Moinur Rahman <bofh@FreeBSD.org>
AuthorDate: 2024-03-09 13:38:57 +0000
Commit:     Muhammad Moinur Rahman <bofh@FreeBSD.org>
CommitDate: 2024-03-09 13:43:13 +0000

    emulators/qemu: Fix regression in gmake

    This issue started popping up after the latest gmake upgrade. Although
    there are multiple ways of fixing this I will stick with the preferred
    path by tijl@ as he is trying to address the issue with other ports.

    As I am not sure sure whether if this triggers a different binary being
    generated but for the safest route bumping portrevision. This problem
    is not reproducible for people using poudreiere to build their ports

    PR:             277527
    Reported by:    rozhuk.im@gmail.com

 emulators/qemu/Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)