Skip to content

Compilation Error with CMake & LLVM #6618

@Scot-Survivor

Description

@Scot-Survivor

Describe the bug
The bug is that when you try to use CMake with Intel Clang or Clang++ it fails due to not being able to build the simple test program.

To Reproduce
Attempt to use CMake as your building script.
Set it to use a LLVM as the tool chain.

cmake_minimum_required(VERSION 3.23)
project(MachineLearning)

set(CMAKE_CXX_STANDARD 17)
include_directories($ENV{DPCPP_HOME}/llvm/build/include)
include_directories($ENV{DPCPP_HOME}/llvm/build/include/sycl/)
include_directories($ENV{DPCPP_HOME}/llvm/build/lib)

add_compile_options(-fsycl -fsycl-targets=nvptx64-nvidia-cuda -fsycl-unnamed-lambda)

add_executable(MachineLearning library.cpp)
target_link_directories(MachineLearning PUBLIC $ENV{DPCPP_HOME}/llvm/build/lib)

This is my CMakeLists.txt file.

Environment (please complete the following information):

  • OS: Linux Ubuntu 20.04.4 LTS
  • Target device and vendor: Nvidia RTX 2060
  • DPC++ version: 770f540
  • Dependencies version: N/A

Additional context
I am using CLion for my IDE in this case.

Exact error from CMake is:

-- The C compiler identification is Clang 16.0.0
-- The CXX compiler identification is Clang 16.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /home/scot/sycl_workspace/llvm/build/bin/clang
-- Check for working C compiler: /home/scot/sycl_workspace/llvm/build/bin/clang - broken
CMake Error at /opt/cmake-3.24.1-linux-x86_64/share/cmake-3.24/Modules/CMakeTestCCompiler.cmake:69 (message):
  The C compiler

    "/home/scot/sycl_workspace/llvm/build/bin/clang"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/scot/CLionProjects/MachineLearning/cmake-build-debug-dpc-cuda/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/home/scot/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/222.3345.126/bin/ninja/linux/ninja cmTC_27ff8 && [1/2] Building C object CMakeFiles/cmTC_27ff8.dir/testCCompiler.c.o
    [2/2] Linking C executable cmTC_27ff8
    FAILED: cmTC_27ff8 
    : && /home/scot/sycl_workspace/llvm/build/bin/clang   CMakeFiles/cmTC_27ff8.dir/testCCompiler.c.o -o cmTC_27ff8   && :
    clang-16: error: unable to execute command: Executable "ld" doesn't exist!
    clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
    ninja: build stopped: subcommand failed.
    
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)


-- Configuring incomplete, errors occurred!
See also "/home/scot/CLionProjects/MachineLearning/cmake-build-debug-dpc-cuda/CMakeFiles/CMakeOutput.log".
See also "/home/scot/CLionProjects/MachineLearning/cmake-build-debug-dpc-cuda/CMakeFiles/CMakeError.log".

Error and Output logs are both attached to this issue
[CMakeOutput.log](https://github.com/intel/llvm/files/9389476/CMakeOutput.log)
[CMakeError.log](https://github.com/intel/llvm/files/9389479/CMakeError.log)
.

Metadata

Metadata

Assignees

No one assigned

    Labels

    StalebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions