Description
On an x86_64-apple-* macOS machine, COMPILER_RT_HAS_MSSE4_2_FLAG
is true (the availability is detected like clang --target=x86_64-apple-darwinXXX -arch x86_64 -Werror -msse4.2 -c src.cxx
).
Ensure that an iOS SDK is available. In the following build,
/opt/homebrew/bin/cmake -GNinja -Sllvm -Bout/runtimes -DCMAKE_BUILD_TYPE=Release -DCLANG_ENABLE_ARCMT=off -DCLANG_ENABLE_STATIC_ANALYZER=off -DLLVM_ENABLE_PROJECTS='clang;lld' -DCOMPILER_RT_ENABLE_IOS=on -DLLVM_ENABLE_RUNTIMES=compiler-rt -DLLVM_TARGETS_TO_BUILD='X86;AArch64' -DLLVM_ENABLE_UNWIND_TABLES=OFF
ninja -C out/runtimes runtimes
ninja -C out/runtimes/runtimes/runtimes-bins tsan
compiler-rt/lib/tsan/rtl/CMakeFiles/clang_rt.tsan_ios_dynamic.dir/tsan_debugging.cpp.o
(and other clang_rt.tsan_ios_dynamic.dir
files due to -DCOMPILER_RT_ENABLE_IOS=on
) will have a warning like the following
% clang -c --target=x86_64-apple-darwin -arch arm64 -msse4.2 a.c
clang: warning: argument unused during compilation: '-msse4.2' [-Wunused-command-line-argument]
This command compiles a.c
using the arm64-apple-darwin triple and -msse4.2
should lead to an error instead of a warning.
The full command line will look like the following if Clang issues an error (https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket/8778547096422852257/+/u/package_clang/stdout)
FAILED: compiler-rt/lib/tsan/rtl/CMakeFiles/clang_rt.tsan_ios_dynamic.dir/tsan_debugging.cpp.o
/Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/./bin/clang++ --target=x86_64-apple-darwin -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Dclang_rt_tsan_ios_dynamic_EXPORTS -I/Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/tsan/rtl/../.. -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -Wall -Wno-unused-parameter -O3 -DNDEBUG -std=c++17 -arch arm64 -isysroot /Volumes/Work/s/w/ir/cache/osx_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -fPIC -stdlib=libc++ -miphoneos-version-min=9.0 -isysroot /Volumes/Work/s/w/ir/cache/osx_sdk/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.2.sdk -fno-lto -fPIC -fno-builtin -fno-exceptions -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -O3 -g -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -nostdinc++ -fPIE -fno-rtti -msse4.2 -Wframe-larger-than=530 -Wglobal-constructors -MD -MT compiler-rt/lib/tsan/rtl/CMakeFiles/clang_rt.tsan_ios_dynamic.dir/tsan_debugging.cpp.o -MF compiler-rt/lib/tsan/rtl/CMakeFiles/clang_rt.tsan_ios_dynamic.dir/tsan_debugging.cpp.o.d -o compiler-rt/lib/tsan/rtl/CMakeFiles/clang_rt.tsan_ios_dynamic.dir/tsan_debugging.cpp.o -c /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/tsan/rtl/tsan_debugging.cpp
clang++: error: unsupported option '-msse4.2' for target 'x86_64-apple-darwin'
It seems tsan's CMake should be fixed to recognize x86_64 options and not pass them to clang_rt.tsan_ios_dynamic.dir builds (clang --target=x86_64-apple-darwinXXX -arch arm64
).
For host files like ./compiler-rt/lib/tsan/rtl/CMakeFiles/clang_rt.tsan_osx_dynamic.dir/tsan_flags.cpp.o
, the Clang command line looks like -arch arm64 -arch x86_64 -arch x86_64h
.
It is benign to pass -msse4.2
but ideally -Xarch_x86_64 -msse4.2 -Xarch_x86_64h -msse4.2
should be used instead.