Date: Mon, 16 Nov 2020 17:50:17 +0000 From: bugzilla-noreply@freebsd.org To: ports-bugs@FreeBSD.org Subject: [Bug 251191] Mk/Uses/ninja.mk: 'USES=cmake emacs' results in build error with ninja Message-ID: <bug-251191-7788@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D251191 Bug ID: 251191 Summary: Mk/Uses/ninja.mk: 'USES=3Dcmake emacs' results in build error with ninja Product: Ports & Packages Version: Latest Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: Individual Port(s) Assignee: ports-bugs@FreeBSD.org Reporter: yasu@utahime.org CC: kde@FreeBSD.org Flags: exp-run? Created attachment 219737 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D219737&action= =3Dedit Patch file 1. Summary 'USES=3Dcmake emacs' results in build error with ninja. This is bug of ports build system. Attached patch fixes it. 2. Background I'm trying to create port of following software. libegit2: Emacs bindings for libgit2 https://github.com/magit/libegit2 3. What is the problem? To port libegit2 following 2 steps are necessary. a. Build libegit2.so with cmake and install it to ${PREFI}/lib b. Byte-compile libgit.el and install them to ${PREFIX}/${EMACS_VERSION_SITE_LISPDIR} So I need to add 'USES=3Dcmake emacs' in Makefile. But it causes error of n= inja such as following. ---------------------------------------------------------------------- =3D=3D=3D> License GPLv3+ accepted by the user =3D=3D=3D> libegit2-emacs27_nox-0.0.1.20200316 depends on file: /usr/loca= l/sbin/pkg - found =3D=3D=3D> Fetching all distfiles required by libegit2-emacs27_nox-0.0.1.20= 200316 for building =3D=3D=3D> Extracting for libegit2-emacs27_nox-0.0.1.20200316 =3D> SHA256 Checksum OK for magit-libegit2-0.0.1.20200316-0ef8b13_GH0.tar.g= z. =3D=3D=3D> Patching for libegit2-emacs27_nox-0.0.1.20200316 =3D=3D=3D> Applying FreeBSD patches for libegit2-emacs27_nox-0.0.1.2020031= 6 from /usr0/freebsd/ports/git/devel/libegit2/files =3D=3D=3D> libegit2-emacs27_nox-0.0.1.20200316 depends on file: /usr/local/bin/cmake - found =3D=3D=3D> libegit2-emacs27_nox-0.0.1.20200316 depends on executable: nin= ja - found =3D=3D=3D> libegit2-emacs27_nox-0.0.1.20200316 depends on file: /usr/local/bin/emacs-27.1 - found =3D=3D=3D> libegit2-emacs27_nox-0.0.1.20200316 depends on package: pkgcon= f>=3D1.3.0_1 - found =3D=3D=3D> libegit2-emacs27_nox-0.0.1.20200316 depends on shared library: libgit2.so - found (/usr/local/lib/libgit2.so) =3D=3D=3D> Configuring for libegit2-emacs27_nox-0.0.1.20200316 =3D=3D=3D> Performing out-of-source build /bin/mkdir -p /usr0/freebsd/ports/work/usr0/freebsd/ports/git/devel/libegit2/work-nox/.bu= ild -- The C compiler identification is Clang 10.0.1 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- The CXX compiler identification is Clang 10.0.1 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found PkgConfig: pkgconf (found version "1.7.3")=20 -- Checking for module 'libgit2' -- Found libgit2, version 1.0.1 -- Configuring done -- Generating done CMake Warning: Manually-specified variables were not used by the project: CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_VERBOSE_MAKEFILE THREADS_HAVE_PTHREAD_ARG -- Build files have been written to: /usr0/freebsd/ports/work/usr0/freebsd/ports/git/devel/libegit2/work-nox/.bu= ild =3D=3D=3D> Building for libegit2-emacs27_nox-0.0.1.20200316 ninja: error: unknown target 'EMACS=3D/usr/local/bin/emacs-27.1' =3D=3D=3D> Compilation failed unexpectedly. Try to set MAKE_JOBS_UNSAFE=3Dyes and rebuild before reporting the failure = to the maintainer. *** Error code 1 Stop. make: stopped in /usr0/freebsd/ports/git/devel/libegit2 Command exit status: 1 ---------------------------------------------------------------------- I tried to build libegit2 according to the steps described in its document = and it succeeded without any error. Moreover I selected some ports that use 'USES=3Dcmake', intentionally change them to 'USES=3Dcmake emacs' and tried= to build them. Then build failed with same error for all of them. So this is b= ug of ports build system. 4. Why the problem happens? There is following line in Mk/Uses/emacs.mk ---------------------------------------------------------------------- MAKE_ARGS+=3D EMACS=3D${EMACS_CMD} ---------------------------------------------------------------------- So if both 'cmake' and 'emacs' is added to USES, then ninja is invoked with something like `ninja -v EMACS=3D/usr/local/bin/emacs-27.1`. But according = to the output of `ninja --help`, ninja doesn't accept such argument as 'NAME=3DVAL= UE' that `make` accepts. So it results in the error that happens when I try to build my devel/libegit2 port. I checked Mk/Uses/*.mk and found following ones also add extra arguments to MAKE_ARGS. * Mk/Uses/gnustep.mk * Mk/Uses/scons.mk * Mk/Uses/waf.mk Moreover each port that uses 'USES=3Dcmake' may do same thing. Therefore th= is problem should be fixed by changing Mk/Uses/ninja.mk. 5. Solution In Mk/bsd.port.mk MAKE_ARGS is used in following targets. * do-build * do-install * do-test So the solution is to re-define them in Mk/Uses/ninja.mk. As for do-install= and do-test, DO_MAKE_BUILD and DO_MAKE_TEST are defined and used when each targ= et is called respectively. So re-define them in ninja.mk so ninja is directly invoked without using MAKE_ARGS. As for do-install DO_MAKE_INSTALL isn't defined. So re-define the target with same way in ninja.mk. As the result re-definition of following variables in ninja.mk gets unnecessary. * MAKE_ARGS * MAKE_CMD * MAKE_FLAGS * MAKE_JOBS * MAKEFILE So remove them. Additionally define NINJA_ARGS whose default value is empty and add it to argument of executing ninja. It is intended that some ports may want to add extra argument when executing ninja. 6. Test Following branch includes both devel/libegit2 port and this fix. https://github.com/yasuhirokimura/freebsd-ports/tree/libegit2/ (Note: This branch will be removed once devel/libegit2 is committed.) It can be build without any error. I also confirmed some ports that uses 'USES=3Dcmake' can be built successfully with attached patch. But it should= be tested more with exp-run. --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-251191-7788>