[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAK7LNAR7qOTYnK3JEShhVo807mMwm9-DiSB2yZrKa4vr+BBD1g@mail.gmail.com>
Date: Thu, 5 Apr 2018 23:50:25 +0900
From: Masahiro Yamada <yamada.masahiro@...ionext.com>
To: Linux Kbuild mailing list <linux-kbuild@...r.kernel.org>
Cc: Greg KH <gregkh@...uxfoundation.org>,
Michal Marek <michal.lkml@...kovi.net>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Tom Rini <trini@...sulko.com>, Joe Perches <joe@...ches.com>,
Randy Dunlap <rdunlap@...radead.org>,
Sam Ravnborg <sam@...nborg.org>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Masahiro Yamada <yamada.masahiro@...ionext.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3] kbuild: use -fmacro-prefix-map to make __FILE__ a
relative path
2018-03-30 13:15 GMT+09:00 Masahiro Yamada <yamada.masahiro@...ionext.com>:
> 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 <yamada.masahiro@...ionext.com>
> ---
>
> I tested this on GCC 8.
> (not released yet, but you can get the source code from the trunk.)
Applied to linux-kbuild.
--
Best Regards
Masahiro Yamada
Powered by blists - more mailing lists