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

Add support for macOS ARM #2435

Closed
johnblommers opened this issue Dec 17, 2020 · 19 comments · Fixed by #2788
Closed

Add support for macOS ARM #2435

johnblommers opened this issue Dec 17, 2020 · 19 comments · Fixed by #2788
Labels
🍏 platform/macOS Pull request or issue on macOS 🐳 help wanted Extra attention is needed

Comments

@johnblommers
Copy link

Describe your feature request

Would like a universal binary able to run natively on the ARM based new M1 Macintosh computers.

What problem does this feature solve? [optional]

Performance is the big benefit for an Apple Silicon native version.

Additional context [optional]

Ideally build a universal binary that contains both Intel and ARM code.

@fxha
Copy link
Contributor

fxha commented Dec 17, 2020

This would be great if anyone would like to contribute but unfortunately, we don't own a M1 device and I don't know whether the used native addons support ARM or what we need to change to get a working build. The ARM package also need testing and we are unable to do so. In addition, we have to set-up a ARM based macOS CI instance to build releases.

List of native addons:

  • @hfelix/electron-spellchecker (owned by us): @hfelix/spellchecker and cld (dependency)
  • fontmanager-redux ("maintained" by us)
  • keyboard-layout
  • keytar
  • vscode-ripgrep (binary file)
  • ced

Ref. #1904

@fxha fxha added 🍏 platform/macOS Pull request or issue on macOS 🛑 blocked This issue or PR is blocked by other issue 🐳 help wanted Extra attention is needed and removed 🛑 blocked This issue or PR is blocked by other issue labels Dec 17, 2020
@fxha fxha changed the title For Macintosh please release a Universal binary Add support for macOS ARM Dec 29, 2020
@fxha fxha pinned this issue Dec 29, 2020
@JackTheFlap
Copy link

I was able to build with a M1 Macbook Air. I did experience an issue with signing with my own developer key.

Error Message:
⨯ Command failed: codesign --sign XXXXXXXXX --force --timestamp --options runtime --entitlements /Users/j/marktext/node_modules/app-builder-lib/templates/entitlements.mac.plist /Users/j/marktext/build/mac-arm64/Mark Text.app/Contents/MacOS/Mark Text
/Users/j/marktext/build/mac-arm64/Mark Text.app/Contents/MacOS/Mark Text: replacing existing signature
/Users/j/marktext/build/mac-arm64/Mark Text.app/Contents/MacOS/Mark Text: code object is not signed at all
In subcomponent: /Users/j/marktext/build/mac-arm64/Mark Text.app/Contents/LICENSE

Other than that issue (which is probably an error on my part...) everything seems to be working fine.
Screenshot 2021-01-12 at 13 52 48
Edit, original comment was removed as I forgot to hide my serial number

@Endogen
Copy link

Endogen commented Jan 14, 2021

I would also love to have an ARM build. @JackTheFlap can you provide info about how to build it on M1?

@JackTheFlap
Copy link

@Endogen

As stated in my earlier comment the signing seems to fail with a standard Apple developer account but Marktext seems to be working fine ignoring this.

@Endogen
Copy link

Endogen commented Jan 15, 2021

@JackTheFlap Oh so no changes needed to the default build instructions and you get an ARM build? Great. Can you maybe check that it's really not running on Rosetta? Open the process overview and on the CPU tab you should see a column that displays the architecture. Make sure that the marktext process doesn't have the value "Intel" there.

Sorry if this is unnecessary because it's maybe obvious that it's running natively

@JackTheFlap
Copy link

@Endogen I used Silicon Info in the screenshot to show it was running natively but here's one from Activity Monitor I just took.
Screenshot 2021-01-15 at 17 12 42

@karkraeg
Copy link

karkraeg commented Apr 5, 2021

Building works fine and improves the speed to a great degree. Couldn't anyone who built this upload the DMG for others? Or would this be problematic because of the missing codesign? Otherwise I‘d be happy to share the M1 dmg.

@Ivan-Malinovski
Copy link

I just built it too, and I can confirm that it's heaps faster. At least at starting up. I haven't tried it a lot, but it does seem to work just fine.

@Endogen
Copy link

Endogen commented Aug 31, 2021

I'd love to have an official M1 version

@Donkey-Doug
Copy link

Why does the ARM build have to be specific for the Apple M1? Other ARM laptops/devices exist.

@johnblommers
Copy link
Author

An ARM build for the Apple M1 has to interface with macOS APIs. An ARM build for Linux has to interface with Linux APIs. An ARM build for Windows has to interface with Windows APIs.
Cross-platform applications that run on Linux, macOS and Windows often use the Electron framework because it provides exactly the necessary APIs for both Intel and AMD processors.

@freepicheep
Copy link

@JackTheFlap I followed the instructions that you gave and get these errors. Do you have any advice? I'm running on a 2021 M1 Pro.

friedrichstoltzfus@Friedrichs-MacBook-Pro marktext % yarn install    
yarn install v1.22.17
$ node .electron-vue/preinstall.js
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
warning " > eslint-plugin-vue@6.2.2" has incorrect peer dependency "eslint@^5.0.0 || ^6.0.0".
[4/4] 🔨  Building fresh packages...
[-/16] ⠂ waiting...
[2/16] ⠂ cld
[12/16] ⠂ lzma-native
[-/16] ⠂ waiting...
error /Users/friedrichstoltzfus/Code/marktext/node_modules/cld: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments: 
Directory: /Users/friedrichstoltzfus/Code/marktext/node_modules/cld
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@8.2.0
gyp info using node@17.0.1 | darwin | arm64
gyp info find Python using Python version 3.9.7 found at "/opt/homebrew/opt/python@3.9/bin/python3.9"
gyp info spawn /opt/homebrew/opt/python@3.9/bin/python3.9
gyp info spawn args [
gyp info spawn args   '/opt/homebrew/Cellar/node/17.0.1/libexec/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/friedrichstoltzfus/Code/marktext/node_modules/cld/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/opt/homebrew/Cellar/node/17.0.1/libexec/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/friedrichstoltzfus/Library/Caches/node-gyp/17.0.1/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/friedrichstoltzfus/Library/Caches/node-gyp/17.0.1',
gyp info spawn args   '-Dnode_gyp_dir=/opt/homebrew/Cellar/node/17.0.1/libexec/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/friedrichstoltzfus/Library/Caches/node-gyp/17.0.1/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/friedrichstoltzfus/Code/marktext/node_modules/cld',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cldutil.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cldutil_shared.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/compact_lang_det.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/compact_lang_det_hint_code.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/compact_lang_det_impl.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/debug.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/fixunicodevalue.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/generated_entities.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/generated_language.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/generated_ulscript.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/getonescriptspan.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/lang_script.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/offsetmap.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/scoreonescriptspan.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/tote.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/utf8statetable.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cld_generated_cjk_uni_prop_80.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cld2_generated_cjk_compatible.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cld_generated_cjk_delta_bi_32.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/generated_distinct_bi_0.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cld2_generated_quad0122.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cld2_generated_deltaocta0122.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cld2_generated_deltaoctachrome.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cld2_generated_distinctocta0122.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cld2_generated_distinctoctachrome.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cld2_generated_quadchrome_16.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cld2_generated_quadchrome_2.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cld_generated_score_quad_octa_0122.o
  CXX(target) Release/obj.target/cld-c/deps/cld/internal/cld_generated_score_quad_octa_2.o
  LIBTOOL-STATIC Release/cld-c.a
  CXX(target) Release/obj.target/cld/src/constants.o
  CXX(target) Release/obj.target/cld/src/cld.o
../src/cld.cc:9:12: error: no member named 'unexpected_handler' in namespace 'std'
using std::unexpected_handler;
      ~~~~~^
1 error generated.
make: *** [Release/obj.target/cld/src/cld.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/opt/homebrew/Cellar/node/17.0.1/libexec/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Darwin 21.1.0
gyp ERR! command "/opt/homebrew/Cellar/node/17.0.1/bin/node" "/opt/homebrew/Cellar/node/17.0.1/libexec/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/friedrichstoltzfus/Code/marktext/node_modules/cld

@wrenger
Copy link

wrenger commented Nov 4, 2021

The std::unexpected_handler was deprecated and removed in newer C++ version. This is probably a problem of the cld dependency. They either have to explicitly use an older C++ version or remove that line.

PS: Just reported this: dachev/node-cld#66

@freepicheep
Copy link

Thanks, that is really helpful, @wrenger. I tried several things, including removing using std::unexpected_handler; from "cld/src/cld.cc" in my local marktext repository, but I still get errors. I'll just have to wait until someone else can fix it.

@freepicheep
Copy link

After dachev/node-cld was updated to remove using std::unexpected_handler;, I was able to build marktext on my 2021 M1 Pro. First I had to update

cld "^2.7.0"
to cld "^2.7.1" and
version "2.7.0"
to cld "^2.7.1". That fixed the unexpected_handler problem. I next got an error saying name 'openssl_fips' is not defined while evaluating condition 'openssl_fips != ""' in binding.gyp while trying to load binding.gyp. After looking at nodejs/node-gyp#652 and nodejs/node-gyp#2543 I figured out that I had to downgrade node to 16.13.0 and that fixed the problem.

@francesco-plt
Copy link

After dachev/node-cld was updated to remove using std::unexpected_handler;, I was able to build marktext on my 2021 M1 Pro. First I had to update

cld "^2.7.0"

to cld "^2.7.1" and

version "2.7.0"

to cld "^2.7.1". That fixed the unexpected_handler problem. I next got an error saying name 'openssl_fips' is not defined while evaluating condition 'openssl_fips != ""' in binding.gyp while trying to load binding.gyp. After looking at nodejs/node-gyp#652 and nodejs/node-gyp#2543 I figured out that I had to downgrade node to 16.13.0 and that fixed the problem.

I'm in your exact situation, but I'm a bit of a newbie with node. Can you explain more precisely how should I downgrade node? I have already node version 16.13.0 installed and available, but I have no clue on how to use it, since the building process is done via yarn which uses the default (higher) node version installed on my system.

@ecnelises
Copy link

I'm in your exact situation, but I'm a bit of a newbie with node. Can you explain more precisely how should I downgrade node? I have already node version 16.13.0 installed and available, but I have no clue on how to use it, since the building process is done via yarn which uses the default (higher) node version installed on my system.

You can type node -v in your terminal to see current node version. If that's v16, yarn should also be using that version. Otherwise try to add path of node v16 in your PATH variable, or brew link --overwrite node@16 if you're using homebrew to install node, or use global to switch node version if you're using nodeenv/nodenv/ndenv.

@ecnelises
Copy link

ecnelises commented Nov 30, 2021

Hi, I built an arm64 package, and I modified the icon to adopt Big Sur's preferred icon style. You can download here.

new icon

@Jocs Jocs unpinned this issue Dec 26, 2021
@fxha
Copy link
Contributor

fxha commented Feb 22, 2022

We decided to not release an Apple M1 (arm64) package for version 0.17.0 because the package is block by macOS without code signing. We'll consider this issues in future releases but we don't want to confuse users with "broken binaries". You can still install the x64 binary or build MarkText for arm64 on macOS and install it yourself bypassing security mechanism. You may want to subscribe #2983 for further updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍏 platform/macOS Pull request or issue on macOS 🐳 help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.