gen_compile_commands: add assembly files to compilation database
Subsystems (2)
PATCH 1/1 gen_compile_commands: add assembly files to compilation database
Like C source files, tooling can find it useful to have the assembly source file compilation recorded.
The .S extension appears to used across all architectures.
---
For example, I'm prototyping adding ASM support to clangd. It can use this information to determine the architecture, macros definitions, include paths, etc. on a per-file basis. I can capture this during compilation with tools like bear, but given this script exists and the change is trivial it seems like a good idea to adjust this script too.
--- scripts/clang-tools/gen_compile_commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/clang-tools/gen_compile_commands.py +1 -1
@@ -19,7 +19,7 @@ _DEFAULT_OUTPUT = 'compile_commands.json' _DEFAULT_LOG_LEVEL = 'WARNING' _FILENAME_PATTERN = r'^\..*\.cmd$' -_LINE_PATTERN = r'^savedcmd_[^ ]*\.o := (.* )([^ ]*\.c) *(;|$)' +_LINE_PATTERN = r'^savedcmd_[^ ]*\.o := (.* )([^ ]*\.[cS]) *(;|$)' _VALID_LOG_LEVELS = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] # The tools/ directory adopts a different build system, and produces .cmd # files in a different format. Do not support it.
Signature · 1 line
2.41.0
Quoted 30 lines · Benjamin Gray
Like C source files, tooling can find it useful to have the assembly source file compilation recorded.
The .S extension appears to used across all architectures.
Signed-off-by Benjamin Gray <[email protected]>---
For example, I'm prototyping adding ASM support to clangd. It can use this information to determine the architecture, macros definitions, include paths, etc. on a per-file basis. I can capture this during compilation with tools like bear, but given this script exists and the change is trivial it seems like a good idea to adjust this script too.
---scripts/clang-tools/gen_compile_commands.py| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)scripts/clang-tools/gen_compile_commands.py +0
-0@@ -19,7 +19,7 @@ _DEFAULT_OUTPUT = 'compile_commands.json'
_DEFAULT_LOG_LEVEL= 'WARNING'
_FILENAME_PATTERN= r'^\..*\.cmd$'scripts/clang-tools/gen_compile_commands.py +1
-1-_LINE_PATTERN = r'^savedcmd_[^ ]*\.o := (.* )([^ ]*\.c) *(;|$)' +_LINE_PATTERN = r'^savedcmd_[^ ]*\.o := (.* )([^ ]*\.[cS]) *(;|$)'
_VALID_LOG_LEVELS= ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] # Thetools/directory adopts a different build system, and produces .cmd
Quoted 4 lines
# files in a different format. Do not support it.Signature · 1 line
2.41.0
Yes, this is also useful for my tool ccls:)
I agree that for assembly files, the compile_commands.json entries are
only useful for C preprocessing directives like #include and macros, so
.S files are needed but .s files are not. In addition, the kernel doesn't seem to have .s files.
Quoted 5 lines · Benjamin Gray
Like C source files, tooling can find it useful to have the assembly source file compilation recorded.
The .S extension appears to used across all architectures.
Quoted 8 lines
Signed-off-by Benjamin Gray <[email protected]>---
For example, I'm prototyping adding ASM support to clangd. It can use this information to determine the architecture, macros definitions, include paths, etc. on a per-file basis. I can capture this during compilation with tools like bear, but given this script exists and the
Right, this script was written specifically to avoid relying on external dependencies to generate a compile_commands file, so modifying this script is definitely the right thing to allow this to work for anyone working on the kernel and using the built-in kbuild targets for the static analyzer and compile_commands.json.
Quoted 1 line
change is trivial it seems like a good idea to adjust this script too.
Thanks for the patch, this seems reasonable.
Quoted 21 lines
--- scripts/clang-tools/gen_compile_commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/clang-tools/gen_compile_commands.py +1
-1@@ -19,7 +19,7 @@ _DEFAULT_OUTPUT = 'compile_commands.json' _DEFAULT_LOG_LEVEL = 'WARNING' _FILENAME_PATTERN = r'^\..*\.cmd$' -_LINE_PATTERN = r'^savedcmd_[^ ]*\.o := (.* )([^ ]*\.c) *(;|$)' +_LINE_PATTERN = r'^savedcmd_[^ ]*\.o := (.* )([^ ]*\.[cS]) *(;|$)' _VALID_LOG_LEVELS = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] # The tools/ directory adopts a different build system, and produces .cmd # files in a different format. Do not support it.Signature · 1 line
2.41.0
Quoted 8 lines · Benjamin Gray
Like C source files, tooling can find it useful to have the assembly source file compilation recorded.
The .S extension appears to used across all architectures.
Signed-off-by Benjamin Gray <[email protected]>
Quoted 7 lines
---
For example, I'm prototyping adding ASM support to clangd. It can use this information to determine the architecture, macros definitions, include paths, etc. on a per-file basis. I can capture this during compilation with tools like bear, but given this script exists and the change is trivial it seems like a good idea to adjust this script too.
Sounds cool, thanks for the patch!
Feel free to subscribe us to the clangd patches; we might have bandwidth to help review, or can at least follow along on progress.
Quoted 21 lines
--- scripts/clang-tools/gen_compile_commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/clang-tools/gen_compile_commands.py +1
-2@@ -19,7 +19,7 @@ _DEFAULT_OUTPUT = 'compile_commands.json' _DEFAULT_LOG_LEVEL = 'WARNING' _FILENAME_PATTERN = r'^\..*\.cmd$' -_LINE_PATTERN = r'^savedcmd_[^ ]*\.o := (.* )([^ ]*\.c) *(;|$)' +_LINE_PATTERN = r'^savedcmd_[^ ]*\.o := (.* )([^ ]*\.[cS]) *(;|$)' _VALID_LOG_LEVELS = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] # The tools/ directory adopts a different build system, and produces .cmd # files in a different format. Do not support it. --2.41.0
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 9 lines · Benjamin Gray
Like C source files, tooling can find it useful to have the assembly source file compilation recorded.
The .S extension appears to used across all architectures.
Signed-off-by Benjamin Gray <[email protected]>---
Applied to linux-kbuild.
Thanks.
Quoted 26 lines
For example, I'm prototyping adding ASM support to clangd. It can use this information to determine the architecture, macros definitions, include paths, etc. on a per-file basis. I can capture this during compilation with tools like bear, but given this script exists and the change is trivial it seems like a good idea to adjust this script too.
--- scripts/clang-tools/gen_compile_commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/clang-tools/gen_compile_commands.py +1
-2@@ -19,7 +19,7 @@ _DEFAULT_OUTPUT = 'compile_commands.json' _DEFAULT_LOG_LEVEL = 'WARNING' _FILENAME_PATTERN = r'^\..*\.cmd$' -_LINE_PATTERN = r'^savedcmd_[^ ]*\.o := (.* )([^ ]*\.c) *(;|$)' +_LINE_PATTERN = r'^savedcmd_[^ ]*\.o := (.* )([^ ]*\.[cS]) *(;|$)' _VALID_LOG_LEVELS = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] # The tools/ directory adopts a different build system, and produces .cmd # files in a different format. Do not support it. --2.41.0
Signature · 2 lines
Best Regards Masahiro Yamada