From patchwork Sat Sep 7 09:40:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Romain Naour X-Patchwork-Id: 1159305 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) 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=none (p=none dis=none) header.from=smile.fr Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=smile-fr.20150623.gappssmtp.com header.i=@smile-fr.20150623.gappssmtp.com header.b="OcLpsD/H"; 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 46QTv65LcZz9sP6 for ; Sat, 7 Sep 2019 19:40:50 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 99CF72050D; Sat, 7 Sep 2019 09:40:46 +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 0NFxSe4TgXyF; Sat, 7 Sep 2019 09:40:43 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 02A6520398; Sat, 7 Sep 2019 09:40:43 +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 E3FFC1BF401 for ; Sat, 7 Sep 2019 09:40:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id E134B20398 for ; Sat, 7 Sep 2019 09:40:37 +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 ScqBVI-OiCso for ; Sat, 7 Sep 2019 09:40:35 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by silver.osuosl.org (Postfix) with ESMTPS id F1CAA20397 for ; Sat, 7 Sep 2019 09:40:34 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id t17so8799818wmi.2 for ; Sat, 07 Sep 2019 02:40:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile-fr.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IEioEvFBI9A5YElusbYbuPVuuG0al5SpWEpmI1AF36I=; b=OcLpsD/HRAMcOD8x29CHnNWHleh3sXiZQmkCO6rW3PuD3Ka5wJKIopIRcCoCHwSZWR 2Jmpv1dAI9ENL91sX2peSiF214BbzMibCIDOSUElsG5hiONcAES4g9LK3b1waUKydtK+ 1oFdlQl5BErSk1M2nyux+RQqd0Emh9jqOwt49fPhtm9/h/a4Ip1xZlR2IMdVq1IZki1L DnR7QVpz6XTEP/gXoXCVWFoq/aHK5XdsdUsllSG62RZgT1zgSM+M1st91XWMbkQzciH7 HjuuKKi48ZPc+g38j80du7rVDPqouc5WA9bzagnb3oQn9FO/kdzaTl5t/w4uxS7VsrYO VSeA== 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=IEioEvFBI9A5YElusbYbuPVuuG0al5SpWEpmI1AF36I=; b=Li96XCFX1PLVVenoZ8r/b7qRx0jLUS4bwvpg3rtEeGBcb7F2mekhwtTUlT/fngongI SOkaV57dQg5zGyLf1J7snbSrr1ak7Wd3N9IzWqzfwXlRepDl+ONWpWfRYbZf4AXPw16p td4F5gJ1AZqGayM7+NFpyV0qevh4mSxJQeqDQqt0i4w2YOOfJVh7NYpa9p0q5Bst5EyI wg48nynvDdtvEpVS2mHAgON9jmWHQjANSPk4+EDvLSGlPc0LZZaxvKET8sdtxhdMKzRI tswUVr8ZRKkOcabDRLe7bQcy9PsVoz+fE7M8GVDabOp/wFA6fl2CowG2Rn4oVCn+lrs8 nBgA== X-Gm-Message-State: APjAAAXpOCjwx55tNV4O1fgumX7h78oUy/NZm+IfPYeRoSCUu0mKCYvT ZIgiSIu1qRJJBJFzvBPsSYanIyxjp/A= X-Google-Smtp-Source: APXvYqxn+fFqtwBy24nFdcGMWGymDVBF9e4/ahyPaJLUp70wyQ5ZqZeHaphBvWh4ObW27fvcE/6SQA== X-Received: by 2002:a7b:cd99:: with SMTP id y25mr1001270wmj.15.1567849233013; Sat, 07 Sep 2019 02:40:33 -0700 (PDT) Received: from P-ASN-Evian.home (2a01cb0589880c00c543929d43aec786.ipv6.abo.wanadoo.fr. [2a01:cb05:8988:c00:c543:929d:43ae:c786]) by smtp.gmail.com with ESMTPSA id f13sm6384700wrq.3.2019.09.07.02.40.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Sep 2019 02:40:31 -0700 (PDT) From: Romain Naour To: buildroot@buildroot.org Date: Sat, 7 Sep 2019 11:40:15 +0200 Message-Id: <20190907094027.9537-1-romain.naour@smile.fr> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [Buildroot] [PATCH v2 00/12] Add the support for Clang 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: Romain Naour Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Last year Valentin Korenblit added during his internship at Smile, llvm/clang packages to provide llvm/clang libraries for the target. See the article from Valentin on Linuxembedded blog [1]. But Clang could not be used as a cross-compiler by Buildroot since it was necessary to build the Linux kernel with GCC [2]. Recently, I've tried to build an aarch64 Linux kernel (5.2.7) with Clang and it worked under Qemu [3]. I also tested for x86_64 but we need the upcomming llvm/clang version 9 to build the kernel [4]. This new version add the support of "asm-goto" which was the last missing part to be able to build the Linux kernel on x86_64 [5]. But for theses tests, only the kernel was built with Clang. While testing the x86_64 kernel and it's rootfs built with Clang under Qemu, I had a runtime issue during the userspace boot process (Busybox's init). While searching about the issue, I discover the lowRISC blog from Luís Marques about the same issue and tested the patch he contributed to the Busybox project (Thanks!). So, this series is about to complete the integration of Clang as cross-compiler by using a toolchain-wrapper and fixing some build system infrastructure (cmake, meson) to use Clang instead of GCC. Add this new experimental option into "Advanced" menu since we are expecting some build and runtime issues for number of packages (bootloaders, kernel). For now, Clang cross-compiler can only be use as internal toolchain, so it is build from the source which take a long time... [1] http://www.linuxembedded.fr/2018/07/llvmclang-integration-into-buildroot [2] https://www.elinux.org/Buildroot:DeveloperDaysFOSDEM2018#LLVM.2FClang [3] http://www.linuxembedded.fr/2019/08/my-first-linux-kernel-built-with-clang-compiler [4] https://www.phoronix.com/scan.php?page=news_item&px=LLVM-9.0-RC3-Released [5] https://www.phoronix.com/scan.php?page=news_item&px=LLVM-Asm-Goto-Merged [6] https://www.lowrisc.org/blog/2019/07/large-scale-risc-v-llvm-testing-with-buildroot Best regards, Romain v2: Fix pkg-meson (missing $) and keep TARGET_CROSS in sed command for other tools (as etc). Install the GCC external toolchain before executing realpath command. Move host-clang dependency to toolchain virtual package since host-clang now depends on external-toolchain. Add Glibc toolchain dependency Use GCC to build Glibc for internal toolchain. Romain Naour (12): package/clang: help host-clang to find our external toolchain package/llvm: add the version major variable package/clang: add the version major variable package/clang: install a toolchain-wrapper for the host clang cross-compiler linux: override CC for the case CC is not GCC package/meson: use TARGET_{CC,CXX} instead of TARGET_CROSS for cc and cpp package/busybox: fix applets runtime issue when building with clang cross-compiler package/clang: add a host entry for clang package/glibc: use GCC cross-compiler if Clang is used as cross-compiler core: allow to use Clang as cross-compiler toolchain: add a warning when Clang is used as cross-compiler linux: don't set -Wno-attribute-alias flag when Clang is used as cross-compiler Config.in | 23 +++ linux/linux.mk | 4 +- package/Config.in.host | 1 + package/Makefile.in | 13 +- ...use-BB_GLOBAL_CONST-where-applicable.patch | 173 ++++++++++++++++++ ...hains-Gnu-Use-GCC_INSTALL_PREFIX-in-.patch | 76 ++++++++ package/clang/Config.in.host | 19 ++ package/clang/clang.mk | 51 +++++- package/glibc/glibc.mk | 5 + package/llvm/llvm.mk | 3 +- package/meson/cross-compilation.conf.in | 4 +- package/meson/meson.mk | 2 + package/pkg-meson.mk | 2 + toolchain/Config.in | 6 + toolchain/toolchain/toolchain.mk | 7 + 15 files changed, 381 insertions(+), 8 deletions(-) create mode 100644 package/busybox/0003-use-BB_GLOBAL_CONST-where-applicable.patch create mode 100644 package/clang/0001-lib-Driver-ToolChains-Gnu-Use-GCC_INSTALL_PREFIX-in-.patch create mode 100644 package/clang/Config.in.host