bugmake - Bugs: bug #31248, .SECONDEXPANSION: Inconsistent...

 
 

bug #31248: .SECONDEXPANSION: Inconsistent expansion of glob patterns in pattern rule dependency lines

Submitter:  None
Submitted:  Mon 04 Oct 2010 10:43:47 PM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
Component Version:  3.82 Operating System:  Any
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 08 Jan 2023 07:32:57 PM UTC, comment #1: 

I've tested this with the latest GNU Make 4.4(.1).  I didn't really follow all the discussion of previous behaviors, but here is how things currently behave, which doesn't seem right to me:

Given the setup below, when run without second expansion:

$ make SEC=no
dir/foo.x from dir/foo.ybot

we can see that the directory prefix "dir/" is added to the pattern "%y*" before the glob is expanded, so that the expansion finds the pre-existing dir/foo.ybot.

However if we enable second expansion:

$ make SEC=yes
dir/foo.ytop
dir/foo.x from dir/foo.ytop

we can see that here, the pattern is replaced giving "foo.y*" and the glob is expanded before the directory prefix "dir/" is added, yielding foo.ytop which is then changed to "dir/foo.ytop".

Clearly the fact that these work differently is wrong.

As for which should happen, my preference would probably be to change the second expansion one to work like the no-second-expansion one, where first the directory prefix is handled then the glob expansion is done afterward.  Adding the directory prefix is part of expanding the pattern, and expanding the pattern should happen before the glob match.

Paul D. Smith <psmith>
Group administrator
Mon 04 Oct 2010 10:43:47 PM UTC, original submission:  

(The test case is at the end.)

In GNU Make 3.80, glob wildcards were not expanded in pattern dependency lines.  In 3.81 they were expanded, but sometimes in the wrong directory.  In 3.82, we get the 3.81 behavior when second expansion is triggered, and otherwise the 3.80 behavior.

Should glob expansion be suppressed for pattern dependency lines, as was historically the case, even after second expansion?  If not, then it may be best to prefix the stem directory before globbing, instead of after globbing.

Consider this makefile:

ifeq ($(SEC),yes)
.SECONDEXPANSION:
TRIGGER=$$(TRIGGER_SECOND_EXPANSION)
endif
all : dir/foo.x
%x : %y* $(TRIGGER) ; @echo '$@' from '$+'
foo.y% : ; @echo '$@'


(The "TRIGGER" stuff can be necessary to ensure that the second expansion code path is followed.)  Consider also this directory tree:

.
./foo.ytop
./Makefile
./dir
./dir/foo.ybot


Linux GNU Make 3.82 and 3.80 with no command line arguments (the historical behavior):

dir/foo.y*
dir/foo.x from dir/foo.y*


Linux GNU Make 3.82 with "SEC=yes" on the command line, and also 3.81 regardless of command line arguments:

dir/foo.ytop
dir/foo.x from dir/foo.ytop


Note that globbing matches "foo.y*" to "foo.ytop" in the top-level directory, even though GNU Make then prefixes "dir/".  If globbing is desired, then I think it would make more sense to match "dir/foo.y*" against "dir/foo.ybot".

(Thanks for reading this lengthy discussion.)

-- John Carey

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by psmith (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code