[bug #60036] Incorrect MAKEFLAGS after $(shell) function call

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[bug #60036] Incorrect MAKEFLAGS after $(shell) function call

Paul D. Smith
URL:
  <https://savannah.gnu.org/bugs/?60036>

                 Summary: Incorrect MAKEFLAGS after $(shell) function call
                 Project: make
            Submitted by: None
            Submitted on: Ср 10 фев 2021 19:33:22
                Severity: 3 - Normal
              Item Group: Bug
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
       Component Version: 4.3
        Operating System: MS Windows
           Fixed Release: None
           Triage Status: None

    _______________________________________________________

Details:

After recursive make call if top-level Makefile set -Otarget and sub-make has
$(shell) function call then MAKEFLAGS exposes all internal values hidden from
user (-j and --jobserver-auth for example). It leads to false warning message
as if -j option specified in Makefile.
It happens because $(shell) function handler invokes define_makeflags(1, 0):

1. define_makeflags()
2. prepare_mutex_handle_string()
3. sync_init()
4. setup_tmpfile()
5. output_start()
6. func_shell_base()

Looks like MAKEFLAGS variable takes its full contents too early. I'm not
familiar with make internals but does it really necessary to do output_start()
in func_shell_base()?

Example Makefile:

start_time := $(shell echo %time%)
MAKEFLAGS += --no-print-directory
MAKEFLAGS += --output-sync=target

.PHONY: all
all:
        $(MAKE) build-$@

.PHONY: build-all
build-all:
        @echo $@

Output of 'make -j8':

make build-all
make[1]: warning: -j8 forced in makefile: resetting jobserver mode.
build-all





    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?60036>

_______________________________________________
  Сообщение отправлено по Savannah
  https://savannah.gnu.org/


Reply | Threaded
Open this post in threaded view
|

[bug #60036] Incorrect MAKEFLAGS after $(shell) function call

Paul D. Smith
Follow-up Comment #1, bug #60036 (project make):

This issue isn't seen on Linux.  I think it must be related to the way the
jobserver mode is handled on Windows, which is different than Linux (on
Windows we use a shared semaphore).

Yes, it's necessary to call output_start() in func_shell_base() because the
shell function doesn't redirect stderr, so it can go to the output and get
mixed up.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?60036>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/