Repoduces an issue with using thread_local in header only libraries when consumed by shared libraries and the main executable.
Build & Run:
mkdir build
cd build
cmake -G Ninja .. -DCMAKE_BUILD_TYPE=Release
ninja all
./thread_local_test
Example output gcc (5.4.0 and 8.1):
static int* i; &i:0x7fe8d20ea738, i:(nil)
static int* i; &i:0x7fe8d20ea730, i:(nil)
static int* i; &i:0x7fe8d20ea738, i:0xb99030
static int* i; &i:0x7fe8d20ea730, i:0xb99050
Example output clang:
static int* i; &i:0x7f3352e3e738, i:(nil)
static int* i; &i:0x7f3352e3e738, i:0x2571030
static int* i; &i:0x7f3352e3e738, i:0x2571030
static int* i; &i:0x7f3352e3e738, i:0x2571030