Merge branch 'stek29-macos-fix'

This commit is contained in:
Marek Milkovič 2017-12-20 19:47:19 +01:00
commit ecc3464d60
4 changed files with 48 additions and 2 deletions

View File

@ -4,6 +4,7 @@
* Enhancement: Decrease the default timeout when downloading the support package during installation ([#6](https://github.com/avast-tl/retdec/pull/6)). * Enhancement: Decrease the default timeout when downloading the support package during installation ([#6](https://github.com/avast-tl/retdec/pull/6)).
* Enhancement: Any shell can be used to install the decompiler, not just Bash. * Enhancement: Any shell can be used to install the decompiler, not just Bash.
* Enhancement: Added unofficial support for macOS build ([#7](https://github.com/avast-tl/retdec/issues/7))
* Fix: Ordering of compiler detections ([#39](https://github.com/avast-tl/retdec/issues/39)). * Fix: Ordering of compiler detections ([#39](https://github.com/avast-tl/retdec/issues/39)).
* Fix: Remove duplicate `lib` prefix when installing [libdwarf](https://github.com/avast-tl/libdwarf) libraries ([#31](https://github.com/avast-tl/retdec/issues/31)). * Fix: Remove duplicate `lib` prefix when installing [libdwarf](https://github.com/avast-tl/libdwarf) libraries ([#31](https://github.com/avast-tl/retdec/issues/31)).
* Fix: When installing the decompiler, do not remove the entire `share` directory ([#12](https://github.com/avast-tl/retdec/issues/12)). * Fix: When installing the decompiler, do not remove the entire `share` directory ([#12](https://github.com/avast-tl/retdec/issues/12)).

View File

@ -27,7 +27,7 @@ For more information, you can check out:
## Installation and Use ## Installation and Use
Currently, we support only Windows (7 or later) and Linux. Currently, we support only Windows (7 or later), Linux and unofficially macOS.
**Warning: Decompilations of larger binaries (1 MB or more) may require a lot of RAM. When running decompilations, we advise you to limit the maximal virtual memory for processes before decompiling to prevent potential swapping and unresponsiveness. On Linux, you can run e.g. `ulimit -Sv 9863168` in your shell to limit the maximal virtual memory to 8 GB.** **Warning: Decompilations of larger binaries (1 MB or more) may require a lot of RAM. When running decompilations, we advise you to limit the maximal virtual memory for processes before decompiling to prevent potential swapping and unresponsiveness. On Linux, you can run e.g. `ulimit -Sv 9863168` in your shell to limit the maximal virtual memory to 8 GB.**
@ -69,6 +69,28 @@ Currently, we support only Windows (7 or later) and Linux.
For more information, run `./decompile.sh --help`. For more information, run `./decompile.sh --help`.
### macOS
**Warning: macOS build was added based on community feedback and is not directly supported by Avast RetDec Team. We do not guarantee you that these instructions will work for you. If you encounter any problem with your build, file an issue so macOS community can help you out.**
1. There are currently no pre-built packages for macOS. You will have to build and install the decompiler by yourself. The process is described below.
2. After you have built the decompiler, you will need to install the following packages:
* [UPX](https://upx.github.io/)
* [Graphviz](http://www.graphviz.org/)
* GNU Bash
* GNU getopt -- should be first in PATH
3. Now, you are all set to run the decompiler. To decompile a binary file named `test.exe`, go into `$RETDEC_INSTALLED_DIR/bin` and run:
```
# /usr/local/bin/bash if installed via Homebrew
/path/to/gnu/bash ./decompile.sh test.exe
```
For more information, run `./decompile.sh --help`.
## Build and Installation ## Build and Installation
This section describes a manual build and installation of RetDec. This section describes a manual build and installation of RetDec.
@ -110,6 +132,14 @@ sudo dnf install git cmake make gcc gcc-c++ perl python3 bash zlib-devel flex bi
* [Active Perl](https://www.activestate.com/activeperl). It needs to be the first Perl in `PATH`, or it has to be provided to CMake using `CMAKE_PROGRAM_PATH` variable, e.g. `-DCMAKE_PROGRAM_PATH=/c/perl/bin`. * [Active Perl](https://www.activestate.com/activeperl). It needs to be the first Perl in `PATH`, or it has to be provided to CMake using `CMAKE_PROGRAM_PATH` variable, e.g. `-DCMAKE_PROGRAM_PATH=/c/perl/bin`.
* [Python](https://www.python.org/) (version >= 3.4) * [Python](https://www.python.org/) (version >= 3.4)
#### macOS:
* Full Xcode installation (Command Line Tools are untested)
* CMake (version >= 3.6)
* Newer versions of bison and flex, preferably installed via [Homebrew](https://brew.sh)
* [wget](https://www.gnu.org/software/wget/)
* [Python](https://www.python.org/) (version >= 3.4, macOS has 2.7)
### Process ### Process
**Warning: Currently, RetDec has to be installed into a clean, dedicated directory. Do NOT install it into `/usr`, `/usr/local`, etc. because our build system is not yet ready for system-wide installations. So, when running `cmake`, always set `-DCMAKE_INSTALL_PREFIX=<path>` to a directory that will be used just by RetDec. For more details, see [#12](https://github.com/avast-tl/retdec/issues/12).** **Warning: Currently, RetDec has to be installed into a clean, dedicated directory. Do NOT install it into `/usr`, `/usr/local`, etc. because our build system is not yet ready for system-wide installations. So, when running `cmake`, always set `-DCMAKE_INSTALL_PREFIX=<path>` to a directory that will be used just by RetDec. For more details, see [#12](https://github.com/avast-tl/retdec/issues/12).**
@ -129,6 +159,17 @@ sudo dnf install git cmake make gcc gcc-c++ perl python3 bash zlib-devel flex bi
* `msbuild /m /p:Configuration=Release retdec.sln` * `msbuild /m /p:Configuration=Release retdec.sln`
* `msbuild /m /p:Configuration=Release INSTALL.vcxproj` * `msbuild /m /p:Configuration=Release INSTALL.vcxproj`
* Alternatively, you can open `retdec.sln` generated by `cmake` in Visual Studio IDE. * Alternatively, you can open `retdec.sln` generated by `cmake` in Visual Studio IDE.
* macOS:
* `cd retdec`
* `mkdir build && cd build`
* ```sh
# 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"
```
* `cmake .. -DCMAKE_INSTALL_PREFIX=<path>`
* `make && make install`
You have to pass the following parameters to `cmake`: You have to pass the following parameters to `cmake`:
* `-DCMAKE_INSTALL_PREFIX=<path>` to set the installation path to `<path>`. * `-DCMAKE_INSTALL_PREFIX=<path>` to set the installation path to `<path>`.

View File

@ -14,7 +14,9 @@ if(MSVC)
# its properties, second as path to library to link it as a whole. # its properties, second as path to library to link it as a whole.
target_link_libraries(bin2llvmirtool bin2llvmir -WHOLEARCHIVE:$<TARGET_FILE_NAME:bin2llvmir>) target_link_libraries(bin2llvmirtool bin2llvmir -WHOLEARCHIVE:$<TARGET_FILE_NAME:bin2llvmir>)
set_target_properties(bin2llvmirtool PROPERTIES LINK_FLAGS "/FORCE:MULTIPLE") set_target_properties(bin2llvmirtool PROPERTIES LINK_FLAGS "/FORCE:MULTIPLE")
else() # Linux/MSYS2 elseif(APPLE)
target_link_libraries(bin2llvmirtool -Wl,-force_load bin2llvmir)
elseif() # Linux/MSYS2
target_link_libraries(bin2llvmirtool -Wl,--whole-archive bin2llvmir -Wl,--no-whole-archive) target_link_libraries(bin2llvmirtool -Wl,--whole-archive bin2llvmir -Wl,--no-whole-archive)
endif() endif()

View File

@ -13,6 +13,8 @@ if(MSVC)
# state 'llvmir2hll' twice in target_link_libraries(), first as a target to get # state 'llvmir2hll' twice in target_link_libraries(), first as a target to get
# its properties, second as path to library to link it as a whole. # its properties, second as path to library to link it as a whole.
target_link_libraries(llvmir2hlltool llvmir2hll -WHOLEARCHIVE:$<TARGET_FILE_NAME:llvmir2hll>) target_link_libraries(llvmir2hlltool llvmir2hll -WHOLEARCHIVE:$<TARGET_FILE_NAME:llvmir2hll>)
elseif(APPLE)
target_link_libraries(llvmir2hlltool -Wl,-force_load llvmir2hll)
else() # Linux/MSYS2 else() # Linux/MSYS2
target_link_libraries(llvmir2hlltool -Wl,--whole-archive llvmir2hll -Wl,--no-whole-archive) target_link_libraries(llvmir2hlltool -Wl,--whole-archive llvmir2hll -Wl,--no-whole-archive)
endif() endif()