Open eklitzke opened 2 years ago
If you compile a simple test program with both of those linker flags can you also reproduce this issue?
There is a double space after -flto=thin
, can you make sure that's unrelated? Because I'm confused how two supported linker flags can cause the "no such file" error message.
I can't build monero using mold 1.3.1 as my linker on Linux. I've isolated the issue to a problematic line in CMakeLists.txt. It's not totally clear to me whether this should be considered a mold bug or if it's a problem in the monero cmake rules, so I'm reporting it for your consideration. Note that I don't have this issue with lld, suggesting that this is arguably a mold bug, but it's also not clear to me that the monero cmake rules are correct.
Here's how I am configuring and building monero (from a clean checkout of the 0.17.3.2 git tag, the latest release tag as I write this):
This fails when building miniupnp with an error message like:
The exact clang invocation that is failing is:
From the original error message ("mold: fatal: cannot open error: No such file or directory") it seems that there is some issue with how mold is parsing the command line, as it appears to think that "error" is the name of a file. If I run the exact same clang command as above but remove the part like "-Wl,-undefined,error" then I don't get an error, so that seems to be the part of the command that is tripping up the linker.
Based on this I realized that the "-Wl,-undefined,error" bit comes from the monero CMakeLists.txt file, and the issue is resolved if I make the following change:
Looking back at the original failing clang invocation, it has both "-Wl,--no-undefined" and "-Wl,-undefined,error". However from the comment in the CMakeLists.txt file, it seems to me that the intention is to use whichever of these two linker flags is supported, with the expectation that only one will pass the linker flag test and actually work. Therefore this could probably be fixed by only testing for the second flag if the first one wasn't added.