From 610a8e1a2ce02b77f905bac261e80b023450b573 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Mon, 29 Jul 2019 23:04:31 -0700 Subject: clang: Upgrade to 9.x-rcX dont package six.py, its provided by python3-six package default to lp64d ABI and rv64gc ISA. Signed-off-by: Khem Raj --- recipes-devtools/clang/clang-cross-canadian_git.bb | 3 +- recipes-devtools/clang/clang-cross_git.bb | 3 +- recipes-devtools/clang/clang-crosssdk_git.bb | 3 +- recipes-devtools/clang/clang.inc | 14 +- .../0001-clang-Enable-SSP-and-PIE-by-default.patch | 63 ---- ...d-lxml2-to-linker-cmdline-of-xml-is-found.patch | 40 +++ .../0002-clang-driver-Use-lib-for-ldso-on-OE.patch | 63 ---- ...ind-libunwind-headers-when-LIBCXXABI_LIBU.patch | 67 ++++ ...iver-tools.cpp-Add-lssp_nonshared-on-musl.patch | 34 -- ...er-rt-support-a-new-embedded-linux-target.patch | 325 +++++++++++++++++ ...-ppc-does-not-support-128-bit-long-double.patch | 28 -- ...-Simplify-cross-compilation.-Don-t-use-na.patch | 46 +++ .../0005-clang-Prepend-trailing-to-sysroot.patch | 41 --- ...0005-compiler-rt-Disable-tsan-on-OE-glibc.patch | 43 +++ ...inside-the-target-sysroot-for-compiler-ru.patch | 44 --- ...LibraryInfo-Undefine-libc-functions-if-th.patch | 91 +++++ ...ang-Define-releative-gcc-installation-dir.patch | 32 -- .../0007-llvm-allow-env-override-of-exe-path.patch | 37 ++ ...dso-for-musl-on-x86-and-x32-architectures.patch | 44 --- .../0008-llvm-Enhance-path-prefix-mapping.patch | 175 ++++++++++ .../0009-clang-Enable-SSP-and-PIE-by-default.patch | 63 ++++ .../0009-clang-scan-view-needs-python-2.x.patch | 27 -- ...pend-libunwind-to-compiler-rt-for-linking.patch | 33 -- .../0010-clang-driver-Use-lib-for-ldso-on-OE.patch | 63 ++++ ...iver-tools.cpp-Add-lssp_nonshared-on-musl.patch | 34 ++ ...LibraryInfo-Undefine-libc-functions-if-th.patch | 91 ----- ...-ppc-does-not-support-128-bit-long-double.patch | 28 ++ .../0012-llvm-allow-env-override-of-exe-path.patch | 37 -- .../0013-clang-Prepend-trailing-to-sysroot.patch | 41 +++ ...AARCH64-Add-support-for-.dword-directives.patch | 57 --- ...inside-the-target-sysroot-for-compiler-ru.patch | 44 +++ ...d-lxml2-to-linker-cmdline-of-xml-is-found.patch | 40 --- ...ang-Define-releative-gcc-installation-dir.patch | 32 ++ ...ind-libunwind-headers-when-LIBCXXABI_LIBU.patch | 68 ---- ...dso-for-musl-on-x86-and-x32-architectures.patch | 44 +++ ...er-rt-support-a-new-embedded-linux-target.patch | 326 ----------------- .../0017-clang-scan-view-needs-python-2.x.patch | 27 ++ ...-Simplify-cross-compilation.-Don-t-use-na.patch | 46 --- ...al-implementation-of-fmacro-prefix-map-an.patch | 383 ++++++++++++++++++++ ...0018-compiler-rt-Disable-tsan-on-OE-glibc.patch | 42 --- ...pthread-and-ldl-along-with-lunwind-for-st.patch | 39 +++ .../0019-llvm-Enhance-path-prefix-mapping.patch | 175 ---------- ...al-implementation-of-fmacro-prefix-map-an.patch | 387 --------------------- ...clang-default-to-lp64d-ABI-and-rv64gc-ISA.patch | 52 +++ recipes-devtools/clang/clang_git.bb | 1 + recipes-devtools/clang/common.inc | 42 +-- recipes-devtools/clang/compiler-rt_git.bb | 9 +- recipes-devtools/clang/libcxx_git.bb | 7 +- recipes-devtools/clang/lldb_git.bb | 1 - recipes-devtools/clang/llvm-common.bb | 4 +- recipes-devtools/clang/nativesdk-clang-glue.bb | 4 +- recipes-devtools/clang/openmp_git.bb | 5 +- 52 files changed, 1720 insertions(+), 1728 deletions(-) delete mode 100644 recipes-devtools/clang/clang/0001-clang-Enable-SSP-and-PIE-by-default.patch create mode 100644 recipes-devtools/clang/clang/0001-lldb-Add-lxml2-to-linker-cmdline-of-xml-is-found.patch delete mode 100644 recipes-devtools/clang/clang/0002-clang-driver-Use-lib-for-ldso-on-OE.patch create mode 100644 recipes-devtools/clang/clang/0002-libcxxabi-Find-libunwind-headers-when-LIBCXXABI_LIBU.patch delete mode 100644 recipes-devtools/clang/clang/0003-clang-Driver-tools.cpp-Add-lssp_nonshared-on-musl.patch create mode 100644 recipes-devtools/clang/clang/0003-compiler-rt-support-a-new-embedded-linux-target.patch delete mode 100644 recipes-devtools/clang/clang/0004-clang-musl-ppc-does-not-support-128-bit-long-double.patch create mode 100644 recipes-devtools/clang/clang/0004-compiler-rt-Simplify-cross-compilation.-Don-t-use-na.patch delete mode 100644 recipes-devtools/clang/clang/0005-clang-Prepend-trailing-to-sysroot.patch create mode 100644 recipes-devtools/clang/clang/0005-compiler-rt-Disable-tsan-on-OE-glibc.patch delete mode 100644 recipes-devtools/clang/clang/0006-clang-Look-inside-the-target-sysroot-for-compiler-ru.patch create mode 100644 recipes-devtools/clang/clang/0006-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch delete mode 100644 recipes-devtools/clang/clang/0007-clang-Define-releative-gcc-installation-dir.patch create mode 100644 recipes-devtools/clang/clang/0007-llvm-allow-env-override-of-exe-path.patch delete mode 100644 recipes-devtools/clang/clang/0008-clang-Fix-ldso-for-musl-on-x86-and-x32-architectures.patch create mode 100644 recipes-devtools/clang/clang/0008-llvm-Enhance-path-prefix-mapping.patch create mode 100644 recipes-devtools/clang/clang/0009-clang-Enable-SSP-and-PIE-by-default.patch delete mode 100644 recipes-devtools/clang/clang/0009-clang-scan-view-needs-python-2.x.patch delete mode 100644 recipes-devtools/clang/clang/0010-clang-Append-libunwind-to-compiler-rt-for-linking.patch create mode 100644 recipes-devtools/clang/clang/0010-clang-driver-Use-lib-for-ldso-on-OE.patch create mode 100644 recipes-devtools/clang/clang/0011-clang-Driver-tools.cpp-Add-lssp_nonshared-on-musl.patch delete mode 100644 recipes-devtools/clang/clang/0011-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch create mode 100644 recipes-devtools/clang/clang/0012-clang-musl-ppc-does-not-support-128-bit-long-double.patch delete mode 100644 recipes-devtools/clang/clang/0012-llvm-allow-env-override-of-exe-path.patch create mode 100644 recipes-devtools/clang/clang/0013-clang-Prepend-trailing-to-sysroot.patch delete mode 100644 recipes-devtools/clang/clang/0013-llvm-AARCH64-Add-support-for-.dword-directives.patch create mode 100644 recipes-devtools/clang/clang/0014-clang-Look-inside-the-target-sysroot-for-compiler-ru.patch delete mode 100644 recipes-devtools/clang/clang/0014-lldb-Add-lxml2-to-linker-cmdline-of-xml-is-found.patch create mode 100644 recipes-devtools/clang/clang/0015-clang-Define-releative-gcc-installation-dir.patch delete mode 100644 recipes-devtools/clang/clang/0015-libcxxabi-Find-libunwind-headers-when-LIBCXXABI_LIBU.patch create mode 100644 recipes-devtools/clang/clang/0016-clang-Fix-ldso-for-musl-on-x86-and-x32-architectures.patch delete mode 100644 recipes-devtools/clang/clang/0016-compiler-rt-support-a-new-embedded-linux-target.patch create mode 100644 recipes-devtools/clang/clang/0017-clang-scan-view-needs-python-2.x.patch delete mode 100644 recipes-devtools/clang/clang/0017-compiler-rt-Simplify-cross-compilation.-Don-t-use-na.patch create mode 100644 recipes-devtools/clang/clang/0018-clang-Initial-implementation-of-fmacro-prefix-map-an.patch delete mode 100644 recipes-devtools/clang/clang/0018-compiler-rt-Disable-tsan-on-OE-glibc.patch create mode 100644 recipes-devtools/clang/clang/0019-clang-Add-lpthread-and-ldl-along-with-lunwind-for-st.patch delete mode 100644 recipes-devtools/clang/clang/0019-llvm-Enhance-path-prefix-mapping.patch delete mode 100644 recipes-devtools/clang/clang/0020-clang-Initial-implementation-of-fmacro-prefix-map-an.patch create mode 100644 recipes-devtools/clang/clang/0020-clang-default-to-lp64d-ABI-and-rv64gc-ISA.patch diff --git a/recipes-devtools/clang/clang-cross-canadian_git.bb b/recipes-devtools/clang/clang-cross-canadian_git.bb index e93e8a4..b16dbe1 100644 --- a/recipes-devtools/clang/clang-cross-canadian_git.bb +++ b/recipes-devtools/clang/clang-cross-canadian_git.bb @@ -3,8 +3,7 @@ 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" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0-with-LLVM-exception;md5=0bcd48c3bdfef0c9d9fd17726e4b7dab" SECTION = "devel" PN = "clang-cross-canadian-${TRANSLATED_TARGET_ARCH}" diff --git a/recipes-devtools/clang/clang-cross_git.bb b/recipes-devtools/clang/clang-cross_git.bb index ffe144a..fd8ece5 100644 --- a/recipes-devtools/clang/clang-cross_git.bb +++ b/recipes-devtools/clang/clang-cross_git.bb @@ -3,8 +3,7 @@ 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" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0-with-LLVM-exception;md5=0bcd48c3bdfef0c9d9fd17726e4b7dab" SECTION = "devel" PN = "clang-cross-${TARGET_ARCH}" diff --git a/recipes-devtools/clang/clang-crosssdk_git.bb b/recipes-devtools/clang/clang-crosssdk_git.bb index 8f07a83..eaea765 100644 --- a/recipes-devtools/clang/clang-crosssdk_git.bb +++ b/recipes-devtools/clang/clang-crosssdk_git.bb @@ -3,8 +3,7 @@ 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" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0-with-LLVM-exception;md5=0bcd48c3bdfef0c9d9fd17726e4b7dab" SECTION = "devel" PN = "clang-crosssdk-${TARGET_ARCH}" diff --git a/recipes-devtools/clang/clang.inc b/recipes-devtools/clang/clang.inc index 3a0e01a..60e74d5 100644 --- a/recipes-devtools/clang/clang.inc +++ b/recipes-devtools/clang/clang.inc @@ -4,18 +4,18 @@ LLVM_DIR = "llvm${LLVM_RELEASE}" LLVM_GIT ?= "git://github.com/llvm" LLVM_GIT_PROTOCOL ?= "https" -MAJOR_VER = "8" +MAJOR_VER = "9" MINOR_VER = "0" -PATCH_VER = "1" +PATCH_VER = "0" -SRCREV ?= "19a71f6bdf2dddb10764939e7f0ec2b98dba76c9" +SRCREV ?= "4b59015880aa4db564f6aaa9c11cade58adb9f4e" PV = "${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}" BRANCH = "release/${MAJOR_VER}.x" -LLVMMD5SUM = "c6b766a4e85dd28301eeed54a6684648" -CLANGMD5SUM = "9a0fe3a7846ba0ffc822a70d6f7f6903" -LLDMD5SUM = "f4941ace8ddb3d6cf177fff94966319a" -LLDBMD5SUM = "b6320ed0b0d00ae661dd94f277bbf024" +LLVMMD5SUM = "8a15a0759ef07f2682d2ba4b893c9afe" +CLANGMD5SUM = "ff42885ed2ab98f1ecb8c1fc41205343" +LLDMD5SUM = "ae7dc7c027b1fa89b5b013d391d3ee2b" +LLDBMD5SUM = "2e0d44968471fcde980034dbb826bea9" require common.inc diff --git a/recipes-devtools/clang/clang/0001-clang-Enable-SSP-and-PIE-by-default.patch b/recipes-devtools/clang/clang/0001-clang-Enable-SSP-and-PIE-by-default.patch deleted file mode 100644 index 12fb8c5..0000000 --- a/recipes-devtools/clang/clang/0001-clang-Enable-SSP-and-PIE-by-default.patch +++ /dev/null @@ -1,63 +0,0 @@ -From c43bf91bc4f9c913b572f546190ce89a758ee288 Mon Sep 17 00:00:00 2001 -From: Evangelos Foutras -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/recipes-devtools/clang/clang/0001-lldb-Add-lxml2-to-linker-cmdline-of-xml-is-found.patch b/recipes-devtools/clang/clang/0001-lldb-Add-lxml2-to-linker-cmdline-of-xml-is-found.patch new file mode 100644 index 0000000..79ad13f --- /dev/null +++ b/recipes-devtools/clang/clang/0001-lldb-Add-lxml2-to-linker-cmdline-of-xml-is-found.patch @@ -0,0 +1,40 @@ +From 79ec5a3eca699011c6f95de36ce027dbfdad0aff Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Mon, 22 May 2017 17:36:16 -0700 +Subject: [PATCH 01/20] 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 +--- + 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 4bb8d363b57..3b58c36c641 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.22.0 + diff --git a/recipes-devtools/clang/clang/0002-clang-driver-Use-lib-for-ldso-on-OE.patch b/recipes-devtools/clang/clang/0002-clang-driver-Use-lib-for-ldso-on-OE.patch deleted file mode 100644 index 3b92897..0000000 --- a/recipes-devtools/clang/clang/0002-clang-driver-Use-lib-for-ldso-on-OE.patch +++ /dev/null @@ -1,63 +0,0 @@ -From b9831e3886b22d243eeb01f0ae67e9485aafd64b Mon Sep 17 00:00:00 2001 -From: Khem Raj -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 ---- - 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/recipes-devtools/clang/clang/0002-libcxxabi-Find-libunwind-headers-when-LIBCXXABI_LIBU.patch b/recipes-devtools/clang/clang/0002-libcxxabi-Find-libunwind-headers-when-LIBCXXABI_LIBU.patch new file mode 100644 index 0000000..bdd148e --- /dev/null +++ b/recipes-devtools/clang/clang/0002-libcxxabi-Find-libunwind-headers-when-LIBCXXABI_LIBU.patch @@ -0,0 +1,67 @@ +From 112e33992bbe21dceb1d14978585bd9d083648ec Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Sun, 27 Aug 2017 10:37:49 -0700 +Subject: [PATCH 02/20] 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 +--- + libcxxabi/CMakeLists.txt | 21 +++++++++++---------- + 1 file changed, 11 insertions(+), 10 deletions(-) + +diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt +index ce69fff1370..47e09e34fc2 100644 +--- a/libcxxabi/CMakeLists.txt ++++ b/libcxxabi/CMakeLists.txt +@@ -455,14 +455,9 @@ 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 libunwind.h ++ find_path(LIBCXXABI_LIBUNWIND_INCLUDES libunwind.h + PATHS ${LIBCXXABI_LIBUNWIND_INCLUDES} + ${LIBCXXABI_LIBUNWIND_PATH}/include + ${CMAKE_BINARY_DIR}/${LIBCXXABI_LIBUNWIND_INCLUDES} +@@ -473,15 +468,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.22.0 + diff --git a/recipes-devtools/clang/clang/0003-clang-Driver-tools.cpp-Add-lssp_nonshared-on-musl.patch b/recipes-devtools/clang/clang/0003-clang-Driver-tools.cpp-Add-lssp_nonshared-on-musl.patch deleted file mode 100644 index 191e21d..0000000 --- a/recipes-devtools/clang/clang/0003-clang-Driver-tools.cpp-Add-lssp_nonshared-on-musl.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 74e2a7f0f28e64f496fc33c38428c81dfc15b783 Mon Sep 17 00:00:00 2001 -From: Khem Raj -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 ---- - 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/recipes-devtools/clang/clang/0003-compiler-rt-support-a-new-embedded-linux-target.patch b/recipes-devtools/clang/clang/0003-compiler-rt-support-a-new-embedded-linux-target.patch new file mode 100644 index 0000000..4a6a915 --- /dev/null +++ b/recipes-devtools/clang/clang/0003-compiler-rt-support-a-new-embedded-linux-target.patch @@ -0,0 +1,325 @@ +From fb4985d596e3f1d74de0b62074b121f8a368c88d Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Sun, 19 Apr 2015 15:16:23 -0700 +Subject: [PATCH 03/20] compiler-rt: support a new embedded linux target + +Signed-off-by: Khem Raj +--- + compiler-rt/lib/builtins/int_util.c | 2 +- + .../make/platform/clang_linux_embedded.mk | 286 ++++++++++++++++++ + .../clang_linux_embedded_test_input.c | 0 + 3 files changed, 287 insertions(+), 1 deletion(-) + 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 226a6e93440..efc977acbb3 100644 +--- a/compiler-rt/lib/builtins/int_util.c ++++ b/compiler-rt/lib/builtins/int_util.c +@@ -54,7 +54,7 @@ void __compilerrt_abort_impl(const char *file, int line, const char *function) { + #else + + // Get the system definition of abort() +-#include ++extern void abort (void) __attribute__ ((__noreturn__)); + + #ifndef _WIN32 + __attribute__((weak)) +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.22.0 + diff --git a/recipes-devtools/clang/clang/0004-clang-musl-ppc-does-not-support-128-bit-long-double.patch b/recipes-devtools/clang/clang/0004-clang-musl-ppc-does-not-support-128-bit-long-double.patch deleted file mode 100644 index 3d257f2..0000000 --- a/recipes-devtools/clang/clang/0004-clang-musl-ppc-does-not-support-128-bit-long-double.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 5a58280d449830a216da015b4a67cbe49b1fd516 Mon Sep 17 00:00:00 2001 -From: Khem Raj -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 ---- - 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/recipes-devtools/clang/clang/0004-compiler-rt-Simplify-cross-compilation.-Don-t-use-na.patch b/recipes-devtools/clang/clang/0004-compiler-rt-Simplify-cross-compilation.-Don-t-use-na.patch new file mode 100644 index 0000000..0de7b14 --- /dev/null +++ b/recipes-devtools/clang/clang/0004-compiler-rt-Simplify-cross-compilation.-Don-t-use-na.patch @@ -0,0 +1,46 @@ +From cf524dbb79dd6cd5ad2daf41683c7ecadd32009d Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Thu, 19 May 2016 23:11:45 -0700 +Subject: [PATCH 04/20] 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 +Signed-off-by: Khem Raj +--- + 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 ae4ed3857db..dbc10652c28 100644 +--- a/compiler-rt/CMakeLists.txt ++++ b/compiler-rt/CMakeLists.txt +@@ -72,7 +72,16 @@ set(COMPILER_RT_BAREMETAL_BUILD OFF CACHE BOOL + "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.22.0 + diff --git a/recipes-devtools/clang/clang/0005-clang-Prepend-trailing-to-sysroot.patch b/recipes-devtools/clang/clang/0005-clang-Prepend-trailing-to-sysroot.patch deleted file mode 100644 index 1c6e16e..0000000 --- a/recipes-devtools/clang/clang/0005-clang-Prepend-trailing-to-sysroot.patch +++ /dev/null @@ -1,41 +0,0 @@ -From cb8ba6da2df40db219bf343e4f2da93089df300b Mon Sep 17 00:00:00 2001 -From: Khem Raj -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 ---- - 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/recipes-devtools/clang/clang/0005-compiler-rt-Disable-tsan-on-OE-glibc.patch b/recipes-devtools/clang/clang/0005-compiler-rt-Disable-tsan-on-OE-glibc.patch new file mode 100644 index 0000000..137c309 --- /dev/null +++ b/recipes-devtools/clang/clang/0005-compiler-rt-Disable-tsan-on-OE-glibc.patch @@ -0,0 +1,43 @@ +From 28443a32a50da7631e24e9892f3ab420d1fb4a01 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Mon, 18 Jul 2016 08:05:02 +0000 +Subject: [PATCH 05/20] 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 +--- + compiler-rt/cmake/config-ix.cmake | 2 +- + compiler-rt/test/sanitizer_common/CMakeLists.txt | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake +index 3cc4c22304e..9da891b62e9 100644 +--- a/compiler-rt/cmake/config-ix.cmake ++++ b/compiler-rt/cmake/config-ix.cmake +@@ -619,7 +619,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 48fccf05855..b4a7f0adf14 100644 +--- a/compiler-rt/test/sanitizer_common/CMakeLists.txt ++++ b/compiler-rt/test/sanitizer_common/CMakeLists.txt +@@ -6,7 +6,7 @@ set(SANITIZER_COMMON_TESTSUITES) + # FIXME(dliew): We should switch to COMPILER_RT_SANITIZERS_TO_BUILD instead of + # the hard coded `SUPPORTED_TOOLS_INIT` list once we know that the other + # sanitizers work. +-set(SUPPORTED_TOOLS_INIT asan lsan msan tsan ubsan) ++set(SUPPORTED_TOOLS_INIT asan lsan msan ubsan) + set(SUPPORTED_TOOLS) + foreach(SANITIZER_TOOL ${SUPPORTED_TOOLS_INIT}) + string(TOUPPER ${SANITIZER_TOOL} SANITIZER_TOOL_UPPER) +-- +2.22.0 + diff --git a/recipes-devtools/clang/clang/0006-clang-Look-inside-the-target-sysroot-for-compiler-ru.patch b/recipes-devtools/clang/clang/0006-clang-Look-inside-the-target-sysroot-for-compiler-ru.patch deleted file mode 100644 index 9535829..0000000 --- a/recipes-devtools/clang/clang/0006-clang-Look-inside-the-target-sysroot-for-compiler-ru.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 3d38148e5ae42e06d4c4f6f29c194c3406402868 Mon Sep 17 00:00:00 2001 -From: Khem Raj -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 ---- - 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/recipes-devtools/clang/clang/0006-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch b/recipes-devtools/clang/clang/0006-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch new file mode 100644 index 0000000..1d23d71 --- /dev/null +++ b/recipes-devtools/clang/clang/0006-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch @@ -0,0 +1,91 @@ +From 45151eede54f84bb1f2c5afae7cfd56eccf8e32b Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Sat, 21 May 2016 00:33:20 +0000 +Subject: [PATCH 06/20] 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 +--- + .../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 afed404f04c..876888656f2 100644 +--- a/llvm/include/llvm/Analysis/TargetLibraryInfo.def ++++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.def +@@ -782,6 +782,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(); +@@ -829,6 +832,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") +@@ -839,6 +845,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); +@@ -854,6 +863,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); +@@ -980,6 +992,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); +@@ -1205,6 +1220,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); +@@ -1340,6 +1358,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.22.0 + diff --git a/recipes-devtools/clang/clang/0007-clang-Define-releative-gcc-installation-dir.patch b/recipes-devtools/clang/clang/0007-clang-Define-releative-gcc-installation-dir.patch deleted file mode 100644 index ab035ce..0000000 --- a/recipes-devtools/clang/clang/0007-clang-Define-releative-gcc-installation-dir.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 2d544dc208202f2017fb897cf956a6e85f8c1597 Mon Sep 17 00:00:00 2001 -From: Khem Raj -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 ---- - 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 - // /usr/lib//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/recipes-devtools/clang/clang/0007-llvm-allow-env-override-of-exe-path.patch b/recipes-devtools/clang/clang/0007-llvm-allow-env-override-of-exe-path.patch new file mode 100644 index 0000000..162d4e1 --- /dev/null +++ b/recipes-devtools/clang/clang/0007-llvm-allow-env-override-of-exe-path.patch @@ -0,0 +1,37 @@ +From eb2aeff635789738b25907388ea1ef8ea3e12641 Mon Sep 17 00:00:00 2001 +From: Martin Kelly +Date: Fri, 19 May 2017 00:22:57 -0700 +Subject: [PATCH 07/20] 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 +Signed-off-by: Khem Raj +--- + 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 7ef7c46a262..a4f7ed82c7b 100644 +--- a/llvm/tools/llvm-config/llvm-config.cpp ++++ b/llvm/tools/llvm-config/llvm-config.cpp +@@ -225,6 +225,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.22.0 + diff --git a/recipes-devtools/clang/clang/0008-clang-Fix-ldso-for-musl-on-x86-and-x32-architectures.patch b/recipes-devtools/clang/clang/0008-clang-Fix-ldso-for-musl-on-x86-and-x32-architectures.patch deleted file mode 100644 index ca7de9f..0000000 --- a/recipes-devtools/clang/clang/0008-clang-Fix-ldso-for-musl-on-x86-and-x32-architectures.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 977b058e4921ff7908bbf972ea61d4ca34ea8b11 Mon Sep 17 00:00:00 2001 -From: Khem Raj -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 ---- - 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/recipes-devtools/clang/clang/0008-llvm-Enhance-path-prefix-mapping.patch b/recipes-devtools/clang/clang/0008-llvm-Enhance-path-prefix-mapping.patch new file mode 100644 index 0000000..c491bb6 --- /dev/null +++ b/recipes-devtools/clang/clang/0008-llvm-Enhance-path-prefix-mapping.patch @@ -0,0 +1,175 @@ +From 262518322d0397ba7fd3876a8710dd453e7d4c59 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Fri, 15 Feb 2019 11:32:09 -0800 +Subject: [PATCH 08/20] llvm: Enhance path prefix mapping + +Upstream-Status: Submitted [https://reviews.llvm.org/D56769] +Signed-off-by: Khem Raj +--- + 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 &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, , /new => /new/foo +-/// /old/foo, /old, => /foo ++/// /foo, , new => new/foo ++/// /old/foo, /old, , false => /foo ++/// /old/foo, /old, , 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 &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 &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 &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 c49260125db..89a1c193d14 100644 +--- a/llvm/lib/Support/Path.cpp ++++ b/llvm/lib/Support/Path.cpp +@@ -496,27 +496,53 @@ void replace_extension(SmallVectorImpl &path, const Twine &extension, + path.append(ext.begin(), ext.end()); + } + +-void replace_path_prefix(SmallVectorImpl &Path, ++bool replace_path_prefix(SmallVectorImpl &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 &result, Style style) { +diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp +index ccd72d7f176..13af998d8f8 100644 +--- a/llvm/unittests/Support/Path.cpp ++++ b/llvm/unittests/Support/Path.cpp +@@ -1219,7 +1219,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(""); +@@ -1239,6 +1241,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.22.0 + diff --git a/recipes-devtools/clang/clang/0009-clang-Enable-SSP-and-PIE-by-default.patch b/recipes-devtools/clang/clang/0009-clang-Enable-SSP-and-PIE-by-default.patch new file mode 100644 index 0000000..5700fa0 --- /dev/null +++ b/recipes-devtools/clang/clang/0009-clang-Enable-SSP-and-PIE-by-default.patch @@ -0,0 +1,63 @@ +From 6ad9263f3bc8ebbf27467f97233e109dfd7987ed Mon Sep 17 00:00:00 2001 +From: Evangelos Foutras +Date: Thu, 20 Sep 2018 06:20:28 +0300 +Subject: [PATCH 09/20] 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 d900508ad93..3e68d50dac2 100644 +--- a/clang/lib/Driver/ToolChains/Linux.cpp ++++ b/clang/lib/Driver/ToolChains/Linux.cpp +@@ -972,8 +972,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::isNoExecStackDefault() const { +diff --git a/clang/lib/Driver/ToolChains/Linux.h b/clang/lib/Driver/ToolChains/Linux.h +index 4c61994691c..66134a3a327 100644 +--- a/clang/lib/Driver/ToolChains/Linux.h ++++ b/clang/lib/Driver/ToolChains/Linux.h +@@ -39,6 +39,7 @@ public: + CXXStdlibType GetDefaultCXXStdlibType() const override; + bool isPIEDefault() const override; + bool isNoExecStackDefault() const override; ++ unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override; + bool IsMathErrnoDefault() const override; + SanitizerMask getSupportedSanitizers() const override; + void addProfileRTLibs(const llvm::opt::ArgList &Args, +-- +2.22.0 + diff --git a/recipes-devtools/clang/clang/0009-clang-scan-view-needs-python-2.x.patch b/recipes-devtools/clang/clang/0009-clang-scan-view-needs-python-2.x.patch deleted file mode 100644 index b6804b4..0000000 --- a/recipes-devtools/clang/clang/0009-clang-scan-view-needs-python-2.x.patch +++ /dev/null @@ -1,27 +0,0 @@ -From afa19d2337434c874bb9328d2f955fa33ad1aa65 Mon Sep 17 00:00:00 2001 -From: Khem Raj -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 ---- - 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/recipes-devtools/clang/clang/0010-clang-Append-libunwind-to-compiler-rt-for-linking.patch b/recipes-devtools/clang/clang/0010-clang-Append-libunwind-to-compiler-rt-for-linking.patch deleted file mode 100644 index 0ca7335..0000000 --- a/recipes-devtools/clang/clang/0010-clang-Append-libunwind-to-compiler-rt-for-linking.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 6c98b7b1df55972f26da3ceceaf87b050e3f05b9 Mon Sep 17 00:00:00 2001 -From: Khem Raj -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 ---- - 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/recipes-devtools/clang/clang/0010-clang-driver-Use-lib-for-ldso-on-OE.patch b/recipes-devtools/clang/clang/0010-clang-driver-Use-lib-for-ldso-on-OE.patch new file mode 100644 index 0000000..6d94df2 --- /dev/null +++ b/recipes-devtools/clang/clang/0010-clang-driver-Use-lib-for-ldso-on-OE.patch @@ -0,0 +1,63 @@ +From 07f5fef22be3800e37c5f635781805fcd60ae00a Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Sat, 21 May 2016 21:52:36 -0700 +Subject: [PATCH 10/20] 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 +--- + 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 3e68d50dac2..dbe5ed7d89e 100644 +--- a/clang/lib/Driver/ToolChains/Linux.cpp ++++ b/clang/lib/Driver/ToolChains/Linux.cpp +@@ -593,12 +593,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; +@@ -620,7 +620,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: +@@ -633,8 +633,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.22.0 + diff --git a/recipes-devtools/clang/clang/0011-clang-Driver-tools.cpp-Add-lssp_nonshared-on-musl.patch b/recipes-devtools/clang/clang/0011-clang-Driver-tools.cpp-Add-lssp_nonshared-on-musl.patch new file mode 100644 index 0000000..a013a36 --- /dev/null +++ b/recipes-devtools/clang/clang/0011-clang-Driver-tools.cpp-Add-lssp_nonshared-on-musl.patch @@ -0,0 +1,34 @@ +From 314859edd5f1a221d4a2c6b787e5bddd9b1c4606 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Thu, 19 May 2016 21:11:06 -0700 +Subject: [PATCH 11/20] 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 +--- + 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 33cdd3585c2..8b14b8ea9cb 100644 +--- a/clang/lib/Driver/ToolChains/Gnu.cpp ++++ b/clang/lib/Driver/ToolChains/Gnu.cpp +@@ -579,6 +579,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 (IsStatic || IsStaticPIE) + CmdArgs.push_back("--end-group"); + else +-- +2.22.0 + diff --git a/recipes-devtools/clang/clang/0011-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch b/recipes-devtools/clang/clang/0011-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch deleted file mode 100644 index 643031d..0000000 --- a/recipes-devtools/clang/clang/0011-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch +++ /dev/null @@ -1,91 +0,0 @@ -From 2a5fbe70a26e6898d970d0f88355cf92e723c00b Mon Sep 17 00:00:00 2001 -From: Khem Raj -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 ---- - .../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/recipes-devtools/clang/clang/0012-clang-musl-ppc-does-not-support-128-bit-long-double.patch b/recipes-devtools/clang/clang/0012-clang-musl-ppc-does-not-support-128-bit-long-double.patch new file mode 100644 index 0000000..fe5206f --- /dev/null +++ b/recipes-devtools/clang/clang/0012-clang-musl-ppc-does-not-support-128-bit-long-double.patch @@ -0,0 +1,28 @@ +From ed78a6b28aa36afbfc7825dcbbacea46d4ea528d Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Tue, 10 May 2016 02:00:11 -0700 +Subject: [PATCH 12/20] clang: musl/ppc does not support 128-bit long double + +Signed-off-by: Khem Raj +--- + 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 6e5df097921..107cef297e2 100644 +--- a/clang/lib/Basic/Targets/PPC.h ++++ b/clang/lib/Basic/Targets/PPC.h +@@ -354,6 +354,10 @@ public: + LongDoubleFormat = &llvm::APFloat::IEEEdouble(); + } + ++ if (getTriple().isMusl()) { ++ LongDoubleWidth = LongDoubleAlign = 64; ++ LongDoubleFormat = &llvm::APFloat::IEEEdouble(); ++ } + // PPC32 supports atomics up to 4 bytes. + MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32; + } +-- +2.22.0 + diff --git a/recipes-devtools/clang/clang/0012-llvm-allow-env-override-of-exe-path.patch b/recipes-devtools/clang/clang/0012-llvm-allow-env-override-of-exe-path.patch deleted file mode 100644 index 5d0fcff..0000000 --- a/recipes-devtools/clang/clang/0012-llvm-allow-env-override-of-exe-path.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 7111770e8290082530d920e120995bf81431b0aa Mon Sep 17 00:00:00 2001 -From: Martin Kelly -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 -Signed-off-by: Khem Raj ---- - 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/recipes-devtools/clang/clang/0013-clang-Prepend-trailing-to-sysroot.patch b/recipes-devtools/clang/clang/0013-clang-Prepend-trailing-to-sysroot.patch new file mode 100644 index 0000000..b8a23c9 --- /dev/null +++ b/recipes-devtools/clang/clang/0013-clang-Prepend-trailing-to-sysroot.patch @@ -0,0 +1,41 @@ +From c37bf49c9734a1ebc9a286225aa2ceae06427c06 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Thu, 16 Mar 2017 09:02:13 -0700 +Subject: [PATCH 13/20] 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 +--- + 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 dbe5ed7d89e..9bf66207ac9 100644 +--- a/clang/lib/Driver/ToolChains/Linux.cpp ++++ b/clang/lib/Driver/ToolChains/Linux.cpp +@@ -223,7 +223,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.22.0 + diff --git a/recipes-devtools/clang/clang/0013-llvm-AARCH64-Add-support-for-.dword-directives.patch b/recipes-devtools/clang/clang/0013-llvm-AARCH64-Add-support-for-.dword-directives.patch deleted file mode 100644 index 2ceda2e..0000000 --- a/recipes-devtools/clang/clang/0013-llvm-AARCH64-Add-support-for-.dword-directives.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 55786ec791b0aa77e3fbd1f647780a4d4a3db8f6 Mon Sep 17 00:00:00 2001 -From: Khem Raj -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 ---- - .../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/recipes-devtools/clang/clang/0014-clang-Look-inside-the-target-sysroot-for-compiler-ru.patch b/recipes-devtools/clang/clang/0014-clang-Look-inside-the-target-sysroot-for-compiler-ru.patch new file mode 100644 index 0000000..5bc6020 --- /dev/null +++ b/recipes-devtools/clang/clang/0014-clang-Look-inside-the-target-sysroot-for-compiler-ru.patch @@ -0,0 +1,44 @@ +From ec8c0bb6f7c252b7d58ee988ccb79e49bb348cfa Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Thu, 16 Mar 2017 19:06:26 -0700 +Subject: [PATCH 14/20] 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 +--- + 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 b1fddb0af55..6eb8fbb8de4 100644 +--- a/clang/lib/Driver/ToolChain.cpp ++++ b/clang/lib/Driver/ToolChain.cpp +@@ -12,6 +12,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" +@@ -352,7 +353,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.22.0 + diff --git a/recipes-devtools/clang/clang/0014-lldb-Add-lxml2-to-linker-cmdline-of-xml-is-found.patch b/recipes-devtools/clang/clang/0014-lldb-Add-lxml2-to-linker-cmdline-of-xml-is-found.patch deleted file mode 100644 index b9b67cb..0000000 --- a/recipes-devtools/clang/clang/0014-lldb-Add-lxml2-to-linker-cmdline-of-xml-is-found.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 6f7cf16d8a891d7e1cdc143dc21623175373c33b Mon Sep 17 00:00:00 2001 -From: Khem Raj -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 ---- - 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/recipes-devtools/clang/clang/0015-clang-Define-releative-gcc-installation-dir.patch b/recipes-devtools/clang/clang/0015-clang-Define-releative-gcc-installation-dir.patch new file mode 100644 index 0000000..905a8bd --- /dev/null +++ b/recipes-devtools/clang/clang/0015-clang-Define-releative-gcc-installation-dir.patch @@ -0,0 +1,32 @@ +From fb1eda44238f4f20f7b0f75cd00d1f715b96693b Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Sun, 21 May 2017 15:38:25 -0700 +Subject: [PATCH 15/20] 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 +--- + 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 8b14b8ea9cb..20517a369f7 100644 +--- a/clang/lib/Driver/ToolChains/Gnu.cpp ++++ b/clang/lib/Driver/ToolChains/Gnu.cpp +@@ -2355,6 +2355,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 + // /usr/lib//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.22.0 + diff --git a/recipes-devtools/clang/clang/0015-libcxxabi-Find-libunwind-headers-when-LIBCXXABI_LIBU.patch b/recipes-devtools/clang/clang/0015-libcxxabi-Find-libunwind-headers-when-LIBCXXABI_LIBU.patch deleted file mode 100644 index a6d9183..0000000 --- a/recipes-devtools/clang/clang/0015-libcxxabi-Find-libunwind-headers-when-LIBCXXABI_LIBU.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 74775fbe6fcee36cbc74703f824a95ef883392e2 Mon Sep 17 00:00:00 2001 -From: Khem Raj -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 ---- - 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/recipes-devtools/clang/clang/0016-clang-Fix-ldso-for-musl-on-x86-and-x32-architectures.patch b/recipes-devtools/clang/clang/0016-clang-Fix-ldso-for-musl-on-x86-and-x32-architectures.patch new file mode 100644 index 0000000..7f6e3da --- /dev/null +++ b/recipes-devtools/clang/clang/0016-clang-Fix-ldso-for-musl-on-x86-and-x32-architectures.patch @@ -0,0 +1,44 @@ +From bb1af5985b7b6e02281be669c28eb897a58c7c2f Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 16 Aug 2017 15:16:15 -0700 +Subject: [PATCH 16/20] 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 +--- + 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 9bf66207ac9..fc7d6c17484 100644 +--- a/clang/lib/Driver/ToolChains/Linux.cpp ++++ b/clang/lib/Driver/ToolChains/Linux.cpp +@@ -519,6 +519,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: +@@ -531,6 +532,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.22.0 + diff --git a/recipes-devtools/clang/clang/0016-compiler-rt-support-a-new-embedded-linux-target.patch b/recipes-devtools/clang/clang/0016-compiler-rt-support-a-new-embedded-linux-target.patch deleted file mode 100644 index 0539989..0000000 --- a/recipes-devtools/clang/clang/0016-compiler-rt-support-a-new-embedded-linux-target.patch +++ /dev/null @@ -1,326 +0,0 @@ -From 81fb306633c76d1ff8956af426173c6da811e605 Mon Sep 17 00:00:00 2001 -From: Khem Raj -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 ---- - 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 -- -+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/recipes-devtools/clang/clang/0017-clang-scan-view-needs-python-2.x.patch b/recipes-devtools/clang/clang/0017-clang-scan-view-needs-python-2.x.patch new file mode 100644 index 0000000..5c309ff --- /dev/null +++ b/recipes-devtools/clang/clang/0017-clang-scan-view-needs-python-2.x.patch @@ -0,0 +1,27 @@ +From 151f2f72b1bfd1ae7c177912c06324af1bb08d69 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Tue, 15 May 2018 10:28:43 -0700 +Subject: [PATCH 17/20] 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 +--- + 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.22.0 + diff --git a/recipes-devtools/clang/clang/0017-compiler-rt-Simplify-cross-compilation.-Don-t-use-na.patch b/recipes-devtools/clang/clang/0017-compiler-rt-Simplify-cross-compilation.-Don-t-use-na.patch deleted file mode 100644 index 65bbf62..0000000 --- a/recipes-devtools/clang/clang/0017-compiler-rt-Simplify-cross-compilation.-Don-t-use-na.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 988c7e3842fcca00faf03d735bd1a25c9e1da30f Mon Sep 17 00:00:00 2001 -From: Khem Raj -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 -Signed-off-by: Khem Raj ---- - 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/recipes-devtools/clang/clang/0018-clang-Initial-implementation-of-fmacro-prefix-map-an.patch b/recipes-devtools/clang/clang/0018-clang-Initial-implementation-of-fmacro-prefix-map-an.patch new file mode 100644 index 0000000..d58c4f5 --- /dev/null +++ b/recipes-devtools/clang/clang/0018-clang-Initial-implementation-of-fmacro-prefix-map-an.patch @@ -0,0 +1,383 @@ +From a4a34addc4d6942bb68a3c298fb07d0e4794e295 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Fri, 15 Feb 2019 10:02:52 -0800 +Subject: [PATCH 18/20] clang: Initial implementation of -fmacro-prefix-map and + -ffile-prefix-map + +Upstream-Status: Submitted [https://reviews.llvm.org/D49466] +Signed-off-by: Khem Raj +--- + .../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 | 13 ++++++- + 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, 132 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 eab453ee20e..adee339938e 100644 +--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td ++++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td +@@ -143,8 +143,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 4ea8bfff097..cf73c9ca465 100644 +--- a/clang/include/clang/Driver/Options.td ++++ b/clang/include/clang/Driver/Options.td +@@ -1866,10 +1866,16 @@ def fsplit_dwarf_inlining: Flag <["-"], "fsplit-dwarf-inlining">, 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, + Flags<[CC1Option]>; ++def ffile_prefix_map_EQ ++ : Joined<["-"], "ffile-prefix-map=">, 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, + Flags<[CC1Option,CC1AsOption]>, + HelpText<"remap file source paths in debug info">; ++def fmacro_prefix_map_EQ ++ : Joined<["-"], "fmacro-prefix-map=">, Group, Flags<[CC1Option]>, ++ HelpText<"remap file source paths in predefined preprocessor macros">; + def g_Flag : Flag<["-"], "g">, Group, + HelpText<"Generate source-level debug information">; + def gline_tables_only : Flag<["-"], "gline-tables-only">, 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 FailedModules; + ++ /// A prefix map for __FILE__ and __BASE_FILE__ ++ std::map> MacroPrefixMap; ++ + public: + PreprocessorOptions() : PrecompiledPreambleBytes(0, false) {} + +diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp +index f6ee7ee26d4..8a190558533 100644 +--- a/clang/lib/CodeGen/CGDebugInfo.cpp ++++ b/clang/lib/CodeGen/CGDebugInfo.cpp +@@ -475,10 +475,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 7edbea86633..7077d0f043c 100644 +--- a/clang/lib/CodeGen/CGDebugInfo.h ++++ b/clang/lib/CodeGen/CGDebugInfo.h +@@ -83,7 +83,7 @@ class CGDebugInfo { + /// Cache of previously constructed Types. + llvm::DenseMap TypeCache; + +- llvm::SmallDenseMap DebugPrefixMap; ++ std::map> 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 cb861f27aed..1c788d97c16 100644 +--- a/clang/lib/Driver/ToolChains/Clang.cpp ++++ b/clang/lib/Driver/ToolChains/Clang.cpp +@@ -612,16 +612,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 disabled, while the slp vectorizer is + /// enabled. +@@ -1306,6 +1320,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 3a0bab8d07f..6eea9f04620 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 20517a369f7..ebb315d9c15 100644 +--- a/clang/lib/Driver/ToolChains/Gnu.cpp ++++ b/clang/lib/Driver/ToolChains/Gnu.cpp +@@ -874,6 +874,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 bc54e38a1a6..ff68adb865d 100644 +--- a/clang/lib/Frontend/CompilerInvocation.cpp ++++ b/clang/lib/Frontend/CompilerInvocation.cpp +@@ -3180,6 +3180,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 687b9a9d3b7..9fffe35d924 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" +@@ -1436,6 +1437,15 @@ static bool isTargetEnvironment(const TargetInfo &TI, + return TI.getTriple().getEnvironment() == Env.getEnvironment(); + } + ++static void remapMacroPath( ++ SmallString<256> &Path, ++ const std::map> ++ &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) { +@@ -1502,7 +1512,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { + } + + // Escape this filename. Turn '\' -> '\\' '"' -> '\"' +- SmallString<128> FN; ++ SmallString<256> FN; + if (PLoc.isValid()) { + // __FILE_NAME__ is a Clang-specific extension that expands to the + // the last part of __FILE__. +@@ -1518,6 +1528,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { + 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.22.0 + diff --git a/recipes-devtools/clang/clang/0018-compiler-rt-Disable-tsan-on-OE-glibc.patch b/recipes-devtools/clang/clang/0018-compiler-rt-Disable-tsan-on-OE-glibc.patch deleted file mode 100644 index 6a690c7..0000000 --- a/recipes-devtools/clang/clang/0018-compiler-rt-Disable-tsan-on-OE-glibc.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 80820b9db8217eeaee5675795380d9b3b1b9c410 Mon Sep 17 00:00:00 2001 -From: Khem Raj -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 ---- - 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/recipes-devtools/clang/clang/0019-clang-Add-lpthread-and-ldl-along-with-lunwind-for-st.patch b/recipes-devtools/clang/clang/0019-clang-Add-lpthread-and-ldl-along-with-lunwind-for-st.patch new file mode 100644 index 0000000..6fa3d5a --- /dev/null +++ b/recipes-devtools/clang/clang/0019-clang-Add-lpthread-and-ldl-along-with-lunwind-for-st.patch @@ -0,0 +1,39 @@ +From 7d855716ab05ec3d7b693cf302713efad5c118fa Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 31 Jul 2019 22:51:39 -0700 +Subject: [PATCH 19/20] clang: Add -lpthread and -ldl along with -lunwind for + static linking + +When doing static liking with --unwindlib=libunwind -static we encounter +undefined symbols +libunwind/src/RWMutex.hpp:68: undefined reference to `pthread_rwlock_wrlock' + +and + +libunwind/src/AddressSpace.hpp:597: undefined reference to `dladdr' + +therefore we need to link in libpthread and libdl to fill these symbols + +Signed-off-by: Khem Raj +--- + clang/lib/Driver/ToolChains/CommonArgs.cpp | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp +index 99691cb43dc..92b3bfbd77f 100644 +--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp ++++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp +@@ -1185,6 +1185,10 @@ static void AddUnwindLibrary(const ToolChain &TC, const Driver &D, + } + case ToolChain::UNW_CompilerRT: + CmdArgs.push_back("-lunwind"); ++ if (Args.hasArg(options::OPT_static)) { ++ CmdArgs.push_back("-lpthread"); ++ CmdArgs.push_back("-ldl"); ++ } + break; + } + +-- +2.22.0 + diff --git a/recipes-devtools/clang/clang/0019-llvm-Enhance-path-prefix-mapping.patch b/recipes-devtools/clang/clang/0019-llvm-Enhance-path-prefix-mapping.patch deleted file mode 100644 index cbfc0be..0000000 --- a/recipes-devtools/clang/clang/0019-llvm-Enhance-path-prefix-mapping.patch +++ /dev/null @@ -1,175 +0,0 @@ -From 07594e15b8e9740012c3bcac00f935faf77f1c99 Mon Sep 17 00:00:00 2001 -From: Khem Raj -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 ---- - 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 &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, , /new => /new/foo --/// /old/foo, /old, => /foo -+/// /foo, , new => new/foo -+/// /old/foo, /old, , false => /foo -+/// /old/foo, /old, , 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 &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 &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 &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 &path, const Twine &extension, - path.append(ext.begin(), ext.end()); - } - --void replace_path_prefix(SmallVectorImpl &Path, -+bool replace_path_prefix(SmallVectorImpl &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 &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/recipes-devtools/clang/clang/0020-clang-Initial-implementation-of-fmacro-prefix-map-an.patch b/recipes-devtools/clang/clang/0020-clang-Initial-implementation-of-fmacro-prefix-map-an.patch deleted file mode 100644 index a8e1c9a..0000000 --- a/recipes-devtools/clang/clang/0020-clang-Initial-implementation-of-fmacro-prefix-map-an.patch +++ /dev/null @@ -1,387 +0,0 @@ -From 29a090d31273e78646cc34a392fa292e63e8e4e4 Mon Sep 17 00:00:00 2001 -From: Khem Raj -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 ---- - .../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 - 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, - Flags<[CC1Option]>; -+def ffile_prefix_map_EQ -+ : Joined<["-"], "ffile-prefix-map=">, 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, - Flags<[CC1Option,CC1AsOption]>, - HelpText<"remap file source paths in debug info">; -+def fmacro_prefix_map_EQ -+ : Joined<["-"], "fmacro-prefix-map=">, Group, Flags<[CC1Option]>, -+ HelpText<"remap file source paths in predefined preprocessor macros">; - def g_Flag : Flag<["-"], "g">, Group, - HelpText<"Generate source-level debug information">; - def gline_tables_only : Flag<["-"], "gline-tables-only">, 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 FailedModules; - -+ /// A prefix map for __FILE__ and __BASE_FILE__ -+ std::map> 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 TypeCache; - -- llvm::SmallDenseMap DebugPrefixMap; -+ std::map> 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 - #include -@@ -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> -+ &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/recipes-devtools/clang/clang/0020-clang-default-to-lp64d-ABI-and-rv64gc-ISA.patch b/recipes-devtools/clang/clang/0020-clang-default-to-lp64d-ABI-and-rv64gc-ISA.patch new file mode 100644 index 0000000..0c931ce --- /dev/null +++ b/recipes-devtools/clang/clang/0020-clang-default-to-lp64d-ABI-and-rv64gc-ISA.patch @@ -0,0 +1,52 @@ +From db66a7c23a2462e618b12e06f1920d30a49f5dce Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Mon, 12 Aug 2019 08:59:28 -0700 +Subject: [PATCH 20/20] clang: default to lp64d ABI and rv64gc ISA + +Signed-off-by: Khem Raj +--- + clang/lib/Driver/ToolChains/Arch/RISCV.cpp | 9 ++++++++- + clang/lib/Driver/ToolChains/Clang.cpp | 2 +- + 2 files changed, 9 insertions(+), 2 deletions(-) + +diff --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp +index b6768de4d29..9671ea270ef 100644 +--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp ++++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp +@@ -350,6 +350,13 @@ void riscv::getRISCVTargetFeatures(const Driver &D, const ArgList &Args, + + // Handle all other types of extensions. + getExtensionFeatures(D, Args, Features, MArch, OtherExts); ++ } else { ++ // Default to imafdc aka gc ++ Features.push_back("+m"); ++ Features.push_back("+a"); ++ Features.push_back("+f"); ++ Features.push_back("+d"); ++ Features.push_back("+c"); + } + + // -mrelax is default, unless -mno-relax is specified. +@@ -375,5 +382,5 @@ StringRef riscv::getRISCVABI(const ArgList &Args, const llvm::Triple &Triple) { + if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ)) + return A->getValue(); + +- return Triple.getArch() == llvm::Triple::riscv32 ? "ilp32" : "lp64"; ++ return Triple.getArch() == llvm::Triple::riscv32 ? "ilp32" : "lp64d"; + } +diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp +index 1c788d97c16..50839de1bf9 100644 +--- a/clang/lib/Driver/ToolChains/Clang.cpp ++++ b/clang/lib/Driver/ToolChains/Clang.cpp +@@ -1867,7 +1867,7 @@ void Clang::AddRISCVTargetArgs(const ArgList &Args, + else if (Triple.getArch() == llvm::Triple::riscv32) + ABIName = "ilp32"; + else if (Triple.getArch() == llvm::Triple::riscv64) +- ABIName = "lp64"; ++ ABIName = "lp64d"; + else + llvm_unreachable("Unexpected triple!"); + +-- +2.22.0 + diff --git a/recipes-devtools/clang/clang_git.bb b/recipes-devtools/clang/clang_git.bb index 2b4461b..75b56ce 100644 --- a/recipes-devtools/clang/clang_git.bb +++ b/recipes-devtools/clang/clang_git.bb @@ -160,6 +160,7 @@ do_compile() { do_install() { DESTDIR=${D} ninja ${PARALLEL_MAKE} ${INSTALLTARGET} + rm -rf ${D}${libdir}/python3*/site-packages/six.py } do_install_append_class-native () { diff --git a/recipes-devtools/clang/common.inc b/recipes-devtools/clang/common.inc index fec78fb..82f5bfd 100644 --- a/recipes-devtools/clang/common.inc +++ b/recipes-devtools/clang/common.inc @@ -3,31 +3,31 @@ FILESEXTRAPATHS =. "${FILE_DIRNAME}/clang:" LIC_FILES_CHKSUM = "file://llvm/LICENSE.TXT;md5=${LLVMMD5SUM} \ file://clang/LICENSE.TXT;md5=${CLANGMD5SUM} \ " -LICENSE = "NCSA" +LICENSE = "Apache-2.0-with-LLVM-exception" 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 \ + file://0001-lldb-Add-lxml2-to-linker-cmdline-of-xml-is-found.patch \ + file://0002-libcxxabi-Find-libunwind-headers-when-LIBCXXABI_LIBU.patch \ + file://0003-compiler-rt-support-a-new-embedded-linux-target.patch \ + file://0004-compiler-rt-Simplify-cross-compilation.-Don-t-use-na.patch \ + file://0005-compiler-rt-Disable-tsan-on-OE-glibc.patch \ + file://0006-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch \ + file://0007-llvm-allow-env-override-of-exe-path.patch \ + file://0008-llvm-Enhance-path-prefix-mapping.patch \ + ${@'file://0009-clang-Enable-SSP-and-PIE-by-default.patch' if '${GCCPIE}' else ''} \ + file://0010-clang-driver-Use-lib-for-ldso-on-OE.patch \ + file://0011-clang-Driver-tools.cpp-Add-lssp_nonshared-on-musl.patch \ + file://0012-clang-musl-ppc-does-not-support-128-bit-long-double.patch \ + file://0013-clang-Prepend-trailing-to-sysroot.patch \ + file://0014-clang-Look-inside-the-target-sysroot-for-compiler-ru.patch \ + file://0015-clang-Define-releative-gcc-installation-dir.patch \ + file://0016-clang-Fix-ldso-for-musl-on-x86-and-x32-architectures.patch \ + file://0017-clang-scan-view-needs-python-2.x.patch \ + file://0018-clang-Initial-implementation-of-fmacro-prefix-map-an.patch \ + file://0019-clang-Add-lpthread-and-ldl-along-with-lunwind-for-st.patch \ + file://0020-clang-default-to-lp64d-ABI-and-rv64gc-ISA.patch \ " # Fallback to no-PIE if not set diff --git a/recipes-devtools/clang/compiler-rt_git.bb b/recipes-devtools/clang/compiler-rt_git.bb index 9a15211..ff8d353 100644 --- a/recipes-devtools/clang/compiler-rt_git.bb +++ b/recipes-devtools/clang/compiler-rt_git.bb @@ -3,7 +3,6 @@ DESCRIPTION = "LLVM based C/C++ compiler Runtime" HOMEPAGE = "http://compiler-rt.llvm.org/" -LICENSE = "MIT | NCSA" SECTION = "base" require clang.inc @@ -12,8 +11,7 @@ require common-source.inc inherit cmake pkgconfig pythonnative -LIC_FILES_CHKSUM = "file://compiler-rt/LICENSE.TXT;md5=f981c4637a4cd67915ac527b3ead3a59; \ -" +LIC_FILES_CHKSUM = "file://compiler-rt/LICENSE.TXT;md5=d846d1d65baf322d4c485d6ee54e877a" BASEDEPENDS_remove_toolchain-clang_class-target = "compiler-rt libcxx" DEPENDS_append_toolchain-clang_class-target = " virtual/${TARGET_PREFIX}compilerlibs" @@ -70,6 +68,7 @@ do_install_append () { install -D -m 0644 $f ${D}${libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/`basename $f` rm $f done + rm -rf ${D}${libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/clang_rt.crt*.o } FILES_SOLIBSDEV = "" @@ -77,7 +76,9 @@ FILES_${PN} += "${libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux ${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" +FILES_${PN}-dev += "${datadir} ${libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/*.syms \ + ${libdir}/clang/${MAJOR_VER}.${MINOR_VER}.${PATCH_VER}/lib/linux/clang_rt.crt*.o \ + " INSANE_SKIP_${PN} = "dev-so" #PROVIDES_append_class-target = "\ diff --git a/recipes-devtools/clang/libcxx_git.bb b/recipes-devtools/clang/libcxx_git.bb index aced724..c115da0 100644 --- a/recipes-devtools/clang/libcxx_git.bb +++ b/recipes-devtools/clang/libcxx_git.bb @@ -3,7 +3,6 @@ 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 @@ -25,9 +24,9 @@ PACKAGECONFIG[unwind] = "-DLIBCXXABI_USE_LLVM_UNWINDER=ON -DLIBUNWIND_ENABLE_SHA #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 \ +LIC_FILES_CHKSUM = "file://libcxx/LICENSE.TXT;md5=55d89dd7eec8d3b4204b680e27da3953 \ + file://libcxxabi/LICENSE.TXT;md5=7b9334635b542c56868400a46b272b1e \ + file://libunwind/LICENSE.TXT;md5=f66970035d12f196030658b11725e1a1 \ " THUMB_TUNE_CCARGS = "" #TUNE_CCARGS += "-nostdlib" diff --git a/recipes-devtools/clang/lldb_git.bb b/recipes-devtools/clang/lldb_git.bb index 5cfbdb7..933aa44 100644 --- a/recipes-devtools/clang/lldb_git.bb +++ b/recipes-devtools/clang/lldb_git.bb @@ -3,7 +3,6 @@ DESCRIPTION = "Next generation, high-performance debugger" HOMEPAGE = "http://lldb.llvm.org/" -LICENSE = "MIT | NCSA" SECTION = "devel" DEPENDS += "clang-native zlib libxml2 ninja-native" diff --git a/recipes-devtools/clang/llvm-common.bb b/recipes-devtools/clang/llvm-common.bb index f17f01c..893abd1 100644 --- a/recipes-devtools/clang/llvm-common.bb +++ b/recipes-devtools/clang/llvm-common.bb @@ -1,6 +1,6 @@ SUMMARY = "Helper script for OE's llvm support" -LICENSE = "MIT" -LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" +LICENSE = "Apache-2.0-with-LLVM-exception" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0-with-LLVM-exception;md5=0bcd48c3bdfef0c9d9fd17726e4b7dab" SRC_URI = "file://llvm-config" diff --git a/recipes-devtools/clang/nativesdk-clang-glue.bb b/recipes-devtools/clang/nativesdk-clang-glue.bb index add6a8b..90eec6a 100644 --- a/recipes-devtools/clang/nativesdk-clang-glue.bb +++ b/recipes-devtools/clang/nativesdk-clang-glue.bb @@ -3,8 +3,8 @@ 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" +LICENSE = "Apache-2.0-with-LLVM-exception" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/'Apache-2.0 WITH LLVM-exception';md5=0bcd48c3bdfef0c9d9fd17726e4b7dab" SECTION = "devel" inherit nativesdk diff --git a/recipes-devtools/clang/openmp_git.bb b/recipes-devtools/clang/openmp_git.bb index f219a0a..e051631 100644 --- a/recipes-devtools/clang/openmp_git.bb +++ b/recipes-devtools/clang/openmp_git.bb @@ -3,8 +3,7 @@ DESCRIPTION = "LLVM based C/C++ compiler Runtime" HOMEPAGE = "http://openmp.llvm.org/" -LICENSE = "MIT | NCSA" -SECTION = "base" +SECTION = "libs" require clang.inc require common-source.inc @@ -16,7 +15,7 @@ RPROVIDES_${PN}-dev += "libgomp-dev" TOOLCHAIN = "clang" -LIC_FILES_CHKSUM = "file://openmp/LICENSE.txt;md5=b1dcbf2c86cbf9bdc0b7cea88a543010" +LIC_FILES_CHKSUM = "file://openmp/LICENSE.txt;md5=d75288d1ce0450b28b8d58a284c09c79" inherit cmake pkgconfig perlnative -- cgit v1.2.3-54-g00ecf