Skip to content

configure: Determine system architecture properly on *BSD systems#2012

Merged
Dead2 merged 1 commit intozlib-ng:developfrom
brad0:configure_uname
Nov 18, 2025
Merged

configure: Determine system architecture properly on *BSD systems#2012
Dead2 merged 1 commit intozlib-ng:developfrom
brad0:configure_uname

Conversation

@brad0
Copy link
Copy Markdown
Contributor

@brad0 brad0 commented Nov 17, 2025

uname -m on a BSD system will provide the architecture port .e.g.
arm64, macppc, octeon instead of the machine architecture .e.g.
aarch64, powerpc, mips64. uname -p will provide the machine
architecture. NetBSD uses x86_64, OpenBSD uses amd64, FreeBSD
is a mix between uname -p (amd64) and the compiler output (x86_64).

@brad0
Copy link
Copy Markdown
Contributor Author

brad0 commented Nov 17, 2025

I came across this as I was wondering why a part of the script was not being run
but ARCH was arm64 instead of aarch64 as the script expected.

And later noticed the amd64 fix to enable the intrinsics support on OpenBSD and FreeBSD.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Nov 17, 2025

Walkthrough

When CHOST is not set, configure uses uname -p on BSD/DragonFly and uname -m elsewhere; it also recognizes amd64 as an alias for x86_64 in ARCH detection and downstream conditionals.

Changes

Cohort / File(s) Summary
ARCH detection & alias normalization
configure
Add BSD/DragonFly branch (case-insensitive uname -s) to set ARCH from uname -p when CHOST is unset; otherwise use uname -m. Expand x86-64 matching to accept amd64 alongside x86_64 in switch/case checks and subsequent ARCH conditionals.

Sequence Diagram(s)

sequenceDiagram
    participant Configure as configure
    participant Sys as System (uname)
    participant Logic as ARCH Logic

    Configure->>Sys: uname -s
    Sys-->>Configure: OS_NAME
    alt OS_NAME matches BSD/DragonFly (case-insensitive)
        Configure->>Sys: uname -p
        Sys-->>Configure: PROC_NAME
        Configure->>Logic: set ARCH = PROC_NAME
    else other non-cross
        Configure->>Sys: uname -m
        Sys-->>Configure: MACHINE
        Configure->>Logic: set ARCH = MACHINE
    end
    Note over Logic: Normalize ARCH aliases
    Logic->>Logic: treat "amd64" as "x86_64" in case checks
    Logic-->>Configure: ARCH determined (used in later conditionals)
Loading

Suggested reviewers

  • Dead2

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: using uname -p on *BSD systems for proper architecture determination instead of uname -m.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description clearly explains the BSD-specific issue with uname -m vs uname -p, detailing how different BSD systems return architecture names and the rationale for the change.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6d8c1ac and 962ac97.

📒 Files selected for processing (1)
  • configure (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: mtl1979
Repo: zlib-ng/zlib-ng PR: 1904
File: arch/riscv/Makefile.in:12-14
Timestamp: 2025-04-15T09:20:52.333Z
Learning: Optional feature flags in Makefile.in templates should default to empty strings. The configure script should detect feature support and update these variables accordingly during the configuration process.
📚 Learning: 2025-04-15T09:20:52.333Z
Learnt from: mtl1979
Repo: zlib-ng/zlib-ng PR: 1904
File: arch/riscv/Makefile.in:12-14
Timestamp: 2025-04-15T09:20:52.333Z
Learning: Optional feature flags in Makefile.in templates should default to empty strings. The configure script should detect feature support and update these variables accordingly during the configuration process.

Applied to files:

  • configure
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (41)
  • GitHub Check: macOS Clang ASAN (ARM64)
  • GitHub Check: Windows MSVC 2022 v141 Win64
  • GitHub Check: Windows MSVC ARM No Test
  • GitHub Check: EL10 Clang S390X DFLTCC MSAN
  • GitHub Check: macOS Clang ASAN (ARM64)
  • GitHub Check: Windows MSVC 2022 v141 Win64
  • GitHub Check: Windows MSVC ARM No Test
  • GitHub Check: EL10 Clang S390X DFLTCC MSAN
  • GitHub Check: macOS Clang ASAN (ARM64)
  • GitHub Check: Windows MSVC 2022 v141 Win64
  • GitHub Check: Windows MSVC ARM No Test
  • GitHub Check: EL10 Clang S390X DFLTCC MSAN
  • GitHub Check: macOS Clang ASAN (ARM64)
  • GitHub Check: Windows MSVC 2022 v141 Win64
  • GitHub Check: Windows MSVC ARM No Test
  • GitHub Check: EL10 Clang S390X DFLTCC MSAN
  • GitHub Check: macOS Clang ASAN (ARM64)
  • GitHub Check: Windows MSVC 2022 v141 Win64
  • GitHub Check: Windows MSVC ARM No Test
  • GitHub Check: EL10 Clang S390X DFLTCC MSAN
  • GitHub Check: macOS Clang ASAN (ARM64)
  • GitHub Check: Windows MSVC 2022 v141 Win64
  • GitHub Check: Windows MSVC ARM No Test
  • GitHub Check: EL10 Clang S390X DFLTCC MSAN
  • GitHub Check: macOS Clang ASAN (ARM64)
  • GitHub Check: Windows MSVC 2022 v141 Win64
  • GitHub Check: Windows MSVC ARM No Test
  • GitHub Check: EL10 Clang S390X DFLTCC MSAN
  • GitHub Check: macOS Clang ASAN (ARM64)
  • GitHub Check: Windows MSVC 2022 v141 Win64
  • GitHub Check: Windows MSVC ARM No Test
  • GitHub Check: EL10 Clang S390X DFLTCC MSAN
  • GitHub Check: macOS Clang ASAN (ARM64)
  • GitHub Check: Windows MSVC 2022 v141 Win64
  • GitHub Check: Windows MSVC ARM No Test
  • GitHub Check: EL10 Clang S390X DFLTCC MSAN
  • GitHub Check: macOS Clang ASAN (ARM64)
  • GitHub Check: Windows MSVC 2022 v141 Win64
  • GitHub Check: Windows MSVC ARM No Test
  • GitHub Check: EL10 Clang S390X DFLTCC MSAN
  • GitHub Check: macOS GCC (ARM64)

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.29%. Comparing base (6d8c1ac) to head (cfa0ac2).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2012      +/-   ##
===========================================
- Coverage    82.37%   81.29%   -1.09%     
===========================================
  Files          163      163              
  Lines        12862    12862              
  Branches      3171     3171              
===========================================
- Hits         10595    10456     -139     
- Misses        1201     1347     +146     
+ Partials      1066     1059       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@brad0
Copy link
Copy Markdown
Contributor Author

brad0 commented Nov 17, 2025

I mean one of the AIs suggestions is something along what I had considered but was not sure which way to go.

@brad0 brad0 force-pushed the configure_uname branch 2 times, most recently from e3568ce to 2c9bf39 Compare November 17, 2025 06:50
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e3568ce and 2c9bf39.

📒 Files selected for processing (1)
  • configure (3 hunks)
🔇 Additional comments (3)
configure (3)

42-42: LGTM: amd64 alias support added.

Correctly treats amd64 (commonly used on BSD systems) as equivalent to x86_64 for architecture detection. This aligns with the PR objective of properly handling BSD architecture names.


346-350: LGTM: Cross-compiler amd64 handling added.

Correctly extends the cross-compiler architecture detection to recognize amd64 alongside x86_64. The logic properly honors the --32 build flag.


1803-1918: LGTM: amd64 included in x86 optimization path.

Essential addition that ensures BSD systems with ARCH=amd64 correctly receive x86-specific optimizations (SSE2, AVX2, AVX512, etc.). Without this change, these systems would fall through to the generic architecture case and miss critical performance optimizations.

@brad0
Copy link
Copy Markdown
Contributor Author

brad0 commented Nov 17, 2025

Also before and after on an OpenBSD/amd64 system..

Checking for GNU style __cpuid... Yes.
Checking for MS style __cpuid... No.
Checking for strerror... Yes.
Checking for getauxval() or elf_aux_info() in sys/auxv.h... Yes.
Checking for unistd.h... Yes.
Checking for linux/auxvec.h... No.
Checking for ptrdiff_t... Yes.
Checking for ANSI C compliant compiler...  Yes.
Checking for -fno-semantic-interposition... No.
Checking for attribute(aligned) ... Yes.
Checking for __builtin_assume_aligned() ... Yes.
Checking for __builtin_ctz ... Yes.
Checking for __builtin_ctzll ... Yes.
Uname: OpenBSD 7.8
ARCH: amd64
Using arch directory: arch/generic
Architecture-specific static object files:
Architecture-specific shared object files:
fubar$ ../configure
Checking for compiler... cc
Checking for Symbol versioning... Yes.
Checking for shared library support... Building shared library libz-ng.so.2.3.0 with cc.
Checking for -Werror=unguarded-availability... No.
Checking for -Werror=unguarded-availability-new... No.
Checking for -Werror=unused-command-line-argument... No.
Checking for version script support... -Wl,--version-script,/home/brad/tmp/zlib-ng/zlib-ng.map.
Checking for off64_t... No.
Checking for _off64_t... No.
Checking for fseeko... Yes.
Checking for GNU style __cpuid... Yes.
Checking for MS style __cpuid... No.
Checking for strerror... Yes.
Checking for getauxval() or elf_aux_info() in sys/auxv.h... Yes.
Checking for unistd.h... Yes.
Checking for linux/auxvec.h... No.
Checking for ptrdiff_t... Yes.
Checking for ANSI C compliant compiler...  Yes.
Checking for -fno-semantic-interposition... No.
Checking for attribute(aligned) ... Yes.
Checking for __builtin_assume_aligned() ... Yes.
Checking for __builtin_ctz ... Yes.
Checking for __builtin_ctzll ... Yes.
Checking for XSAVE intrinsics ... Yes.
Checking for SSE2 intrinsics ... Yes.
Checking for SSSE3 intrinsics ... Yes.
Checking for SSE4.1 intrinsics ... Yes.
Checking for SSE4.2 intrinsics ... Yes.
Checking for PCLMULQDQ intrinsics ... Yes.
Checking for AVX2 intrinsics ... Yes.
Checking for AVX512 intrinsics ... Yes.
Check whether -mtune=cascadelake works ... Yes.
Checking for AVX512VNNI intrinsics ... Yes.
Checking for VPCLMULQDQ intrinsics ... Yes.
Uname: OpenBSD 7.8
ARCH: amd64
Using arch directory: arch/x86
Architecture-specific static object files: x86_features.o chunkset_sse2.o chorba_sse2.o compare256_sse2.o slide_hash_sse2.o adler32_ssse3.o chunkset_ssse3.o chorba_sse41.o adler32_sse42.o crc32_pclmulqdq.o slide_hash_avx2.o chunkset_avx2.o compare256_avx2.o adler32_avx2.o adler32_avx512.o chunkset_avx512.o compare256_avx512.o adler32_avx512_vnni.o crc32_vpclmulqdq.o
Architecture-specific shared object files: x86_features.lo chunkset_sse2.lo chorba_sse2.lo compare256_sse2.lo slide_hash_sse2.lo adler32_ssse3.lo chunkset_ssse3.lo chorba_sse41.lo adler32_sse42.lo crc32_pclmulqdq.lo slide_hash_avx2.lo chunkset_avx2.lo compare256_avx2.lo adler32_avx2.lo adler32_avx512.lo chunkset_avx512.lo compare256_avx512.lo adler32_avx512_vnni.lo crc32_vpclmulqdq.lo
brad@freebsd-vmware-amd64:~/tmp/zlib-ng $ ./configure
Checking for compiler... cc
Checking for Symbol versioning... Yes.
Checking for shared library support... Building shared library libz-ng.so.2.3.0 with cc.
Checking for -Werror=unguarded-availability... No.
Checking for -Werror=unguarded-availability-new... No.
Checking for -Werror=unused-command-line-argument... No.
Checking for version script support... No.
Checking for off64_t... Yes.
Checking for fseeko... Yes.
Checking for GNU style __cpuid... Yes.
Checking for MS style __cpuid... No.
Checking for strerror... Yes.
Checking for getauxval() or elf_aux_info() in sys/auxv.h... Yes.
Checking for unistd.h... Yes.
Checking for linux/auxvec.h... No.
Checking for ptrdiff_t... Yes.
Checking for ANSI C compliant compiler...  Yes.
Checking for -fno-semantic-interposition... No.
Checking for attribute(aligned) ... Yes.
Checking for __builtin_assume_aligned() ... Yes.
Checking for __builtin_ctz ... Yes.
Checking for __builtin_ctzll ... Yes.
Uname: FreeBSD 14.3-RELEASE
ARCH: amd64
Using arch directory: arch/generic
Architecture-specific static object files:
Architecture-specific shared object files:
brad@freebsd-vmware-amd64:~/tmp/zlib-ng/build $ ../configure
Checking for compiler... cc
Checking for Symbol versioning... Yes.
Checking for shared library support... Building shared library libz-ng.so.2.3.0 with cc.
Checking for -Werror=unguarded-availability... No.
Checking for -Werror=unguarded-availability-new... No.
Checking for -Werror=unused-command-line-argument... No.
Checking for version script support... No.
Checking for off64_t... Yes.
Checking for fseeko... Yes.
Checking for GNU style __cpuid... Yes.
Checking for MS style __cpuid... No.
Checking for strerror... Yes.
Checking for getauxval() or elf_aux_info() in sys/auxv.h... Yes.
Checking for unistd.h... Yes.
Checking for linux/auxvec.h... No.
Checking for ptrdiff_t... Yes.
Checking for ANSI C compliant compiler...  Yes.
Checking for -fno-semantic-interposition... No.
Checking for attribute(aligned) ... Yes.
Checking for __builtin_assume_aligned() ... Yes.
Checking for __builtin_ctz ... Yes.
Checking for __builtin_ctzll ... Yes.
Checking for XSAVE intrinsics ... Yes.
Checking for SSE2 intrinsics ... Yes.
Checking for SSSE3 intrinsics ... Yes.
Checking for SSE4.1 intrinsics ... Yes.
Checking for SSE4.2 intrinsics ... Yes.
Checking for PCLMULQDQ intrinsics ... Yes.
Checking for AVX2 intrinsics ... Yes.
Checking for AVX512 intrinsics ... Yes.
Check whether -mtune=cascadelake works ... Yes.
Checking for AVX512VNNI intrinsics ... Yes.
Checking for VPCLMULQDQ intrinsics ... Yes.
Uname: FreeBSD 14.3-RELEASE
ARCH: amd64
Using arch directory: arch/x86
Architecture-specific static object files: x86_features.o chunkset_sse2.o chorba_sse2.o compare256_sse2.o slide_hash_sse2.o adler32_ssse3.o chunkset_ssse3.o chorba_sse41.o adler32_sse42.o crc32_pclmulqdq.o slide_hash_avx2.o chunkset_avx2.o compare256_avx2.o adler32_avx2.o adler32_avx512.o chunkset_avx512.o compare256_avx512.o adler32_avx512_vnni.o crc32_vpclmulqdq.o
Architecture-specific shared object files: x86_features.lo chunkset_sse2.lo chorba_sse2.lo compare256_sse2.lo slide_hash_sse2.lo adler32_ssse3.lo chunkset_ssse3.lo chorba_sse41.lo adler32_sse42.lo crc32_pclmulqdq.lo slide_hash_avx2.lo chunkset_avx2.lo compare256_avx2.lo adler32_avx2.lo adler32_avx512.lo chunkset_avx512.lo compare256_avx512.lo adler32_avx512_vnni.lo crc32_vpclmulqdq.lo

uname -m on a BSD system will provide the architecture port .e.g.
arm64, macppc, octeon instead of the machine architecture .e.g.
aarch64, powerpc, mips64. uname -p will provide the machine
architecture. NetBSD uses x86_64, OpenBSD uses amd64, FreeBSD
is a mix between uname -p and the compiler output.
Copy link
Copy Markdown
Member

@Dead2 Dead2 left a comment

Choose a reason for hiding this comment

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

LGTM

@Dead2 Dead2 merged commit 2a7c40c into zlib-ng:develop Nov 18, 2025
154 of 156 checks passed
@brad0 brad0 deleted the configure_uname branch November 18, 2025 19:12
@Dead2 Dead2 mentioned this pull request Nov 25, 2025
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