Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lldb] Add early CMake check for 'make' tool #111531

Merged

Conversation

weliveindetail
Copy link
Contributor

Around 400 of LLDB's dotest.py based tests require the make tool to be found in Path. If it's not found, they fail with an obscure error and show up as UNRESOLVED. llvm-lit takes care of MSYS based testing tools like cat, printf, etc., but make is not part of that. Let's catch the situation early and raise an error if LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS was enabled. This error is not fatal: It should fail the build, but not immediately stop the configuration process. There might be other issues further down the line that can be caught in the same buildbot run.

Around 400 of LLDB's dotest.py based tests require the make tool to be found in Path. If it's not found, they fail with an obscure error and show up as UNRESOLVED.
llvm-lit takes care of MSYS based testing tools like cat, printf, etc., but make is not part of that. Let's catch the situation early and raise an error if LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS was enabled.
This error is not fatal: It should fail the build, but not immediately stop the configuration process. There might be other issues further down the line that can be caught in the same buildbot run.
@llvmbot
Copy link
Member

llvmbot commented Oct 8, 2024

@llvm/pr-subscribers-lldb

Author: Stefan Gränitz (weliveindetail)

Changes

Around 400 of LLDB's dotest.py based tests require the make tool to be found in Path. If it's not found, they fail with an obscure error and show up as UNRESOLVED. llvm-lit takes care of MSYS based testing tools like cat, printf, etc., but make is not part of that. Let's catch the situation early and raise an error if LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS was enabled. This error is not fatal: It should fail the build, but not immediately stop the configuration process. There might be other issues further down the line that can be caught in the same buildbot run.


Full diff: https://github.com/llvm/llvm-project/pull/111531.diff

1 Files Affected:

  • (modified) lldb/test/CMakeLists.txt (+12)
diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 5ac474736eb63d..7993be2602e538 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -29,6 +29,18 @@ if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS)
         "`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=OFF`")
     endif()
   endforeach()
+
+  # On Windows make is not part of the MSYS tools that llvm-lit takes care of
+  find_program(MAKE_TOOL make)
+  if(MAKE_TOOL)
+    message(STATUS "Found make: ${MAKE_TOOL}")
+  else()
+    message(STATUS "Not found: make")
+    message(SEND_ERROR
+          "LLDB tests require 'make' tool. Please install and add it to Path "
+          "(or otherwise disable strict testing requirements with "
+          "`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=OFF`)")
+  endif()
 endif()
 
 if(LLDB_BUILT_STANDALONE)

Copy link
Member

@JDevlieghere JDevlieghere left a comment

Choose a reason for hiding this comment

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

I like the idea of looking for Make at configuration time. However, I think if we go that route, we should pass make as an explicit argument to dotest.py:

  • We do for other tools that we find at configuration time (such as dsymutil).
  • It eliminates the possibility of dotest.py finding a different make than CMake.

Looking at dotest.py, it already supports --make so hopefully this is trivial to hook up.

@bulbazord
Copy link
Member

+1 to what Jonas said. Making dotest.py more explicit makes reproducing test behavior more reliable. :)

@weliveindetail
Copy link
Contributor Author

Thanks for the quick feedback. Yes, makes sense. Here we go.

Copy link

github-actions bot commented Oct 9, 2024

✅ With the latest revision this PR passed the Python code formatter.

Copy link
Contributor Author

@weliveindetail weliveindetail left a comment

Choose a reason for hiding this comment

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

Two notes inline

lldb/test/API/lit.cfg.py Show resolved Hide resolved
@@ -272,6 +272,8 @@ def parseOptionsAndInitTestdirs():
configuration.make_path = "gmake"
else:
configuration.make_path = "make"
if ' ' in configuration.make_path:
configuration.make_path = f'"{configuration.make_path}"'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The default install path on Windows is C:\Program Files (x86)\GnuWin32\bin\make.exe unfortunately.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That may be fine, but I think this is the wrong place to quote it. I think it should happen somewhere around the place where this variable is concatenated into a string (or passed to whatever it is that requires it to be quoted).

That said, after tracing this variable, I'm a little unsure as to why is this needed. IIUC, this eventually makes its way to the subprocess.check_output call here, which should be able to handle quoting on its own.

Can you explain what the problem was without this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this because yesterday my tests failed with:

'C:/Program' is not recognized as an internal or external command,
operable program or batch file.

I double-checked again today and this doesn't happen anymore. I am not sure why, maybe I had an inconsistent configuration state. The parameter for dotest.py is --make C:/Program Files (x86)/GnuWin32/bin/make.exe and the command that lldbtest.py runs is starting with C:/Program Files (x86)/GnuWin32/bin/make.exe VPATH=.... I cleared the cached in lldb-test-build.noindex and checked sure the binaries are recreated successfully by the test suite. It works without the quotes.

I am attaching a log file TestBreakpointByLineAndColumn.log with the commands dumped for future reference. I will the quoting and assume it just keeps working.

Copy link
Member

@JDevlieghere JDevlieghere left a comment

Choose a reason for hiding this comment

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

LGTM with detection hoisted.

lldb/test/CMakeLists.txt Outdated Show resolved Hide resolved
lldb/test/CMakeLists.txt Outdated Show resolved Hide resolved
@weliveindetail weliveindetail merged commit 0e91323 into llvm:main Oct 10, 2024
5 of 6 checks passed
weliveindetail added a commit to weliveindetail/llvm-project that referenced this pull request Oct 10, 2024
Many LLDB's dotest.py based tests require the `make` tool. If it's not found in Path, they fail with an obscure error and show up as `UNRESOLVED`. On Windows, llvm-lit takes care of MSYS based testing tools like cat, printf, etc., but `make` is not part of that. Let's catch the situation early and check for it at configuration time.

This error isn't fatal: It should fail the build, but not immediately stop the configuration process. There might be other issues further down the line that can be caught in the same buildbot run.
@weliveindetail weliveindetail deleted the lldb-test-check-make-upstream branch October 10, 2024 18:22
DavidSpickett added a commit that referenced this pull request Oct 11, 2024
Fixes 0e91323 /
#111531

For reasons I can't explain, a clean build works fine for me, and all
the bots are working fine. But if I rebuild in some way the make tool
becomes None.

Looking at the other variables, they had these extra lines so I've added
those for make and it seems to solve the problem.
@zeroomega
Copy link
Contributor

Hi,

I noticed that our LLDB Windows builders all failed after this change is landed:

CMake Error at C:/b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/CMakeLists.txt:60 (message):
   LLDB tests require 'make' tool.  Please pass via `LLDB_TEST_MAKE` (or
   otherwise disable tests with `LLDB_INCLUDE_TESTS=OFF`)

We are aware our windows bots don't have make tool and we are not planning to add it anyway. Not all lldb tests require make to run and it feels wrong to me to mandate make tool for a few tests that requires it. Could it be changed to disable such tests when make is not present instead of throw an error to prevent the lldb build?

@JDevlieghere
Copy link
Member

Not all lldb tests require make to run and it feels wrong to me to mandate make tool for a few tests that requires it.

All the API tests build their inferior with Make and looking at the last successful run on Windows, we have 1206 API tests, 561 shell tests and 261 unit tests. Even if we only consider the ones that are passing, the API tests are still the vast majority. I'm not sure how you come to the conclusion that only "a few tests" require it?

@zeroomega
Copy link
Contributor

Not all lldb tests require make to run and it feels wrong to me to mandate make tool for a few tests that requires it.

All the API tests build their inferior with Make and looking at the last successful run on Windows, we have 1206 API tests, 561 shell tests and 261 unit tests. Even if we only consider the ones that are passing, the API tests are still the vast majority. I'm not sure how you come to the conclusion that only "a few tests" require it?

Fine, let me just disable windows tests on our bots all together.

@weliveindetail
Copy link
Contributor Author

In fact, I ran into that on Friday myself. I checked LLDB_INCLUDE_TESTS=Off in my setup and it appeared to be incompatible with LLDB_ENABLE_PYTHON=On if lldb-python is part of LLVM_DISTRIBUTION_COMPONENTS. The error said something like lldb-python-scripts is lacking an install-stripped target. I couldn't fix that quickly and just wired up the LLDB_TEST_MAKE config.

@zeroomega Any similar experiences with LLDB_INCLUDE_TESTS=Off?

@zeroomega
Copy link
Contributor

In fact, I ran into that on Friday myself. I checked LLDB_INCLUDE_TESTS=Off in my setup and it appeared to be incompatible with LLDB_ENABLE_PYTHON=On if lldb-python is part of LLVM_DISTRIBUTION_COMPONENTS. The error said something like lldb-python-scripts is lacking an install-stripped target. I couldn't fix that quickly and just wired up the LLDB_TEST_MAKE config.

@zeroomega Any similar experiences with LLDB_INCLUDE_TESTS=Off?

No, I didn't see this issue. Our build passed after I set LLDB_INCLUDE_TESTS=Off on our Windows bots. But we also didn't set lldb-python in LLVM_DISTRIBUTION_COMPONENTS. We do have lldb-python-scripts. You can see our cmake invocation here:
https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket/8734080863088320417/+/u/build_and_install_lldb/configure/l_execution_details

weliveindetail added a commit that referenced this pull request Oct 15, 2024
…2342)

In recent PR #111531 for
Windows support, we enabled tests that require the `make` tool. On
Windows, default install directories likely contain spaces, in this case
e.g. `C:\Program Files (x86)\GnuWin32\bin\make.exe`. It's typically
handled well by CMake, so that today invocations from `dotest.py` don't
cause issues. However, we also have nested invocations from a number of
Makefiles themselves. These still failed if the path to the `make` tool
contains spaces.

This patch attempts to fix the functionalities/completion test by adding
quotes in the respective Makefile. If it keeps passing on the bots, we can
roll out the fix to all affected tests.
bricknerb pushed a commit to bricknerb/llvm-project that referenced this pull request Oct 16, 2024
…m#112342)

In recent PR llvm#111531 for
Windows support, we enabled tests that require the `make` tool. On
Windows, default install directories likely contain spaces, in this case
e.g. `C:\Program Files (x86)\GnuWin32\bin\make.exe`. It's typically
handled well by CMake, so that today invocations from `dotest.py` don't
cause issues. However, we also have nested invocations from a number of
Makefiles themselves. These still failed if the path to the `make` tool
contains spaces.

This patch attempts to fix the functionalities/completion test by adding
quotes in the respective Makefile. If it keeps passing on the bots, we can
roll out the fix to all affected tests.
DanielCChen pushed a commit to DanielCChen/llvm-project that referenced this pull request Oct 16, 2024
Many LLDB's dotest.py based tests require the `make` tool. If it's not found in Path, they fail with an obscure error and show up as `UNRESOLVED`. On Windows, llvm-lit takes care of MSYS based testing tools like cat, printf, etc., but `make` is not part of that. Let's catch the situation early and check for it at configuration time.

This error isn't fatal: It should fail the build, but not immediately stop the configuration process. There might be other issues further down the line that can be caught in the same buildbot run.
DanielCChen pushed a commit to DanielCChen/llvm-project that referenced this pull request Oct 16, 2024
Fixes 0e91323 /
llvm#111531

For reasons I can't explain, a clean build works fine for me, and all
the bots are working fine. But if I rebuild in some way the make tool
becomes None.

Looking at the other variables, they had these extra lines so I've added
those for make and it seems to solve the problem.
DanielCChen pushed a commit to DanielCChen/llvm-project that referenced this pull request Oct 16, 2024
…m#112342)

In recent PR llvm#111531 for
Windows support, we enabled tests that require the `make` tool. On
Windows, default install directories likely contain spaces, in this case
e.g. `C:\Program Files (x86)\GnuWin32\bin\make.exe`. It's typically
handled well by CMake, so that today invocations from `dotest.py` don't
cause issues. However, we also have nested invocations from a number of
Makefiles themselves. These still failed if the path to the `make` tool
contains spaces.

This patch attempts to fix the functionalities/completion test by adding
quotes in the respective Makefile. If it keeps passing on the bots, we can
roll out the fix to all affected tests.
weliveindetail added a commit to weliveindetail/llvm-project that referenced this pull request Oct 16, 2024
Many LLDB's dotest.py based tests require the `make` tool. If it's not found in Path, they fail with an obscure error and show up as `UNRESOLVED`. On Windows, llvm-lit takes care of MSYS based testing tools like cat, printf, etc., but `make` is not part of that. Let's catch the situation early and check for it at configuration time.

This error isn't fatal: It should fail the build, but not immediately stop the configuration process. There might be other issues further down the line that can be caught in the same buildbot run.
bricknerb pushed a commit to bricknerb/llvm-project that referenced this pull request Oct 17, 2024
Fixes 0e91323 /
llvm#111531

For reasons I can't explain, a clean build works fine for me, and all
the bots are working fine. But if I rebuild in some way the make tool
becomes None.

Looking at the other variables, they had these extra lines so I've added
those for make and it seems to solve the problem.
bricknerb pushed a commit to bricknerb/llvm-project that referenced this pull request Oct 17, 2024
…m#112342)

In recent PR llvm#111531 for
Windows support, we enabled tests that require the `make` tool. On
Windows, default install directories likely contain spaces, in this case
e.g. `C:\Program Files (x86)\GnuWin32\bin\make.exe`. It's typically
handled well by CMake, so that today invocations from `dotest.py` don't
cause issues. However, we also have nested invocations from a number of
Makefiles themselves. These still failed if the path to the `make` tool
contains spaces.

This patch attempts to fix the functionalities/completion test by adding
quotes in the respective Makefile. If it keeps passing on the bots, we can
roll out the fix to all affected tests.
weliveindetail added a commit to weliveindetail/llvm-project that referenced this pull request Oct 17, 2024
…m#112342)

In recent PR llvm#111531 for
Windows support, we enabled tests that require the `make` tool. On
Windows, default install directories likely contain spaces, in this case
e.g. `C:\Program Files (x86)\GnuWin32\bin\make.exe`. It's typically
handled well by CMake, so that today invocations from `dotest.py` don't
cause issues. However, we also have nested invocations from a number of
Makefiles themselves. These still failed if the path to the `make` tool
contains spaces.

This patch attempts to fix the functionalities/completion test by adding
quotes in the respective Makefile. If it keeps passing on the bots, we can
roll out the fix to all affected tests.
@GkvJwa
Copy link
Contributor

GkvJwa commented Oct 21, 2024

In fact, for many developers on Windows, make.exe will not be in the environment PATH, which will cause cmake to fail to find and ultimately delay the build of the project error.
I personally think it is better to use FATAL_ERROR instead of SEND_ERROR. After all, it will cause cmake to continue executing for a short period of time and finally display

CMake Error at C:/llvm-project/lldb/test/API/CMakeLists.txt:60 (message):
  LLDB tests require 'make' tool.  Please pass via `LLDB_TEST_MAKE` (or
  otherwise disable tests with `LLDB_INCLUDE_TESTS=OFF`)


-- BugpointPasses ignored -- Loadable modules not supported on this platform.
-- Google Benchmark version: v0.0.0, normalized to 0.0.0
-- Looking for shm_open in rt
-- Looking for shm_open in rt - not found
-- Performing Test HAVE_CXX_FLAG_EHS_
-- Performing Test HAVE_CXX_FLAG_EHS_ - Success
-- Performing Test HAVE_CXX_FLAG_EHA_
-- Performing Test HAVE_CXX_FLAG_EHA_ - Success
-- Compiling and running to test HAVE_GNU_POSIX_REGEX
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
-- Compiling and running to test HAVE_POSIX_REGEX
-- Performing Test HAVE_POSIX_REGEX -- failed to compile
CMake Warning at C:/llvm-project/third-party/benchmark/CMakeLists.txt:319 (message):
  Using std::regex with exceptions disabled is not fully supported


-- Compiling and running to test HAVE_STEADY_CLOCK
-- Performing Test HAVE_STEADY_CLOCK -- success
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE
-- Compiling and running to test HAVE_PTHREAD_AFFINITY
-- Performing Test HAVE_PTHREAD_AFFINITY -- failed to compile
-- Configuring incomplete, errors occurred!

Of course, a better way may be to search in advance, and if not, automatically close TEST

@weliveindetail
Copy link
Contributor Author

I think it's valuable to get the full config log on buildbots. If this check becomes too much of a burden, I'd rather propose to either turn the error into a warning or revisit the option to guard it by LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS (see my original patch for details). What about that? @GkvJwa

@GkvJwa
Copy link
Contributor

GkvJwa commented Oct 22, 2024

I think it's valuable to get the full config log on buildbots. If this check becomes too much of a burden, I'd rather propose to either turn the error into a warning or revisit the option to guard it by LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS (see my original patch for details). What about that? @GkvJwa

Personally, warnings are better than errors for developers

EricWF pushed a commit to efcs/llvm-project that referenced this pull request Oct 22, 2024
…m#112342)

In recent PR llvm#111531 for
Windows support, we enabled tests that require the `make` tool. On
Windows, default install directories likely contain spaces, in this case
e.g. `C:\Program Files (x86)\GnuWin32\bin\make.exe`. It's typically
handled well by CMake, so that today invocations from `dotest.py` don't
cause issues. However, we also have nested invocations from a number of
Makefiles themselves. These still failed if the path to the `make` tool
contains spaces.

This patch attempts to fix the functionalities/completion test by adding
quotes in the respective Makefile. If it keeps passing on the bots, we can
roll out the fix to all affected tests.
weliveindetail added a commit that referenced this pull request Oct 23, 2024
#111531)

Bot maintainers should be aware and it became too much of a burden
for developers. In particular on Windows, where make.exe won't be
found in Path typically.
@weliveindetail
Copy link
Contributor Author

Yes, for devs it might be too much of a burden and eventually bot maintainers should be aware. If we want the error behavior back, we could make it conditional on LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS. For now I didn't want to make it more complicated than necessary.

DavidSpickett added a commit to DavidSpickett/llvm-project that referenced this pull request Oct 24, 2024
Fixes 0e91323 /
llvm#111531

For reasons I can't explain, a clean build works fine for me, and all
the bots are working fine. But if I rebuild in some way the make tool
becomes None.

Looking at the other variables, they had these extra lines so I've added
those for make and it seems to solve the problem.
@frobtech frobtech mentioned this pull request Oct 25, 2024
NoumanAmir657 pushed a commit to NoumanAmir657/llvm-project that referenced this pull request Nov 4, 2024
llvm#111531)

Bot maintainers should be aware and it became too much of a burden
for developers. In particular on Windows, where make.exe won't be
found in Path typically.
weliveindetail added a commit to weliveindetail/llvm-project that referenced this pull request Nov 5, 2024
Many LLDB's dotest.py based tests require the `make` tool. If it's not found in Path, they fail with an obscure error and show up as `UNRESOLVED`. On Windows, llvm-lit takes care of MSYS based testing tools like cat, printf, etc., but `make` is not part of that. Let's catch the situation early and check for it at configuration time.

This error isn't fatal: It should fail the build, but not immediately stop the configuration process. There might be other issues further down the line that can be caught in the same buildbot run.
weliveindetail added a commit to weliveindetail/llvm-project that referenced this pull request Nov 5, 2024
…m#112342)

In recent PR llvm#111531 for
Windows support, we enabled tests that require the `make` tool. On
Windows, default install directories likely contain spaces, in this case
e.g. `C:\Program Files (x86)\GnuWin32\bin\make.exe`. It's typically
handled well by CMake, so that today invocations from `dotest.py` don't
cause issues. However, we also have nested invocations from a number of
Makefiles themselves. These still failed if the path to the `make` tool
contains spaces.

This patch attempts to fix the functionalities/completion test by adding
quotes in the respective Makefile. If it keeps passing on the bots, we can
roll out the fix to all affected tests.
weliveindetail added a commit to weliveindetail/llvm-project that referenced this pull request Nov 6, 2024
Many LLDB's dotest.py based tests require the `make` tool. If it's not found in Path, they fail with an obscure error and show up as `UNRESOLVED`. On Windows, llvm-lit takes care of MSYS based testing tools like cat, printf, etc., but `make` is not part of that. Let's catch the situation early and check for it at configuration time.

This error isn't fatal: It should fail the build, but not immediately stop the configuration process. There might be other issues further down the line that can be caught in the same buildbot run.
weliveindetail added a commit to weliveindetail/llvm-project that referenced this pull request Nov 6, 2024
…m#112342)

In recent PR llvm#111531 for
Windows support, we enabled tests that require the `make` tool. On
Windows, default install directories likely contain spaces, in this case
e.g. `C:\Program Files (x86)\GnuWin32\bin\make.exe`. It's typically
handled well by CMake, so that today invocations from `dotest.py` don't
cause issues. However, we also have nested invocations from a number of
Makefiles themselves. These still failed if the path to the `make` tool
contains spaces.

This patch attempts to fix the functionalities/completion test by adding
quotes in the respective Makefile. If it keeps passing on the bots, we can
roll out the fix to all affected tests.
weliveindetail added a commit to weliveindetail/llvm-project that referenced this pull request Nov 27, 2024
Many LLDB's dotest.py based tests require the `make` tool. If it's not found in Path, they fail with an obscure error and show up as `UNRESOLVED`. On Windows, llvm-lit takes care of MSYS based testing tools like cat, printf, etc., but `make` is not part of that. Let's catch the situation early and check for it at configuration time.

This error isn't fatal: It should fail the build, but not immediately stop the configuration process. There might be other issues further down the line that can be caught in the same buildbot run.
weliveindetail added a commit to weliveindetail/llvm-project that referenced this pull request Nov 27, 2024
…m#112342)

In recent PR llvm#111531 for
Windows support, we enabled tests that require the `make` tool. On
Windows, default install directories likely contain spaces, in this case
e.g. `C:\Program Files (x86)\GnuWin32\bin\make.exe`. It's typically
handled well by CMake, so that today invocations from `dotest.py` don't
cause issues. However, we also have nested invocations from a number of
Makefiles themselves. These still failed if the path to the `make` tool
contains spaces.

This patch attempts to fix the functionalities/completion test by adding
quotes in the respective Makefile. If it keeps passing on the bots, we can
roll out the fix to all affected tests.
weliveindetail added a commit to weliveindetail/llvm-project that referenced this pull request Dec 4, 2024
llvm#111531)

Bot maintainers should be aware and it became too much of a burden
for developers. In particular on Windows, where make.exe won't be
found in Path typically.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants