<div dir="ltr"><div>I bet clang doesn't like that the LAZY() macros are referring to 
OPENSSL_UplinkTable before it's been defined. To test this theory: does it work if you move the LAZY()s after the table? (I guess you'd need to forward-declare the lazy##i functions then too.)</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 25, 2019 at 11:38 AM Tobias Hieta via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br>
<br>
As part of our efforts to replace MSVC with Clang on Windows we have<br>
started to rebuild our dependencies with clang-cl and lld-link.<br>
<br>
Most dependencies just needs very small adjustments to work, but one<br>
of our dependencies are OpenSSL. It required some editing of the build<br>
system to call clang-cl instead of clang. At the start I thought it<br>
worked just fine because it came all the way to the linking phase -<br>
but that then failed because the linker was running in 32 bit mode and<br>
it said that clang-cl had built 64 bit binaries. Turns out that I had<br>
to make more adjustments to forward the -m32 flag to clang-cl to get<br>
it to build. This unfortunately totally broke the build:<br>
<br>
clang-cl -m32 /Fotmp32dll\uplink.obj -Iinc32 -Itmp32dll /MD /Ox /O2<br>
/Ob2 -DOPENSSL_THREADS -DDSO_WIN32 -DW<br>
INVER=0x0601 -D_WIN32_WINNT=0x0601 -W3 -Gs0 -GF -Gy -nologo<br>
-DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN<br>
-D_CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS<br>
-DOPENSSL_BN_ASM_PART<br>
_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m<br>
-DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM<br>
-DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DOPENSSL<br>
_USE_APPLINK -I. -DOPENSSL_NO_RC5 -DOPENSSL_NO_MD2 -DOPENSSL_NO_SSL2<br>
-DOPENSSL_NO_KRB5 -DOPENSSL_NO_JPAKE -DOPENSSL_NO_WEAK_SSL_CIPHERS<br>
-DOPENSSL_NO_STATIC_ENGINE /Zi /Fdtmp32dll/lib -D_WINDLL -c ms\<br>
uplink.c<br>
ms\uplink.c(106,1): error: asm operand has incomplete type 'void *[]'<br>
LAZY(1) LAZY(2) LAZY(3) LAZY(4) LAZY(5)<br>
^<br>
ms\uplink.c(97,29): note: expanded from macro 'LAZY'<br>
_asm push OFFSET OPENSSL_UplinkTable \<br>
^<br>
ms\uplink.c(106,1): error: asm operand has incomplete type 'void *[]'<br>
ms\uplink.c(100,22): note: expanded from macro 'LAZY'<br>
_asm jmp OPENSSL_UplinkTable+4*i }<br>
^<br>
ms\uplink.c(106,1): error: use of undeclared label 'OPENSSL_UplinkTable'<br>
ms\uplink.c(100,22): note: expanded from macro 'LAZY'<br>
_asm jmp OPENSSL_UplinkTable+4*i }<br>
^<br>
<br>
Dropping the -m32 flag makes this build without a problem. I had to<br>
dig around in the source and it seems like the _asm flags are only<br>
evaluated when we are building 32 bit which explains why it worked<br>
with 64bit, relevant code here:<br>
<br>
<a href="https://github.com/openssl/openssl/blob/OpenSSL_1_0_2-stable/ms/uplink.c#L95" rel="noreferrer" target="_blank">https://github.com/openssl/openssl/blob/OpenSSL_1_0_2-stable/ms/uplink.c#L95</a><br>
<br>
Is this expected? Just a missing feature of Clang?<br>
<br>
Thanks,<br>
Tobias<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>