Skip to content

Commit e7d9652

Browse files
committed
download_libs: keep duplicate-named members when re-indexing msys2 libs
reindexMsys2StaticLibs extracted each archive with "ar x" into one directory and repacked it with "ar rcs". Same-named members overwrite each other on extraction, so the repacked libopencv_world.a lost 17 of its 512 objects (13 duplicate names, incl. core/src/parallel.cpp.o and core/src/tables.cpp.o) and the msys2 allAddonsExample link failed with undefined cv::parallel_for_ / cv::g_Saturate8u - even though the apothecary package itself is correct. Archives with duplicate member names now only get their symbol index rebuilt in place ("ar s" + ranlib), as apothecary does since #606.
1 parent 2465b3c commit e7d9652

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎scripts/dev/download_libs.sh‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,22 @@ reindexMsys2StaticLibs(){
285285
*.dll.a) continue ;;
286286
esac
287287
ARCHIVE_ABS="$(cd "$(dirname "$ARCHIVE")" && pwd)/$(basename "$ARCHIVE")"
288+
# "ar x" flattens members into one directory, so same-named objects (e.g.
289+
# OpenCV world's core/src/parallel.cpp.o and core/src/parallel/parallel.cpp.o)
290+
# overwrite each other and the repacked archive silently loses code
291+
# (undefined cv::parallel_for_ / g_Saturate8u). Only rebuild the symbol
292+
# index in place for those archives (same as apothecary #606).
293+
if [ -n "$("$AR_BIN" t "$ARCHIVE_ABS" 2>/dev/null | sort | uniq -d)" ]; then
294+
if "$AR_BIN" s "$ARCHIVE_ABS"; then
295+
if [ "$AR_KIND" != "llvm" ] && [ -n "$RANLIB_BIN" ]; then
296+
"$RANLIB_BIN" "$ARCHIVE_ABS" >/dev/null 2>&1 || true
297+
fi
298+
echo " reindexed in place [$ARCHIVE] (duplicate member names)"
299+
else
300+
echo " warning: could not reindex [$ARCHIVE] (linker may reject it)"
301+
fi
302+
continue
303+
fi
288304
TMPDIR=$(mktemp -d 2>/dev/null || mktemp -d -t ofar)
289305
if (
290306
cd "$TMPDIR" || exit 1

0 commit comments

Comments
 (0)