-
-
Notifications
You must be signed in to change notification settings - Fork 491
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
The new findMbedTLS from NNG 1.7.2 fails #1771
Comments
My above workaround doesn't appear to fix it entirely. I build static libs on a range of Linux, Mac OS and Windows platforms. I still get a failure on UCRT Windows (oddly not on older setups) where it starts:
but ends with:
For my purposes I've reverted to the previous find mbedtls CMake scripts which still work fine. |
I'm not sure about the static libraries. The situation here with CMake is actually completely awful, and probably you need to "help" it find your installation of Mbed TLS by supplying extra arguments to the CMake process. This one can help: MBEDTLS_ROOT_DIR Also, which version of CMake are you using? |
Ah, I see, CMake 3.22. |
I just did a fresh install on a brand spanking new Ubuntu 22 container (ARM64 because that's what is easy on my mac):
(I also tried dynamic lib without -DNNG_STATIC_LIB=ON, and that worked too.) This all worked flawlessly. How did you install Mbed TLS 3.5.2? |
It would not surprise me if there is some confusion between your mbedTLS 3.5.2 installation and the mbed TLS 2.x default installation. These have different symbols (slightly) and if your headers don't match the libraries, that would cause problems. |
The explanation of CMAKE_FIND_PACKAGE_PREFER_CONFIG is that we prefer to use the configuration mode rather than module mode. That said, there is a typo here which means that we won't allow the user override here that we should have... but I don't think that's what is happening in your case. |
Thanks for the explanation. I need to find some time to pinpoint what's going wrong in my case. |
I've narrowed it down somewhat. After removing all traces of my mbedtls 3.5.2 install in /usr/local, NNG now finds the system mbedtls in /usr.
If I then make a clean install of mbedtls in /usr/local (using cmake, pretty much the same as NNG), NNG is no longer able to find it correctly. I get the following output and mbedtls is NOT linked:
Using the old CMake script, this is not a problem. I know there is I haven't made more progress yet, hope to do so when I get the chance. |
I expect that the version of the library in /usr is being found before the one in /usr/local. Are you building purely static? |
Yes always static. I don't think it's dynamic linking taking precedence. I tried building shared libs as well for mbedtls 3.5.2 in /usr/local, didn't make a difference. I also removed the system libmbedtls in /usr and that didn't help either. |
Whoa. Removing the system libmbedtls didn't solve this?! This is very surprising. Maybe we need to change the environment we give it for finding libmbedtls. Let me double check. |
https://cmake.org/cmake/help/latest/command/find_package.html#search-procedure May have some info. |
From that document, it looks like MBEDTLS_ROOT might be the variable you want to set. |
Ok, thanks. I'll take a look. Sorry I've not been approaching this very methodically thus far. |
This PR may help: #1785 But you'll want to use MBED_ROOT -- this just makes that work with either the new or old configuration. (And provides a fallback for the old.) |
Sorry didn't do anything for me. The docs mention that it should check the CMAKE_PREFIX_PATH automatically? That explicitly referred to common installation locations including /usr/local on Linux. The strange thing is that the old One other thing that came to me is that the following lines do not even appear:
I have seen a case on a Windows platform (I mentioned above) where it says 'not found', so does that give you a clue? I'm just not quite sure what's going on with cmake. |
Ugh. I really really hate CMake. Its better than autotools, but that's about it. The old Find package works ok, but I've been told by others that it didn't work for them with Mbed TLS 3.x. I actually tried to build the Mbed TLS 3.x packages from source, so I could reproduce your behavior, but didn't have luck yet. I may try again in a bit. Also, it should be |
You can also look the CMake log files to see what it is testing and how - that might provide more clue. |
So I just built it all on Ubuntu 20... with Mbed TLS 3.5.2. Here's my shell history (in a brand spanking new docker container running ubuntu:jammy):
Note that steps 17, 18, and 19 were me checking to see what the install prefix for Mbed TLS was -- it was already /usr/local, so I didn't change anything else. Obviously there were some mistakes there -- like the bad directory in step 22, and the attempts to run git tag (to check the version of mbed TLS to check out) in steps 7 & 8. This built perfectly. It looks like it built statically too.
And that TLS test runs fine. At this point I think you should investigate your environment. In your build directory, As I cannot seem to reproduce your test failure, I don't have any further guidance. Here's a cleaned up version of the shell history refactored as a script, with unnecessary or erroneous commands removed - you should be able to run this in a fresh docker ubuntu:jammy container:
|
(Oh make sure you did actually install the Mbed TLS libraries and headers, not just build them..) |
I finally understand what this Config mode for CMake It turns out for me Config mode just fails, when Mbed TLS 3.5.2 is installed in /usr/local (with the CMake files in /usr/local/lib/cmake). I don't know why - the only real difference I can see is that you use Ninja whilst I just use CMake. It could be something peculiar to my environment - I will let you know if I find it. To be clear - it somehow fails in Config mode, doesn't fall back to Module mode and doesn't generate anything in the log file. If I don't force The |
CMake doesn't replace Ninja or vice versa. We always use CMake -- the question is what generator you use. There are numerous options, but Ninja is the only sane one IMO. The others (msbuild or visual studio solution files for Windows, Makefiles for UNIX/Linux) are all much slower and inferior. As far as my choices here; the intent was to respect the installed Mbed TLS configuration. Unfortunately, the default for FindPackage is the opposite of the default I want. The code is not well orchestratred to allow for overriding it to false. Let me think on that. |
Fix to allow you to override it however you like was easy. I've pushed it. |
(You can now use -DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON (or OFF) as you like. |
Describe the bug
The improvements to cmake in NNG 1.7.2 prevent MbedTLS being found.
Actual Behavior
The final lines when running cmake do not appear for me on Ubuntu 22.04:
Tested with:
(i) apt installed MbedTLS 2.28 in /usr and
(ii) MbedTLS 3.5.2 installed in /usr/local
Both are not picked up.
This causes the library to be built without TLS support.
To Reproduce
However it works again if I simplify this part in
src/supplemental/tls/mbedtls/CMakeLists.txt
:to this:
I have no idea what
CMAKE_FIND_PACKAGE_PREFER_CONFIG
is meant for, but perhaps it can be reverted if not important.Note that there is actually a typo in one of the places where it appears above, but that is not causing this bug.
** Environment Details **
The text was updated successfully, but these errors were encountered: