Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[package] qt/6.7.1: cannot build without system installed libclang #24729

Closed
weatherhead99 opened this issue Jul 26, 2024 · 8 comments
Closed
Labels
bug Something isn't working

Comments

@weatherhead99
Copy link
Contributor

weatherhead99 commented Jul 26, 2024

Description

I can no longer build the qt recipe without installing libclang on my system. The submodule "qttools" depends on libclang,
but passing -oqt/*:qttools=False does not prevent building of the qttools module, because it is marked as "essential" (#24481).

I understand there is not a conan recipe that contains libclang, fair enough, but there should be some way to build this without an installed libclang. I do not believe qttools actually is "essential" especially because one could also disable qtdoc and qttranslations which depend on it.

Furthermore, if a system libclang is going to be required, it should be actually in the dependencies of the conan file (i.e. via a "libclang/system" package or similar), and not implicitly assumed.

Package and Environment Details

  • Package Name/Version: qt/6.7.1
  • Operating System+version: Debian 12
  • Compiler+version: GCC 12.2
  • Conan version: conan 2.5.0
  • Python version: Python 3.10.12 (anaconda)

Conan profile

Host profile:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu20
compiler.libcxx=libstdc++11
compiler.version=12
os=Linux
[options]
/:shared=True
qt/*:with_x11=False
[conf]
tools.gnu:pkg_config=/usr/bin/pkg-config

Build profile:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu20
compiler.libcxx=libstdc++11
compiler.version=12
os=Linux
[options]
/:shared=True
qt/*:with_x11=False
[conf]
tools.gnu:pkg_config=/usr/bin/pkg-config

Steps to reproduce

conan install qt/6.7./1@ --build=missing -oqt/:qttools=False -oqt/:qttranslations=False -oqt/*:qtdoc=False

Logs

======== Computing dependency graph ========
ERROR: qt/6.7.1: Error in configure() method, line 230
_enablemodule(module_name)
while calling '_enablemodule', line 220
_enablemodule(req)
while calling '_enablemodule', line 218
setattr(self.options, mod, True)
ConanException: Incorrect attempt to modify option 'qttools' from 'False' to 'True'

@weatherhead99 weatherhead99 added the bug Something isn't working label Jul 26, 2024
@planetmarshall
Copy link
Contributor

#22997 tangentially related as it makes a libclang recipe possible,however that PR has been green for months and I'm becoming a bit disillusioned with making further contributions.

@jwillikers
Copy link
Contributor

jwillikers commented Jul 27, 2024

Yes, this has been a problem for a while now but progress adding anything having to do with LLVM from community contributors tends to end up languishing. You can try commenting on #23834 perhaps to try to get something to happen, but nothing has come of that issue even with all of the interest shown. We basically also need a libc++ package if you want to build Qt using libc++ as well.

@weatherhead99
Copy link
Contributor Author

I was able to get it to build by editing the modules.yml file to make QtTranslation and QtTools not "essential". I think in lieu of getting a conan packaged libClang this might be the way to go, because in my view Qt is still useful without these "essential" features. For my own use, I'm happy to have a distro packaged Qt with all the bells and whistles. Where I need the conan build, I don't generally need the translation tools etc tbh.

@weatherhead99
Copy link
Contributor Author

p.s. I personally do not need to build Qt with libc++. I want to build everything with libstdc++ and gcc. The only need for libclang is for the qttools module - come to think of it, another way round this problem in my particular case is to install libclang from the conda package.

@jcar87
Copy link
Contributor

jcar87 commented Jul 28, 2024

Hi @weatherhead99 , thank you for reporting this

I can no longer build the qt recipe without installing libclang on my system.

Was there a version or revision of the recipe where you could build qt 6.7.1 without having libclang installed?

if the answer is yes - I have a strong suspicion it is related to this PR: #24701 - if this was the cause, if we cannot find a trivial solution, will revert this one to its previous state

The submodule "qttools" depends on libclang,

This is true, however, it should not error out if it doesn't find libclang - it displays a warning that qdoc cannot be compiled and carries on without issue.

On Debian bookworm without having libclang installed in any way, I'm able to build successfully:

conan create . --version=6.7.1 -c tools.system.package_manager:mode=install -o "qt/*:with_x11=False" -o "*:shared=True"

And the build proceeds successfully.

-oqt/*:qttools=False does not prevent building of the qttools module, because it is marked as "essential" (#24481).

Indeed this is a separate bug - I have been tasked with looking after the qt recipe this week and the next, so this is in our radar.

Could you post what error you are getting when you try to build qt 6.7.1 and something complains about libclang?

If you are getting something like this:

-- Configuring submodule 'qttools'
CMake Error at /usr/lib/cmake/clang-14/ClangConfig.cmake:10 (find_package):
  Could not find a package configuration file provided by "LLVM" with any of
  the following names:

    LLVMConfig.cmake
    llvm-config.cmake

  Add the installation prefix of "LLVM" to CMAKE_PREFIX_PATH or set
  "LLVM_DIR" to a directory containing one of the above files.  If "LLVM"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  qttools/cmake/FindWrapLibClang.cmake:17 (find_package)
  qtbase/cmake/QtFindPackageHelpers.cmake:156 (find_package)
  qttools/configure.cmake:20 (qt_find_package)
  qtbase/cmake/QtFeature.cmake:678 (include)
  qttools/src/CMakeLists.txt:18 (qt_feature_evaluate_features)

it means that there is a partial installation of clang that may or may not have libclang, but it doesn't have all the development finds it needs.

@weatherhead99 - if you are using a recent version of Conan 2 (I'm using 2.5.0), could you try building qt with the following conf? It can be passed without modifying the recipe, e.g:

-c tools.cmake.cmaketoolchain:extra_variables="{'CMAKE_DISABLE_FIND_PACKAGE_WrapLibClang':'ON'}"

alternatively, it can be added to the profiles.

This will prevent trying to locate libclang altogether, which is only needed for qtdoc and is optional - regardless of whether there may or may not be a case for requiring libclang from a conan package, I think this falls more in the realm of recipes should disable conditionals on system instrospection.

@weatherhead99
Copy link
Contributor Author

weatherhead99 commented Jul 28, 2024

Hi @jcar87,
thanks for the reply. Firstly sorry I wasn't clear enough, I have never been able to build qt/6.7.1 on this configuration, we didn't try this version before. But I was able to use it I think with earlier qt6 version, can't tell you which one exactly I'm afraid.

Here is the error I get, when building a package which depends on qt/6.7.1 -o shared=True, using --build=missing...

qt/6.7.1: RUN: cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE="/local/home/weatherill/scratch/conan2data/b/qt43fe28f4b9f3e/b/build/Release/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/local/home/weat
herill/scratch/conan2data/b/qt43fe28f4b9f3e/p" -DQT_USE_VCPKG="OFF" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/local/home/weatherill/scratch/conan2data/qt780dc2f7053e8/s/src"       
-- Using Conan toolchain: /local/home/weatherill/scratch/conan2data/b/qt43fe28f4b9f3e/b/build/Release/generators/conan_toolchain.cmake                                                                        
-- Conan toolchain: Defining architecture flag: -m64                                                                                                                                                          
-- Conan toolchain: C++ Standard 20 with extensions ON                                                                                                                                                        
-- Conan toolchain: Setting BUILD_SHARED_LIBS = ON                                                                                                                                                            
-- The CXX compiler identification is GNU 12.2.0                                                                                                                                                              
-- The C compiler identification is GNU 12.2.0                                                                                                                                                                
-- The ASM compiler identification is GNU                                                                                                                                                                     
-- Found assembler: /usr/bin/cc     
-- Detecting CXX compiler ABI info              
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features         
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info       
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features      
-- Detecting C compile features - done
-- Checking dependencies of submodule 'qtbase'
-- Checking dependencies of submodule 'qtdeclarative'
-- Skipping optional dependency 'qtimageformats' of 'qtdeclarative', because building 'qtimageformats' was explicitly disabled.
-- Skipping optional dependency 'qtlanguageserver' of 'qtdeclarative', because building 'qtlanguageserver' was explicitly disabled.
-- Skipping optional dependency 'qtshadertools' of 'qtdeclarative', because building 'qtshadertools' was explicitly disabled.
-- Skipping optional dependency 'qtsvg' of 'qtdeclarative', because building 'qtsvg' was explicitly disabled.
-- Checking dependencies of submodule 'qttools'
-- Skipping optional dependency 'qtactiveqt' of 'qttools', because building 'qtactiveqt' was explicitly disabled.
-- Checking dependencies of submodule 'qtdoc'
-- Skipping optional dependency 'qtgraphs' of 'qtdoc', because building 'qtgraphs' was explicitly disabled.
-- Skipping optional dependency 'qthttpserver' of 'qtdoc', because building 'qthttpserver' was explicitly disabled.
-- Skipping optional dependency 'qtlocation' of 'qtdoc', because building 'qtlocation' was explicitly disabled.
-- Skipping optional dependency 'qtmultimedia' of 'qtdoc', because building 'qtmultimedia' was explicitly disabled.
-- Skipping optional dependency 'qtpositioning' of 'qtdoc', because building 'qtpositioning' was explicitly disabled.
-- Skipping optional dependency 'qtshadertools' of 'qtdoc', because building 'qtshadertools' was explicitly disabled.
-- Skipping optional dependency 'qtwebengine' of 'qtdoc', because building 'qtwebengine' was explicitly disabled.
-- Skipping optional dependency 'qtwebsockets' of 'qtdoc', because building 'qtwebsockets' was explicitly disabled.
-- Checking dependencies of submodule 'qttranslations'          
-- Configuring submodule 'qtbase'
-- [QtBase] CMAKE_BUILD_TYPE was already explicitly set to: 'Release'
            -DCMAKE_C_FLAGS=-m64
            -DCMAKE_C_FLAGS_DEBUG=-g                                                                   
            -DCMAKE_C_FLAGS_RELEASE=-O3 -DNDEBUG
            -DCMAKE_C_FLAGS_RELWITHDEBINFO=-O2 -g -DNDEBUG
            -DCMAKE_CXX_FLAGS=-m64
            -DCMAKE_CXX_FLAGS_DEBUG=-g
            -DCMAKE_CXX_FLAGS_RELEASE=-O3 -DNDEBUG
            -DCMAKE_CXX_FLAGS_RELWITHDEBINFO=-O2 -g -DNDEBUG
            -DCMAKE_OBJCOPY=/usr/bin/objcopy                                                           
            -DCMAKE_EXE_LINKER_FLAGS=-m64                                                              
            -DCMAKE_TOOLCHAIN_FILE=/local/home/weatherill/scratch/conan2data/b/qt43fe28f4b9f3e/b/build/Release/generators/conan_toolchain.cmake
            -DCMAKE_C_STANDARD=11             
            -DCMAKE_C_STANDARD_REQUIRED=ON  
            -DCMAKE_CXX_STANDARD=17                                                                    
            -DCMAKE_CXX_STANDARD_REQUIRED=ON
            -DCMAKE_MODULE_PATH:STRING=/local/home/weatherill/scratch/conan2data/qt780dc2f7053e8/s/src/qtbase/cmake/platforms

then some other unrelated output I think, then:


-- Configuring submodule 'qtquicktimeline'
-- Configuring submodule 'qtquick3d'
-- Configuring submodule 'qtmultimedia'
-- Configuring submodule 'qt3d'
-- Configuring submodule 'qt5compat'
-- Configuring submodule 'qtactiveqt'
-- Configuring submodule 'qtcharts'
-- Configuring submodule 'qtcoap'
-- Configuring submodule 'qtconnectivity'
-- Configuring submodule 'qtdatavis3d'
-- Configuring submodule 'qtgraphs'
-- Configuring submodule 'qtwebsockets'
-- Configuring submodule 'qthttpserver'
-- Configuring submodule 'qtserialport'
-- Configuring submodule 'qtpositioning'
-- Configuring submodule 'qtlocation'
-- Configuring submodule 'qttools'
CMake Error at /usr/lib/llvm-14/lib/cmake/clang/ClangTargets.cmake:756 (message):
  The imported target "clangBasic" references the file

     "/usr/lib/llvm-14/lib/libclangBasic.a"

  but this file does not exist.  Possible reasons include:

  * The file was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and contained

     "/usr/lib/llvm-14/lib/cmake/clang/ClangTargets.cmake"

  but not all the files it references.

Call Stack (most recent call first):
  /usr/lib/cmake/clang-14/ClangConfig.cmake:19 (include)
  qttools/cmake/FindWrapLibClang.cmake:17 (find_package)
  qtbase/cmake/QtFindPackageHelpers.cmake:156 (find_package)
  qttools/configure.cmake:20 (qt_find_package)
  qtbase/cmake/QtFeature.cmake:678 (include)
  qttools/src/CMakeLists.txt:18 (qt_feature_evaluate_features)

is it possible that this is related to me using Ninja as the generator?

running with the CMAKE_DISABLE_FIND_PACKAGE_WrapLibClang option, I get the below warning (expected I guess!) and then the build seems to proceed correctly.

WARNING: QDoc will not be compiled, probably because clang's C and C++ libraries could not be located. This means that you cannot build the Qt documentation.                                                 
You may need to set CMAKE_PREFIX_PATH or LLVM_INSTALL_DIR to the location of your llvm installation.                                                                                                          
Other than clang's libraries, you may need to install another package, such as clang itself, to provide the ClangConfig.cmake file needed to detect your libraries. Once this                                 
file is in place, the configure script may be able to detect your system-installed libraries without further environment variables.
On macOS, you can use Homebrew's llvm package.
You will also need to set the FEATURE_clang CMake variable to ON to re-evaluate this check.
WARNING: Clang-based lupdate parser will not be available. Suitable LLVM and Clang C++ libraries have not been found.
You will need to set the FEATURE_clangcpp CMake variable to ON to re-evaluate this check.

looking at it carefully, I suppose this may be somehow related to a borked Debian package or missing package installation on the system. On this particular system I don't have root so I'm afraid I can't easily test that. I should point out perhaps that it seems that whilst I don't have libClangBasic.a on this system, I DO have a shared library install of libclang, at /usr/lib/llvm-14/lib/libclang-14.so.1 . So maybe somehow qt is asking for static libclang rather than shared libclang here...

@jcar87
Copy link
Contributor

jcar87 commented Jul 29, 2024

Thanks @weatherhead99 for following up on this! This makes more sense now.

I think the reality is that Qt6 has "looked for" libclang for a while - even if the recipe never had that listes as a dependency. Most devs will get a successful build if find_package(Clang) fails early (the build will proceed and won't build QDoc) or if find_package(Clang) fully succeeds and contains the targets needed (it will build QDoc).

This is generally undesirable - as that leaves it unpredictable based on system state.

I should point out perhaps that it seems that whilst I don't have libClangBasic.a on this system, I DO have a shared library install of libclang, at /usr/lib/llvm-14/lib/libclang-14.so.1 .

What's happening in your case is that find_package(Clang) finds a clang at /usr/lib/cmake/clang-14/ClangConfig.cmake - but then the file doesn't fully process. I think it would need libclang-dev or similar to be "complete". The -dev packages contain static libraries and things like cmake config files, which would be needed here.

So maybe somehow qt is asking for static libclang rather than shared libclang here...

I think Qt specifically isn't - it's the config files debian ships that seem to require this target to at least be present.

I DO have a shared library install of libclang, at /usr/lib/llvm-14/lib/libclang-14.so.1

Interestingly, LLVM themselves don't recommend building it as shared libraries: https://llvm.org/docs/CMake.html and the docs still recommend this only for LLVM developers.

I'd say that we should add CMAKE_DISABLE_FIND_PACKAGE_WrapLibClang to the recipe - on the balance of probabilities (and considering this is not technically a new issue) - I'd say QDocs is probably not something most qt users will want, also judging by Qt's own build instructions and the fact that they ship prebuilt libclang binaries https://download.qt.io/development_releases/prebuilt/libclang/) because some clang distributions won't come with the right set of files!
In the future we can look into integrating it with a conan-provided libclang.

@jcar87
Copy link
Contributor

jcar87 commented Jul 30, 2024

Closing via #24753, thank you for reporting this.

We're making an assumption that the QDoc tool is optional, and mainly useful for generating docs for Qt itself - and thus unlikely to be of much use for consumers of the qt recipe - but if this is not the case, we will of course reassess.

@jcar87 jcar87 closed this as completed Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants