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

Cannot build standalone clang due to missing DeviceConfigFile #13396

Closed
MordragT opened this issue Apr 14, 2024 · 5 comments
Closed

Cannot build standalone clang due to missing DeviceConfigFile #13396

MordragT opened this issue Apr 14, 2024 · 5 comments
Labels
bug Something isn't working Need info Some clarifications are needed from the reporter

Comments

@MordragT
Copy link

MordragT commented Apr 14, 2024

Describe the bug

I am not able to build a standalone clang with my prebuilt llvm.
These are the flags I use to build llvm:

    cmakeFlags = [
      "-DCMAKE_BUILD_TYPE=Release"
      "-DLLVM_TARGETS_TO_BUILD=X86"
      "-DLLVM_INSTALL_UTILS=ON"
      "-DLLVM_INSTALL_BINUTILS_SYMLINKS=ON"

      # intrinsics
      "-DLLVMGenXIntrinsics_SOURCE_DIR=${pins.vc-intrinsics}"

      # tests
      "-DLLVM_INCLUDE_TESTS=OFF"
      "-DLLVM_BUILD_TESTS=OFF"
      "-DLLVM_ENABLE_ASSERTIONS=OFF"

      # docs
      "-DLLVM_ENABLE_DOXYGEN=OFF"
      "-DLLVM_ENABLE_SPHINX=OFF"

      # spirv
      "-DLLVM_EXTERNAL_PROJECTS=llvm-spirv"
      "-DLLVM_ENABLE_PROJECTS=llvm-spirv"
      "-DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=${pins.spirv-headers}"
      "-DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR=/build/source/llvm-spirv"
    ];

And these are the flags for clang:

  cmakeFlags = [
    "-DCMAKE_BUILD_TYPE=Release"
    "-DLLVM_TARGETS_TO_BUILD=X86"
    "-DLLVM_INCLUDE_TESTS=OFF"
    "-DLLVM_ENABLE_ASSERTIONS=OFF"
  ];

Here is the error message I am getting:

Call Stack (most recent call first):
  cmake/modules/CMakeLists.txt:59 (extend_path)


-- Configuring done (8.6s)
CMake Error at /nix/store/l5mjyks0xhmr9dyjh0wqdsmmb4by56wn-intel-llvm-18.0.0-unstable-2024-04-12/lib/cmake/llvm/AddLLV>
  The dependency target "DeviceConfigFile" of target "obj.clangDriver" does
  not exist.
Call Stack (most recent call first):
  cmake/modules/AddClang.cmake:106 (llvm_add_library)
  lib/Driver/CMakeLists.txt:24 (add_clang_library)


CMake Error at /nix/store/l5mjyks0xhmr9dyjh0wqdsmmb4by56wn-intel-llvm-18.0.0-unstable-2024-04-12/lib/cmake/llvm/AddLLV>
  The dependency target "DeviceConfigFile" of target "clangDriver" does not
  exist.
Call Stack (most recent call first):
  cmake/modules/AddClang.cmake:106 (llvm_add_library)
  lib/Driver/CMakeLists.txt:24 (add_clang_library)

With my very limited knowledge I am suspecting something is going wrong with clang's tablegen ?

To reproduce

No response

Environment

No response

Additional context

I am trying to package intel llvm for Nixos. I have already sucessfully built llvm with inbuilt clang etc. with the following derivation:

Edit: This is actually an edited version in the original I had also clang enabled

{
  callPackage,
  fetchFromGitHub,
  level-zero,
  boost,
  ocl-icd,
  opencl-headers,
}: let
  pins = import ../pins.nix {
    inherit fetchFromGitHub;
  };
in
  (callPackage ../base.nix {
    name = "llvm";

    cmakeFlags = [
      "-DCMAKE_BUILD_TYPE=Release"
      "-DLLVM_ENABLE_ASSERTIONS=OFF"
      "-DLLVM_TARGETS_TO_BUILD=X86"
      "-DLLVM_EXTERNAL_PROJECTS=sycl;sycl-fusion;llvm-spirv;opencl;xpti;xptifw"
      "-DLLVM_EXTERNAL_SYCL_SOURCE_DIR=/build/source/sycl"
      "-DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR=/build/source/llvm-spirv"
      "-DLLVM_EXTERNAL_XPTI_SOURCE_DIR=/build/source/xpti"
      "-DXPTI_SOURCE_DIR=/build/source/xpti"
      "-DLLVM_EXTERNAL_XPTIFW_SOURCE_DIR=/build/source/xptifw"
      # "-DLLVM_EXTERNAL_LIBDEVICE_SOURCE_DIR=/build/source/libdevice"
      "-DLLVM_EXTERNAL_SYCL_FUSION_SOURCE_DIR=/build/source/sycl-fusion"
      # "-DLLVM_ENABLE_PROJECTS=clang;lld;sycl;sycl-fusion;llvm-spirv;opencl;xpti;xptifw"
      "-DLLVM_ENABLE_PROJECTS=sycl;sycl-fusion;llvm-spirv;opencl;xpti;xptifw"
      "-DLIBCLC_TARGETS_TO_BUILD=''"
      "-DLIBCLC_GENERATE_REMANGLED_VARIANTS=ON"
      "-DSYCL_BUILD_PI_HIP_PLATFORM=''"
      "-DLLVM_BUILD_TOOLS=ON"
      "-DSYCL_ENABLE_WERROR=OFF"
      "-DSYCL_INCLUDE_TESTS=ON"
      "-DLLVM_ENABLE_DOXYGEN=OFF"
      "-DLLVM_ENABLE_SPHINX=OFF"
      "-DBUILD_SHARED_LIBS=ON"
      "-DSYCL_ENABLE_XPTI_TRACING=ON"
      # "-DLLVM_ENABLE_LLD=ON"
      "-DLLVM_ENABLE_LLD=OFF"
      "-DXPTI_ENABLE_WERROR=OFF"
      # "-DSYCL_USE_LIBCXX=ON"
      # "-DSYCL_LIBCXX_INCLUDE_PATH=${libcxx.dev}/include/c++/v1"
      # "-DSYCL_LIBCXX_LIBRARY_PATH=${lib.makeLibraryPath [libcxx]}"
      "-DSYCL_BUILD_PI_ESIMD_CPU=OFF"
      # "-DSYCL_CLANG_EXTRA_FLAGS=''"
      "-DSYCL_ENABLE_PLUGINS=opencl;level_zero;"
      "-DSYCL_ENABLE_KERNEL_FUSION=ON"
      "-DSYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB=ON"
      "-DLEVEL_ZERO_INCLUDE_DIR=${level-zero}/include/level_zero"
      "-DLEVEL_ZERO_LIBRARY=${level-zero}/lib/libze_loader.so"
      "-DSYCL_PI_TESTS=OFF"
      "-DSYCL_PI_UR_USE_FETCH_CONTENT=OFF"
      "-DSYCL_PI_UR_SOURCE_DIR=${pins.unified-runtime}"
      "-DLLVMGenXIntrinsics_SOURCE_DIR=${pins.vc-intrinsics}"
      "-DOpenCL_HEADERS=${pins.ocl-headers}"
      "-DOpenCL_LIBRARY_SRC=${pins.ocl-loader}"
      "-DBOOST_MP11_SOURCE_DIR=${pins.mp11}"
      "-DBOOST_MODULE_SRC_DIR=${boost.dev}"
      "-DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=${pins.spirv-headers}"
      "-DUR_OPENCL_INCLUDE_DIR=${opencl-headers}/include/CL"
      "-DOpenCL-ICD=${ocl-icd}/lib/libOpenCL.so"
    ];
  })
  .overrideAttrs (_: {
    # https://github.com/intel/llvm/issues/6937
    buildPhase = ''
      cmake --build /build/source/llvm/build --parallel $NIX_BUILD_CORES --target=deploy-sycl-toolchain
    '';
  })

But I am now trying to modularize it more.

@MordragT MordragT added the bug Something isn't working label Apr 14, 2024
@steffenlarsen
Copy link
Contributor

Hi @MordragT! Do you know if it is using an upstream version of clang-tblgen (CLANG_TABLEGEN in CMakeCache.txt may tell us)? The DeviceConfigFile.inc configuration uses a special option (-gen-dynamic-tables) that is not in upstream, but we usually rely on building and using our own clang-tblgen executable as part of the build.

@KornevNikita
Copy link
Contributor

@MordragT hi! Any updates here?

@MordragT
Copy link
Author

MordragT commented Jul 4, 2024

Hey I just tried it again. I haven't updated the repo because I then have to manually update also all the fetch-contents occurences to point to the correct source dirs (nix cannot use fetch-content), but I have taken a look at the CMakeCache.txt:

CLANG_TABLEGEN:STRING=clang-tblgen
LLVM_PARALLEL_TABLEGEN_JOBS:STRING=
LLVM_TABLEGEN_EXE:FILEPATH=/nix/store/rzib4gkiyp8gkhs46fddw6003qvnx6rn-intel-llvm-19.0.0-unstable-2024-04-15/bin/llvm-tblgen
CLANG_TABLEGEN_EXE:INTERNAL=clang-tblgen

This is everything I could find about table-gen.
just for context this is the version I am currently trying to build:

      pname = "intel-${name}";
      version = "19.0.0-unstable-2024-04-15";

      src = fetchFromGitHub {
        rev = "06bd6bca82e1ba93e2e233cac9b86631e6c2d958";
        owner = "intel";
        repo = "llvm";
        hash = "sha256-o3QERO8DRnHyQ84WBuDvj46qJT4ZVB3A94QHVIrriIU=";
      };

When I find the time I will try it against the current master.

@dm-vodopyanov dm-vodopyanov added the Need info Some clarifications are needed from the reporter label Jul 10, 2024
@AlexeySachkov
Copy link
Contributor

I don't think that this has anything to do with tablegen, but most likely it was an issue with our cmake files, i.e. actual missed dependency.

If my assumption is correct, then #13328 likely fixed that. @MordragT, could you please check if that change helps you? That's a one-liner, so full update shouldn't be required, you can just apply it locally or do a cherry-pick

@ContradNamiseb
Copy link

ContradNamiseb commented Sep 23, 2024

@AlexeySachkov pr #13328 does solve that error thanks.

@bader bader closed this as completed Sep 23, 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 Need info Some clarifications are needed from the reporter
Projects
None yet
Development

No branches or pull requests

7 participants