From patchwork Fri Oct 23 09:36:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khem Raj X-Patchwork-Id: 1386626 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=ujF3VwRL; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHfJN6fY4z9sV0 for ; Fri, 23 Oct 2020 20:36:52 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id E850C20512; Fri, 23 Oct 2020 09:36:49 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uXPFZA5C0sWT; Fri, 23 Oct 2020 09:36:48 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 88D882050C; Fri, 23 Oct 2020 09:36:48 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 87A711BF5DA for ; Fri, 23 Oct 2020 09:36:47 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 71FC42050C for ; Fri, 23 Oct 2020 09:36:47 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7DhLTRW8tbzX for ; Fri, 23 Oct 2020 09:36:45 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by silver.osuosl.org (Postfix) with ESMTPS id D65C4203C7 for ; Fri, 23 Oct 2020 09:36:45 +0000 (UTC) Received: by mail-pl1-f195.google.com with SMTP id y1so552229plp.6 for ; Fri, 23 Oct 2020 02:36:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=X8fhn/4bTLu6atzlTRSL5XsQanvH8c6PP8FZXb/RKqs=; b=ujF3VwRLWyIG9q6W1UQh193TwAMFVtnnjLWJQf5/F5LB0pgAcdiNgTHZNPmKeFyOLw ViKjCVm0VfOcpGaVwa/OBR8IftRHE6eMeM6pfl/xV9Yx40c1/9U6phUWMJJ38c4i1pTD 9twI/wxS7peQjY083W2VWpwbehwlmEv87V+mlInl1YqYpdZZm2G3GwuCThdGVpPd197e td0TgZz0R9rlEsMP03tkN1AsX5XrSGaCYtDdQsLca5u86+I0B7p1imxxQzH1Xi81oa4Y bYHpwW7MjXoGR5iKIHaAqJZhJtjg8GBD27wDS0qb9SU1O0FEsEYSHUyzf8FqTxc/Py3J szNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=X8fhn/4bTLu6atzlTRSL5XsQanvH8c6PP8FZXb/RKqs=; b=Thhle9JtVpR66W9IP1WVNyrHwBv/qT+KPSontXIzO92ugvgyPiUHNPdgiyzy2IM8ZV p4/ulrtpLaTfH+xcGsc8GBWnoO8HOG9csJHC6syKL74XEsmmDNj7PUrCxlf6zZhzVZXp QWxClm7zqehc2cYeK7Leyr1DIwzfH9YQtNJGB+ZZ6Wt8slJGfWi8usl7KSa6QcNXADGu mvp5iyyScJMalTnkof5i3DEKZyVciMxDLPMc3ZqMTp2ysQyZba/bWLTVQaOSLIghUSzC KlbGRRpHBopYGAUoxHFEHEUf3hM6oUoOZ+O+/XwXNeDmMHlxc6v7IqBd/ATvCS6lnSXc a6yA== X-Gm-Message-State: AOAM530gs3KepBxjZ3H0Rxe1BT/MweX7GxEh7rNa/hn097DG8aJe0DC4 DX2wh6GPl4tB+ROo5yAW+0CKQqQy7qVIWQ== X-Google-Smtp-Source: ABdhPJzhF41MftFcG+j6+LxRZ7ASVfIf7Xccq7cBsvXGGkBA7fAtIBlK8aGI2zf2SEhYCZz+KDBRiw== X-Received: by 2002:a17:902:a50a:b029:d4:da2d:c9a1 with SMTP id s10-20020a170902a50ab02900d4da2dc9a1mr1468247plq.6.1603445804911; Fri, 23 Oct 2020 02:36:44 -0700 (PDT) Received: from apollo.hsd1.ca.comcast.net ([2601:646:9200:4e0::3958]) by smtp.gmail.com with ESMTPSA id k3sm1330624pff.71.2020.10.23.02.36.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Oct 2020 02:36:44 -0700 (PDT) From: Khem Raj To: buildroot@buildroot.org Date: Fri, 23 Oct 2020 02:36:41 -0700 Message-Id: <20201023093641.619746-1-raj.khem@gmail.com> X-Mailer: git-send-email 2.29.0 MIME-Version: 1.0 Subject: [Buildroot] [PATCH] external-toolchain: Detect linux/version.h via cross compiler X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Khem Raj , Thomas Petazzoni Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Using linux/version.h is assumed to be hardcoded inside sysroot but this does not consider the case where toolchains might be built with --with-native-system-header-dir which means the header directories will not be under /usr/include but customized, archlinux, debian built cross toolchains use these install settings ( due to multiarch ) they have the headers installed like /usr/aarch64-linux-gnu/include and not /usr/aarch64-linux-gnu/usr/include This patch adds logic to use cross compiler to compute the path to linux/version.h on the fly, it means we do not really need to assume the install structure Fixes built when using external toolchains provided by archlinux e.g. Signed-off-by: Khem Raj Cc: Thomas Petazzoni --- support/scripts/check-kernel-headers.sh | 15 ++++++++++++++- toolchain/helpers.mk | 2 +- .../toolchain-external/pkg-toolchain-external.mk | 3 ++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/support/scripts/check-kernel-headers.sh b/support/scripts/check-kernel-headers.sh index 4e6dce5487..5cedb9a082 100755 --- a/support/scripts/check-kernel-headers.sh +++ b/support/scripts/check-kernel-headers.sh @@ -21,6 +21,9 @@ SYSROOT="${2}" HDR_VER="${3}.0.0" CHECK="${4}" # 'strict' or 'loose' +# cross compiler passed in case of external toolchains +CROSS_CC="${5}" + HDR_M="${HDR_VER%%.*}" HDR_V="${HDR_VER#*.}" HDR_m="${HDR_V%%.*}" @@ -36,11 +39,21 @@ trap 'rm -f "${EXEC}"' EXIT EXEC="$(mktemp -p "${BUILDDIR}" -t .check-headers.XXXXXX)" +if [ -n "${CROSS_CC}" ]; then + MAKE_VER_H=$(${CROSS_CC} -M -xc - <<_EOF_ +#include +_EOF_ + ) + VER_H=`echo $MAKE_VER_H | awk 'END {print $NF}'` +else + VER_H="${SYSROOT}/usr/include/linux/version.h" +fi + # We do not want to account for the patch-level, since headers are # not supposed to change for different patchlevels, so we mask it out. # This only applies to kernels >= 3.0, but those are the only one # we actually care about; we treat all 2.6.x kernels equally. -${HOSTCC} -imacros "${SYSROOT}/usr/include/linux/version.h" \ +${HOSTCC} -imacros "${VER_H}" \ -x c -o "${EXEC}" - <<_EOF_ #include #include diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk index 17bc159f3e..51d840b176 100644 --- a/toolchain/helpers.mk +++ b/toolchain/helpers.mk @@ -166,7 +166,7 @@ copy_toolchain_sysroot = \ # check_kernel_headers_version = \ if ! support/scripts/check-kernel-headers.sh $(1) $(2) $(3) \ - $(if $(BR2_TOOLCHAIN_HEADERS_LATEST),$(4),strict); \ + $(if $(BR2_TOOLCHAIN_HEADERS_LATEST),$(4),strict) $(5); \ then \ exit 1; \ fi diff --git a/toolchain/toolchain-external/pkg-toolchain-external.mk b/toolchain/toolchain-external/pkg-toolchain-external.mk index 6d91cb5d1e..93f725dada 100644 --- a/toolchain/toolchain-external/pkg-toolchain-external.mk +++ b/toolchain/toolchain-external/pkg-toolchain-external.mk @@ -549,7 +549,8 @@ define $(2)_CONFIGURE_CMDS $$(BUILD_DIR),\ $$(call toolchain_find_sysroot,$$(TOOLCHAIN_EXTERNAL_CC)),\ $$(call qstrip,$$(BR2_TOOLCHAIN_HEADERS_AT_LEAST)),\ - $$(if $$(BR2_TOOLCHAIN_EXTERNAL_CUSTOM),loose,strict)); \ + $$(if $$(BR2_TOOLCHAIN_EXTERNAL_CUSTOM),loose,strict),\ + $$(TOOLCHAIN_EXTERNAL_CC)); \ $$(call check_gcc_version,$$(TOOLCHAIN_EXTERNAL_CC),\ $$(call qstrip,$$(BR2_TOOLCHAIN_GCC_AT_LEAST))); \ if test "$$(BR2_arm)" = "y" ; then \