<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body smarttemplateinserted="true" bgcolor="#FFFFFF" text="#000000">
    <div id="smartTemplate4-template">
      <p> CMAKE_REQUIRED_LIBRARIES is empty and out-of-tree build with
        removed CMake flags didn't help. <br>
      </p>
    </div>
    <p><br>
    </p>
    <br>
    <div id="smartTemplate4-quoteHeader">------ Original Message ------<br>
      Subject: Re: [cfe-dev] [libc++] Compiling with MinGW-w64<br>
      Date: Thu, 23 Mar 2017 05:31:02 -0600<br>
      To: Mateusz Mikuła<br>
      From: Eric Fiselier</div>
    <blockquote
cite="mid:CAB=TDAU3pR_PeA=v-feLyLhHyj4GNm1-jAbRia1OR9LsN7Kk8Q@mail.gmail.com"
      type="cite">
      <div dir="ltr">Also what's your exact CMake invocation?
        <div><br>
        </div>
        <div>/Eric</div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Thu, Mar 23, 2017 at 5:29 AM, Eric
          Fiselier <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:eric@efcs.ca" target="_blank">eric@efcs.ca</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="ltr"><br>
              <div class="gmail_extra"><br>
                <div class="gmail_quote"><span class="">On Thu, Mar 23,
                    2017 at 4:55 AM, Mateusz Mikuła <span dir="ltr"><<a
                        moz-do-not-send="true"
                        href="mailto:mati865@gmail.com" target="_blank">mati865@gmail.com</a>></span>
                    wrote:<br>
                    <blockquote class="gmail_quote" style="margin:0px
                      0px 0px 0.8ex;border-left:1px solid
                      rgb(204,204,204);padding-left:1ex">
                      <div bgcolor="#FFFFFF">
                        <div
id="m_-8342469880804593719gmail-m_-4175624814147688239smartTemplate4-template">
                          <p> Yes, logs come from unmodified build of
                            in-tree build of libc++.</p>
                          <p>Here is NODEFAULTLIBS check<br>
                          </p>
                          <blockquote>
                            <p>Performing C++ SOURCE FILE Test
                              LIBCXXABI_HAS_NODEFAULTLIBS_FL<wbr>AG
                              succeeded with the following output:<br>
                              Change Dir:
                              D:/projekty/msys2/MINGW-packag<wbr>es/mingw-w64-clang/src/build-<wbr>i686/CMakeFiles/CMakeTmp<br>
                              <br>
                              Run Build Command:"D:/msys64/usr/bin/mak<wbr>e.exe"
                              "cmTC_a0b32/fast"<br>
                              /usr/bin/make -f
                              CMakeFiles/cmTC_a0b32.dir/buil<wbr>d.make
                              CMakeFiles/cmTC_a0b32.dir/buil<wbr>d<br>
                              [1;34mmake[1]: [0m Entering directory
                              '/d/projekty/msys2/MINGW-packa<wbr>ges/mingw-w64-clang/src/build-<wbr>i686/CMakeFiles/CMakeTmp'<br>
                              Building CXX object
                              CMakeFiles/cmTC_a0b32.dir/src.<wbr>cxx.obj<br>
                              /D/msys64/mingw32/bin/g++.exe <wbr>   
                              -D_GNU_SOURCE -Wall -W
                              -Wno-unused-parameter -Wwrite-strings
                              -Wcast-qual -Wno-missing-field-initializer<wbr>s
                              -pedantic -Wno-long-long
                              -Wno-maybe-uninitialized
                              -Wdelete-non-virtual-dtor -Wno-comment
                              -Werror=date-time -std=gnu++11
                              -DLIBCXXABI_HAS_NODEFAULTLIBS_<wbr>FLAG  
                              -nodefaultlibs -o
                              CMakeFiles/cmTC_a0b32.dir/src.<wbr>cxx.obj
                              -c
                              /D/projekty/msys2/MINGW-packag<wbr>es/mingw-w64-clang/src/build-<wbr>i686/CMakeFiles/CMakeTmp/src.<wbr>cxx<br>
                              Linking CXX executable cmTC_a0b32.exe<br>
                              /D/msys64/mingw32/bin/cmake.ex<wbr>e -E
                              remove -f CMakeFiles/cmTC_a0b32.dir/obje<wbr>cts.a<br>
                              /D/msys64/mingw32/bin/ar.exe cr
                              CMakeFiles/cmTC_a0b32.dir/obje<wbr>cts.a
                              "CMakeFiles/cmTC_a0b32.dir/src<wbr>.cxx.obj"
                              <br>
                              /D/msys64/mingw32/bin/g++.exe 
                              -D_GNU_SOURCE -Wall -W
                              -Wno-unused-parameter -Wwrite-strings
                              -Wcast-qual -Wno-missing-field-initializer<wbr>s
                              -pedantic -Wno-long-long
                              -Wno-maybe-uninitialized
                              -Wdelete-non-virtual-dtor -Wno-comment
                              -Werror=date-time -std=gnu++11
                              -DLIBCXXABI_HAS_NODEFAULTLIBS_<wbr>FLAG 
                              -pipe -Wl,--stack,16777216 
                              -Wl,--whole-archive
                              CMakeFiles/cmTC_a0b32.dir/obje<wbr>cts.a
                              -Wl,--no-whole-archive  -o cmTC_a0b32.exe
                              -Wl,--major-image-version,0,--<wbr>minor-image-version,0
                              -lkernel32 -luser32 -lgdi32 -lwinspool
                              -lshell32 -lole32 -loleaut32 -luuid
                              -lcomdlg32 -ladvapi32 <br>
                              [1;34mmake[1]: [0m Leaving directory
                              '/d/projekty/msys2/MINGW-packa<wbr>ges/mingw-w64-clang/src/build-<wbr>i686/CMakeFiles/CMakeTmp'<br>
                              <br>
                              Source file was:<br>
                              int main() { return 0; }</p>
                            <p><br>
                            </p>
                          </blockquote>
                        </div>
                        I'll try out of tree build soon.<br>
                      </div>
                    </blockquote>
                    <div><br>
                    </div>
                  </span>
                  <div>I don't think that will make a difference. LLVM
                    isn't adding these libraries AFAIK. They must be
                    getting automatically added by CMake.</div>
                  <div>Can you check if they're getting added via
                    "CMAKE_REQUIRED_LIBRARIES"?</div>
                  <div><br>
                  </div>
                  <div>I've been looking for CMake documentation about
                    this but I can't find anything.</div>
                  <span class="HOEnZb"><font color="#888888">
                      <div><br>
                      </div>
                      <div>/Eric</div>
                    </font></span>
                  <div>
                    <div class="h5">
                      <div><br>
                      </div>
                      <div><br>
                      </div>
                      <blockquote class="gmail_quote" style="margin:0px
                        0px 0px 0.8ex;border-left:1px solid
                        rgb(204,204,204);padding-left:1ex">
                        <div bgcolor="#FFFFFF"> <br>
                          <br>
                          <div
id="m_-8342469880804593719gmail-m_-4175624814147688239smartTemplate4-quoteHeader">------ Original Message ------<br>
                            Subject: Re: [cfe-dev] [libc++] Compiling
                            with MinGW-w64<br>
                            Date: Thu, 23 Mar 2017 02:34:09 -0600<br>
                            To: Mateusz Mikuła<br>
                            From: Eric Fiselier</div>
                          <div>
                            <div class="m_-8342469880804593719gmail-h5">
                              <blockquote type="cite">
                                <div dir="ltr">Just to verify you're not
                                  manually adding any of the following
                                  libraries, right?
                                  <div><br>
                                  </div>
                                  <div><span style="color:rgb(0,0,0);font-family:menlo,consolas,monaco,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(255,254,245)">-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32</span><br>
                                  </div>
                                  <div><span style="color:rgb(0,0,0);font-family:menlo,consolas,monaco,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(255,254,245)">
</span></div>
                                  <div><span style="color:rgb(0,0,0);font-family:menlo,consolas,monaco,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(255,254,245)">/Eric</span></div>
                                </div>
                                <div class="gmail_extra"><br>
                                  <div class="gmail_quote">On Wed, Mar
                                    22, 2017 at 7:04 PM, Eric Fiselier <span
                                      dir="ltr"><<a
                                        moz-do-not-send="true"
                                        href="mailto:eric@efcs.ca"
                                        target="_blank">eric@efcs.ca</a>></span>
                                    wrote:<br>
                                    <blockquote class="gmail_quote"
                                      style="margin:0px 0px 0px
                                      0.8ex;border-left:1px solid
                                      rgb(204,204,204);padding-left:1ex">
                                      <div dir="ltr"><br>
                                        <div class="gmail_extra"><br>
                                          <div class="gmail_quote"><span>On
                                              Fri, Mar 17, 2017 at 4:34
                                              PM, Mateusz Mikuła via
                                              cfe-dev <span dir="ltr"><<a
                                                  moz-do-not-send="true"
href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span>
                                              wrote:<br>
                                              <blockquote
                                                class="gmail_quote"
                                                style="margin:0px 0px
                                                0px
                                                0.8ex;border-left:1px
                                                solid
                                                rgb(204,204,204);padding-left:1ex">
                                                <div bgcolor="#FFFFFF">
                                                  <p>Hello,</p>
                                                  <p>I'm planing to get
                                                    libc++ compiling
                                                    with MinGW-w64,
                                                    right now without
                                                    patches it fails
                                                    with:</p>
                                                  <blockquote>
                                                    <p>CMake Error at
                                                      projects/libcxx/CMakeLists.txt<wbr>:396
                                                      (message):<br>
                                                        C++11 or greater
                                                      is required but
                                                      the compiler does
                                                      not support c++11</p>
                                                  </blockquote>
                                                  <p>It is caused by
                                                    adding
                                                    `-nodefaultlibs`
                                                    flag (it passes it's
                                                    own check <a
                                                      moz-do-not-send="true"
href="https://github.com/llvm-mirror/libcxx/blob/master/cmake/config-ix.cmake#L27"
                                                      target="_blank">[1]</a>).
                                                    However many
                                                    following checks
                                                    fail due to
                                                    undefined
                                                    references, results
                                                    with gcc <a
                                                      moz-do-not-send="true"
href="https://reviews.llvm.org/P7975" target="_blank">[2]</a> and clang
                                                    <a
                                                      moz-do-not-send="true"
href="https://reviews.llvm.org/P7976" target="_blank">[3]</a>.</p>
                                                </div>
                                              </blockquote>
                                            </span>
                                            <div>CMake seems to be
                                              adding system libraries
                                              automagically.
                                              Specifically it adds <span style="background-color:rgb(255,254,245);color:rgb(0,0,0);font-family:menlo,consolas,monaco,monospace;font-size:12px;white-space:pre-wrap"> -lgcc_s -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32.</span></div>
                                            <div>I'm guessing that these
                                              libraries are where the
                                              undefined symbols are
                                              coming from, and I suspect
                                              the correct fix is to
                                              somehow prevent CMake from
                                              adding them.</div>
                                            <div><br>
                                            </div>
                                            <div><br>
                                            </div>
                                            <div><br>
                                            </div>
                                            <blockquote
                                              class="gmail_quote"
                                              style="margin:0px 0px 0px
                                              0.8ex;border-left:1px
                                              solid
                                              rgb(204,204,204);padding-left:1ex"><span>
                                                <div bgcolor="#FFFFFF">
                                                  <p>Hard-coding 0 for
                                                    LIBCXX_SUPPORTS_NODEFAULTLIBS_<wbr>FLAG
                                                    allows it go finish
                                                    configuration and
                                                    fail during build
                                                    (that's another
                                                    story). <br>
                                                  </p>
                                                  <p>`-nodefaultlibs`
                                                    appears several
                                                    times in libc++ and
                                                    libc++abi code and
                                                    I'm not sure about
                                                    cleanest way to
                                                    fix/workaround it.</p>
                                                  <p>Any suggestions?<br>
                                                  </p>
                                                  <p><br>
                                                  </p>
                                                  <p>[1] <a
                                                      moz-do-not-send="true"
class="m_-8342469880804593719gmail-m_-4175624814147688239m_-308411374499290371gmail-m_5555656344556012329m_-6702888354140731109moz-txt-link-freetext"
href="https://github.com/llvm-mirror/libcxx/blob/master/cmake/config-ix.cmake#L27"
                                                      target="_blank">https://github.com/llvm-mirror<wbr>/libcxx/blob/master/cmake/conf<wbr>ig-ix.cmake#L27</a></p>
                                                  <p>[2] <a
                                                      moz-do-not-send="true"
class="m_-8342469880804593719gmail-m_-4175624814147688239m_-308411374499290371gmail-m_5555656344556012329m_-6702888354140731109moz-txt-link-freetext"
href="https://reviews.llvm.org/P7975" target="_blank">https://reviews.llvm.org/P7975</a><br>
                                                  </p>
                                                  <p>[3] <a
                                                      moz-do-not-send="true"
class="m_-8342469880804593719gmail-m_-4175624814147688239m_-308411374499290371gmail-m_5555656344556012329m_-6702888354140731109moz-txt-link-freetext"
href="https://reviews.llvm.org/P7976" target="_blank">https://reviews.llvm.org/P7976</a></p>
                                                  <p><br>
                                                  </p>
                                                  <p>Thanks,</p>
                                                  <p>Mateusz<br>
                                                  </p>
                                                </div>
                                                <br>
                                              </span>______________________________<wbr>_________________<br>
                                              cfe-dev mailing list<br>
                                              <a moz-do-not-send="true"
href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
                                              <a moz-do-not-send="true"
href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev"
                                                rel="noreferrer"
                                                target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
                                              <br>
                                            </blockquote>
                                          </div>
                                          <br>
                                        </div>
                                      </div>
                                    </blockquote>
                                  </div>
                                  <br>
                                </div>
                              </blockquote>
                              <br>
                            </div>
                          </div>
                        </div>
                      </blockquote>
                    </div>
                  </div>
                </div>
                <br>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  </body>
</html>