Skip to content

Commit

Permalink
[#15649] build: fix auto re-running cmake
Browse files Browse the repository at this point in the history
Summary:
When a cmake file is updated, ninja automatically triggers rerun of
cmake.  However, that rerun fails because cmake runs with remote build
enabled, which messes up some output parsing.  A workaround is to use
the --frcm option for yb_build.sh because yb_build.sh sets
YB_REMOTE_COMPILATION=0 before running cmake.

If not using the workaround, ninja runs cmake, and by that point, it is
too late to disable remote compilation from an upper layer.  So tackle
the problem at the compiler wrapper invocation level.

The ninja RERUN_CMAKE rule runs

    cmake --regenerate-during-build ...

which runs

    compiler-wrappers/c++ -v

which is symlinked to compiler-wrapper.sh.  The wrapper runs the command
remotely or locally depending on parameters such as command line
arguments.  Change the logic to run this command (and other similar
ones) locally so that the version is parsed successfully.

Close: #15649

Test Plan:
Jenkins: compile only

The following is a script to update a cmake file (to trigger auto-re-run
cmake) then observe processes during build.  When run in an environment
where remote build (via ssh) is available, the output should initially
show the "c++ -v" command without ssh and then most regular compilation
commands using ssh.

    #!/usr/bin/env bash
    echo '#' >>CMakeLists.txt
    ./yb_build.sh &
    while true; do
      pid=$(pgrep -f yb_build | head -1)
      if [ -n "$pid" ]; then
        pstree -aps "$pid" | grep -PC3 '(c\+\+ -v|ssh)' | grep -v grep
      fi
    done

Reviewers: mbautin, steve.varnau

Reviewed By: steve.varnau

Subscribers: ybase, devops

Differential Revision: https://phabricator.dev.yugabyte.com/D22204
  • Loading branch information
jaki committed Jan 12, 2023
1 parent a93f2c1 commit ae68668
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion build-support/compiler-wrappers/compiler-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@ fi
if [[ $local_build_only == "false" &&
${YB_REMOTE_COMPILATION:-} == "1" &&
$is_build_worker == "false" &&
$lld_linking == "false" ]]; then
$lld_linking == "false" ]] &&
! is_configure_mode_invocation; then

trap remote_build_exit_handler EXIT

Expand Down

0 comments on commit ae68668

Please sign in to comment.