<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/57185>57185</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            installing LLVM for RISCV on Ubuntu
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          mahnaz-namazi
      </td>
    </tr>
</table>

<pre>
    Hi,
I wanna install llvm/clang to compile riscv codes. before installing riscv-gnu-toolchain I can install llvm without any problem, but as far as I install riscv-gnu-toolchain and then try to install llvm/clang based on commands in sifive/risc-llvm (https://github.com/sifive/riscv-llvm) I got the following errors:

```
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- The ASM compiler identification is GNU
CMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:69 (message):
  The C compiler
    /usr/bin/cc
  is not able to compile a simple test program.
```

and these are the configs I use with cmake : 

```
$cmake ../llvm -G Ninja -DCMAKE_BUILD_TYPE="Release" \
  -DBUILD_SHARED_LIBS=True -DLLVM_USE_SPLIT_DWARF=True \
  -DCMAKE_INSTALL_PREFIX="/home/maze/riscv-tools" \
  -DLLVM_OPTIMIZED_TABLEGEN=True -DLLVM_BUILD_TESTS=False \
  -DDEFAULT_SYSROOT="/home/maze/riscv-tools/riscv64-unknown-elf" \
  -DLLVM_DEFAULT_TARGET_TRIPLE="riscv64-unknown-elf" \
  -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="RISCV" 
```

my riscv-gnu-toolchain is being installed in `/home/maze/riscv-tools/ ` and `/home/maze/risv-tools/bin/` has been added to PATH and I am able to compile riscv codes using `riscv64-unknown-elf-gcc`

I have tried this on two different machine with different cpu archs( one is aarch64 and the other x86-64) and different ubuntu versions (21.10 on the first machine and 22.04 on the second one)and the same errors on both.
here is the versions of some tools which are required to build llvm:

```
$gcc --version
gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0

$g++ --version
g++ (Ubuntu 11.2.0-19ubuntu1) 11.2.0

$cmake --version
cmake version 3.22.1

$python --version
Python 3.10.4
```

I have also tried most of the solutions mentioned on the web such as set compiler for CMake but no difference.
any help would be appreciated.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJydVttyozgQ_Rr8ooICfH_wg2PjDLV24rLJbGZfXAJkoxmQvBLE6_n67RYQx0nGNbtVFJdWX05fdEQs0_PkC7f8meXOLXcakhMVghIudEnznOT5S2H5iySn4kBKSRJZHHnOiOI6eYGvlGmHxGwvFWttOGiaZfsgKruUMk8yygUJSULFlWNy4mUmq5JQcSZHJeOcQbAZiVGkyZ4qfISvNp95pSIlZcYEKdUZAX4KPKaapUQKhF-AhQY1ovmevzDQQbe2wWP5o6wsj9rqTkEO1wEAVrEDZvBxZfBi1xHGgO8gS8RA9jLP5QnzZ0pJZdyYqjb3gdtc5tO2SQRGs7amivCUiRKCJLTkAJZrUokfQp7EtcHz8381mW5Xt0zuH55q9dmK_mAkQPCEllCORaUVZp5RhYknBazbXcf34WMl0ypnGt6MWcR0OZs1QRyjCfkPxljUgmlND-Bh_FoS8i75VkouUWMuMGbSLgFSAZWmMCZvR5FCJ4sjygABjtFB0cL5tOT1vRkZDaYwtdi4RIo9P-CoVSDFqSQmAQJwyY0WWn6v1nMcQGpGyL4nD1x8p8Sez1bTP4Ld3VO4nO-ib-vA6s4t39-wnME4whux-rM2N3te622_TDfBfLcM77agHqmKwdJy-XW1e9oGu-16GUa7-Z_TzaJdvfJRRwwfttF0udytN8EifK6jArxMFtjDgv68zDDuI_0Bion3uI7CVfgXgImmd8vgPnh4B6hJLNhGCHVBc_0OzTxYTJ-W0W77bbt5fIx-B0j9NejZzRTbLN9_Dq91Hk039wE8NuF62VT4t30Ez-tgE66CByhX42i7ix7rzJpuhdvZV2P963kqzp8yE4xrzJAMGkoCBgIp2t4uAaoYWvuF6kWz3iConlEMBixI0xTiwO5YT6Mv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