Build openwrt with clang
Alexandru Ardelean
ardeleanalex at gmail.com
Sat Mar 6 16:09:09 GMT 2021
On Sat, Mar 6, 2021 at 10:17 AM Michael Fuckner <michael at fuckner.net> wrote:
>
> Hi,
>
> I'm not exactly sure if this is trivial or totally insane- I have the idea to compile the whole openwrt with clang instead of gcc. I could not get a point to start at. Can you help me?
>
It isn't trivial.
And "insane" depends on who you ask.
But it is some amount of work.
I'm not sure where you want to take this.
To build OpenWrt you need a host gcc/clang that will build the tools
that will build the final image.
So,
1. host-cc builds gcc, binutils, patch, other tools
here; some people have managed to use Clang [even Apple Clang] to build
Usually this works easy when clang is symlinked to gcc ; I don't
know about any clear hints on this
On MacOS, gcc usually points to Apple Clang
But if you search in rules.mk for HOSTCC and HOSTCXX, you can edit those.
Not sure how that works
2. the gcc built in step 1, builds the final image
I'm thinking you want to do 2.
The quickest way to do this, is to try to setup an external toolchain.
1. make menuconfig
2. select ['*] Advanced configuration options (for developers) --->'
and enter menu
3. select '[*] Use external toolchain --->' and enter menu
4. configure all the paths are toolchain prefixes
But you do need to configure a clang compiler specific for the target
you are building for.
I don't know how well this works. Never tried it.
The other method would be to fully-integrate clang along-side gcc.
Which means, a lot of editing in this folder to make sure that you can
hook up clang [in a similar fashion as gcc]:
https://github.com/openwrt/openwrt/tree/master/toolchain
Reading around the comments/code, this may help as a grand view:
https://github.com/openwrt/openwrt/blob/master/toolchain/Makefile#L9
This would be interesting.
It sounds like a fun project to do; but it requires some time/effort.
> Any hints?
>
> Regards,
> Michael!
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list