gigahorse-toolchain icon indicating copy to clipboard operation
gigahorse-toolchain copied to clipboard

Cannot compile on Mac

Open Divide-By-0 opened this issue 2 years ago • 4 comments

Ran

brew install boost
brew install --HEAD souffle-lang/souffle/souffle
git clone --recurse-submodules --remote-submodules https://github.com/nevillegrech/gigahorse-toolchain
cd gigahorse-toolchain
cd souffle-addon
make
cd ..
./gigahorse.py examples/long_running.hex

and get the error

    raise RuntimeError('''
RuntimeError: 
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.
Traceback (most recent call last):
  File "./gigahorse.py", line 550, in <module>
    open(v, 'r') # check program exists
FileNotFoundError: [Errno 2] No such file or directory: '.../gigahorse-toolchain/logic/main.dl_compiled'

Divide-By-0 avatar Apr 11 '22 02:04 Divide-By-0

Unfortunately, our Mac support is really iffy - we are working on improving gigahorse on this front, as it has become a more common problem lately.

In order to help add some support, I revamped the Dockerfile. You could try do the following:

  1. Build the Docker image: docker build -t gigahorse .
  2. Set an alias alias gigahorse=GIGAHORSE_ROOT_ABS_PATH/bin/run_docker
  3. Invoke gigahorse ARGS, for example gigahorse examples/long_running.hex -i

It should work, but please let me know if you encounter any issues. Please note that this is experimental and that the home directory is mounted in the container as it's quite likely that people will want to run some client analyses via gigahorse <HEX> -C <client list>.

You need to be able to run docker without sudo for this to work. See https://docs.docker.com/engine/install/linux-postinstall/ for adding your self into the "docker" group to enable this, or https://docs.docker.com/engine/security/rootless/ to run docker in rootless mode.

iliastsa avatar Apr 12 '22 11:04 iliastsa

Awesome, thanks for the quick action here! I think by default I can do those commands without root. However, I had to edit bin/run_docker to have /bin/bash instead, and then I also need to edit -fm to be -fn, then mkdir cache in addition to the existing .temp. Then, I get this error, which is basically the same thing I was getting before on Mac:

$ gigahorse examples/long_running.hex      
/Users/<username>/Documents/MIT/frontrunner/gigahorse-toolchain
Compiling /opt/gigahorse/gigahorse-toolchain/logic/main.dl to C++ program and executable
Compiling /opt/gigahorse/gigahorse-toolchain/clientlib/function_inliner.dl to C++ program and executable
compiler error: cannot compile source file /opt/gigahorse/gigahorse-toolchain/cache/da6752883df29068047e272158d1b6c0.cpp
g++ -std=c++17   -fwrapv  -DUSE_NCURSES  -O3 -DUSE_LIBZ  -DUSE_SQLITE  -fopenmp  -march=native  -std=c++17 -Wdate-time -D_FORTIFY_SOURCE=2 -o/opt/gigahorse/gigahorse-toolchain/cache/da6752883df29068047e272158d1b6c0 /opt/gigahorse/gigahorse-toolchain/cache/da6752883df29068047e272158d1b6c0.cpp  -ldl -lpthread -lsqlite3 -lz -lncurses -lfunctors  -I/usr/bin/../include -I/usr/bin/include 
/opt/gigahorse/gigahorse-toolchain/souffle-addon/libfunctors.so: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
failed to compile C++ source </opt/gigahorse/gigahorse-toolchain/cache/da6752883df29068047e272158d1b6c0.cpp>
Process Process-2:
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/process.py", line 313, in _bootstrap
    self.run()
  File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/gigahorse/gigahorse-toolchain/gigahorse.py", line 295, in compile_datalog
    assert not(process.returncode), "Compilation failed. Stopping."
AssertionError: Compilation failed. Stopping.
compiler error: cannot compile source file /opt/gigahorse/gigahorse-toolchain/cache/de899845b46df8f5f8a1150ce9d945e6.cpp
g++ -std=c++17   -fwrapv  -DUSE_NCURSES  -O3 -DUSE_LIBZ  -DUSE_SQLITE  -fopenmp  -march=native  -std=c++17 -Wdate-time -D_FORTIFY_SOURCE=2 -o/opt/gigahorse/gigahorse-toolchain/cache/de899845b46df8f5f8a1150ce9d945e6 /opt/gigahorse/gigahorse-toolchain/cache/de899845b46df8f5f8a1150ce9d945e6.cpp  -ldl -lpthread -lsqlite3 -lz -lncurses -lfunctors  -I/usr/bin/../include -I/usr/bin/include 
/opt/gigahorse/gigahorse-toolchain/souffle-addon/libfunctors.so: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
failed to compile C++ source </opt/gigahorse/gigahorse-toolchain/cache/de899845b46df8f5f8a1150ce9d945e6.cpp>
Process Process-1:
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/process.py", line 313, in _bootstrap
    self.run()
  File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/gigahorse/gigahorse-toolchain/gigahorse.py", line 295, in compile_datalog
    assert not(process.returncode), "Compilation failed. Stopping."
AssertionError: Compilation failed. Stopping.
Traceback (most recent call last):
  File "/opt/gigahorse/gigahorse-toolchain/gigahorse.py", line 550, in <module>
    open(v, 'r') # check program exists
FileNotFoundError: [Errno 2] No such file or directory: '/opt/gigahorse/gigahorse-toolchain/logic/main.dl_compiled'

Divide-By-0 avatar Apr 13 '22 23:04 Divide-By-0

We merged PR #35 that should work on M1 Mac - maybe it fixes your issue.

iliastsa avatar Apr 27 '22 09:04 iliastsa

Oh I'm on Intel Mac but I'll give it a shot.

Divide-By-0 avatar Apr 27 '22 12:04 Divide-By-0