Skip to content

Apple Silicon Support #69

Open

Description

hi, I was able to get progcen works on my macbook M1 by doing the following:
Install glfw with homebrew (and make sure the lib path is in DYLD_LIBRARY_PATH)
modify the march=native to mcpu=lightning in the cmake configuration file ...

It is quite an easy fix, so may be good if you want to implement it ...

Activity

  1. christopherhesse commented on Jan 14, 2022

    @christopherhesse
    Collaborator

    I don't have an M1 mac but would accept a PR that improved support for M1. cibuildwheel https://cibuildwheel.readthedocs.io/en/stable/#what-does-it-do says it supports apple silicon, so there's probably some way to make the github actions workflow build a wheel for that platform.

  2. changed the title [-]Not an issue, just a suggestion[/-] [+]Apple Silicon Support[/+] on Jan 15, 2022
  3. heyzude commented on Feb 9, 2022

    @heyzude

    @olmoulin Hi, and thanks for the solution you mentioned!
    However, since I'm novice to mac computer, can you elaborate what is the lib path here and
    let me know where is the cmake configuration file you mentioned?

    Thank you :)

  4. skezle commented on Apr 25, 2022

    @skezle

    Thanks for the answer above!

    I found this worked for me without editing the CMakeLists.txt file.

  5. added a commit that references this issue on Feb 10, 2023
  6. jhsul commented on Mar 14, 2023

    @jhsul

    If mcpu=lightning doesn't work, you can try mcpu=apple-m1. That worked for me. You can check available cpus with the command clang --print-supported-cpus

  7. raymondchua commented on Apr 19, 2023

    @raymondchua

    mcpu=lightning does not work for me too. I tried changing to mcpu=apple-m1. But I got the following errors. Has anyone encountered the same? Is this related to some version issues? I am using python3.8 if it helps.

    building procgen...RUN FAILED ['cmake', '--build', '.', '--config', 'relwithdebinfo']:
    [  3%] Building CXX object CMakeFiles/env.dir/src/assetgen.cpp.o
    [  6%] Building CXX object CMakeFiles/env.dir/src/cpp-utils.cpp.o
    [ 13%] Building CXX object CMakeFiles/env.dir/src/game.cpp.o
    [ 13%] Building CXX object CMakeFiles/env.dir/src/entity.cpp.o
    [ 16%] Building CXX object CMakeFiles/env.dir/src/game-registry.cpp.o
    [ 20%] Building CXX object CMakeFiles/env.dir/src/games/bigfish.cpp.o
    [ 23%] Building CXX object CMakeFiles/env.dir/src/basic-abstract-game.cpp.o
    [ 26%] Building CXX object CMakeFiles/env.dir/src/games/dodgeball.cpp.o
    [ 30%] Building CXX object CMakeFiles/env.dir/src/games/bossfight.cpp.o
    [ 33%] Building CXX object CMakeFiles/env.dir/src/games/caveflyer.cpp.o
    [ 36%] Building CXX object CMakeFiles/env.dir/src/games/climber.cpp.o
    [ 40%] Building CXX object CMakeFiles/env.dir/src/games/coinrun_old.cpp.o
    [ 43%] Building CXX object CMakeFiles/env.dir/src/games/coinrun.cpp.o
    [ 46%] Building CXX object CMakeFiles/env.dir/src/games/fruitbot.cpp.o
    [ 50%] Building CXX object CMakeFiles/env.dir/src/games/heist.cpp.o
    [ 53%] Building CXX object CMakeFiles/env.dir/src/games/jumper.cpp.o
    [ 56%] Building CXX object CMakeFiles/env.dir/src/games/leaper.cpp.o
    [ 60%] Building CXX object CMakeFiles/env.dir/src/games/maze.cpp.o
    [ 63%] Building CXX object CMakeFiles/env.dir/src/games/miner.cpp.o
    [ 66%] Building CXX object CMakeFiles/env.dir/src/games/ninja.cpp.o
    [ 70%] Building CXX object CMakeFiles/env.dir/src/games/chaser.cpp.o
    [ 73%] Building CXX object CMakeFiles/env.dir/src/games/plunder.cpp.o
    [ 76%] Building CXX object CMakeFiles/env.dir/src/games/starpilot.cpp.o
    [ 80%] Building CXX object CMakeFiles/env.dir/src/mazegen.cpp.o
    [ 83%] Building CXX object CMakeFiles/env.dir/src/randgen.cpp.o
    /mydir/procgen/procgen/src/games/chaser.cpp:296:13: error: variable 'num_orbs' set but not used [-Werror,-Wunused-but-set-variable]
            int num_orbs = 0;
                ^
    [ 86%] Building CXX object CMakeFiles/env.dir/src/roomgen.cpp.o
    [ 90%] Building CXX object CMakeFiles/env.dir/src/resources.cpp.o
    [ 93%] Building CXX object CMakeFiles/env.dir/src/vecgame.cpp.o
    1 error generated.
    make[2]: *** [CMakeFiles/env.dir/src/games/chaser.cpp.o] Error 1
    make[2]: *** Waiting for unfinished jobs....
    /mydir/procgen/procgen/src/games/starpilot.cpp:231:18: error: variable 'i' set but not used [-Werror,-Wunused-but-set-variable]
            for (int i = 0; t <= SHOOTER_WIN_TIME; i++) {
                     ^
    1 error generated.
    make[2]: *** [CMakeFiles/env.dir/src/games/starpilot.cpp.o] Error 1
    make[1]: *** [CMakeFiles/env.dir/all] Error 2
    make: *** [all] Error 2
    
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/mydir/procgen/procgen/env.py", line 246, in __init__
        super().__init__(num, env_name, options, **kwargs)
      File "/mydir/procgen/procgen/env.py", line 96, in __init__
        lib_dir = build(debug=debug)
      File "/mydir/procgen/procgen/builder.py", line 138, in build
        check(run(build_cmd), verbose=package)
      File "/mydir/procgen/procgen/builder.py", line 47, in check
        raise RunFailure("failed to build procgen from source")
    procgen.builder.RunFailure: failed to build procgen from source
    
  8. raymondchua commented on Apr 19, 2023

    @raymondchua

    Ok, I manage to fix the errors I had by commenting out the following lines in chaser.cpp:296: // int num_orbs = 0; and chaser.cpp:306: //num_orbs++;

    And by replacing cpp:231:18 in starpilot.cpp with: while (t <= SHOOTER_WIN_TIME) {

  9. falcondai commented on May 3, 2023

    @falcondai

    @raymondchua this seems to be a breaking behavior of c compiler clang from 12 to 13 (my up-to-date M1 Mac's clang is 14) mentioned elsewhere. I bypassed it by adding another flag to CMakeLists.txt. Let me make a quick PR.

  10. added a commit that references this issue on May 3, 2023
  11. raymondchua commented on May 3, 2023

    @raymondchua

    Thanks for following up, @falcondai. My clang version:

    Apple clang version 14.0.3 (clang-1403.0.22.14.1)
    Target: arm64-apple-darwin22.4.0

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions