Skip to content

Commit d42faa3

Browse files
committed
rn20: musl libc vs NO_REGEX / REG_STARTEND
Add description of discussion about Git no longer working with musl libc's regex implementation out of the box (without setting `NO_REGEX=1` in build configuration).
1 parent e508bd8 commit d42faa3

File tree

1 file changed

+49
-2
lines changed

1 file changed

+49
-2
lines changed

rev_news/drafts/edition-20.md

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,56 @@ This edition covers what happened during the month of September 2016.
1717

1818
## Discussions
1919

20-
<!---
20+
2121
### General
22-
-->
22+
23+
* [Regression: git no longer works with musl libc's regex impl](https://public-inbox.org/git/[email protected]/)
24+
25+
Rich Felker complained that compiling Git with [musl libc](https://www.musl-libc.org/)
26+
no longer works out of the box (that is, without setting the `NO_REGEX`
27+
build configuration variable) after commit [2f895225](https://github.com/git/git/commit/2f8952250a84313b74f96abb7b035874854cf202).
28+
The proposed workaround unfortunately didn't work on Windows, as pointed
29+
out by Jeff King and Johannes Schindelin.
30+
31+
There was a bit of derail about which are main Git platforms, and whether
32+
Git code should be able to rely on POSIX features. Jakub Narębski reminded
33+
that [CodingGuidelines](https://github.com/git/git/blob/master/Documentation/CodingGuidelines#L4)
34+
specifically state that:
35+
36+
> - Most importantly, we never say "It's in POSIX; we'll happily
37+
> ignore your needs should your system not conform to it."
38+
> We live in the real world.
39+
>
40+
> - However, we often say "Let's stay away from that construct,
41+
> it's not even in POSIX".
42+
>
43+
> - In spite of the above two rules, we sometimes say "Although
44+
> this is not in POSIX, it (is so convenient | makes the code
45+
> much more readable | has other good characteristics) and
46+
> practically all the platforms we care about support it, so
47+
> let's use it".
48+
49+
The commit in question, making Git require to use regexp engine with
50+
`REG_STARTEND` support, while providing fallback implementation
51+
(turned on with `NO_REGEX`), matches 3rd point in the list above. This
52+
extension to `regexec()`, introduced by the NetBSD project, is present
53+
in all major regex implementation... though not in musl.
54+
55+
There was yet another proposed fix for the problem, namely adding
56+
padding so that end of mmap-ed file doesn't fall on the page boundary,
57+
if regex implementation doesn't support `REG_STARTEND`. One one hand,
58+
the workaround relied on undocumented (but sane) assumptions about
59+
operating system behavior, on the other hand it was faster than the
60+
workaround in original patch, that is copying contents to NUL-terminated
61+
buffer. Nevertheless, any workaround would mean additional code that
62+
needs to be maintained, and it was not accepted.
63+
64+
Also, it turned out that `configure` script detects if regex engine
65+
support `REG_STARTEND` and sets `NO_REGEX` if necessary, it was just
66+
badly described. It was [since corrected](https://github.com/git/git/commit/842a516cb02a53cf0291ff67ed6f8517966345c0).
67+
68+
Though Git doesn't yet set `NO_REGEX` automatically based on information
69+
from `uname`.
2370

2471

2572
### Reviews

0 commit comments

Comments
 (0)