From patchwork Fri Sep 6 09:09:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Romain Naour X-Patchwork-Id: 1158891 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.138; helo=whitealder.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="MKhSoJ8z"; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46PsG26y33z9s3Z for ; Fri, 6 Sep 2019 19:10:02 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 5F7DA86BBD; Fri, 6 Sep 2019 09:10:01 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yVT8NiCsiqlq; Fri, 6 Sep 2019 09:10:00 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 01BB386BF9; Fri, 6 Sep 2019 09:10:00 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 581BC1BF2E3 for ; Fri, 6 Sep 2019 09:09:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 5487F86BF9 for ; Fri, 6 Sep 2019 09:09:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wPOJjTwUH6VJ for ; Fri, 6 Sep 2019 09:09:55 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by whitealder.osuosl.org (Postfix) with ESMTPS id 329F486BBD for ; Fri, 6 Sep 2019 09:09:55 +0000 (UTC) Received: by mail-wr1-f44.google.com with SMTP id s18so5755229wrn.1 for ; Fri, 06 Sep 2019 02:09:55 -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=dpcJe+gECftLBvKsAKwz+ehFzakibbAaUkcgymhly0E=; b=MKhSoJ8zBYbaUMO23Y/6DUBvNr0wBoiulxZ26YcIR75p/c7dGXFG5Hos6b6kGXg5FW 5VODtSs7afSWjkF2POnxk+Ha649qSJ4jspnjArW10InascN6A9LKKZwweX8xpFRNhBgS 4N05W+glfTLJ1SOKMLt6GIoJtTrl0uyr9OB2rU/4LLwUTcOyTt0SWUXknpLWtKes2GMu 5YQHwniIvasyH8eQPR1LMsaqKafCUN7Zezsd361n+eDL8q2xwt7CXcUI21ZK4BcnHGMg 3IaA74y/hTvgByvsovQNTC367emHiJrEvQ+cJWFIu4ouQ8V2EHGYrWClSIlP97edwenu 1knA== 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=dpcJe+gECftLBvKsAKwz+ehFzakibbAaUkcgymhly0E=; b=IOi+q+Hr1a3w6g3ZRkDO9QtGsTohVF+vOZyAZYVjVavtpGRpdKrJG+2sHYVFanyoy5 nDNEdJ1e1TC7kRPeomrdQFqdTXaOE5v8c+74noq4fLiJRtYM/7xHRlXnkO0a1HmEJdFI 3iFo3Z+xCeUtEm/6xyNw/r/xd7QNUerL6vadenyA55Wcq9NpjElZ0T0hE8+614puKTvS bliJ5FOUseGL5OEyUAfRLpcsXyOpFfS1WSkBl1vMqgPDe22cJMSw+GZt+Egc4K+JTgjq 1YKRLKh+eFz9urq2OkHxWy8MD7hez0hnTbAvEM+w0jNDC4KgZ3qgtivTS3PyOm4JjjdS RyOQ== X-Gm-Message-State: APjAAAV5aw1zIbMgJgxJSRM7rWNhK8fNqhbSEl/3jpe/i/hy01UPYPpk ro631JSUtzp7d5z8Yz/84Bydlh8sM6w= X-Google-Smtp-Source: APXvYqz628Mc+iSz0xP3J8SnEY/JffnW6HeFpr+mQZntJJV0rYClwgkRVNUO4vNP1rXiWvHG2Th4mA== X-Received: by 2002:a5d:6049:: with SMTP id j9mr5602916wrt.213.1567760993157; Fri, 06 Sep 2019 02:09:53 -0700 (PDT) Received: from P-ASN-Evian.nantes.intranet (static-css-ccs-204145.business.bouyguestelecom.com. [176.157.204.145]) by smtp.gmail.com with ESMTPSA id u6sm4582924wrr.26.2019.09.06.02.09.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2019 02:09:52 -0700 (PDT) From: Romain Naour To: buildroot@buildroot.org Date: Fri, 6 Sep 2019 11:09:36 +0200 Message-Id: <20190906090947.5476-1-romain.naour@smile.fr> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [Buildroot] [PATCH 00/11] 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 Romain Naour (11): 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 package/busybox: fix applets runtime issue when building with clang cross-compiler package/clang: add a host entry for clang 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 | 20 ++ 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 | 49 ++++- package/llvm/llvm.mk | 3 +- package/meson/cross-compilation.conf.in | 4 +- package/meson/meson.mk | 3 +- package/pkg-meson.mk | 3 +- toolchain/Config.in | 6 + .../toolchain-buildroot.mk | 7 + .../toolchain-external/toolchain-external.mk | 7 + 15 files changed, 378 insertions(+), 10 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