Error while running configure "Cannot locate libclang or headers"

Vipin Sharma vipinsharma85 at gmail.com
Thu Nov 19 21:51:45 UTC 2020


Hi Maurizio,

On Fri, Nov 20, 2020 at 2:47 AM Maurizio Cimadamore <
maurizio.cimadamore at oracle.com> wrote:

>
> On 19/11/2020 21:05, Vipin Sharma wrote:
> > Hi,
> >
> > I am trying to set up https://github.com/openjdk/panama-foreign (default
> > branch foreign-jextract) on my machine, os is Ubuntu 19.10.
> >
> > Getting below error while running configure:
> >
> > checking for clang-c/Index.h... yes
> > configure: error: Cannot locate libclang or headers at the specified
> > locations:
> >              /home/vipin/Softwares/llvm-project/build/lib
> >              /home/vipin/Softwares/llvm-project/build/include
> > configure exiting with result code 1
> >
> > configure command is:
> > bash configure --with-boot-jdk=/home/vipin/Downloads/jdk-15/
> > --with-libclang=/home/vipin/Softwares/llvm-project/build
> >
> >
> > configure and build both works after the below hack, here I have
> commented
> > call to clang_getClangVersion.
>
> Before we look at solutions, I think we need more info.
>
> Are you cross compiling? Or is this just plain Ubuntu 19.10 install? I
> regularly work with 20.04 - and I used to work with Ubuntu 18.04 with no
> issues.
>
> If it's a plain Ubuntu install, can you please list the contents of the
> folder "/home/vipin/Softwares/llvm-project/build" ? More specifically:
>
> * do you have a lib/libclang.so in there?
>
Yes, it is available.

> * do you have a lib/clang/<version>/include in there?
>
Yes, it is available.

This is a plain install.

Also, I tried with clang pre-built binaries from
https://releases.llvm.org/9.0.0/clang+llvm-9.0.0-x86_64-pc-linux-gnu.tar.xz
and built it on my machine from the source code. For both the setups I have
files you asked to check, for both, I am getting the same error.

This is list of files from both clang directories.

dir: /home/vipin/Downloads/clang+llvm-9.0.0-x86_64-pc-linux-gnu
libexec
include
share
lib
bin

dir: /home/vipin/Softwares/llvm-project/build
CPackConfig.cmake
CPackSourceConfig.cmake
include
llvm.spec
cmake
utils
LLVMBuild.cmake
DummyConfigureOutput
CMakeCache.txt
Makefile
cmake_install.cmake
tools
projects
runtimes
examples
test
unittests
docs
benchmarks
compile_commands.json
libexec
share
bin
lib
CMakeFiles


> Note that the hack below completely disables the autoconf checks - which
> might necessary when cross compiling, but should not be needed when the
> library is currently installed and functioning on the system used to build.
>
> Maurizio
>
> >
> > diff --git a/make/autoconf/lib-clang.m4 b/make/autoconf/lib-clang.m4
> > index 40f86bf8c38..1a35fd5fdf2 100644
> > --- a/make/autoconf/lib-clang.m4
> > +++ b/make/autoconf/lib-clang.m4
> > @@ -148,7 +148,8 @@ AC_DEFUN_ONCE([LIB_SETUP_LIBCLANG],
> >           # Just trust the lib is there
> >           LIBS=$LIBCLANG_LIBS
> >         else
> > -        AC_CHECK_LIB(clang, clang_getClangVersion, [],
> > [ENABLE_LIBCLANG="false"])
> > +       # AC_CHECK_LIB(clang, clang_getClangVersion, [],
> > [ENABLE_LIBCLANG="false"])
> > +          AC_MSG_NOTICE('Dummy message')
> >         fi
> >       fi
> >
> > Due to the below variables in lib-clang.m4 control goes to the else part
> > where we call clang_getClangVersion.
> > TOOLCHAIN_TYPE: gcc
> > COMPILE_TYPE: native
> >
> > A similar error was reported at
> > https://mail.openjdk.java.net/pipermail/panama-dev/2019-May/005638.html
> >  From this old discussion, it seems the fix was to add *or condition
> > "x$COMPILE_TYPE" = "xcross"*
> > Being new to this it is not clear to me why in the case of cross
> > compilation we just want to trust clang library is there and no need to
> > call clang_getClangVersion.
> >
> > To fix this problem, in this case, do we need to add one more or
> > condition *"x$COMPILE_TYPE"
> > = "xnative"?* or there is something else wrong in my setup.
> >
> > In case it needs to be fixed I can create a bug id against this.
> >
> > Thanks,
> > Vipin
>


More information about the panama-dev mailing list