[lldb-dev] Cross-building lldb

Martin Storsjö via lldb-dev lldb-dev at lists.llvm.org
Tue Sep 17 05:12:44 PDT 2019


On Mon, 16 Sep 2019, Vadim Chugunov via lldb-dev wrote:

> Hi,
> I'm trying (and failing) to cross-build lldb according to these instructions
> <https://lldb.llvm.org/resources/build.html#example-1-cross-compiling-for-linux-arm64-on-ubuntu-host>.
>
>
> My cmake command line:
>
> cd /workspace/build/lldb && /usr/bin/cmake -DLLVM_VERSION_SUFFIX=-custom
> -DLLVM_PARALLEL_LINK_JOBS=1 "-DLLVM_ENABLE_PROJECTS=clang;libcxx;lldb"
> "-DLLVM_TARGETS_TO_BUILD=X86;AArch64;ARM" -DLLVM_ENABLE_TERMINFO=FALSE
> -DLLVM_ENABLE_LIBXML2=FORCE_ON  -DLLDB_RELOCATABLE_PYTHON=TRUE
> -DLLDB_DISABLE_CURSES=TRUE -DLLDB_DISABLE_LIBEDIT=TRUE
> -DCMAKE_CXX_FLAGS="-static-libstdc++ -static-libgcc"
> -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=aarch64
> -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc
> -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_CROSSCOMPILING=TRUE
> -DLLVM_TARGET_ARCH=aarch64
> -DLLVM_TABLEGEN=/workspace/build/llvm-host/bin/llvm-tblgen
> -DCLANG_TABLEGEN=/workspace/build/llvm-host/bin/clang-tblgen
> -DPYTHON_EXECUTABLE=/usr/bin/python3 -GNinja /workspace/source/llvm
>
> When I kick off a build, a few files get compiled, but then a nested build
> configuration is invoked:
>
> cd /workspace/build/lldb/NATIVE && /usr/bin/cmake -G Ninja
> -DCMAKE_MAKE_PROGRAM="/usr/bin/ninja"
> -DCMAKE_C_COMPILER=/usr/bin/aarch64-linux-gnu-gcc
> -DCMAKE_CXX_COMPILER=/usr/bin/aarch64-linux-gnu-g++ /workspace/source/llvm
> -DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE
> -DLLVM_TARGETS_TO_BUILD="X86;AArch64;ARM"
> -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=""
> -DLLVM_DEFAULT_TARGET_TRIPLE="x86_64-unknown-linux-gnu"
> -DLLVM_TARGET_ARCH="aarch64" -DLLVM_ENABLE_PROJECTS="clang;libcxx;lldb"
> -DLLVM_EXTERNAL_PROJECTS="" -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN="OFF"
> -DCMAKE_BUILD_TYPE=Release
> -DLLVM_EXTERNAL_CLANG_SOURCE_DIR=/workspace/source/llvm/../clang
>
> ... which fails with this error:
>
> CMake Error at
> /usr/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137
> (message):
>  Could NOT find LibEdit (missing: libedit_LIBRARIES) (found version ".")
> Call Stack (most recent call first):
>  /usr/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378
> (_FPHSA_FAILURE_MESSAGE)
>  /workspace/source/lldb/cmake/modules/FindLibEdit.cmake:54
> (find_package_handle_standard_args)
>  /workspace/source/lldb/cmake/modules/LLDBConfig.cmake:104 (find_package)
>  /workspace/source/lldb/CMakeLists.txt:21 (include)
>
> As far as I can tell, this happens because LLDB_DISABLE_LIBEDIT is not
> propagated to this nested build...  but maybe I am missing some cmake flag?

You can add 
-DCROSS_TOOLCHAIN_FLAGS_NATIVE="-DLLDB_DISABLE_LIBEDIT=ON;-DOTHER_FLAGS..." 
to your outer cmake invocation, to pass extra flags to the nested one.

This does override a few implicitly passed variables to the nested native 
cmake invocation though: 
https://github.com/llvm/llvm-project/blob/master/llvm/cmake/modules/CrossCompile.cmake#L14-L21

If you need those passed on, you need to manually specify them in addition 
to LLDB_DISABLE_LIBEDIT in CROSS_TOOLCHAIN_FLAGS_NATIVE.

// Martin



More information about the lldb-dev mailing list