0

This question stems from me trying to compile PyTorch from source. The build fails with:

-- Performing Test SUPPORT_GLIBCXX_USE_C99
-- Performing Test SUPPORT_GLIBCXX_USE_C99 - Failed
CMake Error at cmake/MiscCheck.cmake:63 (message):
  The C++ compiler does not support required functions.  This is very likely
  due to a known bug in GCC 5 (and maybe other versions) on Ubuntu 17.10 and
  newer.  For more information, see:
  https://github.com/pytorch/pytorch/issues/5229

Looking in the cmake for PyTorch this is because the following compilation fails:

#include <cmath>
#include <string>

int main() {
  int a = std::isinf(3.0);
  int b = std::isnan(0.0);
  std::string s = std::to_string(1);

  return 0;
}

Compiling manually as suggested here with /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ we get the following:

% printf "#include <cmath>\n#include <string>\nint main() { int a = std::isinf(3.0);int b = std::isnan(0.0);std::string s = std::to_string(1);return 0;}"|/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -x c++ -std=c++14 -
In file included from <stdin>:1:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:308:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/math.h:300:15: fatal error: 'math.h' file not found
#include_next <math.h>
              ^~~~~~~~
1 error generated.

What is strange is that if I compile with just clang++ it build fine:

%  printf "#include <cmath>\n#include <string>\nint main() { int a = std::isinf(3.0);int b = std::isnan(0.0);std::string s = std::to_string(1);return 0;}"|clang++ -x c++ -std=c++14 -

I am on macOS Ventura Version 13.3 (22E252) and have the latest xcode:

/usr/bin/xcodebuild -version
Xcode 14.3
Build version 14E222b

I have scoured the internet, completely removed/reinstalled xcode and tried many of the suggestions but nothing seems to be helping. Any suggestions are greatly appreciated.

Edit: This very much explains my issue though I still have not found a solid solution. https://stackoverflow.com/a/59780819/2505258

Edit 2: Something strange is going on with finding the standard lib files. As suggested here I manually modified the math.h file just to see what would happen. I commented out the line

#include_next <math.h>

It complained about stdlib.h:

%  printf "#include <cmath>\n#include <string>\nint main() { int a = std::isinf(3.0);int b = std::isnan(0.0);std::string s = std::to_string(1);return 0;}"|/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -x c++ -std=c++14 -
In file included from <stdin>:1:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:308:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/math.h:308:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stdlib.h:93:15: fatal error: 'stdlib.h' file not found
#include_next <stdlib.h>
              ^~~~~~~~~~
1 error generated.
dseiple
  • 598
  • 2
  • 6
  • 17

0 Answers0