clang-native: Add class to use clang as native compiler
PATCH v3 1/4 clang-native: Add class to use clang as native compiler
Some recipes demand full clang/llvm builds e.g. chromium we need to use clang as native toolchain. This class collects all needed bits to enable OE built clang to provide the clang native toolchain
Setting
TOOLCHAIN_NATIVE = "clang"
in recipe will chose clang for native toolchain
--- meta/classes/toolchain/clang-native.bbclass | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 meta/classes/toolchain/clang-native.bbclass
meta/classes/toolchain/clang-native.bbclass new file +18 -0
@@ -0,0 +1,18 @@ +BUILD_CC = "${CCACHE}${BUILD_PREFIX}clang ${BUILD_CC_ARCH}" +BUILD_CXX = "${CCACHE}${BUILD_PREFIX}clang++ ${BUILD_CC_ARCH}" +BUILD_FC = "${BUILD_PREFIX}gfortran ${BUILD_CC_ARCH}" +BUILD_CPP = "${BUILD_PREFIX}clang ${BUILD_CC_ARCH} -E" +BUILD_LD = "${BUILD_PREFIX}ld ${BUILD_LD_ARCH}" +BUILD_CCLD = "${BUILD_PREFIX}clang ${BUILD_CC_ARCH}" +BUILD_AR = "${BUILD_PREFIX}llvm-ar" +BUILD_AS = "${BUILD_PREFIX}as ${BUILD_AS_ARCH}" +BUILD_RANLIB = "${BUILD_PREFIX}llvm-ranlib -D" +BUILD_STRIP = "${BUILD_PREFIX}llvm-strip" +BUILD_OBJCOPY = "${BUILD_PREFIX}llvm-objcopy" +BUILD_OBJDUMP = "${BUILD_PREFIX}llvm-objdump" +BUILD_NM = "${BUILD_PREFIX}llvm-nm" +BUILD_READELF = "${BUILD_PREFIX}llvm-readelf" + +BASE_DEFAULT_DEPS += " clang-native libcxx-native compiler-rt-native" + +LDFLAGS += " --rtlib=libgcc --unwindlib=libgcc"
PATCH v3 2/4 base.bbclass: Deferred inherit native toolchain class
use TOOLCHAIN_NATIVE variable for selecting native compiler
Default it to PREFERRED_TOOLCHAIN_NATIVE, a recipe which wants to enforce a toolchain can do so with
for cross toolchains ( e.g. target, nativesdk )
TOOLCHAIN = "gcc"
For native
TOOLCHAIN_NATIVE = "gcc"
This helps build native recipe with clang as native compiler.
--- meta/classes-global/base.bbclass | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
meta/classes-global/base.bbclass +2 -1
@@ -30,8 +30,9 @@ PREFERRED_TOOLCHAIN:class-crosssdk = "${PREFERRED_TOOLCHAIN_SDK}" PREFERRED_TOOLCHAIN:class-nativesdk = "${PREFERRED_TOOLCHAIN_SDK}" TOOLCHAIN ??= "${PREFERRED_TOOLCHAIN}" +TOOLCHAIN_NATIVE ??= "${PREFERRED_TOOLCHAIN_NATIVE}" -inherit toolchain/gcc-native +inherit_defer toolchain/${TOOLCHAIN_NATIVE}-native inherit_defer toolchain/${TOOLCHAIN} def lsb_distro_identifier(d):
PATCH v3 3/4 Remove oe.utils.host_gcc_version utility
In reply to Khem RajThis was used for the uninative gcc 4.8 and 4.9 incompatibility w.r.t runtime ABI, none of supported distros we use today use that old gcc
Oldest we have is gcc 7.5.0 on opensuse 15.5 hosts
--- meta/classes-global/uninative.bbclass | 2 +- meta/classes-recipe/populate_sdk_base.bbclass | 1 - meta/classes-recipe/populate_sdk_ext.bbclass | 3 +- meta/files/toolchain-shar-extract.sh | 8 - meta/lib/oe/utils.py | 147 +++++++++++------- 5 files changed, 90 insertions(+), 71 deletions(-)
meta/classes-global/uninative.bbclass +1 -1
@@ -142,7 +142,7 @@ def enable_uninative(d): loader = d.getVar("UNINATIVE_LOADER") if os.path.exists(loader): bb.debug(2, "Enabling uninative") - d.setVar("NATIVELSBSTRING", "universal%s" % oe.utils.host_gcc_version(d)) + d.setVar("NATIVELSBSTRING", "universal") d.appendVar("SSTATEPOSTUNPACKFUNCS", " uninative_changeinterp") d.appendVarFlag("SSTATEPOSTUNPACKFUNCS", "vardepvalueexclude", "| uninative_changeinterp") d.appendVar("BUILD_LDFLAGS", " -Wl,--allow-shlib-undefined -Wl,--dynamic-linker=${UNINATIVE_LOADER} -pthread")
meta/classes-recipe/populate_sdk_base.bbclass +0 -1
@@ -373,7 +373,6 @@ EOF -e 's#@SDK_VERSION@#${SDK_VERSION}#g' \ -e '/@SDK_PRE_INSTALL_COMMAND@/d' \ -e '/@SDK_POST_INSTALL_COMMAND@/d' \ - -e 's#@SDK_GCC_VER@#${@oe.utils.host_gcc_version(d, taskcontextonly=True)}#g' \ -e 's#@SDK_ARCHIVE_TYPE@#${SDK_ARCHIVE_TYPE}#g' \ ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.sh
meta/classes-recipe/populate_sdk_ext.bbclass +1 -2
@@ -491,8 +491,7 @@ def prepare_locked_cache(d, baseoutpath, derivative, conf_initpath): sstate_out = baseoutpath + '/sstate-cache' bb.utils.remove(sstate_out, True) - # uninative.bbclass sets NATIVELSBSTRING to 'universal%s' % oe.utils.host_gcc_version(d) - fixedlsbstring = "universal%s" % oe.utils.host_gcc_version(d) if bb.data.inherits_class('uninative', d) else "" + fixedlsbstring = "universal" if bb.data.inherits_class('uninative', d) else "" sdk_include_toolchain = (d.getVar('SDK_INCLUDE_TOOLCHAIN') == '1') sdk_ext_type = d.getVar('SDK_EXT_TYPE')
meta/files/toolchain-shar-extract.sh +0 -8
@@ -31,9 +31,6 @@ tweakpath /sbin INST_ARCH=$(uname -m | sed -e "s/i[3-6]86/ix86/" -e "s/x86[-_]64/x86_64/") SDK_ARCH=$(echo @SDK_ARCH@ | sed -e "s/i[3-6]86/ix86/" -e "s/x86[-_]64/x86_64/") -INST_GCC_VER=$(gcc --version 2>/dev/null | sed -ne 's/.* \([0-9]\+\.[0-9]\+\)\.[0-9]\+.*/\1/p') -SDK_GCC_VER='@SDK_GCC_VER@' - verlte () { [ "$1" = "`printf "$1\n$2" | sort -V | head -n1`" ] }
@@ -145,11 +142,6 @@ fi # SDK_EXTENSIBLE is exposed from the SDK_PRE_INSTALL_COMMAND above if [ "$SDK_EXTENSIBLE" = "1" ]; then DEFAULT_INSTALL_DIR="@SDKEXTPATH@" - if [ "$INST_GCC_VER" = '4.8' -a "$SDK_GCC_VER" = '4.9' ] || [ "$INST_GCC_VER" = '4.8' -a "$SDK_GCC_VER" = '' ] || \ - [ "$INST_GCC_VER" = '4.9' -a "$SDK_GCC_VER" = '' ]; then - echo "Error: Incompatible SDK installer! Your host gcc version is $INST_GCC_VER and this SDK was built by gcc higher version." - exit 1 - fi fi if [ "$target_sdk_dir" = "" ]; then
meta/lib/oe/utils.py +88 -59
429 lines not on this page · raw message
Patchtest results for [PATCH v3 3/4] Remove oe.utils.host_gcc_version utility
Thank you for your submission. Patchtest identified one or more issues with the patch. Please see the log below for more information:
---
Testing patch /home/patchtest/share/mboxes/v3-3-4-Remove-oe.utils.host_gcc_version-utility.patch
FAIL: test shortlog format: Commit shortlog (first line of commit message) should follow the format "<target>: <summary>" (test_mbox.TestMbox.test_shortlog_format)
PASS: pretest pylint (test_python_pylint.PyLint.pretest_pylint)
PASS: test Signed-off-by presence (test_mbox.TestMbox.test_signed_off_by_presence)
PASS: test author valid (test_mbox.TestMbox.test_author_valid)
PASS: test commit message presence (test_mbox.TestMbox.test_commit_message_presence)
PASS: test commit message user tags (test_mbox.TestMbox.test_commit_message_user_tags)
PASS: test max line length (test_metadata.TestMetadata.test_max_line_length)
PASS: test mbox format (test_mbox.TestMbox.test_mbox_format)
PASS: test non-AUH upgrade (test_mbox.TestMbox.test_non_auh_upgrade)
PASS: test pylint (test_python_pylint.PyLint.test_pylint)
PASS: test shortlog length (test_mbox.TestMbox.test_shortlog_length)
PASS: test target mailing list (test_mbox.TestMbox.test_target_mailing_list)
SKIP: pretest src uri left files: No modified recipes, skipping pretest (test_metadata.TestMetadata.pretest_src_uri_left_files)
SKIP: test CVE check ignore: No modified recipes or older target branch, skipping test (test_metadata.TestMetadata.test_cve_check_ignore)
SKIP: test CVE tag format: No new CVE patches introduced (test_patch.TestPatch.test_cve_tag_format)
SKIP: test Signed-off-by presence: No new CVE patches introduced (test_patch.TestPatch.test_signed_off_by_presence)
SKIP: test Upstream-Status presence: No new CVE patches introduced (test_patch.TestPatch.test_upstream_status_presence_format)
SKIP: test bugzilla entry format: No bug ID found (test_mbox.TestMbox.test_bugzilla_entry_format)
SKIP: test lic files chksum modified not mentioned: No modified recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_modified_not_mentioned)
SKIP: test lic files chksum presence: No added recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_presence)
SKIP: test license presence: No added recipes, skipping test (test_metadata.TestMetadata.test_license_presence)
SKIP: test series merge on head: Merge test is disabled for now (test_mbox.TestMbox.test_series_merge_on_head)
SKIP: test src uri left files: No modified recipes, skipping pretest (test_metadata.TestMetadata.test_src_uri_left_files)
SKIP: test summary presence: No added recipes, skipping test (test_metadata.TestMetadata.test_summary_presence)
---
Please address the issues identified and
submit a new revision of the patch, or alternatively, reply to this email with an explanation of why the patch should be accepted. If you believe these results are due to an error in patchtest, please submit a bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest' category under 'Yocto Project Subprojects'). For more information on specific failures, see: https://wiki.yoctoproject.org/wiki/Patchtest. Thank you!
PATCH v3 4/4 compiler-rt,libcxx: Use clang for native versions as well
In reply to Khem RajSet TOOLCHAIN_NATIVE for using clang
--- meta/recipes-devtools/clang/compiler-rt-sanitizers_git.bb | 1 + meta/recipes-devtools/clang/compiler-rt_git.bb | 1 + meta/recipes-devtools/clang/libcxx_git.bb | 1 + 3 files changed, 3 insertions(+)
meta/recipes-devtools/clang/compiler-rt-sanitizers_git.bb +1 -0
@@ -37,6 +37,7 @@ CFLAGS += "${COMPILER_RT}" CXXFLAGS += "${COMPILER_RT} ${LIBCPLUSPLUS}" TOOLCHAIN = "clang" +TOOLCHAIN_NATIVE = "clang" DEPENDS += "ninja-native virtual/crypt compiler-rt" DEPENDS:append:class-native = " clang-native libxcrypt-native libcxx-native"
meta/recipes-devtools/clang/compiler-rt_git.bb +1 -0
@@ -58,6 +58,7 @@ LDFLAGS += "${COMPILER_RT} ${UNWINDLIB}" CXXFLAGS += "${LIBCPLUSPLUS}" TOOLCHAIN = "clang" +TOOLCHAIN_NATIVE = "clang" def get_compiler_rt_arch(bb, d): if bb.utils.contains('TUNE_FEATURES', 'armv5 thumb dsp', True, False, d):
meta/recipes-devtools/clang/libcxx_git.bb +1 -0
@@ -55,6 +55,7 @@ LDFLAGS += "${COMPILER_RT} ${UNWINDLIB} ${LIBCPLUSPLUS}" CXXFLAGS += "${LIBCPLUSPLUS}" TOOLCHAIN = "clang" +TOOLCHAIN_NATIVE = "clang" OECMAKE_SOURCEPATH = "${S}/llvm" EXTRA_OECMAKE += "\