rizsotto / Bear

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

Not working in OSX 10.15.7 #355

Closed jinwik closed 3 years ago

jinwik commented 3 years ago

Describe the bug A clear and concise description of what the bug is. bear create an empty compile_commands.json

To Reproduce bear --verbose -- make COMPILER_WARNINGS_FATAL=false USE_CLANG=true CC="clang -Wno-deprecated-declarations -Wno-implicit-function-declaration"

Environment:

Additional context

Before you send... disable SIP

rizsotto commented 3 years ago

Hi @jinwik , thanks for the report... from the log I see that intercept was only caught the nm -Uj abstractCompiler.o accessFlags.o ad_x86_64.o ... command only. I need the logs before that to see what happened during the build.

It could be that the build system does not respect the CC and CXX variables. Looking at the OpenJDK project quickly, as far as I can judge, the build system requires a configure step before you run make. That's when it decide which compiler it uses. Bear impose compiler wrappers during the build process, which we might want to apply to the configure step too.

I would run these commands

jinwik commented 3 years ago

intercept --verbose -- ./configure --with-debug-level=slowdebug --enable-debug-symbols --disable-zip-debug-info --with-native-debug-symbols=internal --enable-jfr --with-toolchain-type=clang OBJCOPY=objcopy intercept.log

jinwik commented 3 years ago

sqlite3 commands.sqlite3 "select count(*) from events;" 20

jinwik commented 3 years ago

@rizsotto thx for your patience bear.log cat compile_commands.json []

rizsotto commented 3 years ago

Thanks @jinwik , the intercept.log shows where it goes sideways...

...
checking whether we are using the GNU C compiler... yes
checking whether /usr/bin/clang accepts -g... yes
checking for /usr/bin/clang option to accept ISO C89... none needed
checking for clang++... /usr/bin/clang++
checking resolved symbolic links for CXX... no symlink
configure: Using clang C++ compiler version 12.0.0 [Apple clang version 12.0.0 (clang-1200.0.32.28) Target: x86_64-apple-darwin19.6.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin]
checking whether we are using the GNU C++ compiler... yes
checking whether /usr/bin/clang++ accepts -g... yes
...

It should be /usr/local/Cellar/bear/3.0.8/libexec/wrapper.d/cc and not /usr/bin/clang.

It might be looking for directly to clang since, you've added the --with-toolchain-type=clang switch. Could you try to add a clang and clang++ softlink into the /usr/local/Cellar/bear/3.0.8/libexec/wrapper.d/ directory? (Look at other the other files in that directory as example.) And please re-run the git clean -fdx && intercept --verbose -- ./configure ... commands.

jinwik commented 3 years ago

Thanks, @rizsotto but still failed

cd /usr/local/Cellar/bear/3.0.8/libexec/wrapper.d ln -s ../wrapper clang ln -s ../wrapper clang++

intercept --verbose -- ./configure --with-debug-level=slowdebug --enable-debug-symbols --disable-zip-debug-info --with-native-debug-symbols=internal --enable-jfr --with-toolchain-type=clang OBJCOPY=objcopy

[08:25:57.022838, wr, 73935, ppid: 73934] gRPC call requested: supervise::Supervisor::Resolve [08:25:57.024060, wr, 73935, ppid: 73934] gRPC call [Resolve] finished: false [08:25:57.024411, wr, 73935, ppid: 73934] failed with: gRPC call failed: not recognized wrapper" configure: error: A clang compiler is required. Try setting --with-tools-dir. configure exiting with result code 1 [08:25:57.083245, ic, 73321] Process wait request: done. [pid: 73322] [08:25:57.083265, ic, 73321] Running command. [Exited with 1] [08:25:57.083278, ic, 73321] Stopping gRPC server. [08:25:57.083630, ic, 73321] succeeded with: 1

inter.log

rizsotto commented 3 years ago

Thanks @jinwik , this trace was very helpful. I think I've found were it goes wrong.

It uses the wrapper name with full path (instead of the basename of the executable). Will fix it today evening.

rizsotto commented 3 years ago

Hey @jinwik , can you give it a try with the version I have on the devel branch? I think it has a fix for it.

jinwik commented 3 years ago

Thanks @rizsotto, it works. but clion does not seem to recognize the compile_commads.json generated by bear, but it does correctly by making compile-commands (openjdk16). Any suggestions? Thanks! compile-commands-diff.log

rizsotto commented 3 years ago

Good to hear that change on devel branch fix your issue.

About the CLion problem...

jinwik commented 3 years ago

sry, that was my problem, I should move compile_commads.json to the directory folder. Great job, thanks @rizsotto I think we can close the issue.