[Bug c++/113289] New: Error caused by attribute __always_inline__ in file waitpkgintrin.h

2024-01-09 Thread MacroModel at trajectronix dot onmicrosoft.com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113289

Bug ID: 113289
   Summary: Error caused by attribute __always_inline__ in file
waitpkgintrin.h
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: MacroModel at trajectronix dot onmicrosoft.com
  Target Milestone: ---

gcc -v
```bash
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=G:/x86_64-w64-mingw32/bin/../libexec/gcc/x86_64-w64-mingw32/14.0.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: /home/cqwrteur/toolchains_build/gcc/configure
--with-gxx-libcxx-include-dir=/home/cqwrteur/toolchains/x86_64-w64-mingw32/x86_64-w64-mingw32/include/c++/v1
--prefix=/home/cqwrteur/toolchains/x86_64-w64-mingw32/x86_64-w64-mingw32
--build=x86_64-pc-linux-gnu --host=x86_64-w64-mingw32
--target=x86_64-w64-mingw32 --disable-nls --disable-werror
--enable-languages=c,c++ --enable-multilib --disable-bootstrap
--disable-libstdcxx-verbose --with-libstdcxx-eh-pool-obj-count=0
--disable-sjlj-exceptions --enable-libstdcxx-threads
--enable-libstdcxx-backtrace
Thread model: win32
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20231231 (experimental) (GCC)
```

When I was compiling tbb(https://github.com/oneapi-src/oneTBB), I encountered
the following issues:

```bash
G:\x86_64-w64-mingw32\bin\x86_64-w64-mingw32-g++ -c -m64 -fvisibility=hidden
-fvisibility-inlines-hidden -Ofast -std=c++20 -Ithird_party\tbb\include
-finput-charset=UTF-8 -fexec-charset=UTF-8 -flto -DNDEBUG -o
build\.objs\tbb\mingw\x86_64\release\third_party\tbb\src\tbb\misc.cpp.obj
third_party\tbb\src\tbb\misc.cpp
error: In file included from
G:/x86_64-w64-mingw32/lib/gcc/x86_64-w64-mingw32/14.0.0/include/x86gprintrin.h:95,
 from
G:/x86_64-w64-mingw32/lib/gcc/x86_64-w64-mingw32/14.0.0/include/x86intrin.h:27,
 from G:/x86_64-w64-mingw32/include/intrin.h:69,
 from third_party\tbb\include/oneapi/tbb/detail/_machine.h:29,
 from third_party\tbb\include/oneapi/tbb/detail/_utils.h:27,
 from third_party\tbb\src\tbb\task_dispatcher.h:20,
 from third_party\tbb\src\tbb\arena.cpp:17:
G:/x86_64-w64-mingw32/lib/gcc/x86_64-w64-mingw32/14.0.0/include/waitpkgintrin.h:
In function 'tbb::detail::r1::prolonged_pause()':
G:/x86_64-w64-mingw32/lib/gcc/x86_64-w64-mingw32/14.0.0/include/waitpkgintrin.h:53:1:
error: inlining failed in call to 'always_inline' '_tpause': target specific
option mismatch
   53 | _tpause (unsigned int __A, unsigned long long __B)
  | ^~~
In file included from third_party\tbb\src\tbb\task_dispatcher.h:24:
third_party\tbb\src\tbb\scheduler_common.h:248:16: note: called from here
  248 | _tpause(0, time_stamp + 1000);
  | ~~~^~
G:/x86_64-w64-mingw32/lib/gcc/x86_64-w64-mingw32/14.0.0/include/waitpkgintrin.h:53:1:
error: inlining failed in call to 'always_inline' '_tpause': target specific
option mismatch
   53 | _tpause (unsigned int __A, unsigned long long __B)
  | ^~~
third_party\tbb\src\tbb\scheduler_common.h:248:16: note: called from here
  248 | _tpause(0, time_stamp + 1000);
  | ~~~^~
G:/x86_64-w64-mingw32/lib/gcc/x86_64-w64-mingw32/14.0.0/include/waitpkgintrin.h:53:1:
error: inlining failed in call to 'always_inline' '_tpause': target specific
option mismatch
   53 | _tpause (unsigned int __A, unsigned long long __B)
  | ^~~
third_party\tbb\src\tbb\scheduler_common.h:248:16: note: called from here
  248 | _tpause(0, time_stamp + 1000);
  | ~~~^~
```

I found that the file issue occurred in
G:\x86_64-w64-mingw32\lib\gcc\x86_64-w64-mingw32\14.0.0\include\waitpkgintrin.h
, line 52. When I removed the attribute __always_inline__, the compilation was
successful.

[Bug c++/115686] New: gcc cannot generate weak link function for thread_local variable `TLS init function`

2024-06-27 Thread MacroModel at trajectronix dot onmicrosoft.com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115686

Bug ID: 115686
   Summary: gcc cannot generate weak link function for
thread_local variable `TLS init function`
   Product: gcc
   Version: 15.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: MacroModel at trajectronix dot onmicrosoft.com
  Target Milestone: ---

gcc cannot generate weak link function for thread_local variable `TLS init
function`

```cpp

// h1.h

#include 
inline thread_local ::std::vector v{};

// c1.cpp

#include "h1.h"
int main()
{
v.push_back(1);
}

// c2.cpp

#include "h1.h"
void foo()
{
v.push_back(2);
}

```

compile:

```bash
g++ -o test c1.cpp c2.cpp -std=c++2c
G:/x86_64-w64-mingw32/bin/../lib/gcc/x86_64-w64-mingw32/15.0.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
C:\Users\User\AppData\Local\Temp\ccQoDAAa.o:c2.cpp:(.text+0x2a): multiple
definition of `TLS init function for v';
C:\Users\User\AppData\Local\Temp\ccjOPJhU.o:c1.cpp:(.text+0x33): first defined
here
```

gcc version:

```bash
Using built-in specs.
COLLECT_GCC=G:\x86_64-w64-mingw32\bin\g++.exe
COLLECT_LTO_WRAPPER=G:/x86_64-w64-mingw32/bin/../libexec/gcc/x86_64-w64-mingw32/15.0.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: /home/cqwrteur/toolchains_build/gcc/configure
--with-gxx-libcxx-include-dir=/home/cqwrteur/toolchains/x86_64-w64-mingw32/x86_64-w64-mingw32/include/c++/v1
--prefix=/home/cqwrteur/toolchains/x86_64-w64-mingw32/x86_64-w64-mingw32
--build=x86_64-pc-linux-gnu --host=x86_64-w64-mingw32
--target=x86_64-w64-mingw32 --disable-nls --disable-werror
--enable-languages=c,c++ --enable-multilib --disable-bootstrap
--disable-libstdcxx-verbose --enable-libstdcxx-static-eh-pool
--with-libstdcxx-eh-pool-obj-count=0 --disable-sjlj-exceptions
--enable-libstdcxx-threads --enable-libstdcxx-backtrace
Thread model: win32
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240622 (experimental) (GCC)
```