rizsotto / Bear

Bear is a tool that generates a compilation database for clang tooling.
GNU General Public License v3.0
4.83k stars 313 forks source link

bear generated compile_commands.json does not contain the flag in LDFLAGS #488

Closed oicu0619 closed 1 year ago

oicu0619 commented 1 year ago

Makefile:

LDFLAGS = -lpthread all: test

Actual compile commands (make VERBOSE=1):

g++ -lpthread test.cc -o test

compile_commands.json generated by bear:

[ { "arguments": [ "g++", "-c", "-o", "test", "test.cc" ], "directory": "/home/oicu/Downloads/cpp", "file": "test.cc" } ]

the flags in LDFLAGS is missing.

rizsotto commented 1 year ago

Yes, this is intended to filter out the linker flags. Since the JSON compilation database is for compilations only, linker flags will not influence the compilation pass of the compiler.

Does the generated output not working with Clang tooling programs? (clang-tidy or clang-format or with any other tool that you are planning to use the output with)

oicu0619 commented 1 year ago

Thanks for the reply! Generated output works fine with Clang tooling programs.