Slide 1

Slide 1 text

Open Build Service (OBS) Cross-Architecture Build Capabilities

Slide 2

Slide 2 text

Classic Cross Building

Slide 3

Slide 3 text

3 Classic Cross Compile Is • Building a software on architecture A for architecture B. • Used when architecture B is not suitable for developing because: ‒ Slow CPU ‒ Low memory & storage ‒ Convenience: Can't be used as developer workstation ‒ Hardware device not available (yet)

Slide 4

Slide 4 text

4 Classic Cross Compile is Embedded developers are used to do • ./configure –host=armv7l-suse-linux or • rpmbuild --target=armv8l-suse-linux on their ia32 or x86_64 workstation

Slide 5

Slide 5 text

5 Advantages • Very fast results • Work can be done on all kinds of hardware.

Slide 6

Slide 6 text

6 Disadvantages • Sources need to support cross compile • Need to handle dependencies for two architectures • Build result may differ from native compile • No real-life testing during development • No test suite runs usually

Slide 7

Slide 7 text

Emulated Build

Slide 8

Slide 8 text

8 Emulated System • Full emulation (booting target kernel) is usually too slow and not flexible enough. • User land emulation using Qemu: ‒ Install qemu-$ARCH binary for running emulated binaries ‒ Register $ARCH binaries to be handled via qemu-$ARCH binary. The OBS build script can do this during VM setup.

Slide 9

Slide 9 text

9 Setup openSUSE:Factory openSUSE:Factory:ARM x86_64 repository x86_64 repository qemu-linux-user.rpm aggregate armv7l repository Fetch and update rpm via _aggregate ExportFilter to arm repos Project Config ExportFilter: qemu* . armv7l Preinstall: qemu-linux-user

Slide 10

Slide 10 text

10 Advantages • No changes in package sources are needed (almost) • Using it in OBS allows every developer to build and run their tests for the target architectures without the need of real hardware. => This makes it possible at all to do maintenance updates for the openSUSE community for arm.

Slide 11

Slide 11 text

11 Disadvantages • Qemu bugs or missing support may have an influence to the build result. => Lots if qemu fixes during 12.2:ARM development. Qemu thread handling problems are workarounded • Emulation overhead may slow down build process too much. • We rely currently on our patched qemu using qemu- $ARCH-binfmt handler, to be pushed upstream.

Slide 12

Slide 12 text

12 Example • OpenSUSE:12.2:ARM is using this setup. • Want to see how it works ? osc build \ –alternative-project=openSUSE:Factory:ARM \ standard armv7l $YOUR_FILE.spec

Slide 13

Slide 13 text

Tricks for speed improvements

Slide 14

Slide 14 text

14 The icecream/distcc trick • Use native hardware or full emulation for building • Use compiler backend on another, faster host. • Remote host can have any architecture • Use icecream or distcc to distribute the job • ADVANTAGE: scales very very great • DISADVANTAGE: hard to make it secure • Code to sync build environments exists SUSE-

Slide 15

Slide 15 text

15 Native binaries in qemu-linux-user • Use some selected binaries for native architecture during qemu-linux-user emulation. • Building an acceleration package which repackages binaries and needed libs into other directory • ADVANTAGE: Best possible performance • DISADVANTAGES: ‒ risk that tool is arch dependent ‒ source revision needs to be kept in sync

Slide 16

Slide 16 text

Future: Issues To Fix In OBS

Slide 17

Slide 17 text

17 Open Issues • Qemu-linux-user thread handling is not reliable. • kiwi qemu build works only with workaround atm

Slide 18

Slide 18 text

Work in Progress by B1-Systems: Transparent Cross Building

Slide 19

Slide 19 text

19 Transparent Cross Building • Goal: ‒ Do classic cross builds in OBS ‒ Use toolchain from host architecture (speedup, no emulation) ‒ Use the same spec-file for host and target architecture builds ‒ Avoid faking/emulation of build steps where reasonable/possible

Slide 20

Slide 20 text

20 Advantages • Very fast results • Work can be done on all kinds of hardware.

Slide 21

Slide 21 text

21 Disadvantages • Sources need to support cross compile • Need to handle dependencies for two architectures • Build result may differ from native compile • No real-life testing during development • No test suite runs usually

Slide 22

Slide 22 text

22 Transparent Cross Building • Not the intended Goal: ‒ Build existing distribution without any modification

Slide 23

Slide 23 text

23 Transparent Cross Building • OBS scheduler need to take multiple architecture in account • Toolchain BuildRequires get substituted with packages for the host architecture • Setup separated /sysroot for target architecture(s): ‒ /opt/cross-%_target_cpu/ ‒ With separated package database • Exploit cross-compiling support of build environments: ‒ Autotools, CMake, …

Slide 24

Slide 24 text

24 Transparent Cross Building • What gets address so it get “transparent”? ‒ Some BuildRequires: need to get substituted with Host Arch packages or cross-compilers ‒ %check section gets NOOP in the first round ‒ Common build environment calls in spec files need to make use of common packaging macros: ‒ %configure ‒ %cmake ‒ … • Goal: use the same build spec file ‒ Move arch conditionals to the project config

Slide 25

Slide 25 text

25 Transparent Cross Building • Is this the best solution for me? ‒ Do you have enough time/resources to package your entire project/product yourself? ‒ Are you willing to fix a lot of packages which are not aware of cross building? ‒ Emulated cross builds are not fast enough for your packages/projects? • If all of above applies, this might be the right solution • Otherwise emulated or other OBS cross build might be the right thing for you

Slide 26

Slide 26 text

26 Transparent Cross Building • First round: ‒ Initial support to make scheduler aware of multiple architectures ‒ Enable obs-build to setup separated /sysroot ‒ … and do classic cross builds • Later: ‒ Optimize scheduler for taking multiple architectures in account ‒ First round: requires that the entire toolchain of host arch is build ‒ Make some use of binfmt Magic ‒ invoke qemu-$ARCH to run %check or other things ‒ But use as much host toolchain as possible

Slide 27

Slide 27 text

Demonstration

Slide 28

Slide 28 text

Thank you. 28 Learn more about the Open Build Service www.openbuildservice.org

Slide 29

Slide 29 text

No content