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

macOS installation requirements missing requires brew/ports gnu-sed/gsed package #257

Closed
AshKetch-um opened this issue Mar 29, 2018 · 2 comments

Comments

@AshKetch-um
Copy link
Contributor

AshKetch-um commented Mar 29, 2018

The retdec runtime uses sed with flags that are incompatible with the sed built into MacOS, however the Run on MacOS instructions omit this requirement.

I resolved this by installing the gsed (sudo port install gsed) package and then including the GNU symlink tree (/opt/local/libexec/gnubin) in my path before the built-in directories. A similar solution using brew's gnu-sed package should work as well.

Environment
MacOS 10.13.3
Mac Ports
changeset: 31cf35f

Steps to Reproduce
Download, Build and Install on MacOS

sudo port selfupdate
sudo port install cmake git perl5 python27 bison flex autoconf automake libtool coreutils wget doxygen upx graphviz

# See #98
export PATH=/opt/local/bin:/opt/local/sbin:/opt/local/libexec/gnubin:$PATH

git clone https://github.com/avast-tl/retdec
cd retdec
mkdir build && cd build
cmake .. -DCMAKE_INSTALLPREFIX=/opt/local/retdec
make -j6
sudo make install

Run against a simple test 32-bit Linux ELF binary

cd /opt/local/retdec/bin
bash ./retdec-decompiler.sh /tmp/test

Expected Behavior
Clean run

Running phase: emission of the target code [c] ( 0.03s )
Running phase: finalization ( 0.03s )
Running phase: cleanup ( 0.03s )

##### Done!

Observed Behavior
sed errors

Running phase: emission of the target code [c] ( 0.03s )
Running phase: finalization ( 0.03s )
Running phase: cleanup ( 0.03s )
sed: 1: "/private/tmp/test.c": undefined label 'mp/test.c'
sed: 1: "/private/tmp/test.c": undefined label 'mp/test.c'

##### Done!
user@host:/opt/local/retdec/bin:$ which sed
/usr/bin/sed
@s3rvac s3rvac self-assigned this Mar 30, 2018
s3rvac added a commit that referenced this issue Mar 30, 2018
… to work on macOS (#257).

The original commands failed with the following error on macOS:

    sed: 1: "/private/tmp/test.c": undefined label 'mp/test.c'
    sed: 1: "/private/tmp/test.c": undefined label 'mp/test.c'

The reason why the commands failed is that when using the -i parameter of sed
on macOS, you need to specify an extension of the backup file. If you do not
want to create a backup file, you have to pass the empty string. On Linux,
using just -i without any extension suffices.

The new sed command should work on Linux, macOS, and Windows, without a need to
install gnu-sed on macOS.
@s3rvac
Copy link
Member

s3rvac commented Mar 30, 2018

Thank you for the report. I have fixed this in commit 7b5289a. In short, I have modified our sed commands so that they work even with the version of sed on macOS, so there is no need for installing gsed.

The reason why the commands failed is that when using the -i parameter of sed on macOS, you need to specify an extension of the backup file. If you do not want to create a backup file, you have to pass the empty string. On Linux, using just -i without any extension suffices. Nevertheless, there were also some other issues with the original sed commands, so I rewrote them. Another advantage of the new version is that both sed commands are now part of a single sed command.

@s3rvac s3rvac closed this as completed Mar 30, 2018
@AshKetch-um
Copy link
Contributor Author

Awesome, thank you!

mbandzi pushed a commit that referenced this issue Apr 9, 2018
… to work on macOS (#257).

The original commands failed with the following error on macOS:

    sed: 1: "/private/tmp/test.c": undefined label 'mp/test.c'
    sed: 1: "/private/tmp/test.c": undefined label 'mp/test.c'

The reason why the commands failed is that when using the -i parameter of sed
on macOS, you need to specify an extension of the backup file. If you do not
want to create a backup file, you have to pass the empty string. On Linux,
using just -i without any extension suffices.

The new sed command should work on Linux, macOS, and Windows, without a need to
install gnu-sed on macOS.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants