Skip to content

Commit ec7522d

Browse files
rossburtonrpurdie
authored andcommitted
classes/cargo_common: ensure B is clean
The cargo class defaults to out-of-tree builds in WORKDIR/build, but at no point was that directory cleaned. This causes problems with the rust standard library recipe (libstd-rs) which installs manually with cp, so rebuilds can be contaminated with the contents of previous builds. I believe that post-release we should switch cargo.bbclass to mandating out-of-tree builds to reduce the complexity, but for now in out-of-tree builds we can just delete the ${B}/target directory. Note that we use ${B}/target because there at least were reasons to use that name[1], it is unclear if these limitations still hold. We can't simply clean ${B} because that will break recipes that use cargo and something else to build, for example librsvg. [1] rust-lang/cargo#1657 Signed-off-by: Ross Burton <[email protected]> Signed-off-by: Richard Purdie <[email protected]>
1 parent f0f440a commit ec7522d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

meta/classes-recipe/cargo_common.bbclass

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ cargo_common_do_configure () {
110110
# Put build output in build directory preferred by bitbake instead of
111111
# inside source directory unless they are the same
112112
if [ "${B}" != "${S}" ]; then
113+
# We should consider mandating out-of-tree builds and just using [cleandirs]
114+
rm -rf ${B}/target
115+
mkdir -p ${B}
116+
113117
cat <<- EOF >> ${CARGO_HOME}/config.toml
114118

115119
[build]

0 commit comments

Comments
 (0)