Skip to content

fix: check compiler support for date-time warning flag - #175

Open
SoonIter wants to merge 1 commit into
purpleprotocol:masterfrom
SoonIter:fix-optional-date-time-warning
Open

SoonIter wants to merge 1 commit into
purpleprotocol:masterfrom
SoonIter:fix-optional-date-time-warning

Conversation

@SoonIter

@SoonIter SoonIter commented Nov 2, 2026 •

Copy link
Copy Markdown

Summary

-Wdate-time was introduced in GCC 4.9. Modern GCC versions support it, but older compilers are still used in cross-compilation toolchains. For example, another user reported a toolchain bundling GCC 4.8.5.

The build script unconditionally adds -Wno-error=date-time on non-Windows targets. Older compilers that do not recognize this warning option fail with:

cc1: error: -Werror=date-time: no option -Wdate-time

Use flag_if_supported to check compiler support before adding the flag. Supporting compilers retain the date/time warning suppression introduced in #139; other compilers omit the unsupported option.

Validation

  • cargo test and cargo test --features v2 passed on macOS arm64.
  • cargo fmt --all -- --check and git diff --check passed.
  • An isolated build-script check using cc 1.2.45 and a compiler wrapper that rejects this option fails before the change and passes after it. With a supporting compiler, the flag remains in the mimalloc compile command.
  • Complete builds with the affected cross-compilers have not been verified.

Related Links

Copilot AI balanced review requested due to automatic review settings November 2, 2026 08:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the compiler-flag compatibility change.

No open issues 🎉

What changed in this PR

Updates mimalloc’s native build configuration to avoid failures on compilers that reject -Wno-error=date-time, while preserving the existing workaround on supporting compilers.

Changes:

  • Uses flag_if_supported for the date/time warning flag on non-Windows targets.
File Description
libmimalloc-sys/​build.rs Checks compiler support before applying -Wno-error=date-time.

Review effort: Balanced

CPunisher pushed a commit to swc-project/swc-next that referenced this pull request Nov 2, 2026
## Motivation

During the 0.5.0 release, the `aarch64-unknown-linux-gnu`,
`powerpc64le-unknown-linux-gnu`, and `s390x-unknown-linux-gnu` builds
failed while compiling mimalloc. NAPI's bundled GCC compilers reject
`-Wno-error=date-time`, which `libmimalloc-sys` adds unconditionally.
Pinning Clang 15 also fails on Ubuntu 26.04 because that package is no
longer available.

## Changes

Use Ubuntu's system Clang at `/usr/bin/clang` for the three affected
targets while keeping `ubuntu-latest`. Install the unversioned `clang`
package if needed, verify that it includes the required AArch64,
PowerPC64LE, or SystemZ backend, and export `TARGET_CC` for the build.
The absolute path avoids selecting another Clang earlier on `PATH`; NAPI
retains its cross sysroot and linker configuration.

Validation: actionlint passed; 13 matrix selections, nine compiler
setup/backend scenarios, and three environment checks against the
official NAPI CLI passed. Complete Linux builds using this final
configuration have not been rerun; no release workflow was dispatched.

## Related Links

- [Failed 0.5.0 GNU
builds](https://github.com/swc-project/swc-next/actions/runs/41408325522)
- [Ubuntu 26.04 cannot install
clang-15](https://github.com/swc-project/swc-next/actions/runs/41412324382/job/125168000441)
- [Rspack's Clang cross-build
configuration](https://github.com/web-infra-dev/rspack/blob/1bd28315243e5351a41384366307cbd689c71d54/.github/workflows/reusable-build-build.yml#L89-L168)
- [GitHub runner installation of system
Clang](https://github.com/actions/runner-images/blob/main/images/ubuntu/scripts/build/install-clang.sh)
- purpleprotocol/mimalloc_rust#175
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.

2 participants