SlideShare a Scribd company logo
1 of 15
Download to read offline
AOSP Toolchains
Bernhard “Bero” Rosenkränzer
ENGINEERS AND DEVICES
WORKING TOGETHER
Overview of current work
● Making AOSP master userspace build with gcc (6.3 and pre-7) again
○ Still building gcc based AOSP toolchains from TCWG’s releases every month
○ Early testing with gcc 7 snapshots -- gcc 7 release expected soon
● Making the kernel build with Clang (4.0)
○ Target kernels: 4.4-HiKey, 4.9-HiKey, Mainline
● CI efforts: Testing AOSP daily builds with clang daily builds
● To be done: Investigate use of the LLD linker
ENGINEERS AND DEVICES
WORKING TOGETHER
Reversing the world: Building AOSP with gcc, kernel with clang
● Why?
○ Different compilers show different warnings - both can be useful
○ Can’t do meaningful comparison of compilers if there’s only one option
ENGINEERS AND DEVICES
WORKING TOGETHER
Kernel with clang status
● Done for HiKey 4.4, HiKey 4.9 and Mainline post-4.10 kernels
● HiKey works, no known problems that matter right now
○ Compile issues in ARMv8.1-a specific code (for which the hardware doesn’t exist yet):
Makefiles force a number of gcc specific compiler flags that don’t have a direct equivalent in
clang (and clang developers oppose adding them).
● Mainline kernel fails to boot during early-bootup on some x86 hardware when
built with clang
● We’re down to 26 needed patches, 19 of which are relevant for Linaro work (3
are in x86 code, 4 in MIPS code)
ENGINEERS AND DEVICES
WORKING TOGETHER
Interesting problems getting the kernel to build with clang
● Clang is much more picky about inline assembly
-fno-integrated-as helps a lot, but even when not using the integrated
as, clang runs syntax checks.
This breaks the kernel’s abuse of inline assembly to generate asm offset tables
(see include/linux/kbuild.h, scripts/mod/Makefile -- use of asm
statements to generate files that will be processed with sed rather than as) .
● Solution: Still use inline assembly to generate the offset tables - but make the
output file valid (even if unused) assembly code: It becomes a file full of asm
comments.
● Clang is also more picky about using the right constraints and size-specific
instructions (e.g. mulq as opposed to plain mul on x86)
ENGINEERS AND DEVICES
WORKING TOGETHER
Interesting problems getting the kernel to build with clang
● Reliance on gcc extensions in some functions:
○ Nested functions
○ Variable-length arrays in structs
○ __attribute__((externally_visible))
○ Removal of references to functions called from unreachable code
● EFI libstub: Mix of code that must be PIC and code that must not be PIC
○ It’s not yet 100% clear whether the code works with gcc by accident or clang is doing
something wrong, but it’s looking more like it works with gcc by accident and a future gcc
version may expose the same problem.
● gcc plugins for code analysis (obviously) don’t work with clang - implementing
equivalent plugins will probably not be too difficult, but will such an effort be
accepted upstream?
ENGINEERS AND DEVICES
WORKING TOGETHER
Interesting problems getting the kernel to build with clang
● The kernel is still C89 code (and enforcing -std=gnu89)
○ Clang supports C89, but has defaulted to C99 and newer for a long time. C89 support in clang
has not received the same amount of testing as C99 or C11 (or C++14) mode, and may result in
obscure bugs or missing optimizations
○ Moving the kernel to C11 (or at least C99) may be a good idea even when not thinking about
clang (a lot of kernel code already uses C99 initializers and other C99 functions that are
available in gnu89 as extensions to C89)
○ gcc no longer defaults to C89 either
ENGINEERS AND DEVICES
WORKING TOGETHER
AOSP with gcc status
● AOSP master built with gcc 6.3 in January, but upstream changes make new
patches necessary.
● ABI problem: gcc -std=gnu++14 emits calls to __cxa_throw_bad_array,
which doesn’t exist in compiler-rt (upstream bug 25022512) -- but code has
moved on to require C++14 language features
● gcc 7 is still a moving target and used to error out a lot, but it’s getting ready.
Not many additional changes to AOSP needed.
ENGINEERS AND DEVICES
WORKING TOGETHER
Interesting problems getting AOSP to build with gcc
● __attribute__((unused)) is for functions only in gcc -- in clang, it can
also be used for struct members.
○ (may make sense to implement this in gcc)
● gcc warns (or errors out with -Werror) when doing an extra check for a
pointer being NULL when passing a parameter declared
__attribute__((nonnull))
ENGINEERS AND DEVICES
WORKING TOGETHER
Interesting problems getting AOSP to build with gcc
● gcc now warns about bogus indentation (error with -Werror):
for (i=0;i<=jk;i++) {
for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw;
}
○ This may be nice to have in clang…
● gcc is more picky about potentially reaching the end of a non-void function
without returning a value
● On the other hand, only clang thinks there’s something wrong with
void doSomething(char a[10]) {
if(strncmp(a, “1234567890”, sizeof(a)))
something();
}
ENGINEERS AND DEVICES
WORKING TOGETHER
Current CI efforts
● Nightly builds of clang master
● On success, nightly builds of AOSP master with the clang master build
○ Need to apply a minor patch set to AOSP master: mostly about tuning compiler flags and
bypassing newly added error diagnostics
● On success, boot-up test on LAVA Hikey
● Building gcc based AOSP toolchains (with regular binutils updates) with every
TCWG gcc release
ENGINEERS AND DEVICES
WORKING TOGETHER
Future plan: Building AOSP on aarch64
● aarch64 machines are getting strong enough to replace x86 machines
● Step 1: Build AOSP on regular Linux aarch64 hosts
● Step 2: Build AOSP on AOSP -- why put all those 8+ cores on modern Android
devices to waste? Devices like Pixel C could be a good native development
tool, and a startup in France seems to be working on a “plug your phone into
this docking station to make it your desktop” type device.
ENGINEERS AND DEVICES
WORKING TOGETHER
Future plan: LLD
● LLD is a new linker coming out of the LLVM project, replacing the BFD linker
and the gold linker from traditional binutils
● LLVM 4.0 comes with the first version of LLD that is usable
○ Can be used to build most components of a Linux system
○ Patchset to make the kernel build with LLD is available, but needs some more work
● LLD should still be considered experimental, but may well be ready in time for
O based releases
○ Currently missing a couple of --fix-cortex-a*-* workarounds for processor errata known to affect
AOSP under some conditions
Questions?
Ask now, or mail bero@linaro.org
#BUD17
For further information: www.linaro.org
BUD17 keynotes and videos on: connect.linaro.org
Thank You
#BUD17
For further information: www.linaro.org
BUD17 keynotes and videos on: connect.linaro.org

More Related Content

More from Linaro

It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...Linaro
 
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...Linaro
 
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...Linaro
 
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...Linaro
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineLinaro
 
HKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening KeynoteHKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening KeynoteLinaro
 
HKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP WorkshopHKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP WorkshopLinaro
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineLinaro
 
HKG18-315 - Why the ecosystem is a wonderful thing, warts and all
HKG18-315 - Why the ecosystem is a wonderful thing, warts and allHKG18-315 - Why the ecosystem is a wonderful thing, warts and all
HKG18-315 - Why the ecosystem is a wonderful thing, warts and allLinaro
 
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse HypervisorHKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse HypervisorLinaro
 
HKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMUHKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMULinaro
 
HKG18-113- Secure Data Path work with i.MX8M
HKG18-113- Secure Data Path work with i.MX8MHKG18-113- Secure Data Path work with i.MX8M
HKG18-113- Secure Data Path work with i.MX8MLinaro
 
HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation Linaro
 
HKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted bootHKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted bootLinaro
 
HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...
HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...
HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...Linaro
 
HKG18-317 - Arm Server Ready Program
HKG18-317 - Arm Server Ready ProgramHKG18-317 - Arm Server Ready Program
HKG18-317 - Arm Server Ready ProgramLinaro
 
HKG18-312 - CMSIS-NN
HKG18-312 - CMSIS-NNHKG18-312 - CMSIS-NN
HKG18-312 - CMSIS-NNLinaro
 
HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...
HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...
HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...Linaro
 
HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...
HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...
HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...Linaro
 
HKG18-212 - Trusted Firmware M: Introduction
HKG18-212 - Trusted Firmware M: IntroductionHKG18-212 - Trusted Firmware M: Introduction
HKG18-212 - Trusted Firmware M: IntroductionLinaro
 

More from Linaro (20)

It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
 
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
 
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
 
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
 
HKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening KeynoteHKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening Keynote
 
HKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP WorkshopHKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP Workshop
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
 
HKG18-315 - Why the ecosystem is a wonderful thing, warts and all
HKG18-315 - Why the ecosystem is a wonderful thing, warts and allHKG18-315 - Why the ecosystem is a wonderful thing, warts and all
HKG18-315 - Why the ecosystem is a wonderful thing, warts and all
 
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse HypervisorHKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
 
HKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMUHKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMU
 
HKG18-113- Secure Data Path work with i.MX8M
HKG18-113- Secure Data Path work with i.MX8MHKG18-113- Secure Data Path work with i.MX8M
HKG18-113- Secure Data Path work with i.MX8M
 
HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation
 
HKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted bootHKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted boot
 
HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...
HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...
HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...
 
HKG18-317 - Arm Server Ready Program
HKG18-317 - Arm Server Ready ProgramHKG18-317 - Arm Server Ready Program
HKG18-317 - Arm Server Ready Program
 
HKG18-312 - CMSIS-NN
HKG18-312 - CMSIS-NNHKG18-312 - CMSIS-NN
HKG18-312 - CMSIS-NN
 
HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...
HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...
HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...
 
HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...
HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...
HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...
 
HKG18-212 - Trusted Firmware M: Introduction
HKG18-212 - Trusted Firmware M: IntroductionHKG18-212 - Trusted Firmware M: Introduction
HKG18-212 - Trusted Firmware M: Introduction
 

Recently uploaded

Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 

Recently uploaded (20)

DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 

BUD17-202: AOSP Toolchains

  • 2. ENGINEERS AND DEVICES WORKING TOGETHER Overview of current work ● Making AOSP master userspace build with gcc (6.3 and pre-7) again ○ Still building gcc based AOSP toolchains from TCWG’s releases every month ○ Early testing with gcc 7 snapshots -- gcc 7 release expected soon ● Making the kernel build with Clang (4.0) ○ Target kernels: 4.4-HiKey, 4.9-HiKey, Mainline ● CI efforts: Testing AOSP daily builds with clang daily builds ● To be done: Investigate use of the LLD linker
  • 3. ENGINEERS AND DEVICES WORKING TOGETHER Reversing the world: Building AOSP with gcc, kernel with clang ● Why? ○ Different compilers show different warnings - both can be useful ○ Can’t do meaningful comparison of compilers if there’s only one option
  • 4. ENGINEERS AND DEVICES WORKING TOGETHER Kernel with clang status ● Done for HiKey 4.4, HiKey 4.9 and Mainline post-4.10 kernels ● HiKey works, no known problems that matter right now ○ Compile issues in ARMv8.1-a specific code (for which the hardware doesn’t exist yet): Makefiles force a number of gcc specific compiler flags that don’t have a direct equivalent in clang (and clang developers oppose adding them). ● Mainline kernel fails to boot during early-bootup on some x86 hardware when built with clang ● We’re down to 26 needed patches, 19 of which are relevant for Linaro work (3 are in x86 code, 4 in MIPS code)
  • 5. ENGINEERS AND DEVICES WORKING TOGETHER Interesting problems getting the kernel to build with clang ● Clang is much more picky about inline assembly -fno-integrated-as helps a lot, but even when not using the integrated as, clang runs syntax checks. This breaks the kernel’s abuse of inline assembly to generate asm offset tables (see include/linux/kbuild.h, scripts/mod/Makefile -- use of asm statements to generate files that will be processed with sed rather than as) . ● Solution: Still use inline assembly to generate the offset tables - but make the output file valid (even if unused) assembly code: It becomes a file full of asm comments. ● Clang is also more picky about using the right constraints and size-specific instructions (e.g. mulq as opposed to plain mul on x86)
  • 6. ENGINEERS AND DEVICES WORKING TOGETHER Interesting problems getting the kernel to build with clang ● Reliance on gcc extensions in some functions: ○ Nested functions ○ Variable-length arrays in structs ○ __attribute__((externally_visible)) ○ Removal of references to functions called from unreachable code ● EFI libstub: Mix of code that must be PIC and code that must not be PIC ○ It’s not yet 100% clear whether the code works with gcc by accident or clang is doing something wrong, but it’s looking more like it works with gcc by accident and a future gcc version may expose the same problem. ● gcc plugins for code analysis (obviously) don’t work with clang - implementing equivalent plugins will probably not be too difficult, but will such an effort be accepted upstream?
  • 7. ENGINEERS AND DEVICES WORKING TOGETHER Interesting problems getting the kernel to build with clang ● The kernel is still C89 code (and enforcing -std=gnu89) ○ Clang supports C89, but has defaulted to C99 and newer for a long time. C89 support in clang has not received the same amount of testing as C99 or C11 (or C++14) mode, and may result in obscure bugs or missing optimizations ○ Moving the kernel to C11 (or at least C99) may be a good idea even when not thinking about clang (a lot of kernel code already uses C99 initializers and other C99 functions that are available in gnu89 as extensions to C89) ○ gcc no longer defaults to C89 either
  • 8. ENGINEERS AND DEVICES WORKING TOGETHER AOSP with gcc status ● AOSP master built with gcc 6.3 in January, but upstream changes make new patches necessary. ● ABI problem: gcc -std=gnu++14 emits calls to __cxa_throw_bad_array, which doesn’t exist in compiler-rt (upstream bug 25022512) -- but code has moved on to require C++14 language features ● gcc 7 is still a moving target and used to error out a lot, but it’s getting ready. Not many additional changes to AOSP needed.
  • 9. ENGINEERS AND DEVICES WORKING TOGETHER Interesting problems getting AOSP to build with gcc ● __attribute__((unused)) is for functions only in gcc -- in clang, it can also be used for struct members. ○ (may make sense to implement this in gcc) ● gcc warns (or errors out with -Werror) when doing an extra check for a pointer being NULL when passing a parameter declared __attribute__((nonnull))
  • 10. ENGINEERS AND DEVICES WORKING TOGETHER Interesting problems getting AOSP to build with gcc ● gcc now warns about bogus indentation (error with -Werror): for (i=0;i<=jk;i++) { for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw; } ○ This may be nice to have in clang… ● gcc is more picky about potentially reaching the end of a non-void function without returning a value ● On the other hand, only clang thinks there’s something wrong with void doSomething(char a[10]) { if(strncmp(a, “1234567890”, sizeof(a))) something(); }
  • 11. ENGINEERS AND DEVICES WORKING TOGETHER Current CI efforts ● Nightly builds of clang master ● On success, nightly builds of AOSP master with the clang master build ○ Need to apply a minor patch set to AOSP master: mostly about tuning compiler flags and bypassing newly added error diagnostics ● On success, boot-up test on LAVA Hikey ● Building gcc based AOSP toolchains (with regular binutils updates) with every TCWG gcc release
  • 12. ENGINEERS AND DEVICES WORKING TOGETHER Future plan: Building AOSP on aarch64 ● aarch64 machines are getting strong enough to replace x86 machines ● Step 1: Build AOSP on regular Linux aarch64 hosts ● Step 2: Build AOSP on AOSP -- why put all those 8+ cores on modern Android devices to waste? Devices like Pixel C could be a good native development tool, and a startup in France seems to be working on a “plug your phone into this docking station to make it your desktop” type device.
  • 13. ENGINEERS AND DEVICES WORKING TOGETHER Future plan: LLD ● LLD is a new linker coming out of the LLVM project, replacing the BFD linker and the gold linker from traditional binutils ● LLVM 4.0 comes with the first version of LLD that is usable ○ Can be used to build most components of a Linux system ○ Patchset to make the kernel build with LLD is available, but needs some more work ● LLD should still be considered experimental, but may well be ready in time for O based releases ○ Currently missing a couple of --fix-cortex-a*-* workarounds for processor errata known to affect AOSP under some conditions
  • 14. Questions? Ask now, or mail bero@linaro.org #BUD17 For further information: www.linaro.org BUD17 keynotes and videos on: connect.linaro.org
  • 15. Thank You #BUD17 For further information: www.linaro.org BUD17 keynotes and videos on: connect.linaro.org