crystal-lang-tools / vscode-crystal-lang

Yet another VSCode extension for Crystal Programming Language
https://marketplace.visualstudio.com/items?itemName=crystal-lang-tools.crystal-lang
MIT License
275 stars 57 forks source link

building for macOS-x86_64 but attempting to link with file built for macOS-arm64 #161

Closed ivellapillil closed 1 year ago

ivellapillil commented 1 year ago

Description

I got the latest version of crystal (1.7.1) from brew. I have a Mac M1 laptop. Building my project using the standard terminal works without any issues. However, interestingly, if I build from Visual Studio Code (also using terminal within the VSC), I get

ld: warning: ignoring file /opt/homebrew/lib/libevent.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 Undefined symbols for architecture x86_64: "_main", referenced from: implicit entry/start for main executable ld: symbol(s) not found for architecture x86_64


To Reproduce

  1. Install the latest version of crystal (1.7.1)
  2. Install the latest version of Crystal Language Visual Studio extension (v0.8.4)
  3. Do shards init
  4. Create a hello.cr
  5. Write puts "hello"
  6. Open Terminal within Visual Studio Code
  7. Execute shards build

Expected behavior

The code is compiled successfully.

Current behaviour

ld: warning: ignoring file /opt/homebrew/lib/libevent.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 Undefined symbols for architecture x86_64: "_main", referenced from: implicit entry/start for main executable ld: symbol(s) not found for architecture x86_64

What works

If I compile in Mac's native Terminal, using the crystal compiler, it works without any issue.


Machine: MacOS M1 Laptop Crystal 1.7.1 (2023-01-17)

LLVM: 14.0.6 Default target: aarch64-apple-darwin22.2.0

ivellapillil commented 1 year ago

Found the issue: https://github.com/microsoft/vscode/issues/116763

Basically I had migrated from old laptop to new one using Apple Time Machine. The old VS code was i86 and when typing arch in the Terminal also returned i86. Reinstalling VSCode to Apple Silicon solved the issue. Now it compiles without any error.