google / google/libprotobuf-mutator

Build fails on macOS arm64: external protobuf/absl passes -msse4.1 to arm64 compile

Open
#292 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
667
Forks
134
PR merge metrics
No merged PRs in 30d

Description

## Summary
Building `libprotobuf-mutator` (`v1.5`) on macOS arm64 fails while building the downloaded protobuf dependency (`v29.3`) because `absl` injects an x86-only flag (`-msse4.1`) into an arm64 compile command.

## Environment
- OS: macOS 15.7.5 (24G624) arm64 (Darwin 24.6.0)
- Compiler: Apple clang 17.0.0
- libprotobuf-mutator: `v1.5` (`dc4ced337a9fb4047e2dc727268fbac55ca82f73`)

## Reproduction
```bash
rm -rf /tmp/lpm-repro
mkdir -p /tmp/lpm-repro
cd /tmp/lpm-repro
git clone --depth 1 --branch v1.5 https://github.com/google/libprotobuf-mutator.git src

cd /tmp/lpm-repro/src
mkdir -p build && cd build
cmake .. \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_FLAGS='-D_GLIBCXX_USE_CXX11_ABI=1' \
-DCMAKE_CXX_FLAGS='-D_GLIBCXX_USE_CXX11_ABI=1 -stdlib=libc++' \
-DLIB_PROTO_MUTATOR_TESTING=OFF \
-DLIB_PROTO_MUTATOR_EXAMPLES=OFF \
-DLIB_PROTO_MUTATOR_WITH_ASAN=ON \
-DLIB_PROTO_MUTATOR_DOWNLOAD_PROTOBUF=ON \
-Dprotobuf_BUILD_LIBPROTOC=ON \
-Dprotobuf_WITH_ZLIB=ON

cmake --build . -j10
```

## Actual behavior
Build fails in external protobuf/absl target:
```text
Building CXX object ... random_internal_randen_hwaes_impl.dir/internal/randen_hwaes.cc.o
clang++: error: unsupported option '-msse4.1' for target 'arm64-apple-darwin24.6.0'
```

## Evidence
From generated flags file:
`/tmp/lpm-repro/src/build/external.protobuf/src/external.protobuf-build/third_party/abseil-cpp/absl/random/CMakeFiles/random_internal_randen_hwaes_impl.dir/flags.make`

It contains both arm64 and x86 flags in the same compile command:
```text
... -arch arm64 ... -Xarch_x86_64 -maes -msse4.1 -Xarch_arm64 -march=armv8-a+crypto ...
```

This appears to come from absl's Darwin path in:
`absl/copts/AbseilConfigureCopts.cmake`
which appends both `x86_64` and `arm64` randen flags.

## Expected behavior
On macOS arm64, `random_internal_randen_hwaes_impl` should not receive bare x86-only flags that break arm64 compilation.

If this is expected to be fixed in protobuf/absl rather than here, guidance/workaround in `libprotobuf-mutator` docs would also help.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.