Skip to content

[R-package] compiler warning on clang + arm64 macOS: argument unused during compilation: '-msse2' #12490

Description

@jameslamb

Description

While testing the R package after it was switched from autoconf to CMake (#12416), I found that R CMD check --as-cran now raises 1 WARNING on Apple Silicon (e.g. my M2 macbook).

* checking whether package ‘xgboost’ can be installed ... [181s/183s] WARNING
Found the following significant warnings:
  clang: warning: argument unused during compilation: '-msse2' [-Wunused-command-line-argument]

That warning is harmless (it just means "you used an x86-specific flag on a non-x86 system"), but the fact that R CMD check --as-cran emits a WARNING could be enough to cause delays publishing to CRAN. It should be fixed if the fix isn't too much complexity.

Reproducible Example

$ git clean -dfX
$ python -B ops/script/test_r_package.py --task build
$ TEMP_DIR=$(mktemp -d)
$ cp ./xgboost_3.5.0.0.tar.gz "${TEMP_DIR}"/
$ pushd "${TEMP_DIR}"
$ R CMD check --as-cran ./xgboost*.tar.gz
* using R version 4.6.0 (2026-04-24)
* using platform: aarch64-apple-darwin23
* R was compiled by
    Apple clang version 17.0.0 (clang-1700.3.19.1)
    GNU Fortran (GCC) 14.2.0
* running under: macOS Sonoma 14.4.1
* using session charset: UTF-8
* current time: 2026-08-20 03:35:09 UTC
* using option ‘--as-cran’
...
* checking whether package ‘xgboost’ can be installed ... [181s/183s] WARNING
Found the following significant warnings:
  clang: warning: argument unused during compilation: '-msse2' [-Wunused-command-line-argument]
See ‘/private/var/folders/6d/80svzp0d0z1dr414fgnvll6h0000gn/T/tmp.Q5X4NeFmeo/xgboost.Rcheck/00install.out’ for details.

Looks like that is coming from dmlc-core.

[  3%] Building CXX object dmlc-core/CMakeFiles/dmlc.dir/src/config.cc.o
clang: warning: argument unused during compilation: '-msse2' [-Wunused-command-line-argument]
[  4%] Building CXX object dmlc-core/CMakeFiles/dmlc.dir/src/data.cc.o
clang: warning: argument unused during compilation: '-msse2' [-Wunused-command-line-argument]
... etc., etc.

Notes

Why not just suppress it with a -Wno flag?

Suppressing warnings with -Wno-unused-command-line-argument is not allowed by the CRAN policies. From https://cran.r-project.org/web/packages/policies.html

Packages should not attempt to disable compiler diagnostics, nor to remove other diagnostic information such as symbols in shared objects.

XGBoost has been on CRAN and using dmlc-core for a long time, why would this only be a problem now?

I think the switch to CMake means dmlc-core's compiler flags are coming through from its CMake. I don't see this warning in the most recent CRAN checks for XGBoost on CRAN *(based on XGBoost 3.2.1.1):

Approach

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions