Skip to content

Commit 216e96c

Browse files
authored
Merge pull request #7592 from NlightNFotis/fix_name_collisions_static_library
Rename object files so that we don't have collisions between different
2 parents cf084e6 + ed8b841 commit 216e96c

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/libcprover-cpp/add_dependencies.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,44 @@ DESTINATION=$1
1515
shift
1616
LIB_LIST=$@
1717

18+
# We need to do the following renaming of object files because of translation
19+
# unit name collisions which affect linking against the final artefact. For more
20+
# details, please look at https://github.com/diffblue/cbmc/issues/7586 .
21+
22+
# Create a temporary folder for this script to work in.
23+
rm -rf add_dependencies_tmp
24+
mkdir add_dependencies_tmp
25+
cd add_dependencies_tmp
26+
27+
# The full path of the current "root" directory
28+
WORKING_DIR=$(pwd)
29+
1830
# For each library to add:
1931
for lib in ${LIB_LIST}; do
32+
# We will unpack and rename all .o of dependent libraries marking them with
33+
# their library name to avoid clashes.
34+
LIBNAME=$(basename ${lib} .a)
35+
36+
# Remove previous unpacked folders and create a new fresh one to work in.
37+
rm -rf ${LIBNAME}
38+
mkdir ${LIBNAME}
39+
cd ${LIBNAME}
40+
2041
# Unpack the library
2142
${AR_COMMAND} -x ${lib}
43+
44+
# Rename all object files in the library prepending "${LIBNAME}_" to avoid
45+
# clashes, and move to the "root" folder.
46+
for obj in *.o; do
47+
mv ${obj} "${WORKING_DIR}/${LIBNAME}_${obj}"
48+
done
49+
50+
# Move back to the working directory.
51+
cd "${WORKING_DIR}"
2252
done
2353

2454
# Append all the unpacked files to the destination library
2555
${AR_COMMAND} -rcs ${DESTINATION} *.o
56+
57+
# TODO: See if we need to do some cleanup in order to save cache space for
58+
# Github actions runners.

0 commit comments

Comments
 (0)