Skip to content

Commit 45fbdbe

Browse files
committed
Rename object files so that we don't have collisions between different
object files coming from different projects. Fixes #7586 Co-authored-by: Enrico Steffinlongo "[email protected]" Co-authored-by: Fotis Koutoulakis "[email protected]"
1 parent 3cf1ade commit 45fbdbe

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/libcprover-cpp/add_dependencies.sh

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,36 @@ 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+
1822
# For each library to add:
1923
for lib in ${LIB_LIST}; do
24+
# We will unpack and rename all .o of dependent libraries marking them with
25+
# their library name to avoid clashes.
26+
LIBNAME=$(basename ${lib} .a)
27+
28+
# Remove previous unpacked folders and create a new fresh one to work in.
29+
rm -rf ${LIBNAME}
30+
mkdir ${LIBNAME}
31+
cd ${LIBNAME}
32+
2033
# Unpack the library
2134
${AR_COMMAND} -x ${lib}
35+
36+
# Rename all object file in the library prepending "${LIBNAME}_" to avoid
37+
# clashes.
38+
for obj in *.o; do
39+
mv ${obj} "${LIBNAME}_${obj}"
40+
done
41+
42+
# Move back to the working directory.
43+
cd ..
2244
done
2345

2446
# Append all the unpacked files to the destination library
25-
${AR_COMMAND} -rcs ${DESTINATION} *.o
47+
${AR_COMMAND} -rcs ${DESTINATION} **/*.o
48+
49+
# TODO: See if we need to do some cleanup in order to save cache space for
50+
# Github actions runners.

0 commit comments

Comments
 (0)