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

Fails to build with Xcode 10 on macOS Mojave, openssl and yaracpp issue #439

Closed
AlexanderOMara opened this issue Dec 10, 2018 · 43 comments · Fixed by #611
Closed

Fails to build with Xcode 10 on macOS Mojave, openssl and yaracpp issue #439

AlexanderOMara opened this issue Dec 10, 2018 · 43 comments · Fixed by #611

Comments

@AlexanderOMara
Copy link

AlexanderOMara commented Dec 10, 2018

I've been trying to get this to build with Xcode 10 on macOS Mojave, but it seems to be running into trouble with 2 of the dependencies.

CMake Error at /Users/user/Software/RetDec/0.7/retdec-master/build/deps/openssl/openssl/src/openssl-stamp/openssl-build-Release.cmake:16 (message):
  Command failed: 2

   'make' '-j8'

  See also

    /Users/user/Software/RetDec/0.7/retdec-master/build/deps/openssl/openssl/src/openssl-stamp/openssl-build-*.log


make[2]: *** [deps/openssl/openssl/src/openssl-stamp/openssl-build] Error 1
make[1]: *** [deps/openssl/CMakeFiles/openssl.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

...

CMake Error at /Users/user/Software/RetDec/0.7/retdec-master/build/external/src/yaracpp-project-stamp/yaracpp-project-build-Release.cmake:16 (message):
  Command failed: 2

   '/Applications/Xcode.app/Contents/Developer/usr/bin/make'

  See also

    /Users/user/Software/RetDec/0.7/retdec-master/build/external/src/yaracpp-project-stamp/yaracpp-project-build-*.log


make[2]: *** [external/src/yaracpp-project-stamp/yaracpp-project-build] Error 1
make[1]: *** [deps/yaracpp/CMakeFiles/yaracpp-project.dir/all] Error 2

Attached are the log files detailing the errors.

openssl-build-err.log
yaracpp-project-build-err.log

Based on the log file info, I suspect this issue may be related to Apple dropping support for 32-bit code.

@s3rvac
Copy link
Member

s3rvac commented Dec 12, 2018

Hi.

As for the openssl issue, could you try installing it via brew install openssl? After that, CMake should be able to use it instead of building it from source files. After installation of OpenSSL from Homebrew, you will probably need to add it into PATH via export PATH="$(brew --prefix openssl)/bin:$PATH" (this is based on what I have read as I am not a macOS user), clean the build directory and retry the build.

As for the yaracpp issue, could you please ensure that you have Xcode's command-line tools? The yaracpp-project-build-err.log log contains exactly the same error as in #425 and #433, so this may be the reason. After installation of the command-line tools, please clean the build directory and retry the build. Should it fail, please include the output from /Users/user/Software/RetDec/0.7/retdec-master/build/external/src/yaracpp-project-build/deps/yara/src/yara/config.log that will contain more details.

@nkaretnikov
Copy link

nkaretnikov commented Dec 13, 2018

FWIW: same issue with openssl, the suggested fix doesn't help.

UPD: reinstalling openssl and setting some env vars as suggested by brew did work.

Some yara issues were fixed by reinstalling flex and bison (and setting env vars), setting Apple specific env vars as suggested by README, and reinstalling command-line tools.

Current status:

retdec/build/external/src/yaracpp-project-stamp/yaracpp-project-build-err.log

ld: archive has no table of contents file 'libyara/.libs/libyara.a' for architecture x86_64
ld: archive has no table of contents file 'libyara/.libs/libyara.a' for architecture x86_64
clang: error: unable to execute command: Segmentation fault: 11
clang: error: linker command failed due to signal (use -v to see invocation)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[7]: *** [yara] Error 254
make[7]: *** Waiting for unfinished jobs....
make[7]: *** [yarac] Error 1
make[6]: *** [all-recursive] Error 1
make[5]: *** [deps/yara/src/yara-stamp/yara-build] Error 2
make[4]: *** [deps/CMakeFiles/yara.dir/all] Error 2
make[3]: *** [all] Error 2

@AlexanderOMara
Copy link
Author

AlexanderOMara commented Dec 13, 2018

I definitely had the CLI tools installed, and also tried reinstalling them just to be sure. Setting up Homebrew OpenSSL does get around the OpenSSL build failure:

export PATH="/usr/local/opt/openssl/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"

But it still fails on yaracpp:

CMake Error at /Users/user/Software/RetDec/0.7/retdec-master/build/external/src/yaracpp-project-stamp/yaracpp-project-build-Release.cmake:16 (message):
  Command failed: 2

   '/Applications/Xcode.app/Contents/Developer/usr/bin/make'

  See also

    /Users/user/Software/RetDec/0.7/retdec-master/build/external/src/yaracpp-project-stamp/yaracpp-project-build-*.log


make[2]: *** [external/src/yaracpp-project-stamp/yaracpp-project-build] Error 1
make[1]: *** [deps/yaracpp/CMakeFiles/yaracpp-project.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

yaracpp-project-build-err.log

@AlexanderOMara AlexanderOMara changed the title Fails to build on macOS Mojave, openssl and yaracpp issue Fails to build with Xcode 10 on macOS Mojave, openssl and yaracpp issue Dec 13, 2018
@AlexanderOMara
Copy link
Author

AlexanderOMara commented Dec 13, 2018

One thing I should point out, the issue is actually with Xcode 10 (which dropped 32-bit support) rather than Mojave itself. If you were to install the last version of Xcode 9 and the accompanying CLI tools on Mojave you can build it.

I was successfully able to build it in a Mojave VM with Xcode 9 and copy over the builds to my host OS.

@bmourit
Copy link
Contributor

bmourit commented Dec 14, 2018

If I remember correctly, this may have something to do with a homebrew installed version of binutils. I think I had a problem with it using binutils version during building, but macos tool for linking. Or maybe vise-versa. Anyway, uninstalling via "brew remove binutils" fixed it for me. Apparently something changed somewhere.Try it and let us know. I remember seeing Command failed error of 'make' '-jN'.

Hopefully this saves you from downgrading xcode.

@s3rvac
Copy link
Member

s3rvac commented Dec 17, 2018

@AlexanderOMara Can you please attach the output from /Users/user/Software/RetDec/0.7/retdec-master/build/external/src/yaracpp-project-build/deps/yara/src/yara/config.log? It will contain more details why the yaracpp build failed.

@AlexanderOMara
Copy link
Author

Attached:

config.log

@s3rvac
Copy link
Member

s3rvac commented Dec 20, 2018

Thank you. Could you please try the following builds of YARA (our own fork and the upstream version) and let us know whether each of the builds succeeded/failed? It will help us to determine whether the issue is with our own fork or with the upstream version, and if so, whether it has been fixed.

  1. Our own fork (based on YARA v3.6):
git clone https://github.com/avast-tl/yara -b retdec yara-retdec
cd yara-retdec
./bootstrap.sh && ./configure && make && echo OK
  1. Upstream version (v3.6):
git clone https://github.com/VirusTotal/yara -b v3.6.3 yara-3.6.3
cd yara-3.6.3
./bootstrap.sh && ./configure && make && echo OK
  1. Upstream version (v3.7):
git clone https://github.com/VirusTotal/yara -b v3.7.1 yara-3.7.1
cd yara-3.7.1
./bootstrap.sh && ./configure && make && echo OK
  1. Upstream version (v3.8):
git clone https://github.com/VirusTotal/yara -b v3.8.1 yara-3.8.1
cd yara-3.8.1
./bootstrap.sh && ./configure && make && echo OK
  1. Upstream version (master):
git clone https://github.com/VirusTotal/yara yara-master
cd yara-master
./bootstrap.sh && ./configure && make && echo OK

@AlexanderOMara
Copy link
Author

Pass:

  • yara-3.8.1
  • yara-master
  • yara-retdec

Fail:

  • yara-3.6.3
  • yara-3.7.1

@s3rvac
Copy link
Member

s3rvac commented Dec 20, 2018

Are you sure that the yara-retdec build has passed? It should have failed for the following two reasons: (1) yara-retdec is based on yara-3.6.3, whose build has failed, and (2) in your original report, yaracpp build has failed because of a YARA build failure (yara-retdec). Can you please verify?

@AlexanderOMara
Copy link
Author

I thought that was strange too, but I just tested it again, and it passed.

@AlexanderOMara
Copy link
Author

@bmourit I just tried brew remove binutils but it still failed in the same way.

@s3rvac
Copy link
Member

s3rvac commented Dec 20, 2018

Alright. Could I ask you to do one final test?

git clone https://github.com/avast-tl/yara -b retdec yara-retdec-ea101c5
cd yara-retdec-ea101c5
git checkout ea101c5856941f39cad2db3012f2660d1d5c8b65
./bootstrap.sh && ./configure && make && echo OK

That ea101c5 commit is the one that is actually used by yaracpp in RetDec at the moment. The build should fail. If it succeeds, then there is something fishy going on.

@AlexanderOMara
Copy link
Author

I guess something fishy is going on, because that passed too.

@s3rvac
Copy link
Member

s3rvac commented Dec 20, 2018

@metthal Do you have an idea what might be going on here?

@bmourit
Copy link
Contributor

bmourit commented Dec 21, 2018

@AlexanderOMara Did you clean all build cache first? I had to delete the build folder and make a new one and build everything fresh.

@AlexanderOMara
Copy link
Author

@bmourit Yep, I always deleted the build folder between build attempts.

@bmourit
Copy link
Contributor

bmourit commented Dec 21, 2018

Hmm.. odd. I had an issue with those exact same external projects (yaracpp and openssl). I'm trying to remember exactly what I did to fix it. There was something to do with my $PATH as well. I'll see if I can dig around some more to refresh my memory.

@bmourit
Copy link
Contributor

bmourit commented Dec 21, 2018

@AlexanderOMara
What's your output of the following:
which -a ar
which -a ranlib

@AlexanderOMara
Copy link
Author

$ which -a ar
/usr/bin/ar
$ which -a ranlib
/usr/bin/ranlib

@bmourit
Copy link
Contributor

bmourit commented Dec 21, 2018

Try this:
$ brew install make
Once installed, add it to your $PATH and try building again. Also, do you have coreutils installed? I didn't see it in your config file, but it's another difference in our configs (I have it installed).
See if that helps anything.

Update:
The reason I'm going this route is because I am using Mojave with the same Xcode 10 build, previously had this issue, fixed it somehow, but forgot what exactly it was that fixed it.

@dendisuhubdy
Copy link

This happens to me too

@s3rvac
Copy link
Member

s3rvac commented Jan 3, 2019

@AlexanderOMara @dendisuhubdy Could you please try performing the following two builds and let us know if they pass or fail? The results will help us to determine whether the issue is in the currently used version of YARA in RetDec/yaracpp or in something else.

Note: Before you try the builds, please ensure that you have command-line tools installed and the following variables set:

# Apple ships old Flex & Bison, so Homebrew versions should be used.
export CMAKE_INCLUDE_PATH="/usr/local/opt/flex/include"
export CMAKE_LIBRARY_PATH="/usr/local/opt/flex/lib;/usr/local/opt/bison/lib"
export PATH="/usr/local/opt/flex/bin:/usr/local/opt/bison/bin:$PATH"
  1. The currently used version of yaracpp in RetDec:
git clone https://github.com/avast-tl/yaracpp yaracpp-retdec
cd yaracpp-retdec
git checkout b92bde0e59e3b75bc445227e04b71105771dee8b
mkdir build
cd build
cmake ..
make && echo OK
  1. yaracpp using the latest version of YARA (3.8.1):
git clone https://github.com/avast-tl/yaracpp yaracpp-latest-yara
cd yaracpp-latest-yara
mkdir build
cd build
cmake ..
make && echo OK

If any of the builds fail, please attach build/deps/yara/src/yara/config.log for them.

@dendisuhubdy
Copy link

@s3rvac both failed, here are the build log dump on Pastebin (unlisted) https://pastebin.com/bX9r9cmf and https://pastebin.com/G6j5fQsf

@s3rvac
Copy link
Member

s3rvac commented Jan 4, 2019

@dendisuhubdy Thank you. Could you please try installing SDK headers by running

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

and then re-trying the first yaracpp build above from scratch (from a clean directory)?

@metthal
Copy link
Member

metthal commented Jan 4, 2019

EDIT: Please run this even if the workaround above worked for you. We would like to get rid of the requirement of installing command line tools and this would help us understand why is it required.

If the step above didn't work for you, I would like to ask you (or anyone else in this thread who is having this problem) to run this to build yaracpp:

git clone https://github.com/avast-tl/yaracpp.git
cd yaracpp
mkdir build
cd build
cmake ..
cmake --build .
mv deps/yara/src/yara/config.log config-yaracpp.log

And then run this to build upstream yara:

git clone https://github.com/VirusTotal/yara.git
cd yara
./bootstrap.sh
./configure --enable-macho --disable-shared --without-crypto
make

The first build should fail and second one should pass. Now, please attach these two files:

yaracpp/build/config-yaracpp.log
yara/config.log

@dendisuhubdy
Copy link

@s3rvac it says that the .pkg does not exist

 grokmachine@Dendis-MacBook-Pro   ~  open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg                                                                                       ✔  4681  18:05:46 
The file /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg does not exist.

@bmourit
Copy link
Contributor

bmourit commented Jan 4, 2019

@dendisuhubdy Go to https://developer.apple.com/download/more/ and download the "Command Line Tools (macOS 10.14) for Xcode 10.1" pkg.

@dendisuhubdy
Copy link

@bmourit I did that, downloaded it and installed it but honestly I do remember installing the command line tool when I installed Xcode 10.1 already. And I redid what @s3rvac told me to and it still has linking issues. Take a look

libtool: link: ar cru .libs/libyara.a  modules/tests.o modules/pe.o modules/elf.o modules/macho.o modules/math.o modules/pe_utils.o grammar.o ahocorasick.o arena.o atoms.o compiler.o endian.o exec.o exefiles.o filemap.o hash.o hex_grammar.o hex_lexer.o lexer.o libyara.o mem.o modules.o object.o parser.o proc.o re.o re_grammar.o re_lexer.o rules.o scan.o sizedstr.o strutils.o stream.o threading.o
ar: `u' modifier ignored since `D' is the default (see `U')
libtool: link: ranlib .libs/libyara.a
libtool: link: ( cd ".libs" && rm -f "libyara.la" && ln -s "../libyara.la" "libyara.la" )
libtool: link: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -std=gnu99 -Wall -I./libyara/include -O3 -I/opt/local/include -I/usr/local/opt/openssl/include -D_THREAD_SAFE -o yarac args.o yarac.o  -L/usr/local/opt/llvm/lib libyara/.libs/libyara.a -lm
ld: warning: ignoring file libyara/.libs/libyara.a, file was built for archive which is not the architecture being linked (x86_64): libyara/.libs/libyara.a
Undefined symbols for architecture x86_64:
  "_yr_compiler_add_file", referenced from:
      _main in yarac.o
  "_yr_compiler_create", referenced from:
      _main in yarac.o
  "_yr_compiler_define_boolean_variable", referenced from:
      _define_external_variables in yarac.o
  "_yr_compiler_define_integer_variable", referenced from:
      _define_external_variables in yarac.o
  "_yr_compiler_define_string_variable", referenced from:
      _define_external_variables in yarac.o
  "_yr_compiler_destroy", referenced from:
      _main in yarac.o
  "_yr_compiler_get_rules", referenced from:
      _main in yarac.o
  "_yr_compiler_set_callback", referenced from:
      _main in yarac.o
  "_yr_finalize", referenced from:
      _main in yarac.o
  "_yr_initialize", referenced from:
      _main in yarac.o
  "_yr_rules_destroy", referenced from:
      _main in yarac.o
  "_yr_rules_save", referenced from:
      _main in yarac.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[4]: *** [yarac] Error 1
make[4]: *** Waiting for unfinished jobs....
libtool: link: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -std=gnu99 -Wall -I./libyara/include -O3 -I/opt/local/include -I/usr/local/opt/openssl/include -D_THREAD_SAFE -o yara args.o threading.o yara.o  -L/usr/local/opt/llvm/lib libyara/.libs/libyara.a -lm
ld: warning: ignoring file libyara/.libs/libyara.a, file was built for archive which is not the architecture being linked (x86_64): libyara/.libs/libyara.a
Undefined symbols for architecture x86_64:
  "_yr_compiler_add_file", referenced from:
      _main in yara.o
  "_yr_compiler_create", referenced from:
      _main in yara.o
  "_yr_compiler_define_boolean_variable", referenced from:
      _define_external_variables in yara.o
  "_yr_compiler_define_float_variable", referenced from:
      _define_external_variables in yara.o
  "_yr_compiler_define_integer_variable", referenced from:
      _define_external_variables in yara.o
  "_yr_compiler_define_string_variable", referenced from:
      _define_external_variables in yara.o
  "_yr_compiler_destroy", referenced from:
      _main in yara.o
  "_yr_compiler_get_rules", referenced from:
      _main in yara.o
  "_yr_compiler_set_callback", referenced from:
      _main in yara.o
  "_yr_filemap_map", referenced from:
      _load_modules_data in yara.o
  "_yr_filemap_unmap", referenced from:
      _unload_modules_data in yara.o
      _main in yara.o
  "_yr_finalize", referenced from:
      _main in yara.o
  "_yr_finalize_thread", referenced from:
      _scanning_thread in yara.o
  "_yr_get_tidx", referenced from:
      _handle_message in yara.o
  "_yr_initialize", referenced from:
      _main in yara.o
  "_yr_object_print_data", referenced from:
      _callback in yara.o
  "_yr_rules_define_boolean_variable", referenced from:
      _define_external_variables in yara.o
  "_yr_rules_define_float_variable", referenced from:
      _define_external_variables in yara.o
  "_yr_rules_define_integer_variable", referenced from:
      _define_external_variables in yara.o
  "_yr_rules_define_string_variable", referenced from:
      _define_external_variables in yara.o
  "_yr_rules_destroy", referenced from:
      _main in yara.o
  "_yr_rules_load", referenced from:
      _main in yara.o
  "_yr_rules_scan_file", referenced from:
      _scanning_thread in yara.o
      _main in yara.o
  "_yr_rules_scan_proc", referenced from:
      _main in yara.o
  "_yr_set_configuration", referenced from:
      _main in yara.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[4]: *** [yara] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [deps/yara/src/yara-stamp/yara-build] Error 2
make[1]: *** [deps/CMakeFiles/yara.dir/all] Error 2
make: *** [all] Error 2

@bmourit
Copy link
Contributor

bmourit commented Jan 6, 2019

@dendisuhubdy what's your output of the following:
$ which -a ar
$ which -a ranlib

@appleguru
Copy link

I am having the same issues.. watching this thread closely; let me know if I can help.

@metthal
Copy link
Member

metthal commented Jan 7, 2019

You can try what I mentioned in this comment. It would help us with finding differences between direct build of yara and build through CMake in yaracpp.

@dendisuhubdy
Copy link

@bmourit

 grokmachine@Dendis-MacBook-Pro   ~/dev/bitwyre/exchange/bitcoin_dev/bips     master  which -a ar                                                                                                               ✔  5292  00:12:00 
/usr/local/bin/ar
/usr/bin/ar
 grokmachine@Dendis-MacBook-Pro   ~/dev/bitwyre/exchange/bitcoin_dev/bips     master  which -a ranlib                                                                                                           ✔  5293  00:12:53 
/usr/local/bin/ranlib
/usr/bin/ranlib

@appleguru
Copy link

appleguru commented Jan 7, 2019

You can try what I mentioned in this comment. It would help us with finding differences between direct build of yara and build through CMake in yaracpp.

I don't even get far enough to have the build logs you're looking for. I get a libtoolize error in both cases:

yaracpp:

[ 42%] Performing configure-linux step for 'yara'
Can't exec "libtoolize": No such file or directory at /usr/local/share/autoconf/Autom4te/FileUtils.pm line 345, <GEN2> line 4.
autoreconf: failed to run libtoolize: No such file or directory
autoreconf: libtoolize is needed because this package uses Libtool
make[2]: *** [deps/yara/src/yara-stamp/yara-configure-linux] Error 1
make[1]: *** [deps/CMakeFiles/yara.dir/all] Error 2
make: *** [all] Error 2

yara:

144:testing user$ git clone https://github.com/VirusTotal/yara.git
Cloning into 'yara'...
remote: Enumerating objects: 43, done.
remote: Counting objects: 100% (43/43), done.
remote: Compressing objects: 100% (28/28), done.
remote: Total 14274 (delta 17), reused 31 (delta 15), pack-reused 14231
Receiving objects: 100% (14274/14274), 17.87 MiB | 1.46 MiB/s, done.
Resolving deltas: 100% (10244/10244), done.
144:testing user$ cd yara
144:yara user$ ./bootstrap.sh
Can't exec "libtoolize": No such file or directory at /usr/local/share/autoconf/Autom4te/FileUtils.pm line 345, <GEN2> line 4.
autoreconf: failed to run libtoolize: No such file or directory
autoreconf: libtoolize is needed because this package uses Libtool

For some additional environment info, I'm running 10.14.2:

144:yara user$ brew list
adns			fontconfig		help2man		libpng			npth			socat
apktool			freetype		imagemagick		libtasn1		oniguruma		sox
arm-none-eabi-gcc	gawk			isl			libtiff			openssl			sqlite
autoconf		gcc			jpeg			libtool			[email protected]		squashfs
automake		gcc-arm-none-eabi	jq			libunistring		p11-kit			ssdeep
binutils		gd			lame			libusb			p7zip			telnet
binwalk			gdbm			libassuan		libuv			pcre			webp
bison			gettext			libevent		libwebsockets		pinentry		wget
cmake			glib			libffi			lzo			pixman			x264
ddrescue		gmp			libgcrypt		lzop			pkg-config		xvid
dfu-util		gnu-sed			libgpg-error		mad			python			xz
doxygen			gnupg			libidn2			mosquitto		python3
dtc			gnutls			libksba			mpfr			python@2
ffmpeg			graphviz		liblzf			ncurses			qemu
flex			grep			libmpc			nettle			readline
144:yara user$ xcode-select -p
/Applications/Xcode.app/Contents/Developer
144:yara user$ xcodebuild -version
Xcode 10.1
Build version 10B61
144:yara user$ uname -a
Darwin 144.121.37.18.lightower.net 18.2.0 Darwin Kernel Version 18.2.0: Mon Nov 12 20:24:46 PST 2018; root:xnu-4903.231.4~2/RELEASE_X86_64 x86_64

@appleguru
Copy link

I added a symlink to glibtoolize to hack around that error...
sudo ln -s /usr/local/bin/glibtoolize /usr/local/bin/libtoolize

Two build logs attached as requested.
config.log
config-yaracpp.log

@appleguru
Copy link

Ok, success... The workaround above to install the SDK headers seems to have worked. Note, these are apparently not installed as part of the command line tools normally, which I had installed already.

$ open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
$ make clean
$ make -j4
[  0%] Creating directories for 'capstone-project'
...
[100%] Building CXX object src/bin2llvmirtool/CMakeFiles/retdec-bin2llvmirtool.dir/bin2llvmir.cpp.o
[100%] Linking CXX executable retdec-llvmir2hll
[100%] Linking CXX executable retdec-bin2llvmir
[100%] Built target retdec-llvmir2hlltool
[100%] Built target retdec-bin2llvmirtool
$ make install
[  0%] Built target capstone-project
...
-- Installing: /Users/user/retdec/retdec-install/bin/retdec-unpacker
-- Installing: /Users/user/retdec/retdec-install/bin/retdec-getsig

@bmourit
Copy link
Contributor

bmourit commented Jan 8, 2019

@dendisuhubdy
Yes, as mentioned above, your path was finding the homebrew versions of ar and ranlib before the xcode ones. The code was building with xcode, but failing during ar and ranlib due to incompatibility with apple versions. Installing the SDK headers should fix this again. If it doesn't, just change your $PATH so that the xcode versions of the tools for the linker are first, and do a new clean build.

@metthal
Copy link
Member

metthal commented Jan 8, 2019

Thank you @appleguru for the files.

I have prepared branch macos-build in yaracpp repo where we tried to set sysroot of compiler to macOS SDK when configuring yara. It would be really helpful if you or anyone else tried to compile it WITHOUT installed SDK headers.

git clone https://github.com/avast-tl/yaracpp.git
cd yaracpp
git checkout macos-build
mkdir build
cd build
cmake ..
cmake --build .

@dendisuhubdy
Copy link

@bmourit hmm weird ok thanks! Lemme add the correct Xcode versions of ranlib and ar

@s3rvac
Copy link
Member

s3rvac commented Jun 27, 2019

For everyone still having this issue: Could you please try the steps from this comment to see whether it resolves the issue? If not, could you please give us the full output and log files?

@xkubov
Copy link
Contributor

xkubov commented Jun 27, 2019

Hi, I had the same issue and I've been able to fix it by these steps:

OpenSSL issue occurred because cmake was unable to locate it. I fixed this issue by explicitly exporting environment variables with brew installed openssl paths:

export OPENSSL_ROOT_DIR=/usr/local//Cellar/openssl/1.0.2s/
export OPENSSL_LIBRARIES=/usr/local//Cellar/openssl/1.0.2s/lib/

Then I stumbled on the same issue with yaracpp as you. The version of clang that is used by autoconf (installed by Xcode's command-line tools) has invalid include paths which result in basic c program compilation to fail.

To fix this I reinstalled macOS SDK headers:

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

After this, I was able to install RetDec successfully.

Edit:
If OpenSSL is installed from brew then a more generic solution for the specification of OpenSSL path would be:

export OPENSSL_ROOT_DIR="$(brew --prefix openssl)"
export OPENSSL_LIBRARIES="$(brew --prefix openssl)/lib"

PeterMatula added a commit that referenced this issue Jul 2, 2019
This should fix some (not all) macOS compilation issues from #439.
PeterMatula added a commit that referenced this issue Jul 3, 2019
* deps/openssl: bump version from 1.1.0f to 1.1.1c.

This should fix some (not all) macOS compilation issues from #439.

* deps/openssl: add Threads to openssl-crypto's target_link_libraries().
@s3rvac
Copy link
Member

s3rvac commented Jul 8, 2019

OpenSSL-build-related issues should be fixed by #601 (already merged into master). We still need to resolve the yaracpp-build-related issues though.

@s3rvac
Copy link
Member

s3rvac commented Jul 9, 2019

The yaracpp-related issues should be fixed by #611 (already merged into master). If the issue persists, please either re-open the issue or open a new one, depending on the error that you get.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants