From patchwork Fri Nov 8 18:50:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 178936 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3130092ilf; Fri, 8 Nov 2019 11:00:07 -0800 (PST) X-Google-Smtp-Source: APXvYqy+aVgugUVkzjprSYm+ZGSdi3+R2jbrdW/Di9NWlqsHHkEI1fHEm2O7ueBclOK8LLkPV6c8 X-Received: by 2002:a17:906:198c:: with SMTP id g12mr10135532ejd.247.1573239607469; Fri, 08 Nov 2019 11:00:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573239607; cv=none; d=google.com; s=arc-20160816; b=0FDyc1bvEa+D0lKi0vysNFY5bvV5wtNlBuk+fnbhmDGFkzupXFlvl4P9PnFDYBitA+ +BYvXZ0fRSUIeKsc6++6KCVg3sFlbgNKXIHJCzeDXkwR1aVjaCIVykil9r+8Cas3XGy8 Le8RoV0HSriOi+xr3iEmCx3UFKLoWmxx8HNq8joB+aGa32+HP4jT2vqskIOMlpbybvNj JTZlti4fy8dJokba2hM8yCl4RD3MMB7ToPEBLBZINnfjIc59SEjkBrRMFVNreZqjDQuc 8dyitEr02mY0Gzy62uvMXfFVfZTsb0uRUkmJmyTslbGRrnx9GZ6cFWrK1mE/siKm/NP5 aMEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=V/o4sDvr2erPNigAKQEXQcA4WFc173qVHmQQgzCTOWU=; b=CtPxvvaExnDHK3Ih4lH6GoIr+EDwHt9I09nDLto3/1WxiauA9j5gLkELmoMorgZmez jY5lSI+/rDNs6/F9lZGvNmqVb8/AgaAhBy4bfxwBBsQAfEqxiF0gt+aSMFEyH1qNo3N8 uFwlZgB08XBdrI5nqGXsnNS1XStwVLcKdBIqo/nBuckMMRUQ7DcXrQHy5Q9rdKt0klpe 06kwI3phyPepitOV4+dbdizyPu5opcM3or9T0mHC9mvVblwOnXC9ImTNlGkCv/lQCD5o C5PhI0ct81WYm9Xgc0jHz4TRnmkXlqcM1fwDfLM6oHupmN53+zPnbvWogDmbvq4BRvip +HxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LA3bl08A; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v9si5375262edl.90.2019.11.08.11.00.07; Fri, 08 Nov 2019 11:00:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LA3bl08A; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389323AbfKHS77 (ORCPT + 14 others); Fri, 8 Nov 2019 13:59:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:56990 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731773AbfKHS77 (ORCPT ); Fri, 8 Nov 2019 13:59:59 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BF0EC22559; Fri, 8 Nov 2019 18:59:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573239598; bh=GrDR/KfEa55q+XgH6XKOcuelZG4bs5H5zJITdZsvvvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LA3bl08A2Qzg1NKeeWm6S9UllzWHdyzIytKr0AUF3wThmp2Se/gftNbuz7Igo1sUD Hzl2hW9k93gEL0oiraEul3sJi+NzfXC7KvyYHzxaQByqykECm6yMDm9cFqn+TAmeKi e0mUIN+8FIzEZxa0iQpD1fjbFiNd8N2vR6sPczrk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masahiro Yamada , Sasha Levin Subject: [PATCH 4.14 52/62] kbuild: use -fmacro-prefix-map to make __FILE__ a relative path Date: Fri, 8 Nov 2019 19:50:40 +0100 Message-Id: <20191108174755.304501752@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191108174719.228826381@linuxfoundation.org> References: <20191108174719.228826381@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Masahiro Yamada [ Upstream commit a73619a845d5625079cc1b3b820f44c899618388 ] The __FILE__ macro is used everywhere in the kernel to locate the file printing the log message, such as WARN_ON(), etc. If the kernel is built out of tree, this can be a long absolute path, like this: WARNING: CPU: 1 PID: 1 at /path/to/build/directory/arch/arm64/kernel/foo.c:... This is because Kbuild runs in the objtree instead of the srctree, then __FILE__ is expanded to a file path prefixed with $(srctree)/. Commit 9da0763bdd82 ("kbuild: Use relative path when building in a subdir of the source tree") improved this to some extent; $(srctree) becomes ".." if the objtree is a child of the srctree. For other cases of out-of-tree build, __FILE__ is still the absolute path. It also means the kernel image depends on where it was built. A brand-new option from GCC, -fmacro-prefix-map, solves this problem. If your compiler supports it, __FILE__ is the relative path from the srctree regardless of O= option. This provides more readable log and more reproducible builds. Please note __FILE__ is always an absolute path for external modules. Signed-off-by: Masahiro Yamada Signed-off-by: Sasha Levin --- Makefile | 3 +++ 1 file changed, 3 insertions(+) -- 2.20.1 diff --git a/Makefile b/Makefile index 1d7f47334ca2b..61660387eb34b 100644 --- a/Makefile +++ b/Makefile @@ -840,6 +840,9 @@ KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types) # Require designated initializers for all marked structures KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init) +# change __FILE__ to the relative path from the srctree +KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) + # use the deterministic mode of AR if available KBUILD_ARFLAGS := $(call ar-option,D)