Skip to content

Commit 6115c25

Browse files
committed
fix: last --jobserver-auth wins
From the GNU make manual[^1]: > Be aware that the `MAKEFLAGS` variable may contain multiple > instances of the `--jobserver-auth=` option. > Only the last instance is relevant. Hence this commit makes it so. With this commit, `--jobserver-auth` also takes precedence over `--jobserver-fds`, even when `--jobserver-fds` is the last instance of these flags. This is made intentionally since `--jobserver-fds` was an undocumented internal-only flag before `--jobserver-auth` made public, according to this announcement[^2]. [^1]: https://www.gnu.org/software/make/manual/make.html#Job-Slots [^2]: https://lists.gnu.org/archive/html/info-gnu/2016-05/msg00013.html
1 parent 09d0d01 commit 6115c25

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -585,9 +585,9 @@ impl HelperState {
585585
}
586586

587587
fn find_jobserver_auth(var: &str) -> Option<(&str, usize)> {
588-
["--jobserver-fds=", "--jobserver-auth="]
588+
["--jobserver-auth=", "--jobserver-fds="]
589589
.iter()
590-
.map(|&arg| var.find(arg).map(|pos| (arg, pos)))
590+
.map(|&arg| var.rfind(arg).map(|pos| (arg, pos)))
591591
.find_map(|pos| pos)
592592
}
593593

@@ -603,19 +603,19 @@ fn test_find_jobserver_auth() {
603603
let cases = [
604604
(
605605
"--jobserver-auth= --jobserver-auth=",
606-
("--jobserver-auth=", 0),
606+
("--jobserver-auth=", 18),
607607
),
608608
(
609609
"--jobserver-fds= --jobserver-fds=",
610-
("--jobserver-fds=", 0usize),
610+
("--jobserver-fds=", 17),
611611
),
612612
(
613613
"--jobserver-auth= --jobserver-fds= --jobserver-auth=",
614-
("--jobserver-fds=", 18),
614+
("--jobserver-auth=", 35),
615615
),
616616
(
617617
"--jobserver-fds= --jobserver-auth= --jobserver-fds=",
618-
("--jobserver-fds=", 0),
618+
("--jobserver-auth=", 17),
619619
),
620620
];
621621
for (var, expected) in cases {

0 commit comments

Comments
 (0)