Fix exceeding command-line ar limit (#2834).

This commit is contained in:
Wilson Snyder 2021-03-13 15:09:10 -05:00
parent 9dcda6947d
commit 6a189a1f81
2 changed files with 18 additions and 12 deletions

View File

@ -8,6 +8,8 @@ The contributors that suggested a given feature are shown in []. Thanks!
**** Fix class unpacked-array compile error (#2774). [Iru Cai]
**** Fix exceeding command-line ar limit (#2834). [Yinan Xu]
* Verilator 4.200 2021-03-12

View File

@ -201,26 +201,30 @@ else
VK_OBJS += $(VK_FAST_OBJS) $(VK_SLOW_OBJS)
endif
# When archiving just objects (.o), single $(AR) run is enough.
# When merging objects (.o) and archives (.a), the following steps are taken.
fred.a: foo1.a foo2.a out.o
# When archiving just objects (.o), use single $(AR) run
# 1. Make .tmp file with list of objects so don't exceed commend line
# When merging objects (.o) and archives (.a) additionally:
# 1. Extract object files from .a
# 2. Create a new archive from extracted .o and given .o
%.a:
@echo "Archive $(AR) -cr $@ $^"
@if test $(words $(filter %.a,$^)) -eq 0; then \
$(AR) -cr $@ $^; \
$(RANLIB) $@; \
$(info Archive $(AR) -rcs $@ $^)
$(file >$@.tmp)
$(foreach L, $(filter-out %.a,$^), $(file >>$@.tmp, $L))
if test $(words $(filter %.a,$^)) -eq 0; then \
$(AR) -rcs $@ @$@.tmp; \
else \
$(RM) -rf $*__tmpdir; \
$(RM) -rf $@.tmpdir; \
for archive in $(filter %.a,$^); do \
mkdir -p $*__tmpdir/$$(basename $${archive}); \
cd $*__tmpdir/$$(basename $${archive}); \
mkdir -p $@.tmpdir/$$(basename $${archive}); \
cd $@.tmpdir/$$(basename $${archive}); \
$(AR) -x ../../$${archive}; \
cd ../..; \
done; \
$(AR) -cr $@ $(filter %.o,$^) $*__tmpdir/*/*.o; \
$(RM) -rf $*__tmpdir; \
fi
$(AR) -rcs $@ @$@.tmp $@.tmpdir/*/*.o; \
fi \
; $(RM) -rf $@.tmp $@.tmpdir
$(VM_PREFIX)__ALL.a: $(VK_OBJS) $(VM_HIER_LIBS)