Skip to content

external project: invokes make with -j$(nproc), incompatible with jobservers #16020

Description

@thesamesam

If meson is already running under a jobserver (in MAKEFLAGS) when an external project is built, the make call will ignore it, as it always passes the equivalent of -j$(nproc) instead:

if self.supports_jobs_flag():
make_cmd.append(f'-j{determine_worker_count()}')

We should check if MAKEFLAGS (and perhaps GNUMAKEFLAGS to not make the problem worse, though ninja and some others won't look at that) contains --jobserver-auth before adding -j ourselves.

You can see this with e.g (assuming the test fails to make it clear):

$ export MAKEFLAGS="--jobserver-auth=fifo:/dev/steve
$  ./run_single_test.py "./test cases/common/230 external project"
[...]

Build targets in project: 3

test external project undefined

  User defined options
    backend: ninja
    libdir : lib
    prefix : /usr

Found ninja-1.13.2 at /usr/bin/ninja
ninja: Jobserver mode detected: -j32 -l32 --jobserver-auth=fifo:/dev/steve
ninja explain: deps for 'libsomelib.so.p/func.c.o' are missing
[1/6] Compiling C object libsomelib.so.p/func.c.o
ninja explain: libsomelib.so.p/func.c.o is dirty
[2/6] Linking target libsomelib.so
ninja explain: deps for 'libfoo/libfoo.stamp' are missing
ninja explain: libsomelib.so is dirty
[2/6] Generating external project libfoo/libfoo
make: warning: -j32 forced in submake: resetting jobserver mode. 
ninja explain: libsomelib.so is dirty

One can reproduce this with a make invocation that just runs meson too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions