Skip to content
Clang C/C++ cross compiler and runtime for OpenEmbedded/Yocto
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
classes
conf Fix typos in overrides for compiler rt Mar 5, 2019
dynamic-layers/openembedded-layer/recipes-kernel/kernel-selftest layer.conf: Use dynamic layer feature Dec 28, 2018
recipes-bsp/systemd-boot systemd-boot: Do not export NM, AR and RANLIB Dec 28, 2018
recipes-connectivity
recipes-core busybox: Use gcc to compile on x86 Mar 3, 2019
recipes-devtools/clang clang: Update to latest on 8.x release Mar 15, 2019
recipes-extended/mdadm
recipes-gnome/gcr gcr: Do not use introspection when using clang Aug 27, 2017
recipes-graphics Remove the + sign when using append Mar 15, 2019
recipes-kernel/perf
recipes-multimedia/libvorbis
recipes-support/libunwind libunwind: Use static version from libcxx Feb 10, 2019
COPYING.MIT Intial commit Sep 12, 2014
README.md
_config.yml

README.md

meta-clang (a C language family frontend and LLVM compiler backend)

This layer provides clang/llvm as alternative to your system C/C++ compiler for OpenEmbedded based distributions along with gcc

Getting Started

git clone git://github.com/openembedded/openembedded-core.git
cd openembedded-core
git clone git://github.com/openembedded/bitbake.git
git clone git://github.com/kraj/meta-clang.git

$ . ./oe-init-build-env

Edit conf/bblayers.conf to add meta-clang to layer mix e.g.

BBLAYERS ?= " \
  /home/kraj/openembedded-core/meta-clang \
  /home/kraj/openembedded-core/meta \
  "

Default Compiler Switch

Note that by default gcc will remain the system compiler, however if you wish clang to be the default compiler then set

TOOLCHAIN ?= "clang"

in local.conf, this would now switch to using clang as default compiler systemwide you can select clang per package too by writing bbappends for them containing

TOOLCHAIN = "clang"

Default C++ Standard Library Switch

Note that by default clang libc++ is default C++ standard library, however if you wish GNU libstdc++ to be the default one then set

LIBCPLUSPLUS = ""

in local.conf. You can select libstdc++ per package too by writing bbappends for them containing

LIBCPLUSPLUS_toolchain-clang_pn-<recipe> = ""

Default Compiler Runtime ( Compiler-rt + libcxx )

By default, clang build from meta-clang uses gcc runtime ( libgcc + libstdc++ ) out of box However, it is possible to switch to using Clang runtime as default, In order to do that following settings are needed in site configurations e.g. in local.conf

TOOLCHAIN ?= "clang"
TARGET_CXXFLAGS_append_toolchain-clang = " --stdlib=libc++"
TUNE_CCARGS_append_toolchain-clang = " --rtlib=compiler-rt --stdlib=libc++"

Building

Below we build for qemuarm machine as an example

$ MACHINE=qemux86 bitbake core-image-base

Running

$ runqemu qemux86

Limitations

Few components do not build with clang, if you have a component to add to that list simply add it to conf/nonclangable.inc e.g.

TOOLCHAIN_pn-<recipe> = "gcc"

and OE will start using gcc to cross compile that recipe.

And if a component does not build with libc++, you can add it to conf/nonclangable.inc e.g.

CXX_remove_pn-<recipe>_toolchain-clang = " -stdlib=libc++ "

Dependencies

URI: git://github.com/openembedded/openembedded-core.git
branch: master
revision: HEAD

URI: git://github.com/openembedded/bitbake.git
branch: master
revision: HEAD

Send pull requests to openembedded-devel@lists.openembedded.org with '[meta-clang]' in the subject'

When sending single patches, please use something like:

'git send-email -M -1 --to openembedded-devel@lists.openembedded.org --subject-prefix=meta-clang][PATCH'

You are encouraged to fork the mirror on github to share your patches, this is preferred for patch sets consisting of more than one patch. Other services like gitorious, repo.or.cz or self hosted setups are of course accepted as well, 'git fetch ' works the same on all of them. We recommend github because it is free, easy to use, has been proven to be reliable and has a really good web GUI.

Layer Maintainer: Khem Raj

You can’t perform that action at this time.