Fix static linking with minimap2 subproject #11
Closed
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.
Attempting to build pbmm2 statically fails with
This is because both source files use
KSORT_INIT
with the samename
, namelyheap
.https://github.com/lh3/minimap2/blob/1739a260fb044eded97b3271cd5204c79363fa76/map.c#L80
pbmm2/third-party/bam_sort.c
Line 203 in 1fe348e
Some klib facilities (e.g.
KHASH_INIT2
andKHASH_DECLARE
) allow code to specifystatic
and/orextern
to control how the generated klib functions might be shared with or hidden from other translation units. Others, likeKSORT_INIT
, do not and don't even usestatic
, and the onus is on the programmer to ensure that the names are different and they don't clash. (As is usual for klib, this is under-documented…)This patch shows an example of renaming one of them so they're different. With this, pbmm2 can be built with the non-system libraries linked statically:
Of course a good citizen would leave HTSlib linked dynamically so it can be shared and updated as appropriate, but this would be useful for the other components that don't change independently.