New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop -msse4 compiler flag #27121
Drop -msse4 compiler flag #27121
Conversation
ed5335d
to
fd36a5d
Compare
Older CPUs that do not have SSE4.1 would crash with the Ruby native gem due to an illegal instruction exception. The Abseil random library isn't being used at the moment (grpc#26476), and there's no reason gRPC needs to force SSE4.1 instructions on all platforms at the moment. There are other hardware-specific issues that need to be ironed out for this to work: grpc#27121 When the `-msse4` compiler flag was enabled, the Abseil code started using the `pinsrb` instruction: ``` $ elfx86exts abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.o MODE64 (ret) CMOV (cmovne) SSE2 (movdqa) SSE41 (pinsrb) SSE1 (movaps) CPU Generation: Penryn ``` Closes grpc#27095
fd36a5d
to
e380b65
Compare
Older CPUs that do not have SSE4.1 would crash with the Ruby native gem due to an illegal instruction exception. The Abseil random library isn't being used at the moment (grpc#26476), and there's no reason gRPC needs to force SSE4.1 instructions on all platforms at the moment. There are other hardware-specific issues that need to be ironed out for this to work: grpc#27121 When the `-msse4` compiler flag was enabled, the Abseil code started using the `pinsrb` instruction: ``` $ elfx86exts abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.o MODE64 (ret) CMOV (cmovne) SSE2 (movdqa) SSE41 (pinsrb) SSE1 (movaps) CPU Generation: Penryn ``` Closes grpc#27095
70038f9
to
b9995a7
Compare
Older CPUs that do not have SSE4.1 would crash with the Ruby native gem due to an illegal instruction exception. The Abseil random library isn't being used at the moment (grpc#26476), and there's no reason gRPC needs to force SSE4.1 instructions on all platforms at the moment. There are other hardware-specific issues that need to be ironed out for this to work: grpc#26479 When the `-msse4` compiler flag was enabled, the Abseil code started using the `pinsrb` instruction: ``` $ elfx86exts abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.o MODE64 (ret) CMOV (cmovne) SSE2 (movdqa) SSE41 (pinsrb) SSE1 (movaps) CPU Generation: Penryn ``` Closes grpc#27095
b9995a7
to
3b7cc74
Compare
@veblush Just checking if you had a chance to look at this yet? Unfortunately our Ruby 3 migration is blocked by this issue, since we had to revert to an older version of gRPC (from times prior to gRPC receiving Ruby 3 related fixes). The only alternative would be for us to roll our own version of gRPC (or at least abseil-cpp) with these patches applied, which is a lot of effort. |
@jtattermusch Would you mind taking a look at this pull request? |
AFAIK, those flags were necessary to build Abseil. But I could be wrong so let's check the result of CI. FYI, I'm about to change how to build Abseil (#27193) so this will be solved once gRPC gets the next Abseil release. (presumably next this year) |
@veblush Looking at #23357, I see #elif defined(ABSL_ARCH_X86_64) || defined(ABSL_ARCH_X86_32)
// On x86 we rely on the aesni instructions
#include <wmmintrin.h> This sounds like |
I'm not sure what is defining |
Oh, it looks like abseil defines this: https://github.com/abseil/abseil-cpp/blob/997aaf3a28308eba1b9156aa35ab7bca9688e9f6/absl/random/internal/platform.h#L63 |
It looks gcc 5 and up don't need these compiler flags because they are only enabled when specific flags are in use (gcc-mirror/gcc@97db2bf). For example: #ifndef _WMMINTRIN_H_INCLUDED
#define _WMMINTRIN_H_INCLUDED
/* We need definitions from the SSE2 header file. */
#include <emmintrin.h>
/* AES */
#if !defined(__AES__) || !defined(__SSE2__)
#pragma GCC push_options
#pragma GCC target("aes,sse2")
#define __DISABLE_AES__
#endif /* __AES__ */
#ifndef _EMMINTRIN_H_INCLUDED
#define _EMMINTRIN_H_INCLUDED
/* We need definitions from the SSE header files*/
#include <xmmintrin.h>
#ifndef __SSE2__
#pragma GCC push_options
#pragma GCC target("sse2")
#define __DISABLE_SSE2__
#endif /* __SSE2__ */ |
clang doesn't have these guards (https://github.com/llvm-mirror/clang/blob/master/lib/Headers/wmmintrin.h). I wonder how these CI builds are working without the options. Should abeseil be including https://stackoverflow.com/a/42493893 suggests that is the best practice. |
immintrin.h is the de-factor standard header for clang and GCC to include Intel intrinsics. Using this header avoids requiring the compiler to use the `-maes` and `-msse4.1` compiler options on systems that may not have AES or SSE instruction support. clang: As seen in https://github.com/llvm-mirror/clang/blob/master/lib/Headers/immintrin.h, specific intrinsic header files are conditionally included depending on whether the feature is available. gcc: As seen in https://github.com/gcc-mirror/gcc/blob/master/gcc/config/i386/immintrin.h, gcc includes all intrinsic header files, but each individual file guards against the feature not being available. This came out of an investigation in grpc/grpc#27121.
For completeness, I submitted abseil/abseil-cpp#1015. |
grpc_build_artifacts_multiplatform: running |
@stanhu thanks you for investigation on this. I'm okay with removing |
@veblush Yeah, I think dropping |
This reverts commit 3b7cc74.
Older CPUs that do not have SSE4.1 would crash with the Ruby native gem due to an illegal instruction exception. The Abseil random library isn't being used at the moment (grpc#26476), and there's no reason gRPC needs to force SSE4.1 instructions on all platforms at the moment. There are other hardware-specific issues that need to be ironed out for this to work: grpc#26479 When the `-msse4` compiler flag was enabled, the Abseil code started using the `pinsrb` instruction: ``` $ elfx86exts abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.o MODE64 (ret) CMOV (cmovne) SSE2 (movdqa) SSE41 (pinsrb) SSE1 (movaps) CPU Generation: Penryn ``` This was previously needed because gcc 4.8 wouldn't compile without the `-msse4` and `-maes` flags. However, per gcc-mirror/gcc@97db2bf gcc 5.0+ automatically detects whether these options are enabled. clang still needs `-maes` since including `wmmintrin.h` expects the AES option to be enabled. Closes grpc#27095
immintrin.h is the de-factor standard header for clang and GCC to include Intel intrinsics. Using this header avoids requiring the compiler to use the `-maes` and `-msse4.1` compiler options on systems that may not have AES or SSE instruction support. clang: As seen in https://github.com/llvm-mirror/clang/blob/master/lib/Headers/immintrin.h, specific intrinsic header files are conditionally included depending on whether the feature is available. gcc: As seen in https://github.com/gcc-mirror/gcc/blob/master/gcc/config/i386/immintrin.h, gcc includes all intrinsic header files, but each individual file guards against the feature not being available. This came out of an investigation in grpc/grpc#27121.
Thank you for the update. Let me trigger the CI tests. |
@veblush Are these build failures relevant? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you for the PR!
@jtattermusch One more LGTM, please. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM once the tests are green.
Note that the test failures on MacOS look suspicious - @veblush can you please double check that they are 100% not caused by this PR before merging.
@veblush Could you look this again? This is even more urgent now that older versions of gRPC ship a stale cacerts that doesn't work with the recent LetsEncrypt root certificate expiration: https://gitlab.com/gitlab-org/gitlab/-/issues/342346 |
The objC failure https://source.cloud.google.com/results/invocations/433116be-2252-4cf5-b810-9f1573fdf51f/targets/github%2Fgrpc%2Frun_tests%2Fobjc_macos_opt_native%2Fios-test-interoptests/tests looks unrelated and all the other tests are green. |
immintrin.h is the de-factor standard header for clang and GCC to include Intel intrinsics. Using this header avoids requiring the compiler to use the `-maes` and `-msse4.1` compiler options on systems that may not have AES or SSE instruction support. clang: As seen in https://github.com/llvm-mirror/clang/blob/master/lib/Headers/immintrin.h, specific intrinsic header files are conditionally included depending on whether the feature is available. gcc: As seen in https://github.com/gcc-mirror/gcc/blob/master/gcc/config/i386/immintrin.h, gcc includes all intrinsic header files, but each individual file guards against the feature not being available. This came out of an investigation in grpc/grpc#27121.
immintrin.h is the de-factor standard header for clang and GCC to include Intel intrinsics. Using this header avoids requiring the compiler to use the `-maes` and `-msse4.1` compiler options on systems that may not have AES or SSE instruction support. clang: As seen in https://github.com/llvm-mirror/clang/blob/master/lib/Headers/immintrin.h, specific intrinsic header files are conditionally included depending on whether the feature is available. gcc: As seen in https://github.com/gcc-mirror/gcc/blob/master/gcc/config/i386/immintrin.h, gcc includes all intrinsic header files, but each individual file guards against the feature not being available. This came out of an investigation in grpc/grpc#27121.
Older CPUs that do not have SSE4.1 would crash with the Ruby native gem due to an illegal instruction exception.
The Abseil random library isn't being used at the moment (#26476), and there's no reason gRPC needs to force SSE4.1 instructions on all platforms at the moment. There are other hardware-specific issues that need to be ironed out for this to work: #26479
When the
-msse4
compiler flag was enabled, the Abseil code started using thepinsrb
instruction:This was previously needed because gcc 4.8 wouldn't compile without the
-msse4
and-maes
flags.However, per gcc-mirror/gcc@97db2bf gcc 5.0+ automatically detects whether these options are enabled.
clang still needs
-maes
since includingwmmintrin.h
expects the AES option to be enabled.Closes #27095
@markdroth @veblush