[MDEV-26136] Build fails when using gcc installed by homebrew Created: 2021-07-13  Updated: 2022-04-18  Resolved: 2022-04-04

Status: Closed
Project: MariaDB Server
Component/s: Compiling
Affects Version/s: 10.6
Fix Version/s: 10.2.44, 10.3.35, 10.4.25, 10.5.16, 10.6.8, 10.7.4, 10.8.3

Type: Bug Priority: Critical
Reporter: Kento Takeuchi Assignee: Daniel Black
Resolution: Fixed Votes: 0
Labels: None
Environment:

macOS BigSur 11.4
gcc 11.1.0
g++ 11.1.0
cmake 3.19.7
mariadb 10.6 commit: a841069



 Description   

Build fails when using gcc installed by homebrew.

Environments:

$  uname -sr 
Darwin 20.5.0
$ gcc --version
gcc (Homebrew GCC 11.1.0_1) 11.1.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ g++ --version
g++ (Homebrew GCC 11.1.0_1) 11.1.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ cmake --version
cmake version 3.19.7
CMake suite maintained and supported by Kitware (kitware.com/cmake).

Build:

$ cd build
$ cmake -DCMAKE_C_COMPILER=/usr/local/bin/gcc -DCMAKE_CXX_COMPILER=/usr/local/bin/g++ ..
$ cmake --build . --config Debug -j 8
 
.....
In file included from server/sql/structs.h:26,
                 from server/sql/handler.h:34,
                 from server/storage/innobase/include/trx0xa.h:27,
                 from server/storage/innobase/include/trx0trx.h:34,
                 from server/storage/innobase/btr/btr0pcur.cc:30:
server/include/my_time.h: In function 'void my_timeval_trunc(timeval*, uint)':
server/include/my_time.h:249:65: error: conversion from 'long int' to '__darwin_suseconds_t' {aka 'int'} may change value [-Werror=conversion]
  249 |   tv->tv_usec-= my_time_fraction_remainder(tv->tv_usec, decimals);
.....

https://opensource.apple.com/source/xnu/xnu-4570.41.2/bsd/sys/_types/_timeval.h.auto.html

The reason is that the data type of the tv_usec member of the timeval structure used by gcc installed by homebrew is __darwin_suseconds_t, and __darwin_suseconds_t is declared as __int32_t.



 Comments   
Comment by Marko Mäkelä [ 2021-09-10 ]

For the record, a similar warning is reported when building on IBM AIX:

10.7 ddcb242b3cd2e95bcf4c950bffaafc0775db45ee

/home/mdborg/mariadb-server/include/my_time.h: In function 'void my_timeval_trunc(timeval*, uint)':
/home/mdborg/mariadb-server/include/my_time.h:249:65: warning: conversion from 'long int' to 'suseconds_t' {aka 'int'} may change value [-Wconversion]
   tv->tv_usec-= my_time_fraction_remainder(tv->tv_usec, decimals);

Comment by Daniel Black [ 2022-04-01 ]

shulga, kento-takeuchi, I'm fairly sure https://github.com/MariaDB/server/pull/2079 is right, however if you could test it that would be appreciated.

Comment by Daniel Black [ 2022-04-04 ]

Fix pushed. Thanks kento-takeuchi for the bug report. Please reopen if it doesn't work for some reason.

Comment by Kento Takeuchi [ 2022-04-11 ]

danblack Thank you. I'll check it in my machine

Comment by Kento Takeuchi [ 2022-04-18 ]

danblack I confirmed this fix and build completes successfully. Thank you!

Comment by Daniel Black [ 2022-04-18 ]

kento-takeuchi thanks for confirming. Happy compilations.

Generated at Thu Feb 08 09:43:01 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.