Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are RUN_HAVE_STD_REGEX, RUN_HAVE_POSIX_REGEX and RUN_HAVE_STEADY_CLOCK for?

Tags:

grpc

In gRPC, when building for arm, I need to disable those three variables:

-DRUN_HAVE_STD_REGEX=OFF
-DRUN_HAVE_POSIX_REGEX=OFF
-DRUN_HAVE_STEADY_CLOCK=OFF

It is not super clear to me what they do, so I wonder:

  1. Why is it that CMake cannot detect them automatically when cross-compiling?
  2. What is the impact of disabling them, say on a system that does support them? Will it sometimes crash? Reduce performances in some situations?

Because they are not auto-detected by CMake, it would be easier for me to always disable them if that works everywhere without major issues for my use-case.

like image 984
JonasVautherin Avatar asked Sep 17 '25 11:09

JonasVautherin


1 Answers

gRPC uses CMake's try_run to automatically detect if the platform supports a feature when cross-compiling. However, some variables need to be supplied manually. From the documentation (emphasis added):

When cross compiling, the executable compiled in the first step usually cannot be run on the build host. The try_run command checks the CMAKE_CROSSCOMPILING variable to detect whether CMake is in cross-compiling mode. If that is the case, it will still try to compile the executable, but it will not try to run the executable unless the CMAKE_CROSSCOMPILING_EMULATOR variable is set. Instead it will create cache variables which must be filled by the user or by presetting them in some CMake script file to the values the executable would have produced if it had been run on its actual target platform.

Basically, it's saying that CMake won't try to run the compiled executable on the build machine unless some test results are specified manually (test which would have been run on the target machine). The below tests will usually cause problems:

-DRUN_HAVE_STD_REGEX
-DRUN_HAVE_GNU_POSIX_REGEX
-DRUN_HAVE_POSIX_REGEX
-DRUN_HAVE_STEADY_CLOCK

Hopefully that answers your first question. I do not know how to answer your second question, as I have always just set those variables manually to match the features of whatever system I've compiled for.

like image 103
Das_Geek Avatar answered Sep 19 '25 08:09

Das_Geek