Building native compiler for Android-x86 6.0.1

256 views
Skip to first unread message

Jihyun Son

unread,
Mar 20, 2016, 7:28:11 AM3/20/16
to Android-x86
I have been trying to compile some sources such as powertop to analyze my tablet's power consumption.
Simply too hard to get it done by putting those codes into external/powertop tree with dependancies.
(Well I don't like all the ways I should use Android.mk...)

So I thought very thumb way: can I build native gcc compiler for Android-x86?

Spent a whole day... Got it working but I don't know that's enough.

- download android ndk and make standalone toolchain for API 23, because I'm on MM 6.0.1
- using the toolchain with included sysroot, build binutils-2.25.1 and gcc-4.9.3 with mpc, mpfr, gmp.
- put all together into some place in my tablet. (/system/gcc in my case)
- make hello world code and compile with PIE support.
- success.

So I'm going to build powertop, hope it will go well without any issue.

P.S: Should I care about bionic? I heard that's a standard C library but what's different than sysroot from NDK toolchain?

Chih-Wei Huang

unread,
Mar 20, 2016, 10:51:18 PM3/20/16
to Android-x86
2016-03-20 19:28 GMT+08:00 Jihyun Son <itaz...@gmail.com>:
> I have been trying to compile some sources such as powertop to analyze my
> tablet's power consumption.
> Simply too hard to get it done by putting those codes into external/powertop
> tree with dependancies.
> (Well I don't like all the ways I should use Android.mk...)

You should just learn how to write an Android.mk.
Or you have to go through all the details of "cross-compile".

> So I thought very thumb way: can I build native gcc compiler for
> Android-x86?
>
> Spent a whole day... Got it working but I don't know that's enough.
>
> - download android ndk and make standalone toolchain for API 23, because I'm
> on MM 6.0.1
> - using the toolchain with included sysroot, build binutils-2.25.1 and
> gcc-4.9.3 with mpc, mpfr, gmp.
> - put all together into some place in my tablet. (/system/gcc in my case)
> - make hello world code and compile with PIE support.
> - success.

This didn't give you any benefit to your problem.
What you got is just the same binaries in AOSP's prebuilts/gcc/.

The reasons to build toolchains manually are

* You want to learn the techniques to build toolchains
* You want to fix some issues in the prebuilt toolchains

Your problem doesn't fall into these categories I think.

> So I'm going to build powertop, hope it will go well without any issue.

Nope.

> P.S: Should I care about bionic? I heard that's a standard C library but
> what's different than sysroot from NDK toolchain?

Sure. The bionic is Android's C library and
your executable must link with it.

Anyway, I suggest you do more research first
before trying to do something.
I'm very sure someone has ported powertop to Android.
You just need to google it.


--
Chih-Wei
Android-x86 project
http://www.android-x86.org

Jihyun Son

unread,
Mar 20, 2016, 10:59:43 PM3/20/16
to Android-x86
Yeah, you got me.
Nothing left to try more with this bare compiler inside Android-x86.
Just I got some lessons like how to DO cross compile.
I like just try and do before think, huh, sometimes good, sometimes bad. This time? So-so..

I'm googling powertop for Android and somebody already posted that as you said.
Gonna try it and better learn how to use Android.mk

Thanks for the reply.

Reply all
Reply to author
Forward
0 new messages