<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - #pragma comment(lib) not ignored with MS extensions disabled"
   href="https://bugs.llvm.org/show_bug.cgi?id=49536">49536</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>#pragma comment(lib) not ignored with MS extensions disabled
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>c.schaerf@t-online.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Even without MS extensions, Clang still follows the #pragma comment (lib)
directive.

According to the documentation [1], they should per default only be active on
Windows platforms. However, on Linux and even with -fno-ms-extensions
explicitly set, the directive is still followed.

The source code

#pragma comment(lib, "testlib.lib")

int main() {
    return 0;
}

compiles to the following assembly:

        .text
        .file   "test.cpp"
        .globl  main                            # -- Begin function main
        .p2align        4, 0x90
        .type   main,@function
main:                                   # @main
        .cfi_startproc
# %bb.0:
        xorl    %eax, %eax
        retq
.Lfunc_end0:
        .size   main, .Lfunc_end0-main
        .cfi_endproc
                                        # -- End function
        .section        .deplibs,"MS",@llvm_dependent_libraries,1
        .ascii  "testlib.lib"
        .byte   0
        .ident  "clang version 13.0.0 (<a href="https://github.com/llvm/llvm-project">https://github.com/llvm/llvm-project</a>
bc5e9ec2dccdd18f840a09fe63c196ae25ad99d5)"
        .section        ".note.GNU-stack","",@progbits
        .addrsig

This behavior causes linker errors with LLD.

[1] <a href="https://clang.llvm.org/docs/UsersManual.html#microsoft-extensions">https://clang.llvm.org/docs/UsersManual.html#microsoft-extensions</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>