MinGW-w64's gcc and Address Sanitizer - c++

Installing MinGW-w64 5.1 I find -fsanitize=address is available. It compiles fine, and when it starts linking I get thousands of:
undefined reference to '__asan_report_load1'
undefined reference to '__asan_report_load4'
I googled and found libasan referenced various places, but also comments that when you include -fsanitize=address it automatically includes that library for linking. I searched the MinGW-w64 5.1 install dirctory for "asan" and it was not found anywhere.
What do I need to add on to use address sanitizing features in MinGW-w64? Thank you.

I've looked quickly into release notes for 4.8, 4.9 and 5.1 - ASAN is not available for Windows

Related

How to compile with clang and mingw-w64?

I'm trying to use clang10 with mingw-w64's libstdc++, since the MSVC headers don't support clang 10. I don't mind not having the new parts of the standard library, I just want to use the new language features.
I have mingw-w64 version 8.1.0 for x86_64 with POSIX threads and SEH exceptions installed and I run clang with a command:
clang++ -target x86_64-pc-windows-gnu -std=c++20 ...
Everything works OK. All the language features that should be implemented in clang 10 work, but when I throw any exception, this happens when I run the program (the program compiles OK):
Mingw-w64 runtime failure:
Unknown pseudo relocation protocol version 65536.
I tried installing mingw with SJLJ exceptions and use the -fsjlj-exceptions flag in clang, but the program doesn't even compile:
C:\Users\egst\AppData\Local\Temp\test-f4a4de.o:test.cpp:(.text+0x82): undefined reference to `__gxx_personality_sj0'
C:\Users\egst\AppData\Local\Temp\test-f4a4de.o:test.cpp:(.text+0xd9): undefined reference to `_Unwind_SjLj_Register'
C:\Users\egst\AppData\Local\Temp\test-f4a4de.o:test.cpp:(.text+0x177): undefined reference to `_Unwind_SjLj_Resume'
clang++ --version shows Target: x86_64-pc-windows-msvc. Maybe there's a version for x86_64-pc-windows-gnu that I should use instead? Is there any way to make this work at this moment, or should I wait for support from MSVC? Is there maybe any alternative besides MSVC and MinGW?
Based on #HolyBlackCat 's sugestion, I tried this with MSYS2 and it works perfectly. I simply installed MSYS2, then from the MSYS bash I installed this package. It installs everything in in ...\msys2\mingw64. You get clang 10 (+ gcc 9.3) and all the needed stl headers (still no c++20 headers like <concepts> though).

Missing symbols when using Clang with libc++ on CentOS 7 (no C++ ABI lib?)

The following packages were installed from repositories on CentOS 7.6:
clang-3.4.2-9.el7.x86_64
libcxx-3.8.0-3.el7.x86_64
libcxx-devel-3.8.0-3.el7.x86_64
Trying to build a simple C++ program:
clang++ -std=c++11 -stdlib=libc++ junk.cpp
This results in a bunch of linker errors, an example is:
/bin/../lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/libc++.so: undefined reference to `__cxa_throw'
AFAIK, this seems to be a problem of missing C++ ABI library, but I can't figure out how to install one that would provide the needed symbols. I could probably build one from source, but would like to stick with what's available from trustworthy repositories.
Any ideas on how to fix this?
I can build the program just fine if -stdlib=libc++ is omitted, in which case libstdc++ is used.
Try passing -lc++abi manually. This problem is fixed in modern installations, but the Linux packages aren't modern. Consider using apt.llvm.org

gcc build behavior when there is are conflicting version of openssl

I am trying to build a c++ library of mine (which is dependent on facebook/folly) with gcc7. Some important points to note
Previously I was using gcc 4.8 to build this library
Since there is ABI incompatibility introduced in gcc 5.2 - I built folly from source (and all other dependent libraries like glog etc.) with gcc 7 - and I am using the updated libraries and shared objects.
My library uses openssl 1.1 (even previously when it was being built with gcc 4.8), where as folly (the version of folly that I am using) uses openssl 1.0.2
Even with the openssl version incompatibility the build of my library would go through fine with gcc 4.8 with the following warning
/usr/bin/ld: warning: libssl.so.10, needed by /home/<username>/folly/folly/1000.37.2.1/lib/libfolly.so, may conflict with libssl.so.1.1
I get the exact same warning with gcc 7 as well, but my build now fails with the following error
/usr/bin/ld: /home/<username>/folly/folly/1000.37.2.1/lib/libfolly.a(SSLSessionCacheManager.o): undefined reference to symbol 'SSL_CTX_get_ex_new_index##libssl.so.10'
/usr/lib64/libssl.so.10: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
I have tried researching this problem in regards to DSO missing from command line - but the solutions mentioned in other questions doesn't seem to be my case.
There are 3 questions that I am seeking to answer here
Can openssl version incompatibility be the reason for the build failure?
Why would the build succeed in gcc 4.8 but fail on gcc 7?
Is there an way to solve this without updating openssl version in folly (I will have to pull in a lot of changes for that - which will require code changes from my side). My library only uses openssl/md5.h

undefined references during link phase using Boost 1.53

I am using g++ 4.1.2 and Boost 1.53 on Red Hat Linux rel 5.5. There is an issue during the linking process which is unclear to me. I get the error msg:
/usr/local/boost_1_53_0/stage/lib/libboost_thread.so:
undefined reference to `std::bad_exception::what() const#GLIBCXX_3.4.9'
/usr/local/boost_1_53_0/stage/lib/libboost_thread.so:
undefined reference to `std::bad_alloc::what() const#GLIBCXX_3.4.9'
collect2: ld returned 1 exit status
There seems to be a problem related to the libstdc++.so file version I'm linking with. If I alternate hiding and revealing this file I can get my program to link. However, I would like to be able to 'make' in one step as I did before I introduced the Boost libraries and concurrent threading.
Please help shed some light on this issue if you have any insight.
Please try to install via yum.
yum install boost
You will not encouter such issues.
Try to include rpmforge and epel yum repositories.
http://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html#abi.versioning shows that GLIBCXX_3.4.9 is the symbol version used by the libstdc++.so from GCC 4.2.0, so if the Boost library wants that version then it means it was compiled with GCC 4.2.x
That means you can't use the library with a program linked by GCC 4.1.2, you need to link with GCC 4.2.0 or later
libstdc++.so is backward compatible but not forwards compatible, so you can compile a program with one version and link it to a newer version, but you can't compile with a newer version and link to an older version.

gcc 4.7.1 build ends with undefined reference

I am getting a
fortran/arith.o: In function gfc_mpfr_to_mpz(__mpz_struct*,
__mpfr_struct*, locus*)': arith.c:(.text+0x1169): undefined reference tompfr_get_z_2exp'
from gcc 4.7.1 build process. I am following
gcc-wiki
However, I have made a little change to the
download_prequisites
script. And that is I am downloading the latest releases of all the prequisites for gcc where the original one was downloading a bit older ones since the above link was given for gcc 4.6. However, it can not find some symbols related to mpfr library.
A related google search gives me this thread however it also did not help me, maybe someone else could understand that differently than me:
A similar thread
Any hints on how to resolve this problem?
I recently built gcc 4.7.1 for Mountain Lion and followed a very nice tutorial of how to do a gcc build. In it, it describes all the necessary lib compilations, include mpfr, gmp and others. If you're running linux, I think it will work for you as well, give it a try:
http://solarianprogrammer.com/2012/07/21/compiling-gcc-4-7-1-mac-osx-lion/
Let me know if that helps.