From patchwork Fri Feb 17 15:18:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florent Revest X-Patchwork-Id: 58659 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp951848wrn; Fri, 17 Feb 2023 07:36:09 -0800 (PST) X-Google-Smtp-Source: AK7set+a1fsc+buogvAgjZOl7ITwXeE8DbhnJdpjZJ7A86PCfhOm9j+IlgoDFC63218vab4FtbYc X-Received: by 2002:a17:906:4ecc:b0:8b0:ad1a:d021 with SMTP id i12-20020a1709064ecc00b008b0ad1ad021mr1010975ejv.39.1676648169772; Fri, 17 Feb 2023 07:36:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676648169; cv=none; d=google.com; s=arc-20160816; b=UNwmmMe8r3ct2RlcWxubHybwdsdmS3wzQAVgt5IpxN5uTwm/ykEID/jEiR4WPfNc/2 CRNcJ4ZIBJ5cMmLrn0oUwCHc4g4gLDj3WyzwbsE6pNpyAl2KxOR/7oToeaheJe04cdmR jbZzfJLW/5lOUtJ7g4VFuVqN61MgxSAeanvEftcgZc6vayUHAlu7GXTK6K6sY3+GDQGS L17WMc6GxcOvKjfhCQAl/m7Rn3RuBR2WIfHXZIFfpvaLRPcxzNrof29A3AGJ+2/tcjFZ cqHu+jev6fqMIjhb3l92JZp7S2PEPllS9ABCuxBMW7iCfuqA+FYtsbJaOWOLbvIrLZCA U9Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=GHpElbdT8yGvO2G+2wK7hH12e2y8DO+zHXf7OVoJ8YY=; b=hfXzYsM0YQ06doaNby44izh5HoFD/LMii1kgVceMd8YqQ4CyYww58VtV3xebXFYuMr Qoqfw+1oTuNCZjINxi7Wfdrh/VsZ5pZUqKbUJU3UP1195KLB09sckrnbKyAAXLF48f/Y DbUuhlD5BDzZ4b89kiLpRuaGY0LyXsTokcpv4czHbtZjfgjD5IZasGpouJOfrUnRQR89 ltFDOT2oOpfnib2048NjgR93USwriW6g0NdzUghbAoF38FbZb2Y+Ghr2z7yKg8CxVF+m W//VWZyZS6vpPp2RvssLIJ9vo08xf73yXDCptLXOUv5EUiawc84J1jZ8E5nj3Jw/K++H za7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="Xw/ILqWd"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u11-20020a170906108b00b008b17aec0300si4002048eju.122.2023.02.17.07.35.36; Fri, 17 Feb 2023 07:36:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="Xw/ILqWd"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230292AbjBQPSy (ORCPT + 99 others); Fri, 17 Feb 2023 10:18:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230290AbjBQPSu (ORCPT ); Fri, 17 Feb 2023 10:18:50 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0F766EF36 for ; Fri, 17 Feb 2023 07:18:45 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id bv17so1193527wrb.9 for ; Fri, 17 Feb 2023 07:18:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=GHpElbdT8yGvO2G+2wK7hH12e2y8DO+zHXf7OVoJ8YY=; b=Xw/ILqWdiTi7Y5ML8FZgvK/UJFdWtP/qoxwRrlczOKWdxKZ3ltZr09E7i7Kb6hx3pg CwaTCoeenVJmC58suWT4k7NVsQCIPpNt6mwkWd6wlcRVqP+3xr/wF+u8asvJYhM8SHCH Y+ExaTAObLFUuT0b0f1DMpW/t+f20533EBThc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GHpElbdT8yGvO2G+2wK7hH12e2y8DO+zHXf7OVoJ8YY=; b=1iO8MR8mGLRAazNGqF6llCKNgmpBeujgblL1rjMtKGa8gGzMtODWcY9oO3t0bpICOj Q3K+bRyKXwsqB3emwJm4EjfVqxundgK55oKMcZhu/I/ndlxnwPu+f0k31Xu5C13M6t3e b0YasRWVJdDo9y9vxuHIi1n0QnOUwV2aY9xh5gfNZcoMAGvBuTIyBtobkN+kVe8PFUL+ ezoPFPaZtkOGA2fu06p5Mpo5obmmFAs57Rmw/qL7EmNsOSvyYUNYVSL+2L6JVAonFDc6 i1BcYz759Nnwc03Ox4oc5hul1h4YVGH6NI3SEZBeYKOIN8lZEodnRYIwqL04//1fk6N2 8INQ== X-Gm-Message-State: AO0yUKVA3KQAy8o+EMvRIrhMI5RaGRkCGyAjVXb6MPXS2vtYsLN/YyQv tdk4VQuOlGD1uaMUSIWh7skiEA== X-Received: by 2002:adf:f646:0:b0:2c6:e87f:f19 with SMTP id x6-20020adff646000000b002c6e87f0f19mr1491310wrp.57.1676647124414; Fri, 17 Feb 2023 07:18:44 -0800 (PST) Received: from revest.zrh.corp.google.com ([2a00:79e0:9d:6:1704:c044:3b31:aaca]) by smtp.gmail.com with ESMTPSA id 26-20020a05600c229a00b003dc49e0132asm1166420wmf.1.2023.02.17.07.18.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Feb 2023 07:18:43 -0800 (PST) From: Florent Revest To: bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-kbuild@vger.kernel.org Cc: andrii@kernel.org, mykolal@fb.com, ast@kernel.org, daniel@iogearbox.net, kpsingh@kernel.org, masahiroy@kernel.org, nathan@kernel.org, ndesaulniers@google.com, Florent Revest Subject: [PATCH bpf-next] selftests/bpf: Fix cross compilation with CLANG_CROSS_FLAGS Date: Fri, 17 Feb 2023 16:18:32 +0100 Message-Id: <20230217151832.27784-1-revest@chromium.org> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758093031127260070?= X-GMAIL-MSGID: =?utf-8?q?1758093031127260070?= I cross-compile my BPF selftests with the following command: CLANG_CROSS_FLAGS="--target=aarch64-linux-gnu --sysroot=/sysroot/" \ make LLVM=1 CC=clang CROSS_COMPILE=aarch64-linux-gnu- SRCARCH=arm64 (Note the use of CLANG_CROSS_FLAGS to specify a custom sysroot instead of letting clang use gcc's default sysroot) However, CLANG_CROSS_FLAGS gets propagated to host tools builds (libbpf and bpftool) and because they reference it directly in their Makefiles, they end up cross-compiling host objects which results in linking errors. This patch ensures that CLANG_CROSS_FLAGS is reset if CROSS_COMPILE isn't set (for example when reaching a BPF host tool build). Signed-off-by: Florent Revest --- tools/scripts/Makefile.include | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include index 0efb8f2b33ce..ff527ac065cf 100644 --- a/tools/scripts/Makefile.include +++ b/tools/scripts/Makefile.include @@ -108,6 +108,8 @@ endif # GCC_TOOLCHAIN_DIR endif # CLANG_CROSS_FLAGS CFLAGS += $(CLANG_CROSS_FLAGS) AFLAGS += $(CLANG_CROSS_FLAGS) +else +CLANG_CROSS_FLAGS := endif # CROSS_COMPILE # Hack to avoid type-punned warnings on old systems such as RHEL5: