- 1 year ago
Mingw disable TLS ( thread local storage ) on Windows
To disable TLS (Thread Local Storage) in MinGW on Windows, you can use the -mno-tls-direct-seg-refs
compiler flag. This flag tells the compiler to disable the use of direct segment references for TLS variables. Here's how you can use it:
Open your command prompt or terminal.
Compile your code using the
-mno-tls-direct-seg-refs
flag. For example, if you're compiling a C file namedexample.c
, you can use the following command:gcc -mno-tls-direct-seg-refs example.c -o example.exe
Replace
example.c
with the name of your source file andexample.exe
with the desired output executable name.The resulting executable will be compiled with TLS disabled.
Note that by disabling TLS, you may affect the functionality of code that relies on thread-local storage. Make sure to test your code thoroughly after disabling TLS to ensure that it still behaves as expected.
Also, keep in mind that the availability and effectiveness of the -mno-tls-direct-seg-refs
flag may depend on the version of MinGW and the specific compiler you are using.