• Stars
    star
    290
  • Rank 140,063 (Top 3 %)
  • Language
    C
  • License
    Other
  • Created over 4 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Proton Clang toolchains builds in the form of a continuously updating Git repository. Clone with --depth=1.

Proton Clang

This is a LLVM and Clang compiler toolchain built for kernel development. Builds are always made from the latest LLVM sources rather than stable releases, so complete stability cannot be guaranteed.

This toolchain targets the AArch32, AArch64, and x86 architectures. It is built with LTO and PGO to reduce compile times as much as possible. Polly, LLVM's polyhedral loop optimizer, is also included for users who want to experiment with additional optimization. Note that this toolchain is not suitable for anything other than bare-metal development; it has not been built with support for any libc or userspace development in mind.

binutils is also included for convenience. Unlike LLVM, however, the latest stable version of binutils is always used to reduce the opportunity for breakage because this project is primarily focused on cutting-edge Clang, not binutils. This means that users do not need to download separate GCC toolchains to build the Linux kernel.

Automated builds occur weekly at 3 PM PST on every Saturday using fresh sources from the LLVM Git monorepo. If any part of the builds fail, this repository will not be updated. The build scripts (powered by tc-build) behind this can be found here.

Build notifications and other information can be obtained from the Telegram channel.

Host compatibility

This toolchain is built on Ubuntu 18.04 LTS, which uses glibc 2.27. Compatibility with older distributions cannot be guaranteed. Other libc implementations (such as musl) are not supported.

Building Linux

Make sure you have this toolchain in your PATH:

export PATH="$HOME/toolchains/proton-clang/bin:$PATH"

For an AArch64 cross-compilation setup, you must set the following variables. Some of them can be environment variables, but some must be passed directly to make as a command-line argument. It is recommended to pass all of them as make arguments to avoid confusing errors:

  • CC=clang (must be passed directly to make)
  • CROSS_COMPILE=aarch64-linux-gnu-
  • If your kernel has a 32-bit vDSO: CROSS_COMPILE_ARM32=arm-linux-gnueabi-

Optionally, you can also choose to use as many LLVM tools as possible to reduce reliance on binutils. All of these must be passed directly to make:

  • AR=llvm-ar
  • NM=llvm-nm
  • OBJCOPY=llvm-objcopy
  • OBJDUMP=llvm-objdump
  • STRIP=llvm-strip

Note, however, that additional kernel patches may be required for these LLVM tools to work. It is also possible to replace the binutils linkers (lf.bfd and ld.gold) with lld and use Clang's integrated assembler for inline assembly in C code, but that will require many more kernel patches and it is currently impossible to use the integrated assembler for all assembly code in the kernel.

Android kernels older than 4.14 will require patches for compiling with any Clang toolchain to work; those patches are out of the scope of this project. See android-kernel-clang for more information.

Android kernels 4.19 and newer use the upstream variable CROSS_COMPILE_COMPAT. When building these kernels, replace CROSS_COMPILE_ARM32 in your commands and scripts with CROSS_COMPILE_COMPAT.

Differences from other toolchains

Proton Clang has been designed to be easy-to-use compared to other toolchains, such as AOSP Clang. The differences are as follows:

  • CLANG_TRIPLE does not need to be set because we don't use AOSP binutils
  • LD_LIBRARY_PATH does not need to be set because we set library load paths in the toolchain
  • No separate GCC/binutils toolchains are necessary; all tools are bundled

Common problems

as: unrecognized option '-EL'

Usually, this means that CROSS_COMPILE is not set correctly. Check that variable as well as your PATH to make sure that the required tools are available for Clang to invoke. You can test it manually like tihs:

$ ${CROSS_COMPILE}ld -v
GNU ld (GNU Binutils) 2.34

If you see Command not found or any other error, one of the two variables mentioned above is most likely set incorrectly.

If you continue to encounter this error after verifying CROSS_COMPILE and PATH, you are probably running into a change in Clang 12's handling of cross-compiling. The fix is to either merge linux-stable (which already has the fix included) cherry-pick "Makefile: Fix GCC_TOOLCHAIN_DIR prefix for Clang cross compilation" manually.

If the error still continues to appear and you have an arm64 kernel that includes vdso32, you will also need to cherry-pick "arm64: vdso32: Fix '--prefix=' value for newer versions of clang" to fix the second vdso32 error. Merging linux-stable is also an option if you are on Linux 5.4 or newer.

Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: -fstack-protector-strong not supported by compiler

This error is actually a result of stack protector checks in the Makefile that cause the real error to be masked. It indicates that one or more unsupported compiler flags have been passed to Clang. Disable CONFIG_CC_STACKPROTECTOR_STRONG in favor of CONFIG_CC_STACKPROTECTOR_NONE temporarily (make sure you don't keep this change permanently for security reasons) and Clang will output the flag that is causing the problem.

In downstream kernels, the cause is usually big.LITTLE CPU optimization flags that have been added to the Makefile unconditionally. The correct solution is to check cc-name for the current compiler and adjust the optimization flags accordingly — big.LITTLE for GCC and little-only for Clang. See "Makefile: Optimize for sm8150's Kryo 485 CPU setup" for an example implementation of this.

scripts/gcc-version.sh: line 25: aarch64-linux-gnu-gcc: command not found

This is caused by unconditional invocations of gcc-version.sh in CAF's camera_v2 driver. The recommended solution is to cherry-pick Google's fix from the Pixel 2 kernel, which simply removes the faulty invocations as they were never useful to begin with.

Note that these errors are harmless and don't necessarily need to be fixed, but nonetheless, ignoring them is not recommended.

undefined reference to 'stpcpy'

This is caused by a libcall optimization added in Clang 12 that optimizes certain basic sprintf calls into stpcpy calls. The correct fix for this is to cherry-pick "lib/string.c: implement stpcpy", which adds a simple implementation of stpcpy to the kernel so that Clang can use it.

More Repositories

1

safetynet-fix

Google SafetyNet attestation workarounds for Magisk
C++
6,032
star
2

android12-extensions

Enable and customize hidden features on Android 12.
Kotlin
429
star
3

fastboot.js

WebUSB implementation of the Android fastboot protocol
TypeScript
383
star
4

android-webinstall

Easy-to-use web installer for Android-based operating systems
Vue
245
star
5

adevtool

Android ROM device support and bringup tool, designed for maximum automation and speed.
TypeScript
215
star
6

base16-kitty

Base16 color scheme template for kitty
Mustache
192
star
7

freqbench

Comprehensive CPU frequency performance/power benchmark
Python
160
star
8

pyrobud

A clean selfbot for Telegram with an emphasis on quality and practicality, designed to complement the official clients.
Python
126
star
9

cbackup

Fast & complete app + data backup script for Android
Shell
85
star
10

tipatch

A patcher for TWRP to backup internal storage/emulated SD card contents (photos, downloads, videos, etc).
Kotlin
70
star
11

touchpaint

An experimental Linux kernel module that demonstrates the lowest possible input latency on modern smartphones. Not for Android or production use.
C
63
star
12

colorkt

Modern color science library for Kotlin Multiplatform and Java
Kotlin
61
star
13

android_packages_apps_RepainterServicePriv

First-class custom ROM integration service for my Repainter app
Kotlin
58
star
14

linux-virtcontainer

Guest kernel for Nestbox (rootless VM containers on Android)
C
58
star
15

inter-font-pack

Magisk module that replaces Android's system fonts with Inter and other complementary fonts.
Shell
50
star
16

proton_kernel_redbull

Proton Kernel for the Pixel 5 (redfin) and Pixel 4a 5G (bramble), unified as redbull.
C
43
star
17

proton_zf6

Proton Kernel for the Asus Zenfone 6 (2019), codename Kirin and also known as I01WD and ZS630KL.
C
42
star
18

proton_bluecross

Proton Kernel for the Pixel 3 (blueline) and Pixel 3 XL (crosshatch) unified as bluecross. (discontinued)
C
36
star
19

proton_wsl2

Proton Kernel for the Windows Subsystem for Linux 2 (WSL 2). Highly experimental and always at the mercy of Windows Update.
C
26
star
20

base16-termux

Base16 for Termux
Mustache
26
star
21

aarch64-elf-gcc

GCC 9.2.0 + binutils 2.32 toolchain for x86_64 hosts, targeted for bare-metal (ELF / kernel-only) AArch64 systems.
C
25
star
22

proton_kernel_wahoo

Proton Kernel for the Pixel 2 (walleye) and Pixel 2 XL (taimen), unified as wahoo.
C
25
star
23

earlypilot

All-in-one server for monetizing software development with the early access supporter model
Kotlin
23
star
24

glcolortest

GLSL shader for testing color science and palette generation algorithms interactively
GLSL
23
star
25

kramflash

A fast & simple bootable GKI kernel flasher for boot image v2 and v3 devices.
Perl
20
star
26

benchkit

A developer-centric toolkit module for Android to facilitate in-depth profiling and benchmarking. MOVED to official Magisk module repo: https://github.com/Magisk-Modules-Repo/benchkit
Shell
19
star
27

ulog

Simple, fast, efficient logging facade for Android apps
Kotlin
17
star
28

mainline_kernel_easel

Mainline Linux kernel for the Pixel Visual Core image coprocessor (codename Easel/Monette Hill) found in the Pixel 2 and 3.
C
17
star
29

protonaosp.kdrag0n.dev

Website for @ProtonAOSP, a minimal Android fork focused on UI/UX and performance.
JavaScript
16
star
30

arm-eabi-gcc

GCC 9.2.0 + binutils 2.32 toolchain for x86_64 hosts, targeted for bare-metal (ELF / kernel-only) AArch32 systems.
C
15
star
31

touchpaint-android

Touchpaint Android app for latency testing, corollary to the Linux kernel module: https://github.com/kdrag0n/touchpaint
Kotlin
14
star
32

fxdsp

Fast and simple C++ DSP engine with high-quality effects. Originally built for PhantomAmp, an Android app for rootless system-wide audio effects.
C++
13
star
33

kdrag0n.dev

My personal website.
HTML
12
star
34

linux-m1

My experiments with Linux for the Apple M1 platform, based on Asahi and Corellium patches
C
11
star
35

app-utils

Select parts of my homegrown library for Android app development
Kotlin
10
star
36

drone-ssh-debug

A Drone plugin to enable remote build monitoring and debugging over SSH.
Shell
10
star
37

touchpaint-flutter

Touchpaint Flutter app for touch latency testing, corollary to the Android app: https://github.com/kdrag0n/touchpaint-android
Dart
9
star
38

velocity_tissot

Velocity Kernel for the Xiaomi Mi A1 (tissot). (discontinued)
C
9
star
39

eas_sdm660

An accurate, performant, and power-efficient EAS energy model for the Qualcomm Snapdragon 660 SoC (codename sdm660). THIS IS NOT A FULL EAS IMPLEMENTATION.
C
8
star
40

callbench

A program to measure the speed of simple time syscalls and vDSO calls, as well as basic in-memory file I/O using the mmap(2) and read(2) syscalls.
C
8
star
41

github-releases-proxy

GitHub Releases asset proxy for Cloudflare Workers
JavaScript
7
star
42

kbench

A Linux kernel microbenchmark suite.
Go
7
star
43

velocity_dream

Velocity Kernel for the Samsung Galaxy S8/S8+ (dreamlte/dream2lte). (discontinued)
C
7
star
44

blurtest

Test implementation of dual-filter Kawase blur in OpenGL ES 3.1, in the form of an Android app.
Kotlin
6
star
45

confirmationui-test

Simple app for testing Android Protected Confirmation (Confirmation UI)
Kotlin
6
star
46

serenade-calhacks23

TypeScript
6
star
47

aoc2021

My solutions for Advent of Code 2021
Python
5
star
48

DeviceSink

Android 11 device controls kitchen sink with all possible device types for testing.
Kotlin
5
star
49

caf4.14_kernel_wahoo

CAF 4.14 kernel for msm8998 wahoo
C
5
star
50

allocbench

Benchmark memory allocators realistically with techniques from Android, such as real-world trace replaying.
C++
5
star
51

msft-wsl2-kernel

An OLD and ABANDONED import of Microsoft's customized WSL2 Linux kernel with differentiated changes. Please use Microsoft's official up-to-date repository: https://github.com/microsoft/WSLv2-Linux-Kernel
C
5
star
52

aoc2020

My Advent of Code 2020 solutions in Rust and Python.
Python
4
star
53

passt-virtcontainer

C
4
star
54

caf_kernel_wahoo

CAF 4.4-based kernel for the Pixel 2 / XL (walleye/taimen), unified as wahoo. Note that this is a proof-of-concept which cannot fully boot Android due to encryption issues.
C
4
star
55

SwiftUI-AKList

Fast, stable, flexible SwiftUI wrapper for AppKit's NSOutlineView
Swift
3
star
56

speedscribble-htn2021

Hack the North 2021 team project: Draw against your friends in 1 minute!
JavaScript
3
star
57

stock_kernel_bluecross

A flashable stock kernel package for the Pixel 3 (blueline) and Pixel 3 XL (crosshatch) unified as bluecross/b1c1. Files extracted from Google factory images.
Shell
2
star
58

proprietary_vendor_asus

Proprietary vendor blobs for Asus devices, currently only the ZenFone 6 (I01WD).
Makefile
2
star
59

nanotap

A daemon that parses and dumps touch input events on Linux.
Go
2
star
60

structalgo

My implementations of various data structures and algorithms in C.
C
2
star
61

github-release-redirector

A simple Go web server that redirects a configured list of paths to the latest release asset on a GitHub repository.
Go
2
star
62

quicklock

Research project: Secure smart lock protocol with auditing and access control delegation.
Kotlin
2
star
63

archenemy

ArchEnemy Linux — a spin of Arch's official archiso live rescue disk with additional tools, tailored for my use.
Shell
2
star
64

hueflake-issues

Issue tracker for Hueflake
2
star
65

freebsd_easel

FreeBSD ported to the Pixel Visual Core (codename Easel/Monette Hill).
C
2
star
66

vardbg

A simple Python debugger and profiler, written for GCI 2019. Moved to CCExtractor.
Python
2
star
67

netbsd_easel

NetBSD ported to the Pixel Visual Core (codename Easel/Monette Hill).
2
star
68

aoc2022

Advent of Code 2022 solutions
Python
2
star
69

soca-treehacks24

JavaScript
2
star
70

gtcycles

A tool to measure the frequency of the generic timer on ARMv8 CPUs.
C
1
star
71

binderlat

A Go program to measure the latency of Binder IPC transactions on Android.
Go
1
star
72

slack-greeter

A simple Slack bot to greet new members of a workspace, written in Rust for GCI 2019.
Rust
1
star
73

platform_packages_modules_Connectivity

Java
1
star
74

pyrowall

Prototype Telegram bot with module and command discovery written in Go using gotgbot.
Go
1
star
75

biowave

A fast Discord bot prototype written in Go with module and command discovery.
Go
1
star
76

plushed

An Android plushie recognizer using Flutter and TensorFlow, made for GCI 2019.
Dart
1
star
77

flex-gestures

A failed attempt at a fluid iPhone X-like gestures app for Android that doesn't require root.
Kotlin
1
star
78

kdrag0n

Profile
1
star
79

gci-stats

A simple stats fetcher for Google Code-in that supports sending data to Graphite.
Python
1
star
80

android_device_asus_I01WD

Old Android 10 device tree for AOSiP on the Asus ZenFone 6.
C++
1
star
81

bluestone

A discontinued multi-purpose Discord bot written in Java, available for reference purposes.
Java
1
star
82

osrc_dream

Samsung OSRC updates for the Exynos Galaxy S8/+ (dreamlte/dream2lte) as Git commits.
C
1
star
83

HierarchialPerformanceTest.jl

Julia implementation of Non-parametric Hierarchial Performance Testing, a statistical technique for comparing the performance of different computers.
Julia
1
star