tensorflow/mlir-hlo

build error /usr/bin/ld.lld: error: unknown argument: --push-state

victorygogogo opened this issue · 4 comments

-- Performing Test HAVE_STEADY_CLOCK
-- Performing Test HAVE_STEADY_CLOCK
-- Performing Test HAVE_STEADY_CLOCK -- success
-- Configuring done
-- Generating done
-- Build files have been written to: /home/e0004850/project_code/llvm_for_hlo/llvm-build

  • cmake --build /home/e0004850/project_code/mlir-hlo/../llvm_for_hlo/llvm-build --target all --target mlir-cpu-runner
    [383/2912] Linking C executable bin/count
    FAILED: bin/count
    : && /usr/bin/cc -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-comment -fdiagnostics-color -O2 -g -DNDEBUG -fuse-ld=lld -W
    l,--color-diagnostics -Wl,-O3 -Wl,--gc-sections utils/count/CMakeFiles/count.dir/count.c.o -o bin/count -Wl,-rpath,"$ORIGIN/../lib" -lpthread && :
    /usr/bin/ld.lld: error: unknown argument: --push-state
    /usr/bin/ld.lld: error: unknown argument: --pop-state
    /usr/bin/ld.lld: error: unknown argument: --push-state
    /usr/bin/ld.lld: error: unknown argument: --pop-state

    collect2: error: ld returned 1 exit status
    [416/2912] Building CXX object lib/DebugInfo/CodeView/CMakeFiles/LLVMDebugInfoCodeView.dir/EnumTables.cpp.o
    ninja: build stopped: subcommand failed.

how to solve this problem

if use "DLLVM_INSTALL_UTILS=ON" will cause this problem.

The issue seems like mixing gcc with the lld linker. Which version of gcc are you using? (/usr/bin/cc --version)
Disabling -DLLVM_ENABLE_LLD=ON or building with clang (or a more recent gcc) should work I think?

gcc version (Ubuntu 8.4.0-1ubuntu1~18.04) 8.4.0 ,
Disabling -DLLVM_ENABLE_LLD=ON build is ok when use "build_tools/build_mlir.sh ${PWD}/llvm-project/ ${PWD}/llvm-build" this command
$ mkdir build && cd build
$ cmake .. -GNinja
-DLLVM_ENABLE_LLD=ON
-DCMAKE_BUILD_TYPE=Release
-DLLVM_ENABLE_ASSERTIONS=On
-DMLIR_DIR=${PWD}/../llvm-build/lib/cmake/mlir
$ ninja check-mlir-hlo
use the above command, set -DLLVM_ENABLE_LLD=OFF \ cause a link problem , so set -DLLVM_ENABLE_LLD=ON build is ok, is there any problem build like this?

and how to build wth clang ,can you tell me ?

-DCMAKE_C_COMPILER=<path_to_clang> -DCMAKE_CXX_COMPILER=<path_to_clang++>