summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2019-02-08 10:07:54 -0800
committerKhem Raj <raj.khem@gmail.com>2019-02-09 19:27:13 -0800
commit48107e9c52b6ef16174280db582b078f687ae99f (patch)
tree0d54433fd0df6423972c70dcde3b43f4eced6431
parent00b9cd93d591099071e7087b9a354da6338dc1b7 (diff)
downloadmeta-clang-48107e9c52b6ef16174280db582b078f687ae99f.tar.gz
clang: Enable LTO and lld based on distro knobs
Add to local.conf or distro config the following to enable lto flavors and lld linker DISTRO_FEATURES += "thin-lto" DISTRO_FEATURES += "full-lto" DISTRO_FEATURES += "lld" Add lto.bbclass To enable LTO is currently per recipe, or globally to enable globally add following to global config meta-data e.g. local.conf INHRIT += "lto" other-wise enable LTO per recipe using inherit lto to recipe via bbappend or in main recipe Signed-off-by: Khem Raj <raj.khem@gmail.com>
-rw-r--r--classes/clang.bbclass3
-rw-r--r--classes/lto.bbclass7
-rw-r--r--recipes-devtools/clang/clang_git.bb9
3 files changed, 15 insertions, 4 deletions
diff --git a/classes/clang.bbclass b/classes/clang.bbclass
index 88dd893..2d08c10 100644
--- a/classes/clang.bbclass
+++ b/classes/clang.bbclass
@@ -18,6 +18,9 @@ TUNE_CCARGS_append_toolchain-clang = " -Wno-error=unused-command-line-argument -
18TOOLCHAIN_OPTIONS_append_toolchain-clang_class-nativesdk_x86-64 = " -Wl,-dynamic-linker,${base_libdir}/ld-linux-x86-64.so.2" 18TOOLCHAIN_OPTIONS_append_toolchain-clang_class-nativesdk_x86-64 = " -Wl,-dynamic-linker,${base_libdir}/ld-linux-x86-64.so.2"
19TOOLCHAIN_OPTIONS_append_toolchain-clang_class-nativesdk_x86 = " -Wl,-dynamic-linker,${base_libdir}/ld-linux.so.2" 19TOOLCHAIN_OPTIONS_append_toolchain-clang_class-nativesdk_x86 = " -Wl,-dynamic-linker,${base_libdir}/ld-linux.so.2"
20 20
21# Enable lld globally"
22TOOLCHAIN_OPTIONS_append_toolchain-clang = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-lld', ' -fuse-ld=lld', '', d)}"
23
21# choose between 'gcc' 'clang' an empty '' can be used as well 24# choose between 'gcc' 'clang' an empty '' can be used as well
22TOOLCHAIN ??= "gcc" 25TOOLCHAIN ??= "gcc"
23 26
diff --git a/classes/lto.bbclass b/classes/lto.bbclass
new file mode 100644
index 0000000..80a3d4d
--- /dev/null
+++ b/classes/lto.bbclass
@@ -0,0 +1,7 @@
1# Enable LTO based on global distro settings
2TOOLCHAIN_OPTIONS_append_toolchain-clang = "${@bb.utils.contains('DISTRO_FEATURES', 'thin-lto', ' -flto=thin -fuse-ld=gold', '', d)}"
3TOOLCHAIN_OPTIONS_append_toolchain-clang = "${@bb.utils.contains('DISTRO_FEATURES', 'full-lto', ' -flto=full -fuse-ld=gold', '', d)}"
4RANLIB_toolchain-clang = "${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ranlib"
5AR_toolchain-clang = "${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ar"
6NM_toolchain-clang = "${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-nm"
7
diff --git a/recipes-devtools/clang/clang_git.bb b/recipes-devtools/clang/clang_git.bb
index 63709fa..52d013d 100644
--- a/recipes-devtools/clang/clang_git.bb
+++ b/recipes-devtools/clang/clang_git.bb
@@ -43,13 +43,14 @@ def get_clang_target_arch(bb, d):
43def get_clang_experimental_target_arch(bb, d): 43def get_clang_experimental_target_arch(bb, d):
44 return get_clang_experimental_arch(bb, d, 'TARGET_ARCH') 44 return get_clang_experimental_arch(bb, d, 'TARGET_ARCH')
45 45
46PACKAGECONFIG ??= "compiler-rt libcplusplus lto shared-libs" 46PACKAGECONFIG ??= "compiler-rt libcplusplus shared-libs ${@bb.utils.filter('DISTRO_FEATURES', 'thin-lto full-lto', d)}"
47PACKAGECONFIG_class-native = "lto" 47PACKAGECONFIG_class-native = "thin-lto ${@bb.utils.filter('DISTRO_FEATURES', 'full-lto', d)}"
48PACKAGECONFIG_class-nativesdk = "compiler-rt libcplusplus lto" 48PACKAGECONFIG_class-nativesdk = "compiler-rt libcplusplus thin-lto ${@bb.utils.filter('DISTRO_FEATURES', 'full-lto', d)}"
49 49
50PACKAGECONFIG[compiler-rt] = "-DCLANG_DEFAULT_RTLIB=compiler-rt,,compiler-rt" 50PACKAGECONFIG[compiler-rt] = "-DCLANG_DEFAULT_RTLIB=compiler-rt,,compiler-rt"
51PACKAGECONFIG[libcplusplus] = "-DCLANG_DEFAULT_CXX_STDLIB=libc++,,libcxx" 51PACKAGECONFIG[libcplusplus] = "-DCLANG_DEFAULT_CXX_STDLIB=libc++,,libcxx"
52PACKAGECONFIG[lto] = "-DLLVM_ENABLE_LTO=Thin -DLLVM_BINUTILS_INCDIR=${STAGING_INCDIR},,binutils," 52PACKAGECONFIG[thin-lto] = "-DLLVM_ENABLE_LTO=Thin -DLLVM_BINUTILS_INCDIR=${STAGING_INCDIR},,binutils,"
53PACKAGECONFIG[full-lto] = "-DLLVM_ENABLE_LTO=Full -DLLVM_BINUTILS_INCDIR=${STAGING_INCDIR},,binutils,"
53PACKAGECONFIG[shared-libs] = "-DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON,,," 54PACKAGECONFIG[shared-libs] = "-DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON,,,"
54 55
55# 56#