google / bloaty

Bloaty: a size profiler for binaries
Apache License 2.0
4.76k stars 345 forks source link

Build fails on Devuan Ascii #113

Closed MageSlayer closed 5 years ago

MageSlayer commented 6 years ago

Hi

I am getting following errors when built on Devuan Ascii. Any help?

Scanning dependencies of target bloaty
Scanning dependencies of target bloaty_test
Scanning dependencies of target bloaty_misc_test
Scanning dependencies of target fuzz_test
Scanning dependencies of target range_map_test
[ 98%] Building CXX object CMakeFiles/bloaty.dir/src/main.cc.o
[ 98%] Building CXX object CMakeFiles/bloaty_misc_test.dir/tests/bloaty_misc_test.cc.o
[ 98%] Building CXX object CMakeFiles/bloaty_test.dir/tests/bloaty_test.cc.o
[ 98%] Building CXX object CMakeFiles/fuzz_test.dir/tests/fuzz_target.cc.o
[ 99%] Building CXX object CMakeFiles/fuzz_test.dir/tests/fuzz_driver.cc.o
[ 99%] Building CXX object CMakeFiles/range_map_test.dir/tests/range_map_test.cc.o
[ 99%] Linking CXX executable bloaty
[ 99%] Linking CXX executable fuzz_test
/usr/bin/ld: third_party/capstone/libcapstone.a(cs.c.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: third_party/capstone/libcapstone.a(SStream.c.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: third_party/capstone/libcapstone.a(ARMModule.c.o): relocation R_X86_64_32 against symbol `Thumb_getInstruction' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: third_party/capstone/libcapstone.a(AArch64Module.c.o): relocation R_X86_64_32S against symbol `AArch64_printInst' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: third_party/capstone/libcapstone.a(MipsModule.c.o): relocation R_X86_64_32S against symbol `Mips_printInst' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: third_party/capstone/libcapstone.a(PPCModule.c.o): relocation R_X86_64_32S against symbol `PPC_printInst' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: third_party/capstone/libcapstone.a(X86Module.c.o): relocation R_X86_64_32 against symbol `regsize_map_64' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: third_party/capstone/libcapstone.a(X86ATTInstPrinter.c.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: third_party/capstone/libcapstone.a(SparcModule.c.o): relocation R_X86_64_32S against symbol `Sparc_printInst' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: third_party/capstone/libcapstone.a(SystemZModule.c.o): relocation R_X86_64_32S against symbol `SystemZ_printInst' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: third_party/capstone/libcapstone.a(XCoreModule.c.o): relocation R_X86_64_32S against symbol `XCore_printInst' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: third_party/capstone/libcapstone.a(ARMDisassembler.c.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIC

Adding following to third_party/capstone/CMakeLists.txt seems to fix the issue.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 66127c4e..18de9166 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,6 +5,8 @@ set(VERSION_MAJOR 3)
 set(VERSION_MINOR 0)
 set(VERSION_PATCH 5)

+set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+
 # to configure the options specify them in in the command line or change them in the cmake UI.
 # Don't edit the makefile!
 option(CAPSTONE_BUILD_STATIC_RUNTIME "Embed static runtime" OFF)
haberman commented 6 years ago

Hmm, I wonder why it is trying to build a position-independent executable. And I wonder why this only happens on Devuan.

Capstone is in a separate repo so it wouldn't be possible to make that fix in Bloaty's repo.

haberman commented 5 years ago

Without more reports of this I think I'm going to close this for now.