Fix avoid linking libpcre
when unused
#14891
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As reported by galapagdos on the Crystal forum, crystal always links libpcre/libpcre2 even if you don not use regular expressions, and calls the function
pcre2_config_8
.crystal build hello_world.cr ldd hello_world # libpcre2 is linked even if regular expressions are not used
This occurs because
begin
is used inclass_getter
in the Regex::PCRE module (src/regex/pcre.cr).I searched the Crystal code with grep command and could not find any other uses of
begin
inclass_getters
.supplement
According to
crystal tool expand
, the macro is expanded as below.Before:
After:
Could you please review if it's ok not to use
begin
here?Thank you.
Resolves #5379