Multiply defined symbols compiling with gcc@10.1.0
System information
- OS: (
cat /etc/os-release | grep "NAME"
)
spack@lap-fey2> cat /etc/os-release | grep NAME
NAME="CentOS Linux"
PRETTY_NAME="CentOS Linux 7 (Core)"
CPE_NAME="cpe:/o:centos:centos:7"
- Kernel version: (run
uname -a
)
spack@lap-fey2> uname -a
Linux lap-fey2.lanl.gov 3.10.0-1127.13.1.el7.x86_64 #1 SMP Tue Jun 23 15:46:38 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Describe the issue
GNU compilers before version 10 defaulted to -fcommon
but gcc 10.x now defaults to -fno-common
(see https://gcc.gnu.org/gcc-10/porting_to.html). As a result, Mesa fails to build due to a common global C variable definition in 2 source files:
spack@lap-fey2> grep -r symbols_hash .
./src/gallium/auxiliary/util/u_debug_stack.c:struct hash_table* symbols_hash;
./src/gallium/auxiliary/util/u_debug_stack.c: if(!symbols_hash)
./src/gallium/auxiliary/util/u_debug_stack.c: symbols_hash = util_hash_table_create_ptr_keys();
./src/gallium/auxiliary/util/u_debug_stack.c: name = util_hash_table_get(symbols_hash, addr);
./src/gallium/auxiliary/util/u_debug_stack.c: _mesa_hash_table_insert(symbols_hash, addr, (void*)name);
./src/gallium/auxiliary/util/u_debug_symbol.c:struct hash_table* symbols_hash;
./src/gallium/auxiliary/util/u_debug_symbol.c: if(!symbols_hash)
./src/gallium/auxiliary/util/u_debug_symbol.c: symbols_hash = util_hash_table_create_ptr_keys();
./src/gallium/auxiliary/util/u_debug_symbol.c: name = util_hash_table_get(symbols_hash, (void*)addr);
./src/gallium/auxiliary/util/u_debug_symbol.c: _mesa_hash_table_insert(symbols_hash, (void*)addr, (void*)name);
The fix is to simply change the definition of symbols_hash
in these two files to unique names.
Regression
Compiles with gcc 10.x using -fcommon