Skip to content

Commit

Permalink
Build auto configures features
Browse files Browse the repository at this point in the history
  • Loading branch information
ijl committed Nov 12, 2024
1 parent 56fbd97 commit 5243edd
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 109 deletions.
44 changes: 15 additions & 29 deletions .github/workflows/artifact.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: push
env:
CARGO_UNSTABLE_SPARSE_REGISTRY: "true"
PIP_DISABLE_PIP_VERSION_CHECK: "1"
RUST_TOOLCHAIN: "nightly-2024-09-25"
RUST_TOOLCHAIN: "nightly-2024-11-12"
UNSAFE_PYO3_BUILD_FREE_THREADED: "1"
UNSAFE_PYO3_SKIP_VERSION_CHECK: "1"
UV_LINK_MODE: "copy"
Expand Down Expand Up @@ -77,25 +77,23 @@ jobs:
{
cc: "clang",
cflags: "-Os -fstrict-aliasing -fno-plt -flto=full -emit-llvm",
features: "avx512,no-panic,unstable-simd,yyjson",
ldflags: "-fuse-ld=lld -Wl,-plugin-opt=also-emit-llvm -Wl,--as-needed -Wl,-zrelro,-znow",
rustflags: "-C linker=clang -C link-arg=-fuse-ld=lld -C linker-plugin-lto -C lto=fat -C link-arg=-Wl,-zrelro,-znow -Z mir-opt-level=4 -Z threads=4 -D warnings",
tag: null,
target: "x86_64-unknown-linux-gnu",
},
]
env:
PYTHON: "${{ matrix.python.interpreter }}"
PYTHON_PACKAGE: "${{ matrix.python.package }}"
TARGET: "${{ matrix.arch.target }}"
CARGO_TARGET_DIR: "/tmp/orjson"
CC: "${{ matrix.arch.cc }}"
VENV: ".venv"
FEATURES: "${{ matrix.arch.features }}"
CFLAGS: "${{ matrix.arch.cflags }}"
COMPATIBILITY: "${{ matrix.python.compatibility }}"
LDFLAGS: "${{ matrix.arch.ldflags }}"
PYTHON: "${{ matrix.python.interpreter }}"
PYTHON_PACKAGE: "${{ matrix.python.package }}"
RUSTFLAGS: "${{ matrix.arch.rustflags }}"
CARGO_TARGET_DIR: "/tmp/orjson"
COMPATIBILITY: "${{ matrix.python.compatibility }}"
TARGET: "${{ matrix.arch.target }}"
VENV: ".venv"
steps:

- name: cpuinfo
Expand Down Expand Up @@ -130,7 +128,6 @@ jobs:
source "${VENV}/bin/activate"
maturin build --release --strip \
--features="${FEATURES}" \
--compatibility="${COMPATIBILITY}" \
--interpreter="${PYTHON}" \
--target="${TARGET}"
Expand Down Expand Up @@ -167,25 +164,23 @@ jobs:
{
cc: "clang",
cflags: "-Os -fstrict-aliasing -fno-plt -flto=full -emit-llvm",
features: "no-panic,unstable-simd,yyjson",
ldflags: "-fuse-ld=lld -Wl,-plugin-opt=also-emit-llvm -Wl,--as-needed -Wl,-zrelro,-znow",
rustflags: "-C linker=clang -C link-arg=-fuse-ld=lld -C linker-plugin-lto -C lto=fat -C link-arg=-Wl,-zrelro,-znow -Z mir-opt-level=4 -Z threads=4 -D warnings",
tag: "aarch64",
target: "aarch64-unknown-linux-gnu",
},
]
env:
PYTHON: "${{ matrix.python.interpreter }}"
PYTHON_PACKAGE: "${{ matrix.python.package }}"
TARGET: "${{ matrix.arch.target }}"
CARGO_TARGET_DIR: "/tmp/orjson"
CC: "${{ matrix.arch.cc }}"
VENV: ".venv"
FEATURES: "${{ matrix.arch.features }}"
CFLAGS: "${{ matrix.arch.cflags }}"
COMPATIBILITY: "${{ matrix.python.compatibility }}"
LDFLAGS: "${{ matrix.arch.ldflags }}"
PYTHON: "${{ matrix.python.interpreter }}"
PYTHON_PACKAGE: "${{ matrix.python.package }}"
RUSTFLAGS: "${{ matrix.arch.rustflags }}"
CARGO_TARGET_DIR: "/tmp/orjson"
COMPATIBILITY: "${{ matrix.python.compatibility }}"
TARGET: "${{ matrix.arch.target }}"
VENV: ".venv"
steps:

- name: cpuinfo
Expand Down Expand Up @@ -219,7 +214,6 @@ jobs:
source "${VENV}/bin/activate"
maturin build --release --strip \
--features="${FEATURES}" \
--compatibility="${COMPATIBILITY}" \
--interpreter="${PYTHON}" \
--target="${TARGET}"
Expand Down Expand Up @@ -256,11 +250,9 @@ jobs:
- target: aarch64-unknown-linux-musl
arch: aarch64
platform: linux/arm64
features: no-panic,unstable-simd,unwind,yyjson
- target: x86_64-unknown-linux-musl
arch: x86_64
platform: linux/amd64
features: avx512,no-panic,unstable-simd,unwind,yyjson
steps:
- uses: actions/checkout@v4

Expand All @@ -281,7 +273,7 @@ jobs:
rustup-components: rust-src
target: "${{ matrix.platform.target }}"
manylinux: musllinux_1_2
args: --release --strip --out=dist --features=${{ matrix.platform.features }} -i python${{ matrix.python.version }}
args: --release --strip --out=dist -i python${{ matrix.python.version }}

- name: QEMU
if: matrix.platform.arch != 'x86_64'
Expand Down Expand Up @@ -331,28 +323,24 @@ jobs:
{
arch: 'aarch64',
cflags: '-Os -flto=full -fstrict-aliasing',
features: 'no-panic,unstable-simd,yyjson',
rustflags: '-Z mir-opt-level=4 -C lto=fat -D warnings',
target: 'aarch64-unknown-linux-gnu',
},
{
arch: 'armv7',
cflags: '-Os -flto=full -fstrict-aliasing',
features: 'no-panic,yyjson', # no SIMD
rustflags: '-Z mir-opt-level=4 -C lto=fat -D warnings -C opt-level=s',
target: 'armv7-unknown-linux-gnueabihf',
},
{
arch: 'ppc64le',
cflags: '-Os -flto=full -fstrict-aliasing',
features: 'no-panic,unstable-simd,yyjson',
rustflags: '-Z mir-opt-level=4 -C lto=fat -D warnings',
target: 'powerpc64le-unknown-linux-gnu',
},
{
arch: 's390x',
cflags: '-Os -flto=full -fstrict-aliasing -march=z10',
features: 'no-panic,yyjson',
rustflags: '-Z mir-opt-level=4 -C lto=fat -D warnings -C target-cpu=z10',
target: 's390x-unknown-linux-gnu',
},
Expand All @@ -377,7 +365,7 @@ jobs:
rust-toolchain: "${{ env.RUST_TOOLCHAIN }}"
rustup-components: rust-src
manylinux: auto
args: --release --strip --out=dist --features=${{ matrix.target.features }} -i python${{ matrix.python.version }}
args: --release --strip --out=dist -i python${{ matrix.python.version }}

- name: Store wheels
if: "startsWith(github.ref, 'refs/tags/')"
Expand Down Expand Up @@ -439,7 +427,6 @@ jobs:
MACOSX_DEPLOYMENT_TARGET="${{ matrix.python.macosx_target }}" \
PYO3_CROSS_LIB_DIR=$(python -c "import sysconfig;print(sysconfig.get_config_var('LIBDIR'))") \
maturin build --release --strip \
--features=no-panic,unstable-simd,yyjson \
--interpreter python${{ matrix.python.version }} \
--target=universal2-apple-darwin
uv pip install target/wheels/orjson*.whl
Expand Down Expand Up @@ -509,7 +496,6 @@ jobs:
MACOSX_DEPLOYMENT_TARGET="${{ matrix.python.macosx_target }}" \
PYO3_CROSS_LIB_DIR=$(python -c "import sysconfig;print(sysconfig.get_config_var('LIBDIR'))") \
maturin build --release --strip \
--features=no-panic,unstable-simd,yyjson \
--interpreter python${{ matrix.python.version }} \
--target=universal2-apple-darwin
uv pip install target/wheels/orjson*.whl
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/debug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ jobs:
profile: [
{ rust: "1.72", features: "" },
{ rust: "1.72", features: "--features=yyjson" },
{ rust: "nightly-2024-09-25", features: "--features=yyjson,unstable-simd" },
{ rust: "nightly-2024-09-25", features: "--features=avx512,yyjson,unstable-simd" },
{ rust: "nightly-2024-11-12", features: "--features=yyjson,unstable-simd" },
]
python: [
{ version: '3.13' },
Expand Down
32 changes: 16 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 4 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,17 @@ crate-type = ["cdylib"]
[features]
default = []

# Use SIMD intrinsics. This requires Rust on the nightly channel.
unstable-simd = []

# Include runtime-detected functions that use AVX512VL. Requires unstable-simd and amd64.
avx512 = []

no-panic = [
"itoa/no-panic",
"ryu/no-panic",
]

# Avoid bundling libgcc on musl.
unwind = ["unwinding"]

# Build yyjson as a backend and panic if it fails. The default is to attempt
# to build and on failure fall back to another backend.
yyjson = []

# Features detected by build.rs. Do not specify.
avx512 = []
inline_int = []
intrinsics = []
optimize = []
unstable-simd = []
unwind = ["unwinding"]

[dependencies]
associative-cache = { version = "2", default-features = false }
Expand All @@ -71,7 +60,7 @@ serde = { version = "1", default-features = false }
serde_json = { version = "1", default-features = false, features = ["std", "float_roundtrip"] }
simdutf8 = { version = "0.1", default-features = false, features = ["std", "public_imp", "aarch64_neon"] }
smallvec = { version = "^1.11", default-features = false, features = ["union", "write"] }
unwinding = { version = "=0.2.2", default-features = false, features = ["unwinder"], optional = true }
unwinding = { version = "^0.2.3", default-features = false, features = ["unwinder"], optional = true }
uuid = { version = "1", default-features = false }
xxhash-rust = { version = "^0.8", default-features = false, features = ["xxh3"] }

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1224,9 +1224,10 @@ It benefits from also having a C build environment to compile a faster
deserialization backend. See this project's `manylinux_2_28` builds for an
example using clang and LTO.

The project's own CI tests against `nightly-2024-09-25` and stable 1.72. It
The project's own CI tests against `nightly-2024-11-12` and stable 1.72. It
is prudent to pin the nightly version because that channel can introduce
breaking changes.
breaking changes. There is a significant performance benefit to using
nightly.

orjson is tested for amd64 on Linux and cross-compiles for aarch64, arm7,
ppc64le, and s390x. It is tested for either aarch64 or amd64 on macOS and
Expand Down
Loading

0 comments on commit 5243edd

Please sign in to comment.