From 5eafc37e95736508f7e44705b7ca4a1876c09e2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Sun, 1 Sep 2019 14:59:59 +0200 Subject: regex: make sure to link against PCRE2's regex functions PCRE2's header defines just the basic names but that means that we'll link against libc's version while using PCRE2's struct definitions, leading to crashes. To work around this, package maintainers have added prefixes to the exported functions so we can link against them. But the definitions in the header are still of the basic names so we need to tell the compiler/linker to replace these names when linking. --- src/posix_regex.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/posix_regex.h b/src/posix_regex.h index 421ffeba1..9b9ca94e8 100644 --- a/src/posix_regex.h +++ b/src/posix_regex.h @@ -37,8 +37,21 @@ #else +/* + * PCRE2's header defines just the basic names but that means that we'll link + * against libc's version while using PCRE2's struct definitions, leading to + * crashes. To work around this, package maintainers have added prefixes to the + * exported functions so we can link against them. + * + * But the definitions in the header are still of the basic names so we need to + * tell the compiler/linker to replace these names when linking. + */ # if defined(GIT_REGEX_PCRE2) # include +# pragma redefine_extname regerror PCRE2regerror +# pragma redefine_extname regexec PCRE2regexec +# pragma redefine_extname regfree PCRE2regfree +# pragma redefine_extname regcomp PCRE2regcomp # elif defined(GIT_REGEX_PCRE) # include # else -- cgit v1.2.1