tinygo-org / tinygo

Go compiler for small places. Microcontrollers, WebAssembly (WASM/WASI), and command-line tools. Based on LLVM.
https://tinygo.org
Other
14.73k stars 859 forks source link

Unable to find headers for building #4249

Closed apprehensions closed 2 months ago

apprehensions commented 2 months ago

Using my system's LLVM:


$ go build -o tinygo
# tinygo.org/x/go-llvm
../../.cache/go/mod/tinygo.org/x/go-llvm@v0.0.0-20240106122909-c2c543540318/analysis.go:16:10: fatal error: llvm-c/Analysis.h: No such file or directory
   16 | #include "llvm-c/Analysis.h" // If you are getting an error here you need to build or install LLVM, see https://tinygo.org/docs/guides/build/
      |          ^~~~~~~~~~~~~~~~~~~
compilation terminated.
$ CGO_CFLAGS=-I/usr/lib/llvm17/include CFLAGS=-I/usr/lib/llvm17/include go build -o tinygo # headers are somewhere else
# tinygo.org/x/go-llvm
In file included from IRBindings.cpp:13:
IRBindings.h:16:10: fatal error: llvm-c/Core.h: No such file or directory
   16 | #include "llvm-c/Core.h"
      |          ^~~~~~~~~~~~~~~
compilation terminated.
$ ls /usr/lib/llvm17/include/llvm-c/Core.h 
/usr/lib/llvm17/include/llvm-c/Core.h
apprehensions commented 2 months ago

It seems to have ignored the flag entirely, as the compiler doesnt check for the given cflag.

apprehensions commented 2 months ago

Fixed: CGO_CPPFLAGS=-I/usr/lib/llvm17/include go build