[all-commits] [llvm/llvm-project] a72dc8: tsan: tsan_interface.h: make constants static

Dmitry Vyukov via All-commits all-commits at lists.llvm.org
Tue Mar 10 01:14:14 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: a72dc86cddd26921f12184032e27abcc3be427cb
      https://github.com/llvm/llvm-project/commit/a72dc86cddd26921f12184032e27abcc3be427cb
  Author: Dmitry Vyukov <dvyukov at google.com>
  Date:   2020-03-10 (Tue, 10 Mar 2020)

  Changed paths:
    M compiler-rt/include/sanitizer/tsan_interface.h

  Log Message:
  -----------
  tsan: tsan_interface.h: make constants static

Note that in C++ the static keyword is implicit for const objects.
In C however it is not, and we get clashes at link time after
including the header from more than one C file:

lib.a(bar.o):(.rodata+0x0): multiple definition of `__tsan_mutex_linker_init'
lib.a(foo.o):(.rodata+0x0): first defined here
lib.a(bar.o):(.rodata+0xc): multiple definition of `__tsan_mutex_not_static'
lib.a(foo.o):(.rodata+0xc): first defined here
<snip>
Indeed both foo.o and bar.o define the clashing symbols:

$ nm foo.o
<snip>
0000000000000000 R __tsan_mutex_linker_init
000000000000000c R __tsan_mutex_not_static
<snip>
Fix it by explicitly making the constants static.

Reviewed-in: https://reviews.llvm.org/D75820
Author: cota (Emilio G. Cota)




More information about the All-commits mailing list