All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Stephen Zhang <stephenzhangzsd@gmail.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>,
	natechancellor@gmail.com, clang-built-linux@googlegroups.com,
	LKML <linux-kernel@vger.kernel.org>,
	Tom Roeder <tmroeder@google.com>
Subject: Re: [PATCH v1] clang_tools:gen_compile_commands: Change the default source directory
Date: Wed, 10 Feb 2021 11:24:00 -0700	[thread overview]
Message-ID: <20210210182400.GA3502674@ubuntu-m3-large-x86> (raw)
In-Reply-To: <CALuz2=dyA_ki98t8VNe2L1UcBXrSoJT1r6j1puEmLn7WrX87XQ@mail.gmail.com>

On Wed, Feb 10, 2021 at 08:15:27PM +0800, Stephen Zhang wrote:
> Nathan Chancellor <nathan@kernel.org> 于2021年2月10日周三 上午3:27写道:
> 
> > Just as an FYI, your email was HTML, which means it won't hit LKML.
> 
> 
> Thanks for pointing that out. The existence of a GFW makes it difficult for
> me to connect
> to the mail server.  so I use git client to send patches only and reply to
> emails with
> gmail  web client.

You can configure your Gmail web client to send text responses by
default by clicking on the three dot menu in the compose window then
chose the "plain text mode" option.

> $ mkdir -p /tmp/build/perf
> >
> > $ make -C tools/perf -skj"$(nproc)" O=/tmp/build/perf
> >
> > $ cd /tmp/build/perf
> >
> > $ ~/cbl/src/linux/scripts/clang-tools/gen_compile_commands.py --log_level
> > INFO -d .
> > ...
> >
> 
> According to the code logic, the source directory is specified by
> parameters  “-d”.

Yes and no. '-d' is supposed to be the build directory but the logic of
the script clearly does not work when the build and source directories
are in completely separate tree paths. In other works:

$ make

and

$ make O=build

will work with '-d .' because the .cmd files are in '.' and the source
files will be placed relative to '.', which is correct. Your command
does not work for two reasons:

1. You are using a build directory that is not a subpath of the source
directory. In other words, this script would not work for

$ make O=/tmp/build

because '-d /tmp/build' needs to be used to find the .cmd files but then
the relative path of the source files is messed up, as you point out.

2. The source files are in tools/perf, not .

> def process_line(root_directory, command_prefix, file_path):
>     ...
>     abs_path = os.path.abspath(os.path.join(root_directory, file_path))
>     ...
> 
> The "root_directory" is passed by "-d", which finally become the prefix
> like  "/tmp/build/perf/"
> of  "File /tmp/build/perf/arch/x86/tests/bp-modify.c not found".so the
> command is:
> 
>   $ ~/cbl/src/linux/scripts/clang-tools/gen_compile_commands.py --log_level
> INFO -d  ~/cbl/src/linux/tools/perf/
> 
> Maybe we should make an updated version, in which the help message of "-d"
> can be changed
> to specify the source directory instead, or I am just misunderstanding the
> code logic.
> 

The build directory needs to be involved because that is where the .cmd
files will be but the source directory needs to be known because the
source files in the .cmd files are relative to the source directory, not
the build directory. This happens to work in most situations like I
point out above but not always.

I think that my patch is most likely the way to go unless others feel
differently. It would be nice if you could give it a go.

Cheers,
Nathan

  parent reply	other threads:[~2021-02-10 18:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-08 11:28 [PATCH v1] clang_tools:gen_compile_commands: Change the default source directory Stephen Zhang
2021-02-08 19:54 ` Nathan Chancellor
     [not found]   ` <CALuz2=d-ENRbWgGYaO_ESEaw5eOVSwkQmkeYBJ-w0Vb3zZ+REg@mail.gmail.com>
2021-02-09 19:27     ` Nathan Chancellor
     [not found]       ` <CALuz2=dyA_ki98t8VNe2L1UcBXrSoJT1r6j1puEmLn7WrX87XQ@mail.gmail.com>
2021-02-10 18:24         ` Nathan Chancellor [this message]
2021-02-11 13:47           ` Stephen Zhang
2021-02-11 14:15             ` Masahiro Yamada
2021-02-12 11:20               ` Stephen Zhang
2021-02-13 12:45                 ` Masahiro Yamada
2021-02-14 11:49                   ` Stephen Zhang
2021-02-14 17:09                     ` Masahiro Yamada
2021-02-15 11:57                       ` Stephen Zhang
2021-02-14 23:28                     ` Nathan Chancellor
2021-02-15 11:36                       ` Stephen Zhang
2021-02-10 20:32       ` Tom Roeder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210210182400.GA3502674@ubuntu-m3-large-x86 \
    --to=nathan@kernel.org \
    --cc=clang-built-linux@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=natechancellor@gmail.com \
    --cc=ndesaulniers@google.com \
    --cc=stephenzhangzsd@gmail.com \
    --cc=tmroeder@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.