Bug 8378 - archiver class is broken for gcc packages when using patched sources
Summary: archiver class is broken for gcc packages when using patched sources
Status: VERIFIED FIXED
Alias: None
Product: BitBake
Classification: Build System, Metadata & Runtime
Component: bitbake (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Medium+ normal
Target Milestone: 2.1 M1
Assignee: Alejandro Hernandez
QA Contact: Bogdan Alexandru Voiculescu
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2015-09-22 21:56 UTC by Alejandro Hernandez
Modified: 2016-01-06 14:40 UTC (History)
4 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alejandro Hernandez 2015-09-22 21:56:19 UTC
The archiver class is used to obtain the sources used to build the distribution, it has different options; see http://www.yoctoproject.org/docs/1.8/mega-manual/mega-manual.html#maintaining-open-source-license-compliance-during-your-products-lifecycle for more info.

When using:
ARCHIVER_MODE[src] = "patched"

to obtain the patched sources, we obtain an error like the following:

ERROR: Command Error: exit status: 1  Output:
Applying patch 0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch
patching file configure
Reversed (or previously applied) patch detected!  Assume -R? [n] 
Apply anyway? [n] 
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file configure.rej
Patch 0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch appears to be empty; applied
ERROR: Function failed: patch_do_patch

This simply states that bitbake tried to apply a patch, but that patch had already been applied so it skips it (which is good), but this still causes the task to fail, hence the build fails too.

This is caused because gcc packages use a shared directory for performance and space efficiency (http://www.yoctoproject.org/docs/1.8/mega-manual/mega-manual.html#structure-build-work-shared), now, since several packages use the same source, the first task to patch the source will patch it correctly and succeed, but the second one will find an already patched source and produce the error mentioned above.

I believe gcc packages were initially not supported by the archiver class for this same reason, it appears to me that using shared states to check whether or not the patches have already been applied is not an option (although I don't know much about SSTATES), since these refer to different tasks for different packages, another option would be to create a specific case to handle gcc packages, perhaps somehow check if the source is already patched and simply return, or do not support gcc packages on the archiver class at all.
Comment 2 Alejandro Hernandez 2015-09-30 20:44:36 UTC
My mistake, this wasn't fixed completely, working on it
Comment 3 Alejandro Hernandez 2015-10-07 19:43:41 UTC
This started causing errors with the kernel too, a race condition was created when using patched sources between kernel_configme and unpack_and_patch, producing errors during kernel configuration.

Also, as Richard Purdie noted, we don't need to have multiple identical gcc source tarballs.

I sent a patch to the ML fixing both these new issues along with the original one.
Comment 5 Bogdan Alexandru Voiculescu 2016-01-06 14:40:42 UTC
Verified on master 2cd061a29a94fdcdfec86732e6bcbb71c12c4afc