Comment 1 for bug 2002076

Revision history for this message
Shengjing Zhu (zhsj) wrote :

$bf->strip first split its input (here is `-ffat-lto-objects -flto=auto`), then use for loop to strip every flag.

```
    my ($self, $flag, $value, $src, $maint) = @_;
    foreach my $tostrip (split(/\s+/, $value)) {
        next unless length $tostrip;
        $self->{flags}->{$flag} =~ s/(^|\s+)\Q$tostrip\E(\s+|$)/ /g;
    }

```

It does use `g` flag in regex, (maybe want to strip all duplicated flag?)

In first loop, for `-ffat-lto-objects`, it does strip two `-ffat-lto-objects`. Then the flag becomes `-flto=auto -flto=auto`.

Then in second loop, it stops working. Because there's only one space between two `-flto=auto`. However the regex expects space before and after one token. So it only strips one `-flto=auto`.

See https://regex101.com/r/AgDMzv/1 for regex debug.