>Synopsis:      the -q switch to make has no effect in "compatibility mode" 
>which is the default
>Category:      user
>Environment:
        System      : OpenBSD 6.3
        Details     : OpenBSD 6.3-current (GENERIC.MP) #192: Sun Apr 15 
23:26:13 MDT 2018
                         
[email protected]:/usr/src/sys/arch/amd64/compile/GENERIC.MP

        Architecture: OpenBSD.amd64
        Machine     : amd64
>Description:
        By default, make(1) operates in compat mode which builds targets 
sequentially,
        implemented in the function Compat_Run (compat.c). When -j is passed,
        Make_Run (make.c) is used instead.  The latter returns a boolean 
indicating
        whether any work was or would have been done. Compat_Run on the other 
hand
        does not return this information. As a result, the -q switch, used 
without -j,
        does not work as expected.
>How-To-Repeat:
        $ echo 'int main(void) {return 0;}' > /tmp/hello.c
        $ make /tmp/hello
        cc -O2 -pipe    -o /tmp/hello /tmp/hello.c 
        $ make -q /tmp/hello; echo $?       # should print 0
        `/tmp/hello' is up to date.
        1
>Fix:
        As a workaround, passing -j1 to make disables compat mode and behaves
        correctly.

        $ make -j1 -q /tmp/hello; echo $?
        0

        The following patch does essentially the same, disabling compat mode 
when
        -q is given. Rationale for doing it this way instead of returning the
        necessary information from Compat_Run:

        (a) The change is much simpler.
        (b) In query (-q) mode, no work is actually performed, so parallel and
            compat mode should be equivalent. Confirm?

        --- usr.bin/make/main.c 20 Apr 2017 03:04:11 -0000      1.122
        +++ usr.bin/make/main.c 10 Jun 2018 19:51:42 -0000
        @@ -719,8 +719,10 @@ main(int argc, char **argv)
         
                        /*
                         * Be compatible if user did not specify -j
        +        * Also do not enter compatibility mode if user gave -q 
(query), which
        +        * Compat_Run does not support
                         */
        -       if (!forceJobs)
        +       if (!forceJobs && !queryFlag)
                                        compatMake = true;
         
                        /* And set up everything for sub-makes */

Reply via email to