<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/121709>121709</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang] Precompilation of `std` module fails with _FORTIFY_SOURCE
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          nmlgc
      </td>
    </tr>
</table>

<pre>
    Tested on the current trunk:

```
clang version 20.0.0 (/home/nmlgc/aur/llvm-git/llvm-project 743c84bb9b79ed70d9bed926c2a173db3b30f587)
Target: x86_64-pc-linux-gnu
Thread model: posix
```

```shell
$ clang++ -O -D_FORTIFY_SOURCE -stdlib=libc++ -std=c++2c --precompile -Wno-reserved-module-identifier /usr/share/libc++/v1/std.cppm
In file included from /usr/share/libc++/v1/std.cppm:237:
/usr/share/libc++/v1/std/cstdio.inc:47:14: error: using declaration referring to 'snprintf' with internal linkage cannot be exported
   47 |   using std::snprintf _LIBCPP_USING_IF_EXISTS;
      | ^
/usr/include/bits/stdio2.h:75:8: note: target of using declaration
   75 | __NTH (snprintf (__fortify_clang_overload_arg (char *, __restrict, __s),
      |        ^
In file included from /usr/share/libc++/v1/std.cppm:237:
/usr/share/libc++/v1/std/cstdio.inc:48:14: error: using declaration referring to 'sprintf' with internal linkage cannot be exported
   48 |   using std::sprintf _LIBCPP_USING_IF_EXISTS;
      | ^
/usr/include/bits/stdio2.h:37:8: note: target of using declaration
   37 | __NTH (sprintf (__fortify_clang_overload_arg (char *, __restrict, __s),
      |        ^
In file included from /usr/share/libc++/v1/std.cppm:242:
/usr/share/libc++/v1/std/cwchar.inc:30:14: error: using declaration referring to 'swprintf' with internal linkage cannot be exported
   30 |   using std::swprintf _LIBCPP_USING_IF_EXISTS;
      | ^
/usr/include/bits/wchar2.h:181:8: note: target of using declaration
  181 | __NTH (swprintf (__fortify_clang_overload_arg (wchar_t *, __restrict, __s),
      |        ^
3 errors generated.
```
`_FORTIFY_SOURCE` is part of the default `CFLAGS` of (at least) Arch Linux during package builds via `makepkg`, and would need to be manually removed to work with modules.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzUll1v2zYXxz8NfXMggyL1euELJan6GCjaoknxbFcCJVISF4oUSMpOvv1AyVk7DwWaYAM2Q4DFt8PzP_wJ_DPn5KCFOKD0BqV3O7b40diDntTQ7VrDnw8PwnnBwWjwo4BusVZoD94u-hHRCuH1yfDlwVWnmB7gJKyTRgPBe7zHgEiBSD2aSSBSr8ERqdliEamVOk3RIP3L62zNb6LzkCe0K5K2Ldu8FDzHvGwFL0nWERbnlLe0pbhPixyREuHqgdlBeEQreCqyJkuiuYuU1MtTNOgljI9WMA6T4UKFWbNx8ukq8--bbhRKhQ6SwKoIkRtEbiD6BNFdU3_68nCsf23uP339cvsOIue5ki2id0q23ctM5zmid5cm6SCKZis6M81SCYj-r01khRP2JHg0Gb4oEUkutJe9FBYQqRcXyuNGZkPRvkVGpD7FYcTzfTfPE8LVUUMfokrdqYULDr0106ti0IrQ_HKeP7UMkbpznkuzl7pDtErC6jgJtRXWGhteFif1AFx0ilnmAw5W9MLa0OsNIJI7PVupfY9IDmfpR5DaC6uZAiX1IxsEdExr46EVIJ5mY73gCFcAkOSA8luAyyZrsStEq5eI0Hw43tx-_tx8vT9-fN8c6-bdL8f7h3tEb7YAAGsAlL77XvOlgojUrfRukyoN2Y-IVnmKaFUEYdp4Ef79Sh2Y_q9St03ydN2kaT4-_C98BH9kh0jRNL2xXvbPzQpYY07CKsN4w-wQxruRBQ4qREIAK5y3svNbywXqye2flFx-m6B_AxHFm4h4MxDFD4D4x3hYy_M6Hmh-xcN_CYeEvBaHc0j6ggPFb8Lh_FYeKP4BD-e_F4hV4wZEXMSvJSIu4isizj-PxLp1499MBd1OwsEgtLDMC76_vhIzfHXZoQyDdDAzu6oKnoCLni3KA8rwbf2hen8f5phVAfOgBHMekR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