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

Building mbedtls 2.2.0 on RHEL 5 leads to "No rule to make target library/libmbedtls.so', needed by tests/test_suite_aes.cbc.c'" #391

Closed
robert-scheck opened this issue Jan 11, 2016 · 11 comments

Comments

@robert-scheck
Copy link

Trying to build mbedtls 2.2.0 on RHEL 5 leads to the failure:

make[2]: *** No rule to make target `library/libmbedtls.so', needed by `tests/test_suite_aes.cbc.c'. Stop.

Running

sed -e 's/libmbedtls.so$/libmbedtls.so.2.2.0/' -i tests/CMakeFiles/test_suite_*.dir/build.make

after "cmake" and before "make" works around the issue. Interestingly, this only affects RHEL 5, not RHEL 6 or 7, thus this must be related to cmake somehow.

@ciarmcom
Copy link

ARM Internal Ref: IOTSSL-596

@mpg
Copy link
Contributor

mpg commented Jan 11, 2016

To be honest, I looks more like a CMake issue than an mbed TLS issue, if it works with RHEL 6 and 7 but not 5. Did you try asking CMake folks what they think about it?

Also, though I realize this might not be very satisfactory, if CMake is not working for you, we have good old Makefiles too.

@NWilson
Copy link
Contributor

NWilson commented Jan 11, 2016

It could be that RHEL 5 has a very old version of CMake. You could try installing a recent CMake version, just to see if the problem then goes away.

Here, we use CMake on a variety of very old Unix and Linux platforms, and we actually installed the latest CMake from the source distribution when we moved from autoconf, since we couldn't find packages for all our build machines.

@robert-scheck
Copy link
Author

RHEL 5 has cmake in Version 2.6.4 – which we can't upgrade in EPEL, because it is a RHEL package. Do you see chances to get the CMakefiles adapted accordingly so that they support this cmake version (like mbedtls 1.3.x did)?

@mpg
Copy link
Contributor

mpg commented Jan 11, 2016

I'm certainly not opposed in principle to supporting older CMake versions if we can, but right now it isn't obvious to me what we changed between 1.3 and now that broke the CMake build with old versions. If you can help us pinpoint what the culprit is, I'll be able to give you a better answer as to whether we can adapt our CMakelists.txt to solve your issue. If you're able to git-bisect the issue and point us to the commit that introduces it, that would probably be a good starting point.

@robert-scheck
Copy link
Author

The problem is caused by your "make apidoc" target. Running "make -j4 all" seems to create the symlink, however "make apidoc" removes the symlink.

@mpg
Copy link
Contributor

mpg commented Jan 12, 2016

I read your patch and commit message, and while I agree that using cp -p in this case is desirable, I still think that:

  • it should work without -p if you do make -j4 all && make apidoc instead of make -j4 all apidoc
  • and you shouldn't do make -j4 all apidoc anyway because it's racy and you risk building the library with the wrong config.h modified by apidoc depending on the order things are built.

Anyway, I'm considering reverting the change to the apidoc target, because it's quite counter-intuitive and error-prone that make -j4 all apidoc is now racy.

@robert-scheck
Copy link
Author

When I apply my -p patch from #392 on RHEL 5, make -j4 all apidoc fails like #390 is doing on RHEL 7 and 6. However, #392 together with make -j4 all && make apidoc works fine on RHEL 7, 6 and 5 for me.

Given I understand that make -j4 all apidoc is racy, I had a discussion with @mortenstevens already about maybe using make -j4 all && make apidoc for Fedora and RHEL (which makes our *.spec file hopefully more readable again).

@mpg
Copy link
Contributor

mpg commented Jan 12, 2016

Does make -j4 all && make apidoc also work without #392? I think it should work (expect that if you run make all again after that it will re-build instead of outputing "nothing to do" as expected, which I agree is bad). I'm asking because if it fails, that means there is another issue I didn't understand yet, and I'd rather understand everything that's going on, in order to avoid making similar mistakes in the future.

Again, sorry for breaking your build script, especially on a patch release, that was definitely not the intention.

@robert-scheck
Copy link
Author

No. make -j4 all works as it should, however make apidoc kills the symlinks for library/libmbed*.so and this causes at latest a failure at make install then (already make apidoc fails if you drop the sed command from my initial posting).

This is because the header file timestamp changed, thus it needs to rebuild the library. As part of that, the symlinks library/libmbed*.so are partially removed and not created again. So the -p is essential for RHEL 5.

@mpg
Copy link
Contributor

mpg commented Jan 12, 2016

I'll see if I can reproduce the issue with cmake 2.8.9 (the oldest version I can easily access). I'm reverting the change anyway, but I'd really like to understand everything that's going on here.

@mpg mpg closed this as completed in c990189 Jan 12, 2016
gilles-peskine-arm pushed a commit to gilles-peskine-arm/mbedtls that referenced this issue Sep 10, 2018
This partially reverts 1989caf (only the changes to Makefile and
CMakeLists, the addition to scripts/config.pl is kept).

Modifying config.h in the apidoc target creates a race condition with

    make -j4 all apidoc

where some parts of the library, tests or programs could be built with the
wrong config.h, resulting in all kinds of (semi-random) errors. Recent
versions of CMake mitigate this by adding a .NOTPARALLEL target to the
generated Makefile, but people would still get errors with older CMake
versions that are still in use (eg in RHEL 5), and with plain make.

An additional issue is that, by failing to use cp -p, the apidoc target was
updating the timestamp on config.h, which seems to cause further build issues.

Let's get back to the previous, safe, situation. The improved apidoc building
will be resurrected in a script in the next commit.

fixes Mbed-TLS#390
fixes Mbed-TLS#391
iameli pushed a commit to livepeer/mbedtls that referenced this issue Dec 5, 2023
Return NULL when allocating memory of size zero
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants