-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb][test] Prefer gmake to make and warn for potentially non-GNU make #119573
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
Conversation
@llvm/pr-subscribers-lldb Author: David Spickett (DavidSpickett) Changesgmake is GNU make where make is not GNU compatible. This leads to a lot of tests failing to build
See https://cmake.org/cmake/help/latest/variable/CMAKE_SYSTEM_NAME.html for the platform names. Tested on Linux and FreeBSD. Not tested on NetBSD, but the logic was always "if netbsd or freebsd use gmake" so I think I'm safe to assume NetBSD will be fine with this. Full diff: https://github.com/llvm/llvm-project/pull/119573.diff 1 Files Affected:
diff --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt
index 36f4973ad9a452..66eccff297a999 100644
--- a/lldb/test/API/CMakeLists.txt
+++ b/lldb/test/API/CMakeLists.txt
@@ -52,11 +52,18 @@ set(LLDB_DEFAULT_TEST_DSYMUTIL "${LLVM_TOOLS_BINARY_DIR}/dsymutil${CMAKE_EXECUTA
if(LLDB_TEST_MAKE)
set(LLDB_DEFAULT_TEST_MAKE ${LLDB_TEST_MAKE})
else()
- find_program(LLDB_DEFAULT_TEST_MAKE make gmake)
+ set(MAKE_NAMES "gmake")
+
+ # "make" on FreeBSD and NetBSD is not GNU make compatible.
+ if(NOT CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND NOT CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
+ list(APPEND MAKE_NAMES "make")
+ endif()
+
+ find_program(LLDB_DEFAULT_TEST_MAKE NAMES ${MAKE_NAMES})
if(LLDB_DEFAULT_TEST_MAKE)
message(STATUS "Found make: ${LLDB_DEFAULT_TEST_MAKE}")
else()
- message(STATUS "Not found: make")
+ message(STATUS "Did not find one of: ${MAKE_NAMES}")
message(WARNING
"Many LLDB API tests require 'make' tool. Please provide it in Path "
"or pass via LLDB_TEST_MAKE.")
|
We could say we require a "GNU compatible" make but I didn't want to get into the weeds of whether Mac's make is technically GNU compatible or just happens to have all the features we need. This change makes FreeBSD work out of the box, that's the key goal here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I believe there was a condition like that in my patch that introduced the check. And then I simplified it.
So, now the problem is that FreeBSD has both, make and gmake, and when we pick up make, the tests fail right? Wouldn't it be sufficient to change the order?
find_program(LLDB_DEFAULT_TEST_MAKE gmake make)
The only difference to your proposed change is that it would silently pick up make on the BSDs if gmake isn't found (like today).
However, it shows an issue that is a concern actually: Do we really want to prefer gmake over make on all platforms? Not sure which platforms actually have it, but it feels incorrect. Why not do something like this?
if (FreeBSD or NetBSD)
find_program(LLDB_DEFAULT_TEST_MAKE gmake)
else()
find_program(LLDB_DEFAULT_TEST_MAKE make gmake)
endif()
It will fix the build on FreeBSD where you have Though. It is a warning when we don't find a make at all. So you could argue that we should accept So yes maybe gmake only on those systems is a bit harsh.
I'm assuming anything that has "gmake" it'll be a GNU compatible make, or at least more compatible than "make. I could just switch the order. Prefer gmake on BSDs, prefer make everywhere else. Which is effectively what was happening before your patch, and it means you can still build on BSD without having to install gmake. At the cost of weird errors maybe. I'll add a warning on BSD that we've found |
4bec90c
to
aa3c542
Compare
I've updated it so that we prefer gmake on the BSDs, but we will use make if we cannot find gmake. Everywhere else we prefer make instead. If we can't find a gmake on BSD we will warn but not error. Which means you can build on a fresh FreeBSD without installing gmake. The tests won't build, but at least if they look at the cmake log / we ask them for the cmake log, there will be an obvious warning to explain the reason. |
I'm going to jump in here, since I think this was my idea. :) I actually believe that preferring Conditionalizing it on the platform (particularly on the target platform) seems wrong. I think it be better to stick to the "gmake, make" order, and then check whether the thing we found was actually a GNU make (through
FWIW, the Mac make is not just "GNU compatible". It is GNU:
(amusingly it thinks it's an i386 binary even though I'm running an arm macbook) |
I thought they would have switched to a BSD make but perhaps this is left over. Ok cool then I just need to check a few --version to see what we can look for. |
aa3c542
to
d04d592
Compare
I've updated it as suggested. The non-GNU check isn't great but as long as it isn't spamming the build logs it should be ok. FreeBSD make's --version is just an empty string (odd, but ok) and all the GNU makes I tried start with "GNU Make". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks.
System make on FreeBSD is missing some GNU make features so out of the box you get a lot of: ``` make: "<...>/Makefile.rules" line 569: Invalid line type ``` You can install gmake which is a port of GNU make to solve this. However because we prefer 'make', it still won't be found. To fix that, prefer 'gmake'. Also check (as best we can) that the make we found is GNU make. This won't be perfect but it's better than the cryptic error shown above.
d04d592
to
42fe1cb
Compare
I was using RHEL9 today and it has gmake and make but they are both GNU make. So I think we're safe using gmake if we find it. |
On my system (Gentoo),
I'd be willing to bet that the version of the code before this patch (which preferred (In other words, I agree with you :) ) |
System make on FreeBSD is missing some GNU make features so out of the box you get a lot of:
To solve this, you can install gmake which is a port of GNU make. However because we prefer 'make', gmake won't be used unless you set LLDB_TEST_MAKE.
To fix that, prefer 'gmake'. Also check (as best we can) that the make we found is GNU make. This won't be perfect but it's better than the cryptic error shown above.
When a make isn't found at all, the warning message will show the names we tried: