diff options
-rw-r--r-- | README.md | 61 |
1 files changed, 36 insertions, 25 deletions
@@ -32,7 +32,7 @@ bitbake-layers add-layer ../meta-clang | |||
32 | 32 | ||
33 | Check `conf/bblayers.conf` to see that meta-clang is added to layer mix e.g. | 33 | Check `conf/bblayers.conf` to see that meta-clang is added to layer mix e.g. |
34 | 34 | ||
35 | # Default Compiler Switch | 35 | # Default Compiler |
36 | 36 | ||
37 | Note that by default gcc will remain the system compiler, however if you wish | 37 | Note that by default gcc will remain the system compiler, however if you wish |
38 | clang to be the default compiler then set | 38 | clang to be the default compiler then set |
@@ -47,45 +47,56 @@ you can select clang per recipe too by writing bbappends for them containing | |||
47 | ```shell | 47 | ```shell |
48 | TOOLCHAIN = "clang" | 48 | TOOLCHAIN = "clang" |
49 | ``` | 49 | ``` |
50 | also look at `conf/nonclangable.conf` for list of recipes which do not yet fully | ||
51 | build with clang | ||
50 | 52 | ||
51 | # Default C++ Standard Library Switch | 53 | # Default Compiler Runtime |
52 | 54 | ||
53 | Note that by default clang libc++ is default C++ standard library, however if you wish | 55 | Default is to use GNU runtime `RUNTIME = "gnu"` which consists of libgcc, libstdc++ to provide C/C++ |
54 | to keep GNU libstdc++ to be the default then set | 56 | runtime support. However its possible to use LLVM runtime to replace it where |
57 | compile-rt, llvm libunwind, and libc++ are used to provide C/C++ runtime, while | ||
58 | GNU runtime works with both GCC and Clang, LLVM runtime is only tested with Clang | ||
59 | compiler, Switching to use LLVM runtime is done via a config metadata knob | ||
55 | 60 | ||
56 | ```shell | 61 | ```shell |
57 | LIBCPLUSPLUS = "" | 62 | RUNTIME = "llvm" |
58 | ``` | 63 | ``` |
59 | 64 | ||
60 | in `local.conf`. | 65 | RUNTIME variable influences individual runtime elements and can be set explcitly as well |
61 | You can select libstdc++ per package too by writing bbappends for them containing | 66 | e.g. `LIBCPLUSPLUS` `COMPILER_RT` and `UNWINDLIB` |
62 | 67 | ||
63 | ```shell | 68 | Please note that this will still use crt files from GNU compiler always, while llvm now |
64 | LIBCPLUSPLUS_toolchain-clang_pn-<recipe> = "" | 69 | do provide crt files, they have not been yet intergrated into toolchain |
65 | ``` | ||
66 | 70 | ||
67 | # Default Compiler Runtime ( Compiler-rt + libc++ ) | 71 | # Default C++ Standard Library Switch |
68 | 72 | ||
69 | By default, clang build from meta-clang uses clang runtime ( compiler-rt + libc++ + libunwind ) out of box | 73 | Using RUNTIME bariable will select which C++ runtime is used, however it can be overridden |
70 | However, it is possible to switch to using gcc runtime as default, In order to do that | 74 | if needed to by modifying `LIBCPLUSPLUS` variable, usually defaults used by `RUNTIME` is |
71 | following settings are needed in site configurations e.g. in `local.conf` | 75 | best fit. e.g. below we select LLVM C++ as default C++ runtime. |
72 | 76 | ||
73 | ```shell | 77 | ```shell |
74 | TOOLCHAIN ?= "clang" | 78 | LIBCPLUSPLUS = "--stdlib=libc++" |
75 | LIBCPLUSPLUS = "" | 79 | ``` |
76 | COMPILER_RT = "" | 80 | |
77 | UNWINDLIB = "" | 81 | in `local.conf`. |
82 | You can select libstdc++ per package too by writing bbappends for them containing | ||
78 | 83 | ||
84 | ```shell | ||
85 | LIBCPLUSPLUS_toolchain-clang_pn-<recipe> = "--stdlibc=libc++" | ||
79 | ``` | 86 | ``` |
87 | Defaults are chosen to be GNU for maximum compatibility with existing GNU systems. Its always | ||
88 | good to use single runtime on a system, mixing runtimes can cause complications during | ||
89 | compilation as well as runtime. However, its upto distribution policies to decide which runtime | ||
90 | to use. | ||
80 | 91 | ||
81 | # Removing clang from generated SDK toolchain | 92 | # Adding clang in generated SDK toolchain |
82 | 93 | ||
83 | clang based cross compiler is automatically included into the generated SDK using `bitbake meta-toolchain` or | 94 | clang based cross compiler is not included into the generated SDK using `bitbake meta-toolchain` or |
84 | `bitbake -cpopulate_sdk <image>` in circumstanced where clang is not expected to be part of SDK, then reset `CLANGSDK` | 95 | `bitbake -cpopulate_sdk <image>` if clang is expected to be part of SDK, add `CLANGSDK = "1"` |
85 | variable in `local.conf` | 96 | in `local.conf` |
86 | 97 | ||
87 | ```shell | 98 | ```shell |
88 | CLANGSDK = "" | 99 | CLANGSDK = "1" |
89 | ``` | 100 | ``` |
90 | 101 | ||
91 | # Building | 102 | # Building |
@@ -104,7 +115,7 @@ $ runqemu nographic | |||
104 | # Limitations | 115 | # Limitations |
105 | 116 | ||
106 | Few components do not build with clang, if you have a component to add to that list | 117 | Few components do not build with clang, if you have a component to add to that list |
107 | simply add it to conf/nonclangable.inc e.g. | 118 | simply add it to `conf/nonclangable.inc` e.g. |
108 | 119 | ||
109 | ```shell | 120 | ```shell |
110 | TOOLCHAIN_pn-<recipe> = "gcc" | 121 | TOOLCHAIN_pn-<recipe> = "gcc" |
@@ -112,7 +123,7 @@ TOOLCHAIN_pn-<recipe> = "gcc" | |||
112 | 123 | ||
113 | and OE will start using gcc to cross compile that recipe. | 124 | and OE will start using gcc to cross compile that recipe. |
114 | 125 | ||
115 | And if a component does not build with libc++, you can add it to `conf/nonclangable.inc` e.g. | 126 | if a component does not build with libc++, you can add it to `conf/nonclangable.inc` e.g. |
116 | 127 | ||
117 | ```shell | 128 | ```shell |
118 | CXX_remove_pn-<recipe>_toolchain-clang = " -stdlib=libc++ " | 129 | CXX_remove_pn-<recipe>_toolchain-clang = " -stdlib=libc++ " |