[Qbs] (no subject)

Dan Pat dannix84 at gmail.com
Fri Nov 29 08:03:34 CET 2019


 > Who imposes that requirement and why?
Ok. Here's the thing. The project I am working on is based on Qt library
and consists of a bunch of libraries and executables with dependencies
between them expressed via a "Depends" language item. Plus there a number
of pre-built third-party libraries wrapped in Modules that some of the
Products within the project depend on. The project compiles and links and I
can run the executables just fine. Now comes Asan. We use a dynamic version
of Asan, since the CRT we use is dynamic (compilation with /MD option) .
The first step was to compile the project with sanitiser support. I managed
that, but I when tried to to run one of the tests, Asan reported an error.
I did a bit of research and figured out that the error was detected early
on during initialization of Qt DLLs. From what I have been able to find out
from Internet sources and through a  bit of testing I concluded that for
the sanitizer to work properly, the asan.dll must be loaded before any
other DLL in the process, specifically before the C runtime library,
because it needs to do some hotpatching in order to be able trace every
heap allocation call. In my case, seemingly, the asan.dll was loaded
somewhere in the middle of the DLL loading sequence when some of the heap
allocation has already been done resulting in a false error report. My
research revealed that in order for the asan.dll to be loaded first, its
import record in the binary IAT must come first, and for the import record
to come first the corresponding import library must come first on the
linker's list of imports. The asan library is contained in a Module, and I
have no idea how to get its import to the beginning of the linker's list.
Let's consider an example Product. Looking at an issued linker command:
Module dependencies are listed after any Product dependencies, any
libraries specified directly in cpp.dynamicLibraries (as an experiment, we
normally use Depends) come before Module dependencies but after any Product
dependencies, any cpp,linkerFlags (tried as a last resort) go the end of
the linker's arguments string.  I hope I have made myself clear, thank you.

чт, 28 нояб. 2019 г. в 21:37, Иван Комиссаров <abbapoh at gmail.com>:

> It’s worth mentioning, that compiling with verbose flag can give some
> insight on what libraries/options clang-cl passes to the linker:
>
> clang-cl -v -fsanitize=address main.cpp
>
> Иван Комиссаров
>
> 28 нояб. 2019 г., в 17:23, Иван Комиссаров <abbapoh at gmail.com> написал(а):
>
> I did a small research and was able to compile a small example with
> clang-cl and asan.
> Here are the flags I had to set manually:
>
>
> cpp.optimization: "none"
>
>     cpp.cxxFlags: [
>
>         "/MT",
>
>         "-fsanitize=address",
>
>     ]
>
>     cpp.linkerFlags: [
>
>
> "-wholearchive:C:\\Developer\\LLVM\\lib\\clang\\8.0.0\\lib\\windows\\clang_rt.asan-x86_64.lib",
>
>
> "-wholearchive:C:\\Developer\\LLVM\\lib\\clang\\8.0.0\\lib\\windows\\clang_rt.asan_cxx-x86_64.lib",
>
>     ]
>
>     cpp.staticLibraries: [
>
>
> "C:\\Developer\\LLVM\\lib\\clang\\8.0.0\\lib\\windows\\clang_rt.asan-x86_64.lib",
>
>
> "C:\\Developer\\LLVM\\lib\\clang\\8.0.0\\lib\\windows\\clang_rt.asan_cxx-x86_64.lib",
>
>     ]
>
> Probably, we should add some support for that in Qbs...
> The problem is that qbs calls the linker directly (which is not the same
> clang-cl uses), maybe it’s worth using clang-cl for linking... or just add
> support for the usual clang with msvc ABI (I have plans for that for 1.16)
>
> Иван Комиссаров
>
> 28 нояб. 2019 г., в 15:53, Christian Kandeler <Christian.Kandeler at qt.io>
> написал(а):
>
> On Thu, 28 Nov 2019 18:58:54 +0500
> Dan Pat <dannix84 at gmail.com> wrote:
>
> Hello. I am trying to use Asan in my project (windows 10, clang-cl).
>
> There's a requirement for the Asan import library to appear first in the
>
> linker's list of import libraries.
>
>
> Who imposes that requirement and why?
>
> I cannot seem to find a way to achieve this with qbs. Any suggestions?
>
>
> If you are sure it's really, really needed, you can use a Properties item
> in your product with e.g. cpp.dynamicLibraries (
> https://doc.qt.io/qbs/qml-qbslanguageitems-properties.html#overrideListProperties-prop),
> but then you will have to list *all* libraries there.
>
>
> Christian
> _______________________________________________
> Qbs mailing list
> Qbs at qt-project.org
> https://lists.qt-project.org/listinfo/qbs
>
> _______________________________________________
> Qbs mailing list
> Qbs at qt-project.org
> https://lists.qt-project.org/listinfo/qbs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20191129/e6e23267/attachment-0001.html>


More information about the Qbs mailing list