Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 702048 - sys-devel/clang-9.0.0 on prefix - ninja: error: '/usr/lib/llvm-6.0/lib/cmake/llvm/GenerateVersionFromVCS.cmake', needed by 'lib/Basic/VCSVersion.inc', missing and no known rule to make it
Summary: sys-devel/clang-9.0.0 on prefix - ninja: error: '/usr/lib/llvm-6.0/lib/cmake/...
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Prefix Support (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Prefix
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-12-05 16:22 UTC by gerion
Modified: 2021-08-29 14:35 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (build.log,14.48 KB, text/plain)
2019-12-05 16:24 UTC, gerion
Details
environment.gz (environment.gz,37.16 KB, application/gzip)
2019-12-05 18:03 UTC, gerion
Details

Note You need to log in before you can comment on or make changes to this bug.
Description gerion 2019-12-05 16:22:49 UTC
sys-devel/clang-9.0.0 fails to build for me. I'm on prefix (x86_64), so this can be the reason, but I'm not sure.

This seems to be the relevant error message:
```
>>> Compiling source in /srv/scratch/entrup/gentoo/var/tmp/portage/sys-devel/clang-9.0.0/work/x/y/clang ...
 * abi_x86_64.amd64: running multilib-minimal_abi_src_compile
>>> Working in BUILD_DIR: "/srv/scratch/entrup/gentoo/var/tmp/portage/sys-devel/clang-9.0.0/work/x/y/clang-abi_x86_64.amd64"
ninja -v -j96 -l0
ninja: error: '/usr/lib/llvm-6.0/lib/cmake/llvm/GenerateVersionFromVCS.cmake', needed by 'lib/Basic/VCSVersion.inc', missing and no known rule to make it
```
llvm-6.0 seems to be the host LLVM (Ubuntu 18.04). Here are some more commands of this machine:
```
% ls -lh /usr/lib/ | grep llvm
drwxr-xr-x  7 root root 4.0K Dec  4 16:17 llvm-6.0
% which llvm-config                                                                    
/srv/scratch/entrup/gentoo/usr/lib/llvm/9/bin/llvm-config
% llvm-config --version
9.0.0
```

Reproducible: Always

Steps to Reproduce:
emerge clang
Comment 1 gerion 2019-12-05 16:24:28 UTC
Created attachment 598532 [details]
build.log
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2019-12-05 17:33:08 UTC
What's your PATH in build environment?  Generally our LLVM dir should come first, and cause CMake to use it rather than host's LLVM.
Comment 3 gerion 2019-12-05 17:38:08 UTC
(In reply to Michał Górny from comment #2)
> What's your PATH in build environment?

```
% /srv/scratch/entrup/gentoo/startprefix
Entering Gentoo Prefix /srv/scratch/entrup/gentoo
entrup:~% echo $PATH              
/home/srastaff/entrup/.local/share/zplug/bin:/home/srastaff/entrup/.local/bin:/srv/scratch/entrup/gentoo/usr/lib/llvm/9/bin:/srv/scratch/entrup/gentoo/usr/local/sbin:/srv/scratch/entrup/gentoo/usr/local/bin:/srv/scratch/entrup/gentoo/usr/sbin:/srv/scratch/entrup/gentoo/usr/bin:/srv/scratch/entrup/gentoo/sbin:/srv/scratch/entrup/gentoo/bin:/srv/scratch/entrup/gentoo/opt/bin:/usr/sbin:/sbin:/usr/bin:/bin:/home/srastaff/entrup/.bin
entrup:~% emerge -a1 clang
... and fail
```
Comment 4 gerion 2019-12-05 17:41:54 UTC
Maybe the local stuff is interesting, too:
```
% ls ~/.local/bin         
alembic     datafreeze  easy_install      flask     gunicorn_paster  jp.pyc      mako-render  netaddr      rst2html.pyc  rst2html4.pyc  rst2html5.pyc  rst2latex.pyc  rst2man.pyc  rst2odt.pyc            rst2odt_prepstyles.pyc  rst2pseudoxml.pyc  rst2s5.pyc    rst2xetex.pyc  rst2xml.pyc     rstpep2html.pyc
chardetect  dotenv      easy_install-2.7  gunicorn  jp.py            jsonschema  meson        rst2html.py  rst2html4.py  rst2html5.py   rst2latex.py   rst2man.py     rst2odt.py   rst2odt_prepstyles.py  rst2pseudoxml.py        rst2s5.py          rst2xetex.py  rst2xml.py     rstpep2html.py
% ls ~/.local/share/zplug/bin 
zplug-env
```
Comment 5 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2019-12-05 17:54:29 UTC
I actually meant temp/environment(.bz2) from Portage build env.  Alternatively, put a 'die "$PATH"' in the ebuild (in src_compile(), I suppose).
Comment 6 gerion 2019-12-05 18:00:46 UTC
Ah, ok. The path is:

/srv/scratch/entrup/gentoo/var/tmp/portage/sys-devel/clang-9.0.0/temp/python3.6/bin:/srv/scratch/entrup/gentoo/usr/lib/llvm/9/bin:/srv/scratch/entrup/gentoo/usr/lib/portage/python3.6/ebuild-helpers/unprivileged:/srv/scratch/entrup/gentoo/usr/lib/portage/python3.6/ebuild-helpers:/srv/scratch/entrup/gentoo/usr/lib/llvm/9/bin:/srv/scratch/entrup/gentoo/usr/local/sbin:/srv/scratch/entrup/gentoo/usr/local/bin:/srv/scratch/entrup/gentoo/usr/sbin:/srv/scratch/entrup/gentoo/usr/bin:/srv/scratch/entrup/gentoo/sbin:/srv/scratch/entrup/gentoo/bin:/srv/scratch/entrup/gentoo/opt/bin:/usr/sbin:/sbin:/usr/bin:/bin

For me, this looks like a Cmake error. How does Cmake search its build files in other directories?
Comment 7 gerion 2019-12-05 18:03:08 UTC
Created attachment 598534 [details]
environment.gz
Comment 8 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2019-12-05 18:11:36 UTC
That second path on the list should be the right one.  You have some /srv/scratch/entrup/gentoo/usr/lib/llvm/9/lib*/cmake/llvm or something like that, correct?

CMake logic is quite weird.  Generally, we're relying on the behavior of looking for files in ../${libdir}/cmake relative to directories in PATH.  Which makes my first suspicion that it doesn't get correct libdir there.  Or that Ubuntu is using some magic that puts higher priority on their directory.

https://cmake.org/cmake/help/v3.0/command/find_package.html

Grep for 'search path'.
Comment 9 gerion 2019-12-05 18:32:13 UTC
(In reply to Michał Górny from comment #8)
> That second path on the list should be the right one.  You have some
> /srv/scratch/entrup/gentoo/usr/lib/llvm/9/lib*/cmake/llvm or something like
> that, correct?
Yes

```
% ls /srv/scratch/entrup/gentoo/usr/lib/llvm/9/lib64/cmake/llvm/
...
GenerateVersionFromVCS.cmake
...
```


> CMake logic is quite weird.  Generally, we're relying on the behavior of
> looking for files in ../${libdir}/cmake relative to directories in PATH. 
> Which makes my first suspicion that it doesn't get correct libdir there.

Can I check this somehow? This is the output of `env | grep lib` within src_compile:
```
PORTAGE_PYTHONPATH=/srv/scratch/entrup/gentoo/usr/lib64/python3.6/site-packages
PORTAGE_FEATURES=strict merge-sync force-prefix unmerge-orphans ebuild-locks assume-digests news preserve-libs unmerge-logs sfperms protect-owned ipc-sandbox nostrip binpkg-logs multilib-strict fixlafiles network-sandbox parallel-install parallel-fetch binpkg-docompress config-protect-if-modified distlocks unprivileged unknown-features-warn pid-sandbox binpkg-dostrip
ROOTPATH=/srv/scratch/entrup/gentoo/usr/lib/llvm/9/bin:/srv/scratch/entrup/gentoo/usr/local/sbin:/srv/scratch/entrup/gentoo/usr/local/bin:/srv/scratch/entrup/gentoo/usr/sbin:/srv/scratch/entrup/gentoo/usr/bin:/srv/scratch/entrup/gentoo/sbin:/srv/scratch/entrup/gentoo/bin:/srv/scratch/entrup/gentoo/opt/bin:/usr/sbin:/sbin:/usr/bin:/bin
MULTILIB_STRICT_DIRS=/lib32 /lib /usr/lib32 /usr/lib /usr/kde/*/lib32 /usr/kde/*/lib /usr/qt/*/lib32 /usr/qt/*/lib /usr/X11R6/lib32 /usr/X11R6/lib
IUSE_EFFECTIVE=abi_mips_n32 abi_mips_n64 abi_mips_o32 abi_riscv_lp64 abi_riscv_lp64d abi_s390_32 abi_s390_64 abi_x86_32 abi_x86_64 abi_x86_x32 alpha amd64 amd64-fbsd amd64-linux arm arm64 debug default-compiler-rt default-libcxx doc elibc_AIX elibc_Cygwin elibc_Darwin elibc_DragonFly elibc_FreeBSD elibc_HPUX elibc_Interix elibc_NetBSD elibc_OpenBSD elibc_SunOS elibc_Winnt elibc_bionic elibc_glibc elibc_mingw elibc_mintlib elibc_musl elibc_uclibc hppa ia64 kernel_AIX kernel_Darwin kernel_FreeBSD kernel_HPUX kernel_NetBSD kernel_OpenBSD kernel_SunOS kernel_Winnt kernel_freemint kernel_linux llvm_targets_AArch64 llvm_targets_AMDGPU llvm_targets_ARM llvm_targets_BPF llvm_targets_Hexagon llvm_targets_Lanai llvm_targets_MSP430 llvm_targets_Mips llvm_targets_NVPTX llvm_targets_PowerPC llvm_targets_RISCV llvm_targets_Sparc llvm_targets_SystemZ llvm_targets_WebAssembly llvm_targets_X86 llvm_targets_XCore m68k m68k-mint mips ppc ppc-aix ppc-macos ppc64 ppc64-linux prefix prefix-guest prefix-stack python_single_target_python2_7 python_single_target_python3_5 python_single_target_python3_6 python_single_target_python3_7 python_targets_python2_7 python_targets_python3_5 python_targets_python3_6 python_targets_python3_7 riscv s390 sh sparc sparc-solaris sparc64-solaris static-analyzer test userland_BSD userland_GNU x64-cygwin x64-macos x64-solaris x86 x86-cygwin x86-fbsd x86-linux x86-macos x86-solaris x86-winnt xml
INHERITED= toolchain-funcs multilib multiprocessing ninja-utils eutils flag-o-matic xdg-utils cmake-utils llvm llvm.org multibuild multilib-build multilib-minimal pax-utils python-utils-r1 python-single-r1
LIBDIR_amd64=lib64
FEATURES=strict merge-sync force-prefix unmerge-orphans ebuild-locks assume-digests news preserve-libs unmerge-logs sfperms protect-owned ipc-sandbox nostrip binpkg-logs multilib-strict fixlafiles network-sandbox parallel-install parallel-fetch binpkg-docompress config-protect-if-modified distlocks unprivileged unknown-features-warn pid-sandbox binpkg-dostrip
PORTAGE_BIN_PATH=/srv/scratch/entrup/gentoo/usr/lib/portage/python3.6
PORTAGE_PYM_PATH=/srv/scratch/entrup/gentoo/usr/lib64/python3.6/site-packages
MULTILIB_STRICT_EXEMPT=(perl5|gcc|gcc-lib|binutils|eclipse-3|debug|portage|udev|systemd|clang|python-exec|llvm)
BOOTSTRAP_USE=unicode internal-glib pkg-config split-usr python_targets_python3_6 python_targets_python2_7 multilib
LIBDIR_x32=libx32
USE_EXPAND_VALUES_ELIBC=AIX bionic Cygwin Darwin DragonFly FreeBSD glibc HPUX Interix mingw mintlib musl NetBSD OpenBSD SunOS uclibc Winnt
LIBDIR_default=lib
PATH=/srv/scratch/entrup/gentoo/var/tmp/portage/sys-devel/clang-9.0.0/temp/python3.6/bin:/srv/scratch/entrup/gentoo/usr/lib/llvm/9/bin:/srv/scratch/entrup/gentoo/usr/lib/portage/python3.6/ebuild-helpers/unprivileged:/srv/scratch/entrup/gentoo/usr/lib/portage/python3.6/ebuild-helpers:/srv/scratch/entrup/gentoo/usr/lib/llvm/9/bin:/srv/scratch/entrup/gentoo/usr/local/sbin:/srv/scratch/entrup/gentoo/usr/local/bin:/srv/scratch/entrup/gentoo/usr/sbin:/srv/scratch/entrup/gentoo/usr/bin:/srv/scratch/entrup/gentoo/sbin:/srv/scratch/entrup/gentoo/bin:/srv/scratch/entrup/gentoo/opt/bin:/usr/sbin:/sbin:/usr/bin:/bin
USE=abi_x86_64 amd64 elibc_glibc kernel_linux llvm_targets_ARM llvm_targets_BPF llvm_targets_RISCV llvm_targets_WebAssembly llvm_targets_X86 prefix python_single_target_python3_6 python_targets_python2_7 python_targets_python3_6 static-analyzer userland_GNU
LIBDIR_x86=lib32
ELIBC=glibc
```
Comment 10 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2019-12-05 19:08:00 UTC
This is beyond my knowledge, and I'm afraid I can't find sufficient time to try to figure it out.  I'm reassigning the bug to Prefix team, and CC-ing cmake maintainers in case they could help.
Comment 11 gerion 2019-12-06 13:26:23 UTC
Maybe interesting. I adjusted the src_configure phase with:
```
	mycmakeargs+=(
		-DCMAKE_FIND_DEBUG_MODE=1
	)
```
The relevant output seems to be:
```
>>> Working in BUILD_DIR: "/srv/scratch/entrup/gentoo/var/tmp/portage/sys-devel/clang-9.0.0/work/x/y/clang-abi_x86_64.amd64"
cmake -C /srv/scratch/entrup/gentoo/var/tmp/portage/sys-devel/clang-9.0.0/work/x/y/clang-abi_x86_64.amd64/gentoo_common_config.cmake -G Ninja -DCMAKE_INSTALL_PREFIX=/srv/scratch/entrup/gentoo/usr -DCMAKE_INSTALL_PREFIX=/srv/scratch/entrup/gentoo/usr/lib/llvm/9 -DCMAKE_INSTALL_MANDIR=/srv/scratch/entrup/gentoo/usr/lib/llvm/9/share/man -DCLANG_RESOURCE_DIR=../../../../lib/clang/9.0.0 -DBUILD_SHARED_LIBS=ON -DLLVM_TARGETS_TO_BUILD=ARM;BPF;RISCV;WebAssembly;X86 -DLLVM_BUILD_TESTS=no -DLLVM_ENABLE_EH=ON -DLLVM_ENABLE_RTTI=ON -DCMAKE_DISABLE_FIND_PACKAGE_LibXml2=yes -DCLANG_DEFAULT_OPENMP_RUNTIME=libomp -DCLANG_DEFAULT_CXX_STDLIB= -DCLANG_DEFAULT_RTLIB= -DCLANG_ENABLE_ARCMT=yes -DCLANG_ENABLE_STATIC_ANALYZER=yes -DCLANG_INCLUDE_DOCS=no -DCLANG_TOOLS_EXTRA_INCLUDE_DOCS=no -DGCC_INSTALL_PREFIX=/srv/scratch/entrup/gentoo/usr -DCMAKE_FIND_DEBUG_MODE=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_TOOLCHAIN_FILE=/srv/scratch/entrup/gentoo/var/tmp/portage/sys-devel/clang-9.0.0/work/x/y/clang-abi_x86_64.amd64/gentoo_toolchain.cmake  /srv/scratch/entrup/gentoo/var/tmp/portage/sys-devel/clang-9.0.0/work/x/y/clang
loading initial cache file /srv/scratch/entrup/gentoo/var/tmp/portage/sys-devel/clang-9.0.0/work/x/y/clang-abi_x86_64.amd64/gentoo_common_config.cmake
-- The C compiler identification is GNU 9.2.0
-- The CXX compiler identification is GNU 9.2.0
-- Check for working C compiler: /srv/scratch/entrup/gentoo/usr/bin/x86_64-pc-linux-gnu-gcc
-- Check for working C compiler: /srv/scratch/entrup/gentoo/usr/bin/x86_64-pc-linux-gnu-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /srv/scratch/entrup/gentoo/usr/bin/x86_64-pc-linux-gnu-g++
-- Check for working CXX compiler: /srv/scratch/entrup/gentoo/usr/bin/x86_64-pc-linux-gnu-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Checking prefix [/srv/scratch/entrup/gentoo/var/tmp/portage/sys-devel/clang-9.0.0/work/x/y/clang/]
Checking file [/srv/scratch/entrup/gentoo/var/tmp/portage/sys-devel/clang-9.0.0/work/x/y/clang/LLVMConfig.cmake]
Checking file [/srv/scratch/entrup/gentoo/var/tmp/portage/sys-devel/clang-9.0.0/work/x/y/clang/llvm-config.cmake]
Checking file [/srv/scratch/entrup/gentoo/var/tmp/portage/sys-devel/clang-9.0.0/work/x/y/clang/cmake/LLVMConfig.cmake]
Checking file [/srv/scratch/entrup/gentoo/var/tmp/portage/sys-devel/clang-9.0.0/work/x/y/clang/cmake/llvm-config.cmake]
Checking prefix [/srv/scratch/entrup/gentoo/var/tmp/portage/sys-devel/clang-9.0.0/temp/python3.6/]
Checking file [/srv/scratch/entrup/gentoo/var/tmp/portage/sys-devel/clang-9.0.0/temp/python3.6/LLVMConfig.cmake]
Checking file [/srv/scratch/entrup/gentoo/var/tmp/portage/sys-devel/clang-9.0.0/temp/python3.6/llvm-config.cmake]
Checking prefix [/srv/scratch/entrup/gentoo/usr/lib/llvm/9/]
Checking file [/srv/scratch/entrup/gentoo/usr/lib/llvm/9/LLVMConfig.cmake]
Checking file [/srv/scratch/entrup/gentoo/usr/lib/llvm/9/llvm-config.cmake]
Checking prefix [/srv/scratch/entrup/gentoo/usr/lib/portage/python3.6/ebuild-helpers/unprivileged/]
Checking file [/srv/scratch/entrup/gentoo/usr/lib/portage/python3.6/ebuild-helpers/unprivileged/LLVMConfig.cmake]
Checking file [/srv/scratch/entrup/gentoo/usr/lib/portage/python3.6/ebuild-helpers/unprivileged/llvm-config.cmake]
Checking prefix [/srv/scratch/entrup/gentoo/usr/lib/portage/python3.6/ebuild-helpers/]
Checking file [/srv/scratch/entrup/gentoo/usr/lib/portage/python3.6/ebuild-helpers/LLVMConfig.cmake]
Checking file [/srv/scratch/entrup/gentoo/usr/lib/portage/python3.6/ebuild-helpers/llvm-config.cmake]
Checking prefix [/srv/scratch/entrup/gentoo/usr/local/]
Checking file [/srv/scratch/entrup/gentoo/usr/local/LLVMConfig.cmake]
Checking file [/srv/scratch/entrup/gentoo/usr/local/llvm-config.cmake]
Checking prefix [/srv/scratch/entrup/gentoo/usr/]
Checking file [/srv/scratch/entrup/gentoo/usr/LLVMConfig.cmake]
Checking file [/srv/scratch/entrup/gentoo/usr/llvm-config.cmake]
Checking file [/srv/scratch/entrup/gentoo/usr/lib/llvm/LLVMConfig.cmake]
Checking file [/srv/scratch/entrup/gentoo/usr/lib/llvm/llvm-config.cmake]
Checking prefix [/srv/scratch/entrup/gentoo/]
Checking file [/srv/scratch/entrup/gentoo/LLVMConfig.cmake]
Checking file [/srv/scratch/entrup/gentoo/llvm-config.cmake]
Checking prefix [/srv/scratch/entrup/gentoo/opt/]
Checking prefix [/usr/]
Checking file [/usr/LLVMConfig.cmake]
Checking file [/usr/llvm-config.cmake]
Checking file [/usr/lib/llvm-6.0/LLVMConfig.cmake]
Checking file [/usr/lib/llvm-6.0/llvm-config.cmake]
Checking file [/usr/share/llvm-6.0/LLVMConfig.cmake]
Checking file [/usr/share/llvm-6.0/llvm-config.cmake]
Checking file [/usr/lib/llvm-6.0/cmake/LLVMConfig.cmake]
-- Linker detection: GNU ld
...
```
That means, it actually searches in the Gentoo LLVM but does not find LLVMConfig.cmake there.

Relevant:
```
% pwd
/srv/scratch/entrup/gentoo/usr/lib/llvm
% find -name 'llvm-config.cmake'
% find -name 'LLVMConfig.cmake' 
./9/lib64/cmake/llvm/LLVMConfig.cmake
```
Comment 12 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2019-12-06 13:31:13 UTC
That may actually be a red herring, i.e. the search path accidentally resembling Gentoo LLVM location.
Comment 13 gerion 2019-12-06 14:12:33 UTC
(In reply to Michał Górny from comment #12)
> That may actually be a red herring

Hm, ok. I have tried to use it, anyway. I have put a file "LLVMConfig.cmake" with this content in the LLVM folder (/srv/scratch/entrup/gentoo/usr/lib/llvm/9):
```
include(${CMAKE_CURRENT_LIST_DIR}/lib64/cmake/llvm/LLVMConfig.cmake)
list(APPEND CMAKE_MODULE_PATH ${LLVM_CMAKE_DIR})
```

Clang then builds. Is of course a workaround.
Comment 14 Guilherme Amadio gentoo-dev 2019-12-06 14:44:10 UTC
I have two prefixes, one with clang-5.0 through clang-9.0 installed, and another just with clang-9.0. Could it be a local setup problem? Can you please print your PATH and confirm that you are using CMake from prefix?
Comment 15 gerion 2019-12-06 15:17:31 UTC
(In reply to Guilherme Amadio from comment #14)
> I have two prefixes, one with clang-5.0 through clang-9.0 installed, and
> another just with clang-9.0. Could it be a local setup problem?
I have used the provided interactive script to install prefix. Should be all standard stuff.

> Can you please print your PATH
I have printed my path already.

> and confirm that you are using CMake from prefix?
```
% /srv/scratch/entrup/gentoo/startprefix
Entering Gentoo Prefix /srv/scratch/entrup/gentoo
% which cmake
/srv/scratch/entrup/gentoo/usr/bin/cmake
```
Comment 16 Guilherme Amadio gentoo-dev 2019-12-06 15:45:12 UTC
(In reply to gerion from comment #15)
> (In reply to Guilherme Amadio from comment #14)
> > I have two prefixes, one with clang-5.0 through clang-9.0 installed, and
> > another just with clang-9.0. Could it be a local setup problem?
> I have used the provided interactive script to install prefix. Should be all
> standard stuff.
> 
> > Can you please print your PATH
> I have printed my path already.

Sorry, I only saw that after adding my comment. I see you prepend some things to PATH. That won't play nice with prefix in general, and that could be the cause of your CMake problems, as CMake uses the PATH to search for things by replacing bin directories with other paths. Also, another thing that might create problems is CMake's own package registry in ~/.cmake. If you installed another llvm by hand, check that this registry is not finding stuff for prefix as well.

> > and confirm that you are using CMake from prefix?
> ```
> % /srv/scratch/entrup/gentoo/startprefix
> Entering Gentoo Prefix /srv/scratch/entrup/gentoo
> % which cmake
> /srv/scratch/entrup/gentoo/usr/bin/cmake
> ```

I will try re-emerging clang in my prefixes to check if it's an issue with newer versions of CMake. One thing that might cause problems is the fact that no version is exported in the LLVM CMake configuration, so CMake sometimes mixes things up. Maybe try to add an option of -DLLVM_DIR=/srv/scratch/entrup/gentoo/usr/lib/llvm/9/lib64/cmake/llvm to your EXTRA_ECONF (the directory containing LLVMConfig.cmake) or -DLLVM_CONFIG=/srv/scratch/entrup/gentoo/usr/lib/llvm/9/bin/llvm-config. This is a better workaround than placing an LLVMConfig.cmake where CMake will look based on PATH.
Comment 17 gerion 2019-12-06 16:01:38 UTC
(In reply to Guilherme Amadio from comment #16)
> (In reply to gerion from comment #15)
> > > Can you please print your PATH
> > I have printed my path already.
> 
> Sorry, I only saw that after adding my comment. I see you prepend some
> things to PATH. That won't play nice with prefix in general, and that could
> be the cause of your CMake problems, as CMake uses the PATH to search for
> things by replacing bin directories with other paths.
If I understand Michał Górny right, my local PATH is not respected by Portage anyway but overwritten with another (clean) PATH. But yes, I have already noticed that this mixes things up. Maybe the best way is to do it in the startprefix path.

When I remove my faked LLVMConfig.cmake file and edit my PATH variable so it only contains prefix paths, the error is the same as reported.

> Also, another thing
> that might create problems is CMake's own package registry in ~/.cmake.
I have no ~/.cmake folder or file.

> If you installed another llvm by hand, check that this registry is not finding
> stuff for prefix as well.
I have once done it on another machine but with a shared home directory. However, my hand installed llvm was also a LLVM 9 and not LLVM 6 from Ubuntu.
 
> > > and confirm that you are using CMake from prefix?
> > ```
> > % /srv/scratch/entrup/gentoo/startprefix
> > Entering Gentoo Prefix /srv/scratch/entrup/gentoo
> > % which cmake
> > /srv/scratch/entrup/gentoo/usr/bin/cmake
> > ```
> 
> I will try re-emerging clang in my prefixes to check if it's an issue with
> newer versions of CMake. One thing that might cause problems is the fact
> that no version is exported in the LLVM CMake configuration, so CMake
> sometimes mixes things up. Maybe try to add an option of
> -DLLVM_DIR=/srv/scratch/entrup/gentoo/usr/lib/llvm/9/lib64/cmake/llvm to
> your EXTRA_ECONF (the directory containing LLVMConfig.cmake) or
> -DLLVM_CONFIG=/srv/scratch/entrup/gentoo/usr/lib/llvm/9/bin/llvm-config.
> This is a better workaround than placing an LLVMConfig.cmake where CMake
> will look based on PATH.
Will do, but I don't understand where to place the EXTRA_ECONF variable. Is it within the ebuild or can I place it in make.conf etc?
Comment 18 Guilherme Amadio gentoo-dev 2019-12-06 16:20:42 UTC
(In reply to gerion from comment #17)
> (In reply to Guilherme Amadio from comment #16)
> > I will try re-emerging clang in my prefixes to check if it's an issue with
> > newer versions of CMake. One thing that might cause problems is the fact
> > that no version is exported in the LLVM CMake configuration, so CMake
> > sometimes mixes things up. Maybe try to add an option of
> > -DLLVM_DIR=/srv/scratch/entrup/gentoo/usr/lib/llvm/9/lib64/cmake/llvm to
> > your EXTRA_ECONF (the directory containing LLVMConfig.cmake) or
> > -DLLVM_CONFIG=/srv/scratch/entrup/gentoo/usr/lib/llvm/9/bin/llvm-config.
> > This is a better workaround than placing an LLVMConfig.cmake where CMake
> > will look based on PATH.
> Will do, but I don't understand where to place the EXTRA_ECONF variable. Is
> it within the ebuild or can I place it in make.conf etc?

At first, just use EXTRA_ECONF="..." emerge clang, and if that works, you can create a etc/portage/env/clang and place it there, than add a file etc/portage/pacakge.env with "sys-devel/clang clang" as content.

I will come back to this bug once I can reproduce and debug the problem.
Comment 19 Benda Xu gentoo-dev 2019-12-07 03:46:52 UTC
(In reply to gerion from comment #17)
> (In reply to Guilherme Amadio from comment #16)
> > (In reply to gerion from comment #15)
> > > > Can you please print your PATH
> > > I have printed my path already.
> > 
> > Sorry, I only saw that after adding my comment. I see you prepend some
> > things to PATH. That won't play nice with prefix in general, and that could
> > be the cause of your CMake problems, as CMake uses the PATH to search for
> > things by replacing bin directories with other paths.
> If I understand Michał Górny right, my local PATH is not respected by
> Portage anyway but overwritten with another (clean) PATH. But yes, I have
> already noticed that this mixes things up. Maybe the best way is to do it in
> the startprefix path.
> 
> When I remove my faked LLVMConfig.cmake file and edit my PATH variable so it
> only contains prefix paths, the error is the same as reported.

There could be other environment variables causing trouble, please look for `env | grep PATH` and `env | grep CMAKE` to see if there is anything suspicious.
Comment 20 gerion 2019-12-07 12:20:14 UTC
This is the modified ebuild code:
```
...
multilib_src_compile() {

	echo "---------------------------------: $PATH"
	env | grep lib
	echo "CMAKE"
	env | grep -i cmake
	echo "PATH"
	env | grep -i path
	echo "--------------------------------"

	cmake-utils_src_compile
...
```

and this is the output:

```
>>> Compiling source in /srv/scratch/entrup/gentoo/var/tmp/portage/sys-devel/clang-9.0.0/work/x/y/clang ...
 * abi_x86_64.amd64: running multilib-minimal_abi_src_compile
---------------------------------: /srv/scratch/entrup/gentoo/var/tmp/portage/sys-devel/clang-9.0.0/temp/python3.6/bin:/srv/scratch/entrup/gentoo/usr/lib/llvm/9/bin:/srv/scratch/entrup/gentoo/usr/lib/portage/python3.6/ebuild-helpers/unprivileged:/srv/scratch/entrup/gentoo/usr/lib/portage/python3.6/ebuild-helpers:/srv/scratch/entrup/gentoo/usr/lib/llvm/9/bin:/srv/scratch/entrup/gentoo/usr/local/sbin:/srv/scratch/entrup/gentoo/usr/local/bin:/srv/scratch/entrup/gentoo/usr/sbin:/srv/scratch/entrup/gentoo/usr/bin:/srv/scratch/entrup/gentoo/sbin:/srv/scratch/entrup/gentoo/bin:/srv/scratch/entrup/gentoo/opt/bin:/usr/sbin:/sbin:/usr/bin:/bin
PORTAGE_PYTHONPATH=/srv/scratch/entrup/gentoo/usr/lib64/python3.6/site-packages
PORTAGE_FEATURES=sfperms protect-owned unmerge-orphans binpkg-logs parallel-install unprivileged pid-sandbox parallel-fetch merge-sync binpkg-docompress config-protect-if-modified multilib-strict preserve-libs network-sandbox unknown-features-warn fixlafiles strict news ipc-sandbox force-prefix assume-digests unmerge-logs nostrip ebuild-locks binpkg-dostrip distlocks
ROOTPATH=/srv/scratch/entrup/gentoo/usr/lib/llvm/9/bin:/srv/scratch/entrup/gentoo/usr/local/sbin:/srv/scratch/entrup/gentoo/usr/local/bin:/srv/scratch/entrup/gentoo/usr/sbin:/srv/scratch/entrup/gentoo/usr/bin:/srv/scratch/entrup/gentoo/sbin:/srv/scratch/entrup/gentoo/bin:/srv/scratch/entrup/gentoo/opt/bin:/usr/sbin:/sbin:/usr/bin:/bin
MULTILIB_STRICT_DIRS=/lib32 /lib /usr/lib32 /usr/lib /usr/kde/*/lib32 /usr/kde/*/lib /usr/qt/*/lib32 /usr/qt/*/lib /usr/X11R6/lib32 /usr/X11R6/lib
IUSE_EFFECTIVE=abi_mips_n32 abi_mips_n64 abi_mips_o32 abi_riscv_lp64 abi_riscv_lp64d abi_s390_32 abi_s390_64 abi_x86_32 abi_x86_64 abi_x86_x32 alpha amd64 amd64-fbsd amd64-linux arm arm64 debug default-compiler-rt default-libcxx doc elibc_AIX elibc_Cygwin elibc_Darwin elibc_DragonFly elibc_FreeBSD elibc_HPUX elibc_Interix elibc_NetBSD elibc_OpenBSD elibc_SunOS elibc_Winnt elibc_bionic elibc_glibc elibc_mingw elibc_mintlib elibc_musl elibc_uclibc hppa ia64 kernel_AIX kernel_Darwin kernel_FreeBSD kernel_HPUX kernel_NetBSD kernel_OpenBSD kernel_SunOS kernel_Winnt kernel_freemint kernel_linux llvm_targets_AArch64 llvm_targets_AMDGPU llvm_targets_ARM llvm_targets_BPF llvm_targets_Hexagon llvm_targets_Lanai llvm_targets_MSP430 llvm_targets_Mips llvm_targets_NVPTX llvm_targets_PowerPC llvm_targets_RISCV llvm_targets_Sparc llvm_targets_SystemZ llvm_targets_WebAssembly llvm_targets_X86 llvm_targets_XCore m68k m68k-mint mips ppc ppc-aix ppc-macos ppc64 ppc64-linux prefix prefix-guest prefix-stack python_single_target_python2_7 python_single_target_python3_5 python_single_target_python3_6 python_single_target_python3_7 python_targets_python2_7 python_targets_python3_5 python_targets_python3_6 python_targets_python3_7 riscv s390 sh sparc sparc-solaris sparc64-solaris static-analyzer test userland_BSD userland_GNU x64-cygwin x64-macos x64-solaris x86 x86-cygwin x86-fbsd x86-linux x86-macos x86-solaris x86-winnt xml
INHERITED= toolchain-funcs multilib multiprocessing ninja-utils eutils flag-o-matic xdg-utils cmake-utils llvm llvm.org multibuild multilib-build multilib-minimal pax-utils python-utils-r1 python-single-r1
LIBDIR_amd64=lib64
FEATURES=sfperms protect-owned unmerge-orphans binpkg-logs parallel-install unprivileged pid-sandbox parallel-fetch merge-sync binpkg-docompress config-protect-if-modified multilib-strict preserve-libs network-sandbox unknown-features-warn fixlafiles strict news ipc-sandbox force-prefix assume-digests unmerge-logs nostrip ebuild-locks binpkg-dostrip distlocks
PORTAGE_BIN_PATH=/srv/scratch/entrup/gentoo/usr/lib/portage/python3.6
PORTAGE_PYM_PATH=/srv/scratch/entrup/gentoo/usr/lib64/python3.6/site-packages
MULTILIB_STRICT_EXEMPT=(perl5|gcc|gcc-lib|binutils|eclipse-3|debug|portage|udev|systemd|clang|python-exec|llvm)
BOOTSTRAP_USE=unicode internal-glib pkg-config split-usr python_targets_python3_6 python_targets_python2_7 multilib
LIBDIR_x32=libx32
USE_EXPAND_VALUES_ELIBC=AIX bionic Cygwin Darwin DragonFly FreeBSD glibc HPUX Interix mingw mintlib musl NetBSD OpenBSD SunOS uclibc Winnt
LIBDIR_default=lib
PATH=/srv/scratch/entrup/gentoo/var/tmp/portage/sys-devel/clang-9.0.0/temp/python3.6/bin:/srv/scratch/entrup/gentoo/usr/lib/llvm/9/bin:/srv/scratch/entrup/gentoo/usr/lib/portage/python3.6/ebuild-helpers/unprivileged:/srv/scratch/entrup/gentoo/usr/lib/portage/python3.6/ebuild-helpers:/srv/scratch/entrup/gentoo/usr/lib/llvm/9/bin:/srv/scratch/entrup/gentoo/usr/local/sbin:/srv/scratch/entrup/gentoo/usr/local/bin:/srv/scratch/entrup/gentoo/usr/sbin:/srv/scratch/entrup/gentoo/usr/bin:/srv/scratch/entrup/gentoo/sbin:/srv/scratch/entrup/gentoo/bin:/srv/scratch/entrup/gentoo/opt/bin:/usr/sbin:/sbin:/usr/bin:/bin
USE=abi_x86_64 amd64 elibc_glibc kernel_linux llvm_targets_ARM llvm_targets_BPF llvm_targets_RISCV llvm_targets_WebAssembly llvm_targets_X86 prefix python_single_target_python3_6 python_targets_python2_7 python_targets_python3_6 python_targets_python3_7 static-analyzer userland_GNU
LIBDIR_x86=lib32
ELIBC=glibc
CMAKE
INHERITED= toolchain-funcs multilib multiprocessing ninja-utils eutils flag-o-matic xdg-utils cmake-utils llvm llvm.org multibuild multilib-build multilib-minimal pax-utils python-utils-r1 python-single-r1
PATH
PORTAGE_PYTHONPATH=/srv/scratch/entrup/gentoo/usr/lib64/python3.6/site-packages
ROOTPATH=/srv/scratch/entrup/gentoo/usr/lib/llvm/9/bin:/srv/scratch/entrup/gentoo/usr/local/sbin:/srv/scratch/entrup/gentoo/usr/local/bin:/srv/scratch/entrup/gentoo/usr/sbin:/srv/scratch/entrup/gentoo/usr/bin:/srv/scratch/entrup/gentoo/sbin:/srv/scratch/entrup/gentoo/bin:/srv/scratch/entrup/gentoo/opt/bin:/usr/sbin:/sbin:/usr/bin:/bin
PKG_CONFIG_PATH=/srv/scratch/entrup/gentoo/var/tmp/portage/sys-devel/clang-9.0.0/temp/python3.6/pkgconfig
FPATH=/home/srastaff/entrup/.local/share/zplug/repos/rust-lang/zsh-config:/home/srastaff/entrup/.local/share/zplug/autoload:/home/srastaff/entrup/.local/share/zplug/misc/completions:/home/srastaff/entrup/.local/share/zplug/base/sources:/home/srastaff/entrup/.local/share/zplug/base/utils:/home/srastaff/entrup/.local/share/zplug/base/job:/home/srastaff/entrup/.local/share/zplug/base/log:/home/srastaff/entrup/.local/share/zplug/base/io:/home/srastaff/entrup/.local/share/zplug/base/core:/home/srastaff/entrup/.local/share/zplug/base/base:/home/srastaff/entrup/.local/share/zplug/autoload/commands:/home/srastaff/entrup/.local/share/zplug/autoload/options:/home/srastaff/entrup/.local/share/zplug/autoload/tags:/srv/scratch/entrup/gentoo/usr/local/share/zsh/site-functions:/srv/scratch/entrup/gentoo/usr/share/zsh/site-functions:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/Calendar:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/Chpwd:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/Completion:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/Completion/AIX:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/Completion/BSD:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/Completion/Base:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/Completion/Cygwin:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/Completion/Darwin:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/Completion/Debian:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/Completion/Linux:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/Completion/Mandriva:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/Completion/Redhat:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/Completion/Solaris:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/Completion/Unix:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/Completion/X:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/Completion/Zsh:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/Completion/openSUSE:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/Exceptions:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/MIME:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/Math:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/Misc:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/Newuser:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/Prompts:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/TCP:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/VCS_Info:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/VCS_Info/Backends:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/Zftp:/srv/scratch/entrup/gentoo/usr/share/zsh/5.7.1/functions/Zle
_ZPLUG_AWKPATH=/home/srastaff/entrup/.local/share/zplug/misc/contrib
PORTAGE_BIN_PATH=/srv/scratch/entrup/gentoo/usr/lib/portage/python3.6
PORTAGE_PYM_PATH=/srv/scratch/entrup/gentoo/usr/lib64/python3.6/site-packages
sync-openpgp-key-path = /srv/scratch/entrup/gentoo/usr/share/openpgp-keys/gentoo-release.asc
PATH=/srv/scratch/entrup/gentoo/var/tmp/portage/sys-devel/clang-9.0.0/temp/python3.6/bin:/srv/scratch/entrup/gentoo/usr/lib/llvm/9/bin:/srv/scratch/entrup/gentoo/usr/lib/portage/python3.6/ebuild-helpers/unprivileged:/srv/scratch/entrup/gentoo/usr/lib/portage/python3.6/ebuild-helpers:/srv/scratch/entrup/gentoo/usr/lib/llvm/9/bin:/srv/scratch/entrup/gentoo/usr/local/sbin:/srv/scratch/entrup/gentoo/usr/local/bin:/srv/scratch/entrup/gentoo/usr/sbin:/srv/scratch/entrup/gentoo/usr/bin:/srv/scratch/entrup/gentoo/sbin:/srv/scratch/entrup/gentoo/bin:/srv/scratch/entrup/gentoo/opt/bin:/usr/sbin:/sbin:/usr/bin:/bin
--------------------------------
>>> Working in BUILD_DIR: "/srv/scratch/entrup/gentoo/var/tmp/portage/sys-devel/clang-9.0.0/work/x/y/clang-abi_x86_64.amd64"
ninja -v -j96 -l0
ninja: error: '/usr/lib/llvm-6.0/lib/cmake/llvm/GenerateVersionFromVCS.cmake', needed by 'lib/Basic/VCSVersion.inc', missing and no known rule to make it
```
Comment 21 gerion 2019-12-07 12:21:49 UTC
BTW: Is there any mechanism to embed formatted code in Bugzilla?
Comment 22 Fabian Groffen gentoo-dev 2021-08-29 14:35:06 UTC
we would have to revisit this with current versions