Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable Detect Clang Compiler in MacOS #12044

Closed
SajjadPourali opened this issue Nov 2, 2018 · 15 comments
Closed

Unable Detect Clang Compiler in MacOS #12044

SajjadPourali opened this issue Nov 2, 2018 · 15 comments
Labels
buildsystem MacOS Apple OS X platform support issues
Milestone

Comments

@SajjadPourali
Copy link
Contributor

Hi,
When building librz.a clang has an error, I didn't yet check why it's happened.

$uname -a 
Darwin xxx.local 18.2.0 Darwin Kernel Version 18.2.0: Fri Oct  5 19:41:49 PDT 2018; root:xnu-4903.221.2~2/RELEASE_X86_64 x86_64
$clang --version
Apple LLVM version 10.0.0 (clang-1000.10.44.2)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
cp -f ../../shlr/spp//config.def.h ../../shlr/spp//config.h
/Library/Developer/CommandLineTools/usr/bin/make spp_build
make[2]: Nothing to be done for `spp_build'.
/Library/Developer/CommandLineTools/usr/bin/make all2
"gcc -dynamiclib -o libr_util.dylib -Wl,-install_name,/opt/local//lib/libr_util.dylib binheap.o mem.o unum.o str.o hex.o file.o range.o tinyrange.o prof.o cache.o sys.o buf.o w32-sys.o ubase64.o base85.o base91.o list.o flist.o mixed.o btree.o chmod.o graph.o event.o regex/regcomp.o regex/regerror.o regex/regexec.o uleb128.o sandbox.o calc.o thread.o thread_sem.o thread_lock.o thread_cond.o strpool.o bitmap.o date.o format.o pie.o print.o ctype.o seven.o slist.o randomart.o zip.o debruijn.o log.o utf8.o utf16.o utf32.o strbuf.o lib.o name.o spaces.o signal.o syscmd.o diff.o bdiff.o stack.o queue.o tree.o des.o idpool.o assert.o punycode.o pkcs7.o x509.o asn1.o astr.o json_indent.o skiplist.o r_json.o rbtree.o qrcode.o trie.o vector.o str_trim.o ascii_table.o ../../shlr/sdb/src/buffer.o ../../shlr/sdb/src/cdb.o ../../shlr/sdb/src/cdb_make.o ../../shlr/sdb/src/ht.o ../../shlr/sdb/src/sdbht.o ../../shlr/sdb/src/json.o ../../shlr/sdb/src/lock.o ../../shlr/sdb/src/ls.o ../../shlr/sdb/src/ns.o ../../shlr/sdb/src/query.o ../../shlr/sdb/src/sdb.o ../../shlr/sdb/src/base64.o ../../shlr/sdb/src/disk.o ../../shlr/sdb/src/dict.o ../../shlr/sdb/src/array.o ../../shlr/sdb/src/fmt.o ../../shlr/sdb/src/match.o ../../shlr/sdb/src/num.o ../../shlr/sdb/src/util.o ../../shlr/sdb/src/journal.o ../../shlr/spp/spp.o       -fPIC /opt/radare2/libr/../shlr/zip/librz.a -fvisibility=hidden     -lpthread  -lm -fvisibility=hidden"
ld: warning: ignoring file /opt/radare2/libr/../shlr/zip/librz.a, file was built for archive which is not the architecture being linked (x86_64): /opt/radare2/libr/../shlr/zip/librz.a
Undefined symbols for architecture x86_64:
  "_inflate", referenced from:
      _r_inflate in zip.o
     (maybe you meant: _r_inflate)
  "_inflateEnd", referenced from:
      _r_inflate in zip.o
  "_inflateInit2_", referenced from:
      _r_inflate in zip.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libr_util.dylib] Error 1
make[1]: *** [all] Error 2
make: *** [all] Error 2
@SajjadPourali
Copy link
Contributor Author

SajjadPourali commented Nov 2, 2018

It seems problem is related to build script, it can not detect compiler is clang.

Final report:
 - R_CHECKS_LEVEL = 2
 - PREFIX = /usr/local
 - HAVE_LIB_GMP = 0
 - HAVE_OPENSSL = 0
 - HAVE_LIBUV = 0
 - USE_CAPSTONE = 0
 - HAVE_PTRACE = 1
 - USE_PTRACE_WRAP = 0
 - HAVE_FORK = 1
 - VERSION = 3.1.0-git
 - USE_LIB_ZIP = 0
 - USE_LIB_MAGIC = 0
 - USE_LIB_XXHASH = 0
 - DEBUGGER = 1
 - CC = gcc
 - USERCC = gcc
 - HAVE_ARC4RANDOM_UNIFORM = 1
 - HAVE_EXPLICIT_BZERO = 0
 - USEROSTYPE = darwin
 - LIBVERSION = 3.1.0-git
 - BUILD = x86_64-unknown-darwin
 - HOST = x86_64-unknown-darwin
 - TARGET = x86_64-unknown-darwin

@SajjadPourali SajjadPourali changed the title MacOS Mojave Librz Linking Build Error Clang Linking Build Error Nov 2, 2018
@SajjadPourali SajjadPourali changed the title Clang Linking Build Error Unable Detect Clang Compiler in MacOS Nov 2, 2018
@radare
Copy link
Collaborator

radare commented Nov 3, 2018 via email

@SajjadPourali
Copy link
Contributor Author

SajjadPourali commented Nov 3, 2018

Yes, I did try with make and sys/install.sh.
result of sys/install.sh:
https://asciinema.org/a/HtyFF5sGTiI5kOrormBpcNzDT

result of make command :
https://asciinema.org/a/K4BdilN5rzP97VZJb8fv0rwQN

env:

TERM_PROGRAM=iTerm.app
TERM=xterm-256color
SHELL=/bin/bash
TMPDIR=/var/folders/zw/***/T/
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.***/Render
TERM_PROGRAM_VERSION=3.2.5
TERM_SESSION_ID=***:***
USER=***
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.***/Listeners
__CF_USER_TEXT_ENCODING=0x0:0:0
PATH=/Users/***/.cargo/bin:/Users/***/.jenv/shims:/Users/***/.rbenv/shims:/opt/local/bin:/usr/local/opt/findutils/libexec/gnubin:/Users/***/.cargo/bin:/usr/local/bin:/usr/local/sbin:/Users/***/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/Library/TeX/texbin:/opt/X11/bin:/Applications/Wireshark.app/Contents/MacOS
JENV_LOADED=1
PWD=/opt/radare2
LANG=en_US.UTF-8
ITERM_PROFILE=Default
XPC_FLAGS=0x0
RBENV_SHELL=bash
XPC_SERVICE_NAME=0
SHLVL=1
HOME=/Users/***
COLORFGBG=7;0
ITERM_SESSION_ID=***:****
LOGNAME=***
DISPLAY=/private/tmp/com.apple.launchd.***/org.macosforge.xquartz:0
COLORTERM=truecolor
_=/usr/bin/env
OLDPWD=/opt
$gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.10.44.2)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$uname -a
Darwin ***.local 18.2.0 Darwin Kernel Version 18.2.0: Fri Oct  5 19:41:49 PDT 2018; root:xnu-4903.221.2~2/RELEASE_X86_64 x86_64

@ZhangZhuoSJTU
Copy link
Contributor

Same problem here.

$ uname -a
Darwin xxx.local 18.0.0 Darwin Kernel Version 18.0.0: Wed Aug 22 20:13:40 PDT 2018; root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64
$ clang --version
Apple LLVM version 10.0.0 (clang-1000.10.44.4)
Target: x86_64-apple-darwin18.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Error report is almost the same:

ld: warning: ignoring file XXX/radare2/libr/../shlr/zip/librz.a, file was built for archive which is not the architecture being linked (x86_64): XXX/radare2/libr/../shlr/zip/librz.a
Undefined symbols for architecture x86_64:
  "_inflate", referenced from:
      _r_inflate in zip.o
     (maybe you meant: _r_inflate)
  "_inflateEnd", referenced from:
      _r_inflate in zip.o
  "_inflateInit2_", referenced from:
      _r_inflate in zip.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libr_util.dylib] Error 1
make[1]: *** [all] Error 2
make: *** [all] Error 2

@XVilka XVilka added buildsystem MacOS Apple OS X platform support issues labels Nov 5, 2018
@radare
Copy link
Collaborator

radare commented Nov 5, 2018

Did you git clean -xdf. Sounds to me like you have upgraded xcode and the builddir have still object files created with the old one

@radare radare closed this as completed Nov 5, 2018
@radare radare reopened this Nov 5, 2018
@ZhangZhuoSJTU
Copy link
Contributor

I think I have done git clean -xdf, but it failed. I also cloned the repo in a new directory, same error occurred.

@radare
Copy link
Collaborator

radare commented Nov 5, 2018

The real error here is in
8f1d57cd-6243-423f-93a9-6be5708d57f6

@radare
Copy link
Collaborator

radare commented Nov 5, 2018

I have also seen warnings that are fixed in master.. and cant repro yet..

@SajjadPourali
Copy link
Contributor Author

SajjadPourali commented Nov 5, 2018

I have also seen warnings that are fixed in master.. and cant repro yet..

It can be fix by using libtool -static instead of ar q command.


Please check this topic too : https://stackoverflow.com/questions/52529838/gdb-8-2-cant-recognized-executable-file-on-macos-mojave-10-14#answer-52995622

@radare radare added this to the 3.1.0 milestone Nov 6, 2018
@ZhangZhuoSJTU
Copy link
Contributor

@SajjadPourali A quick question. May I know which place you have edited to make clang work? I tried but failed these days. :(

@radare
Copy link
Collaborator

radare commented Nov 7, 2018 via email

@ZhangZhuoSJTU
Copy link
Contributor

I have also seen warnings that are fixed in master.. and cant repro yet..

Could you please let me know which commit fixed these warnings? This might help me debug about why building failed on my machine. Thanks a lot.

@SajjadPourali
Copy link
Contributor Author

SajjadPourali commented Nov 7, 2018

@ZhangZhuoSJTU : I did attach my changes, it's dirty fix but it works.
my changes : radare-fixed.tar.gz

sorry, I didn't create patch file, because I'm sleepy and capstone needs patch too, it take a little bit time.

@sferrini
Copy link
Contributor

sferrini commented Nov 8, 2018

@SajjadPourali and @ZhangZhuoSJTU are you using binutils from brew (Check with brew list | grep binutils)?

I solved uninstalling it and just using binutils from Xcode (default).

@SajjadPourali
Copy link
Contributor Author

SajjadPourali commented Nov 8, 2018

@sferrini : Thank you,I did unlink binutils and it works.
I think when I did update binutils to 2.31.1, this problem appears.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
buildsystem MacOS Apple OS X platform support issues
Projects
None yet
Development

No branches or pull requests

5 participants