How To choose toolchain for kernel compilation - General Questions and Answers

Hi,
I can't find useful information on this title, How to choose the best match toolchain for kernel compilation?
my kernel is this.
Another question is while android kernel compiled with clang then in what areas GCC is required.
Thanks

Compileit said:
Hi,
I can't find useful information on this title, How to choose the best match toolchain for kernel compilation?
my kernel is this.
Another question is while android kernel compiled with clang then in what areas GCC is required.
Thanks
Click to expand...
Click to collapse
clone this clang build from https://github.com/kdrag0n/proton-clang.git .it has gcc built-in and should work fine. if issues arise then that clang url will also have info on that. you might have to specify a few things though.
something like this needs to be in your path or in build script.
export CLANG_PATH=/home/the_anomalist/Toolchains/proton-clang/bin
export PATH=${CLANG_PATH}:${EXT_UTILS}:${PATH}
#export DTC_EXT=$EXT_UTILS/dtc-aosp
#export CLANG_TRIPLE=aarch64-linux-gnu-
export CROSS_COMPILE=/home/the_anomalist/Toolchains/proton-clang/aarch64-linux-android-
export CROSS_COMPILE_ARM32=/home/the_anomalist/Toolchains/proton-clang/arm-linux-gnueabi-
export LD_LIBRARY_PATH=/home/the_anomalist/Toolchains/proton-clang/lib:$LD_LIBRARY_PATH
ofc other things will be needed to work but this should help out

Related

Building Kernel for Dream

Hello
As the prebuilt Kernel which comes with the dream-open project is not as cutting edge es I'd like it to be, I wanted to build the Kernel myself and checked out the sources for 2.6.29.
Now I've got some questions and problems:
Are there any known problems of using this kernel with the master branch? Are there any special/manual changes needed?
What are the best settings for the .config file to get a performance oriented and good kernel? Is msm_defconfig any good? (Maybe someone has a .config he could share with me?)
Are there any build time optimizations which would increase perfomance? (I read something about -O2)
Does only the WiFi Module have to be rebuilt?
When I played around, I got an error that a file (elf.h) is missing. How would I correct that/Which file is meant/Where would I get it?
It would be great if someone could answer these questions
Thank you very much

[MacOSX][ToolchainProject] Linaro-6.0.0 Toolchain for OSX

Code:
I am not sure this thread is in right place. If not, please reply here so i can move this thread to elsewhere.
THIS IS NOT ROM, THIS IS TOOLCHAIN
Introduction:
This is a "toolchain" that only for MacOSX-Android. This toolchain is based on Linaro toolchain 6.0.0, and this linaro toolchain is combined version of kernel toolchain and platform toolchain. This was built because i needed it. I have been working this for 4 months to able to build this toolchain successfully.
HOSTGCC=Linaro-4.9 Toolchain(Self-Built)
TARGETGCC=LInaro 6.0 android-eabi(combined version of arm-eabi and platform-eabi)
Any bugs, Reply with LOG.
Download:
https://github.com/KangDroid/mac-linaro-toolchain (Branch at: android-eabi-6.0)
How to use: (For only kernel)
1. Clone the repository. (I put my toolchain to /tmp.)
$ cd /tmp <-- you can choose your directory, somewhere for put toolchain. I will say this value is "toolchaindir"
$ git clone https://github.com/KangDroid/mac-linaro-toolchain.git -b android-eabi-6.0
2. GOTO KERNEL
$ cd kernel_dir
3. Apply patch to kernel
See : https://github.com/KangDroid/androi...mmit/30377f1482e877154c56f11934a47f440c5f082b
for details
4. Build:
make ARCH=arm CROSS_COMPILE=toolchaindir/bin/arm-eabi- (defconfig)
make ARCH=arm CROSS_COMPILE=toolchaindir/bin/arm-eabi- (zImage-dtb or whatever your kernel image, build)
Note:
I haven't tested building kernel/platform with this toolchain. I don't have much time to do it. Please try and report will be great!
I never tested platform with 6.0 gcc. It won't boot ROM. (I just saw from other thread, not sure)
XDA:DevDB Information
[MacOSX][ToolchainProject] Linaro-6.0.0 Toolchain for OSX, ROM for all devices (see above for details)
Contributors
Jason Hyunwoo
Source Code: https://github.com/KangDroid/mac-linaro-toolchain
Toolchain Version: 6.0.0-Experimental
Version Information
Status: Testing
Created 2015-06-14
Last Updated 2015-06-14
I'll be the first to say it, I've never heard of MacOSX-Android even after a google search. Care to explain some more?
Awesome toolchain, buddy!
berryman13 said:
I'll be the first to say it, I've never heard of MacOSX-Android even after a google search. Care to explain some more?
Awesome toolchain, buddy!
Click to expand...
Click to collapse
oh I just saw it :
Sorry that is my bad word, it means "Build android on OS X ) That's why I wrote MacOSX-Android(Host is MacOSX, target is Android.)

[Q] How to Build My Own Custom ROM

So, how to build my own custom rom version ?
I want to build CM and cherrypicks some feature.
Does anyone have a guide or maybe anyone could teach me? Because i can't really follow the tutorial on CM wiki page.
Thanks a lot !
You need fairly decent specs internet and specs to compile. You can rent a linux VPS to compile to get rid of most of the headaches, or install a Linux distribution on your pc. Then you can follow https://wiki.cyanogenmod.org/w/Build_for_bacon#Build_CyanogenMod_and_CyanogenMod_Recovery if you have a Debian based Linux(Ubuntu) install, just substitute the branch in "repo init -u https://github.com/CyanogenMod/android.git -b cm-12.1" with cm-13, if you want to build cm13 nighties. If you want to cherry go to the root of the build directory and copy and paste the commands from the cm gerrit. You can find the command under the download tab.
Hello since I'm kinda new to xda , I cant create a thread
Quick question
How can I implement kexec hardboot patch in my kernel ,
I found this kernel by the mod developer
github. com/ davidepianca98/android_kernel_oneplus_msm8974-kexec
But cm-13.0 branch isn't available
https://github.com/davidepianca98/a...mmit/af5ef3d76f863f02c51cf860702b01536620ebf5 this commit tells you how to modify your kernel to implement it. You can possibly cherrypick it too.

[GCC][Toolchain] Eva GCC | Calling all kernel devs!

Introducing Eva GCC Toolchain
What is GCC?​
The GNU Compiler Collection (GCC) is an optimizing compiler produced by the GNU Project supporting various programming languages, hardware architectures and operating systems. The Free Software Foundation (FSF) distributes GCC as free software under the GNU General Public License (GNU GPL). Major corporate contributors to GCC include Red Hat, IBM, SUSE, ARM, Google and Intel. GCC is a key component of the GNU toolchain and the standard compiler for most projects related to GNU and the Linux kernel. With ~15 million lines of code in 2019, GCC is one of the biggest open source programs in existence. It has played an important role in the growth of free software, as both a tool and an example.
Source: Wikipedia
Click to expand...
Click to collapse
What is LLVM Clang?​
Clang is a compiler front end for the C, C++, Objective-C and Objective-C++ programming languages, as well as the OpenMP, OpenCL, RenderScript, CUDA and HIP frameworks. It uses the LLVM compiler infrastructure as its back end and has been part of the LLVM release cycle since LLVM 2.6.
It is designed to act as a drop-in replacement for the GNU Compiler Collection (GCC), supporting most of its compilation flags and unofficial language extensions. Its contributors include Apple, Microsoft, Google, ARM, Sony, Intel and Advanced Micro Devices (AMD). It is open-source software, with source code released under the University of Illinois/NCSA License, a permissive free software licence. Since v9.0.0, it was relicensed to the Apache License 2.0 with LLVM Exceptions.
Source: Wikipedia
Click to expand...
Click to collapse
Introduction​Android as a whole has now fully switched to LLVM Clang for both their Platform (AOSP) and Kernels. In fact Pixel Phones have been shipping with Clang built and optimised kernels since 2018! But are there any improvements with using clang over GCC. I'd say yes, because the GCC that AOSP used was ancient (GCC 4.9). Also LLVM Clang has proven to be faster in compilation than GCC. But is this speed worth the improvement in Kernels? Let's answer that question with EvaGCC Toolchain.
How is my toolchain different from Android GCC?​As I've mentioned earlier, AOSP GCC is ancient (version 4.9) in terms of the present stable GCC release (10.2.x). EvaGCC is compiled straight from the Master branch, making it a Bleeding Edge C Compiler. It is built with LTO and disabled a lot of feature bloat that are unneccesary for kernel building to yield a very small binary size. To list the features:
Bare Metal GCC (This does not depend on the standard libc)​
Built straight from the GNU GCC Master branch​
Built with LTO and O3 optimisations​
Disabled documentation (Smaller size of the toolchain)​
Disabled decimal float, libffi, libmudflap, libquadmath, libstdcxx-pch, native language support​
Statically linked GCC​
Integrated LLVM LLD (For faster linking, optional)​
Built twice weekly (Thanks to Github Actions!)​
Where can I find these toolchains?​Well you have two options, you can compile them yourself (by using my script) or you can download precompiled binaries!
To compile this toolchain by yourself (although I recommend that you use precompiled binaries, to avoid the hassle and time to compile the toolchain itself), to use my script to compile your toolchain, it has everything preconfigured for GCC setup and cloning. Although you'll have to setup your system for building GCC, you can refer to my README for system setup.
Note:
To obtain precompiled binaries (Highly recommended), head over to these links (according to your architechture and liking):
ARM Git Repository with Precompiled Binaries
ARM precompiled binaries in a compressed zip (direct download)
AARCH64 (ARM64) Git Repository with Precompiled Binaries
AARCH64 (ARM64) precompiled binaries in a compressed zip (direct download)
Note: If you're doing a git clone, use --depth=1 to avoid heavy transfers, because the repositories are bound get bigger with subsequent updates.
How do I use these toolchains for compiling my kernel​You can either append the toolchain dir into your PATH variable, or you can just pass it along with make with setting your CROSS_COMPILE argument. I usually use the latter one.
Since this is a bare metal compiler, the prefix differs from the normal AOSP or Linux GNU GCC. the prefix is:
Bash:
# Pass this to your CROSS_COMPILE argument if you have appended toolchain to your PATH
## for AARCH64 or ARM64
$ make CROSS_COMPILE=aarch64-elf- ... # "..." indicates rest of your args
## for ARM
$ make CROSS_COMPILE=arm-eabi- ...
# Passing to make when you haven't appended to PATH
## for AARCH64 or ARM64
$ make CROSS_COMPILE=<path to toolchain>/bin/aarch64-elf- ...
## for ARM
$ make CROSS_COMPILE=path to toolchain>/bin/arm-eabi- ...
Sources:
Everything here is OSS, including the script, my ci automation script.
GCC: https://gcc.gnu.org/git/?p=gcc.git or https://git.linaro.org/toolchain/gcc.git
Binutils: https://sourceware.org/git/binutils-gdb.git
GCC Build script: https://github.com/mvaisakh/gcc-build
LLVM (Used for LLD): https://github.com/llvm/llvm-project
GCC Version: 13.x
Binutils Version: 2.36.x
LLD Version: 16.x
Telegram Channel:
Eva GCC
Bleeding Edge Bare Metal GCC, primarily targeting Android kernels.
t.me
NOTE: According to SultanXDA, and I quote
GCC 10 updated its interprocedural optimizer's logic to have it make
more conservative inlining decisions, resulting in worse syscall and
hackbench performance compared to GCC 9.
Click to expand...
Click to collapse
This can be fixed with a patch that he himself provided:
gcc-inline-regressions-2.patch
GitHub Gist: instantly share code, notes, and snippets.
gist.github.com
and if that did not work for you, try applying this patch
gcc-inline-regressions-2.patch
GitHub Gist: instantly share code, notes, and snippets.
gist.github.com
Update 30-Jan-2021
GCC+LLD has been merged into the main branch of the build script. Now GCC+LLD would be updated twice every week (on Sundays and Thurdays). This wasn't done before as it was under testing, and so far it only fails under LTO kernel compilation (Due to lack of GCC Plugin for LLD and vice versa).
Update 07-April-2021
lld-integration trunk has been merged into gcc-master branch. For those who use LLD, should switch to gcc-master as the lld-integration branch is now deprecated and will be removed soon.
The size difference between the two isn't much (~86mb vs 125mb), so it makes sense to have a single branch for everything.
I recommend to use zipped archive toolchains or if you use git operations to clone toolchain binaries, I recommend using --depth=1 while cloning the toolchain to avoid huge binary size cloning.
Update 27-April-2021
GCC Version has been bumped to 12.x
Eva GCC now ships with
GCC: 12.x
LLD: 13.x
BinUtils: 2.36.x
Update 26-June-2021
Toolchain binaries have been stripped off of debugging and hence are much smaller than before, ~90MB shaved off!
Shallow clones shall be much faster than before!
Update 24-Nov-2021
LLD has been bumped to version 14.x
GCC is still on 12.x
Update 1-May-2022
GCC has been bumped to version 13.x
LLD is at 15.x
Pro Vaisakh
Yes yes super pro Vaisakh
Nice
It's kang time
Let me try great work
Oh pro iz here
Going to use it soon
god level pro work
Amazing job at collecting data and optimising the toolchain, looking forward to using this as default in my kernel builds!
Keep up the great work dude
great work sar, tysm!
A small update!
GCC+LLD has been merged into the main branch of the build script. Now GCC+LLD would be updated twice every week (on Sundays and Thurdays). This wasn't done before as it was under testing, and so far it only fails under LTO kernel compilation (Due to lack of GCC Plugin for LLD and vice versa).
If anyone faces any issues with the toolchain, please do let me know. I will try to investigate the issue and check accordingly if it's a toolchain issue or a kernel side issue.
Because being a cron built toolchain, it's necessary for people to report bugs as soon as possible.
I still monitor on my end, but it's always good to have a helping hand
Thanks @m_vaisakh,
Kernel 3.18.140 compiled with https://github.com/mvaisakh/gcc-arm64.git -b gcc-master works fine on Oreo. No errors thru whole process.
adeii said:
Thanks @m_vaisakh,
Kernel 3.18.140 compiled with https://github.com/mvaisakh/gcc-arm64.git -b gcc-master works fine on Oreo. No errors thru whole process.
Click to expand...
Click to collapse
How is the performance?
@nift4 also uses 3.18.140 and has it has improved everything in his case.
m_vaisakh said:
How is the performance?
@nift4 also uses 3.18.140 and has it has improved everything in his case.
Click to expand...
Click to collapse
*3.18.124 sadly
m_vaisakh said:
How is the performance?
Click to expand...
Click to collapse
Lets see what Antutu Benchmaker v8.4.5 said:
Same kernel source, same device, connected via USB, 10 minutes after boot:
With GCC 4.9: score 71192, HTML5 score: 13087
With EVA-GCC: ... 72392, HTML5: 14554 and kernel is smaller for 235520 bytes !
Update!
lld-integration trunk has been merged into gcc-master branch. For those who use LLD, should switch to gcc-master as the lld-integration branch is now deprecated and will be removed soon.
The size difference between the two isn't much (~86mb vs 125mb), so it makes sense to have a single branch for everything.
I recommend to use zipped archive toolchains or if you use git operations to clone toolchain binaries, I recommend using --depth=1 while cloning the toolchain to avoid huge binary size cloning.
Update!
GCC Version has been bumped to 12.x
Eva GCC now ships with
GCC: 12.x
LLD: 13.x
BinUtils: 2.36.x
m_vaisakh said:
Update!
GCC Version has been bumped to 12.x
Eva GCC now ships with
GCC: 12.x
LLD: 13.x
BinUtils: 2.36.x
Click to expand...
Click to collapse
Been using Eva GCC for over 3 months now and it's been very reliable

Question Help compiling kernel with KVM

Hi,
I wanted to compile a custom kernel with KVM for the ROG Phone 5 on the latest Android 12 (EU variant) so I looked at the Kirisakura kernel for base (from @Freak07) and I looked at the script that starts compiling the kernel. I could not find some things that was required such as the Google's GCC thing or the "DU_Tools" but I still managed to start compiling the kernel after editing the defconfig file using make menuconfig to enable KVM. Once I did that I ran the script but after like two minutes I got an error (Error 2).
So can someone help me doing this please?
Thanks.
Hey Alex - been looking in to creating a build script using docker for this out of curiosity.
Out of interest though - how are you planning to use KVM once it's enabled?
Moved all of my development efforts from XDA.
chrisaw said:
Hey Alex - been looking in to creating a build script using docker for this out of curiosity.
Out of interest though - how are you planning to use KVM once it's enabled?
Click to expand...
Click to collapse
Hey, I didn't tried using docker (because I don't know how to xD) and I want to use KVM because I heard that the Snapdragon 888 is compatible with it so I was thinking about doing a Windows 10 arm VM with native performance.
chrisaw said:
Got this building cleanly and producing a flashable ZIP:
GitHub - cawilliamson/Kirisakura_ANAKIN_ROG5 at master_release_s_1
Contribute to cawilliamson/Kirisakura_ANAKIN_ROG5 development by creating an account on GitHub.
github.com
Build instructions:
Code:
$ cd <kernel sources>/build/
$ ./build.sh
You will need Docker installed on your system via whatever means necessary and this is really aimed at Linux systems although you could also run the build on a Windows or Mac PC if you setup Docker correctly.
Click to expand...
Click to collapse
Thanks I will try that
Moved all of my development efforts from XDA.
chrisaw said:
Your chances of getting that working easily are slim.
Adding the KVM support to the kernel is easy but the problem you then get is about switching the CPU to "HYP" mode. (just based on what I read online)
If you have further info about this I'd be interested in reading it and seeing if we can get something which works. What I can tell you is that /dev/kvm does not get created simply by the changes I made.
Also be aware that /proc/config.gz is spoofed in these kernels with the "stock" config file so running something like "zcat /proc/config.gz" wont show KVM is enabled but it is.
Click to expand...
Click to collapse
Yes you are R8! Without hyp we can't enable KVM support.. but i found a site where telling android 13 has full KVM support.. but don't know it's true or not..
Because KVM support only available on some snapdragon chipset only..
Redirect Notice
Can't all of this work be ported to the Infinix NOTE 8 on Android 10 too?

Categories

Resources