From patchwork Fri Nov 8 18:50:37 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: 178950 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3161648ilf; Fri, 8 Nov 2019 11:23:45 -0800 (PST) X-Google-Smtp-Source: APXvYqx5eY5JGj32uY/1xgG5cN649kyF8kR8E1tUbAVW6FCISkfSduE7mnJYS5Pra9OSP0FwOrkZ X-Received: by 2002:aa7:cc95:: with SMTP id p21mr12138635edt.189.1573240929322; Fri, 08 Nov 2019 11:22:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573240929; cv=none; d=google.com; s=arc-20160816; b=p/UFNgtnQkjEu2TGXAiKhWHn4Pwaoje1f7OSTHlclSw2KyA3UYBcz9vwUyHGC0OOr3 go/sfMILd+p6hVEwuMnZlfprAg/ggGEXcUlqv/YE88ibsUrr93LxNKqMkw0ZAbAhCfQC Tbwl2UfsN1tCPJuaJXHr1lIpCxSbFQ9tgdoLg8cgq41GDr2DnrceykxBLOQKXQKn1Bdo auJerWAN6g9grulJA4TGml+kNx90bUUtL8o4dbCqyLizqYI/bextiiTdXcN3Sgo2DxMo tx8dOOzD1sVK0zJJbIr87LURkvwKx0UO+8xVaD/APWkXL9pe4VeTEf4kVFe/VCiX+8/h 2Z+A== 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=zoWjoXGT2NrhMvOqyo559WmPV4VjSBBM7YDWRvmcDqs=; b=b5e817BSmbOASAppVxV+R50MTgAREZz2o2Gg0hAcKfPTlxqWK5crUDoRhkdECf1Edp 8DAkoo/H8BDRApJP2ibopeE2swCZmtsmiB4O/soVb+rIhdlEAOfRipzH7MBpe2exjefn wvLDD6hp1+hvCSah9K0T7Y2guBszcuJ29IsFfYM3RpSDE49MhZIs8VcjuH+/H82CiW4J +laZ4NUxxYkbglad2XtU5NUSJHIBCZp/zqgsBX9aOM1Q906PnXYLi3f785fDHa+kqrwW In9H/frDTZ0bLllqmahqfDF7Zy1cLgEEvP+OXv9I+EljTx+MJKuCtAtPjgp1KM2eh+61 qWsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Z44crNc0; 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 u6si4443550ejr.410.2019.11.08.11.22.09; Fri, 08 Nov 2019 11:22:09 -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=Z44crNc0; 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 S1732304AbfKHTWF (ORCPT + 14 others); Fri, 8 Nov 2019 14:22:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:54572 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732708AbfKHS4w (ORCPT ); Fri, 8 Nov 2019 13:56:52 -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 CC2FF21D7E; Fri, 8 Nov 2019 18:56:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573239412; bh=qtBG9KGoVwj4vVLmTJ8RrLge0p0xuVRCHL1ui7zx5Ag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z44crNc0FEuugk6rlhoD0LdY96bFR6icsNsxL6wyJJoXXa3WxtBRozB5lR7ZFAcFR skNwmLPqZi4r3+dYH+qzoKyHTJeTa1ra7iyE14irSDaIv+fXv/wmolnTO4Ac3gRm/q uZmybqcFry5ztew2mYBh6mEUkZ5DS1F9xdvNj4i4= 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.9 30/34] kbuild: use -fmacro-prefix-map to make __FILE__ a relative path Date: Fri, 8 Nov 2019 19:50:37 +0100 Message-Id: <20191108174652.792481163@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191108174618.266472504@linuxfoundation.org> References: <20191108174618.266472504@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 19c7e30684077..62ce3766032c9 100644 --- a/Makefile +++ b/Makefile @@ -837,6 +837,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)