Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2710439pxv; Sat, 3 Jul 2021 18:34:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyauqJgnTzA2R0WdAaqpzaa/kXU1FFLyHzRlLPbXgbL5hpFr3ZYHm0iDZKzdC5zf1L/y9AI X-Received: by 2002:a17:906:4c91:: with SMTP id q17mr6242911eju.122.1625362451844; Sat, 03 Jul 2021 18:34:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625362451; cv=none; d=google.com; s=arc-20160816; b=W3FRBuSBc1i4wds/iQnp28fPQYj+AdA1xSZ32ChZAzVR/02tG99/LsPgFE3u3Y28qO 5MhGBtsXaSgR8LwVcALLlOZxQ8r/VSxa8qNwnincSZRf8yLcPmZjgCsYkcZnGas2Xv80 cZOVLUtpVcMJxKppehq75qAg27xwrXL8mZafb1Fy/yJSYazeMitTfkZiQJdVNnFypfMu H+iLgM2tRxgCRl7Ydi7hCpAoG1RsuscmqXiJpdZzzo9Z4kQmn2m5OObKDB9LP1WOqwnC lxJOVU7RacVj10Lml8JHxhTLPHbSxOaUleSg3KjIGV7vS7ZiN+jKYTgrdOND0JhgzTpc MHFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=np9lNBSWqpFW+tay+FZLu+teV0mCRq7c0OGZ5lwb2iQ=; b=LX/6lc8NC5OQoq+UQU0kCjS5kCWIpz5GIR789LkM+Au8reAdtUiIHHl89qNK1c2wkE hZmGF7Ga9JFxwJUpFn6Zn/gD00XZExxbD7irHMXBhNUTkrXOhv1V6qePuli6rtHKJfCV FecB81kTcIjef/VtcVj4UnByC+xe3Rar8yBScr3fH9toUWATR2+d5ULC8mByhVqjAkxi VnsGqYz3DolMrRPfU+UEyGJH8Eh/+v9bxBlo5TJd9S6oLyhLZnba74m45ASj20LPGHtR w8j1SVvhW0iHE58dx4ZYpZvZ8GHoJY7E3C/J9KbPhGjqf+gzFAKsuXmNyKaM+Big831c e3iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=htslqKoG; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ji16si6864328ejc.362.2021.07.03.18.33.17; Sat, 03 Jul 2021 18:34:11 -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=@kernel.org header.s=k20201202 header.b=htslqKoG; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229732AbhGDAt7 (ORCPT + 99 others); Sat, 3 Jul 2021 20:49:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:57890 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229529AbhGDAt7 (ORCPT ); Sat, 3 Jul 2021 20:49:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D4AF5615A0; Sun, 4 Jul 2021 00:47:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625359644; bh=tNmU3/BJSe1WKBQAIawduNDOsi8ptZPl+E8CPIdtgSY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=htslqKoGRK2dOOFeN/2PafvZxs3xFi8BsMEDmetFYgTBmZfI/eyxrDt+FV/8tX+W/ 1ZTHSJYJHSCV7wmoNAkqCorxrXi+7vGH9pOVI2I7+rofWgPTEVjz1jvJlh1Yv6jzv8 HRNZ47r5qERvu5kYNpd2HW0kB+xjZ+WkWmh654TpdqaNWb/EYL3sYwcytx3LJKms2U gJw4yAoMT3HeT3BmkQQp4GeRWbi7HkSZ7Eo5sUJrVPffQmg8cbYt+lwXDMC2Estjdu h2fC7K7IBvgnruYBbre5SWF5HHo/PoVsJaK3pyXTYmKpL1Jyf7SNLxWRr4sOl5/rWQ uUOvy6FNsnrqA== Date: Sat, 3 Jul 2021 17:47:21 -0700 From: Nathan Chancellor To: Nick Desaulniers Cc: Arnd Bergmann , Masahiro Yamada , Catalin Marinas , Will Deacon , Fangrui Song , Linux ARM , Linux Kernel Mailing List , clang-built-linux Subject: Re: [PATCH] arm64: drop CROSS_COMPILE for LLVM=1 LLVM_IAS=1 Message-ID: References: <20210701235505.1792711-1-ndesaulniers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Cheers, Nathan