[LLVM/CLANG] DragonTC ~ The future is now

Search This thread

frap129

Inactive Recognized Developer
Jan 6, 2013
1,392
4,126
gFcFcZ7.png

DragonTC is a build system for compiling custom clang toolchains. These toolchains contain some AOSP patches(where applicable) and things not included in AOSP clang, such as LTO and Gold plugins, and OpenMP, Polly compiled and automatically linked into tools, improved krait optimizations (-mcpu=krait2), and annoying flags such as -Werror, -Wfatal-errors, and -Weverything internally disabled for non-default parameters. DragonTC compilers are also built with -O3, -pthread, and -fopenmp in order to reduce compile time when used for ROMs. DragonTC has been around for a few months now, but now that some testers have helped me work out the bugs and make it close to stable, I've decided to make an XDA thread.

Why use custom Clang?
Google has been slowly moving away from GCC for a while now, so we believe that we should get ahead of the toolchain game and start now! Furthermore, AOSP modules that are compiled with clang can easily be optimized with the new LTO and Polly options.

How do I build DragonTC?
It's simple! Run the following commands in bash to get set up:
Code:
$ mkdir dtc
$ cd dtc
$ repo init -u https://github.com/dragon-tc/DragonTC -b master
$ repo sync -j(# of cores) -c -f

For Debian and Ubuntu:
Code:
sudo aptitude install build-essential git git-svn bc binfmt-support libllvm-3.6-ocaml-dev llvm-3.6 llvm-3.6-dev llvm-3.6-runtime cmake automake autogen autoconf autotools-dev libtool shtool python m4 gcc libtool zlib1g-dev

And run the following to build your desired toolchain:
Code:
$ cd build
$ ./version
Where "version" is 3.6. 3.7, 3.8, or 3.9.

To optimize the toolchain for your local system, run with the 'opt' argument. Example:
Code:
$ ./3.7 opt

How do use DragonTC in AOSP?
  • Either clone a prebuilt or build your own toolchain and place it in prebuilts/clang/linux-x86/host/your_version (3.7 is the prefered version)
  • Change the version in build/core/clang/config.mk to reflect the directory you placed it in.
  • Either clone ours, or cherry-pick our changes to prebuilts/ndk and frameworks/rs.
  • Cherry-pick our DragonTC support commit in build.
  • Edit build/core/clang/config.mk and set "TARGET_DRAGONTC_VERSION := " to the name of the folder you placed the toolchain in (your_version is the example used above)

How can I fix module issues when compiling with Polly?
It's simple. Just take the module name (ex. "target C++: module_name_here <= some/path/to/code") and add it to the DISABLE_POLLY list. You can also disable Clang all together, use AOSP clang, or force GCC modules to use Clang.

Why call it DragonTC?
The LLVM logo/mascot is a dragon, so in homage to the developers of LLVM and Clang, I used DragonTC as the name.

Credits
A huge thanks to all of the people who helped:
xboxfanj for recreating the Snapdragon Compiler optimizations
xanaxdroid for maintenance, bug fixes, and testing
The LLVM developers for the great work and continuous improvement
All of the great devs/rom builders that helped test
and anyone that I missed!

XDA:DevDB Information
DragonTC, Tool/Utility for the Android General

Contributors
frap129, xanaxdroid
Source Code: https://github.com/dragon-tc


Version Information
Status: Beta

Created 2016-02-19
Last Updated 2016-05-21
 
Last edited:

frap129

Inactive Recognized Developer
Jan 6, 2013
1,392
4,126
This sounds interesting. Thanks for sharing your work. I might try it, but as a bloody beginner, can you maybe give a bit more detail on how it affects building / the result?

Once I get a bit more time, I'll edit the op to have more information. In short, Clang is a compiler (like GCC) that is rapidly growing. Google is currently using Clang 3.6 which produces binaries that perform slower than GCC compiled binaries, but they choose to use Clang because it takes less time to compile overall. DragonTC allows you to use the latest Clang toolchains (3.6, 3.7, 3.8, or 3.9) with extra functionality that Google doesn't have, such as LTO, Polly, OpenMP, and Snapdragon Krait optimizations. These make your rom (or anything you compile with it) perform better than if you were to use the stock AOSP clang.
 

brandonabandon

Senior Member
Nov 17, 2013
290
304
http://pastebin.com/z9G5Pr0S using your sabernaro 4.9 rom and kernel repos. Cloned ndk from op, and picked build/rs commits from op. Any ideas? Aosp source.

Edit; readding the triple flags and rebuilding c, same error.
edit: sry double post

Edit. Its handled. Ty, 1000% improvement.
 

Attachments

  • Screenshot_20160306-205520.png
    Screenshot_20160306-205520.png
    72.6 KB · Views: 2,448
Last edited:
  • Like
Reactions: frap129

spezi77

Recognized Developer / Contributor
Jan 27, 2013
3,519
7,852
/home/less
Big thanks to the dev for this evolutionary TC! In my device the rom feels much snappier now, even when Antutu does not reflect this observation in higher scoring. Benchmark is pretty much the same as before. But maybe I didn't understand the concepts well enough and this is how we should expect it.
DragonTC allows you to use the latest Clang toolchains (3.6, 3.7, 3.8, or 3.9) with extra functionality that Google doesn't have, such as LTO, Polly, OpenMP, and Snapdragon Krait optimizations. These make your rom (or anything you compile with it) perform better than if you were to use the stock AOSP clang.
@frap129 Did you or someone else do benchmarks to check whether a rom compiled with the latest Clang toolchains actually perform better than if we use one of the latest GCC tc, e.g. 5.3?
 
Last edited:
  • Like
Reactions: frap129

tetsuo55

Senior Member
Aug 20, 2007
588
229
Hello @frap129 @brandonabandon after switching to dragonTC i get the following error:
Code:
build/core/dynamic_binary.mk:20: *** external/compiler-rt/lib/asan: LOCAL_MODULE not defined before call to local-intermediates-dir.  Stop.
I am building for lollipop so the code is here
I am using prebuilt 3.7 and the patches to platform build which you can see here

Any help would be greatly appreciated.
 
Last edited:
  • Like
Reactions: frap129

Top Liked Posts

  • There are no posts matching your filters.
  • 51
    gFcFcZ7.png

    DragonTC is a build system for compiling custom clang toolchains. These toolchains contain some AOSP patches(where applicable) and things not included in AOSP clang, such as LTO and Gold plugins, and OpenMP, Polly compiled and automatically linked into tools, improved krait optimizations (-mcpu=krait2), and annoying flags such as -Werror, -Wfatal-errors, and -Weverything internally disabled for non-default parameters. DragonTC compilers are also built with -O3, -pthread, and -fopenmp in order to reduce compile time when used for ROMs. DragonTC has been around for a few months now, but now that some testers have helped me work out the bugs and make it close to stable, I've decided to make an XDA thread.

    Why use custom Clang?
    Google has been slowly moving away from GCC for a while now, so we believe that we should get ahead of the toolchain game and start now! Furthermore, AOSP modules that are compiled with clang can easily be optimized with the new LTO and Polly options.

    How do I build DragonTC?
    It's simple! Run the following commands in bash to get set up:
    Code:
    $ mkdir dtc
    $ cd dtc
    $ repo init -u https://github.com/dragon-tc/DragonTC -b master
    $ repo sync -j(# of cores) -c -f

    For Debian and Ubuntu:
    Code:
    sudo aptitude install build-essential git git-svn bc binfmt-support libllvm-3.6-ocaml-dev llvm-3.6 llvm-3.6-dev llvm-3.6-runtime cmake automake autogen autoconf autotools-dev libtool shtool python m4 gcc libtool zlib1g-dev

    And run the following to build your desired toolchain:
    Code:
    $ cd build
    $ ./version
    Where "version" is 3.6. 3.7, 3.8, or 3.9.

    To optimize the toolchain for your local system, run with the 'opt' argument. Example:
    Code:
    $ ./3.7 opt

    How do use DragonTC in AOSP?
    • Either clone a prebuilt or build your own toolchain and place it in prebuilts/clang/linux-x86/host/your_version (3.7 is the prefered version)
    • Change the version in build/core/clang/config.mk to reflect the directory you placed it in.
    • Either clone ours, or cherry-pick our changes to prebuilts/ndk and frameworks/rs.
    • Cherry-pick our DragonTC support commit in build.
    • Edit build/core/clang/config.mk and set "TARGET_DRAGONTC_VERSION := " to the name of the folder you placed the toolchain in (your_version is the example used above)

    How can I fix module issues when compiling with Polly?
    It's simple. Just take the module name (ex. "target C++: module_name_here <= some/path/to/code") and add it to the DISABLE_POLLY list. You can also disable Clang all together, use AOSP clang, or force GCC modules to use Clang.

    Why call it DragonTC?
    The LLVM logo/mascot is a dragon, so in homage to the developers of LLVM and Clang, I used DragonTC as the name.

    Credits
    A huge thanks to all of the people who helped:
    xboxfanj for recreating the Snapdragon Compiler optimizations
    xanaxdroid for maintenance, bug fixes, and testing
    The LLVM developers for the great work and continuous improvement
    All of the great devs/rom builders that helped test
    and anyone that I missed!

    XDA:DevDB Information
    DragonTC, Tool/Utility for the Android General

    Contributors
    frap129, xanaxdroid
    Source Code: https://github.com/dragon-tc


    Version Information
    Status: Beta

    Created 2016-02-19
    Last Updated 2016-05-21
    6
    This sounds interesting. Thanks for sharing your work. I might try it, but as a bloody beginner, can you maybe give a bit more detail on how it affects building / the result?

    Once I get a bit more time, I'll edit the op to have more information. In short, Clang is a compiler (like GCC) that is rapidly growing. Google is currently using Clang 3.6 which produces binaries that perform slower than GCC compiled binaries, but they choose to use Clang because it takes less time to compile overall. DragonTC allows you to use the latest Clang toolchains (3.6, 3.7, 3.8, or 3.9) with extra functionality that Google doesn't have, such as LTO, Polly, OpenMP, and Snapdragon Krait optimizations. These make your rom (or anything you compile with it) perform better than if you were to use the stock AOSP clang.