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

error: unknown FP unit 'sse' (on MacBook M1) #457

Closed
kewp opened this issue May 31, 2021 · 19 comments
Closed

error: unknown FP unit 'sse' (on MacBook M1) #457

kewp opened this issue May 31, 2021 · 19 comments

Comments

@kewp
Copy link

kewp commented May 31, 2021

Tried building this on my MacBook Air M1. Assuming this doesn't work for that processor?

karl@Karls-Air hashlink % make
cc -Wall -O3 -I src -msse2 -mfpmath=sse -std=c11 -I include -I include/pcre -I include/mikktspace -I include/minimp3 -D LIBHL_EXPORTS -m64 -I /usr/local/include -I /usr/local/opt/libjpeg-turbo/include -I /usr/local/opt/jpeg-turbo/include -I /usr/local/opt/sdl2/include/SDL2 -I /usr/local/opt/libvorbis/include -I /usr/local/opt/openal-soft/include -Dopenal_soft  -DGL_SILENCE_DEPRECATION -o include/pcre/pcre_chartables.o -c include/pcre/pcre_chartables.c
clang: warning: argument unused during compilation: '-msse2' [-Wunused-command-line-argument]
error: unknown FP unit 'sse'
make: *** [include/pcre/pcre_chartables.o] Error 1
@ncannasse
Copy link
Member

Hashlink JIT is only x86 / x86_64, we don't support ARM atm. Try compiling using emulation mode (not sure how to do that on OSX).

@kewp
Copy link
Author

kewp commented May 31, 2021

Ok will do. Thanks for the reply

@shakesoda
Copy link
Contributor

note that while the jit doesn't work, hl/c works fine on arm (my game is running perfectly well with this on my m1 mac mini). i think i had to dummy out some mdbg stuff but that's about all.

@tgienger
Copy link

tgienger commented Dec 4, 2021

@kewp Did you have any luck getting hashlink to run on m1 or is it a lost cause for now? I'm curious if I have to fire up my old laptop to build a game or not :P

@kewp
Copy link
Author

kewp commented Dec 4, 2021

Hi @tgienger i can't remember. I did experiment with Rosetta but not sure how that went. I'll try again when I can and will let you know

@shakesoda
Copy link
Contributor

if you run arch -x86_64 zsh before building to spawn a rosetta shell it should work fine

@tgienger
Copy link

tgienger commented Dec 6, 2021

now it has the 'png.h' file not found error. libpng is in the brewfile and it did install so I'm kind of stuck again it seems. Thanks for that though, make did at least start :)

@tgienger
Copy link

tgienger commented Dec 6, 2021

I changed the Makefile's mac specific sections to:
CFLAGS += -m$(MARCH) -I /usr/local/include -I /opt/homebrew/Cellar/jpeg-turbo/2.1.2/include -I /opt/homebrew/Cellar/libpng/1.6.37/include -I /opt/homebrew/Cellar/sdl2/2.0.18/include -I /opt/homebrew/Cellar/libogg/1.3.5/include -I /opt/homebrew/Cellar/libvorbis/1.3.7/include -I /opt/homebrew/Cellar/openal-soft/1.21.1/include -Dopenal_soft -DGL_SILENCE_DEPRECATION

and
LIBFLAGS += -L/opt/homebrew/Cellar/jpeg-turbo/2.1.2/lib -L/usr/local/lib -L/opt/homebrew/Cellar/libpng/1.6.37/lib -L/opt/homebrew/Cellar/libogg/1.3.5/lib -L/opt/homebrew/Cellar/libvorbis/1.3.7/lib -L/opt/homebrew/Cellar/openal-soft/1.21.1/lib

Now the current issue I'm getting is:

Undefined symbols for architecture x86_64:
"_ov_clear", referenced from:
_ogg_finalize in fmt.o
"_ov_info", referenced from:
_fmt_ogg_info in fmt.o
"_ov_open_callbacks", referenced from:
_fmt_ogg_open in fmt.o
"_ov_pcm_seek", referenced from:
_fmt_ogg_seek in fmt.o
"_ov_pcm_tell", referenced from:
_fmt_ogg_tell in fmt.o
"_ov_pcm_total", referenced from:
_fmt_ogg_info in fmt.o
"_ov_read", referenced from:
_fmt_ogg_read in fmt.o
"_png_image_begin_read_from_memory", referenced from:
_fmt_png_decode in fmt.o
"_png_image_finish_read", referenced from:
_fmt_png_decode in fmt.o
"_png_image_free", referenced from:
_fmt_png_decode in fmt.o
"_tjDecompress2", referenced from:
_fmt_jpg_decode in fmt.o
"_tjDestroy", referenced from:
_fmt_jpg_decode in fmt.o
"_tjInitDecompress", referenced from:
_fmt_jpg_decode in fmt.o
ld: symbol(s) not found for architecture x86_64

@tgienger
Copy link

tgienger commented Dec 6, 2021

I'm new to this, but assume it's because the libraries are compiled for Arm. :(
I'll try getting the x86 versions and try again tomorrow.

@kewp
Copy link
Author

kewp commented Dec 6, 2021

I tried @shakesoda's suggestion (I ran arch -x86_64 zsh in the console and then ran make from hashlink) and it did then start to work - it actually got passed several files - but then it died with lots of these conflicting type errors:

src/std/thread.c:111:19: error: conflicting types for 'hl_mutex_alloc'
HL_PRIM hl_mutex *hl_mutex_alloc( bool gc_thread ) {
                  ^
src/hl.h:689:18: note: previous declaration is here
HL_API hl_mutex *hl_mutex_alloc( bool gc_thread );

@tgienger
Copy link

tgienger commented Dec 6, 2021

That is with x86_64 libraries?

@kewp
Copy link
Author

kewp commented Dec 6, 2021

Not sure what you mean? I didn't specify different libraries, I just ran make from the hashlink directory...

@tgienger
Copy link

tgienger commented Dec 6, 2021

When you install the plugins through the Brewfile, it will install arm64 plugins by default. That's what I did. Then when I finally got to make file figured out, I ran into an issue where it was trying to build for x86 from an arm64 plugin. And that's where I left off. I haven't had time to mess with it since.

@kewp
Copy link
Author

kewp commented Dec 6, 2021

Yes when I try to run brew bundle I get a bunch of errors:

Upgrading cmake
Error: Cannot install under Rosetta 2 in ARM default prefix (/opt/homebrew)!
To rerun under ARM use:
    arch -arm64 brew install ...
To install under x86_64, install Homebrew into /usr/local.
Upgrading cmake has failed!
Upgrading jpeg-turbo
Error: Cannot install under Rosetta 2 in ARM default prefix (/opt/homebrew)!
To rerun under ARM use:
    arch -arm64 brew install ...
To install under x86_64, install Homebrew into /usr/local.
Upgrading jpeg-turbo has failed!

@orderrrr
Copy link

Hi Guys
Also trying to build hl with M1

Did a brew bundle with the arm homebrew.
Then entered rosetta and ran make.

getting the same issue as a bit above:

libs/fmt/fmt.c:2:10: fatal error: 'png.h' file not found
#include <png.h>

However have confirmed this is installed with brew install libpng

Going to try installing homebrew again under rosetta and see how that goes. ( not exactly ideal )

Is arm support planned?

@profelis
Copy link

profelis commented Feb 5, 2022

Hi! Next steps should help

  1. install homebrew for x64 apps in /usr/local/homebrew
    manual https://medium.com/mkdir-awesome/how-to-install-x86-64-homebrew-packages-on-apple-m1-macbook-54ba295230f
  2. setup aliases
CPU=$(uname -p)
if [[ "$CPU" == "arm" ]]; then
    export PATH="/opt/homebrew/bin:$PATH"
    alias brew=/opt/homebrew/bin/brew
else
    export PATH="/usr/local/bin:$PATH"
    alias brew=/usr/local/homebrew/bin/brew
fi
  1. switch arch to x64 > arch -x86_64 zsh
  • check brew installation/setup, brew executable should be found in /usr/local/homebrew/bin folder (redo first two steps if not)
> type brew
brew is an alias for /usr/local/homebrew/bin/brew
  1. update Makefile
  • replace all path /usr/local/opt to /usr/local/homebrew/opt
    > sed "s/\/usr\/local\/opt/\/usr\/local\/homebrew\/opt/g" Makefile > Makefile.m1 && cat Makefile.m1 > Makefile
  • and add some missing include/libs paths (see Makefile from gist)
  1. steps from README.md (brew bundle...)

same manual with updated Makefile https://gist.github.com/profelis/9bd8851237d3da4b00a42b3e8a4f07c2

@FlorianB-playdigious
Copy link

Late to the party but adding something :
the solution from @profelis above works like a charm provided you have the same setup. For some reason, running make kept spawning errors about missing headers and/or libs (libpng, then libogg, etc...). It might be specific to my machine and environment (more on that later). Nonetheless, I think I found a small addition that can prove useful. I fixed the issue on my end with two different solutions (which can be combined if you want).

  1. Explicitly list the path to every single dependency include and lib directories. The modified makefile provided by profelis is rather "old" compared to the current state of hashlink, which skip a lot of those include and libs for the linker. Pushing things even further compared to profelis' version and being extra explicit so the compiler and linker cannot be mistaken is always helpful (but harder to maintain).

  2. Add -I /usr/local/homebrew/include to CFLAGS as well as -L/usr/local/homebrew/lib to LFLAGS. It complements the lib and include directories found in /usr/local and provide necessary files for libs installed with the x86_64 version of Homebrew.

The reason I had to do this on my machine is because I started clean, wiping out the old homebrew instance. Starting fresh with the M1 version installed in /opt/homebrew, I eventually had to reinstall the X86_64 version following @profelis advice and provided manual. Worked like a charm BUT the configuration of this instance is wrong. Running brew doctor will show warnings regarding Homebrew's prefix and Cellar location. Same warning can be observed when installing formulae. Funnily, the warning is also shown on the screenshots in the manual.

Running brew config on my end shows this :

HOMEBREW_VERSION: 3.6.2-26-g4441452
ORIGIN: https://github.com/Homebrew/brew
HEAD: 4441452f4e7a7efdd5ae8cc98466d8cf6fa410ab
Last commit: 4 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: c75ac607ce6a019d41287e3734ed6654d4acad3d
Core tap last commit: 3 hours ago
Core tap branch: master
HOMEBREW_PREFIX: /usr/local/homebrew
HOMEBREW_REPOSITORY: /usr/local/homebrew
HOMEBREW_CELLAR: /usr/local/homebrew/Cellar
HOMEBREW_CASK_OPTS: []
HOMEBREW_FORCE_BREWED_CURL: set
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.8 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit westmere
Clang: 14.0.0 build 1400
Git: 2.37.0 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.85.0 => /usr/local/homebrew/opt/curl/bin/curl
macOS: 12.6-x86_64
CLT: 14.0.0.0.1.1661618636
Xcode: 14.0
Rosetta 2: true

As you can see, the HOMEBREW_PREFIX and HOMEBREW_CELLAR do not point to /usr/local but /usr/local/homebrew. I don't know why, might be due to the way it has been installed ? In any case, it means that any formula or cask installed will not be installed in /usr/local, meaning /usr/local/include and /usr/local/lib will not contain the necessary files.

Hope it may help someone wondering what sorcery is happening with homebrew on M1 + hashlink.

@profelis
Copy link

As you can see, the HOMEBREW_PREFIX and HOMEBREW_CELLAR do not point to /usr/local but /usr/local/homebrew. I don't know why,

@FlorianB-playdigious this is correct behaviour, in result you have 2 versions of homebrew setups. One (arm64 version) installed in /opt/homebrew, and (rosetta/x64 version) in /usr/local/homebrew. And hashlink should be compiled using x86 version.
Take a look at last line in your brew config Rosetta 2: true

Currently on my macbook

> brew config | grep HOMEBREW_PREFIX
HOMEBREW_PREFIX: /opt/homebrew      // <-- arm64 home
> arch -x86_64 zsh
> brew config | grep HOMEBREW_PREFIX
HOMEBREW_PREFIX: /usr/local/homebrew      // <-- rosetta/x64 home

hashlink correct compiles only with rosetta setup, always switch to x64 brew version (> arch -x86_64 zsh) before (3rd step from my instruction)

@FlorianB-playdigious
Copy link

FlorianB-playdigious commented Sep 26, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants