reclient icon indicating copy to clipboard operation
reclient copied to clipboard

How to use scandeps_server to auto-get the c/c++ includes

Open Zhoucaijie opened this issue 2 years ago • 2 comments

Hello everyone! I want to use reclient as an client and connect to buildfarm for remote execution.

  • Start the reproxy:
./bootstrap -cfg=/path/to/reproxy.cfg

The reproxy.cfg is:

service=xx.xxx.xxx.xxx:xxx
server_address=unix:///tmp/reproxy.sock
instance=main
fail_early_min_action_count=4000
fail_early_min_fallback_ratio=0.5
service_no_security=true
service_no_auth=true
use_rpc_credentials=false
use_gce_credentials=false 
use_application_default_credentials=false 
output_dir=/path/to/out 
proxy_log_dir=/path/to/out
  • Wrap the gcc:
CC=$(rewrapper_path) -cfg=$(rewrapper_cfg_path) gcc

CFLAGS=-I. -I/usr/lib/gcc/x86_64-linux-gnu/11/include
OBJ = hellomake.o hellofunc.o

%.o:%.c
        $(CC) -c $(CFLAGS) -o $@ $<
hellomake: $(OBJ)
        $(CC) -o $@ $^

The rewrapper.cfg is:

exec_strategy=remote
server_address=unix:///tmp/reproxy.sock
exec_root=/path/to/reclient_test
inputs=hellofunc.c,hellomake.c
output_files=hellofunc.o,hellomake.o
download_outputs=true

I hope that the scandeps_server in the same directory as reproxy can search and upload the includes of .c files to buildfarm. However, the remote execution returns error as:

hellomake.c:1:9: fatal error: hellomake.h: No such file or directory
    1 | #include<hellomake.h>
      |         ^~~~~~~~~~~~~
compilation terminated.
make: *** [makefile:11: hellomake.o] Error 1

where, hellomake.h is in the exec_root. If I want to successfully implement a remote build, I have to add all needed srcs and headers to the -inputs, but the included headers are often difficult to obtain in advance. The directory structure of the demo is as follows:

|-- hellofunc.c
|-- hellomake.c
|-- hellomake.h
|-- makefile
|-- out
`-- rbe
    |-- bin
    |   |-- bigquery
    |   |-- bootstrap
    |   |-- downloadmismatch
    |   |-- dumpstats
    |   |-- logdump
    |   |-- metricsuploader
    |   |-- reclientreport
    |   |-- reproxy
    |   |-- reproxystatus
    |   |-- reproxytool
    |   |-- rewrapper
    |   |-- rpl2cloudtrace
    |   |-- rpl2trace
    |   `-- scandeps_server
    `-- configs
        |-- reproxy.cfg
        `-- rewrapper.cfg

How to use reclient without setting rewrapper's -inputs and -output_files parameters?

Zhoucaijie avatar Nov 23 '23 09:11 Zhoucaijie

Have you specific the depsscanner_address in the reproxy config file? If you haven't you have to set it in the config file like so: depsscanner_address=exec://$absolute_path_to_reclient_dir/scandeps_server

nqcuongit95 avatar Nov 27 '23 03:11 nqcuongit95

Have you specific the depsscanner_address in the reproxy config file? If you haven't you have to set it in the config file like so: depsscanner_address=exec://$absolute_path_to_reclient_dir/scandeps_server

Thanks a lot, this issue can be solved by placing the scandeps_server binary in the same dir of reproxy。However, there is another issue that the scandeps_server binary can't find the system headers.

A system headers in the path of clang toolchain clang/linux-x86_64/llvm/lib/clang/15.0.4/include/stdint.h by #include <stdint.h> can not be found.

Zhoucaijie avatar Mar 27 '24 09:03 Zhoucaijie