Closed rochaferraz closed 3 years ago
Hi @rochaferraz , thanks for the report.
I guess the compiler you run is the /Users/user/lw-pixel2/third-party/arm-toolchain/osx/7.2_2017q4/bin/arm-none-eabi-gcc
? From the log I can see the wrappers are set up for /usr/bin/clang
to intercept. So, what I would try is this:
CC=/Users/user/lw-pixel2/third-party/arm-toolchain/osx/7.2_2017q4/bin/arm-none-eabi-gcc bear --verbose -- make
(use CXX
for the C++ compiler) This is the easiest way to tell Bear what is the compiler to wrap around.
The new 3.0 bear on MacOS does only compiler wrappers. Passing --force-wrapper
is not necessary.
Hi @rizsotto. Thanks. I tried, but I have the same results
I tried used both absolute and relative paths
[19:51:53.134284, br, 68562] bear: 3.0.9
[19:51:53.135288, br, 68562] arguments: ["bear", "--verbose", "--", "make", "VERBOSE=1"]
[19:51:53.135323, br, 68562] environment: […, "CC=../third-party/arm-toolchain/osx/7.2_2017q4/bin/arm-none-eabi-gcc", "_=/usr/local/bin/bear"]
[19:51:53.135527, br, 68562] sysname: Darwin
[19:51:53.135533, br, 68562] release: 19.6.0
[19:51:53.135535, br, 68562] version: Darwin Kernel Version 19.6.0: Tue Nov 10 00:10:30 PST 2020; root:xnu-6153.141.10~1/RELEASE_X86_64
[19:51:53.135538, br, 68562] machine: x86_64
[19:51:53.135571, br, 68562] arguments parsed: {program: bear, arguments: [{--: [make, VERBOSE=1]}, {--citnames: [/usr/local/bin/citnames]}, {--interceptor: [/usr/local/bin/intercept]}, {--libexec: [/usr/local/libexec/libexec.dylib]}, {--output: [compile_commands.json]}, {--verbose: []}, {--wrapper: [/usr/local/libexec/wrapper]}, {--wrapper-dir: [/usr/local/libexec/wrapper.d]}]}
[19:51:53.138993, br, 68562] Process spawned. [pid: 68563, command: [/usr/local/bin/intercept, --library, /usr/local/libexec/libexec.dylib, --wrapper, /usr/local/libexec/wrapper, --wrapper-dir, /usr/local/libexec/wrapper.d, --output, compile_commands.sqlite3, --verbose, --, make, VERBOSE=1]]
[19:51:53.139059, br, 68562] Process wait requested. [pid: 68563]
[19:51:53.149425, ic, 68563] intercept: 3.0.9
[19:51:53.149841, ic, 68563] arguments: ["/usr/local/bin/intercept", "--library", "/usr/local/libexec/libexec.dylib", "--wrapper", "/usr/local/libexec/wrapper", "--wrapper-dir", "/usr/local/libexec/wrapper.d", "--output", "compile_commands.sqlite3", "--verbose", "--", "make", "VERBOSE=1"]
[19:51:53.149865, ic, 68563] environment: ["CC=../third-party/arm-toolchain/osx/7.2_2017q4/bin/arm-none-eabi-gcc", …]
[19:51:53.162179, ic, 68563] sysname: Darwin
[19:51:53.162186, ic, 68563] release: 19.6.0
[19:51:53.162188, ic, 68563] version: Darwin Kernel Version 19.6.0: Tue Nov 10 00:10:30 PST 2020; root:xnu-6153.141.10~1/RELEASE_X86_64
[19:51:53.162189, ic, 68563] machine: x86_64
[19:51:53.162226, ic, 68563] arguments parsed: {program: /usr/local/bin/intercept, arguments: [{--: [make, VERBOSE=1]}, {--library: [/usr/local/libexec/libexec.dylib]}, {--output: [compile_commands.sqlite3]}, {--verbose: []}, {--wrapper: [/usr/local/libexec/wrapper]}, {--wrapper-dir: [/usr/local/libexec/wrapper.d]}]}
[19:51:53.193537, ic, 68563] session initialized with: wrapper_dir: /usr/local/libexec/wrapper.d
[19:51:53.193564, ic, 68563] session initialized with: mapping: [{ "ar": "/opt/local/bin/ar" }, { "as": "/opt/local/bin/as" }, { "bison": "/usr/bin/bison" }, { "c++": "/usr/bin/clang++" }, { "cc": "/Users/user/lw-pixel2/third-party/arm-toolchain/osx/7.2_2017q4/bin/arm-none-eabi-gcc" }, { "clang": "/usr/bin/clang" }, { "clang++": "/usr/bin/clang++" }, { "cpp": "/usr/bin/cpp" }, { "flex": "/opt/local/bin/flex" }, { "g++": "/usr/bin/g++" }, { "gcc": "/usr/bin/gcc" }, { "ld": "/opt/local/libexec/ld64/ld-xcode" }, { "lex": "/usr/bin/lex" }, { "makeinfo": "/opt/local/bin/texi2any" }, { "nm": "/opt/local/bin/llvm-nm-mp-10" }, { "objdump": "/usr/bin/objdump" }, { "ranlib": "/opt/local/bin/libtool" }, { "strip": "/opt/local/bin/strip" }, { "yacc": "/usr/bin/yacc" }]
[19:51:53.203880, ic, 68563] session initialized with: override: [{ "CC": "cc" }]
[19:51:53.207824, ic, 68563] Running gRPC server. 127.0.0.1:60095
[19:51:53.208432, ic, 68563] Process spawned. [pid: 68564, command: [make, VERBOSE=1]]
[19:51:53.208484, ic, 68563] Process wait requested. [pid: 68564]
[19:51:53.226263, wr, 68566, ppid: 68565] wrapper: 3.0.9
[19:51:53.226897, wr, 68566, ppid: 68565] arguments: ["cc", "--version"]
[19:51:53.226924, wr, 68566, ppid: 68565] environment: [“…”]
[19:51:53.228347, wr, 68566, ppid: 68565] gRPC call requested: supervise::Supervisor::Resolve
[19:51:53.230611, ic, 68563] trying to resolve for wrapper: cc
[19:51:53.231183, wr, 68566, ppid: 68565] gRPC call [Resolve] finished: true
[19:51:53.232170, wr, 68566, ppid: 68565] Process spawned. [pid: 68569, command: [/Users/user/lw-pixel2/third-party/arm-toolchain/osx/7.2_2017q4/bin/arm-none-eabi-gcc, --version]]
[19:51:53.232874, wr, 68566, ppid: 68565] gRPC call requested: supervise::Interceptor::Register
[19:51:53.244227, wr, 68566, ppid: 68565] gRPC call [Register] finished: true
[19:51:53.244338, wr, 68566, ppid: 68565] Process wait requested. [pid: 68569]
[19:51:53.244349, wr, 68566, ppid: 68565] Process wait request: done. [pid: 68569]
[19:51:53.244364, wr, 68566, ppid: 68565] gRPC call requested: supervise::Interceptor::Register
[19:51:53.247621, wr, 68566, ppid: 68565] gRPC call [Register] finished: true
[19:51:53.248635, wr, 68566, ppid: 68565] succeeded with: 0
../third-party/arm-toolchain/osx/7.2_2017q4/bin/arm-none-eabi-gcc -g3 -gdwarf-2 -mcpu=cortex-m33 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=hard --specs=nosys.specs -u _printf_float -Os -Wall -c -fmessage-length=0 -ffunction-sections -fdata-sections -DNULL_BTL -DPLATFORM_HEADER=\"platform/base/hal/micro/cortexm3/compiler/gcc.h\" -DNVIC_CONFIG=\"platform/base/hal/micro/cortexm3/efm32/nvic-config.h\" -DEFR32MG21A010F1024IM32 -DEFR32MG21 -DCORTEXM3 -DCORTEXM3_EFR32 -DCORTEXM3_EFR32_MICRO -DCORTEXM3_EFM32_MICRO -DEFR32_SERIES2_CONFIG1_MICRO (…) -DOPENTHREAD_CONFIG_LOG_OUTPUT=OPENTHREAD_CONFIG_LOG_OUTPUT_APP -DHAP_LOG_LEVEL=3 -I../third-party/gecko-sdk/v2.7 -I../third-party/gecko-sdk/v2.7/hardware/kit/common/bsp -I../third-party/gecko-sdk/v2.7/hardware/kit/common/drivers -I../third-party/gecko-sdk/v2.7/hardware/kit/common/halconfig -I../third-party/gecko-sdk/v2.7/hardware/kit/EFR32MG21_BRD4180A/config -std=gnu99 ../modules/hk/App/App.c -o ../modules/hk/App/App.o
../third-party/arm-toolchain/osx/7.2_2017q4/bin/arm-none-eabi-g++ -g3 -gdwarf-2 -mcpu=cortex-m33 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=hard --specs=nosys.specs -u _printf_float -T "../build_system/efr32mg21.ld" -Xlinker --defsym="LONGTOKEN_SIZE=0" -Xlinker --defsym="LOCKBITS_IN_MAINFLASH_SIZE=0" -Xlinker --defsym="FLASH_SIZE=1048576" -Xlinker --defsym="RAM_SIZE=262144" -Xlinker --defsym="FLASH_PAGE_SIZE=2048" -Xlinker --defsym="NULL_BTL=1" -Xlinker --defsym="HEADER_SIZE=512" -Xlinker --gc-sections -Xlinker -Map="../build/pix.map" --specs=nano.specs -u _printf_float -o ../build/pix.out -Wl,--start-group -lgcc -lc -lnosys -Wl,--end-group -Wl,--start-group ../modules/hk/App/App.o ../modules/hk/App/Main.o ../modules/hk/App/AppBase.o ../modules/hk/DB/DB.o ../third-party/gecko-sdk/v2.7/platform/Device/SiliconLabs/EFR32MG21/Source/system_efr32mg21.o ../third-party/gecko-sdk/v2.7/platform/Device/SiliconLabs/EFR32MG21/Source/GCC/startup_efr32mg21.o ../modules/sl_custom/BLECustomGeckoEvent.o ../modules/sl_custom/gatt_db.o ../third-party/gecko-sdk/v2.7/protocol/bluetooth/lib/EFR32MG21/GCC/libbluetooth.a ../third-party/gecko-sdk/v2.7/platform/radio/rail_lib/autogen/librail_release/librail_multiprotocol_efr32xg21_gcc_release.a ../third-party/gecko-sdk/v2.7/platform/emdrv/nvm3/lib/libnvm3_CM33_gcc.a ../lib/libpix.a -Wl,--end-group
Done.
[19:51:56.789649, ic, 68563] Process wait request: done. [pid: 68564]
[19:51:56.789687, ic, 68563] Running command. [Exited with 0]
[19:51:56.789712, ic, 68563] Stopping gRPC server.
[19:51:56.790373, ic, 68563] succeeded with: 0
[19:51:56.791230, br, 68562] Process wait request: done. [pid: 68563]
[19:51:56.791266, br, 68562] Running intercept finished. [Exited with 0]
[19:51:56.792386, br, 68562] Process spawned. [pid: 68594, command: [/usr/local/bin/citnames, --input, compile_commands.sqlite3, --output, compile_commands.json, --run-checks, --verbose]]
[19:51:56.792446, br, 68562] Process wait requested. [pid: 68594]
[19:51:56.795958, cs, 68594] citnames: 3.0.9
[19:51:56.796537, cs, 68594] arguments: ["/usr/local/bin/citnames", "--input", "compile_commands.sqlite3", "--output", "compile_commands.json", "--run-checks", "--verbose"]
[19:51:56.796566, cs, 68594] environment: ["CC=../third-party/arm-toolchain/osx/7.2_2017q4/bin/arm-none-eabi-gcc", …]
[19:51:56.796739, cs, 68594] sysname: Darwin
[19:51:56.796742, cs, 68594] release: 19.6.0
[19:51:56.796744, cs, 68594] version: Darwin Kernel Version 19.6.0: Tue Nov 10 00:10:30 PST 2020; root:xnu-6153.141.10~1/RELEASE_X86_64
[19:51:56.796745, cs, 68594] machine: x86_64
[19:51:56.796760, cs, 68594] arguments parsed: {program: /usr/local/bin/citnames, arguments: [{--input: [compile_commands.sqlite3]}, {--output: [compile_commands.json]}, {--run-checks: []}, {--verbose: []}]}
[19:51:56.796975, cs, 68594] Configuration: {"compilation":{"compilers_to_recognize":[{"executable":"../third-party/arm-toolchain/osx/7.2_2017q4/bin/arm-none-eabi-gcc"}]},"output":{"content":{"include_only_existing_source":true},"format":{"command_as_array":true,"drop_output_field":false}}}
[19:51:56.801476, cs, 68594] [pid: 68569] execution: {"executable":"/Users/user/lw-pixel2/third-party/arm-toolchain/osx/7.2_2017q4/bin/arm-none-eabi-gcc","arguments":["/Users/user/lw-pixel2/third-party/arm-toolchain/osx/7.2_2017q4/bin/arm-none-eabi-gcc","--version"],"workingDir":"/Users/user/lw-pixel2/build_system","environment”:{…}
[19:51:56.801776, cs, 68594] [pid: 68569] recognized with: GCC
[19:51:56.801810, cs, 68594] [pid: 68569] recognized as: [Query]
[19:51:56.801845, cs, 68594] compilation entries created. [size: 0]
[19:51:56.801847, cs, 68594] compilation entries to output. [size: 0]
[19:51:56.802142, cs, 68594] compilation entries written. [size: 0]
[19:51:56.802208, cs, 68594] succeeded with: 0
[19:51:56.802672, br, 68562] Process wait request: done. [pid: 68594]
[19:51:56.802717, br, 68562] Running citnames finished. [Exited with 0]
[19:51:56.802853, br, 68562] succeeded with: 0
Thanks for the quick update... it looks better to me. :) Can see that intercept
picks up the CC
from the environment. The log also shows that it sets a new CC
environment and points to the compiler wrapper. The build process now uses the cc
wrapper for a single execution.
Is the build system respects the CC
and CXX
environments? (I only see the cc --version
call, but the actual compilation is using the arm-none-eabi-gcc
compiler.) Can you check the make file is the compiler called via CC
or it's hardcoded location? Is there a way you can specify the compiler to the build?
The makefile we use uses the following pattern: we first set the toolchain in there
ARCH = $(STUDIO_ARM_GNU_DIR)/bin/arm-none-eabi-gcc-ar
AS = $(STUDIO_ARM_GNU_DIR)/bin/arm-none-eabi-gcc
CC = $(STUDIO_ARM_GNU_DIR)/bin/arm-none-eabi-gcc
CXX = $(STUDIO_ARM_GNU_DIR)/bin/arm-none-eabi-g++
ELFTOOL = $(STUDIO_ARM_GNU_DIR)/bin/arm-none-eabi-objcopy
LD = $(STUDIO_ARM_GNU_DIR)/bin/arm-none-eabi-g++
then the compile calls are
$(COBJS): %.o: %.c
@echo 'Building $(notdir $(@:%.o=%.c))...'
@$(CC) $(CFLAGS) -o $@ $<
$(CPPOBJS): %.o: %.cpp
@echo 'Building $(notdir $(@:%.o=%.cpp))...'
@$(CXX) $(CXXFLAGS) -o $@ $<
I've tried calling w/ and w/o the "@" output suppressor, but it looks for new Bear 3 it doesn't make mush difference, correct?
Hmm, interesting. I stopped reassigning the CC/CXX variables inside the makefile. And it seems it's working ;-)
That makes sense to me... Since you've been overriding the Bear set environments, it was not able to call the compiler wrappers, therefore could not intercept the calls, which ends up an empty output.
I'm closing this ticket.
Thanks!
Describe the bug Bear generates an empty compilation database when using arm-none-eabi toolchain. Already tried to --force-wrapper, but same result. Also tried to name the C/CXX compiler (using a Bear 2). SIP is off.
I'm not sure how to name the compiler in Bear 3. Bear 2 installed from macports used to work in this project about a year back when I first used it.
To Reproduce Steps to reproduce the behavior:
Sample Log
Expected behavior A clear and concise description of what you expected to happen.
Environment:
Observation I had to make the following change to build Bear in my system:
Additional context This is a SiliconLabs ARM Cortex M33 project that uses ARM bare metal toolchain (arm-none-eabi), based on a makefile build.
When building a simple Makefile project for my own architecture (gcc), Bear works.