diff --git a/.github/workflows/push-check-arm.yml b/.github/workflows/push-check-arm.yml index aab33ab79..cbb8f6f32 100644 --- a/.github/workflows/push-check-arm.yml +++ b/.github/workflows/push-check-arm.yml @@ -7,7 +7,7 @@ jobs: strategy: matrix: go-version: [1.15.x, 1.19.x] - os: [arm, macos-latest] + os: [arm] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 @@ -25,4 +25,6 @@ jobs: ${{ runner.os }}-go- - name: Compatibility Test - run: go test -v -gcflags=-d=checkptr=0 . + run: | + GOARCH=amd64 go test -gcflags=-d=checkptr=0 -c . + qemu-x86_64 -cpu max ./sonic.test -test.v diff --git a/README.md b/README.md index 21a793835..05604e22e 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ A blazingly fast JSON serializing & deserializing library, accelerated by JI ## Requirement - Go 1.15/1.16/1.17/1.18/1.19 - Linux/MacOS/Windows -- Amd64 CPU with AVX instruction set +- Amd64 ARCH ## Features - Runtime object binding without code generation @@ -261,7 +261,12 @@ println(string(buf) == string(exp)) // true - modification: `Set()`, `SetByIndex()`, `Add()` ## Compatibility -Sonic **DOSE NOT** ensure to support all environments, due to the difficulty of developing high-performance codes. For developers who use sonic to build their applications in different environments (ex: developing on M1 Mac but running on Linux server), or those who want to handle JSON strictly consistent with `encoding/json`, we provide some compatible APIs as `sonic.API` +Sonic **DOSE NOT** ensure to support all environments, due to the difficulty of developing high-performance codes. For developers who use sonic to build their applications in different environments, we have the following suggestions: + +- Developing on **Mac M1**: Make sure you have Rosetta 2 installed on your machine, and set `GOARCH=amd64` when building your application. Rosetta 2 can automatically translate x86 binaries to arm64 binaries and run x86 applications on Mac M1. +- Developing on **Linux arm64**: You can install qemu and use the `qemu-x86_64 -cpu max` command to convert x86 binaries to amr64 binaries for applications built with sonic. The qemu can achieve similar transfer effect to Rosetta 2 on Mac M1. + +For developers who want to use sonic on Linux arm64 without qemu, or those who want to handle JSON strictly consistent with `encoding/json`, we provide some compatible APIs as `sonic.API` - `ConfigDefault`: the sonic's default config (`EscapeHTML=false`,`SortKeys=false`...) to run on sonic-supporting environment. It will fall back to `encoding/json` with the corresponding config, and some options like `SortKeys=false` will be invalid. - `ConfigStd`: the std-compatible config (`EscapeHTML=true`,`SortKeys=true`...) to run on sonic-supporting environment. It will fall back to `encoding/json`. - `ConfigFastest`: the fastest config (`NoQuoteTextMarshaler=true`) to run on sonic-supporting environment. It will fall back to `encoding/json` with corresponding config, and some options will be invalid. @@ -325,4 +330,4 @@ Why? Because `ast.Node` stores its children using `array`: **CAUTION:** `ast.Node` **DOESN'T** ensure concurrent security directly, due to its **lazy-load** design. However, your can call `Node.Load()`/`Node.LoadAll()` to achieve that, which may bring performance reduction while it still works faster than converting to `map` or `interface{}` ## Community -Sonic is a subproject of [CloudWeGo](https://www.cloudwego.io/). We are committed to building a cloud native ecosystem. \ No newline at end of file +Sonic is a subproject of [CloudWeGo](https://www.cloudwego.io/). We are committed to building a cloud native ecosystem. diff --git a/compat.go b/compat.go index 4e9f79ca0..700ee4787 100644 --- a/compat.go +++ b/compat.go @@ -1,4 +1,4 @@ -// +build !amd64 +// +build !amd64,!darwin /* * Copyright 2021 ByteDance Inc.