lifting-bits / remill

Library for lifting machine code to LLVM bitcode
Apache License 2.0
1.27k stars 143 forks source link

Compile error when running ./build.sh #494

Closed Muqi-Zou closed 3 years ago

Muqi-Zou commented 3 years ago

Environment info: Ubuntu 18.04, clang-10, llvm-10.

I have following errors, when running "./remill/scripts/build.sh --llvm-version 10"

/home/muqi/anvill_only.0224/lifting-bits-downloads/vcpkg_ubuntu-18.04_llvm-10_amd64/installed/x64-linux-rel/lib/libglog.a(signalhandler.cc.o): In function `google::InstallFailureSignalHandler()':
signalhandler.cc:(.text+0x149a): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
signalhandler.cc:(.text+0x1504): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
signalhandler.cc:(.text+0x156e): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
signalhandler.cc:(.text+0x15d8): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
signalhandler.cc:(.text+0x1642): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
/home/muqi/anvill_only.0224/lifting-bits-downloads/vcpkg_ubuntu-18.04_llvm-10_amd64/installed/x64-linux-rel/lib/libglog.a(signalhandler.cc.o):signalhandler.cc:(.text+0x16ac): more undefined references to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)' follow
clang: error: linker command failed with exit code 1 (use -v to see invocation)
bin/lift/CMakeFiles/remill-lift-10.dir/build.make:206: recipe for target 'bin/lift/remill-lift-10' failed
make[2]: *** [bin/lift/remill-lift-10] Error 1
make[2]: Leaving directory '/home/muqi/anvill_only.0224/remill-build'
CMakeFiles/Makefile2:1970: recipe for target 'bin/lift/CMakeFiles/remill-lift-10.dir/all' failed
make[1]: *** [bin/lift/CMakeFiles/remill-lift-10.dir/all] Error 2
make[1]: Leaving directory '/home/muqi/anvill_only.0224/remill-build'
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
[x] Build aborted.

I do not think this error is related with my environment, since I also have the old repo with following version:

muqi@muqi-desktop:~/decompile_tool/remill$ git log -1
commit c30cb5f4b57878a6a5794aa3289fa74cf3b053ea (HEAD -> master, tag: v4.0.18, origin/master, origin/HEAD)
Author: Eric Kilmer <eric.d.kilmer@gmail.com>
Date:   Fri Feb 12 15:34:24 2021 -0500

    Add more CallSite.h Cloning.h compatibility for LLVM 11 used in McSema (#482)

And it compiles... current version is:

commit 6fc78e6db23e7699b5e6eec9921db3c4d616a264 (HEAD -> master, origin/master, origin/HEAD)
Author: Peter Goodman <peter@trailofbits.com>
Date:   Wed Feb 24 18:36:02 2021 -0500

    Adds GlobalAlias awareness to the StripAndAccumulateConstantOffsets function (#493)
losfree commented 3 years ago

same question in ubuntu20.04... not sure what's going on

ekilmer commented 3 years ago

Apologies for not answering this sooner. Have you run this on the latest master branch commit by any chance? Please git pull.

I am able to run it successfully (from the minimal ubuntu:20.04 Docker image) with the following steps

# These probably aren't all _essential_ but this is what we use in CI
$ sudo apt-get install g++-multilib libzstd-dev python3.8 python3-pip \
      python3-setuptools python-setuptools \
      build-essential g++ gcc clang-10 lld-10 ninja-build \
      curl unzip tar git zip python python3 pkg-config \
      rpm cmake

$ git clone https://github.com/lifting-bits/remill

# This shouldn't be _required_ but might help reduce variables to figure out what's wrong
$ export CC=$(which clang-10) && export CXX=$(which clang++-10)

$ ./remill/scripts/build.sh --llvm-version 10

You can test your installation with the following:

$ cd remill-build
$ cmake --build . --target test_dependencies
$ env CTEST_OUTPUT_ON_FAILURE=1 cmake --build . --target test

If the above doesn't work for you, then I'm afraid there's something else in your environment that is causing issues.

That being said, if you're willing to compile LLVM (and all other dependencies) from source, try following the directions here (https://github.com/trailofbits/cxx-common#just-release-builds) to build the dependencies. After that script is done running, it should tell you how to use it with CMake by adding -DVCPKG_ROOT=/path/to/vcpkg when configuring via CMake:

Example:

$ git clone https://github.com/trailofbits/cxx-common
$ cd cxx-common
$ ./build_dependencies.sh --release llvm-10
# A long while later....
# It will print a message about how to use what you just built with
# -DVCPKG_ROOT=/path/to/vcpkg

# Now, either in the same directory or wherever...
$ git clone https://github.com/lifting-bits/remill
$ mkdir remill-build && cd remill-build
$ cmake -DVCPKG_ROOT=/path/to/vcpkg -DCMAKE_INSTALL_PREFIX=$(pwd)/install ../remill

$ cmake --build . --target test_dependencies
$ env CTEST_OUTPUT_ON_FAILURE=1 cmake --build . --target test

Let me know if you get any errors!

Muqi-Zou commented 3 years ago

I retried the remill master, it works now! Thanks!