arnetheduck / nlvm

LLVM-based compiler for the Nim language
Other
701 stars 41 forks source link

stdint file not found when trying to build with STATIC_LLVM=1 #56

Open astrolemonade opened 12 months ago

astrolemonade commented 12 months ago

Hey! I'm trying to build nlvm statically because I want to delete the big LLVM directory. The commit I am trying to build is: https://github.com/arnetheduck/nlvm/commit/99fe81717c21ac07104d60938a7d57154220df3a I managed to build nlvm by simply doing the following commands:

git clone https://github.com/arnetheduck/nlvm
cd nlvm
git submodule update --init --recursive
make

I tried similar steps for the static one:

git clone https://github.com/arnetheduck/nlvm
cd nlvm
git submodule update --init --recursive
make STATIC_LLVM=1

and after some time I receive the following:

[~/ProgrammingLanguages/nlvm-static] $ make STATIC_LLVM=1
cd nlvm && time ../Nim/bin/nim --debuginfo --linedir:on -d:staticLLVM --dynliboverrideall c nlvm
Hint: used config file '/home/user/ProgrammingLanguages/nlvm-static/Nim/config/nim.cfg' [Conf]
Hint: used config file '/home/user/ProgrammingLanguages/nlvm-static/Nim/config/config.nims' [Conf]
Hint: used config file '/home/user/ProgrammingLanguages/nlvm-static/nlvm/nim.cfg' [Conf]
......................................................................................................................................................................................................................................
/home/user/ProgrammingLanguages/nlvm-static/llvm/llvm.nim(199, 19) Warning: conversion to enum with holes is unsafe: DIFlags(flags) [HoleEnumConv]
/home/user/ProgrammingLanguages/nlvm-static/llvm/llvm.nim(215, 29) Warning: conversion to enum with holes is unsafe: DIFlags(flags) [HoleEnumConv]
/home/user/ProgrammingLanguages/nlvm-static/llvm/llvm.nim(223, 41) Warning: conversion to enum with holes is unsafe: DIFlags(flags) [HoleEnumConv]
/home/user/ProgrammingLanguages/nlvm-static/llvm/llvm.nim(238, 33) Warning: conversion to enum with holes is unsafe: DIFlags(flags) [HoleEnumConv]
/home/user/ProgrammingLanguages/nlvm-static/llvm/llvm.nim(244, 47) Warning: conversion to enum with holes is unsafe: DIFlags(flags) [HoleEnumConv]
/home/user/ProgrammingLanguages/nlvm-static/llvm/llvm/Orc.nim(56, 3) Hint: 'JITSymbolGenericFlagsExported' is declared but not used [XDeclaredButNotUsed]
/home/user/ProgrammingLanguages/nlvm-static/llvm/llvm/Orc.nim(57, 3) Hint: 'JITSymbolGenericFlagsWeak' is declared but not used [XDeclaredButNotUsed]
/home/user/ProgrammingLanguages/nlvm-static/llvm/llvm/Orc.nim(58, 3) Hint: 'JITSymbolGenericFlagsCallable' is declared but not used [XDeclaredButNotUsed]
/home/user/ProgrammingLanguages/nlvm-static/llvm/llvm/Orc.nim(59, 3) Hint: 'JITSymbolGenericFlagsMaterializationSideEffectsOnly' is declared but not used [XDeclaredButNotUsed]
...
/home/user/ProgrammingLanguages/nlvm-static/nlvm/llgen.nim(292, 10) Hint: 'int16Ty' is declared but not used [XDeclaredButNotUsed]
...........................................
/home/user/ProgrammingLanguages/nlvm-static/nlvm/nlvm.nim(187, 6) Hint: 'commandScan' is declared but not used [XDeclaredButNotUsed]
CC: wrapper
In file included from /home/user/ProgrammingLanguages/nlvm-static/llvm/wrapper.cc:1:
In file included from ../ext/llvm-16.0.2.src/sta/include/llvm/IR/Constants.h:23:
In file included from ../ext/llvm-16.0.2.src/sta/include/llvm/ADT/APFloat.h:18:
In file included from ../ext/llvm-16.0.2.src/sta/include/llvm/ADT/APInt.h:19:
In file included from ../ext/llvm-16.0.2.src/sta/include/llvm/Support/MathExtras.h:16:
../ext/llvm-16.0.2.src/sta/include/llvm/ADT/bit.h:18:10: fatal error: 'stdint' file not found
#include <stdint>
         ^~~~~~~~
1 error generated.
Error: execution of an external compiler program 'clang++ -c -std=gnu++14 -funsigned-char -w -ferror-limit=3 -I../ext/llvm-16.0.2.src/include -I../ext/llvm-16.0.2.src/sta/include -I../ext/lld-16.0.2.src/include -g  -std=gnu++17  -I/home/user/ProgrammingLanguages/nlvm-static/Nim/lib -I/home/user/ProgrammingLanguages/nlvm-static/nlvm -o /home/user/.cache/nim/nlvm_d/@m..@sllvm@swrapper.cc.o /home/user/ProgrammingLanguages/nlvm-static/llvm/wrapper.cc' failed with exit code: 1

real    0m6.788s
user    0m6.421s
sys 0m0.364s
make: *** [Makefile:44: nlvm/nlvm] Error 1

My system details are the following:

$ cmake --version
cmake version 3.24.1

$ g++ --version
g++ (Solus) 12.3.0

$ gcc --version
gcc (Solus) 12.3.0

$ clang --version
clang version 15.0.7
Target: x86_64-solus-linux
Thread model: posix
InstalledDir: /usr/bin

I tried to modify the stdint reference in that file to point to stdint.h but there are many other include problems: limits, type_traits etc.

Can you help me debug the problem?

Note 1: Sometimes the cstdint not found error is thrown instead of the stdint one. This happens if I follow the steps from the CI.

arnetheduck commented 11 months ago

were you able to figure this out? we discussed that it looked like a package problem on your setup (ie missing c++ library or something like this)..

astrolemonade commented 10 months ago

I am not missing any library. I just gave up on the idea of building nlvm from source and also statically.