nmwsharp / gc-polyscope-project-template

A template project to get started with geometry-central and Polyscope.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Apple M1 Pro unknown target CPU compile error and GLFW runtime error

trastopchin opened this issue · comments

I've previously successfully built and run this project on a 2017 MacBook Pro with an Intel Core i5. However, I'm running into issues both building and running this project on a 2022 MacBook Pro with an Apple M1 Pro.

The first issue I ran into was that when building the project by running the make command, I got the compile error:

[  1%] Building CXX object deps/polyscope/deps/stb/CMakeFiles/stb.dir/stb_impl.cpp.o
error: unknown target CPU 'vortex'
note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, rocketlake, icelake-server, tigerlake, sapphirerapids, alderlake, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, znver3, x86-64, x86-64-v2, x86-64-v3, x86-64-v4

I suspected the problem had something to do with the build configuration, so I updated the command line tools so that clang -v yields

Apple clang version 13.1.6 (clang-1316.0.21.2.5)
Target: arm64-apple-darwin21.6.0

However, that did not solve the problem. I cannot recreate the exact build output, but before I updated the compiler it had made some message about the -march=native flag being passed on like 39 of the CMakeLists.txt configuration file:

SET(CMAKE_CXX_FLAGS_RELEASE        "-O3 -march=native -DNDEBUG")

Removing the -march=native option finally allowed the project to build.

However, running the project with any input mesh yields a GLFW error:

./bin/gc_project ./cube_frame.obj
GLFW emitted error: Cocoa: Failed to find service port for display
[polyscope] Backend: openGL3_glfw -- Loaded openGL version: 4.1 Metal - 76.3

After GLFW emits this error, the actual project template program works perfectly fine. However, I use this project template as a template for a project that uses more of the Geometry Central and Polyscope features and the program has the exact same GLFW error and acts sporadically. So I thought this error message might lead to other issues down the line.

My best guess is that all of these issues are directly related to the Apple M1 Pro chip's different ARM instruction set; but that might not be the case. Would it be best to specify the build target as if it were an Intel processor and let Apple's Rosetta 2 translate for the Apple Silicon chip?