[SERVER-32649] got "used vector type where scalar is required" when using GCC 7 Created: 10/Jan/18  Updated: 30/Oct/23  Resolved: 16/Jan/18

Status: Closed
Project: Core Server
Component/s: Build
Affects Version/s: None
Fix Version/s: 3.6.3, 3.7.2

Type: Bug Priority: Major - P3
Reporter: Calvin Sze Assignee: Mark Benvenuto
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Backwards Compatibility: Fully Compatible
Operating System: Linux
Backport Requested:
v3.6
Sprint: Platforms 2018-01-29
Participants:

 Description   

When compiling Mongo core components on a Power9 with GCC 7 (Advance Toolchain 11.02)
Got following error,
opt/at11.0/bin/gcc -o build/opt/third_party/wiredtiger/src/block/block_compact.o -c -std=c11 -fno-omit-frame-pointer -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -O2 -Wno-unused-local-typedefs -Wno-unused-function -Wno-deprecated-declarations -Wno-unused-const-variable -Wno-unused-but-set-variable -Wno-missing-braces -fstack-protector-strong -fno-builtin-memcmp -fPIE -DPCRE_STATIC -DNDEBUG -D_FORTIFY_SOURCE=2 -DBOOST_THREAD_VERSION=4 -DBOOST_THREAD_DONT_PROVIDE_VARIADIC_THREAD -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS -DBOOST_THREAD_HAS_NO_EINTR_BUG -DHAVE_VERBOSE -DHAVE_FALLOCATE -DHAVE_SYNC_FILE_RANGE -DHAVE_X86INTRIN_H -D_GNU_SOURCE -DHAVE_BUILTIN_EXTENSION_ZLIB -DHAVE_BUILTIN_EXTENSION_SNAPPY -DHAVE_CRC32_HARDWARE -Isrc/third_party/snappy-1.1.3 -Isrc/third_party/zlib-1.2.8 -Ibuild/opt/third_party/wiredtiger -Isrc/third_party/wiredtiger -Ibuild/opt/third_party/wiredtiger/src/include -Isrc/third_party/wiredtiger/src/include -Ibuild/opt/third_party/wiredtiger/build_linux -Isrc/third_party/wiredtiger/build_linux src/third_party/wiredtiger/src/block/block_compact.c
In file included from src/third_party/wiredtiger/src/include/wt_internal.h:384:0,
from src/third_party/wiredtiger/src/async/async_api.c:9:
src/third_party/wiredtiger/src/include/cursor.i: In function '__cursor_func_init':
src/third_party/wiredtiger/src/include/cursor.i:234:6: error: used vector type where scalar is required
if (reenter) {
^~~~~~~
In file included from src/third_party/wiredtiger/src/include/btree_cmp.i:11:0,
from src/third_party/wiredtiger/src/include/wt_internal.h:382,
from src/third_party/wiredtiger/src/async/async_op.c:9:

The reason of this is that gcc used -DHAVE_X86INTRIN_H which was generated by
====================================================================================
./src/third_party/wiredtiger/SConscript

if conf.CheckCHeader('x86intrin.h'):
conf.env.Append(CPPDEFINES=[
"HAVE_X86INTRIN_H"
])

=====================================================================================
I was told GCC 7 and later version will have the file, x86intrin.h, included, is there a way we could avoid it if the target platform is not x86?

Thanks



 Comments   
Comment by Githook User [ 18/Jan/18 ]

Author:

{'name': 'Mark Benvenuto', 'email': 'mark.benvenuto@mongodb.com', 'username': 'markbenvenuto'}

Message: SERVER-32649 WiredTiger fails on non-x64 builds of new GCC

(cherry picked from commit f971dee540b9c9f7d6a92e278900e8bb00014f92)
Branch: v3.6
https://github.com/mongodb/mongo/commit/75a2492cdf0dd73e294bb1df1cfb9b4c5a38ee79

Comment by Mark Benvenuto [ 16/Jan/18 ]

I was always going to fix the issue. I just wanted to understand how it was hit, and which versions of the product to backport it to. We make the fixes in master typically, and then backport to older releases as needed. I will backport this fix to 3.6.

Our process is similar to how GCC works. I tracked down how x86intrin.h was introduced, and noticed that wschmidt backported the change to the gcc 7 branch used in the IBM Advance Toolchain.

GCC Master:
https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=247988

IBM GCC 7 Branch:
https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=254527

Comment by Githook User [ 16/Jan/18 ]

Author:

{'email': 'mark.benvenuto@mongodb.com', 'name': 'Mark Benvenuto', 'username': 'markbenvenuto'}

Message: SERVER-32649 WiredTiger fails on non-x64 builds of new GCC
Branch: master
https://github.com/mongodb/mongo/commit/f971dee540b9c9f7d6a92e278900e8bb00014f92

Comment by Peter Bergner [ 12/Jan/18 ]

So applying the SERVER-32161 fix to the 3.6 release git checkout fixes the ucontext issue I ran into, so if that fix could be backported, then that takes care of that issue. Note, I have not tried building anything older than v3.6.

With that fix manually applied, then building again, without the --disable-warnins-as-errors, I see the following warning which causes an error:

src/third_party/IntelRDFPMathLib20U1/LIBRARY/src/bid_conf.h:75:27: note: the ABI of passing aggregates with 16-byte alignment has changed in GCC 5
#define bid128_sin __bid128_sin^M
^
src/third_party/IntelRDFPMathLib20U1/LIBRARY/src/bid_conf.h:1751:6: note: in definition of macro 'BID128_FUNCTION_ARG1'
fn_name (BID_UINT128 bid_##arg_name _RND_MODE_PARAM _EXC_FLAGS_PARAM ^M
^~~~~~~
src/third_party/IntelRDFPMathLib20U1/LIBRARY/src/bid128_sin.c:12430:23: note: in expansion of macro 'bid128_sin'
BID128_FUNCTION_ARG1 (bid128_sin, x)^M
^~~~~~~~~~
scons: building terminated because of errors.

This I cannot work around, so next, I built using the --disable-warnings-as-errors and I see this failure:

/opt/at11.0/lib/gcc/powerpc64le-linux-gnu/7.2.1/include/mmintrin.h:52:2: warning: #warning "Please read comment above. Use -DNO_WARN_X86_INTRINSICS to disable this warning." [-Wcpp]
#warning "Please read comment above. Use -DNO_WARN_X86_INTRINSICS to disable this warning."
^~~~~~~
In file included from src/third_party/wiredtiger/src/include/wt_internal.h:388:0,
from src/third_party/wiredtiger/src/block/block_open.c:9:
src/third_party/wiredtiger/src/include/cursor.i: In function '__cursor_func_init':
src/third_party/wiredtiger/src/include/cursor.i:324:6: error: used vector type where scalar is required
if (reenter) {
^~~~~~~
This is due to some hairy interaction between altivec.h and the X86 intrinsic compat headers. Since we shouldn't be using the x86 intrinsic compat support at all, I think my patch above to SConscript should be applied. Using the SConscript patch does allow me to build mongodb to completion.

Comment by Peter Bergner [ 12/Jan/18 ]

Mark Benvenuto wrote:
> Are you compiling with "--disable-warnings-as-errors"?

Yes, I inherited that from Calvin.

> The other issue is a known issue: SERVER-32161

Looking at my source, I don't seem to have that. I'll try updating my source, and I suspect I won't need my ucontext change given the fix for the above. Thanks for pointing me to it!

Comment by Calvin Sze [ 11/Jan/18 ]

Yes, I compiled with --disable-warnings-as-errors, since I encountered the same issue as, https://jira.mongodb.org/browse/SERVER-30711

Comment by Mark Benvenuto [ 11/Jan/18 ]

Are you compiling with "--disable-warnings-as-errors"?

The other issue is a known issue: SERVER-32161

When I tried this locally, we did not pick up "x86intrin.h" because of the warning:

/opt/at11.0/bin/gcc -o build/scons/opt/sconf_temp/conftest_67.o -c -std=c11 -fno-omit-frame-pointer -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -Werror -O2 -Wno-unused-local-typedefs -Wno-unused-function -Wno-deprecated-declarations -Wno-unused-const-variable -Wno-unused-but-set-variable -Wno-missing-braces -fstack-protector-strong -fno-builtin-memcmp -fPIE -DPCRE_STATIC -DNDEBUG -D_FORTIFY_SOURCE=2 -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS -DHAVE_VERBOSE -DHAVE_FALLOCATE -DHAVE_SYNC_FILE_RANGE -Isrc/third_party/snappy-1.1.3 -Isrc/third_party/zlib-1.2.8 -Ibuild/opt/third_party/wiredtiger -Isrc/third_party/wiredtiger -I/data2/mark/opt/at11.0/lib/gcc/powerpc64le-linux-gnu/7.2.1/include -Ibuild/opt/third_party/wiredtiger/src/include -Isrc/third_party/wiredtiger/src/include build/scons/opt/sconf_temp/conftest_67.c
In file included from build/scons/opt/sconf_temp/conftest_67.c:2:0:
/data2/mark/opt/at11.0/lib/gcc/powerpc64le-linux-gnu/7.2.1/include/x86intrin.h:32:2: error: #warning "Please read comment above.  Use -DNO_WARN_X86_INTRINSICS to disable this warning." [-Werror=cpp]
 #warning "Please read comment above.  Use -DNO_WARN_X86_INTRINSICS to disable this warning."
  ^~~~~~~
In file included from /data2/mark/opt/at11.0/lib/gcc/powerpc64le-linux-gnu/7.2.1/include/x86intrin.h:39:0,
                 from build/scons/opt/sconf_temp/conftest_67.c:2:
/data2/mark/opt/at11.0/lib/gcc/powerpc64le-linux-gnu/7.2.1/include/mmintrin.h:52:2: error: #warning "Please read comment above.  Use -DNO_WARN_X86_INTRINSICS to disable this warning." [-Werror=cpp]

Comment by Peter Bergner [ 11/Jan/18 ]

Ok, I have verified the fix above does allow both the AT10 and AT11 builds to succeed.

Comment by Peter Bergner [ 11/Jan/18 ]

Ok, using AT11 to build mongodb git sources, I need an additional patch to fix a problem wrt ucontext usage in mongodb caused by a recent glibc change. That glibc change is described here:

https://sourceware.org/glibc/wiki/Release/2.26#Removal_of_.27struct_ucontext.27

With the following patch, I get a successful build. I do want to rerun the AT10 build to make sure the ucontext change doesn't affect that build.

diff --git a/src/third_party/gperftools-2.5/src/stacktrace_powerpc-linux-inl.h b/src/third_party/gperftools-2.5/src/stacktrace_powerpc-linux-inl.h
index 5d16fa1..7654c53 100644
— a/src/third_party/gperftools-2.5/src/stacktrace_powerpc-linux-inl.h
+++ b/src/third_party/gperftools-2.5/src/stacktrace_powerpc-linux-inl.h
@@ -51,8 +51,9 @@
#include <sys/ucontext.h>
#elif defined(HAVE_UCONTEXT_H)
#include <ucontext.h> // for ucontext_t
-#endif
+#else
typedef ucontext ucontext_t;
+#endif

// PowerPC64 Little Endian follows BE wrt. backchain, condition register,
// and LR save area, so no need to adjust the reading struct.
diff --git a/src/third_party/wiredtiger/SConscript b/src/third_party/wiredtiger/SConscript
index 1e07852..9f8df66 100644
— a/src/third_party/wiredtiger/SConscript
+++ b/src/third_party/wiredtiger/SConscript
@@ -36,7 +36,7 @@ if conf.CheckFunc("sync_file_range"):
"HAVE_SYNC_FILE_RANGE"
])

-if conf.CheckCHeader('x86intrin.h'):
+if (env['TARGET_ARCH'] == 'x86_64' and conf.CheckCHeader('x86intrin.h')):
conf.env.Append(CPPDEFINES=[
"HAVE_X86INTRIN_H"
])

Comment by Calvin Sze [ 11/Jan/18 ]

Hi Mark,

I tried both 3.4.4 and 3.6.1 Mongodb, both have this issue.
The AT version I used is 11.0.2, You are right, the 11.0 does not have the x86intrin.h file

Comment by Mark Benvenuto [ 11/Jan/18 ]

What version of MongoDB are you building? After I make the fix, I want to make sure I backport it the right release.

Comment by Peter Bergner [ 11/Jan/18 ]

Slight typo (missing ')') on the patch which I'm testing now.

diff --git a/src/third_party/wiredtiger/SConscript b/src/third_party/wiredtiger/SConscript
index 5d36706..529bd9f 100644
— a/src/third_party/wiredtiger/SConscript
+++ b/src/third_party/wiredtiger/SConscript
@@ -41,7 +41,7 @@ if conf.CheckFunc("sync_file_range"):
"HAVE_SYNC_FILE_RANGE"
])

-if conf.CheckCHeader('x86intrin.h'):
+if (env['TARGET_ARCH'] == 'x86_64' and conf.CheckCHeader('x86intrin.h')):
conf.env.Append(CPPDEFINES=[
"HAVE_X86INTRIN_H"
])

Comment by Peter Bergner [ 11/Jan/18 ]

Please note that this is NOT an AT 11 issue. Current GCC trunk (soon to be GCC 8) will also have the x86intrin.h file added as Bill mentions, so future distro compilers will also hit this issue. This is noticed in AT 11, because the x86 intrinsic compat support was back ported to AT 11.

That said, I had a look at SConscript, and maybe we can solve this problem with the following patch?

— src/third_party/wiredtiger/SConscript.orig 2018-01-10 19:35:50.532058937 -0600
+++ src/third_party/wiredtiger/SConscript 2018-01-10 19:37:23.992631076 -0600
@@ -41,7 +41,7 @@
"HAVE_SYNC_FILE_RANGE"
])

-if conf.CheckCHeader('x86intrin.h'):
+if (env['TARGET_ARCH'] == 'x86_64' and conf.CheckCHeader('x86intrin.h'):
conf.env.Append(CPPDEFINES=[
"HAVE_X86INTRIN_H"
])

Comment by Bill Schmidt [ 10/Jan/18 ]

The most recent version of AT 11.0 added this file as an aid to help people port x86 vector intrinsics to Power VSX intrinsics. It should only be used when building an application if neither generic code nor Power-specific code is available. It contains a #warning (soon to be changed to an #error) that including the file should only be done under control of a specific -D define. Using an #error would have caught this problem sooner. Usual configury practice is to test whether a function provided by an include file succeeds. Would this be possible?

Comment by Mark Benvenuto [ 10/Jan/18 ]

What version of MongoDB are you compiling? Are you cross-compiling?

The header file should only exist on x86 and so scons should not have defined that flag. I cannot find it in AT 11.0 for instance on my RHEL 7 PPC64LE box.

Generated at Thu Feb 08 04:30:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.