Skip to content

Conversation

guitargeek
Copy link
Contributor

@guitargeek guitargeek commented Aug 30, 2025

Instead of running the root ... <macro>.C+ build step as the command
associated with a custom CMake target, just run the command directly in
the test added with add_test.

This simplification is possible because for the custom CMake target, no
dependencies are ever specified. This makes building it not different
from just running the underlying command directly.

Do some further CMake code simplifications in a second commit (more detail in the commit description).

Copy link

github-actions bot commented Aug 30, 2025

Test Results

    19 files      19 suites   3d 9h 1m 51s ⏱️
 3 658 tests  3 656 ✅   0 💤 2 ❌
67 869 runs  67 767 ✅ 100 💤 2 ❌

For more details on these failures, see this check.

Results for commit c273e07.

♻️ This comment has been updated with latest results.

Copy link
Member

@hahnjo hahnjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrapping to command inside a Cmake target doesn't seem to be necessary, because in the test, the target is forced to be built without dependencies anyway (e.g. cmake --build . --target my_macro_test/fast --always-make when using makefiles).

This is only partially true, for Unix Makefiles. With Ninja, we don't use /fast nor --always-make AFAICT

@guitargeek
Copy link
Contributor Author

The intention of the original macro is apparently to only build this one target that runs the command. The fact that this was not done correctly for Ninja doesn't mean that rebuilding all dependencies was the intended behavior. I suppose it was just not correctly implemented.

@@ -2340,36 +2340,18 @@ macro(ROOTTEST_COMPILE_MACRO filename)
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

if(ARG_DEPENDS)
set(deps ${ARG_DEPENDS})
message(WARNING "Specifying DEPENDS in ROOTTEST_COMPILE_MACRO has no effect.")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this warning is never hit. Nowhere in the codebase to we specify DEPENDS in a ROOTTEST_COMPILE_MACRO. Together with the dependencies being ignored via the \fast target when using Makefiles, that makes it clear to me that it was never the intention to have dependencies for these macro tests.

The problem is that even with no dependencies, a re-configuration will still be triggered if the CMake code was changed, which is the reason thy the RUN_SERIAL true workaround was needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to suggest removing DEPENDS from the allowed arguments altogether.

@hahnjo
Copy link
Member

hahnjo commented Sep 4, 2025

In principle makes sense to me; maybe rephrase the first commit message because it still sounds wrong that dependencies would be ignored "anyway".

Also adding @hageboeck because it's related to #19702

Copy link
Member

@hageboeck hageboeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the explanation confusing. I'll come discuss this in person.

@@ -2340,36 +2340,18 @@ macro(ROOTTEST_COMPILE_MACRO filename)
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

if(ARG_DEPENDS)
set(deps ${ARG_DEPENDS})
message(WARNING "Specifying DEPENDS in ROOTTEST_COMPILE_MACRO has no effect.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to suggest removing DEPENDS from the allowed arguments altogether.

Instead of running the `root ... <macro>.C+` build step as the command
associated with a custom CMake target, just run the command directly in
the test added with `add_test`.

This simplification is possible because for the custom CMake target, no
dependencies are ever specified. This makes building it not different
from just running the underlying command directly.
  * Remove preprocessor variables that were always defined and hence
    carried no information

  * Add include path and library path via environment variables

  * Remove redundant `gROOT->SetMacroPath()` call with path to source
    directory, because the `${realfp}` variable passed to the `build.C`
    script already contains the full path
Copy link
Member

@hageboeck hageboeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much clearer, thank you!

@@ -75,9 +75,6 @@ void build(const char *filename, const char *lib = 0, const char *obj = 0, const
}
// fprintf(stderr,"from %s to %s\n",filename,fname.Data());
int result = gSystem->CompileMacro(fname,"kc");
#elif defined(CMakeEnvironment) && defined(CMakeBuildDir)
// fprintf(stderr,"CmakeBuildDir: %s filename: %s", CMakeBuildDir, filename);
int result = gSystem->CompileMacro(filename,"kc-", libname, CMakeBuildDir);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be an unintentional behavior change. If I read correctly, before this PR, ROOTTEST_COMPILE_MACRO was always setting CMakeEnvironment and CMakeBuildDir and thus always passing "kc-", while it now passes "only" "kc" thus removing the - and changing the output directory layout.

@pcanal
Copy link
Member

pcanal commented Sep 5, 2025

Simplify ROOTTEST_COMPILE_MACRO to shorten test command
Add include path and library path via environment variables

How does switching from an argument to an environment variable concretely help? If one ever tries to reproduce the failing compilation 'exactly', one now needs to copy paste (the extended version of):

      ROOT_LIBRARY_PATH="${CMAKE_CURRENT_BINARY_DIR}"
      ROOT_INCLUDE_PATH="${CMAKE_CURRENT_BINARY_DIR}"
      ${ROOT_root_CMD}
      -e "gSystem->SetBuildDir(\"${CMAKE_CURRENT_BINARY_DIR}\", true)"
      ${RootMacroDirDefines}
      -q -l -b ....

instead of the extended version of:

      ${ROOT_root_CMD}
      -e "gSystem->AddDynamicPath(\"${CMAKE_CURRENT_BINARY_DIR}\")"
      -e "gInterpreter->AddIncludePath(\"-I${CMAKE_CURRENT_BINARY_DIR}\")"
      -e "gSystem->SetBuildDir(\"${CMAKE_CURRENT_BINARY_DIR}\", true)"
      ${RootMacroDirDefines}
      -q -l -b ... 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clean build Ask CI to do non-incremental build on PR in:Build System
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants