Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 903646 - sys-devel/clang-16: fails to compile (Cannot set CLANG_LINK_CLANG_DYLIB=ON when LLVM_LINK_LLVM_DYLIB=OFF)
Summary: sys-devel/clang-16: fails to compile (Cannot set CLANG_LINK_CLANG_DYLIB=ON wh...
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: LLVM support project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-03-31 17:42 UTC by rlkandela
Modified: 2023-04-13 06:55 UTC (History)
1 user (show)

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


Attachments
Output of emerge --info (emerge_info.txt,7.79 KB, text/plain)
2023-03-31 17:42 UTC, rlkandela
Details
complete build log (build.log,10.85 KB, text/plain)
2023-04-11 21:39 UTC, rlkandela
Details
grep of LLVMConfig.cmake (grep.log,474 bytes, text/plain)
2023-04-12 10:54 UTC, rlkandela
Details
debug1.patch (debug1.patch,408 bytes, patch)
2023-04-12 16:03 UTC, Michał Górny
Details | Diff
Complete build log with the debug1.patch applied (build.log,6.94 KB, text/plain)
2023-04-12 19:55 UTC, rlkandela
Details

Note You need to log in before you can comment on or make changes to this bug.
Description rlkandela 2023-03-31 17:42:01 UTC
Created attachment 859354 [details]
Output of emerge --info

When compiling clang new slot 16 fails to build with the next error 


CMake Error at CMakeLists.txt:270 (message):
  Cannot set CLANG_LINK_CLANG_DYLIB=ON when LLVM_LINK_LLVM_DYLIB=OFF

I have recompiled llvm to make sure that -DLLVM_LINK_LLVM_DYLIB was passed as ON, and it was, but for whatever reason clang keeps outputing an error telling that it's off
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-03-31 17:44:46 UTC
Please always include the full build.log.
Comment 2 rlkandela 2023-04-11 21:38:40 UTC
I have tried to make an attachment with the complete build log but it fails to submit, I will append it asap.
Comment 3 rlkandela 2023-04-11 21:39:57 UTC
Created attachment 859897 [details]
complete build log
Comment 4 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-04-12 08:04:18 UTC
CMake Error at CMakeLists.txt:270 (message):
  Cannot set CLANG_LINK_CLANG_DYLIB=ON when LLVM_LINK_LLVM_DYLIB=OFF


-- Configuring incomplete, errors occurred!
 [31;01m*[0m ERROR: sys-devel/clang-16.0.1::gentoo failed (configure phase):
 [31;01m*[0m   cmake failed
Comment 5 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2023-04-12 08:06:59 UTC
$ grep -RH LLVM_LINK_LLVM /usr/lib/llvm/*/lib*/cmake/llvm/LLVMConfig.cmake

plz.
Comment 6 rlkandela 2023-04-12 10:53:16 UTC
(In reply to Michał Górny from comment #5)
> $ grep -RH LLVM_LINK_LLVM /usr/lib/llvm/*/lib*/cmake/llvm/LLVMConfig.cmake
> 
> plz.

It's quite brief, but I will add it as an attachment anyways.

/usr/lib/llvm/14/lib64/cmake/llvm/LLVMConfig.cmake:set(LLVM_LINK_LLVM_DYLIB ON)
/usr/lib/llvm/14/lib/cmake/llvm/LLVMConfig.cmake:set(LLVM_LINK_LLVM_DYLIB ON)
/usr/lib/llvm/15/lib64/cmake/llvm/LLVMConfig.cmake:set(LLVM_LINK_LLVM_DYLIB ON)
/usr/lib/llvm/15/lib/cmake/llvm/LLVMConfig.cmake:set(LLVM_LINK_LLVM_DYLIB ON)
/usr/lib/llvm/16/lib64/cmake/llvm/LLVMConfig.cmake:set(LLVM_LINK_LLVM_DYLIB ON)
/usr/lib/llvm/16/lib/cmake/llvm/LLVMConfig.cmake:set(LLVM_LINK_LLVM_DYLIB ON)
Comment 7 rlkandela 2023-04-12 10:54:44 UTC
Created attachment 859935 [details]
grep of LLVMConfig.cmake
Comment 8 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2023-04-12 16:03:01 UTC
Created attachment 859941 [details, diff]
debug1.patch

I'm afraid I have no clue what's happening here.  Clearly the .cmake files have the correct value, and clang doesn't override it anywhere.

Try using the attached patch (debug1.patch).  It should cause CMake to fail with the value of LLVM_LINK_LLVM_DYLIB after LLVMConfig.cmake is supposedly loaded.  On my system, it prints:

CMake Error at CMakeLists.txt:39 (message):
  ON


-- Configuring incomplete, errors occurred!
Comment 9 rlkandela 2023-04-12 19:55:15 UTC
Seems to be unset, because it's not printing any value

CMake Error at CMakeLists.txt:39 (message):


-- Configuring incomplete, errors occurred!

and the patch is correctly applied

 * Applying user patches from /etc/portage/patches ...
 * Applying debug1.patch ...                       [ ok ]
 * User patches applied.

I will upload the complete build log of the patch anyways in case it's useful
Comment 10 rlkandela 2023-04-12 19:55:58 UTC
Created attachment 859962 [details]
Complete build log with the debug1.patch applied
Comment 11 rlkandela 2023-04-12 20:01:00 UTC
Also, I have been looking in the work/clang/CMakeLists.txt and the patch seems correctly aplied


    mark_as_advanced(LLVM_ENABLE_ASSERTIONS)
  endif()

  find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
  message(FATAL_ERROR ${LLVM_LINK_LLVM_DYLIB})
  list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")

  # Turn into CACHE PATHs for overwritting
Comment 12 rlkandela 2023-04-12 20:43:00 UTC
I didn't knew I could patch files from the package I was going to install before you mentioned it. I have been messing around with the patch and printing some vars and now I think I know what happens. I printed this stuff

message(FATAL_ERROR "${LLVM_LINK_LLVM_DYLIB} ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH} @ ${LLVM_DIR} @ ${LLVM_CMAKE_DIR}")

And this is what got printed

   16.0.0 @ /opt/llvmv7emhf/lib/cmake/llvm @ /opt/llvmv7emhf/lib/cmake/llvm

I don't really know if this is made by crossdev or it was me messing with llvm, i might move it and try the system to see if nothing complains and then proceed to delete it
Comment 13 rlkandela 2023-04-12 21:09:18 UTC
Once I moved it, without removing the patch, this is the output message

  ON 16.0.1 @ /usr/lib/llvm/16/lib/cmake/llvm @
  /usr/lib/llvm/16/lib/cmake/llvm

I checked the reverse dependencies of llvm:16 just in case I had to recompile any package (there were none) and now it's compiling already.

Thank you very much, for the help and for what you taught me, 
For me this can be marked as resolved.
Comment 14 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2023-04-13 06:55:52 UTC
I'm guessing PEBKAC then.  You really shouldn't be putting custom stuff in PATH ahead of system stuff.