[Feature]add MT2731_MP2_MR2_SVN388 baseline version

Change-Id: Ief04314834b31e27effab435d3ca8ba33b499059
diff --git a/meta/meta-clang/COPYING.MIT b/meta/meta-clang/COPYING.MIT
new file mode 100644
index 0000000..fb950dc
--- /dev/null
+++ b/meta/meta-clang/COPYING.MIT
@@ -0,0 +1,17 @@
+Permission is hereby granted, free of charge, to any person obtaining a copy 
+of this software and associated documentation files (the "Software"), to deal 
+in the Software without restriction, including without limitation the rights 
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
+copies of the Software, and to permit persons to whom the Software is 
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in 
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
+THE SOFTWARE.
diff --git a/meta/meta-clang/README.md b/meta/meta-clang/README.md
new file mode 100644
index 0000000..f5e5c26
--- /dev/null
+++ b/meta/meta-clang/README.md
@@ -0,0 +1,125 @@
+# meta-clang (a C language family frontend and LLVM compiler backend)
+
+This layer provides [clang/llvm](http://clang.llvm.org/) as alternative to your system
+C/C++ compiler for OpenEmbedded based distributions along with gcc
+
+# Getting Started
+
+```shell
+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.
+
+```python
+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
+
+```python
+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
+
+```python
+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
+
+```python
+LIBCPLUSPLUS = ""
+```
+
+in local.conf.
+You can select libstdc++ per package too by writing bbappends for them containing
+
+```python
+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
+
+```python
+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
+
+```shell
+$ MACHINE=qemux86 bitbake core-image-base
+```
+# Running
+
+```shell
+$ 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.
+
+```shell
+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.
+
+```shell
+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](https://github.com/kraj/meta-clang/)
+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 <remote>' 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](<mailto:raj.khem@gmail.com>)
diff --git a/meta/meta-clang/_config.yml b/meta/meta-clang/_config.yml
new file mode 100644
index 0000000..c419263
--- /dev/null
+++ b/meta/meta-clang/_config.yml
@@ -0,0 +1 @@
+theme: jekyll-theme-cayman
\ No newline at end of file
diff --git a/meta/meta-clang/classes/clang.bbclass b/meta/meta-clang/classes/clang.bbclass
new file mode 100644
index 0000000..d6a4e9b
--- /dev/null
+++ b/meta/meta-clang/classes/clang.bbclass
@@ -0,0 +1,66 @@
+# Add the necessary override
+CC_toolchain-clang  = "${CCACHE}${HOST_PREFIX}clang ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
+CXX_toolchain-clang = "${CCACHE}${HOST_PREFIX}clang++ ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
+CPP_toolchain-clang = "${CCACHE}${HOST_PREFIX}clang ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} -E"
+CCLD_toolchain-clang = "${CCACHE}${HOST_PREFIX}clang ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
+CLANG_TIDY_EXE_toolchain-clang = "${CCACHE}${HOST_PREFIX}clang-tidy ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
+RANLIB_toolchain-clang = "${HOST_PREFIX}llvm-ranlib"
+AR_toolchain-clang = "${HOST_PREFIX}llvm-ar"
+NM_toolchain-clang = "${HOST_PREFIX}llvm-nm"
+
+COMPILER_RT ??= "--rtlib=compiler-rt"
+LIBCPLUSPLUS ??= "--stdlib=libc++"
+
+COMPILER_RT_toolchain-gcc = ""
+LIBCPLUSPLUS_toolchain-gcc = ""
+
+TARGET_CXXFLAGS_append_toolchain-clang = " ${LIBCPLUSPLUS}"
+TUNE_CCARGS_append_toolchain-clang = " ${COMPILER_RT} ${LIBCPLUSPLUS}"
+
+THUMB_TUNE_CCARGS_remove_toolchain-clang = "-mthumb-interwork"
+TUNE_CCARGS_remove_toolchain-clang = "-meb"
+TUNE_CCARGS_remove_toolchain-clang = "-mel"
+TUNE_CCARGS_append_toolchain-clang = "${@bb.utils.contains("TUNE_FEATURES", "bigendian", " -mbig-endian", " -mlittle-endian", d)}"
+
+TUNE_CCARGS_remove_toolchain-clang_powerpc = "-mhard-float"
+TUNE_CCARGS_remove_toolchain-clang_powerpc = "-mno-spe"
+
+TUNE_CCARGS_append_toolchain-clang = " -Wno-error=unused-command-line-argument -Qunused-arguments"
+
+LDFLAGS_append_toolchain-clang_class-nativesdk_x86-64 = " -Wl,-dynamic-linker,${base_libdir}/ld-linux-x86-64.so.2"
+LDFLAGS_append_toolchain-clang_class-nativesdk_x86 = " -Wl,-dynamic-linker,${base_libdir}/ld-linux.so.2"
+LDFLAGS_append_toolchain-clang_class-nativesdk_aarch64 = " -Wl,-dynamic-linker,${base_libdir}/ld-linux-aarch64.so.1"
+
+LDFLAGS_toolchain-clang_class-nativesdk = "${BUILDSDK_LDFLAGS} \
+                                           -Wl,-rpath-link,${STAGING_LIBDIR}/.. \
+                                           -Wl,-rpath,${libdir}/.. "
+
+# Enable lld globally"
+LDFLAGS_append_toolchain-clang = "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-lld', ' -fuse-ld=lld', '', d)}"
+
+# choose between 'gcc' 'clang' an empty '' can be used as well
+TOOLCHAIN ??= "gcc"
+
+TOOLCHAIN_class-native = "gcc"
+TOOLCHAIN_class-nativesdk = "gcc"
+TOOLCHAIN_class-cross-canadian = "gcc"
+TOOLCHAIN_class-crosssdk = "gcc"
+TOOLCHAIN_class-cross = "gcc"
+
+OVERRIDES =. "${@['', 'toolchain-${TOOLCHAIN}:']['${TOOLCHAIN}' != '']}"
+OVERRIDES[vardepsexclude] += "TOOLCHAIN"
+
+#DEPENDS_append_toolchain-clang_class-target = " clang-cross-${TARGET_ARCH} "
+#DEPENDS_remove_toolchain-clang_allarch = "clang-cross-${TARGET_ARCH}"
+
+def clang_dep_prepend(d):
+    if not d.getVar('INHIBIT_DEFAULT_DEPS', False):
+        if not oe.utils.inherits(d, 'allarch') :
+            return " clang-cross-${TARGET_ARCH} compiler-rt libcxx"
+    return ""
+
+BASEDEPENDS_remove_toolchain-clang_class-target = "virtual/${TARGET_PREFIX}gcc virtual/${TARGET_PREFIX}compilerlibs"
+BASEDEPENDS_append_toolchain-clang_class-target = "${@clang_dep_prepend(d)}"
+
+PREFERRED_PROVIDER_libunwind = "libunwind"
+PREFERRED_PROVIDER_libunwind_mipsarch = "libunwind"
diff --git a/meta/meta-clang/classes/cmake-native.bbclass b/meta/meta-clang/classes/cmake-native.bbclass
new file mode 100644
index 0000000..7cdb89d
--- /dev/null
+++ b/meta/meta-clang/classes/cmake-native.bbclass
@@ -0,0 +1,51 @@
+# We need to unset CCACHE otherwise cmake gets too confused
+CCACHE = ""
+
+# Native C/C++ compiler (without cpu arch/tune arguments)
+OECMAKE_NATIVE_C_COMPILER ?= "`echo ${BUILD_CC} | sed 's/^\([^ ]*\).*/\1/'`"
+OECMAKE_NATIVE_CXX_COMPILER ?= "`echo ${BUILD_CXX} | sed 's/^\([^ ]*\).*/\1/'`"
+OECMAKE_NATIVE_AR ?= "${BUILD_AR}"
+OECMAKE_NATIVE_RANLIB ?= "${BUILD_RANLIB}"
+OECMAKE_NATIVE_NM ?= "${BUILD_NM}"
+
+# Native compiler flags
+OECMAKE_NATIVE_C_FLAGS ?= "${BUILD_CC_ARCH} ${BUILD_CFLAGS}"
+OECMAKE_NATIVE_CXX_FLAGS ?= "${BUILD_CC_ARCH} ${BUILD_CXXFLAGS}"
+OECMAKE_NATIVE_C_FLAGS_RELEASE ?= "-DNDEBUG"
+OECMAKE_NATIVE_CXX_FLAGS_RELEASE ?= "-DNDEBUG"
+OECMAKE_NATIVE_C_LINK_FLAGS ?= "${BUILD_CC_ARCH} ${BUILD_CPPFLAGS} ${BUILD_LDFLAGS}"
+OECMAKE_NATIVE_CXX_LINK_FLAGS ?= "${BUILD_CC_ARCH} ${BUILD_CXXFLAGS} ${BUILD_LDFLAGS}"
+BUILD_CXXFLAGS += "${BUILD_CC_ARCH}"
+BUILD_CFLAGS += "${BUILD_CC_ARCH}"
+
+do_generate_native_toolchain_file() {
+        cat > ${WORKDIR}/toolchain-native.cmake <<EOF
+set( CMAKE_SYSTEM_NAME `echo ${BUILD_OS} | sed -e 's/^./\u&/' -e 's/^\(Linux\).*/\1/'` )
+set( CMAKE_SYSTEM_PROCESSOR ${BUILD_ARCH} )
+set( CMAKE_C_COMPILER ${OECMAKE_NATIVE_C_COMPILER} )
+set( CMAKE_CXX_COMPILER ${OECMAKE_NATIVE_CXX_COMPILER} )
+set( CMAKE_ASM_COMPILER ${OECMAKE_NATIVE_C_COMPILER} )
+set( CMAKE_AR ${OECMAKE_NATIVE_AR} CACHE FILEPATH "Archiver" )
+set( CMAKE_RANLIB ${OECMAKE_NATIVE_RANLIB} CACHE FILEPATH "Archive Indexer" )
+set( CMAKE_NM ${OECMAKE_NATIVE_NM} CACHE FILEPATH "Symbol Lister" )
+set( CMAKE_C_FLAGS "${OECMAKE_NATIVE_C_FLAGS}" CACHE STRING "CFLAGS" )
+set( CMAKE_CXX_FLAGS "${OECMAKE_NATIVE_CXX_FLAGS}" CACHE STRING "CXXFLAGS" )
+set( CMAKE_ASM_FLAGS "${OECMAKE_NATIVE_C_FLAGS}" CACHE STRING "ASM FLAGS" )
+set( CMAKE_C_FLAGS_RELEASE "${OECMAKE_NATIVE_C_FLAGS_RELEASE}" CACHE STRING "Additional CFLAGS for release" )
+set( CMAKE_CXX_FLAGS_RELEASE "${OECMAKE_NATIVE_CXX_FLAGS_RELEASE}" CACHE STRING "Additional CXXFLAGS for release" )
+set( CMAKE_ASM_FLAGS_RELEASE "${OECMAKE_NATIVE_C_FLAGS_RELEASE}" CACHE STRING "Additional ASM FLAGS for release" )
+set( CMAKE_C_LINK_FLAGS "${OECMAKE_NATIVE_C_LINK_FLAGS}" CACHE STRING "LDFLAGS" )
+set( CMAKE_CXX_LINK_FLAGS "${OECMAKE_NATIVE_CXX_LINK_FLAGS}" CACHE STRING "LDFLAGS" )
+
+set( CMAKE_FIND_ROOT_PATH ${STAGING_DIR_NATIVE} )
+set( CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY )
+set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH )
+set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
+set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
+
+# Use native cmake modules
+list(APPEND CMAKE_MODULE_PATH "${STAGING_DATADIR_NATIVE}/cmake/Modules/")
+EOF
+}
+
+addtask generate_native_toolchain_file after do_patch before do_configure
diff --git a/meta/meta-clang/classes/lto.bbclass b/meta/meta-clang/classes/lto.bbclass
new file mode 100644
index 0000000..80a3d4d
--- /dev/null
+++ b/meta/meta-clang/classes/lto.bbclass
@@ -0,0 +1,7 @@
+# Enable LTO based on global distro settings
+TOOLCHAIN_OPTIONS_append_toolchain-clang = "${@bb.utils.contains('DISTRO_FEATURES', 'thin-lto', ' -flto=thin -fuse-ld=gold', '', d)}"
+TOOLCHAIN_OPTIONS_append_toolchain-clang = "${@bb.utils.contains('DISTRO_FEATURES', 'full-lto', ' -flto=full -fuse-ld=gold', '', d)}"
+RANLIB_toolchain-clang = "${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ranlib"
+AR_toolchain-clang = "${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ar"
+NM_toolchain-clang = "${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-nm"
+
diff --git a/meta/meta-clang/classes/scan-build.bbclass b/meta/meta-clang/classes/scan-build.bbclass
new file mode 100644
index 0000000..e0de56b
--- /dev/null
+++ b/meta/meta-clang/classes/scan-build.bbclass
@@ -0,0 +1,58 @@
+# Copyright (C) 2018 Khem Raj <raj.khem@gmail.com>
+# Released under the MIT license (see COPYING.MIT for the terms)
+
+CFLAGS =+ "${TARGET_CC_ARCH} ${TOOLCHAIN_OPTIONS}"
+CXXFLAGS =+ "${TARGET_CC_ARCH} ${TOOLCHAIN_OPTIONS}"
+
+#EXTRA_ANALYZER_OPTIONS ?= "-analyze-headers"
+CLANG_SCAN_ENABLED ??= "1"
+#CLANG_SCAN_SERVER_IP ??= "127.0.0.1"
+CLANG_SCAN_SERVER_IP ??= "10.0.0.10"
+CLANG_SCAN_PORT ??= "8181"
+SCAN_RESULTS_DIR ?= "${TMPDIR}/static-scan/${PN}"
+
+scanbuild_munge_cc_cxx() {
+        cc="`echo ${CC} | cut -f1 -d " "`"
+        cxx="`echo ${CXX} | cut -f1 -d " "`"
+        export CC="${cc}"
+        export CXX="${cxx}"
+}
+
+do_configure[prefuncs] += "scanbuild_munge_cc_cxx"
+
+do_scanbuild() {
+        cc="`echo ${CC} | cut -f1 -d " "`"
+        cxx="`echo ${CXX} | cut -f1 -d " "`"
+        #mk="scan-build --use-cc=${cc} --use-c++=${cxx} --analyzer-target=${HOST_SYS} --html-title="${BP}" -o ${SCAN_RESULTS_DIR} ${EXTRA_ANALYZER_OPTIONS} make"
+        #export MAKE="${mk}"
+        export CC="${cc}"
+        export CXX="${cxx}"
+        scan-build --use-cc=${cc} --use-c++=${cxx} --analyzer-target=${HOST_SYS} --html-title="${BP}" -o ${SCAN_RESULTS_DIR} ${EXTRA_ANALYZER_OPTIONS} ${MAKE} ${EXTRA_OEMAKE}
+}
+
+do_scanview() {
+        bbplain "================================================================"
+        bbplain "Stating scan-view server at: http://${CLANG_SCAN_SERVER_IP}:${CLANG_SCAN_PORT}"
+        bbplain "Use Ctrl-C to exit"
+        bbplain "================================================================"
+        scan-view --host ${CLANG_SCAN_SERVER_IP} --port ${CLANG_SCAN_PORT} --allow-all-hosts ${SCAN_RESULTS_DIR}/*/
+}
+
+do_scanview[depends] += "${PN}:do_scanbuild"
+do_scanbuild[cleandirs] += "${SCAN_RESULTS_DIR}"
+do_scanbuild[dirs] += "${B}"
+do_scanview[dirs] += "${SCAN_RESULTS_DIR}"
+#do_build[recrdeptask] += "do_scanbuild"
+
+do_scanbuild[doc] = "Build and scan static analysis data using clang"
+do_scanview[doc] = "Start a webserver to visualize static analysis data"
+
+addtask scanbuild after do_configure before do_compile
+addtask scanview
+
+python () {
+    # Remove scanbuild task when scanning is not enabled
+    if not(d.getVar('CLANG_SCAN_ENABLED') == "1"):
+        for i in ['do_scanbuild', 'do_scanview']:
+            bb.build.deltask(i, d)
+}
diff --git a/meta/meta-clang/conf/layer.conf b/meta/meta-clang/conf/layer.conf
new file mode 100644
index 0000000..eacedf1
--- /dev/null
+++ b/meta/meta-clang/conf/layer.conf
@@ -0,0 +1,23 @@
+# We have a conf and classes directory, append to BBPATH
+BBPATH .= ":${LAYERDIR}"
+
+# We have a recipes directory, add to BBFILES
+BBFILES += "${LAYERDIR}/recipes*/*/*.bb ${LAYERDIR}/recipes*/*/*.bbappend"
+
+BBFILE_COLLECTIONS += "clang-layer"
+BBFILE_PATTERN_clang-layer := "^${LAYERDIR}/"
+BBFILE_PRIORITY_clang-layer = "7"
+LAYERSERIES_COMPAT_clang-layer = "sumo thud warrior"
+
+BBFILES_DYNAMIC += " \
+    openembedded-layer:${LAYERDIR}/dynamic-layers/openembedded-layer/*/*/*.bb \
+    openembedded-layer:${LAYERDIR}/dynamic-layers/openembedded-layer/*/*/*.bbappend \
+    networking-layer:${LAYERDIR}/dynamic-layers/networking-layer/*/*/*.bb \
+    networking-layer:${LAYERDIR}/dynamic-layers/networking-layer/*/*/*.bbappend \
+"
+
+PREFERRED_PROVIDER_libgcc-initial = "libgcc-initial"
+#PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}compilerlibs_forcevariable = "libcxx"
+INHERIT += "clang"
+
+require conf/nonclangable.conf
diff --git a/meta/meta-clang/conf/nonclangable.conf b/meta/meta-clang/conf/nonclangable.conf
new file mode 100644
index 0000000..215bd1c
--- /dev/null
+++ b/meta/meta-clang/conf/nonclangable.conf
@@ -0,0 +1,196 @@
+TOOLCHAIN_pn-aspell = "gcc"
+TOOLCHAIN_pn-cpufrequtils = "gcc"
+# crash embeds version of gdb which is not buildable with clang
+TOOLCHAIN_pn-crash = "gcc"
+TOOLCHAIN_pn-elfutils = "gcc"
+# /mnt/a/yoe/build/tmp/work/cortexa7t2hf-neon-vfpv4-yoe-linux-gnueabi/firefox/60.1.0esr-r0/recipe-sysroot-native/usr/lib/clang/7.0.1/include/arm_neon.h:433:1: error: unknown type name 'inline'
+# __ai uint8x16_t vabdq_u8(uint8x16_t __p0, uint8x16_t __p1) {
+TOOLCHAIN_pn-firefox = "gcc"
+TOOLCHAIN_pn-gcc = "gcc"
+TOOLCHAIN_pn-gcc-runtime = "gcc"
+TOOLCHAIN_pn-gcc-sanitizers = "gcc"
+TOOLCHAIN_pn-glibc = "gcc"
+TOOLCHAIN_pn-glibc-initial = "gcc"
+TOOLCHAIN_pn-glibc-locale = "gcc"
+TOOLCHAIN_pn-glibc-mtrace = "gcc"
+TOOLCHAIN_pn-glibc-scripts = "gcc"
+TOOLCHAIN_pn-grub = "gcc"
+TOOLCHAIN_pn-grub-efi = "gcc"
+# VLAs
+#| control.c:286:19: error: fields must have a constant size: 'variable length array in structure' extension will never be supported
+#|             __u32 buffer[cam->max_response_quads];
+#|                   ^
+#| 1 error generated.
+TOOLCHAIN_pn-libdc1394 = "gcc"
+TOOLCHAIN_pn-libgcc = "gcc"
+TOOLCHAIN_pn-libgcc-initial = "gcc"
+TOOLCHAIN_pn-libgfortran = "gcc"
+TOOLCHAIN_pn-libssp-nonshared = "gcc"
+#| cargo:warning=/mnt/a/yoe/build/tmp/work/cortexa7t2hf-neon-vfpv4-yoe-linux-gnueabi/libstd-rs/1.27.1-r0/re
+#cipe-sysroot/usr/include/bits/stdlib.h:90:3: error: "Assumed value of MB_LEN_MAX wrong"
+#| cargo:warning=# error "Assumed value of MB_LEN_MAX wrong"
+#| cargo:warning=  ^
+TOOLCHAIN_pn-libstd-rs = "gcc"
+# clang does not have 64bit atomics on mips32
+TOOLCHAIN_pn-mesa_mips = "gcc"
+TOOLCHAIN_pn-mesa_mipsel = "gcc"
+TOOLCHAIN_pn-openjdk-8 = "gcc"
+TOOLCHAIN_pn-openjre-8 = "gcc"
+TOOLCHAIN_pn-piglit = "gcc"
+TOOLCHAIN_pn-prelink = "gcc"
+# has dpkg source which does not compile
+TOOLCHAIN_pn-start-stop-daemon = "gcc"
+TOOLCHAIN_pn-syslinux = "gcc"
+TOOLCHAIN_pn-systemtap = "gcc"
+# v4l-utils uses nested functions
+TOOLCHAIN_pn-v4l-utils = "gcc"
+TOOLCHAIN_pn-valgrind = "gcc"
+# uses C++ which clang does not like
+TOOLCHAIN_pn-wvstreams = "gcc"
+TOOLCHAIN_pn-wvdial = "gcc"
+#| ../../mpfr-3.1.4/src/mul.c:324:11: error: invalid output constraint '=h' in asm
+#|           umul_ppmm (tmp[1], tmp[0], MPFR_MANT (b)[0], MPFR_MANT (c)[0]);
+TOOLCHAIN_pn-mpfr_mips = "gcc"
+TOOLCHAIN_pn-mpfr_mips64 = "gcc"
+#
+#../../lib/libicui18n.so: undefined reference to `__atomic_fetch_sub_4'
+#../../lib/libicui18n.so: undefined reference to `__atomic_load_4'
+#../../lib/libicui18n.so: undefined reference to `__atomic_store_4'
+#../../lib/libicui18n.so: undefined reference to `__atomic_fetch_add_4'
+#
+TOOLCHAIN_pn-icu_armv4 = "gcc"
+TOOLCHAIN_pn-icu_armv5 = "gcc"
+
+#../../libgcrypt-1.6.5/mpi/mpih-div.c:98:3: error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast or build with -fheinous-gnu-extensions
+TOOLCHAIN_pn-libgcrypt_mips64 = "gcc"
+
+#| ../../pixman-0.34.0/test/utils-prng.c:131:29: error: cannot convert between vector type '__attribute__((__vector_size__(16 * sizeof(char)))) char' (vector of 16 'char' values) and vector type 'uint8x16' (vector of 16 'uint8_t' values) as implicit conversion would cause truncation
+#|                 randdata.vb |= (t.vb >= const_C0#);
+#|                             ^
+# also see http://lists.llvm.org/pipermail/llvm-dev/2016-October/105997.html
+TOOLCHAIN_pn-pixman = "gcc"
+
+#| ./ports/linux/pseudo_wrappers.c:80:14: error: use of unknown builtin '__builtin_apply' [-Wimplicit-function-declaration]
+#|         void *res = __builtin_apply((void (*)()) real_syscall, __builtin_apply_args(), sizeof(long) * 7);
+#|                     ^
+#| ./ports/linux/pseudo_wrappers.c:80:57: error: use of unknown builtin '__builtin_apply_args' [-Wimplicit-function-declaration]
+#|         void *res = __builtin_apply((void (*)()) real_syscall, __builtin_apply_args(), sizeof(long) * 7);
+
+TOOLCHAIN_pn-pseudo = "gcc"
+#| ../../pulseaudio-10.0/src/pulsecore/mix_neon.c../../pulseaudio-10.0/src/pulsecore/sconv_neon.c:49::27: error: unknown register name 'q0' in asm
+#|         : "memory", "cc", "q0" /* clobber list */
+#|                           ^
+TOOLCHAIN_pn-pulseaudio_aarch64 = "gcc"
+# mix_neon.c:179:9: error: invalid operand in inline asm: 'vld1.s32 ${0:h}, [$2]
+#      vld1.s32 ${1:h}, [$3] '
+TOOLCHAIN_pn-pulseaudio_armv7ve = "gcc"
+TOOLCHAIN_pn-pulseaudio_armv7a = "gcc"
+
+# clang++ 6.0 crashes during link phase of a shared library
+TOOLCHAIN_pn-wpewebkit = "gcc"
+
+# x264 causes a infinite loop when compiling 1 source file
+#
+TOOLCHAIN_pn-x264_x86 = "gcc"
+
+#| /usr/src/debug/qemu/2.6.0-r1/qemu-2.6.0/util/bitmap.c:191: undefined reference to `__atomic_fetch_or_4'
+#| /usr/src/debug/qemu/2.6.0-r1/qemu-2.6.0/util/bitmap.c:210: undefined reference to `__atomic_fetch_or_4'
+#| libqemuutil.a(bitmap.o): In function `bitmap_test_and_clear_atomic':
+#| /usr/src/debug/qemu/2.6.0-r1/qemu-2.6.0/util/bitmap.c:250: undefined reference to `__atomic_fetch_and_4'
+#| /usr/src/debug/qemu/2.6.0-r1/qemu-2.6.0/util/bitmap.c:262: undefined reference to `__atomic_exchange_4'
+#| /usr/src/debug/qemu/2.6.0-r1/qemu-2.6.0/util/bitmap.c:273: undefined reference to `__atomic_fetch_and_4'
+# We need to link in with -latomic which comes from gcc-runtime anyway so just keep using gcc
+# to compile qemu for target
+TOOLCHAIN_pn-qemu_arm = "gcc"
+
+# llvm-profdata fails see
+# | error: Could not read profile code.profd: No such file or directory
+TOOLCHAIN_pn-python3 = "gcc"
+
+#| ./dsp/v4f_IIR2.h:554:12: error: no matching function for call to 'v4f_map'
+#|                                 a[5] = v4f_map<__builtin_cosf> (f);
+#|                                        ^~~~~~~~~~~~~~~~~~~~~~~
+TOOLCHAIN_pn-caps = "gcc"
+
+CFLAGS_append_pn-liboil_toolchain-clang_x86-64 = " -fheinous-gnu-extensions "
+
+#io_getevents.c:25:141: error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast or build with -fheinous-gnu-extensions
+#io_syscall5(int, __io_getevents_0_4, io_getevents, io_context_t, ctx, long, min_nr, long, nr, struct io_event *, events, struct timespec *, timeout)
+CFLAGS_append_pn-libaio_toolchain-clang_mips = " -fheinous-gnu-extensions"
+
+#| error: unknown warning option '-Wimplicit-fallthrough=0'; did you mean '-Wimplicit-fallthrough'? [-Werror,-Wunknown-warning-option]
+CFLAGS_append_pn-mdadm_toolchain-clang = " -Wno-error=unknown-warning-option"
+
+#../libffi-3.2.1/src/arm/sysv.S:363:2: error: invalid instruction, did you mean: fldmiax?
+# fldmiadgt ip, {d0-d7}
+CFLAGS_append_pn-libffi_toolchain-clang = " -no-integrated-as"
+# ../db-5.3.28/src/mutex/mut_tas.c:150:34: error: unknown directive
+#<inline asm>:9:2: note: instantiated into assembly here
+# .force_thumb
+#        ^
+CFLAGS_append_pn-db_toolchain-clang = " -no-integrated-as"
+#
+#| ../../../DirectFB-1.7.7/lib/direct/armasm_memcpy.S:63:2: error: invalid instruction
+#|  ldmgeia r1!, {r3, r4, r12, lr}
+#|  ^
+CFLAGS_append_pn-directfb_toolchain-clang_arm = " -no-integrated-as"
+
+# Disable internal assembler for armv7 since it uses gnu assmebly syntax
+# which should be preprocessed via gcc/compiler
+#
+CFLAGS_append_pn-openssl_toolchain-clang_armv7ve = " -no-integrated-as"
+CFLAGS_append_pn-openssl_toolchain-clang_armv7a = " -no-integrated-as"
+CFLAGS_append_pn-openssl10_toolchain-clang_armv7ve = " -no-integrated-as"
+CFLAGS_append_pn-openssl10_toolchain-clang_armv7a = " -no-integrated-as"
+CFLAGS_append_pn-userland_toolchain-clang = " -no-integrated-as"
+
+# src/libswscale/arm/rgb2yuv_neon_common.S:239:11: error: unexpected token in argument list
+# CO_RY .dn d0.s16[0]
+#          ^
+CPPFLAGS_append_pn-gstreamer1.0-libav_toolchain-clang = " -no-integrated-as"
+
+#../kexec-tools-2.0.18/purgatory/arch/i386/entry32-16.S:23:2: error: unknown directive
+# .arch i386
+# ^
+CC_append_pn-kexec-tools_toolchain-clang_x86-64 = " -no-integrated-as"
+CC_append_pn-kexec-tools_toolchain-clang_x86 = " -no-integrated-as"
+CC_append_pn-kexec-tools-klibc_toolchain-clang_x86-64 = " -no-integrated-as"
+CC_append_pn-kexec-tools-klibc_toolchain-clang_x86 = " -no-integrated-as"
+
+#| /tmp/x86-sse2-cdb148.s:207:9: error: ambiguous operand size for instruction 'sub'
+#|     sub SIZE, 64
+#|         ^~~~
+CFLAGS_append_pn-tinymembench_toolchain-clang_x86-64 = " -no-integrated-as"
+CFLAGS_append_pn-tinymembench_toolchain-clang_x86 = " -no-integrated-as"
+
+# regtest.cc:374:39: error: invalid suffix on literal; C++11 requires a
+# space between literal and identifier [-Wreserved-user-defined-literal]
+#|   snprintf_func (buf, sizeof(buf), "%"Q"u", x);
+#|                                       ^
+
+CXXFLAGS_append_pn-xdelta3_toolchain-clang = " -Wno-error=reserved-user-defined-literal"
+# -fno-tree-vrp is gcc specific
+CXXFLAGS_remove_pn-mozjs_toolchain-clang = "-fno-tree-vrp"
+CFLAGS_remove_pn-mozjs_toolchain-clang = "-fno-tree-vrp"
+
+#memcached.c:6280:2: error: embedding a directive within macro arguments has undefined behavior [-Werror,-Wembedded-directive]
+CPPFLAGS_append_pn-memcached_toolchain-clang = " -Wno-error=embedded-directive"
+
+#| /tmp/mcp2515-578c41.s: Assembler messages:
+#| /tmp/mcp2515-578c41.s:1525: Error: r13 not allowed here -- `sub.w sp,r1,#8'
+#| /tmp/mcp2515-578c41.s:1821: Error: r13 not allowed here -- `sub.w sp,r6,#8'
+#| clang-7: error: assembler command failed with exit code 1 (use -v to see invocation)
+TUNE_CCARGS_remove_pn-upm_toolchain-clang = "-no-integrated-as"
+TUNE_CCARGS_remove_pn-omxplayer_toolchain-clang = "-no-integrated-as"
+
+#| /usr/src/debug/ruby/2.5.1-r0/build/../ruby-2.5.1/process.c:7073: undefined reference to `__mulodi4'
+#| clang-7: error: linker command failed with exit code 1 (use -v to see invocation)
+LDFLAGS_append_pn-ruby_toolchain-clang = " -rtlib=compiler-rt"
+LDFLAGS_append_pn-m4_toolchain-clang = " -rtlib=compiler-rt"
+
+#(unwind.o): in function `__pthread_unwind':
+#/usr/src/debug/glibc/2.29-r0/git/nptl/unwind.c:121: undefined reference to `_Unwind_ForcedUnwind'
+#clang-8: error: linker command failed with exit code 1 (use -v to see invocation)
+COMPILER_RT_pn-libc-bench_libc-glibc_toolchain-clang_arm = "--rtlib=libgcc"
+COMPILER_RT_pn-aufs-util_libc-glibc_toolchain-clang_arm = "--rtlib=libgcc"
+COMPILER_RT_pn-libhugetlbfs_libc-glibc_toolchain-clang_arm = "--rtlib=libgcc"
diff --git a/meta/meta-clang/dynamic-layers/networking-layer/recipes-connectivity/samba/files/fix_duplicate_pdb_search_init.patch b/meta/meta-clang/dynamic-layers/networking-layer/recipes-connectivity/samba/files/fix_duplicate_pdb_search_init.patch
new file mode 100644
index 0000000..e9d88d2
--- /dev/null
+++ b/meta/meta-clang/dynamic-layers/networking-layer/recipes-connectivity/samba/files/fix_duplicate_pdb_search_init.patch
@@ -0,0 +1,10 @@
+--- a/source3/wscript_build	2019-03-14 09:03:29.498617250 +0100
++++ b/source3/wscript_build	2019-03-14 09:06:19.824949694 +0100
+@@ -124,7 +124,6 @@
+                      '!get_attr_list']
+ private_pdb_match.append('!pdb_nds_*')
+ private_pdb_match.append('!pdb_ldapsam_init*')
+-private_pdb_match.append('!pdb_*_init')
+ private_pdb_match = private_pdb_match + ldapsam_pdb_match
+ 
+ bld.SAMBA3_LIBRARY('samba-passdb',
diff --git a/meta/meta-clang/dynamic-layers/networking-layer/recipes-connectivity/samba/samba_4.8.%.bbappend b/meta/meta-clang/dynamic-layers/networking-layer/recipes-connectivity/samba/samba_4.8.%.bbappend
new file mode 100644
index 0000000..dd3c5f9
--- /dev/null
+++ b/meta/meta-clang/dynamic-layers/networking-layer/recipes-connectivity/samba/samba_4.8.%.bbappend
@@ -0,0 +1,3 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
+
+SRC_URI_append = " file://fix_duplicate_pdb_search_init.patch "
diff --git a/meta/meta-clang/dynamic-layers/openembedded-layer/recipes-kernel/kernel-selftest/kernel-selftest.bbappend b/meta/meta-clang/dynamic-layers/openembedded-layer/recipes-kernel/kernel-selftest/kernel-selftest.bbappend
new file mode 100644
index 0000000..5340962
--- /dev/null
+++ b/meta/meta-clang/dynamic-layers/openembedded-layer/recipes-kernel/kernel-selftest/kernel-selftest.bbappend
@@ -0,0 +1 @@
+DEPENDS_append = " clang-native"
diff --git a/meta/meta-clang/recipes-bsp/systemd-boot/systemd-boot_%.bbappend b/meta/meta-clang/recipes-bsp/systemd-boot/systemd-boot_%.bbappend
new file mode 100644
index 0000000..d5e4bcc
--- /dev/null
+++ b/meta/meta-clang/recipes-bsp/systemd-boot/systemd-boot_%.bbappend
@@ -0,0 +1,4 @@
+do_configure_append_toolchain-clang() {
+	export EFI_CC="${CC}"
+	sed -i -e "s#O0#O#g" ${S}/src/boot/efi/meson.build
+}
diff --git a/meta/meta-clang/recipes-connectivity/openssh/openssh_%.bbappend b/meta/meta-clang/recipes-connectivity/openssh/openssh_%.bbappend
new file mode 100644
index 0000000..88966e5
--- /dev/null
+++ b/meta/meta-clang/recipes-connectivity/openssh/openssh_%.bbappend
@@ -0,0 +1,3 @@
+do_configure_prepend() {
+	sed -i -e '/-ftrapv/d' ${S}/configure.ac
+}
diff --git a/meta/meta-clang/recipes-core/busybox/busybox/0001-writing-to-a-const-variable-is-undefined-behavior-C9.patch b/meta/meta-clang/recipes-core/busybox/busybox/0001-writing-to-a-const-variable-is-undefined-behavior-C9.patch
new file mode 100644
index 0000000..6b933da
--- /dev/null
+++ b/meta/meta-clang/recipes-core/busybox/busybox/0001-writing-to-a-const-variable-is-undefined-behavior-C9.patch
@@ -0,0 +1,27 @@
+From 64c27d12dab4d5a31103f48773733f17c84b0a77 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Wed, 16 Jan 2019 22:39:24 -0800
+Subject: [PATCH] writing to a const variable is undefined behavior (C99 6.7.3
+ paragraph 5).
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ include/libbb.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/include/libbb.h b/include/libbb.h
+index 3366df30f..6b925eb2d 100644
+--- a/include/libbb.h
++++ b/include/libbb.h
+@@ -2092,7 +2092,7 @@ struct globals;
+ /* '*const' ptr makes gcc optimize code much better.
+  * Magic prevents ptr_to_globals from going into rodata.
+  * If you want to assign a value, use SET_PTR_TO_GLOBALS(x) */
+-extern struct globals *const ptr_to_globals;
++extern struct globals *ptr_to_globals;
+ /* At least gcc 3.4.6 on mipsel system needs optimization barrier */
+ #define barrier() __asm__ __volatile__("":::"memory")
+ #define SET_PTR_TO_GLOBALS(x) do { \
+-- 
+2.20.1
+
diff --git a/meta/meta-clang/recipes-core/busybox/busybox_%.bbappend b/meta/meta-clang/recipes-core/busybox/busybox_%.bbappend
new file mode 100644
index 0000000..a4c90f4
--- /dev/null
+++ b/meta/meta-clang/recipes-core/busybox/busybox_%.bbappend
@@ -0,0 +1,3 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+SRC_URI_append_toolchain-clang = " file://0001-writing-to-a-const-variable-is-undefined-behavior-C9.patch"
+TOOLCHAIN_x86 = "gcc"
diff --git a/meta/meta-clang/recipes-core/glib-2.0/glib-2.0_%.bbappend b/meta/meta-clang/recipes-core/glib-2.0/glib-2.0_%.bbappend
new file mode 100644
index 0000000..4a0f94a
--- /dev/null
+++ b/meta/meta-clang/recipes-core/glib-2.0/glib-2.0_%.bbappend
@@ -0,0 +1 @@
+CFLAGS_append_libc-musl = " -Wno-format-nonliteral"
diff --git a/meta/meta-clang/recipes-core/meta/meta-environment.bbappend b/meta/meta-clang/recipes-core/meta/meta-environment.bbappend
new file mode 100644
index 0000000..f385a11
--- /dev/null
+++ b/meta/meta-clang/recipes-core/meta/meta-environment.bbappend
@@ -0,0 +1,17 @@
+export TARGET_CLANGCC_ARCH = "${TARGET_CC_ARCH}"
+TARGET_CLANGCC_ARCH_remove = "-mthumb-interwork"
+TARGET_CLANGCC_ARCH_remove = "-mmusl"
+TARGET_CLANGCC_ARCH_remove = "-muclibc"
+TARGET_CLANGCC_ARCH_remove = "-meb"
+TARGET_CLANGCC_ARCH_remove = "-mel"
+TARGET_CLANGCC_ARCH_append = "${@bb.utils.contains("TUNE_FEATURES", "bigendian", " -mbig-endian", " -mlittle-endian", d)}"
+TARGET_CLANGCC_ARCH_remove_powerpc = "-mhard-float"
+TARGET_CLANGCC_ARCH_remove_powerpc = "-mno-spe"
+
+create_sdk_files_append() {
+        script=${SDK_OUTPUT}/${SDKPATH}/environment-setup-${REAL_MULTIMACH_TARGET_SYS}
+        echo 'export CLANGCC="${TARGET_PREFIX}clang ${TARGET_CLANGCC_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script
+        echo 'export CLANGCXX="${TARGET_PREFIX}clang++ ${TARGET_CLANGCC_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script
+        echo 'export CLANGCPP="${TARGET_PREFIX}clang -E ${TARGET_CLANGCC_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script
+        echo 'export CLANG_TIDY_EXE="${TARGET_PREFIX}clang-tidy ${TARGET_CLANGCC_ARCH} --sysroot=$SDKTARGETSYSROOT"' >> $script
+}
diff --git a/meta/meta-clang/recipes-core/musl/musl_%.bbappend b/meta/meta-clang/recipes-core/musl/musl_%.bbappend
new file mode 100644
index 0000000..652982c
--- /dev/null
+++ b/meta/meta-clang/recipes-core/musl/musl_%.bbappend
@@ -0,0 +1,2 @@
+DEPENDS_append_toolchain-clang = " clang-cross-${TARGET_ARCH}"
+inherit lto
diff --git a/meta/meta-clang/recipes-core/ncurses/ncurses_%.bbappend b/meta/meta-clang/recipes-core/ncurses/ncurses_%.bbappend
new file mode 100644
index 0000000..096d5bc
--- /dev/null
+++ b/meta/meta-clang/recipes-core/ncurses/ncurses_%.bbappend
@@ -0,0 +1 @@
+CACHED_CONFIGUREVARS_append_toolchain-clang = " cf_cv_prog_CC_c_o=yes cf_cv_prog_CXX_c_o=yes"
diff --git a/meta/meta-clang/recipes-core/packagegroups/nativesdk-packagegroup-sdk-host.bbappend b/meta/meta-clang/recipes-core/packagegroups/nativesdk-packagegroup-sdk-host.bbappend
new file mode 100644
index 0000000..a8e81aa
--- /dev/null
+++ b/meta/meta-clang/recipes-core/packagegroups/nativesdk-packagegroup-sdk-host.bbappend
@@ -0,0 +1,3 @@
+NATIVESDKCLANG ?= "nativesdk-clang"
+
+RDEPENDS_${PN} += "${NATIVESDKCLANG}"
diff --git a/meta/meta-clang/recipes-core/packagegroups/packagegroup-core-standalone-sdk-target.bbappend b/meta/meta-clang/recipes-core/packagegroups/packagegroup-core-standalone-sdk-target.bbappend
new file mode 100644
index 0000000..dd0f83c
--- /dev/null
+++ b/meta/meta-clang/recipes-core/packagegroups/packagegroup-core-standalone-sdk-target.bbappend
@@ -0,0 +1,6 @@
+RRECOMMENDS_${PN} += "\
+    libcxx-dev \
+    libcxx-staticdev \
+    compiler-rt-dev \
+    compiler-rt-staticdev \
+"
diff --git a/meta/meta-clang/recipes-core/packagegroups/packagegroup-cross-canadian.bbappend b/meta/meta-clang/recipes-core/packagegroups/packagegroup-cross-canadian.bbappend
new file mode 100644
index 0000000..2618d20
--- /dev/null
+++ b/meta/meta-clang/recipes-core/packagegroups/packagegroup-cross-canadian.bbappend
@@ -0,0 +1,5 @@
+CLANGCROSSCANADIAN ?= "clang-cross-canadian-${TRANSLATED_TARGET_ARCH}"
+CLANGCROSSCANADIAN_riscv64 = ""
+RDEPENDS_${PN} += "\
+    ${@all_multilib_tune_values(d, 'CLANGCROSSCANADIAN')} \
+"
diff --git a/meta/meta-clang/recipes-devtools/clang/clang-cross-canadian_git.bb b/meta/meta-clang/recipes-devtools/clang/clang-cross-canadian_git.bb
new file mode 100644
index 0000000..e93e8a4
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/clang-cross-canadian_git.bb
@@ -0,0 +1,33 @@
+# Copyright (C) 2014 Khem Raj <raj.khem@gmail.com>
+# Released under the MIT license (see COPYING.MIT for the terms)
+
+DESCRIPTION = "Clang/LLVM based C/C++ compiler (cross-canadian for ${TARGET_ARCH} target)"
+HOMEPAGE = "http://clang.llvm.org/"
+LICENSE = "NCSA"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/NCSA;md5=1b5fdec70ee13ad8a91667f16c1959d7"
+SECTION = "devel"
+
+PN = "clang-cross-canadian-${TRANSLATED_TARGET_ARCH}"
+
+require clang.inc
+require common-source.inc
+inherit cross-canadian
+
+DEPENDS += "nativesdk-clang binutils-cross-canadian-${TRANSLATED_TARGET_ARCH} virtual/${HOST_PREFIX}binutils-crosssdk virtual/nativesdk-libc"
+# We have to point gcc at a sysroot but we don't need to rebuild if this changes
+# e.g. we switch between different machines with different tunes.
+EXTRA_OECONF_PATHS[vardepsexclude] = "TUNE_PKGARCH"
+TARGET_ARCH[vardepsexclude] = "TUNE_ARCH"
+
+do_install() {
+        install -d ${D}${bindir}
+	for tool in clang clang++ clang-tidy lld ld.lld llvm-profdata llvm-ar llvm-ranlib llvm-nm
+	do
+		ln -sf ../$tool ${D}${bindir}/${TARGET_PREFIX}$tool
+	done
+}
+SSTATE_SCAN_FILES += "*-clang *-clang++ *-llvm-profdata *-llvm-ar \
+                      *-llvm-ranlib *-llvm-nm *-lld *-ld.lld"
+do_install_append() {
+        cross_canadian_bindirlinks
+}
diff --git a/meta/meta-clang/recipes-devtools/clang/clang-cross_git.bb b/meta/meta-clang/recipes-devtools/clang/clang-cross_git.bb
new file mode 100644
index 0000000..ffe144a
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/clang-cross_git.bb
@@ -0,0 +1,32 @@
+# Copyright (C) 2014 Khem Raj <raj.khem@gmail.com>
+# Released under the MIT license (see COPYING.MIT for the terms)
+
+DESCRIPTION = "Cross compiler wrappers for LLVM based C/C++ compiler"
+HOMEPAGE = "http://clang.llvm.org/"
+LICENSE = "NCSA"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/NCSA;md5=1b5fdec70ee13ad8a91667f16c1959d7"
+SECTION = "devel"
+
+PN = "clang-cross-${TARGET_ARCH}"
+
+require clang.inc
+require common-source.inc
+inherit cross
+DEPENDS += "clang-native binutils-cross-${TARGET_ARCH}"
+
+do_install() {
+        install -d ${D}${bindir}
+	for tool in clang clang++ clang-tidy lld ld.lld llvm-profdata llvm-ar llvm-ranlib llvm-nm
+	do
+		ln -sf ../$tool ${D}${bindir}/${TARGET_PREFIX}$tool
+	done
+}
+SSTATE_SCAN_FILES += "*-clang *-clang++ *-llvm-profdata *-llvm-ar \
+                      *-llvm-ranlib *-llvm-nm *-lld *-ld.lld"
+
+SYSROOT_PREPROCESS_FUNCS += "clangcross_sysroot_preprocess"
+
+clangcross_sysroot_preprocess () {
+        sysroot_stage_dir ${D}${bindir} ${SYSROOT_DESTDIR}${bindir}
+}
+PACKAGES = ""
diff --git a/meta/meta-clang/recipes-devtools/clang/clang-crosssdk_git.bb b/meta/meta-clang/recipes-devtools/clang/clang-crosssdk_git.bb
new file mode 100644
index 0000000..8f07a83
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/clang-crosssdk_git.bb
@@ -0,0 +1,31 @@
+# Copyright (C) 2014 Khem Raj <raj.khem@gmail.com>
+# Released under the MIT license (see COPYING.MIT for the terms)
+
+DESCRIPTION = "SDK Cross compiler wrappers for LLVM based C/C++ compiler"
+HOMEPAGE = "http://clang.llvm.org/"
+LICENSE = "NCSA"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/NCSA;md5=1b5fdec70ee13ad8a91667f16c1959d7"
+SECTION = "devel"
+
+PN = "clang-crosssdk-${TARGET_ARCH}"
+
+require clang.inc
+require common-source.inc
+inherit crosssdk
+DEPENDS += "clang-native nativesdk-clang-glue virtual/${TARGET_PREFIX}binutils-crosssdk virtual/nativesdk-libc"
+
+do_install() {
+        install -d ${D}${bindir}
+	for tool in clang clang++ clang-tidy lld ld.lld llvm-profdata llvm-ar llvm-ranlib llvm-nm
+	do
+		ln -sf ../$tool ${D}${bindir}/${TARGET_PREFIX}$tool
+	done
+}
+SSTATE_SCAN_FILES += "*-clang *-clang++ *-llvm-profdata *-llvm-ar \
+                      *-llvm-ranlib *-llvm-nm *-lld *-ld.lld"
+sysroot_stage_all () {
+        sysroot_stage_dir ${D}${bindir} ${SYSROOT_DESTDIR}${bindir}
+}
+
+PACKAGES = ""
+
diff --git a/meta/meta-clang/recipes-devtools/clang/clang.inc b/meta/meta-clang/recipes-devtools/clang/clang.inc
new file mode 100644
index 0000000..4a2d7c0
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/clang.inc
@@ -0,0 +1,21 @@
+LLVM_RELEASE = ""
+LLVM_DIR = "llvm${LLVM_RELEASE}"
+
+LLVM_GIT ?= "git://github.com/llvm"
+LLVM_GIT_PROTOCOL ?= "https"
+
+MAJOR_VER = "8"
+MINOR_VER = "0"
+PATCH_VER = "1"
+
+SRCREV ?= "9124fda0adfec205856a1ecca76d2cead11a0e2c"
+
+PV = "${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}"
+BRANCH = "release/${MAJOR_VER}.x"
+
+LLVMMD5SUM = "c6b766a4e85dd28301eeed54a6684648"
+CLANGMD5SUM = "9a0fe3a7846ba0ffc822a70d6f7f6903"
+LLDMD5SUM = "f4941ace8ddb3d6cf177fff94966319a"
+LLDBMD5SUM = "b6320ed0b0d00ae661dd94f277bbf024"
+
+require common.inc
diff --git a/meta/meta-clang/recipes-devtools/clang/clang/0001-clang-Enable-SSP-and-PIE-by-default.patch b/meta/meta-clang/recipes-devtools/clang/clang/0001-clang-Enable-SSP-and-PIE-by-default.patch
new file mode 100644
index 0000000..12fb8c5
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/clang/0001-clang-Enable-SSP-and-PIE-by-default.patch
@@ -0,0 +1,63 @@
+From c43bf91bc4f9c913b572f546190ce89a758ee288 Mon Sep 17 00:00:00 2001
+From: Evangelos Foutras <evangelos@foutrelis.com>
+Date: Thu, 20 Sep 2018 06:20:28 +0300
+Subject: [PATCH 01/18] clang: Enable SSP and PIE by default
+
+This is a minimal set of changes needed to make clang use SSP and PIE by
+default on Arch Linux. Tests that were easy to adjust have been changed
+accordingly; only test/Driver/linux-ld.c has been marked as "expected
+failure" due to the number of changes it would require (mostly replacing
+crtbegin.o with crtbeginS.o).
+
+Doing so is needed in order to align clang with the new default GCC
+behavior in Arch which generates PIE executables by default and also
+defaults to -fstack-protector-strong. It is not meant to be a long term
+solution, but a simple temporary fix.
+
+Hopefully these changes will be obsoleted by the introduction upstream
+of a compile-time option (https://bugs.llvm.org/show_bug.cgi?id=13410)
+---
+ clang/lib/Driver/ToolChains/Linux.cpp | 14 ++++++++++++--
+ clang/lib/Driver/ToolChains/Linux.h   |  1 +
+ 2 files changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
+index 65ab9b2daf5..5b757b8028c 100644
+--- a/clang/lib/Driver/ToolChains/Linux.cpp
++++ b/clang/lib/Driver/ToolChains/Linux.cpp
+@@ -968,8 +968,18 @@ void Linux::AddIAMCUIncludeArgs(const ArgList &DriverArgs,
+ }
+ 
+ bool Linux::isPIEDefault() const {
+-  return (getTriple().isAndroid() && !getTriple().isAndroidVersionLT(16)) ||
+-          getTriple().isMusl() || getSanitizerArgs().requiresPIE();
++  const bool IsMips = getTriple().isMIPS();
++  const bool IsAndroid = getTriple().isAndroid();
++
++  if (IsMips || IsAndroid)
++    return (getTriple().isAndroid() && !getTriple().isAndroidVersionLT(16)) ||
++            getTriple().isMusl() || getSanitizerArgs().requiresPIE();
++
++  return true;
++}
++
++unsigned Linux::GetDefaultStackProtectorLevel(bool KernelOrKext) const {
++  return 2;
+ }
+ 
+ bool Linux::IsMathErrnoDefault() const {
+diff --git a/clang/lib/Driver/ToolChains/Linux.h b/clang/lib/Driver/ToolChains/Linux.h
+index 4a662cb4b42..2ddd4056573 100644
+--- a/clang/lib/Driver/ToolChains/Linux.h
++++ b/clang/lib/Driver/ToolChains/Linux.h
+@@ -39,6 +39,7 @@ public:
+                            llvm::opt::ArgStringList &CC1Args) const override;
+   CXXStdlibType GetDefaultCXXStdlibType() const override;
+   bool isPIEDefault() const override;
++  unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override;
+   bool IsMathErrnoDefault() const override;
+   SanitizerMask getSupportedSanitizers() const override;
+   void addProfileRTLibs(const llvm::opt::ArgList &Args,
+-- 
+2.20.1
+
diff --git a/meta/meta-clang/recipes-devtools/clang/clang/0002-clang-driver-Use-lib-for-ldso-on-OE.patch b/meta/meta-clang/recipes-devtools/clang/clang/0002-clang-driver-Use-lib-for-ldso-on-OE.patch
new file mode 100644
index 0000000..3b92897
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/clang/0002-clang-driver-Use-lib-for-ldso-on-OE.patch
@@ -0,0 +1,63 @@
+From b9831e3886b22d243eeb01f0ae67e9485aafd64b Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sat, 21 May 2016 21:52:36 -0700
+Subject: [PATCH 01/18] clang: driver: Use /lib for ldso on OE
+
+OE does not follow the default base_libdir
+that clang has, therefore adjust it for OE
+it wont be able to support multilib since
+in multilib case OE switches the base libdir
+for 64bit to /lib64 instead of /lib
+
+Make sure that the change only happens for cross
+compilation on x86_64 architecture
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ clang/lib/Driver/ToolChains/Linux.cpp | 12 +++++++-----
+ 1 file changed, 7 insertions(+), 5 deletions(-)
+
+diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
+index e9169e91fd4..9c08a794f5c 100644
+--- a/clang/lib/Driver/ToolChains/Linux.cpp
++++ b/clang/lib/Driver/ToolChains/Linux.cpp
+@@ -595,12 +595,12 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
+     Loader = "ld.so.1";
+     break;
+   case llvm::Triple::ppc64:
+-    LibDir = "lib64";
++    LibDir = "lib";
+     Loader =
+         (tools::ppc::hasPPCAbiArg(Args, "elfv2")) ? "ld64.so.2" : "ld64.so.1";
+     break;
+   case llvm::Triple::ppc64le:
+-    LibDir = "lib64";
++    LibDir = "lib";
+     Loader =
+         (tools::ppc::hasPPCAbiArg(Args, "elfv1")) ? "ld64.so.1" : "ld64.so.2";
+     break;
+@@ -622,7 +622,7 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
+     Loader = "ld-linux.so.2";
+     break;
+   case llvm::Triple::sparcv9:
+-    LibDir = "lib64";
++    LibDir = "lib";
+     Loader = "ld-linux.so.2";
+     break;
+   case llvm::Triple::systemz:
+@@ -635,8 +635,10 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
+     break;
+   case llvm::Triple::x86_64: {
+     bool X32 = Triple.getEnvironment() == llvm::Triple::GNUX32;
+-
+-    LibDir = X32 ? "libx32" : "lib64";
++    if (Triple.getEnvironment() == llvm::Triple::GNU)
++      LibDir = X32 ? "libx32" : "lib64";
++    else
++      LibDir = "lib";
+     Loader = X32 ? "ld-linux-x32.so.2" : "ld-linux-x86-64.so.2";
+     break;
+   }
+-- 
+2.21.0
+
diff --git a/meta/meta-clang/recipes-devtools/clang/clang/0003-clang-Driver-tools.cpp-Add-lssp_nonshared-on-musl.patch b/meta/meta-clang/recipes-devtools/clang/clang/0003-clang-Driver-tools.cpp-Add-lssp_nonshared-on-musl.patch
new file mode 100644
index 0000000..191e21d
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/clang/0003-clang-Driver-tools.cpp-Add-lssp_nonshared-on-musl.patch
@@ -0,0 +1,34 @@
+From 74e2a7f0f28e64f496fc33c38428c81dfc15b783 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Thu, 19 May 2016 21:11:06 -0700
+Subject: [PATCH 03/18] clang: Driver/tools.cpp: Add -lssp_nonshared on musl
+
+musl driver will need to add ssp_nonshared for stack_check_local
+on the linker cmdline when using stack protector commands on
+compiler cmdline
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ clang/lib/Driver/ToolChains/Gnu.cpp | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
+index 2ad45097dce..c841399193e 100644
+--- a/clang/lib/Driver/ToolChains/Gnu.cpp
++++ b/clang/lib/Driver/ToolChains/Gnu.cpp
+@@ -525,6 +525,12 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
+       if (IsIAMCU)
+         CmdArgs.push_back("-lgloss");
+ 
++      if (ToolChain.getTriple().isMusl() &&
++          (Args.hasArg(options::OPT_fstack_protector) ||
++          Args.hasArg(options::OPT_fstack_protector_strong) ||
++          Args.hasArg(options::OPT_fstack_protector_all))) {
++        CmdArgs.push_back("-lssp_nonshared");
++      }
+       if (Args.hasArg(options::OPT_static))
+         CmdArgs.push_back("--end-group");
+       else
+-- 
+2.20.1
+
diff --git a/meta/meta-clang/recipes-devtools/clang/clang/0004-clang-musl-ppc-does-not-support-128-bit-long-double.patch b/meta/meta-clang/recipes-devtools/clang/clang/0004-clang-musl-ppc-does-not-support-128-bit-long-double.patch
new file mode 100644
index 0000000..3d257f2
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/clang/0004-clang-musl-ppc-does-not-support-128-bit-long-double.patch
@@ -0,0 +1,28 @@
+From 5a58280d449830a216da015b4a67cbe49b1fd516 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Tue, 10 May 2016 02:00:11 -0700
+Subject: [PATCH 04/18] clang: musl/ppc does not support 128-bit long double
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ clang/lib/Basic/Targets/PPC.h | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
+index cbe7a9a2fa8..8df609a9b04 100644
+--- a/clang/lib/Basic/Targets/PPC.h
++++ b/clang/lib/Basic/Targets/PPC.h
+@@ -342,6 +342,10 @@ public:
+       break;
+     }
+ 
++    if (getTriple().isMusl()) {
++      LongDoubleWidth = LongDoubleAlign = 64;
++      LongDoubleFormat = &llvm::APFloat::IEEEdouble();
++    }
+     // PPC32 supports atomics up to 4 bytes.
+     MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
+   }
+-- 
+2.20.1
+
diff --git a/meta/meta-clang/recipes-devtools/clang/clang/0005-clang-Prepend-trailing-to-sysroot.patch b/meta/meta-clang/recipes-devtools/clang/clang/0005-clang-Prepend-trailing-to-sysroot.patch
new file mode 100644
index 0000000..1c6e16e
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/clang/0005-clang-Prepend-trailing-to-sysroot.patch
@@ -0,0 +1,41 @@
+From cb8ba6da2df40db219bf343e4f2da93089df300b Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Thu, 16 Mar 2017 09:02:13 -0700
+Subject: [PATCH 05/18] clang: Prepend trailing '/' to sysroot
+
+This is needed to handle a case where clang
+isntall and target sysroot are perilously same
+
+e.g.
+
+sysroot = /mnt/clang/recipe-sysroot
+clang install = /mnt/clang/recipe-sysroot-native
+
+in this case it will mistakenly assume that
+clang is installed under the same sysroot dir
+and it will try to add relative ../lib paths
+to linker steps which would then be wrong
+since they will become relative to clang
+installation and not sysroot
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ clang/lib/Driver/ToolChains/Linux.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
+index 552d329e7b8..7d5a85ed744 100644
+--- a/clang/lib/Driver/ToolChains/Linux.cpp
++++ b/clang/lib/Driver/ToolChains/Linux.cpp
+@@ -219,7 +219,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
+   Multilibs = GCCInstallation.getMultilibs();
+   SelectedMultilib = GCCInstallation.getMultilib();
+   llvm::Triple::ArchType Arch = Triple.getArch();
+-  std::string SysRoot = computeSysRoot();
++  std::string SysRoot = computeSysRoot() + "/";
+ 
+   // Cross-compiling binutils and GCC installations (vanilla and openSUSE at
+   // least) put various tools in a triple-prefixed directory off of the parent
+-- 
+2.20.1
+
diff --git a/meta/meta-clang/recipes-devtools/clang/clang/0006-clang-Look-inside-the-target-sysroot-for-compiler-ru.patch b/meta/meta-clang/recipes-devtools/clang/clang/0006-clang-Look-inside-the-target-sysroot-for-compiler-ru.patch
new file mode 100644
index 0000000..9535829
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/clang/0006-clang-Look-inside-the-target-sysroot-for-compiler-ru.patch
@@ -0,0 +1,44 @@
+From 3d38148e5ae42e06d4c4f6f29c194c3406402868 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Thu, 16 Mar 2017 19:06:26 -0700
+Subject: [PATCH 06/18] clang: Look inside the target sysroot for compiler
+ runtime
+
+In OE compiler-rt and libc++ are built and staged into target
+sysroot and not into resourcedir which is relative to clang
+driver installation where the libraries are not instlled
+
+Specific to cross compiling the way yocto/OE works
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ clang/lib/Driver/ToolChain.cpp | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
+index 88a627eab6d..d56b5264b4d 100644
+--- a/clang/lib/Driver/ToolChain.cpp
++++ b/clang/lib/Driver/ToolChain.cpp
+@@ -13,6 +13,7 @@
+ #include "ToolChains/Clang.h"
+ #include "clang/Basic/ObjCRuntime.h"
+ #include "clang/Basic/Sanitizers.h"
++#include "clang/Basic/Version.h"
+ #include "clang/Config/config.h"
+ #include "clang/Driver/Action.h"
+ #include "clang/Driver/Driver.h"
+@@ -353,7 +354,10 @@ StringRef ToolChain::getOSLibName() const {
+ }
+ 
+ std::string ToolChain::getCompilerRTPath() const {
+-  SmallString<128> Path(getDriver().ResourceDir);
++  SmallString<128> Path(getDriver().SysRoot);
++  StringRef ClangLibdirSuffix(CLANG_LIBDIR_SUFFIX);
++  llvm::sys::path::append(Path, "/usr/", Twine("lib") + ClangLibdirSuffix, "clang",
++                            CLANG_VERSION_STRING);
+   if (Triple.isOSUnknown()) {
+     llvm::sys::path::append(Path, "lib");
+   } else {
+-- 
+2.20.1
+
diff --git a/meta/meta-clang/recipes-devtools/clang/clang/0007-clang-Define-releative-gcc-installation-dir.patch b/meta/meta-clang/recipes-devtools/clang/clang/0007-clang-Define-releative-gcc-installation-dir.patch
new file mode 100644
index 0000000..ab035ce
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/clang/0007-clang-Define-releative-gcc-installation-dir.patch
@@ -0,0 +1,32 @@
+From 2d544dc208202f2017fb897cf956a6e85f8c1597 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sun, 21 May 2017 15:38:25 -0700
+Subject: [PATCH 07/18] clang: Define / releative gcc installation dir
+
+This is required for OE gcc installation to work.
+Without this its not able to find the paths for libgcc
+and other standard headers and libraries from gcc
+installation in OE
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ clang/lib/Driver/ToolChains/Gnu.cpp | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
+index c841399193e..468ee821a57 100644
+--- a/clang/lib/Driver/ToolChains/Gnu.cpp
++++ b/clang/lib/Driver/ToolChains/Gnu.cpp
+@@ -2280,6 +2280,9 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
+       {"gcc-cross/" + CandidateTriple.str(), "../..",
+        TargetTriple.getOS() != llvm::Triple::Solaris},
+ 
++      // OE cross-compilers path structures
++      {"/" + CandidateTriple.str(), "..", true},
++
+       // The Freescale PPC SDK has the gcc libraries in
+       // <sysroot>/usr/lib/<triple>/x.y.z so have a look there as well. Only do
+       // this on Freescale triples, though, since some systems put a *lot* of
+-- 
+2.20.1
+
diff --git a/meta/meta-clang/recipes-devtools/clang/clang/0008-clang-Fix-ldso-for-musl-on-x86-and-x32-architectures.patch b/meta/meta-clang/recipes-devtools/clang/clang/0008-clang-Fix-ldso-for-musl-on-x86-and-x32-architectures.patch
new file mode 100644
index 0000000..ca7de9f
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/clang/0008-clang-Fix-ldso-for-musl-on-x86-and-x32-architectures.patch
@@ -0,0 +1,44 @@
+From 977b058e4921ff7908bbf972ea61d4ca34ea8b11 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Wed, 16 Aug 2017 15:16:15 -0700
+Subject: [PATCH 08/18] clang: Fix ldso for musl on x86 and x32 architectures
+
+x32 linker is called ld-musl-x32.so.1 and x86 linker
+is called ld-musl-i386.so.1, Currently, linker for
+x86 is returned as ld-musl-i586.so.1, when default
+arch is i586, which is not the right thing
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ clang/lib/Driver/ToolChains/Linux.cpp | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
+index 7d5a85ed744..4dfef25aa63 100644
+--- a/clang/lib/Driver/ToolChains/Linux.cpp
++++ b/clang/lib/Driver/ToolChains/Linux.cpp
+@@ -516,6 +516,7 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
+   if (Triple.isMusl()) {
+     std::string ArchName;
+     bool IsArm = false;
++    bool isX32 = false;
+ 
+     switch (Arch) {
+     case llvm::Triple::arm:
+@@ -528,6 +529,13 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
+       ArchName = "armeb";
+       IsArm = true;
+       break;
++    case llvm::Triple::x86:
++      ArchName = "i386";
++      break;
++    case llvm::Triple::x86_64:
++      isX32 = Triple.getEnvironment() == llvm::Triple::GNUX32;
++      ArchName = isX32 ? "x32" : Triple.getArchName().str();
++      break;
+     default:
+       ArchName = Triple.getArchName().str();
+     }
+-- 
+2.20.1
+
diff --git a/meta/meta-clang/recipes-devtools/clang/clang/0009-clang-scan-view-needs-python-2.x.patch b/meta/meta-clang/recipes-devtools/clang/clang/0009-clang-scan-view-needs-python-2.x.patch
new file mode 100644
index 0000000..b6804b4
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/clang/0009-clang-scan-view-needs-python-2.x.patch
@@ -0,0 +1,27 @@
+From afa19d2337434c874bb9328d2f955fa33ad1aa65 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Tue, 15 May 2018 10:28:43 -0700
+Subject: [PATCH 09/18] clang: scan-view needs python 2.x
+
+Some distributions e.g. archlinux have switched to pointing
+python to python3, therefore its better to be specific about
+python version needed.
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ clang/tools/scan-view/bin/scan-view | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/clang/tools/scan-view/bin/scan-view b/clang/tools/scan-view/bin/scan-view
+index 6165432e7af..04ad518a60c 100755
+--- a/clang/tools/scan-view/bin/scan-view
++++ b/clang/tools/scan-view/bin/scan-view
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/env python2
+ 
+ from __future__ import print_function
+ 
+-- 
+2.20.1
+
diff --git a/meta/meta-clang/recipes-devtools/clang/clang/0010-clang-Append-libunwind-to-compiler-rt-for-linking.patch b/meta/meta-clang/recipes-devtools/clang/clang/0010-clang-Append-libunwind-to-compiler-rt-for-linking.patch
new file mode 100644
index 0000000..0ca7335
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/clang/0010-clang-Append-libunwind-to-compiler-rt-for-linking.patch
@@ -0,0 +1,33 @@
+From 6c98b7b1df55972f26da3ceceaf87b050e3f05b9 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Fri, 25 Jan 2019 14:39:04 -0800
+Subject: [PATCH 10/18] clang: Append libunwind to compiler-rt for linking
+
+Some packages which use libgcc tend to use low level unwind functions
+too, and they are missing in compiler-rt but provided by llvm libunwind
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ clang/lib/Driver/ToolChains/CommonArgs.cpp | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
+index d7e316befa6..5f6b24e33eb 100644
+--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
++++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
+@@ -1191,6 +1191,12 @@ void tools::AddRunTimeLibs(const ToolChain &TC, const Driver &D,
+   switch (RLT) {
+   case ToolChain::RLT_CompilerRT:
+     CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins"));
++    CmdArgs.push_back("--as-needed");
++    CmdArgs.push_back("-l:libunwind.a");
++    CmdArgs.push_back("-lpthread");
++    CmdArgs.push_back("-ldl");
++    CmdArgs.push_back("--no-as-needed");
++
+     break;
+   case ToolChain::RLT_Libgcc:
+     // Make sure libgcc is not used under MSVC environment by default
+-- 
+2.20.1
+
diff --git a/meta/meta-clang/recipes-devtools/clang/clang/0011-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch b/meta/meta-clang/recipes-devtools/clang/clang/0011-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch
new file mode 100644
index 0000000..643031d
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/clang/0011-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch
@@ -0,0 +1,91 @@
+From 2a5fbe70a26e6898d970d0f88355cf92e723c00b Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sat, 21 May 2016 00:33:20 +0000
+Subject: [PATCH 11/18] llvm: TargetLibraryInfo: Undefine libc functions if
+ they are macros
+
+musl defines some functions as macros and not inline functions
+if this is the case then make sure to undefine them
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ .../llvm/Analysis/TargetLibraryInfo.def       | 21 +++++++++++++++++++
+ 1 file changed, 21 insertions(+)
+
+diff --git a/llvm/include/llvm/Analysis/TargetLibraryInfo.def b/llvm/include/llvm/Analysis/TargetLibraryInfo.def
+index 518a85ee1a0..6b4ead4efc6 100644
+--- a/llvm/include/llvm/Analysis/TargetLibraryInfo.def
++++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.def
+@@ -731,6 +731,9 @@ TLI_DEFINE_STRING_INTERNAL("fmodl")
+ TLI_DEFINE_ENUM_INTERNAL(fopen)
+ TLI_DEFINE_STRING_INTERNAL("fopen")
+ /// FILE *fopen64(const char *filename, const char *opentype)
++#ifdef fopen64
++#undef fopen64
++#endif
+ TLI_DEFINE_ENUM_INTERNAL(fopen64)
+ TLI_DEFINE_STRING_INTERNAL("fopen64")
+ /// int fork();
+@@ -778,6 +781,9 @@ TLI_DEFINE_STRING_INTERNAL("fseek")
+ /// int fseeko(FILE *stream, off_t offset, int whence);
+ TLI_DEFINE_ENUM_INTERNAL(fseeko)
+ TLI_DEFINE_STRING_INTERNAL("fseeko")
++#ifdef fseeko64
++#undef fseeko64
++#endif
+ /// int fseeko64(FILE *stream, off64_t offset, int whence)
+ TLI_DEFINE_ENUM_INTERNAL(fseeko64)
+ TLI_DEFINE_STRING_INTERNAL("fseeko64")
+@@ -788,6 +794,9 @@ TLI_DEFINE_STRING_INTERNAL("fsetpos")
+ TLI_DEFINE_ENUM_INTERNAL(fstat)
+ TLI_DEFINE_STRING_INTERNAL("fstat")
+ /// int fstat64(int filedes, struct stat64 *buf)
++#ifdef fstat64
++#undef fstat64
++#endif
+ TLI_DEFINE_ENUM_INTERNAL(fstat64)
+ TLI_DEFINE_STRING_INTERNAL("fstat64")
+ /// int fstatvfs(int fildes, struct statvfs *buf);
+@@ -803,6 +812,9 @@ TLI_DEFINE_STRING_INTERNAL("ftell")
+ TLI_DEFINE_ENUM_INTERNAL(ftello)
+ TLI_DEFINE_STRING_INTERNAL("ftello")
+ /// off64_t ftello64(FILE *stream)
++#ifdef ftello64
++#undef ftello64
++#endif
+ TLI_DEFINE_ENUM_INTERNAL(ftello64)
+ TLI_DEFINE_STRING_INTERNAL("ftello64")
+ /// int ftrylockfile(FILE *file);
+@@ -929,6 +941,9 @@ TLI_DEFINE_STRING_INTERNAL("logl")
+ TLI_DEFINE_ENUM_INTERNAL(lstat)
+ TLI_DEFINE_STRING_INTERNAL("lstat")
+ /// int lstat64(const char *path, struct stat64 *buf);
++#ifdef lstat64
++#undef lstat64
++#endif
+ TLI_DEFINE_ENUM_INTERNAL(lstat64)
+ TLI_DEFINE_STRING_INTERNAL("lstat64")
+ /// void *malloc(size_t size);
+@@ -1154,6 +1169,9 @@ TLI_DEFINE_STRING_INTERNAL("sscanf")
+ TLI_DEFINE_ENUM_INTERNAL(stat)
+ TLI_DEFINE_STRING_INTERNAL("stat")
+ /// int stat64(const char *path, struct stat64 *buf);
++#ifdef stat64
++#undef stat64
++#endif
+ TLI_DEFINE_ENUM_INTERNAL(stat64)
+ TLI_DEFINE_STRING_INTERNAL("stat64")
+ /// int statvfs(const char *path, struct statvfs *buf);
+@@ -1283,6 +1301,9 @@ TLI_DEFINE_STRING_INTERNAL("times")
+ TLI_DEFINE_ENUM_INTERNAL(tmpfile)
+ TLI_DEFINE_STRING_INTERNAL("tmpfile")
+ /// FILE *tmpfile64(void)
++#ifdef tmpfile64
++#undef tmpfile64
++#endif
+ TLI_DEFINE_ENUM_INTERNAL(tmpfile64)
+ TLI_DEFINE_STRING_INTERNAL("tmpfile64")
+ /// int toascii(int c);
+-- 
+2.20.1
+
diff --git a/meta/meta-clang/recipes-devtools/clang/clang/0012-llvm-allow-env-override-of-exe-path.patch b/meta/meta-clang/recipes-devtools/clang/clang/0012-llvm-allow-env-override-of-exe-path.patch
new file mode 100644
index 0000000..5d0fcff
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/clang/0012-llvm-allow-env-override-of-exe-path.patch
@@ -0,0 +1,37 @@
+From 7111770e8290082530d920e120995bf81431b0aa Mon Sep 17 00:00:00 2001
+From: Martin Kelly <mkelly@xevo.com>
+Date: Fri, 19 May 2017 00:22:57 -0700
+Subject: [PATCH 12/18] llvm: allow env override of exe path
+
+When using a native llvm-config from inside a sysroot, we need llvm-config to
+return the libraries, include directories, etc. from inside the sysroot rather
+than from the native sysroot. Thus provide an env override for calling
+llvm-config from a target sysroot.
+
+Signed-off-by: Martin Kelly <mkelly@xevo.com>
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ llvm/tools/llvm-config/llvm-config.cpp | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/llvm/tools/llvm-config/llvm-config.cpp b/llvm/tools/llvm-config/llvm-config.cpp
+index bec89fef98c..f9a2862a55d 100644
+--- a/llvm/tools/llvm-config/llvm-config.cpp
++++ b/llvm/tools/llvm-config/llvm-config.cpp
+@@ -226,6 +226,13 @@ Typical components:\n\
+ 
+ /// Compute the path to the main executable.
+ std::string GetExecutablePath(const char *Argv0) {
++  // Hack for Yocto: we need to override the root path when we are using
++  // llvm-config from within a target sysroot.
++  const char *Sysroot = std::getenv("YOCTO_ALTERNATE_EXE_PATH");
++  if (Sysroot != nullptr) {
++    return Sysroot;
++  }
++
+   // This just needs to be some symbol in the binary; C++ doesn't
+   // allow taking the address of ::main however.
+   void *P = (void *)(intptr_t)GetExecutablePath;
+-- 
+2.20.1
+
diff --git a/meta/meta-clang/recipes-devtools/clang/clang/0013-llvm-AARCH64-Add-support-for-.dword-directives.patch b/meta/meta-clang/recipes-devtools/clang/clang/0013-llvm-AARCH64-Add-support-for-.dword-directives.patch
new file mode 100644
index 0000000..2ceda2e
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/clang/0013-llvm-AARCH64-Add-support-for-.dword-directives.patch
@@ -0,0 +1,57 @@
+From 55786ec791b0aa77e3fbd1f647780a4d4a3db8f6 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Thu, 31 Jan 2019 10:53:22 -0800
+Subject: [PATCH 13/18] llvm: [AARCH64] Add support for .dword directives
+
+This directives is supported in GNU assembler, Add support via addAliasForDirective.
+Add a testcase to check for data directives
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ .../AArch64/AsmParser/AArch64AsmParser.cpp       |  3 ++-
+ llvm/test/MC/AArch64/data-directives-invalid.s   | 16 ++++++++++++++++
+ 2 files changed, 18 insertions(+), 1 deletion(-)
+ create mode 100644 llvm/test/MC/AArch64/data-directives-invalid.s
+
+diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+index 6cc9b67e4d2..c43b9827cbd 100644
+--- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
++++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+@@ -244,10 +244,11 @@ public:
+ 
+     // Alias .hword/.word/xword to the target-independent .2byte/.4byte/.8byte
+     // directives as they have the same form and semantics:
+-    ///  ::= (.hword | .word | .xword ) [ expression (, expression)* ]
++    ///  ::= (.hword | .word | .xword | .dword ) [ expression (, expression)* ]
+     Parser.addAliasForDirective(".hword", ".2byte");
+     Parser.addAliasForDirective(".word", ".4byte");
+     Parser.addAliasForDirective(".xword", ".8byte");
++    Parser.addAliasForDirective(".dword", ".8byte");
+ 
+     // Initialize the set of available features.
+     setAvailableFeatures(ComputeAvailableFeatures(getSTI().getFeatureBits()));
+diff --git a/llvm/test/MC/AArch64/data-directives-invalid.s b/llvm/test/MC/AArch64/data-directives-invalid.s
+new file mode 100644
+index 00000000000..7b59a2e60fa
+--- /dev/null
++++ b/llvm/test/MC/AArch64/data-directives-invalid.s
+@@ -0,0 +1,16 @@
++# RUN: not llvm-mc -triple aarch64 < %s 2>&1 | FileCheck %s
++
++# CHECK: [[@LINE+1]]:8: error: out of range literal value in '.hword' directive
++.hword 0xffffa
++# CHECK: [[@LINE+1]]:8: error: out of range literal value in '.2byte' directive
++.2byte 0xffffa
++# CHECK: [[@LINE+1]]:7: error: out of range literal value in '.word' directive
++.word 0xffffffffa
++# CHECK: [[@LINE+1]]:8: error: out of range literal value in '.4byte' directive
++.4byte 0xffffffffa
++# CHECK: [[@LINE+1]]:8: error: literal value out of range for directive in '.dword' directive
++.dword 0xffffffffffffffffa
++# CHECK: [[@LINE+1]]:8: error: literal value out of range for directive in '.xword' directive
++.xword 0xffffffffffffffffa
++# CHECK: [[@LINE+1]]:8: error: literal value out of range for directive in '.8byte' directive
++.8byte 0xffffffffffffffffa
+-- 
+2.20.1
+
diff --git a/meta/meta-clang/recipes-devtools/clang/clang/0014-lldb-Add-lxml2-to-linker-cmdline-of-xml-is-found.patch b/meta/meta-clang/recipes-devtools/clang/clang/0014-lldb-Add-lxml2-to-linker-cmdline-of-xml-is-found.patch
new file mode 100644
index 0000000..b9b67cb
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/clang/0014-lldb-Add-lxml2-to-linker-cmdline-of-xml-is-found.patch
@@ -0,0 +1,40 @@
+From 6f7cf16d8a891d7e1cdc143dc21623175373c33b Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Mon, 22 May 2017 17:36:16 -0700
+Subject: [PATCH 14/18] lldb: Add -lxml2 to linker cmdline of xml is found
+
+When cross compiling for systems where static libs
+for libxml are not available cmake's detection mechanism
+resort to linking with libxml.so but doesnt use -lxml2
+liblldbHost.a however requires libxml on linker
+cmdline _after_ itself so its use of symbols from libxml2
+can be resolved. Here check for libxml2 being detected and
+add it if its found.
+
+Fixes
+
+| ../../../../lib/liblldbHost.a(XML.cpp.o): In function `lldb_private::XMLDocument::Clear()':
+| /usr/src/debug/lldb/5.0.0+gitAUTOINC+69edad7913_08d6b47db9_cf6c5b3386-r0/git/tools/lldb/source/Host/common/XML.cpp:29: undefined reference to `xmlFreeDoc'
+| /usr/src/debug/lldb/5.0.0+gitAUTOINC+69edad7913_08d6b47db9_cf6c5b3386-r0/git/tools/lldb/source/Host/common/XML.cpp:29: undefined reference to `xmlFreeDoc'
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ lldb/source/Host/CMakeLists.txt | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt
+index 333f109a9a2..a5237c4b779 100644
+--- a/lldb/source/Host/CMakeLists.txt
++++ b/lldb/source/Host/CMakeLists.txt
+@@ -148,7 +148,7 @@ if (APPLE)
+   list(APPEND EXTRA_LIBS xml2)
+ else ()
+   if (LIBXML2_FOUND)
+-    list(APPEND EXTRA_LIBS ${LIBXML2_LIBRARIES})
++    list(APPEND EXTRA_LIBS xml2)
+   endif()
+ endif ()
+ if (HAVE_LIBDL)
+-- 
+2.20.1
+
diff --git a/meta/meta-clang/recipes-devtools/clang/clang/0015-libcxxabi-Find-libunwind-headers-when-LIBCXXABI_LIBU.patch b/meta/meta-clang/recipes-devtools/clang/clang/0015-libcxxabi-Find-libunwind-headers-when-LIBCXXABI_LIBU.patch
new file mode 100644
index 0000000..a6d9183
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/clang/0015-libcxxabi-Find-libunwind-headers-when-LIBCXXABI_LIBU.patch
@@ -0,0 +1,68 @@
+From 74775fbe6fcee36cbc74703f824a95ef883392e2 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sun, 27 Aug 2017 10:37:49 -0700
+Subject: [PATCH 15/18] libcxxabi: Find libunwind headers when
+ LIBCXXABI_LIBUNWIND_INCLUDES is set
+
+Currently, when LIBCXXABI_LIBUNWIND_INCLUDES is set via CMake arguments
+then it ends up not searching the specified dir and unwind.h is not found
+especially for ARM targets
+
+This patch makes the searching synthesized directories and then set
+LIBCXXABI_LIBUNWIND_INCLUDES if its there in environment
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ libcxxabi/CMakeLists.txt | 21 +++++++++++----------
+ 1 file changed, 11 insertions(+), 10 deletions(-)
+
+diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
+index 92c7dc5dc55..d67bb43aba3 100644
+--- a/libcxxabi/CMakeLists.txt
++++ b/libcxxabi/CMakeLists.txt
+@@ -434,15 +434,10 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBCXXABI_C_FLAGS}")
+ # Setup Source Code
+ #===============================================================================
+ 
+-set(LIBCXXABI_LIBUNWIND_INCLUDES "${LIBCXXABI_LIBUNWIND_INCLUDES}" CACHE PATH
+-    "Specify path to libunwind includes." FORCE)
+-set(LIBCXXABI_LIBUNWIND_PATH "${LIBCXXABI_LIBUNWIND_PATH}" CACHE PATH
+-    "Specify path to libunwind source." FORCE)
+-
+ include_directories(include)
+ if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_NATIVE_ARCH MATCHES ARM)
+   find_path(
+-    LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL
++    LIBCXXABI_LIBUNWIND_INCLUDES
+     libunwind.h
+     PATHS ${LIBCXXABI_LIBUNWIND_INCLUDES}
+           ${LIBCXXABI_LIBUNWIND_PATH}/include
+@@ -454,15 +449,21 @@ if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_NATIVE_ARCH MATCHES ARM)
+     NO_CMAKE_FIND_ROOT_PATH
+   )
+ 
+-  if (LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND")
+-    set(LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL "")
++  if (LIBCXXABI_LIBUNWIND_INCLUDES STREQUAL "LIBCXXABI_LIBUNWIND_INCLUDES-NOTFOUND")
++    set(LIBCXXABI_LIBUNWIND_INCLUDES "")
+   endif()
+ 
+-  if (NOT LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "")
+-    include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
++  if (NOT LIBCXXABI_LIBUNWIND_INCLUDES STREQUAL "")
++    include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES}")
+   endif()
+ endif()
+ 
++set(LIBCXXABI_LIBUNWIND_INCLUDES "${LIBCXXABI_LIBUNWIND_INCLUDES}" CACHE PATH
++    "Specify path to libunwind includes." FORCE)
++set(LIBCXXABI_LIBUNWIND_PATH "${LIBCXXABI_LIBUNWIND_PATH}" CACHE PATH
++    "Specify path to libunwind source." FORCE)
++
++
+ # Add source code. This also contains all of the logic for deciding linker flags
+ # soname, etc...
+ add_subdirectory(src)
+-- 
+2.20.1
+
diff --git a/meta/meta-clang/recipes-devtools/clang/clang/0016-compiler-rt-support-a-new-embedded-linux-target.patch b/meta/meta-clang/recipes-devtools/clang/clang/0016-compiler-rt-support-a-new-embedded-linux-target.patch
new file mode 100644
index 0000000..0539989
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/clang/0016-compiler-rt-support-a-new-embedded-linux-target.patch
@@ -0,0 +1,326 @@
+From 81fb306633c76d1ff8956af426173c6da811e605 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sun, 19 Apr 2015 15:16:23 -0700
+Subject: [PATCH 16/18] compiler-rt: support a new embedded linux target
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ compiler-rt/lib/builtins/int_util.c           |   3 +-
+ .../make/platform/clang_linux_embedded.mk     | 286 ++++++++++++++++++
+ .../clang_linux_embedded_test_input.c         |   0
+ 3 files changed, 287 insertions(+), 2 deletions(-)
+ create mode 100644 compiler-rt/make/platform/clang_linux_embedded.mk
+ create mode 100644 compiler-rt/make/platform/clang_linux_embedded_test_input.c
+
+diff --git a/compiler-rt/lib/builtins/int_util.c b/compiler-rt/lib/builtins/int_util.c
+index 752f2015580..494c870b41d 100644
+--- a/compiler-rt/lib/builtins/int_util.c
++++ b/compiler-rt/lib/builtins/int_util.c
+@@ -58,8 +58,7 @@ void __compilerrt_abort_impl(const char *file, int line, const char *function) {
+ #else
+ 
+ /* Get the system definition of abort() */
+-#include <stdlib.h>
+-
++extern void abort (void) __attribute__ ((__noreturn__));
+ #ifndef _WIN32
+ __attribute__((weak))
+ __attribute__((visibility("hidden")))
+diff --git a/compiler-rt/make/platform/clang_linux_embedded.mk b/compiler-rt/make/platform/clang_linux_embedded.mk
+new file mode 100644
+index 00000000000..d0a890075a1
+--- /dev/null
++++ b/compiler-rt/make/platform/clang_linux_embedded.mk
+@@ -0,0 +1,286 @@
++# These are the functions which clang needs when it is targeting a previous
++# version of the OS. The issue is that the backend may use functions which were
++# not present in the libgcc that shipped on the platform. In such cases, we link
++# with a version of the library which contains private_extern definitions of all
++# the extra functions which might be referenced.
++
++Description := Static runtime libraries for embedded clang/Linux
++
++# A function that ensures we don't try to build for architectures that we
++# don't have working toolchains for.
++CheckArches = \
++  $(shell \
++    result=""; \
++    for arch in $(1); do \
++      if $(CC) -arch $$arch -c \
++	  -integrated-as \
++	  $(ProjSrcRoot)/make/platform/clang_linux_embedded_test_input.c \
++	  -o /dev/null > /dev/null 2> /dev/null; then \
++        result="$$result$$arch "; \
++      else \
++	printf 1>&2 \
++	  "warning: clang_linux_embedded.mk: dropping arch '$$arch' from lib '$(2)'\n"; \
++      fi; \
++    done; \
++    echo $$result)
++
++XCRun = \
++  $(shell \
++    result=`xcrun -find $(1) 2> /dev/null`; \
++    if [ "$$?" != "0" ]; then result=$(1); fi; \
++    echo $$result)
++
++###
++
++CC       := $(call XCRun,clang)
++AR       := $(call XCRun,ar)
++RANLIB   := $(call XCRun,ranlib)
++STRIP    := $(call XCRun,strip)
++LIPO     := $(call XCRun,lipo)
++DSYMUTIL := $(call XCRun,dsymutil)
++Configs :=
++UniversalArchs :=
++
++# Soft-float version of the runtime. No floating-point instructions will be used
++# and the ABI (out of necessity) passes floating values in normal registers:
++# non-VFP variant of the AAPCS.
++UniversalArchs.soft_static := $(call CheckArches,arm armv7m armv7em armv7,soft_static)
++Configs += $(if $(UniversalArchs.soft_static),soft_static)
++
++# Hard-float version of the runtime. On ARM VFP instructions and registers are
++# allowed, and floating point values get passed in them. VFP variant of the
++# AAPCS.
++UniversalArchs.hard_static := $(call CheckArches,armv7em armv7 i386 x86_64,hard_static)
++Configs += $(if $(UniversalArchs.hard_static),hard_static)
++
++UniversalArchs.soft_pic := $(call CheckArches,armv6m armv7m armv7em armv7,soft_pic)
++Configs += $(if $(UniversalArchs.soft_pic),soft_pic)
++
++UniversalArchs.hard_pic := $(call CheckArches,armv7em armv7 i386 x86_64,hard_pic)
++Configs += $(if $(UniversalArchs.hard_pic),hard_pic)
++
++CFLAGS := -Wall -Werror -Oz -fomit-frame-pointer -ffreestanding
++
++PIC_CFLAGS := -fPIC
++STATIC_CFLAGS := -static
++
++CFLAGS_SOFT := -mfloat-abi=soft
++CFLAGS_HARD := -mfloat-abi=hard
++
++CFLAGS_I386  := -march=pentium
++
++CFLAGS.soft_static := $(CFLAGS) $(STATIC_CFLAGS) $(CFLAGS_SOFT)
++CFLAGS.hard_static := $(CFLAGS) $(STATIC_CFLAGS) $(CFLAGS_HARD)
++CFLAGS.soft_pic    := $(CFLAGS) $(PIC_CFLAGS) $(CFLAGS_SOFT)
++CFLAGS.hard_pic    := $(CFLAGS) $(PIC_CFLAGS) $(CFLAGS_HARD)
++
++CFLAGS.soft_static.armv7 := $(CFLAGS.soft_static) $(CFLAGS_ARMV7)
++CFLAGS.hard_static.armv7 := $(CFLAGS.hard_static) $(CFLAGS_ARMV7)
++CFLAGS.soft_pic.armv7    := $(CFLAGS.soft_pic) $(CFLAGS_ARMV7)
++CFLAGS.hard_pic.armv7    := $(CFLAGS.hard_pic) $(CFLAGS_ARMV7)
++
++# x86 platforms ignore -mfloat-abi options and complain about doing so. Despite
++# this they're hard-float.
++CFLAGS.hard_static.i386   := $(CFLAGS) $(STATIC_CFLAGS) $(CFLAGS_I386)
++CFLAGS.hard_pic.i386      := $(CFLAGS) $(PIC_CFLAGS) $(CFLAGS_I386)
++CFLAGS.hard_static.x86_64 := $(CFLAGS) $(STATIC_CFLAGS)
++CFLAGS.hard_pic.x86_64    := $(CFLAGS) $(PIC_CFLAGS)
++
++# Functions not wanted:
++#   + eprintf is obsolete anyway
++#   + *vfp: designed for Thumb1 CPUs with VFPv2
++
++COMMON_FUNCTIONS := \
++	absvdi2 \
++	absvsi2 \
++	addvdi3 \
++	addvsi3 \
++	ashldi3 \
++	ashrdi3 \
++	bswapdi2 \
++	bswapsi2 \
++	clzdi2 \
++	clzsi2 \
++	cmpdi2 \
++	ctzdi2 \
++	ctzsi2 \
++	divdc3 \
++	divdi3 \
++	divsc3 \
++	divmodsi4 \
++	udivmodsi4 \
++	do_global_dtors \
++	ffsdi2 \
++	fixdfdi \
++	fixsfdi \
++	fixunsdfdi \
++	fixunsdfsi \
++	fixunssfdi \
++	fixunssfsi \
++	floatdidf \
++	floatdisf \
++	floatundidf \
++	floatundisf \
++	gcc_bcmp \
++	lshrdi3 \
++	moddi3 \
++	muldc3 \
++	muldi3 \
++	mulsc3 \
++	mulvdi3 \
++	mulvsi3 \
++	negdi2 \
++	negvdi2 \
++	negvsi2 \
++	paritydi2 \
++	paritysi2 \
++	popcountdi2 \
++	popcountsi2 \
++	powidf2 \
++	powisf2 \
++	subvdi3 \
++	subvsi3 \
++	ucmpdi2 \
++	udiv_w_sdiv \
++	udivdi3 \
++	udivmoddi4 \
++	umoddi3 \
++	adddf3 \
++	addsf3 \
++	cmpdf2 \
++	cmpsf2 \
++	div0 \
++	divdf3 \
++	divsf3 \
++	divsi3 \
++	extendsfdf2 \
++	ffssi2 \
++	fixdfsi \
++	fixsfsi \
++	floatsidf \
++	floatsisf \
++	floatunsidf \
++	floatunsisf \
++	comparedf2 \
++	comparesf2 \
++	modsi3 \
++	muldf3 \
++	mulsf3 \
++	negdf2 \
++	negsf2 \
++	subdf3 \
++	subsf3 \
++	truncdfsf2 \
++	udivsi3 \
++	umodsi3 \
++	unorddf2 \
++	unordsf2
++
++ARM_FUNCTIONS := \
++	aeabi_cdcmpeq \
++	aeabi_cdrcmple \
++	aeabi_cfcmpeq \
++	aeabi_cfrcmple \
++	aeabi_dcmpeq \
++	aeabi_dcmpge \
++	aeabi_dcmpgt \
++	aeabi_dcmple \
++	aeabi_dcmplt \
++	aeabi_drsub \
++	aeabi_fcmpeq \
++	aeabi_fcmpge \
++	aeabi_fcmpgt \
++	aeabi_fcmple \
++	aeabi_fcmplt \
++	aeabi_frsub \
++	aeabi_idivmod \
++	aeabi_uidivmod \
++
++# ARM Assembly implementation which requires Thumb2 (i.e. won't work on v6M).
++THUMB2_FUNCTIONS := \
++	switch16 \
++	switch32 \
++	switch8 \
++	switchu8 \
++	sync_fetch_and_add_4 \
++	sync_fetch_and_sub_4 \
++	sync_fetch_and_and_4 \
++	sync_fetch_and_or_4 \
++	sync_fetch_and_xor_4 \
++	sync_fetch_and_nand_4 \
++	sync_fetch_and_max_4 \
++	sync_fetch_and_umax_4 \
++	sync_fetch_and_min_4 \
++	sync_fetch_and_umin_4 \
++	sync_fetch_and_add_8 \
++	sync_fetch_and_sub_8 \
++	sync_fetch_and_and_8 \
++	sync_fetch_and_or_8 \
++	sync_fetch_and_xor_8 \
++	sync_fetch_and_nand_8 \
++	sync_fetch_and_max_8 \
++	sync_fetch_and_umax_8 \
++	sync_fetch_and_min_8 \
++	sync_fetch_and_umin_8
++
++I386_FUNCTIONS :=  \
++	i686.get_pc_thunk.eax \
++	i686.get_pc_thunk.ebp \
++	i686.get_pc_thunk.ebx \
++	i686.get_pc_thunk.ecx \
++	i686.get_pc_thunk.edi \
++	i686.get_pc_thunk.edx \
++	i686.get_pc_thunk.esi
++
++# FIXME: Currently, compiler-rt is missing implementations for a number of the
++# functions. Filter them out for now.
++MISSING_FUNCTIONS := \
++	cmpdf2 cmpsf2 div0 \
++	ffssi2 \
++	udiv_w_sdiv unorddf2 unordsf2 bswapdi2 \
++	bswapsi2 \
++	gcc_bcmp \
++	do_global_dtors \
++	i686.get_pc_thunk.eax i686.get_pc_thunk.ebp i686.get_pc_thunk.ebx \
++	i686.get_pc_thunk.ecx i686.get_pc_thunk.edi i686.get_pc_thunk.edx \
++	i686.get_pc_thunk.esi \
++	aeabi_cdcmpeq aeabi_cdrcmple aeabi_cfcmpeq aeabi_cfrcmple aeabi_dcmpeq \
++	aeabi_dcmpge aeabi_dcmpgt aeabi_dcmple aeabi_dcmplt aeabi_drsub \
++	aeabi_fcmpeq \ aeabi_fcmpge aeabi_fcmpgt aeabi_fcmple aeabi_fcmplt \
++	aeabi_frsub aeabi_idivmod aeabi_uidivmod
++
++FUNCTIONS_ARMV6M  := $(COMMON_FUNCTIONS) $(ARM_FUNCTIONS)
++FUNCTIONS_ARM_ALL := $(COMMON_FUNCTIONS) $(ARM_FUNCTIONS) $(THUMB2_FUNCTIONS)
++FUNCTIONS_I386    := $(COMMON_FUNCTIONS) $(I386_FUNCTIONS)
++FUNCTIONS_X86_64  := $(COMMON_FUNCTIONS)
++
++FUNCTIONS_ARMV6M := \
++	$(filter-out $(MISSING_FUNCTIONS),$(FUNCTIONS_ARMV6M))
++FUNCTIONS_ARM_ALL := \
++	$(filter-out $(MISSING_FUNCTIONS),$(FUNCTIONS_ARM_ALL))
++FUNCTIONS_I386 := \
++	$(filter-out $(MISSING_FUNCTIONS),$(FUNCTIONS_I386))
++FUNCTIONS_X86_64 := \
++	$(filter-out $(MISSING_FUNCTIONS),$(FUNCTIONS_X86_64))
++
++FUNCTIONS.soft_static.armv6m := $(FUNCTIONS_ARMV6M)
++FUNCTIONS.soft_pic.armv6m    := $(FUNCTIONS_ARMV6M)
++
++FUNCTIONS.soft_static.armv7m := $(FUNCTIONS_ARM_ALL)
++FUNCTIONS.soft_pic.armv7m    := $(FUNCTIONS_ARM_ALL)
++
++FUNCTIONS.soft_static.armv7em := $(FUNCTIONS_ARM_ALL)
++FUNCTIONS.hard_static.armv7em := $(FUNCTIONS_ARM_ALL)
++FUNCTIONS.soft_pic.armv7em    := $(FUNCTIONS_ARM_ALL)
++FUNCTIONS.hard_pic.armv7em    := $(FUNCTIONS_ARM_ALL)
++
++FUNCTIONS.soft_static.armv7 := $(FUNCTIONS_ARM_ALL)
++FUNCTIONS.hard_static.armv7 := $(FUNCTIONS_ARM_ALL)
++FUNCTIONS.soft_pic.armv7    := $(FUNCTIONS_ARM_ALL)
++FUNCTIONS.hard_pic.armv7    := $(FUNCTIONS_ARM_ALL)
++
++FUNCTIONS.hard_static.i386 := $(FUNCTIONS_I386)
++FUNCTIONS.hard_pic.i386    := $(FUNCTIONS_I386)
++
++FUNCTIONS.hard_static.x86_64 := $(FUNCTIONS_X86_64)
++FUNCTIONS.hard_pic.x86_64    := $(FUNCTIONS_X86_64)
+diff --git a/compiler-rt/make/platform/clang_linux_embedded_test_input.c b/compiler-rt/make/platform/clang_linux_embedded_test_input.c
+new file mode 100644
+index 00000000000..e69de29bb2d
+-- 
+2.20.1
+
diff --git a/meta/meta-clang/recipes-devtools/clang/clang/0017-compiler-rt-Simplify-cross-compilation.-Don-t-use-na.patch b/meta/meta-clang/recipes-devtools/clang/clang/0017-compiler-rt-Simplify-cross-compilation.-Don-t-use-na.patch
new file mode 100644
index 0000000..65bbf62
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/clang/0017-compiler-rt-Simplify-cross-compilation.-Don-t-use-na.patch
@@ -0,0 +1,46 @@
+From 988c7e3842fcca00faf03d735bd1a25c9e1da30f Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Thu, 19 May 2016 23:11:45 -0700
+Subject: [PATCH 17/18] compiler-rt: Simplify cross-compilation. Don't use
+ native-compiled llvm-config.
+
+    Note: AddLLVM.cmake does not expose the LLVM source directory.
+    So if you want to run the test suite, you need to either:
+
+    1) set LLVM_MAIN_SRC_DIR explicitly (to find lit.py)
+    2) change AddLLVM.cmake to point to an installed 'lit'.
+    3) add_subdirectory(compiler-rt/test) from clang instead of compiler-rt.
+
+https://us.codeaurora.org/patches/quic/llvm/50683/compiler-rt-cross-compilation.patch
+
+Signed-off-by: Greg Fitzgerald <gregf@codeaurora.org>
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ compiler-rt/CMakeLists.txt | 11 ++++++++++-
+ 1 file changed, 10 insertions(+), 1 deletion(-)
+
+diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
+index aa360a3ef36..264d39c95c3 100644
+--- a/compiler-rt/CMakeLists.txt
++++ b/compiler-rt/CMakeLists.txt
+@@ -66,7 +66,16 @@ set(COMPILER_RT_BAREMETAL_BUILD OFF CACHE BOOLEAN
+   "Build for a bare-metal target.")
+ 
+ if (COMPILER_RT_STANDALONE_BUILD)
+-  load_llvm_config()
++  find_package(LLVM REQUIRED)
++  list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
++
++  # Variables that AddLLVM.cmake depends on (included by AddCompilerRT)
++  set(LLVM_TOOLS_BINARY_DIR "${LLVM_INSTALL_PREFIX}/bin")
++  set(LLVM_LIBRARY_DIR "${LLVM_INSTALL_PREFIX}/lib")
++
++  set(LLVM_LIBRARY_OUTPUT_INTDIR
++    ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
++
+   if (TARGET intrinsics_gen)
+     # Loading the llvm config causes this target to be imported so place it
+     # under the appropriate folder in an IDE.
+-- 
+2.20.1
+
diff --git a/meta/meta-clang/recipes-devtools/clang/clang/0018-compiler-rt-Disable-tsan-on-OE-glibc.patch b/meta/meta-clang/recipes-devtools/clang/clang/0018-compiler-rt-Disable-tsan-on-OE-glibc.patch
new file mode 100644
index 0000000..6a690c7
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/clang/0018-compiler-rt-Disable-tsan-on-OE-glibc.patch
@@ -0,0 +1,42 @@
+From 80820b9db8217eeaee5675795380d9b3b1b9c410 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Mon, 18 Jul 2016 08:05:02 +0000
+Subject: [PATCH 18/18] compiler-rt: Disable tsan on OE/glibc
+
+It does not build see
+http://lists.llvm.org/pipermail/llvm-dev/2016-July/102235.html
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ compiler-rt/cmake/config-ix.cmake                | 2 +-
+ compiler-rt/test/sanitizer_common/CMakeLists.txt | 1 -
+ 2 files changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
+index 5b943387717..151b6069e16 100644
+--- a/compiler-rt/cmake/config-ix.cmake
++++ b/compiler-rt/cmake/config-ix.cmake
+@@ -594,7 +594,7 @@ else()
+ endif()
+ 
+ if (COMPILER_RT_HAS_SANITIZER_COMMON AND TSAN_SUPPORTED_ARCH AND
+-    OS_NAME MATCHES "Darwin|Linux|FreeBSD|Android|NetBSD")
++    OS_NAME MATCHES "Darwin|FreeBSD|Android|NetBSD")
+   set(COMPILER_RT_HAS_TSAN TRUE)
+ else()
+   set(COMPILER_RT_HAS_TSAN FALSE)
+diff --git a/compiler-rt/test/sanitizer_common/CMakeLists.txt b/compiler-rt/test/sanitizer_common/CMakeLists.txt
+index 23292e54820..cae7e010885 100644
+--- a/compiler-rt/test/sanitizer_common/CMakeLists.txt
++++ b/compiler-rt/test/sanitizer_common/CMakeLists.txt
+@@ -8,7 +8,6 @@ if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux|FreeBSD|NetBSD|SunOS")
+   list(APPEND SUPPORTED_TOOLS asan)
+ endif()
+ if(CMAKE_SYSTEM_NAME MATCHES "NetBSD" OR (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT ANDROID))
+-  list(APPEND SUPPORTED_TOOLS tsan)
+   list(APPEND SUPPORTED_TOOLS msan)
+   list(APPEND SUPPORTED_TOOLS ubsan)
+ endif()
+-- 
+2.20.1
+
diff --git a/meta/meta-clang/recipes-devtools/clang/clang/0019-llvm-Enhance-path-prefix-mapping.patch b/meta/meta-clang/recipes-devtools/clang/clang/0019-llvm-Enhance-path-prefix-mapping.patch
new file mode 100644
index 0000000..cbfc0be
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/clang/0019-llvm-Enhance-path-prefix-mapping.patch
@@ -0,0 +1,175 @@
+From 07594e15b8e9740012c3bcac00f935faf77f1c99 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Fri, 15 Feb 2019 11:32:09 -0800
+Subject: [PATCH 1/2] llvm: Enhance path prefix mapping
+
+Upstream-Status: Submitted [https://reviews.llvm.org/D56769]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ llvm/include/llvm/Support/Path.h | 25 +++++++++++++++---
+ llvm/lib/Support/Path.cpp        | 44 +++++++++++++++++++++++++-------
+ llvm/unittests/Support/Path.cpp  | 29 +++++++++++++++++++++
+ 3 files changed, 85 insertions(+), 13 deletions(-)
+
+diff --git a/llvm/include/llvm/Support/Path.h b/llvm/include/llvm/Support/Path.h
+index 5c0bee58f18..20332c09852 100644
+--- a/llvm/include/llvm/Support/Path.h
++++ b/llvm/include/llvm/Support/Path.h
+@@ -150,18 +150,35 @@ void replace_extension(SmallVectorImpl<char> &path, const Twine &extension,
+ ///
+ /// @code
+ ///   /foo, /old, /new => /foo
++///   /old, /old, /new => /new
++///   /old, /old/, /new, false => /old
++///   /old, /old/, /new, true => /new
+ ///   /old/foo, /old, /new => /new/foo
++///   /old/foo, /old/, /new => /new/foo
++///   /old/foo, /old/, /new/ => /new/foo
++///   /oldfoo, /old, /new => /oldfoo
+ ///   /foo, <empty>, /new => /new/foo
+-///   /old/foo, /old, <empty> => /foo
++///   /foo, <empty>, new => new/foo
++///   /old/foo, /old, <empty>, false => /foo
++///   /old/foo, /old, <empty>, true => foo
+ /// @endcode
+ ///
+ /// @param Path If \a Path starts with \a OldPrefix modify to instead
+ ///        start with \a NewPrefix.
+-/// @param OldPrefix The path prefix to strip from \a Path.
++/// @param OldPrefix The path prefix to strip from \a Path. Any trailing
++///        path separator is ignored if strict is true.
+ /// @param NewPrefix The path prefix to replace \a NewPrefix with.
+-void replace_path_prefix(SmallVectorImpl<char> &Path,
++/// @param style The path separator style
++/// @param strict Strict prefix path checking
++/// @result true if \a Path begins with OldPrefix
++bool replace_path_prefix(SmallVectorImpl<char> &Path,
+                          const StringRef &OldPrefix, const StringRef &NewPrefix,
+-                         Style style = Style::native);
++                         Style style = Style::native, bool strict = false);
++static inline bool replace_path_prefix(SmallVectorImpl<char> &Path,
++                         const StringRef &OldPrefix, const StringRef &NewPrefix,
++                         bool strict, Style style = Style::native) {
++  return replace_path_prefix(Path, OldPrefix, NewPrefix, style, strict);
++}
+ 
+ /// Append to path.
+ ///
+diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp
+index 8f580c66d24..e368fe0e17b 100644
+--- a/llvm/lib/Support/Path.cpp
++++ b/llvm/lib/Support/Path.cpp
+@@ -520,27 +520,53 @@ void replace_extension(SmallVectorImpl<char> &path, const Twine &extension,
+   path.append(ext.begin(), ext.end());
+ }
+ 
+-void replace_path_prefix(SmallVectorImpl<char> &Path,
++bool replace_path_prefix(SmallVectorImpl<char> &Path,
+                          const StringRef &OldPrefix, const StringRef &NewPrefix,
+-                         Style style) {
++                         Style style, bool strict) {
+   if (OldPrefix.empty() && NewPrefix.empty())
+-    return;
++    return false;
+ 
+   StringRef OrigPath(Path.begin(), Path.size());
+-  if (!OrigPath.startswith(OldPrefix))
+-    return;
++  StringRef OldPrefixDir;
++
++  if (!strict && OldPrefix.size() > OrigPath.size())
++    return false;
++
++  if (!strict && OldPrefix.size() > OrigPath.size())
++    return false;
++
++  // Ensure OldPrefixDir does not have a trailing separator.
++  if (!OldPrefix.empty() && is_separator(OldPrefix.back()))
++    OldPrefixDir = parent_path(OldPrefix, style);
++  else
++    OldPrefixDir = OldPrefix;
++
++  if (!OrigPath.startswith(OldPrefixDir))
++    return false;
++
++  if (OrigPath.size() > OldPrefixDir.size())
++    if (!is_separator(OrigPath[OldPrefixDir.size()], style) && strict)
++      return false;
+ 
+   // If prefixes have the same size we can simply copy the new one over.
+-  if (OldPrefix.size() == NewPrefix.size()) {
++  if (OldPrefixDir.size() == NewPrefix.size() && !strict) {
+     llvm::copy(NewPrefix, Path.begin());
+-    return;
++    return true;
+   }
+ 
+-  StringRef RelPath = OrigPath.substr(OldPrefix.size());
++  StringRef RelPath = OrigPath.substr(OldPrefixDir.size());
+   SmallString<256> NewPath;
+   path::append(NewPath, style, NewPrefix);
+-  path::append(NewPath, style, RelPath);
++  if (!RelPath.empty()) {
++    if (!is_separator(RelPath[0], style) || !strict)
++      path::append(NewPath, style, RelPath);
++    else
++      path::append(NewPath, style, relative_path(RelPath, style));
++  }
++
+   Path.swap(NewPath);
++
++  return true;
+ }
+ 
+ void native(const Twine &path, SmallVectorImpl<char> &result, Style style) {
+diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp
+index 7ce6d2d52db..eaf8557ca8d 100644
+--- a/llvm/unittests/Support/Path.cpp
++++ b/llvm/unittests/Support/Path.cpp
+@@ -1207,7 +1207,9 @@ TEST(Support, RemoveDots) {
+ TEST(Support, ReplacePathPrefix) {
+   SmallString<64> Path1("/foo");
+   SmallString<64> Path2("/old/foo");
++  SmallString<64> Path3("/oldnew/foo");
+   SmallString<64> OldPrefix("/old");
++  SmallString<64> OldPrefixSep("/old/");
+   SmallString<64> NewPrefix("/new");
+   SmallString<64> NewPrefix2("/longernew");
+   SmallString<64> EmptyPrefix("");
+@@ -1227,6 +1229,33 @@ TEST(Support, ReplacePathPrefix) {
+   Path = Path2;
+   path::replace_path_prefix(Path, OldPrefix, EmptyPrefix);
+   EXPECT_EQ(Path, "/foo");
++  Path = Path2;
++  path::replace_path_prefix(Path, OldPrefix, EmptyPrefix, true);
++  EXPECT_EQ(Path, "foo");
++  Path = Path3;
++  path::replace_path_prefix(Path, OldPrefix, NewPrefix, false);
++  EXPECT_EQ(Path, "/newnew/foo");
++  Path = Path3;
++  path::replace_path_prefix(Path, OldPrefix, NewPrefix, true);
++  EXPECT_EQ(Path, "/oldnew/foo");
++  Path = Path3;
++  path::replace_path_prefix(Path, OldPrefixSep, NewPrefix, true);
++  EXPECT_EQ(Path, "/oldnew/foo");
++  Path = Path1;
++  path::replace_path_prefix(Path, EmptyPrefix, NewPrefix);
++  EXPECT_EQ(Path, "/new/foo");
++  Path = OldPrefix;
++  path::replace_path_prefix(Path, OldPrefix, NewPrefix);
++  EXPECT_EQ(Path, "/new");
++  Path = OldPrefixSep;
++  path::replace_path_prefix(Path, OldPrefix, NewPrefix);
++  EXPECT_EQ(Path, "/new/");
++  Path = OldPrefix;
++  path::replace_path_prefix(Path, OldPrefixSep, NewPrefix, false);
++  EXPECT_EQ(Path, "/old");
++  Path = OldPrefix;
++  path::replace_path_prefix(Path, OldPrefixSep, NewPrefix, true);
++  EXPECT_EQ(Path, "/new");
+ }
+ 
+ TEST_F(FileSystemTest, OpenFileForRead) {
+-- 
+2.20.1
+
diff --git a/meta/meta-clang/recipes-devtools/clang/clang/0020-clang-Initial-implementation-of-fmacro-prefix-map-an.patch b/meta/meta-clang/recipes-devtools/clang/clang/0020-clang-Initial-implementation-of-fmacro-prefix-map-an.patch
new file mode 100644
index 0000000..a8e1c9a
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/clang/0020-clang-Initial-implementation-of-fmacro-prefix-map-an.patch
@@ -0,0 +1,387 @@
+From 29a090d31273e78646cc34a392fa292e63e8e4e4 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Fri, 15 Feb 2019 10:02:52 -0800
+Subject: [PATCH 2/2] clang: Initial implementation of -fmacro-prefix-map and
+ -ffile-prefix-map
+
+Upstream-Status: Submitted [https://reviews.llvm.org/D49466]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ .../clang/Basic/DiagnosticDriverKinds.td      |  4 +-
+ clang/include/clang/Driver/Options.td         |  6 +++
+ clang/include/clang/Lex/PreprocessorOptions.h |  3 ++
+ clang/lib/CodeGen/CGDebugInfo.cpp             |  9 +++--
+ clang/lib/CodeGen/CGDebugInfo.h               |  2 +-
+ clang/lib/Driver/ToolChains/Clang.cpp         | 20 +++++++++-
+ clang/lib/Driver/ToolChains/FreeBSD.cpp       | 14 +++++++
+ clang/lib/Driver/ToolChains/Gnu.cpp           | 12 ++++++
+ clang/lib/Frontend/CompilerInvocation.cpp     |  3 ++
+ clang/lib/Lex/PPMacroExpansion.cpp            | 14 ++++++-
+ clang/test/CodeGen/debug-prefix-map.c         |  2 +
+ clang/test/Driver/debug-prefix-map.S          |  1 +
+ clang/test/Driver/debug-prefix-map.c          | 37 ++++++++++++++-----
+ clang/test/Preprocessor/file_test.c           | 22 +++++++++++
+ clang/test/Preprocessor/file_test.h           |  2 +
+ 15 files changed, 133 insertions(+), 18 deletions(-)
+ create mode 100644 clang/test/Preprocessor/file_test.c
+ create mode 100644 clang/test/Preprocessor/file_test.h
+
+diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td
+index 189e0565a83..46972e7c288 100644
+--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
++++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
+@@ -114,8 +114,8 @@ def err_drv_missing_arg_mtp : Error<
+   "missing argument to '%0'">;
+ def err_drv_invalid_libcxx_deployment : Error<
+   "invalid deployment target for -stdlib=libc++ (requires %0 or later)">;
+-def err_drv_invalid_argument_to_fdebug_prefix_map : Error<
+-  "invalid argument '%0' to -fdebug-prefix-map">;
++def err_drv_invalid_argument_to_option : Error<
++  "invalid argument '%0' to -%1">;
+ def err_drv_malformed_sanitizer_blacklist : Error<
+   "malformed sanitizer blacklist: '%0'">;
+ def err_drv_duplicate_config : Error<
+diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
+index a6a6e3b5b53..b9734ea8e4d 100644
+--- a/clang/include/clang/Driver/Options.td
++++ b/clang/include/clang/Driver/Options.td
+@@ -1838,10 +1838,16 @@ def fsplit_dwarf_inlining: Flag <["-"], "fsplit-dwarf-inlining">, Group<f_Group>
+   Flags<[CC1Option]>, HelpText<"Provide minimal debug info in the object/executable to facilitate online symbolication/stack traces in the absence of .dwo/.dwp files when using Split DWARF">;
+ def fno_split_dwarf_inlining: Flag<["-"], "fno-split-dwarf-inlining">, Group<f_Group>,
+   Flags<[CC1Option]>;
++def ffile_prefix_map_EQ
++  : Joined<["-"], "ffile-prefix-map=">, Group<f_Group>, Flags<[CC1Option]>,
++    HelpText<"remap file source paths in debug info and predefined preprocessor macros">;
+ def fdebug_prefix_map_EQ
+   : Joined<["-"], "fdebug-prefix-map=">, Group<f_Group>,
+     Flags<[CC1Option,CC1AsOption]>,
+     HelpText<"remap file source paths in debug info">;
++def fmacro_prefix_map_EQ
++  : Joined<["-"], "fmacro-prefix-map=">, Group<Preprocessor_Group>, Flags<[CC1Option]>,
++    HelpText<"remap file source paths in predefined preprocessor macros">;
+ def g_Flag : Flag<["-"], "g">, Group<g_Group>,
+   HelpText<"Generate source-level debug information">;
+ def gline_tables_only : Flag<["-"], "gline-tables-only">, Group<gN_Group>,
+diff --git a/clang/include/clang/Lex/PreprocessorOptions.h b/clang/include/clang/Lex/PreprocessorOptions.h
+index 1480548c7fb..712b423e679 100644
+--- a/clang/include/clang/Lex/PreprocessorOptions.h
++++ b/clang/include/clang/Lex/PreprocessorOptions.h
+@@ -169,6 +169,9 @@ public:
+   /// build it again.
+   std::shared_ptr<FailedModulesSet> FailedModules;
+ 
++  /// A prefix map for __FILE__ and __BASE_FILE__
++  std::map<std::string, std::string, std::greater<std::string>> MacroPrefixMap;
++
+ public:
+   PreprocessorOptions() : PrecompiledPreambleBytes(0, false) {}
+ 
+diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
+index ce48f8bb132..c5d41667487 100644
+--- a/clang/lib/CodeGen/CGDebugInfo.cpp
++++ b/clang/lib/CodeGen/CGDebugInfo.cpp
+@@ -470,10 +470,13 @@ CGDebugInfo::createFile(StringRef FileName,
+ }
+ 
+ std::string CGDebugInfo::remapDIPath(StringRef Path) const {
++  SmallString<256> p = Path;
+   for (const auto &Entry : DebugPrefixMap)
+-    if (Path.startswith(Entry.first))
+-      return (Twine(Entry.second) + Path.substr(Entry.first.size())).str();
+-  return Path.str();
++    if (llvm::sys::path::replace_path_prefix(p, Entry.first, Entry.second))
++      break;
++  while (llvm::sys::path::is_separator(p.back()))
++    p.set_size(p.size() - 1);
++  return p.str();
+ }
+ 
+ unsigned CGDebugInfo::getLineNumber(SourceLocation Loc) {
+diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
+index 67331b65d3b..c88665d269c 100644
+--- a/clang/lib/CodeGen/CGDebugInfo.h
++++ b/clang/lib/CodeGen/CGDebugInfo.h
+@@ -82,7 +82,7 @@ class CGDebugInfo {
+   /// Cache of previously constructed Types.
+   llvm::DenseMap<const void *, llvm::TrackingMDRef> TypeCache;
+ 
+-  llvm::SmallDenseMap<llvm::StringRef, llvm::StringRef> DebugPrefixMap;
++  std::map<llvm::StringRef, llvm::StringRef, std::greater<llvm::StringRef>> DebugPrefixMap;
+ 
+   /// Cache that maps VLA types to size expressions for that type,
+   /// represented by instantiated Metadata nodes.
+diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
+index fc95003e41b..974bc19403c 100644
+--- a/clang/lib/Driver/ToolChains/Clang.cpp
++++ b/clang/lib/Driver/ToolChains/Clang.cpp
+@@ -613,16 +613,30 @@ static void addDebugCompDirArg(const ArgList &Args, ArgStringList &CmdArgs) {
+ 
+ /// Add a CC1 and CC1AS option to specify the debug file path prefix map.
+ static void addDebugPrefixMapArg(const Driver &D, const ArgList &Args, ArgStringList &CmdArgs) {
+-  for (const Arg *A : Args.filtered(options::OPT_fdebug_prefix_map_EQ)) {
++  for (const Arg *A : Args.filtered(options::OPT_ffile_prefix_map_EQ,
++                                    options::OPT_fdebug_prefix_map_EQ)) {
+     StringRef Map = A->getValue();
+     if (Map.find('=') == StringRef::npos)
+-      D.Diag(diag::err_drv_invalid_argument_to_fdebug_prefix_map) << Map;
++      D.Diag(diag::err_drv_invalid_argument_to_option) << Map << A->getOption().getName();
+     else
+       CmdArgs.push_back(Args.MakeArgString("-fdebug-prefix-map=" + Map));
+     A->claim();
+   }
+ }
+ 
++/// Add a CC1 and CC1AS option to specify the macro file path prefix map.
++static void addMacroPrefixMapArg(const Driver &D, const ArgList &Args, ArgStringList &CmdArgs) {
++  for (const Arg *A : Args.filtered(options::OPT_ffile_prefix_map_EQ,
++                                    options::OPT_fmacro_prefix_map_EQ)) {
++    StringRef Map = A->getValue();
++    if (Map.find('=') == StringRef::npos)
++      D.Diag(diag::err_drv_invalid_argument_to_option) << Map << A->getOption().getName();
++    else
++      CmdArgs.push_back(Args.MakeArgString("-fmacro-prefix-map=" + Map));
++    A->claim();
++  }
++}
++
+ /// Vectorize at all optimization levels greater than 1 except for -Oz.
+ /// For -Oz the loop vectorizer is disable, while the slp vectorizer is enabled.
+ static bool shouldEnableVectorizerAtOLevel(const ArgList &Args, bool isSlpVec) {
+@@ -1261,6 +1275,8 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
+     // For IAMCU add special include arguments.
+     getToolChain().AddIAMCUIncludeArgs(Args, CmdArgs);
+   }
++
++  addMacroPrefixMapArg(D, Args, CmdArgs);
+ }
+ 
+ // FIXME: Move to target hook.
+diff --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp b/clang/lib/Driver/ToolChains/FreeBSD.cpp
+index 55586df9e2f..63d5ebe6984 100644
+--- a/clang/lib/Driver/ToolChains/FreeBSD.cpp
++++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp
+@@ -12,6 +12,7 @@
+ #include "Arch/Sparc.h"
+ #include "CommonArgs.h"
+ #include "clang/Driver/Compilation.h"
++#include "clang/Driver/DriverDiagnostic.h"
+ #include "clang/Driver/Options.h"
+ #include "clang/Driver/SanitizerArgs.h"
+ #include "llvm/Option/ArgList.h"
+@@ -30,6 +31,7 @@ void freebsd::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
+                                       const char *LinkingOutput) const {
+   claimNoWarnArgs(Args);
+   ArgStringList CmdArgs;
++  const auto &D = getToolChain().getDriver();
+ 
+   // When building 32-bit code on FreeBSD/amd64, we have to explicitly
+   // instruct as in the base system to assemble 32-bit code.
+@@ -103,6 +105,18 @@ void freebsd::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
+   }
+   }
+ 
++  for (const Arg *A : Args.filtered(options::OPT_ffile_prefix_map_EQ,
++                                    options::OPT_fdebug_prefix_map_EQ)) {
++    StringRef Map = A->getValue();
++    if (Map.find('=') == StringRef::npos)
++      D.Diag(diag::err_drv_invalid_argument_to_option) << Map << A->getOption().getName();
++    else {
++      CmdArgs.push_back(Args.MakeArgString("--debug-prefix-map"));
++      CmdArgs.push_back(Args.MakeArgString(Map));
++    }
++    A->claim();
++  }
++
+   Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, options::OPT_Xassembler);
+ 
+   CmdArgs.push_back("-o");
+diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
+index e3d836a0b2c..02a1169772b 100644
+--- a/clang/lib/Driver/ToolChains/Gnu.cpp
++++ b/clang/lib/Driver/ToolChains/Gnu.cpp
+@@ -804,6 +804,18 @@ void tools::gnutools::Assembler::ConstructJob(Compilation &C,
+   }
+   }
+ 
++  for (const Arg *A : Args.filtered(options::OPT_ffile_prefix_map_EQ,
++                                    options::OPT_fdebug_prefix_map_EQ)) {
++    StringRef Map = A->getValue();
++    if (Map.find('=') == StringRef::npos)
++      D.Diag(diag::err_drv_invalid_argument_to_option) << Map << A->getOption().getName();
++    else {
++      CmdArgs.push_back(Args.MakeArgString("--debug-prefix-map"));
++      CmdArgs.push_back(Args.MakeArgString(Map));
++    }
++    A->claim();
++  }
++
+   Args.AddAllArgs(CmdArgs, options::OPT_I);
+   Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, options::OPT_Xassembler);
+ 
+diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
+index bda8427b1a1..0f396d1cc7c 100644
+--- a/clang/lib/Frontend/CompilerInvocation.cpp
++++ b/clang/lib/Frontend/CompilerInvocation.cpp
+@@ -3084,6 +3084,9 @@ static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args,
+   for (const auto *A : Args.filtered(OPT_error_on_deserialized_pch_decl))
+     Opts.DeserializedPCHDeclsToErrorOn.insert(A->getValue());
+ 
++  for (const auto &A : Args.getAllArgValues(OPT_fmacro_prefix_map_EQ))
++    Opts.MacroPrefixMap.insert(StringRef(A).split('='));
++
+   if (const Arg *A = Args.getLastArg(OPT_preamble_bytes_EQ)) {
+     StringRef Value(A->getValue());
+     size_t Comma = Value.find(',');
+diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp
+index 2e9c686b2a0..9e72596145f 100644
+--- a/clang/lib/Lex/PPMacroExpansion.cpp
++++ b/clang/lib/Lex/PPMacroExpansion.cpp
+@@ -28,6 +28,7 @@
+ #include "clang/Lex/MacroInfo.h"
+ #include "clang/Lex/Preprocessor.h"
+ #include "clang/Lex/PreprocessorLexer.h"
++#include "clang/Lex/PreprocessorOptions.h"
+ #include "clang/Lex/Token.h"
+ #include "llvm/ADT/ArrayRef.h"
+ #include "llvm/ADT/DenseMap.h"
+@@ -43,6 +44,7 @@
+ #include "llvm/Support/Casting.h"
+ #include "llvm/Support/ErrorHandling.h"
+ #include "llvm/Support/Format.h"
++#include "llvm/Support/Path.h"
+ #include "llvm/Support/raw_ostream.h"
+ #include <algorithm>
+ #include <cassert>
+@@ -1455,6 +1457,15 @@ static bool isTargetEnvironment(const TargetInfo &TI,
+   return TI.getTriple().getEnvironment() == Env.getEnvironment();
+ }
+ 
++static void remapMacroPath(
++    SmallString<256> &Path,
++    const std::map<std::string, std::string, std::greater<std::string>>
++        &MacroPrefixMap) {
++  for (const auto &Entry : MacroPrefixMap)
++    if (llvm::sys::path::replace_path_prefix(Path, Entry.first, Entry.second))
++      break;
++}
++
+ /// ExpandBuiltinMacro - If an identifier token is read that is to be expanded
+ /// as a builtin macro, handle it and return the next token as 'Tok'.
+ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
+@@ -1518,10 +1529,11 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
+     }
+ 
+     // Escape this filename.  Turn '\' -> '\\' '"' -> '\"'
+-    SmallString<128> FN;
++    SmallString<256> FN;
+     if (PLoc.isValid()) {
+       FN += PLoc.getFilename();
+       Lexer::Stringify(FN);
++      remapMacroPath(FN, PPOpts->MacroPrefixMap);
+       OS << '"' << FN << '"';
+     }
+     Tok.setKind(tok::string_literal);
+diff --git a/clang/test/CodeGen/debug-prefix-map.c b/clang/test/CodeGen/debug-prefix-map.c
+index f755ba47a29..e57808f03f9 100644
+--- a/clang/test/CodeGen/debug-prefix-map.c
++++ b/clang/test/CodeGen/debug-prefix-map.c
+@@ -2,6 +2,8 @@
+ // RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH=empty %s -emit-llvm -o - | FileCheck %s -check-prefix CHECK-EVIL
+ // RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -main-file-name debug-prefix-map.c | FileCheck %s
+ // RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -fdebug-compilation-dir %p | FileCheck %s -check-prefix CHECK-COMPILATION-DIR
++// RUN: %clang -g -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty -S -c %s -emit-llvm -o - | FileCheck %s
++// RUN: %clang -g -ffile-prefix-map=%p=/UNLIKELY_PATH/empty -S -c %s -emit-llvm -o - | FileCheck %s
+ 
+ #include "Inputs/stdio.h"
+ 
+diff --git a/clang/test/Driver/debug-prefix-map.S b/clang/test/Driver/debug-prefix-map.S
+index 2ba66be0edf..7d12a174797 100644
+--- a/clang/test/Driver/debug-prefix-map.S
++++ b/clang/test/Driver/debug-prefix-map.S
+@@ -1,4 +1,5 @@
+ // RUN: %clang -### -g -fdebug-prefix-map=old=new %s 2>&1 | FileCheck %s
++// RUN: %clang -### -g -ffile-prefix-map=old=new %s 2>&1 | FileCheck %s
+ 
+ // CHECK: cc1as
+ // CHECK-SAME: -fdebug-prefix-map=old=new
+diff --git a/clang/test/Driver/debug-prefix-map.c b/clang/test/Driver/debug-prefix-map.c
+index b4f3859f982..f2c87cb7c11 100644
+--- a/clang/test/Driver/debug-prefix-map.c
++++ b/clang/test/Driver/debug-prefix-map.c
+@@ -1,9 +1,28 @@
+-// RUN: %clang -### -fdebug-prefix-map=old %s 2>&1 | FileCheck %s -check-prefix CHECK-INVALID
+-// RUN: %clang -### -fdebug-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-SIMPLE
+-// RUN: %clang -### -fdebug-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-COMPLEX
+-// RUN: %clang -### -fdebug-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-EMPTY
+-
+-// CHECK-INVALID: error: invalid argument 'old' to -fdebug-prefix-map
+-// CHECK-SIMPLE: fdebug-prefix-map=old=new
+-// CHECK-COMPLEX: fdebug-prefix-map=old=n=ew
+-// CHECK-EMPTY: fdebug-prefix-map=old=
++// RUN: %clang -### -fdebug-prefix-map=old %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-INVALID
++// RUN: %clang -### -fmacro-prefix-map=old %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-INVALID
++// RUN: %clang -### -ffile-prefix-map=old %s 2>&1 | FileCheck %s -check-prefix CHECK-FILE-INVALID
++
++// RUN: %clang -### -fdebug-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-SIMPLE
++// RUN: %clang -### -fmacro-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-SIMPLE
++// RUN: %clang -### -ffile-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-SIMPLE
++// RUN: %clang -### -ffile-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-SIMPLE
++
++// RUN: %clang -### -fdebug-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-COMPLEX
++// RUN: %clang -### -fmacro-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-COMPLEX
++// RUN: %clang -### -ffile-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-COMPLEX
++// RUN: %clang -### -ffile-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-COMPLEX
++
++// RUN: %clang -### -fdebug-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-EMPTY
++// RUN: %clang -### -fmacro-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-EMPTY
++// RUN: %clang -### -ffile-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-EMPTY
++// RUN: %clang -### -ffile-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-EMPTY
++
++// CHECK-DEBUG-INVALID: error: invalid argument 'old' to -fdebug-prefix-map
++// CHECK-MACRO-INVALID: error: invalid argument 'old' to -fmacro-prefix-map
++// CHECK-FILE-INVALID: error: invalid argument 'old' to -ffile-prefix-map
++// CHECK-DEBUG-SIMPLE: fdebug-prefix-map=old=new
++// CHECK-MACRO-SIMPLE: fmacro-prefix-map=old=new
++// CHECK-DEBUG-COMPLEX: fdebug-prefix-map=old=n=ew
++// CHECK-MACRO-COMPLEX: fmacro-prefix-map=old=n=ew
++// CHECK-DEBUG-EMPTY: fdebug-prefix-map=old=
++// CHECK-MACRO-EMPTY: fmacro-prefix-map=old=
+diff --git a/clang/test/Preprocessor/file_test.c b/clang/test/Preprocessor/file_test.c
+new file mode 100644
+index 00000000000..bdc5f1df659
+--- /dev/null
++++ b/clang/test/Preprocessor/file_test.c
+@@ -0,0 +1,22 @@
++// RUN: %clang -E -ffile-prefix-map=%p=/UNLIKELY_PATH/empty -c -o - %s | FileCheck %s
++// RUN: %clang -E -fmacro-prefix-map=%p=/UNLIKELY_PATH/empty -c -o - %s | FileCheck %s
++// RUN: %clang -E -fmacro-prefix-map=%p=/UNLIKELY_PATH=empty -c -o - %s | FileCheck %s -check-prefix CHECK-EVIL
++// RUN: %clang -E -fmacro-prefix-map=%p/= -c -o - %s | FileCheck %s --check-prefix CHECK-REMOVE
++
++filename: __FILE__
++#include "file_test.h"
++
++// CHECK: filename: "/UNLIKELY_PATH/empty{{[/\\]}}file_test.c"
++// CHECK: filename: "/UNLIKELY_PATH/empty{{[/\\]}}file_test.h"
++// CHECK: basefile: "/UNLIKELY_PATH/empty{{[/\\]}}file_test.c"
++// CHECK-NOT: filename:
++
++// CHECK-EVIL: filename: "/UNLIKELY_PATH=empty{{[/\\]}}file_test.c"
++// CHECK-EVIL: filename: "/UNLIKELY_PATH=empty{{[/\\]}}file_test.h"
++// CHECK-EVIL: basefile: "/UNLIKELY_PATH=empty{{[/\\]}}file_test.c"
++// CHECK-EVIL-NOT: filename:
++
++// CHECK-REMOVE: filename: "file_test.c"
++// CHECK-REMOVE: filename: "file_test.h"
++// CHECK-REMOVE: basefile: "file_test.c"
++// CHECK-REMOVE-NOT: filename:
+diff --git a/clang/test/Preprocessor/file_test.h b/clang/test/Preprocessor/file_test.h
+new file mode 100644
+index 00000000000..c289e5c8362
+--- /dev/null
++++ b/clang/test/Preprocessor/file_test.h
+@@ -0,0 +1,2 @@
++filename: __FILE__
++basefile: __BASE_FILE__
+-- 
+2.20.1
+
diff --git a/meta/meta-clang/recipes-devtools/clang/clang_git.bb b/meta/meta-clang/recipes-devtools/clang/clang_git.bb
new file mode 100644
index 0000000..484e85c
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/clang_git.bb
@@ -0,0 +1,214 @@
+# Copyright (C) 2014 Khem Raj <raj.khem@gmail.com>
+# Released under the MIT license (see COPYING.MIT for the terms)
+
+DESCRIPTION = "LLVM based C/C++ compiler"
+HOMEPAGE = "http://clang.llvm.org/"
+SECTION = "devel"
+
+require clang.inc
+require common-source.inc
+
+INHIBIT_DEFAULT_DEPS = "1"
+
+BUILD_AR_class-nativesdk = "llvm-ar"
+BUILD_RANLIB_class-nativesdk = "llvm-ranlib"
+BUILD_NM_class-nativesdk = "llvm-nm"
+LDFLAGS_append_class-nativesdk = " -fuse-ld=gold"
+
+inherit cmake cmake-native
+
+OECMAKE_FIND_ROOT_PATH_MODE_PROGRAM = "BOTH"
+
+def get_clang_experimental_arch(bb, d, arch_var):
+    import re
+    a = d.getVar(arch_var, True)
+    if re.match('riscv(32|64)$', a):                 return 'RISCV'
+    return ""
+
+def get_clang_arch(bb, d, arch_var):
+    import re
+    a = d.getVar(arch_var, True)
+    if   re.match('(i.86|athlon|x86.64)$', a):         return 'X86'
+    elif re.match('arm$', a):                          return 'ARM'
+    elif re.match('armeb$', a):                        return 'ARM'
+    elif re.match('aarch64$', a):                      return 'AArch64'
+    elif re.match('aarch64_be$', a):                   return 'AArch64'
+    elif re.match('mips(isa|)(32|64|)(r6|)(el|)$', a): return 'Mips'
+    elif re.match('p(pc|owerpc)(|64)', a):             return 'PowerPC'
+    else:
+        bb.note("'%s' is not a primary llvm architecture" % a)
+    return ""
+
+def get_clang_host_arch(bb, d):
+    return get_clang_arch(bb, d, 'HOST_ARCH')
+
+def get_clang_target_arch(bb, d):
+    return get_clang_arch(bb, d, 'TARGET_ARCH')
+
+def get_clang_experimental_target_arch(bb, d):
+    return get_clang_experimental_arch(bb, d, 'TARGET_ARCH')
+
+PACKAGECONFIG ??= "compiler-rt libcplusplus shared-libs ${@bb.utils.filter('DISTRO_FEATURES', 'thin-lto full-lto', d)}"
+PACKAGECONFIG_class-native = ""
+PACKAGECONFIG_class-nativesdk = "thin-lto"
+
+PACKAGECONFIG[compiler-rt] = "-DCLANG_DEFAULT_RTLIB=compiler-rt,,libcxx,compiler-rt"
+PACKAGECONFIG[libcplusplus] = "-DCLANG_DEFAULT_CXX_STDLIB=libc++,,libcxx"
+PACKAGECONFIG[thin-lto] = "-DLLVM_ENABLE_LTO=Thin -DLLVM_BINUTILS_INCDIR=${STAGING_INCDIR},,binutils,"
+PACKAGECONFIG[full-lto] = "-DLLVM_ENABLE_LTO=Full -DLLVM_BINUTILS_INCDIR=${STAGING_INCDIR},,binutils,"
+PACKAGECONFIG[shared-libs] = "-DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON,,,"
+PACKAGECONFIG[terminfo] = "-DLLVM_ENABLE_TERMINFO=ON,-DLLVM_ENABLE_TERMINFO=OFF,ncurses,"
+PACKAGECONFIG[pfm] = "-DLLVM_ENABLE_LIBPFM=ON,-DLLVM_ENABLE_LIBPFM=OFF,libpfm,"
+PACKAGECONFIG[libedit] = "-DLLVM_ENABLE_LIBEDIT=ON,-DLLVM_ENABLE_LIBEDIT=OFF,libedit,"
+
+#
+# Default to build all OE-Core supported target arches (user overridable).
+#
+LLVM_TARGETS_TO_BUILD ?= "AArch64;ARM;BPF;Mips;PowerPC;X86"
+LLVM_TARGETS_TO_BUILD_append = ";${@get_clang_host_arch(bb, d)};${@get_clang_target_arch(bb, d)}"
+
+LLVM_TARGETS_TO_BUILD_TARGET ?= ""
+LLVM_TARGETS_TO_BUILD_TARGET_append ?= "${@get_clang_target_arch(bb, d)}"
+
+LLVM_EXPERIMENTAL_TARGETS_TO_BUILD ?= "RISCV"
+LLVM_EXPERIMENTAL_TARGETS_TO_BUILD_append = ";${@get_clang_experimental_target_arch(bb, d)}"
+
+HF = "${@ bb.utils.contains('TUNE_CCARGS_MFLOAT', 'hard', 'hf', '', d)}"
+HF[vardepvalue] = "${HF}"
+
+EXTRA_OECMAKE += "-DLLVM_ENABLE_ASSERTIONS=OFF \
+                  -DLLVM_ENABLE_EXPENSIVE_CHECKS=OFF \
+                  -DLLVM_ENABLE_PIC=ON \
+                  -DLLVM_BINDINGS_LIST='' \
+                  -DLLVM_ENABLE_FFI=ON \
+                  -DFFI_INCLUDE_DIR=$(pkg-config --variable=includedir libffi) \
+                  -DLLVM_OPTIMIZED_TABLEGEN=ON \
+                  -DLLVM_ENABLE_RTTI=ON \
+                  -DLLVM_ENABLE_EH=ON \
+                  -DLLVM_BUILD_EXTERNAL_COMPILER_RT=ON \
+                  -DCMAKE_SYSTEM_NAME=Linux \
+                  -DCMAKE_BUILD_TYPE=Release \
+                  -DBUILD_SHARED_LIBS=OFF \
+                  -DLLVM_ENABLE_PROJECTS='clang;lld' \
+                  -DLLVM_BINUTILS_INCDIR=${STAGING_INCDIR} \
+                  -G Ninja ${S}/llvm \
+                  -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON \
+"
+
+EXTRA_OECMAKE_append_class-native = "\
+                  -DCLANG_ENABLE_BOOTSTRAP=On \
+                  -DCLANG_BOOTSTRAP_PASSTHROUGH='${PASSTHROUGH}' \
+                  -DBOOTSTRAP_LLVM_ENABLE_LTO=Thin \
+                  -DBOOTSTRAP_LLVM_ENABLE_LLD=ON \
+                  -DLLVM_TARGETS_TO_BUILD='${LLVM_TARGETS_TO_BUILD}' \
+                  -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD='${LLVM_EXPERIMENTAL_TARGETS_TO_BUILD}' \
+"
+EXTRA_OECMAKE_append_class-nativesdk = "\
+                  -DCMAKE_CROSSCOMPILING:BOOL=ON \
+                  -DCROSS_TOOLCHAIN_FLAGS_NATIVE='-DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain-native.cmake' \
+                  -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ranlib \
+                  -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ar \
+                  -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-nm \
+                  -DLLVM_TARGETS_TO_BUILD='${LLVM_TARGETS_TO_BUILD}' \
+                  -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD='${LLVM_EXPERIMENTAL_TARGETS_TO_BUILD}' \
+                  -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen \
+                  -DCLANG_TABLEGEN=${STAGING_BINDIR_NATIVE}/clang-tblgen \
+"
+EXTRA_OECMAKE_append_class-target = "\
+                  -DCMAKE_CROSSCOMPILING:BOOL=ON \
+                  -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen \
+                  -DCLANG_TABLEGEN=${STAGING_BINDIR_NATIVE}/clang-tblgen \
+                  -DLLVM_TARGETS_TO_BUILD='${LLVM_TARGETS_TO_BUILD_TARGET}' \
+                  -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ranlib \
+                  -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ar \
+                  -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-nm \
+                  -DLLVM_TARGET_ARCH=${@get_clang_target_arch(bb, d)} \
+                  -DLLVM_DEFAULT_TARGET_TRIPLE=${TARGET_SYS}${HF} \
+"
+EXTRA_OECMAKE_append_class-target_riscv64 = "\
+                  -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD='${LLVM_EXPERIMENTAL_TARGETS_TO_BUILD}' \
+"
+EXTRA_OECMAKE_append_class-target_riscv32 = "\
+                  -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD='${LLVM_EXPERIMENTAL_TARGETS_TO_BUILD}' \
+"
+DEPENDS = "binutils zlib libffi libxml2 ninja-native"
+DEPENDS_append_class-nativesdk = " clang-crosssdk-${SDK_ARCH} virtual/${TARGET_PREFIX}binutils-crosssdk"
+DEPENDS_append_class-target = " clang-cross-${TARGET_ARCH}"
+
+BOOTSTRAPSTAGE ?= ""
+BOOTSTRAPSTAGE_class-native = "stage2"
+INSTALLTARGET ?= "install"
+INSTALLTARGET_class-native = "stage2-install"
+PASSTRHOUGH ?= ""
+PASSTHROUGH_class-native = "\
+CLANG_DEFAULT_RTLIB;CLANG_DEFAULT_CXX_STDLIB;LLVM_BUILD_LLVM_DYLIB;LLVM_LINK_LLVM_DYLIB;\
+LLVM_ENABLE_ASSERTIONS;LLVM_ENABLE_EXPENSIVE_CHECKS;LLVM_ENABLE_PIC;\
+LLVM_BINDINGS_LIST;LLVM_ENABLE_FFI;FFI_INCLUDE_DIR;LLVM_OPTIMIZED_TABLEGEN;\
+LLVM_ENABLE_RTTI;LLVM_ENABLE_EH;LLVM_BUILD_EXTERNAL_COMPILER_RT;CMAKE_SYSTEM_NAME;\
+CMAKE_BUILD_TYPE;BUILD_SHARED_LIBS;LLVM_ENABLE_PROJECTS;LLVM_BINUTILS_INCDIR;\
+LLVM_TARGETS_TO_BUILD;LLVM_EXPERIMENTAL_TARGETS_TO_BUILD;\
+"
+
+RRECOMMENDS_${PN} = "binutils"
+RRECOMMENDS_${PN}_append_class-target = " libcxx-dev"
+
+do_compile() {
+	ninja ${PARALLEL_MAKE} ${BOOTSTRAPSTAGE}
+}
+
+do_install() {
+        DESTDIR=${D} ninja ${PARALLEL_MAKE} ${INSTALLTARGET}
+}
+
+do_install_append_class-native () {
+	install -Dm 0755 ${B}/bin/clang-tblgen ${D}${bindir}/clang-tblgen
+	for f in `find ${D}${bindir} -executable -type f -not -type l`; do
+		test -n "`file $f|grep -i ELF`" && ${STRIP} $f
+		echo "stripped $f"
+	done
+}
+
+do_install_append_class-nativesdk () {
+	install -Dm 0755 ${B}/bin/clang-tblgen ${D}${bindir}/clang-tblgen
+	for f in `find ${D}${bindir} -executable -type f -not -type l`; do
+		test -n "`file $f|grep -i ELF`" && ${STRIP} $f
+	done
+	rm -rf ${D}${datadir}/llvm/cmake
+	rm -rf ${D}${datadir}/llvm
+}
+
+PACKAGE_DEBUG_SPLIT_STYLE_class-nativesdk = "debug-without-src"
+
+PACKAGES =+ "${PN}-libllvm"
+
+BBCLASSEXTEND = "native nativesdk"
+
+FILES_${PN} += "\
+  ${libdir}/BugpointPasses.so \
+  ${libdir}/LLVMHello.so \
+  ${libdir}/TestPlugin.so \
+  ${libdir}/LLVMgold.so \
+  ${datadir}/scan-* \
+  ${datadir}/opt-viewer/ \
+"
+
+FILES_${PN}-libllvm += "\
+  ${libdir}/libLLVM-${MAJOR_VER}.${MINOR_VER}.so \
+  ${libdir}/libLLVM-${MAJOR_VER}.so \
+  ${libdir}/libLLVM-${MAJOR_VER}.${MINOR_VER}svn.so \
+"
+
+FILES_${PN}-dev += "\
+  ${datadir}/llvm/cmake \
+  ${libdir}/cmake \
+"
+
+INSANE_SKIP_${PN} += "already-stripped"
+INSANE_SKIP_${PN}-dev += "dev-elf"
+
+#Avoid SSTATE_SCAN_COMMAND running sed over llvm-config.
+SSTATE_SCAN_FILES_remove = "*-config"
+
+TOOLCHAIN = "clang"
+TOOLCHAIN_class-native = "gcc"
+TOOLCHAIN_class-nativesdk = "clang"
diff --git a/meta/meta-clang/recipes-devtools/clang/common-source.inc b/meta/meta-clang/recipes-devtools/clang/common-source.inc
new file mode 100644
index 0000000..e7fb06f
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/common-source.inc
@@ -0,0 +1,11 @@
+do_fetch() {
+        :
+}
+do_fetch[noexec] = "1"
+deltask do_unpack
+deltask do_patch
+
+SRC_URI = ""
+
+do_configure[depends] += "llvm-project-source-${PV}:do_patch"
+do_populate_lic[depends] += "llvm-project-source-${PV}:do_unpack"
diff --git a/meta/meta-clang/recipes-devtools/clang/common.inc b/meta/meta-clang/recipes-devtools/clang/common.inc
new file mode 100644
index 0000000..fec78fb
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/common.inc
@@ -0,0 +1,42 @@
+FILESEXTRAPATHS =. "${FILE_DIRNAME}/clang:"
+
+LIC_FILES_CHKSUM = "file://llvm/LICENSE.TXT;md5=${LLVMMD5SUM} \
+                    file://clang/LICENSE.TXT;md5=${CLANGMD5SUM} \
+"
+LICENSE = "NCSA"
+
+BASEURI ??= "${LLVM_GIT}/llvm-project;protocol=${LLVM_GIT_PROTOCOL};branch=${BRANCH}"
+SRC_URI = "\
+    ${BASEURI} \
+    ${@'file://0001-clang-Enable-SSP-and-PIE-by-default.patch' if '${GCCPIE}' else ''} \
+    file://0002-clang-driver-Use-lib-for-ldso-on-OE.patch \
+    file://0003-clang-Driver-tools.cpp-Add-lssp_nonshared-on-musl.patch \
+    file://0004-clang-musl-ppc-does-not-support-128-bit-long-double.patch \
+    file://0005-clang-Prepend-trailing-to-sysroot.patch \
+    file://0006-clang-Look-inside-the-target-sysroot-for-compiler-ru.patch \
+    file://0007-clang-Define-releative-gcc-installation-dir.patch \
+    file://0008-clang-Fix-ldso-for-musl-on-x86-and-x32-architectures.patch \
+    file://0009-clang-scan-view-needs-python-2.x.patch \
+    file://0010-clang-Append-libunwind-to-compiler-rt-for-linking.patch \
+    file://0011-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch \
+    file://0012-llvm-allow-env-override-of-exe-path.patch \
+    file://0013-llvm-AARCH64-Add-support-for-.dword-directives.patch \
+    file://0014-lldb-Add-lxml2-to-linker-cmdline-of-xml-is-found.patch \
+    file://0015-libcxxabi-Find-libunwind-headers-when-LIBCXXABI_LIBU.patch \
+    file://0016-compiler-rt-support-a-new-embedded-linux-target.patch \
+    file://0017-compiler-rt-Simplify-cross-compilation.-Don-t-use-na.patch \
+    file://0018-compiler-rt-Disable-tsan-on-OE-glibc.patch \
+    file://0019-llvm-Enhance-path-prefix-mapping.patch \
+    file://0020-clang-Initial-implementation-of-fmacro-prefix-map-an.patch \
+"
+
+# Fallback to no-PIE if not set
+GCCPIE ??= ""
+
+S = "${TMPDIR}/work-shared/llvm-project-source-${PV}-${PR}/git"
+B = "${WORKDIR}/llvm-project-source-${PV}/build.${HOST_SYS}.${TARGET_SYS}"
+
+# We need to ensure that for the shared work directory, the do_patch signatures match
+# The real WORKDIR location isn't a dependency for the shared workdir.
+src_patches[vardepsexclude] = "WORKDIR"
+should_apply[vardepsexclude] += "PN"
diff --git a/meta/meta-clang/recipes-devtools/clang/compiler-rt_git.bb b/meta/meta-clang/recipes-devtools/clang/compiler-rt_git.bb
new file mode 100644
index 0000000..9a15211
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/compiler-rt_git.bb
@@ -0,0 +1,99 @@
+# Copyright (C) 2015 Khem Raj <raj.khem@gmail.com>
+# Released under the MIT license (see COPYING.MIT for the terms)
+
+DESCRIPTION = "LLVM based C/C++ compiler Runtime"
+HOMEPAGE = "http://compiler-rt.llvm.org/"
+LICENSE = "MIT | NCSA"
+SECTION = "base"
+
+require clang.inc
+require common-source.inc
+
+inherit cmake pkgconfig pythonnative
+
+
+LIC_FILES_CHKSUM = "file://compiler-rt/LICENSE.TXT;md5=f981c4637a4cd67915ac527b3ead3a59; \
+"
+
+BASEDEPENDS_remove_toolchain-clang_class-target = "compiler-rt libcxx"
+DEPENDS_append_toolchain-clang_class-target = " virtual/${TARGET_PREFIX}compilerlibs"
+TARGET_CXXFLAGS_remove_toolchain-clang = "--stdlib=libc++"
+TUNE_CCARGS_remove_toolchain-clang = "--rtlib=compiler-rt --stdlib=libc++"
+TUNE_CCARGS_remove = "-no-integrated-as"
+DEPENDS += "ninja-native"
+DEPENDS_append_class-nativesdk = " clang-native"
+
+THUMB_TUNE_CCARGS = ""
+#TUNE_CCARGS += "-nostdlib"
+
+HF = "${@ bb.utils.contains('TUNE_CCARGS_MFLOAT', 'hard', 'hf', '', d)}"
+HF[vardepvalue] = "${HF}"
+EXTRA_OECMAKE += "-DCOMPILER_RT_STANDALONE_BUILD=OFF \
+                  -DCOMPILER_RT_DEFAULT_TARGET_TRIPLE=${HOST_ARCH}${HF}${HOST_VENDOR}-${HOST_OS} \
+                  -DCOMPILER_RT_BUILD_XRAY=OFF \
+                  -DLLVM_ENABLE_PROJECTS='compiler-rt' \
+                  -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ranlib \
+                  -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ar \
+                  -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-nm \
+                  -G Ninja ${S}/llvm \
+"
+
+EXTRA_OECMAKE_append_class-nativesdk = "\
+               -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen \
+               -DCLANG_TABLEGEN=${STAGING_BINDIR_NATIVE}/clang-tblgen \
+"
+
+EXTRA_OECMAKE_append_libc-musl = " -DCOMPILER_RT_BUILD_SANITIZERS=OFF "
+CXXFLAGS_append_libc-musl = " -D_LIBCPP_HAS_MUSL_LIBC=ON "
+EXTRA_OECMAKE_append_mipsarch = "-DCOMPILER_RT_BUILD_SANITIZERS=OFF "
+
+do_compile() {
+	ninja ${PARALLEL_MAKE} compiler-rt
+}
+
+do_install() {
+	DESTDIR=${D} ninja ${PARALLEL_MAKE} install-compiler-rt
+}
+
+
+do_install_append () {
+	if [ -d ${D}${libdir}/linux ]; then
+		for f in `find ${D}${libdir}/linux -maxdepth 1 -type f`
+		do
+			install -D -m 0644 $f ${D}${libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/`basename $f`
+			rm $f
+		done
+		rmdir ${D}${libdir}/linux
+	fi
+	for f in `find ${D}${exec_prefix} -maxdepth 1 -name '*.txt' -type f`
+	do
+		install -D -m 0644  $f ${D}${libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/`basename $f`
+		rm $f
+	done
+}
+
+FILES_SOLIBSDEV = ""
+FILES_${PN} += "${libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/lib*${SOLIBSDEV} \
+                ${libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/*.txt \
+                ${libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/share/*.txt"
+FILES_${PN}-staticdev += "${libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/*.a"
+FILES_${PN}-dev += "${datadir} ${libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/*.syms"
+INSANE_SKIP_${PN} = "dev-so"
+
+#PROVIDES_append_class-target = "\
+#        virtual/${TARGET_PREFIX}compilerlibs \
+#        libgcc \
+#        libgcc-initial \
+#        libgcc-dev \
+#        libgcc-initial-dev \
+#        "
+#
+
+RDEPENDS_${PN}-dev += "${PN}-staticdev"
+
+BBCLASSEXTEND = "native nativesdk"
+
+ALLOW_EMPTY_${PN} = "1"
+ALLOW_EMPTY_${PN}-dev = "1"
+
+TOOLCHAIN_forcevariable = "clang"
diff --git a/meta/meta-clang/recipes-devtools/clang/libcxx_git.bb b/meta/meta-clang/recipes-devtools/clang/libcxx_git.bb
new file mode 100644
index 0000000..ad755b9
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/libcxx_git.bb
@@ -0,0 +1,80 @@
+# Copyright (C) 2015 Khem Raj <raj.khem@gmail.com>
+# Released under the MIT license (see COPYING.MIT for the terms)
+
+DESCRIPTION = "libc++ is a new implementation of the C++ standard library, targeting C++11"
+HOMEPAGE = "http://libcxx.llvm.org/"
+LICENSE = "MIT | NCSA"
+SECTION = "base"
+
+require clang.inc
+require common-source.inc
+
+inherit cmake pythonnative
+
+DEPENDS += "ninja-native"
+BASEDEPENDS_remove_toolchain-clang = "libcxx"
+DEPENDS_append_toolchain-clang = " virtual/${TARGET_PREFIX}compilerlibs"
+TARGET_CXXFLAGS_remove_toolchain-clang = "--stdlib=libc++"
+TUNE_CCARGS_remove_toolchain-clang = "--rtlib=compiler-rt --stdlib=libc++"
+
+PACKAGECONFIG ??= "unwind"
+PACKAGECONFIG_powerpc = ""
+PACKAGECONFIG_mipsarch = ""
+PACKAGECONFIG_riscv64 = ""
+PACKAGECONFIG[unwind] = "-DLIBCXXABI_USE_LLVM_UNWINDER=ON -DLIBUNWIND_ENABLE_SHARED=OFF -DLIBCXXABI_ENABLE_STATIC_UNWINDER=ON -DLIBCXXABI_LIBUNWIND_INCLUDES=${S}/projects/libunwind/include, -DLIBCXXABI_USE_LLVM_UNWINDER=OFF,"
+
+#PROVIDES += "${@bb.utils.contains('PACKAGECONFIG', 'unwind', 'libunwind', '', d)}"
+LIBUNWIND = "${@bb.utils.contains('PACKAGECONFIG', 'unwind', ';libunwind', '', d)}"
+
+LIC_FILES_CHKSUM = "file://libcxx/LICENSE.TXT;md5=3de3deb8323d5cf3360104190e804a75 \
+                    file://libcxxabi/LICENSE.TXT;md5=9dad5a191d1fc03b31525706040c4ed1 \
+                    file://libunwind/LICENSE.TXT;md5=af2bc0b29ead3c8f201c5486f3c9d59b \
+"
+THUMB_TUNE_CCARGS = ""
+#TUNE_CCARGS += "-nostdlib"
+EXTRA_OECMAKE_append_armv5 = " -D_LIBCXXABI_HAS_ATOMIC_BUILTINS=OFF"
+
+EXTRA_OECMAKE += "\
+                  -DLIBCXX_CXX_ABI=libcxxabi \
+                  -DLIBCXX_USE_COMPILER_RT=YES \
+                  -DLIBCXXABI_USE_COMPILER_RT=YES \
+                  -DCXX_SUPPORTS_CXX11=ON \
+                  -DLIBCXXABI_LIBCXX_INCLUDES=${S}/libcxx/include \
+                  -DLIBCXX_CXX_ABI_INCLUDE_PATHS=${S}/libcxxabi/include \
+                  -DLIBCXX_CXX_ABI_LIBRARY_PATH=${B}/lib \
+                  -DCMAKE_AR=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ar \
+                  -DCMAKE_NM=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-nm \
+                  -DCMAKE_RANLIB=${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}llvm-ranlib \
+                  -DLLVM_ENABLE_PROJECTS='libcxx;libcxxabi${LIBUNWIND}' \
+                  -G Ninja \
+                  ${S}/llvm \
+"
+
+EXTRA_OECMAKE_append_class-native = " -DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=OFF"
+EXTRA_OECMAKE_append_class-nativesdk = " -DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=OFF"
+EXTRA_OECMAKE_append_libc-musl = " -DLIBCXX_HAS_MUSL_LIBC=ON "
+
+do_compile() {
+    if ${@bb.utils.contains('PACKAGECONFIG', 'unwind', 'true', 'false', d)}; then
+        ninja -v ${PARALLEL_MAKE} unwind
+    fi
+    ninja -v ${PARALLEL_MAKE} cxxabi
+    ninja -v ${PARALLEL_MAKE} cxx
+}
+
+do_install() {
+    if ${@bb.utils.contains('PACKAGECONFIG', 'unwind', 'true', 'false', d)}; then
+        DESTDIR=${D} ninja ${PARALLEL_MAKE} install-unwind
+        rm -rf ${D}${libdir}/libunwind.so
+    fi
+    DESTDIR=${D} ninja ${PARALLEL_MAKE} install-cxx install-cxxabi
+}
+
+ALLOW_EMPTY_${PN} = "1"
+
+#PROVIDES = "virtual/${TARGET_PREFIX}compilerlibs"
+
+RDEPENDS_${PN}-dev += "${PN}-staticdev"
+
+BBCLASSEXTEND = "native nativesdk"
+TOOLCHAIN_forcevariable = "clang"
diff --git a/meta/meta-clang/recipes-devtools/clang/lldb_git.bb b/meta/meta-clang/recipes-devtools/clang/lldb_git.bb
new file mode 100644
index 0000000..7c4be42
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/lldb_git.bb
@@ -0,0 +1,57 @@
+# Copyright (C) 2017 Kai Ruhnau <kai.ruhnau@target-sg.com>
+# Released under the MIT license (see COPYING.MIT for the terms)
+
+DESCRIPTION = "Next generation, high-performance debugger"
+HOMEPAGE = "http://lldb.llvm.org/"
+LICENSE = "MIT | NCSA"
+SECTION = "devel"
+
+DEPENDS += "clang-native zlib libxml2 ninja-native"
+
+require clang.inc
+require common-source.inc
+
+inherit cmake pkgconfig
+
+LIC_FILES_CHKSUM = "file://llvm/LICENSE.TXT;md5=${LLVMMD5SUM}; \
+                    file://clang/LICENSE.TXT;md5=${CLANGMD5SUM}; \
+                    file://lldb/LICENSE.TXT;md5=${LLDBMD5SUM}; \
+"
+
+OECMAKE_FIND_ROOT_PATH_MODE_PROGRAM = "BOTH"
+
+EXTRA_OECMAKE="\
+    -DCMAKE_CROSSCOMPILING=1 \
+    -DLLVM_ENABLE_CXX11=ON \
+    -DLLVM_BUILD_LLVM_DYLIB=ON \
+    -DBUILD_SHARED_LIBS=OFF \
+    -DLLVM_BUILD_LLVM_DYLIB=ON \
+    -DLLVM_ENABLE_PIC=ON \
+    -DLLDB_DISABLE_LIBEDIT=1 \
+    -DLLDB_DISABLE_CURSES=1 \
+    -DLLDB_DISABLE_PYTHON=1 \
+    -DLLVM_ENABLE_TERMINFO=0 \
+    -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen \
+    -DCLANG_TABLEGEN=${STAGING_BINDIR_NATIVE}/clang-tblgen \
+    -DLLVM_HOST_TRIPLE=${TARGET_SYS} \
+    -DLLDB_TEST_USE_CUSTOM_C_COMPILER=ON \
+    -DLLDB_TEST_USE_CUSTOM_CXX_COMPILER=ON \
+    -DLLDB_TEST_C_COMPILER='${CC}' \
+    -DLLDB_TEST_CXX_COMPILER='${CXX}' \
+    -DCMAKE_BUILD_TYPE=Release \
+    -DLLVM_ENABLE_PROJECTS='clang;lldb' \
+    -G Ninja ${S}/llvm \
+"
+
+EXTRA_OEMAKE = "VERBOSE=1"
+
+do_compile() {
+       ninja ${PARALLEL_MAKE} lldb
+}
+
+do_install() {
+       DESTDIR=${D} ninja ${PARALLEL_MAKE} tools/lldb/install
+}
+
+INSANE_SKIP_${PN}-dbg = "libdir"
+INSANE_SKIP_${PN} = "libdir"
diff --git a/meta/meta-clang/recipes-devtools/clang/llvm-common.bb b/meta/meta-clang/recipes-devtools/clang/llvm-common.bb
new file mode 100644
index 0000000..f17f01c
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/llvm-common.bb
@@ -0,0 +1,22 @@
+SUMMARY = "Helper script for OE's llvm support"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+
+SRC_URI = "file://llvm-config"
+
+S = "${WORKDIR}"
+
+ALLOW_EMPTY_${PN} = "1"
+SYSROOT_PREPROCESS_FUNCS_append_class-target = " llvm_common_sysroot_preprocess"
+
+llvm_common_sysroot_preprocess() {
+    install -d ${SYSROOT_DESTDIR}${bindir_crossscripts}/
+    install -m 0755 ${WORKDIR}/llvm-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/
+}
+
+do_install_class-native() {
+    install -d ${D}${bindir}
+    install -m 0755 ${WORKDIR}/llvm-config ${D}${bindir}
+}
+
+BBCLASSEXTEND = "native"
diff --git a/meta/meta-clang/recipes-devtools/clang/llvm-common/llvm-config b/meta/meta-clang/recipes-devtools/clang/llvm-common/llvm-config
new file mode 100644
index 0000000..4462896
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/llvm-common/llvm-config
@@ -0,0 +1,39 @@
+#!/bin/bash
+#
+# Wrapper script for llvm-config. Supplies the right environment variables
+# for the target and delegates to the native llvm-config for anything else. This
+# is needed because arguments like --ldflags, --cxxflags, etc. are set by the
+# native compile rather than the target compile.
+#
+
+SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
+NEXT_LLVM_CONFIG="$(which -a llvm-config | sed -n 2p)"
+export YOCTO_ALTERNATE_EXE_PATH="$(readlink -f "$SCRIPT_DIR/../llvm-config")"
+
+if [[ $# == 0 ]]; then
+  exec "$NEXT_LLVM_CONFIG"
+fi
+
+if [[ $1 == "--libs" ]]; then
+  exec "$NEXT_LLVM_CONFIG" $@
+fi
+
+for arg in "$@"; do
+  case "$arg" in
+    --cppflags)
+      echo $TARGET_CPPFLAGS
+      ;;
+    --cflags)
+      echo $TARGET_CFLAGS
+      ;;
+    --cxxflags)
+      echo $TARGET_CXXFLAGS
+      ;;
+    --ldflags)
+      echo $TARGET_LDFLAGS
+      ;;
+    *)
+      echo "$("$NEXT_LLVM_CONFIG" "$arg")"
+      ;;
+  esac
+done
diff --git a/meta/meta-clang/recipes-devtools/clang/llvm-project-source.bb b/meta/meta-clang/recipes-devtools/clang/llvm-project-source.bb
new file mode 100644
index 0000000..78664c5
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/llvm-project-source.bb
@@ -0,0 +1,10 @@
+# Copyright (C) 2018 Khem Raj <raj.khem@gmail.com>
+# Released under the MIT license (see COPYING.MIT for the terms)
+
+SUMMARY = "This is the canonical git mirror of the LLVM subversion repository."
+HOMEPAGE = "https://github.com/llvm/llvm-project"
+
+require llvm-project-source.inc
+require clang.inc
+
+EXCLUDE_FROM_WORLD = "1"
diff --git a/meta/meta-clang/recipes-devtools/clang/llvm-project-source.inc b/meta/meta-clang/recipes-devtools/clang/llvm-project-source.inc
new file mode 100644
index 0000000..f6c552d
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/llvm-project-source.inc
@@ -0,0 +1,20 @@
+deltask do_configure
+deltask do_compile
+deltask do_install
+deltask do_populate_sysroot
+deltask do_populate_lic
+RM_WORK_EXCLUDE += "${PN}"
+
+inherit nopackages
+
+PN = "llvm-project-source-${PV}"
+
+WORKDIR = "${TMPDIR}/work-shared/llvm-project-source-${PV}-${PR}"
+SSTATE_SWSPEC = "sstate:llvm-project-source::${PV}:${PR}::${SSTATE_VERSION}:"
+
+STAMP = "${STAMPS_DIR}/work-shared/llvm-project-source-${PV}-${PR}"
+STAMPCLEAN = "${STAMPS_DIR}/work-shared/llvm-project-source-${PV}-*"
+
+INHIBIT_DEFAULT_DEPS = "1"
+DEPENDS = ""
+PACKAGES = ""
diff --git a/meta/meta-clang/recipes-devtools/clang/nativesdk-clang-glue.bb b/meta/meta-clang/recipes-devtools/clang/nativesdk-clang-glue.bb
new file mode 100644
index 0000000..add6a8b
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/nativesdk-clang-glue.bb
@@ -0,0 +1,33 @@
+# Copyright (C) 2014 Khem Raj <raj.khem@gmail.com>
+# Released under the MIT license (see COPYING.MIT for the terms)
+
+DESCRIPTION = "SDK Cross compiler wrappers for LLVM based C/C++ compiler"
+HOMEPAGE = "http://clang.llvm.org/"
+LICENSE = "NCSA"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/NCSA;md5=1b5fdec70ee13ad8a91667f16c1959d7"
+SECTION = "devel"
+
+inherit nativesdk
+DEPENDS += "nativesdk-clang"
+
+do_install() {
+    install -d ${D}${prefix_nativesdk}
+    cd ${D}${prefix_nativesdk}
+    ln -s ..${libdir} .
+    ln -s ..${includedir} .
+    cd ..
+    ln -s .${base_libdir} .
+}
+
+sysroot_stage_all () {
+	sysroot_stage_dir ${D} ${SYSROOT_DESTDIR}
+}
+
+FILES_${PN} += "${prefix_nativesdk} ${base_libdir_nativesdk}"
+FILES_${PN}-dbg = ""
+
+deltask do_configure
+deltask do_compile
+deltask do_patch
+deltask do_fetch
+deltask do_unpack
diff --git a/meta/meta-clang/recipes-devtools/clang/openmp_git.bb b/meta/meta-clang/recipes-devtools/clang/openmp_git.bb
new file mode 100644
index 0000000..f219a0a
--- /dev/null
+++ b/meta/meta-clang/recipes-devtools/clang/openmp_git.bb
@@ -0,0 +1,40 @@
+# Copyright (C) 2017 Khem Raj <raj.khem@gmail.com>
+# Released under the MIT license (see COPYING.MIT for the terms)
+
+DESCRIPTION = "LLVM based C/C++ compiler Runtime"
+HOMEPAGE = "http://openmp.llvm.org/"
+LICENSE = "MIT | NCSA"
+SECTION = "base"
+
+require clang.inc
+require common-source.inc
+
+DEPENDS += "ninja-native"
+
+RPROVIDES_${PN} += "libgomp"
+RPROVIDES_${PN}-dev += "libgomp-dev"
+
+TOOLCHAIN = "clang"
+
+LIC_FILES_CHKSUM = "file://openmp/LICENSE.txt;md5=b1dcbf2c86cbf9bdc0b7cea88a543010"
+
+inherit cmake pkgconfig perlnative
+
+EXTRA_OECMAKE = "-G Ninja ${S}/openmp"
+
+THUMB_TUNE_CCARGS = ""
+
+do_compile() {
+	ninja ${PARALLEL_MAKE}
+}
+
+do_install() {
+	DESTDIR=${D} ninja ${PARALLEL_MAKE} install
+}
+
+FILES_SOLIBSDEV = ""
+FILES_${PN} += "${libdir}/lib*${SOLIBSDEV}"
+INSANE_SKIP_${PN} = "dev-so"
+
+COMPATIBLE_HOST_riscv64 = "null"
+COMPATIBLE_HOST_riscv32 = "null"
diff --git a/meta/meta-clang/recipes-extended/mdadm/mdadm_%.bbappend b/meta/meta-clang/recipes-extended/mdadm/mdadm_%.bbappend
new file mode 100644
index 0000000..903836e
--- /dev/null
+++ b/meta/meta-clang/recipes-extended/mdadm/mdadm_%.bbappend
@@ -0,0 +1,6 @@
+# Fix errors like
+# | super-intel.c:1673:23: error: taking address of packed member 'size_high' of class or structure 'imsm_dev' may result in an unaligned pointer value [-Werror,-Waddress-of-packed-member]
+# |                                  &dev->size_low, &dev->size_high);
+# |                                                   ^~~~~~~~~~~~~~
+
+CFLAGS_append_toolchain-clang = " -Wno-error=address-of-packed-member"
diff --git a/meta/meta-clang/recipes-gnome/gcr/gcr_%.bbappend b/meta/meta-clang/recipes-gnome/gcr/gcr_%.bbappend
new file mode 100644
index 0000000..4432748
--- /dev/null
+++ b/meta/meta-clang/recipes-gnome/gcr/gcr_%.bbappend
@@ -0,0 +1,4 @@
+# qemu crashes when built with hardening flags
+#
+GI_DATA_ENABLED_toolchain-clang = "False"
+
diff --git a/meta/meta-clang/recipes-graphics/mesa/mesa_%.bbappend b/meta/meta-clang/recipes-graphics/mesa/mesa_%.bbappend
new file mode 100644
index 0000000..fadc95c
--- /dev/null
+++ b/meta/meta-clang/recipes-graphics/mesa/mesa_%.bbappend
@@ -0,0 +1,5 @@
+LDFLAGS_append_toolchain-clang = " -latomic -lm"
+DEPENDS_append_toolchain-clang = " libatomic-ops"
+
+EXTRA_OECONF_append_toolchain-clang_x86 = " --disable-asm"
+EXTRA_OECONF_append_toolchain-clang_x86-64 = " --disable-asm"
diff --git a/meta/meta-clang/recipes-kernel/perf/perf.bbappend b/meta/meta-clang/recipes-kernel/perf/perf.bbappend
new file mode 100644
index 0000000..82f7d8b
--- /dev/null
+++ b/meta/meta-clang/recipes-kernel/perf/perf.bbappend
@@ -0,0 +1 @@
+DEPENDS_append_class-target = " clang-cross-${TARGET_ARCH}"
diff --git a/meta/meta-clang/recipes-multimedia/libvorbis/libvorbis_%.bbappend b/meta/meta-clang/recipes-multimedia/libvorbis/libvorbis_%.bbappend
new file mode 100644
index 0000000..c6fe98c
--- /dev/null
+++ b/meta/meta-clang/recipes-multimedia/libvorbis/libvorbis_%.bbappend
@@ -0,0 +1,4 @@
+# | clang-7: error: unknown argument: '-mfused-madd'
+do_configure_prepend_toolchain-clang() {
+	sed -i -e "s/-mfused-madd//g" ${S}/configure.ac
+}
diff --git a/meta/meta-clang/recipes-support/libunwind/libunwind_%.bbappend b/meta/meta-clang/recipes-support/libunwind/libunwind_%.bbappend
new file mode 100644
index 0000000..6ce6935
--- /dev/null
+++ b/meta/meta-clang/recipes-support/libunwind/libunwind_%.bbappend
@@ -0,0 +1,4 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+# For clang libunwind.a comes from libcxx
+EXTRA_OECONF_remove_toolchain-clang = "--enable-static"
+EXTRA_OECONF_append_toolchain-clang = " --disable-static"