Issue compiling simple code with clang++-mp-11
Andrew Udvare
audvare at gmail.com
Mon May 3 12:14:36 UTC 2021
This code compiles fine with Xcode but fails with Clang from MacPorts. I have not been able to figure out why. I successfully rebuilt Clang and LLVM from source but it made no difference.
Setup:
macOS 11.3 20E232 x86_64
Xcode 12.5 12E262
The code (main.cpp):
#include <filesystem>
int main(int argc, char *argv[]) {
std::filesystem::path p(argv[0]);
return p.string().length();
}
$ xcrun clang++ -std=c++17 main.cpp
# No errors
Anyone know why it would fail with MacPorts' Clang? Seems to be an include path/file issue.
$ /opt/local/bin/clang++-mp-11 -std=c++17 main.cpp -ferror-limit=2
In file included from main.cpp:1:
In file included from /opt/local/libexec/llvm-11/bin/../include/c++/v1/filesystem:234:
In file included from /opt/local/libexec/llvm-11/bin/../include/c++/v1/cstdlib:85:
/opt/local/libexec/llvm-11/bin/../include/c++/v1/stdlib.h:142:34: error: unknown type name 'ldiv_t'
inline _LIBCPP_INLINE_VISIBILITY ldiv_t div(long __x, long __y) _NOEXCEPT {
^
/opt/local/libexec/llvm-11/bin/../include/c++/v1/stdlib.h:143:12: error: no member named 'ldiv' in the global namespace
return ::ldiv(__x, __y);
~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
3 errors generated.
This generates a lot of errors that are members are missing from the global namespace.
This affects this port I have had working for a while, probably by accident because it wasn't until recently that Xcode Clang and MacPorts Clang versions mismatched their highest numbers (Xcode 12.5 having Clang 12, MacPorts having up to 11).
https://github.com/Tatsh/ports/blob/ycm-fixes/devel/ycmd/Portfile
This project tries to compile this code within CMake to test for required arguments, but it's failing for the reason above rather than actually missing filesystem implementation. See https://github.com/ycm-core/ycmd/blob/master/cpp/ycm/CMakeLists.txt#L279
--
Andrew Udvare
More information about the macports-users
mailing list