discord / lilliput

Resize images and animated GIFs in Go

Home Page:https://discord.com/blog/how-discord-resizes-150-million-images-every-day-with-go-and-c

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Apple M1 issues

jjoliveira opened this issue · comments

I'm having some problems with lilliput on my M1 machine.

Running go get github.com/discord/lilliput returns me:

# github.com/discord/lilliput
ld: warning: ignoring file ../../go/pkg/mod/github.com/discord/lilliput@v0.0.0-20210720001558-e1547514bd5f/deps/osx/lib/libswscale.a, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file ../../go/pkg/mod/github.com/discord/lilliput@v0.0.0-20210720001558-e1547514bd5f/deps/osx/lib/libavformat.a, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file ../../go/pkg/mod/github.com/discord/lilliput@v0.0.0-20210720001558-e1547514bd5f/deps/osx/lib/libavfilter.a, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file ../../go/pkg/mod/github.com/discord/lilliput@v0.0.0-20210720001558-e1547514bd5f/deps/osx/lib/libz.a, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file ../../go/pkg/mod/github.com/discord/lilliput@v0.0.0-20210720001558-e1547514bd5f/deps/osx/lib/libbz2.a, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file ../../go/pkg/mod/github.com/discord/lilliput@v0.0.0-20210720001558-e1547514bd5f/deps/osx/lib/libavutil.a, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file ../../go/pkg/mod/github.com/discord/lilliput@v0.0.0-20210720001558-e1547514bd5f/deps/osx/lib/libavcodec.a, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file ../../go/pkg/mod/github.com/discord/lilliput@v0.0.0-20210720001558-e1547514bd5f/deps/osx/lib/libopencv_core.a, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file ../../go/pkg/mod/github.com/discord/lilliput@v0.0.0-20210720001558-e1547514bd5f/deps/osx/lib/libwebp.a, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file ../../go/pkg/mod/github.com/discord/lilliput@v0.0.0-20210720001558-e1547514bd5f/deps/osx/share/OpenCV/3rdparty/lib/libippicv.a, missing required architecture arm64 in file ../../go/pkg/mod/github.com/discord/lilliput@v0.0.0-20210720001558-e1547514bd5f/deps/osx/share/OpenCV/3rdparty/lib/libippicv.a (2 slices)
ld: warning: ignoring file ../../go/pkg/mod/github.com/discord/lilliput@v0.0.0-20210720001558-e1547514bd5f/deps/osx/lib/libpng.a, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file ../../go/pkg/mod/github.com/discord/lilliput@v0.0.0-20210720001558-e1547514bd5f/deps/osx/lib/libjpeg.a, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file ../../go/pkg/mod/github.com/discord/lilliput@v0.0.0-20210720001558-e1547514bd5f/deps/osx/lib/libgif.a, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file ../../go/pkg/mod/github.com/discord/lilliput@v0.0.0-20210720001558-e1547514bd5f/deps/osx/lib/libopencv_imgproc.a, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file ../../go/pkg/mod/github.com/discord/lilliput@v0.0.0-20210720001558-e1547514bd5f/deps/osx/lib/libopencv_imgcodecs.a, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture arm64:
  "_DGifCloseFile", referenced from:
      _giflib_decoder_release in _x006.o
  "_DGifExtensionToGCB", referenced from:
      _giflib_decoder_decode_frame in _x006.o
      _giflib_encoder_encode_frame in _x006.o
  ...
  "_sws_scale", referenced from:
      _avcodec_decoder_decode in _x005.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

My machine go version and arch is as follow:

❯ go version
go version go1.17 darwin/arm64

Is this a known issue? Is there any workaround?

Cheers

I'm working on a fix around this issue, so far I have successfully built it on linux/arm64, which can be used with Docker on Mac without performance degradation. For the Apple M1, it seems more challenge. I'm happy to create a PR after that. But this would potentially increase the cost of all upcoming changes, the maintainers have to update all the libs for linux/drawin * amd64/arm64.

Just link my forked version here for anyone who has interests.

Thank you @kenshin54! It looks like you've got it workin on Apple M1 and opened the PR: #98 . I've tested it and it seems to work for me on my Mac natively (darwin/arm64) and in docker (linux/arm64).