[cfe-dev] Latest clang from source breaks clang on Windows targeting gcc linking

Yaron Keren yaron.keren at gmail.com
Sat Aug 8 10:59:41 PDT 2015


I'm looking into this, see https://llvm.org/bugs/show_bug.cgi?id=24395
The solution is somewhat more compilcated but you can use the patch there
for now.


2015-08-08 20:20 GMT+03:00 Edward Diener <eldlistmailingz at tropicsoft.com>:

> Some change in the latest source has completely broken linking for clang
> on Windows targeting gcc.
>
> // ex_aclass.hpp
>
> #ifndef EX_ACLASS_HPP
> #define EX_ACLASS_HPP
> #if defined(BLD_EX_EXAMPLE)
>         #define EX_DECL __attribute__((__dllexport__))
> #else
>         #define EX_DECL __attribute__((__dllimport__))
> #endif
> class EX_DECL ex_aclass
> {
> public:
>     int a_function(long);
> };
> #endif // EX_ACLASS_HPP
>
> // ex_aclass.cpp
>
> #define BLD_EX_EXAMPLE
> #include "ex_aclass.hpp"
> int ex_aclass::a_function(long amt)
>         {
>         return(amt > 1000000 ? 10 : 20);
>         }
>
> // Compile ex_aclass.cpp
>
> clang++.exe -c -x c++ -D__MINGW_FORCE_SYS_INTRINS -O0 -g -fno-inline -Wall
> -g -march=i686 -m32 -o "ex_aclass.obj" "ex_aclass.cpp"
>
> // Link into ex_ac.dll
>
> clang++.exe" -o "ex_ac.dll" -Wl,-soname -Wl,ex_ac.dll -shared
> -Wl,--start-group "ex_aclass.obj" -Wl,-Bstatic -Wl,-Bdynamic
> -Wl,--end-group -g -march=i686 -m32
>
> libmingw32.a(lib32_libmingw32_a-pseudo-reloc.o):pseudo-reloc.c:(.text+0x1d6):
> undefined reference to `__chkstk_ms'
> clang++.exe: error: linker command failed with exit code 1 (use -v to see
> invocation)
>
> Nor does it matter what source file is used in general, whenever the link
> is done for anything the "undefined reference to `__chkstk_ms'" occurs.
>
> Can some one of the clang developers please look at this ?
>
> I am using clang on Windows with the 32-bit version of mingw-64/gcc-5.1 as
> i686-5.1.0-posix-dwarf-rt_v4-rev0.
>
> I realize the current problems for clang on Windows targeting gcc may have
> occurred trying to fix a more specific problem I reported in two other
> threads about linkage failure using dllexport and dllimport attributes on
> Windows, but going from a situation where a specific problem broke the
> linking to all situations are broken when attempting to link is not good.
>
> I tried looking at the clang unit tests and how they can be run on Windows
> but found very little information about both. I wouldn't mind contributing
> some basic unit tests, even though I am not a clang developer, just to make
> sure that clang on Windows targeting gcc will work when compiling/linking
> dlls and using those dlls from another module, if I could understand what
> to do. That way such a snafu as this latest breakage would not occur so
> easily as whatever broke in the change should have been caught by some unit
> tests.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150808/d507cb93/attachment.html>


More information about the cfe-dev mailing list