Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp5868310pxv; Wed, 7 Jul 2021 13:42:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlnDtOhB9FZ5gVDcOs8w20hCiyeXL4ZiiHgZ5rJ2zNAieinWgzf8n4Mav8kNHr0l/Ny0L9 X-Received: by 2002:a05:6638:5b0:: with SMTP id b16mr8735883jar.76.1625690548051; Wed, 07 Jul 2021 13:42:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625690548; cv=none; d=google.com; s=arc-20160816; b=TokQ/VK1l4xXq8pp/udIyLUgsPmfuDnP+kNOyJg/mHZNvrWOOk+8qSvE2ikhxGvSIB Yth2a2iO/KpQRLsDi7KsT/fReqeV8CVix2N9iQa8UJZHM617TjMe21uFOR0a0e9z+zf5 x/2FX4+EQti0kvnFazwgiT+SCp0d03UDdXSLTfNMchBnD1uxtct9I0nLpIOwHs+izQXj cPaGD8QPCpG1LvaD7OCGPyosdZlILEfkp+/Wp/IFS28S7u3roAGcdroppwQ5kLXFzOG9 zuxO1XYISsvaqoOiwn5dj9KeCBuQuoUXXy0zbap+w+fSXvY+SCOyjksteIMiRQU9XC0H R+7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=z/sINFkidd4wbdannETMgW4bElM0CKhLWIVOtap5WLM=; b=xfqEJ8SD4u9PLHiEHHnJr63jlhvi6V/6691NoygJsTsXHrKO+aVldYBT+hO1Eblme8 1vcH2WOV7N59g2Q+gvNHBJH5pxAfeSfK0bh+mCUikhgbZ5QOgq9pu+EcapwzcSPnMNm+ 7ujjn3HlmU2uocMFS9Wz1xwtltVc47zUgfx6XCb+9jQ7PX3KzGUr3/TJXsMH3eG5rTkl qrLlBj8UOi1zXY57DlEmo64xZUv/MN6eF4pIDE086DxNknlRNUW5hbRtzQoVFurG7SMb kG/YgTswKXie4ZPBRn4T+/El1UYEesbFpyv7JXliwh4S3rZL0+CRNeMV1mx9g6POBoL2 UC9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=SORU3JdY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l7si24843135iow.4.2021.07.07.13.42.14; Wed, 07 Jul 2021 13:42:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=SORU3JdY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230475AbhGGTHA (ORCPT + 99 others); Wed, 7 Jul 2021 15:07:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230004AbhGGTG7 (ORCPT ); Wed, 7 Jul 2021 15:06:59 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D07DC061574 for ; Wed, 7 Jul 2021 12:04:18 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id r26so6776094lfp.2 for ; Wed, 07 Jul 2021 12:04:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=z/sINFkidd4wbdannETMgW4bElM0CKhLWIVOtap5WLM=; b=SORU3JdYg0sCHUPztl5Sml1zZLI4bEsIExEkumwT+4AQKUur+pkRMK1BnvW1ONXbtZ 0JzEmU1KTlaFatTgJ2vPGUxRkVucKmsp/J2D4T/ZZSpSg8TH0kb6bVZpH1hdU3BCe4XC 5ojVf2YiAaP69x0d8mlP1aCaCc74oxVkaFMQgc0SAoUVhqoOG1IAeVtKYkAcU8p5JKM2 4McElwBzpbXd6Hlmcnzk5MO7+3quCv+izlM/4M4qiPG8lGW6wgnzbtYPxp/d8cRBevUv pQPxZqg524zAEYBuw+P2u1/ew3cyz89dSbil2YS3V6u0ZUBnZWw1bHWSqcbHJHdaVygb CfaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=z/sINFkidd4wbdannETMgW4bElM0CKhLWIVOtap5WLM=; b=ntUo/qqxFm/rK7NoN8gLaSL45vFfiCe3Be0/1yraL/xYKJ3agiMzTZALq09t6mDMF7 uIJIrzbpsA67OQquJ0jvYDPE2Fvbtr5VWNeUNOSb1Ec2McT0GD9OoKdbIVSqQOcgjeHX ACnDIupGVHGPEninRE+sUg0EKe5RnWVagjIMB/JQIl3ze5Hvttz2UJJl4TlV3PGrw988 DLYvNSR/qX6S7TCT7hcD+icIR469VQ2fo3dXwkcNrG7zW5jxK5G6sGtNmPQJmOHPULhQ 3VyrWCxkbVVerJ8kX1T7OFnqXcWDHKngRV/bOQKMPkTX+l+iCg0ZgV9+35xHo5RruM9M nJbA== X-Gm-Message-State: AOAM5306RroOhf2nSEooLBGkNNpP/k5a4CwyF23PLJohVkkgB8xbHBVy ZXByxUvJINSMaAAZ8G1A8K+jn8PGMvjlyL/X+THpSA== X-Received: by 2002:a2e:b5b5:: with SMTP id f21mr20457637ljn.479.1625684656197; Wed, 07 Jul 2021 12:04:16 -0700 (PDT) MIME-Version: 1.0 References: <20210701235505.1792711-1-ndesaulniers@google.com> In-Reply-To: From: Nick Desaulniers Date: Wed, 7 Jul 2021 12:04:04 -0700 Message-ID: Subject: Re: [PATCH] arm64: drop CROSS_COMPILE for LLVM=1 LLVM_IAS=1 To: Nathan Chancellor , Masahiro Yamada , Miguel Ojeda Cc: Arnd Bergmann , Catalin Marinas , Will Deacon , Fangrui Song , Linux ARM , Linux Kernel Mailing List , clang-built-linux Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 3, 2021 at 5:47 PM Nathan Chancellor wrote: > > On Fri, Jul 02, 2021 at 11:29:31AM -0700, Nick Desaulniers wrote: > > On Fri, Jul 2, 2021 at 4:59 AM Arnd Bergmann wrote: > > > > > > On Fri, Jul 2, 2021 at 1:55 AM 'Nick Desaulniers' via Clang Built > > > Linux wrote: > > > > > > > > +ifneq ($(LLVM),) > > > > +ifneq ($(LLVM_IAS),) > > > > +ifeq ($(CROSS_COMPILE),) > > > > +CLANG_TARGET :=--target=aarch64-linux > > > > +CLANG_FLAGS += $(CLANG_TARGET) > > > > +KBUILD_CFLAGS += $(CLANG_TARGET) > > > > +KBUILD_AFLAGS += $(CLANG_TARGET) > > > > +endif > > > > +endif > > > > +endif > > > > > > I think only the "CLANG_TARGET :=--target=aarch64-linux" line should > > > go into the > > > per-architecture Makefile. It doesn't hurt to just set that > > > unconditionally here, > > > and then change the CLANG_FLAGS logic in the top-level Makefile to use this > > > in place of $(notdir $(CROSS_COMPILE:%-=%)). > > > > I don't think we can do that. Based on the order the arch/ specific > > Makefiles are included, if we don't eagerly add --target to the > > KBUILD_{C|A}FLAGS, then cc-option, as-option, and as-instr macros > > (defined in scripts/Makefile.compiler) checks in per arch/ Makefiles > > may fail erroneously because --target was not set for > > KBUILD_{C|A}FLAGS yet. > > > > Another issue is the order of operations between the top level > > Makefile and the per arch/ Makefiles. The `notdir` block you > > reference occurs earlier than the per-arch includes: > > > > 609 TENTATIVE_CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) > > ... > > 648 include $(srctree)/arch/$(SRCARCH)/Makefile > > > > We would need the opposite order to do what you describe. Reordering > > these would effectively be a revert of > > commit ae6b289a3789 ("kbuild: Set KBUILD_CFLAGS before incl. arch Makefile") > > which I'm not sure we want to do. But maybe there's another way I'm > > not seeing yet? > > Is there any reason we cannot just add this sort of logic to the main > Makefile? > > Such as (indentation to emphasis diff): > > ifeq ($(CROSS_COMPILE),) > ifneq ($(LLVM),) > ifeq ($(LLVM_IAS),1) > ifeq ($(ARCH),arm64) > TENTATIVE_CLANG_FLAGS += --target=aarch64-linux > else ifeq ($(ARCH),s390) > TENTATIVE_CLANG_FLAGS += --target=s390x-linux > else ifeq ($(ARCH),x86_64) > TENTATIVE_CLANG_FLAGS += --target=x86_64-linux > else > $(error Specify CROSS_COMPILE or add '--target=' option to Makefile) > endif > endif > endif > else > TENTATIVE_CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) > ifeq ($(LLVM_IAS),1) > TENTATIVE_CLANG_FLAGS += -integrated-as > else > TENTATIVE_CLANG_FLAGS += -no-integrated-as > GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) > TENTATIVE_CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) > endif > endif > > I know this looks a little cumbersome but it does help us avoid > duplication across architecture Makefiles and ordering dependencies. Yeah, ok. I like the use of `include` to compartmentalize the top level Makefile further. We can move this whole block of LLVM related flag handling into something under scripts, then add this block and it doesn't look too bad IMO. Masahiro, are you ok with that? If so, I'd break this into 2 patches: 1. moving this block of existing code into a new file. 2. adding the CROSS_COMPILE functionality. See https://groups.google.com/g/clang-built-linux/c/s-voh6WQFxM for the gist of what I was thinking (though not broken into 2 patches yet, just testing that it works; it does). This approach will collide with Miguel's series in -next. Should I base the patches on mainline, or linux-kbuild, then have Miguel rebase his patches on that or what? -- Thanks, ~Nick Desaulniers