Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Build: Add -mno-strict-align flag for RISC-V architecture#4584

Open
Polaris-911 wants to merge 1 commit intofacebook:dev from
Polaris-911:dev
Open

Build: Add -mno-strict-align flag for RISC-V architecture #4584
Polaris-911 wants to merge 1 commit intofacebook:dev from
Polaris-911:dev

Conversation

@Polaris-911
Copy link
Contributor

@Polaris-911 Polaris-911 commented Feb 4, 2026

Description

This PR updates the root Makefile to automatically detect RISC-V architectures (via uname -m) and append the -mno-strict-align flag to MOREFLAGS.

On many RISC-V implementations standard builds can suffer from significant performance degradation. Adding -mno-strict-align instructs the compiler to generate code that handles unaligned accesses via byte-wise instructions or other safe methods, thereby avoiding expensive traps and improving runtime performance.

Changes

  • Detects riscv% in UNAME_M.
  • Appends -mno-strict-align to MOREFLAGS.
  • Exports MOREFLAGS to ensure the flag is correctly propagated to sub-makefiles (lib, programs, etc.).

Validation & Benchmarks

Tested on a RISC-V device (Sophon SG2044 / 64-core RISC-V).

Benchmark Environment:

  • Hardware: Sophon SG2044
  • OS: Linux (RISC-V 64-bit)
  • Compiler: GCC 12.3.1

Results:
Comparison between the original build and the build with -mno-strict-align.

Metric Original With -mno-strict-align Improvement rate
Compression Speed 64.0 MB/s 75.2 MB/s +17.50%
Decompression Speed 102.9 MB/s 165.1 MB/s +60.45%

(Note: Data collected using zstd -b benchmark)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /