-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
cmake: lookup strip tool and set CMAKE_STRIP for host-gnu target #51837
cmake: lookup strip tool and set CMAKE_STRIP for host-gnu target #51837
Conversation
Fixes: zephyrproject-rtos#51821 Set CMAKE_STRIP using `find_program(CMAKE_STRIP strip)` to support strip when building on native posix. Signed-off-by: Torsten Rasmussen <[email protected]>
Thanks @tejlmand for the very prompt fix. Any idea why running cmake twice worked around this problem? Could there be other differences between running cmake once versus twice? |
Trying to answer myself after some I think the design issue here is: I suspect the reason why running CMake twice avoided bug #51821 is because of some "race" to between I think some Messing with CMake's INTERNAL variables feels like a really bad idea. |
Not correct, those variables are perfectly valid to set and are often required to be set in a cross compilation environment. But it is correct, that if you don't specify them, then CMake will try to look up a host tool.
No, the reason it worked on a second run is because CMake will lookup the tool and set it in the CMake cache if it has not been set already by the system. However, CMake did this after we had used it for the external command call. Therefore, on a second CMake run, the Zephyr build system would be using the value that is now present in the CMake cache, but on the first run it was empty. |
Thanks @tejlmand !
Could you share the corresponding CMake documentation? What I found seemed different. In https://cmake.org/cmake/help/latest/manual/cmake-variables.7.html
In the
Yes, that's exactly what I was trying to say. A behavior depending on the number of time cmake is run is a very unexpected hence incredibly confusing cmake debug experience and I suspect it will happen again the next time someone forgets something in a new toolchain or wants to add some new |
because your looking at general CMake documentation. What we are doing in Zephyr is to implement our own toolchain infrastructure, this means the corresponding toolchain handling we do is more aligned with how CMake's built-in toolchain support is working. So for a normal user, this variable is surely informational, but when implementing complete toolchain support (which users regularly don't do), then such variables are valid to set, just as such variables are set by modules shipped as part of CMake releases.
And so is the CMake C compiler, yet it's a variable users are expected to set when cross compiling:
I agree, but this is actually not specific to toolchain handling, but a general problem that if we have any CMake code which relies on a cache variable not set on first invocation then we are in trouble. Also one reason among many that I introduced #41301 because it provides us a better possibility to ensure depending modules has been loaded before current module.
Which is why I would like if we could disable the zephyr/cmake/modules/FindHostTools.cmake Lines 75 to 77 in 5d05911
(just noticed that the above code should probably be moved to another location). That way, something like your issue would probably have been easier to identify if the regular CMake infrastructure would not kick in at a later unexpected stage, which resulted in a second CMake apparently fixing the problem. |
Fixes: #51821
Set CMAKE_STRIP using
find_program(CMAKE_STRIP strip)
to support strip when building on native posix.Signed-off-by: Torsten Rasmussen [email protected]