clang-cl question

I'm experimenting with building LibreOffice on Windows with the clang-cl wrapper (and that looks really promising nowadays; it looked much worse when I naively tried last time). I'm using a recent Clang trunk build.

After some trial and error, I get along quite well for a while with passing

C:/clang/build/Debug/bin/clang-cl.exe -fmsc-version=1700 -Qunused-arguments --target=x86_64-windows-mscv

as CC and CXX into LibreOffice's build system (which heavily expects the compiler to be MSVC on Windows, of course).

However, one place that is causing trouble is code calling RtlSecureZeroMemory, which leads to referencing an unresolved external symbol __stosb during linking. The definition of RtlSecureZeroMemory in winnt.h is using

#if defined(_M_AMD64)
__stosb(...)

where __stosb is apparently an MSVC intrinsic, and I see an inline definition of it in the Clang installation's lib/clang/3.8.0/include/Intrin.h, but that include file is apparently not used when compiling the above code.

When I manually #include <Intrin.h> into the LibreOffice source file that calls RtlSecureZeroMemory, compiling and linking succeeds, but I'm not sure that's the intended setup. Am I missing something how to set up things so that Clang's Intrin.h gets picked up automatically (or is this the wrong approach to fix things anyway)?

Hi Stephan,

#pragma intrinsic isn’t implemented yet, this is http://llvm.org/PR19898 . As a workaround, you can pass /FIIntrin.h in your compiler flags, then things should work.

Slides 83-88 of this deck give some advice such as this for using clang-cl in practice: https://docs.google.com/presentation/d/1oxNHaVjA9Gn_rTzX6HIpJHP7nXRua_0URXxxJ3oYRq0/edit#slide=id.p

Nico

Ah, those slides are reassuring; thanks!

(Btw, ran into a case where I also need to pass in -D_CRT_RAND_S= to cl-clang in addition to -FIIntrin.h, for a file that does

   #define _CRT_RAND_S
   #include <stdlib.h>

and Intrin.h apparently (indirectly) includes stdlib.h, too.)