Skip to content

Fix build for Apple M<x> silicon #145

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

PauloMigAlmeida
Copy link

@PauloMigAlmeida PauloMigAlmeida commented Dec 2, 2024

In order to make it run on Apple M1,2,3 devices I had to upgrade LuaJit to the latest version (2.1) and tweak a few things on the makefile.

I also made LuaJIT to be downloaded during build phase so upgrades to different versions don't result in massive PR due to the lib vendoring (which is hard to evalute)

One can compile it to arm arch by executing

brew install openssl@3 gcc@12
make \
    CC=/opt/homebrew/Cellar/gcc@12/12.4.0/bin/gcc-12 \
    OPENSSL_LIB=/opt/homebrew/Cellar/openssl@3/3.3.2/ \
    clean all

Running wrk

 ./wrk -t2 -c10 -d30s -R200 https://google.com                                                                    
Running 30s test @ https://google.com
  2 threads and 10 connections
  Thread calibration: mean lat.: 4713.042ms, rate sampling interval: 16343ms
  Thread calibration: mean lat.: 4693.897ms, rate sampling interval: 16293ms
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    18.08s     5.19s   27.08s    57.71%
    Req/Sec     9.50      0.50    10.00    100.00%
  593 requests in 30.03s, 491.08KB read
Requests/sec:     19.74
Transfer/sec:     16.35KB

@@ -1,5 +1,6 @@
CFLAGS := -std=c99 -Wall -O2 -D_REENTRANT
LIBS := -lpthread -lm -lcrypto -lssl
OPENSSL_LIB := /usr/local/opt/openssl/
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heads up: Homebrew on M1 Macs stores openssl at /opt/homebrew/opt/openssl

@jion
Copy link

jion commented Apr 15, 2025

What I'm doing wrong? Macbook with an M3

❯ brew install openssl@3 gcc@12
==> Downloading https://formulae.brew.sh/api/formula.jws.json
==> Downloading https://formulae.brew.sh/api/cask.jws.json
Warning: openssl@3 3.4.1 is already installed and up-to-date.
To reinstall 3.4.1, run:
  brew reinstall openssl@3
==> Downloading https://ghcr.io/v2/homebrew/core/gcc/12/manifests/12.4.0
############################################################################################################################################################################ 100.0%
==> Fetching gcc@12
==> Downloading https://ghcr.io/v2/homebrew/core/gcc/12/blobs/sha256:55614581a8985550c5cc84cd29f7122d4aca5d11f60c5ff119e7432419c2b9d8
############################################################################################################################################################################ 100.0%
==> Pouring [email protected]_sonoma.bottle.tar.gz
🍺  /opt/homebrew/Cellar/gcc@12/12.4.0: 1,438 files, 356.7MB
==> Running `brew cleanup gcc@12`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
❯ make \
    CC=/opt/homebrew/Cellar/gcc@12/12.4.0/bin/gcc-12 \
    OPENSSL_LIB=/opt/homebrew/Cellar/openssl@3/3.3.2/ \
    clean all
rm -f wrk obj/*
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C src clean
lj_arch.h:55:2: error: #error "No support for this architecture (yet)"
   55 | #error "No support for this architecture (yet)"
      |  ^~~~~
lj_arch.h:279:2: error: #error "No target architecture defined"
  279 | #error "No target architecture defined"
      |  ^~~~~
lj_arch.h:55:2: error: #error "No support for this architecture (yet)"
   55 | #error "No support for this architecture (yet)"
      |  ^~~~~
lj_arch.h:279:2: error: #error "No target architecture defined"
  279 | #error "No target architecture defined"
      |  ^~~~~
lj_arch.h:55:2: error: #error "No support for this architecture (yet)"
   55 | #error "No support for this architecture (yet)"
      |  ^~~~~
lj_arch.h:279:2: error: #error "No target architecture defined"
  279 | #error "No target architecture defined"
      |  ^~~~~
lj_arch.h:55:2: error: #error "No support for this architecture (yet)"
   55 | #error "No support for this architecture (yet)"
      |  ^~~~~
lj_arch.h:279:2: error: #error "No target architecture defined"
  279 | #error "No target architecture defined"
      |  ^~~~~
lj_arch.h:55:2: error: #error "No support for this architecture (yet)"
   55 | #error "No support for this architecture (yet)"
      |  ^~~~~
lj_arch.h:279:2: error: #error "No target architecture defined"
  279 | #error "No target architecture defined"
      |  ^~~~~
lj_arch.h:55:2: error: #error "No support for this architecture (yet)"
   55 | #error "No support for this architecture (yet)"
      |  ^~~~~
lj_arch.h:279:2: error: #error "No target architecture defined"
  279 | #error "No target architecture defined"
      |  ^~~~~
Makefile:231: *** Unsupported target architecture.  Stop.
make[1]: *** [clean] Error 2
make: *** [clean] Error 2

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

Successfully merging this pull request may close these issues.

3 participants