bugmake - Bugs: bug #62206, Fix % substitution in pattern...

 
 

bug #62206: Fix % substitution in pattern rules.

Submitter:  Dmitry Goncharov <dgoncharov>
Submitted:  Mon 21 Mar 2022 01:04:05 AM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Fixed Privacy:  Public
Assigned to:  psmith Open/Closed:  Closed
Component Version:  4.4 Operating System:  Any
Fixed Release:  4.4 Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 24 Apr 2022 10:09:12 PM UTC, comment #5: 

Fixed, thanks!

Paul D. Smith <psmith>
Group administrator
Mon 21 Mar 2022 03:32:00 PM UTC, comment #4: 

Such a workaround with 2 rules could be something like


.SECONDEXPANSION:
all: lib/hello.o hello.o
%.o: 3$$*.c; $(info $@ from $<)
lib/%.o: lib/3$$*.c; $(info $@ from $<)


Dmitry Goncharov <dgoncharov>
Mon 21 Mar 2022 03:16:26 PM UTC, comment #3: 


> What I usually do is recommend people use $$* instead of % in secondary expansion expressions like this as it's more clear and less confusing, and ends up being the same result.


There are situations where the difference between % and $$* matters.

For example, let us say there are files 3hello.c and lib/3hello.c and the following makefile.



.SECONDEXPANSION:
all: lib/hello.o hello.o
%.o: 3%.c; $(info $@ from $<)



This makefile allows to build both hello.o from 3hello.c and lib/hello.o from lib/3hello.c with a single rule.

It is possible to workaround this as well by using two rules lib/%.o: and %.o:. So, i was thinking maybe fixing this is not worth the effort. On the other hand, lots of users may not be familiar with make enough to figure this out. With this patch it just works.

Dmitry Goncharov <dgoncharov>
Mon 21 Mar 2022 12:58:51 PM UTC, comment #2: 

What I usually do is recommend people use $$* instead of % in secondary expansion expressions like this as it's more clear and less confusing, and ends up being the same result.

I'll look at this change.

Paul D. Smith <psmith>
Group administrator
Mon 21 Mar 2022 01:28:59 AM UTC, comment #1: 

Tested on linux, sun and aix, 64 and 32 bits.

Dmitry Goncharov <dgoncharov>
Mon 21 Mar 2022 01:04:05 AM UTC, original submission:  

Make fails to substitute % with the stem in prerequisites of pattern rules when second expansion is enabled.

E.g. given makefile


.SECONDEXPANSION:
all: hello.x
%.x: $$(wordlist 1, 99, %.1 %.2) $$(wordlist 1, 99, %.3 %.4); $(info $@ from $^)


make fails to substitute '%' with 'hello' in '%.2' and '%.4'.

Specifically, make substitutes the first % in each 'word', where 'word' is determined by get_next_word. In the example above, '$(wordlist 1, 99, %.1 %.2)' and '$(wordlist 1, 99, %.3 %.4)' are such 'words'.

Dmitry Goncharov <dgoncharov>

 

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

Attach Files:
   
   
Comment:
   

 

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)
  • -email is unavailable- added by dgoncharov (Submitted the item)
  •  

    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.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-04-24 psmith StatusNone Fixed
        Assigned toNone psmith
        Open/ClosedOpen Closed
        Fixed ReleaseNone 4.4
    2022-03-21 dgoncharov Attached File- Added sv62206_stem_substitution_in_pattern_rules_fix.diff, #53008
        Attached File- Added sv62206_stem_substitution_in_pattern_rules_test.diff, #53009

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code