ROCm-OpenCL-Runtime icon indicating copy to clipboard operation
ROCm-OpenCL-Runtime copied to clipboard

fatal error: math.h: No such file or directory

Open ChristophHaag opened this issue 5 years ago • 4 comments

On Archlinux with gcc 8.2.1 I get this error:

In file included from /home/chris/oldhome/build/rocm-opencl-git/src/opencl/compiler/llvm/include/llvm-c/DataTypes.h:28,
                 from /home/chris/oldhome/build/rocm-opencl-git/src/opencl/compiler/llvm/include/llvm/Support/DataTypes.h:17,
                 from /home/chris/oldhome/build/rocm-opencl-git/src/opencl/compiler/llvm/include/llvm/Support/SwapByteOrder.h:19,
                 from /home/chris/oldhome/build/rocm-opencl-git/src/opencl/compiler/llvm/include/llvm/Support/MathExtras.h:18,
                 from /home/chris/oldhome/build/rocm-opencl-git/src/opencl/compiler/llvm/include/llvm/ADT/APInt.h:20,
                 from /home/chris/oldhome/build/rocm-opencl-git/src/opencl/compiler/llvm/include/llvm/ADT/APSInt.h:18,
                 from /home/chris/oldhome/build/rocm-opencl-git/src/opencl/compiler/llvm/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h:13,
                 from /home/chris/oldhome/build/rocm-opencl-git/src/opencl/compiler/llvm/tools/clang/lib/StaticAnalyzer/Core/APSIntType.cpp:10:
/usr/include/c++/8.2.1/cmath:45:15: fatal error: math.h: No such file or directory
 #include_next <math.h>
               ^~~~~~~~

Unfortunately it's not very clear what causes it.

ChristophHaag avatar Mar 12 '19 23:03 ChristophHaag

Hi @ChristophHaag

This sounds like a problem with your Arch installation -- your system include directory (or directories) does not include math.h, and so your C++ compiler can't properly use cmath. This is way outside of ROCm's wheelhouse.

jlgreathouse avatar Mar 12 '19 23:03 jlgreathouse

/usr/include/math.h exists and most likely changing the #include_next <math.h> to #include <math.h> would work (haven't tested yet).

It most likely has something to do with the build system and the system include path, see issues like https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71090 https://github.com/ponylang/ponyc/issues/797

ChristophHaag avatar Mar 12 '19 23:03 ChristophHaag

In vanilla llvm something similar started happening recently, so I took the time to find out why.

Turns out this is the issue: https://github.com/llvm-mirror/llvm/blob/097d54dca0cf7585898f44158d453b70611a7bcb/lib/Support/CMakeLists.txt#L195-L200

This adds -isystem /include to the gcc command line, which breaks its ability to find system headers, in the case of vanilla llvm, the first affected one is stdlib.h.

I'll try later if this is the cause in rocm opencl too and see if there are more.

ChristophHaag avatar Jun 24 '19 10:06 ChristophHaag

In ubuntu 20.04 x86 the following changes had to be made from the APT lines: sudo apt update sudo apt install libhamlib2 libqwt-qt5-6 libqt5svg5* sudo apt install g++ unzip make qtbase5-dev-tools automake libtool libtool-bin >

Also, there were errors that a file existed in the ln lines which aborted the script.

The script eventually aborted at: In file included from /usr/include/c++/9/complex:44, from src/linux/../util/../GlobalDefinitions.h:32, from src/linux/../util/Pacer.h:4, from src/linux/Pacer.cpp:2: /usr/include/c++/9/cmath:45:15: fatal error: math.h: No such file or directory 45 | #include_next <math.h>

... when a build has problems with math.h, that's the "screw this" point for me.

cjritola avatar Apr 02 '21 01:04 cjritola