radareorg / radare2

UNIX-like reverse engineering framework and command-line toolset
https://www.radare.org/
GNU Lesser General Public License v3.0
20.71k stars 3.01k forks source link

Failed to compile on Fedora #19921

Closed junchao98 closed 2 years ago

junchao98 commented 2 years ago

Environment

uname -a

Linux fedora 5.11.12-300.fc34.x86_64 #1 SMP Wed Apr 7 16:31:13 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

root@fedora ~/softwares [15:13:56]

cat /etc/os-release

NAME=Fedora VERSION="34 (Workstation Edition)"

The latest code from git clone

Description

make[2]: 'run.o' is up to date.
make[2]: 'r2pipe.o' is up to date.
make[2]: 'socket_serial.o' is up to date.
make[2]: Leaving directory '/root/softwares/radare2/libr/socket'
make[1]: Leaving directory '/root/softwares/radare2/libr/socket'
make -C shlr
make[1]: Entering directory '/root/softwares/radare2/shlr'
make -C winkd all
make[2]: Entering directory '/root/softwares/radare2/shlr/winkd'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/root/softwares/radare2/shlr/winkd'
if [ ! -d capstone ]; then \
    "/bin/sh" capstone.sh "https://github.com/capstone-engine/capstone.git" "next" "31af3c3e3bf75ca5074715fe966094606c816ba6" "" "" ; \
fi
cd capstone && CFLAGS=" -MD   -fPIC -g -Wall -D__UNIX__=1 -MD" LDFLAGS="" \
    make  CC="gcc" AR_EXT=a IS_CYGWIN=0 CAPSTONE_STATIC=yes CAPSTONE_SHARED=no \
    RANLIB="ranlib" LIBARCHS="" AR="ar" IS_MINGW=0 libcapstone.a
make[2]: Entering directory '/root/softwares/radare2/shlr/capstone'
make[2]: *** No rule to make target 'libcapstone.a'.  Stop.
make[2]: Leaving directory '/root/softwares/radare2/shlr/capstone'
make[1]: *** [Makefile:271: capstone-build] Error 2
make[1]: Leaving directory '/root/softwares/radare2/shlr'
make: *** [Makefile:55: all] Error 2

Test

git clone https://github.com/radareorg/radare2.git ./sys/install.sh or ./configure && make

radare commented 2 years ago

Looks like capstone wasnt cloned properly

On 6 Apr 2022, at 09:17, junchao98 @.***> wrote:

 Environment

uname -a

Linux fedora 5.11.12-300.fc34.x86_64 #1 SMP Wed Apr 7 16:31:13 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

@.*** ~/softwares [15:13:56]

cat /etc/os-release

NAME=Fedora VERSION="34 (Workstation Edition)"

The latest code from git clone

Description

make[2]: 'run.o' is up to date. make[2]: 'r2pipe.o' is up to date. make[2]: 'socket_serial.o' is up to date. make[2]: Leaving directory '/root/softwares/radare2/libr/socket' make[1]: Leaving directory '/root/softwares/radare2/libr/socket' make -C shlr make[1]: Entering directory '/root/softwares/radare2/shlr' make -C winkd all make[2]: Entering directory '/root/softwares/radare2/shlr/winkd' make[2]: Nothing to be done for 'all'. make[2]: Leaving directory '/root/softwares/radare2/shlr/winkd' if [ ! -d capstone ]; then \ "/bin/sh" capstone.sh "https://github.com/capstone-engine/capstone.git" "next" "31af3c3e3bf75ca5074715fe966094606c816ba6" "" "" ; \ fi cd capstone && CFLAGS=" -MD -fPIC -g -Wall -DUNIX=1 -MD" LDFLAGS="" \ make CC="gcc" AR_EXT=a IS_CYGWIN=0 CAPSTONE_STATIC=yes CAPSTONE_SHARED=no \ RANLIB="ranlib" LIBARCHS="" AR="ar" IS_MINGW=0 libcapstone.a make[2]: Entering directory '/root/softwares/radare2/shlr/capstone' make[2]: No rule to make target 'libcapstone.a'. Stop. make[2]: Leaving directory '/root/softwares/radare2/shlr/capstone' make[1]: [Makefile:271: capstone-build] Error 2 make[1]: Leaving directory '/root/softwares/radare2/shlr' make: *** [Makefile:55: all] Error 2

Test

git clone https://github.com/radareorg/radare2.git ./sys/install.sh or ./configure && make

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.

junchao98 commented 2 years ago

root@fedora ~/softwares/radare2/shlr/capstone                                                 [15:26:19] 
#git pull                                                                                     [±next]
Already up to date.

root@fedora ~/softwares/radare2/shlr/capstone [15:26:22]

[±next]

root@fedora ~/softwares/radare2/shlr/capstone [15:26:25]

ls [±next]

CMakeLists.txt MCFixedLenDisassembler.h SPONSORS.TXT contrib pkgconfig.mk COMPILE.TXT MCInst.c SStream.c cs.c suite COMPILE_CMAKE.TXT MCInst.h SStream.h cs_priv.h tests COMPILE_MSVC.TXT MCInstrDesc.c TODO cstool utils.c CREDITS.TXT MCInstrDesc.h arch docs utils.h ChangeLog MCRegisterInfo.c bindings functions.mk windows HACK.TXT MCRegisterInfo.h capstone-config.cmake.in include windowsce LEB128.h Makefile capstone.pc.in make.sh xcode LICENSE.TXT MathExtras.h cmake.sh msvc LICENSE_LLVM.TXT README.md cmake_uninstall.cmake.in nmake.bat MCDisassembler.h RELEASE_NOTES config.mk packages
root@fedora ~/softwares/radare2/shlr/capstone [15:44:14]

git status [±next]

On branch next Your branch is up to date with 'origin/next'.

Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git restore ..." to discard changes in working directory) modified: arch/X86/X86ATTInstPrinter.c modified: arch/X86/X86IntelInstPrinter.c modified: functions.mk

no changes added to commit (use "git add" and/or "git commit -a")



capstone seems to be complete
trufae commented 2 years ago

Can you provide the full build log? is this happening on a clean checkout? i can't reproduce :?

in case of a hurry you can also build it with meson (meson b;ninja -C b)

junchao98 commented 2 years ago

Can you provide the full build log? is this happening on a clean checkout? i can't reproduce :?

in case of a hurry you can also build it with meson (meson b;ninja -C b)

root@fedora ~/softwares/radare2                                                                                                                                                                         [20:44:03] 
> #meson build                                                                                                                                                                                          [±master]
The Meson build system
Version: 0.59.4
Source dir: /root/softwares/radare2
Build dir: /root/softwares/radare2/build
Build type: native build
Project name: radare2
Project version: 5.6.7
C compiler for the host machine: cc (gcc 11.2.1 "cc (GCC) 11.2.1 20220127 (Red Hat 11.2.1-9)")
C linker for the host machine: cc ld.bfd 2.35.2-6
Host machine cpu family: x86_64
Host machine cpu: x86_64
Program python3 found: YES (/usr/bin/python3)
Program git found: YES (/usr/bin/git)
Message: r2 lib version: 5.6.7
Library dl found: YES
Run-time dependency threads found: YES
Library util found: YES
Library m found: YES
Configuring config.h using configuration
Library magic found: NO
Found pkg-config: /usr/bin/pkg-config (1.7.3)
Found CMake: /usr/bin/cmake (3.20.5)
Run-time dependency libxxhash found: NO (tried pkgconfig and cmake)
Run-time dependency xxhash found: NO (tried pkgconfig and cmake)
Library xxhash found: NO
Message: Using bundled xxhash library
Run-time dependency libuv found: NO (tried pkgconfig and cmake)
meson.build:298: WARNING: use_libuv option was set to true, but libuv was not found.
Message: Not using libuv, thus using fallback server implementations
Message: HAVE_PTRACE: true
Message: USE_PTRACE_WRAP: true
Message: R2_CHECKS_LEVEL: 2
Header <sys/personality.h> has symbol "ADDR_NO_RANDOMIZE" : YES 
Checking for function "clock_gettime" : YES 
Checking for function "arc4random_uniform" : NO 
Checking for function "explicit_bzero" : YES 
Checking for function "explicit_memset" : NO 
Checking for function "clock_nanosleep" : YES 
Checking for function "clock_gettime" : YES (cached)
Checking for function "sigaction" : YES 
Configuring r_userconf.h using configuration
Configuring r_version.h using configuration
Configuring libr.pc using configuration
Run-time dependency zlib found: YES 1.2.11
Message: Use bundled zlib
Run-time dependency libzip found: NO (tried pkgconfig and cmake)
Message: Use bundled zip
Run-time dependency liblz4 found: NO (tried pkgconfig and cmake)
Message: Using bundled lz4
Run-time dependency capstone found: NO (tried pkgconfig and cmake)
Message: Use bundled capstone
Message: Use bundled magic library
Program sys/create_r2.sh found: YES (/root/softwares/radare2/sys/create_r2.sh)
Build targets in project: 353

Found ninja-1.10.2 at /usr/bin/ninja

root@fedora ~/softwares/radare2                                                                                                                                                                         [20:44:12] 
> #ninja -C build                                                                                                                                                                                       [±master]
ninja: Entering directory `build'
[291/1504] Compiling C object libr/hash/libr_hash.so.5.6.7.p/sha2.c.o
../libr/hash/sha2.c:513:26: warning: argument 1 of type 'uint8_t *' {aka 'unsigned char *'} declared as a pointer [-Warray-parameter=]
  513 | void r_SHA256_Final(ut8 *digest, R_SHA256_CTX *context) {
In file included from ../libr/include/r_types.h:8,
                 from ../libr/include/r_hash.h:4,
                 from ../libr/hash/sha2.c:36:
../libr/include/r_types_base.h:21:13: note: previously declared as an array 'uint8_t[32]' {aka 'unsigned char[32]'}
   21 | #define ut8 uint8_t
../libr/hash/sha2.h:78:21: note: in expansion of macro 'ut8'
   78 | void r_SHA256_Final(ut8[r_SHA256_DIGEST_LENGTH], R_SHA256_CTX*);
      |                     ^~~
../libr/hash/sha2.c:585:48: warning: argument 2 of type 'char[]' with mismatched bound [-Warray-parameter=]
  585 | char *r_SHA256_End(R_SHA256_CTX *context, char buffer[]) {
      |                                           ~~~~~^~~~~~~~
In file included from ../libr/hash/sha2.c:37:
../libr/hash/sha2.h:79:35: note: previously declared as 'char[65]'
   79 | char* r_SHA256_End(R_SHA256_CTX*, char[r_SHA256_DIGEST_STRING_LENGTH]);
      |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../libr/hash/sha2.c:896:25: warning: argument 1 of type 'uint8_t[]' {aka 'unsigned char[]'} with mismatched bound [-Warray-parameter=]
  896 | void r_SHA512_Final(ut8 digest[], R_SHA512_CTX *context) {
In file included from ../libr/include/r_types.h:8,
                 from ../libr/include/r_hash.h:4,
                 from ../libr/hash/sha2.c:36:
../libr/include/r_types_base.h:21:13: note: previously declared as 'uint8_t[64]' {aka 'unsigned char[64]'}
   21 | #define ut8 uint8_t
../libr/hash/sha2.h:90:21: note: in expansion of macro 'ut8'
   90 | void r_SHA512_Final(ut8[r_SHA512_DIGEST_LENGTH], R_SHA512_CTX*);
      |                     ^~~
../libr/hash/sha2.c:927:48: warning: argument 2 of type 'char[]' with mismatched bound [-Warray-parameter=]
  927 | char *r_SHA512_End(R_SHA512_CTX *context, char buffer[]) {
      |                                           ~~~~~^~~~~~~~
In file included from ../libr/hash/sha2.c:37:
../libr/hash/sha2.h:91:35: note: previously declared as 'char[129]'
   91 | char* r_SHA512_End(R_SHA512_CTX*, char[r_SHA512_DIGEST_STRING_LENGTH]);
      |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../libr/hash/sha2.c:974:25: warning: argument 1 of type 'uint8_t[]' {aka 'unsigned char[]'} with mismatched bound [-Warray-parameter=]
  974 | void r_SHA384_Final(ut8 digest[], R_SHA384_CTX *context) {
In file included from ../libr/include/r_types.h:8,
                 from ../libr/include/r_hash.h:4,
                 from ../libr/hash/sha2.c:36:
../libr/include/r_types_base.h:21:13: note: previously declared as 'uint8_t[48]' {aka 'unsigned char[48]'}
   21 | #define ut8 uint8_t
../libr/hash/sha2.h:84:21: note: in expansion of macro 'ut8'
   84 | void r_SHA384_Final(ut8[r_SHA384_DIGEST_LENGTH], R_SHA384_CTX*);
      |                     ^~~
../libr/hash/sha2.c:1005:48: warning: argument 2 of type 'char[]' with mismatched bound [-Warray-parameter=]
 1005 | char *r_SHA384_End(R_SHA384_CTX *context, char buffer[]) {
      |                                           ~~~~~^~~~~~~~
In file included from ../libr/hash/sha2.c:37:
../libr/hash/sha2.h:85:35: note: previously declared as 'char[97]'
   85 | char* r_SHA384_End(R_SHA384_CTX*, char[r_SHA384_DIGEST_STRING_LENGTH]);
      |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[1504/1504] Linking target test/unit/test_vector

root@fedora ~/softwares/radare2                                                                                                                                                                         [20:48:07] 
> #radare2 -v                                                                                                                                                                                           [±master]
radare2 5.6.7 27746 @ linux-x86-64 git.5.6.6-68-g2b77b277d
commit: 2b77b277d67ce061ee6ef839e7139ebc2103c1e3 build: 2022-04-11__12:44:09

Thanks to you, it compiles fine with meson

trufae commented 2 years ago

Can you share the build log using configure make instead? I'm happy that it worked with meson, but the working log doesnt helps me to understand your issue

junchao98 commented 2 years ago

I found the cause of the error because I set some environment variables in .bashrc to facilitate the cross-compilation of my project, which caused the error

export CROSS_HOST=xxx
export CROSS_TARGET=xxx
export BUILDDIR=xxx
export SYSDIR=

Thanks again for your help!