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

    <tr>
        <th>Summary</th>
        <td>
            Failed to cross-compiling llvm from x86 to RISC-V
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            build-problem
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          fourdim
      </td>
    </tr>
</table>

<pre>
    After merging https://github.com/llvm/llvm-project/commit/b1aed14bfea07508e4b9d864168c1ae6b5b5c665, we will generate following error when cross-compiling llvm from x86 to RISC-V.
```
[37/2083] Building CXX object lib/LineEditor/CMakeFiles/LLVMLineEditor.dir/LineEditor.cpp.o
FAILED: lib/LineEditor/CMakeFiles/LLVMLineEditor.dir/LineEditor.cpp.o 
/usr/bin/clang++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/username/llvm-project/build_riscv/lib/LineEditor -I/home/username/llvm-project/llvm/lib/LineEditor -I/home/username/llvm-project/build_riscv/include -I/home/username/llvm-project/llvm/include --target=riscv64-unknown-linux-gnu --gcc-toolchain=/home/username/riscv --sysroot=/home/username/riscv/sysroot -march=rv64ifd -latomic -fvisibility-inlines-hidden -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -fdiagnostics-color -g  -fno-exceptions -fno-rtti -std=c++14 -MD -MT lib/LineEditor/CMakeFiles/LLVMLineEditor.dir/LineEditor.cpp.o -MF lib/LineEditor/CMakeFiles/LLVMLineEditor.dir/LineEditor.cpp.o.d -o lib/LineEditor/CMakeFiles/LLVMLineEditor.dir/LineEditor.cpp.o -c /home/username/llvm-project/llvm/lib/LineEditor/LineEditor.cpp
clang-13: warning: -latomic: 'linker' input unused [-Wunused-command-line-argument]
/home/username/llvm-project/llvm/lib/LineEditor/LineEditor.cpp:18:10: fatal error: 'histedit.h' file not found
#include <histedit.h>
         ^~~~~~~~~~~~
1 error generated.
```
It implies that we need libedit-dev(riscv-64) for cross-compiling, which is not expected. Any ideas?

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVktz4jgQ_jXmohLlBzZw4EB4ZKkKSVUgk7lRstW2tZElrySHZH_9tgxMdjKp3ZndUMJWq1vdn1r9cK7562xeOjCkAVMJVZHaudYGyTyI1zgq4eouHxa6QULK58uLtkb_DoVDEnmN8JM8YsCjUV4CC8dpOIFRPuWTbBRlkwJZWZ7maZFlaRAvyBHIUUhJKlBgmANSain10QMAY7QhxxoUKYy2lqKBVkjP8pZJaXRDXiYZcZrcb3YL-mUYhMsgnAdZeB4nMr1KxggrDidJkC7JVSck91oWX78SnXv0RIocJW6EghUXThskFlv2BGshwXrOzZftG3fIhflOfFi07VCfzK3nm5vVEh33OUrJ-RDxurOenwvlfS2ZqoL4Cgehy-v9arc__DbfHe73-02QLENcPCxXVw_XfnJ9-3DY3T3cL1aeOuz2y8VhcXe7289v94ftfHF_t3tjrO_ut_Mfl282283b6gYh1LqBHhUYxfrpu3jIvZ8PRtji2TPfOeMnlVxC7b_t_h6CUIXsOPya5W-bqGOmAofe7fVlI9qpJ6WPimJIdi-0Uh0KVUVBndayqBleVLL80FKvAIXtqzVau38Uw_dZjNCGmaL2ANC6KDmhkjndiILQ8llYkWNyuFcqFAICS2vBOeYOfWSYX_QRXpxh-FYagaMVTltm0JDPefp4NMIBtc5gYlikC2Yd_aNjfmcjrMVlWgqQHNULJ5gUf4JBwRY4U85D8IqlRjH_OJFKw0sBraPutYV-SdFnYRyqpby_xUcOEhHQDzi2qypAEPoZC4Hgp_2-BjSg0BclF6xS2qJtXxmk31MRXEehk1WhlT3RxjlB8HAcfVecsiYaE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