URL: <https://savannah.gnu.org/bugs/?64746>
Summary: Exponential Runtime in make 4.4.1 when export is used Group: make Submitter: tback Submitted: Wed 04 Oct 2023 09:31:42 PM UTC Severity: 3 - Normal Item Group: Bug Status: None Privacy: Public Assigned to: None Open/Closed: Open Discussion Lock: Any Component Version: 4.4.1 Operating System: POSIX-Based Fixed Release: None Triage Status: None _______________________________________________________ Follow-up Comments: ------------------------------------------------------- Date: Wed 04 Oct 2023 09:31:42 PM UTC By: Till Backhaus <tback> This is my first report here, I might lack the proper etiquette. I'm on fedora 38 which installs gnu-make 4.4.1. I'm reporting a regression related to the changed behavior of export: > * WARNING: Backward-incompatibility! > Previously makefile variables marked as export were not exported to commands > started by the $(shell ...) function. Now, all exported variables are > exported to $(shell ...). If this leads to recursion during expansion, then > for backward-compatibility the value from the original environment is used. > To detect this change search for 'shell-export' in the .FEATURES variable. This rather short Makefile shows exponential runtime depending on the number of variables. export VAR_1 ?= $(shell echo 1) VAR_2 ?= $(shell echo 2) VAR_3 ?= $(shell echo 3) VAR_4 ?= $(shell echo 4) VAR_5 ?= $(shell echo 5) VAR_6 ?= $(shell echo 6) VAR_7 ?= $(shell echo 7) foo: echo foo Runtime with 7 variables is ~20s on reasonably current hardware (AMD Ryzen 7 4750U): time make foo echo foo foo real 0m21.663s user 0m4.082s sys 0m18.027s make foo --debug=verbose GNU Make 4.4.1 Built for x86_64-redhat-linux-gnu Copyright (C) 1988-2023 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Reading makefiles... Reading makefile 'Makefile'... Updating makefiles.... Updating goal targets.... Considering target file 'foo'. File 'foo' does not exist. Finished prerequisites of target file 'foo'. Must remake target 'foo'. echo foo Makefile:7: not recursively expanding VAR_5 to export to shell function ... Makefile:4: not recursively expanding VAR_2 to export to shell function foo Successfully remade target file 'foo'. The number of expansions grows exponentially: I modified the Makefile to contain different numbers of variables and got an exponential number of suppressed expansions: make foo --debug=verbose | grep -c recurs 82201 Variables to Expansions: 1 var 1 2 vars 6 3 vars 33 4 vars 196 5 vars 1305 6 vars 9786 7 vars 82201 Best regards, Till _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?64746> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/