public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH] meson.eclass: stop using the incomparably broken "meson compile"
@ 2024-06-02 19:08 Eli Schwartz
  2024-06-02 19:43 ` [gentoo-dev] [PATCH 0/3] meson.eclass: corresponding updates to ebuilds Eli Schwartz
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Schwartz @ 2024-06-02 19:08 UTC (permalink / raw)
  To: gentoo-dev

With my upstream meson hat on, I have griped about this for years any
time someone mentions "meson compile" to me. I think it was badly
motivated and shouldn't exist.

The purpose of this command is "for symmetry" with meson setup and meson
test and meson install, even though all of those are python programs
first and foremost, which have ninja targets that simply call back into
the meson tool but with less control.

Symmetry doesn't make a whole lot of sense. The compile phase actually
is implemented as a... ninja file, not a python program. Using ninja
directly is:
- faster, since you don't load hundreds of python modules into memory,
  just to fork out to ninja
- easier to control, since you can directly control the ninja arguments

The "meson compile" program actually, in fact, only really exists for
two reasons:

- meson supports multiple backends -- only when manually requested -- on
  operating systems other than linux. Namely, VS on Windows, and xcode
  on macOS. The wrapper first checks which backend has been generated,
  and then runs the appropriate command there. It also provides the
  ninja argument syntax for options that multiple backends understand,
  so, you can pass -v -j8 and it actually works regardless of backend
  (even if in fact it has to pass `-verbosity:minimal -maxCpuCount:8` to
  do it).

- via retconning, on Windows when using the MSVC `cl.exe` meson compile
  started actually adding this to PATH and setting it up (because it
  requires sourcing a batch script in order to both add to PATH and set
  inscrutable mandatory environment variables) to prevent ninja utterly
  failing if you missed this yourself.

For portage purposes, neither of these matter whatsoever. Even if
portage were to ever use cl.exe on Windows (???) it could set up the
environment just fine on its own, and actually using alternative
backends would require extending the eclass to configure xcode/vs for
tremendous slowdown in compile time, which would be silly.

In exchange for all these features portage doesn't need, what do we get?

meson compile unabashedly doesn't support all possible ninja arguments,
and says you should instead pass the combination of --ninja-args "..."
--vs-args "..." --xcode-args "..." and it will figure out which ones are
relevant for *your* backend and forward it to the backend. We don't
actually do that -- it would be super ugly for the common case of -v
-j8.

As a result, we ignore $NINJAOPTS, which ninja-utils.eclass claims we
are allowed to use. Instead we manually parse out some subset of
"supported" values. We *cannot* respect NINJAOPTS anyways, because...

... meson compile sucks and cannot handle it. To be more accurate: it
expects --ninja-args to be formatted using `meson-format-array`, the
same format that machine files use. No thank you!

And we still have to move to get_NINJAOPTS, then pass it as:

```
meson compile -C "${BUILD_DIR}" --ninja-args="['-j', '8', '-k', '0', '-v', '-l', '0']"
```

instead of:
```
meson compile -C "${BUILD_DIR}" -j 8 -v -l 0 --ninja-args="['-k0']"
```

The overengineered complexity of this is immense. ninja-utils.eclass
exists for an extremely good reason, provides best practices, and means
we don't have to maintain an interface to a custom tool with unintuitive
behavior since we get precisely the common functionality we already
want, for free.

Just use eninja.

Fixes:

- the absolute inability to use standard $NINJAOPTS to fine-tune
  meson-using packages, for example to keep going and collect all the
  build errors before aborting with a failure.
- support for ${NINJA_VERBOSE} (expected to be the fallback if
  MESON_VERBOSE isn't set)

Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
---
 eclass/meson.eclass | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/eclass/meson.eclass b/eclass/meson.eclass
index a22a85887584..a2bc5537e458 100644
--- a/eclass/meson.eclass
+++ b/eclass/meson.eclass
@@ -440,23 +440,11 @@ meson_src_compile() {
 
 	pushd "${BUILD_DIR}" > /dev/null || die
 
-	local mesoncompileargs=(
-		--jobs "$(get_makeopts_jobs 0)"
-		--load-average "$(get_makeopts_loadavg 0)"
-	)
-
 	case ${MESON_VERBOSE} in
-		OFF) ;;
-		*) mesoncompileargs+=( --verbose ) ;;
+		OFF) NINJA_VERBOSE=OFF eninja "$@" ;;
+		*) eninja "$@" ;;
 	esac
-
-	mesoncompileargs+=( "$@" )
-
-	set -- meson compile "${mesoncompileargs[@]}"
-	echo "$@" >&2
-	"$@"
 	local rv=$?
-	[[ ${rv} -eq 0 ]] || die -n "compile failed"
 
 	popd > /dev/null || die
 	return ${rv}
-- 
2.44.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [gentoo-dev] [PATCH 0/3] meson.eclass: corresponding updates to ebuilds
  2024-06-02 19:08 [gentoo-dev] [PATCH] meson.eclass: stop using the incomparably broken "meson compile" Eli Schwartz
@ 2024-06-02 19:43 ` Eli Schwartz
  2024-06-02 19:43   ` [gentoo-dev] [PATCH 1/3] net-libs/libsrtp: pass in a ninja-compatible value to meson_src_compile Eli Schwartz
                     ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Eli Schwartz @ 2024-06-02 19:43 UTC (permalink / raw)
  To: gentoo-dev


Eli Schwartz (3):
  net-libs/libsrtp: pass in a ninja-compatible value to
    meson_src_compile
  sys-apps/systemd-utils: pass in a ninja-compatible value to
    meson_src_compile
  dev-db/postgresql: pass in a ninja-compatible value to
    meson_src_compile

 dev-db/postgresql/postgresql-9999.ebuild              | 2 +-
 net-libs/libsrtp/libsrtp-2.4.2.ebuild                 | 2 +-
 sys-apps/systemd-utils/systemd-utils-254.10-r1.ebuild | 2 +-
 sys-apps/systemd-utils/systemd-utils-254.12.ebuild    | 2 +-
 sys-apps/systemd-utils/systemd-utils-254.13.ebuild    | 2 +-
 sys-apps/systemd-utils/systemd-utils-255.4.ebuild     | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

-- 
2.44.2



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [gentoo-dev] [PATCH 1/3] net-libs/libsrtp: pass in a ninja-compatible value to meson_src_compile
  2024-06-02 19:43 ` [gentoo-dev] [PATCH 0/3] meson.eclass: corresponding updates to ebuilds Eli Schwartz
@ 2024-06-02 19:43   ` Eli Schwartz
  2024-06-02 19:43   ` [gentoo-dev] [PATCH 2/3] sys-apps/systemd-utils: " Eli Schwartz
  2024-06-02 19:43   ` [gentoo-dev] [PATCH 3/3] dev-db/postgresql: " Eli Schwartz
  2 siblings, 0 replies; 5+ messages in thread
From: Eli Schwartz @ 2024-06-02 19:43 UTC (permalink / raw)
  To: gentoo-dev

Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
---
 net-libs/libsrtp/libsrtp-2.4.2.ebuild | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net-libs/libsrtp/libsrtp-2.4.2.ebuild b/net-libs/libsrtp/libsrtp-2.4.2.ebuild
index 96e02837fcf2..1aaaf742a61f 100644
--- a/net-libs/libsrtp/libsrtp-2.4.2.ebuild
+++ b/net-libs/libsrtp/libsrtp-2.4.2.ebuild
@@ -55,7 +55,7 @@ multilib_src_configure() {
 multilib_src_compile() {
 	meson_src_compile
 	if multilib_is_native_abi && use doc; then
-		meson_src_compile doc
+		meson_src_compile doc/html
 	fi
 }
 
-- 
2.44.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [gentoo-dev] [PATCH 2/3] sys-apps/systemd-utils: pass in a ninja-compatible value to meson_src_compile
  2024-06-02 19:43 ` [gentoo-dev] [PATCH 0/3] meson.eclass: corresponding updates to ebuilds Eli Schwartz
  2024-06-02 19:43   ` [gentoo-dev] [PATCH 1/3] net-libs/libsrtp: pass in a ninja-compatible value to meson_src_compile Eli Schwartz
@ 2024-06-02 19:43   ` Eli Schwartz
  2024-06-02 19:43   ` [gentoo-dev] [PATCH 3/3] dev-db/postgresql: " Eli Schwartz
  2 siblings, 0 replies; 5+ messages in thread
From: Eli Schwartz @ 2024-06-02 19:43 UTC (permalink / raw)
  To: gentoo-dev

It is an alias_target so "libudev" is anyways the correct way to do it.

Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
---
 sys-apps/systemd-utils/systemd-utils-254.10-r1.ebuild | 2 +-
 sys-apps/systemd-utils/systemd-utils-254.12.ebuild    | 2 +-
 sys-apps/systemd-utils/systemd-utils-254.13.ebuild    | 2 +-
 sys-apps/systemd-utils/systemd-utils-255.4.ebuild     | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys-apps/systemd-utils/systemd-utils-254.10-r1.ebuild b/sys-apps/systemd-utils/systemd-utils-254.10-r1.ebuild
index ca3697269cd2..b906b6110034 100644
--- a/sys-apps/systemd-utils/systemd-utils-254.10-r1.ebuild
+++ b/sys-apps/systemd-utils/systemd-utils-254.10-r1.ebuild
@@ -375,7 +375,7 @@ multilib_src_compile() {
 	fi
 	if use udev; then
 		targets+=(
-			udev:shared_library
+			libudev
 			src/libudev/libudev.pc
 		)
 		if use test; then
diff --git a/sys-apps/systemd-utils/systemd-utils-254.12.ebuild b/sys-apps/systemd-utils/systemd-utils-254.12.ebuild
index 9ba529076182..4e14021f3732 100644
--- a/sys-apps/systemd-utils/systemd-utils-254.12.ebuild
+++ b/sys-apps/systemd-utils/systemd-utils-254.12.ebuild
@@ -375,7 +375,7 @@ multilib_src_compile() {
 	fi
 	if use udev; then
 		targets+=(
-			udev:shared_library
+			libudev
 			src/libudev/libudev.pc
 		)
 		if use test; then
diff --git a/sys-apps/systemd-utils/systemd-utils-254.13.ebuild b/sys-apps/systemd-utils/systemd-utils-254.13.ebuild
index 9ba529076182..4e14021f3732 100644
--- a/sys-apps/systemd-utils/systemd-utils-254.13.ebuild
+++ b/sys-apps/systemd-utils/systemd-utils-254.13.ebuild
@@ -375,7 +375,7 @@ multilib_src_compile() {
 	fi
 	if use udev; then
 		targets+=(
-			udev:shared_library
+			libudev
 			src/libudev/libudev.pc
 		)
 		if use test; then
diff --git a/sys-apps/systemd-utils/systemd-utils-255.4.ebuild b/sys-apps/systemd-utils/systemd-utils-255.4.ebuild
index 4c64afbd80c1..ea1032f738dc 100644
--- a/sys-apps/systemd-utils/systemd-utils-255.4.ebuild
+++ b/sys-apps/systemd-utils/systemd-utils-255.4.ebuild
@@ -384,7 +384,7 @@ multilib_src_compile() {
 	fi
 	if use udev; then
 		targets+=(
-			udev:shared_library
+			libudev
 			src/libudev/libudev.pc
 		)
 		if use test; then
-- 
2.44.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [gentoo-dev] [PATCH 3/3] dev-db/postgresql: pass in a ninja-compatible value to meson_src_compile
  2024-06-02 19:43 ` [gentoo-dev] [PATCH 0/3] meson.eclass: corresponding updates to ebuilds Eli Schwartz
  2024-06-02 19:43   ` [gentoo-dev] [PATCH 1/3] net-libs/libsrtp: pass in a ninja-compatible value to meson_src_compile Eli Schwartz
  2024-06-02 19:43   ` [gentoo-dev] [PATCH 2/3] sys-apps/systemd-utils: " Eli Schwartz
@ 2024-06-02 19:43   ` Eli Schwartz
  2 siblings, 0 replies; 5+ messages in thread
From: Eli Schwartz @ 2024-06-02 19:43 UTC (permalink / raw)
  To: gentoo-dev

Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
---
 dev-db/postgresql/postgresql-9999.ebuild | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dev-db/postgresql/postgresql-9999.ebuild b/dev-db/postgresql/postgresql-9999.ebuild
index e5eaa285027b..3f53c730579f 100644
--- a/dev-db/postgresql/postgresql-9999.ebuild
+++ b/dev-db/postgresql/postgresql-9999.ebuild
@@ -199,7 +199,7 @@ src_compile() {
 		# Generates both manpages and HTML documentation.
 		meson_src_compile docs
 	else
-		meson_src_compile man:alias
+		meson_src_compile man
 	fi
 }
 
-- 
2.44.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-06-02 19:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-02 19:08 [gentoo-dev] [PATCH] meson.eclass: stop using the incomparably broken "meson compile" Eli Schwartz
2024-06-02 19:43 ` [gentoo-dev] [PATCH 0/3] meson.eclass: corresponding updates to ebuilds Eli Schwartz
2024-06-02 19:43   ` [gentoo-dev] [PATCH 1/3] net-libs/libsrtp: pass in a ninja-compatible value to meson_src_compile Eli Schwartz
2024-06-02 19:43   ` [gentoo-dev] [PATCH 2/3] sys-apps/systemd-utils: " Eli Schwartz
2024-06-02 19:43   ` [gentoo-dev] [PATCH 3/3] dev-db/postgresql: " Eli Schwartz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox