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

    <tr>
        <th>Summary</th>
        <td>
            [clang][regression] Cannot build the boost library for AArch64 Linux after 20d497c26fc95c80a1bacb38820d92e5f52bec58
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          pawosm-arm
      </td>
    </tr>
</table>

<pre>
    The boost library, even the most recent sources, has the clang.jam file which computes a target triple as such:

```
local rule init-flags-cross ( toolset : condition * : architecture + : address-model + : target-os )
{
    local vendor = unknown ;
    local sys = unknown ;
 switch $(target-os)
    {
        case darwin : vendor = apple ; sys = darwin ;
        case linux : vendor = pc ; sys = linux ;
    }
 local vendor-sys = $(vendor)-$(sys) ;
    for local _architecture_ in $(architecture)
    {
        for local _address-model_ in $(address-model)
        {
            local arch = unknown ;
 switch $(_architecture_)-$(_address-model_)
            {
 case arm-64 : arch = arm64 ;
                case arm-32 : arch = arm ;
                case x86-64 : arch = x86_64 ;
 case x86-32 : arch = i386 ;
            }

            toolset.flags $(toolset)
                OPTIONS $(condition)/<target-os>$(target-os)/<architecture>$(_architecture_)/<address-model>$(_address-model_)
 : "--target=$(arch)-$(vendor-sys)"
                : unchecked ;
        }
    }
}
```

In effect, for AArch64 Linux the target triple is `arm64-pc-linux`. With a target triple like that, after `20d497c26fc95c80a1bacb38820d92e5f52bec58` commit, the C++ compiler cannot find the standard library headers anymore (at least when they're provided by the GCC's libstdc++).

Consider example file, std.cc:

```
#include <cstddef>
```

Try to compile it the way bjam would do it when building boost:

```
$ clang -c -x c++ -fvisibility-inlines-hidden -fPIC -pthread -O3 -Wall -fvisibility=hidden -Wno-inline -std=c++11 -mcpu=native -ffp-contract=fast -Wno-error=enum-constexpr-conversion -DBOOST_ALL_NO_LIB=1 -DBOOST_MPI_DYN_LINK=1 -DBOOST_MPI_PYTHON_DYN_LINK=1 -DBOOST_PYTHON_DYN_LINK=1 -DNDEBUG -I"." -I"/usr/include/python3.10" std.cc --target=aarch64-pc-linux
std.cc:1:10: fatal error: 'cstddef' file not found
    1 | #include <cstddef>
      |          ^~~~~~~~~
1 error generated.
```

Now, replace the `aarch64-pc-linux` target triple with more appropriate `aarch64-linux-gnu`:

```
$ clang -c -x c++ -fvisibility-inlines-hidden -fPIC -pthread -O3 -Wall -fvisibility=hidden -Wno-inline -std=c++11 -mcpu=native -ffp-contract=fast -Wno-error=enum-constexpr-conversion -DBOOST_ALL_NO_LIB=1 -DBOOST_MPI_DYN_LINK=1 -DBOOST_MPI_PYTHON_DYN_LINK=1 -DBOOST_PYTHON_DYN_LINK=1 -DNDEBUG -I"." -I"/usr/include/python3.10" std.cc --target=aarch64-linux-gnu
$ file std.o
std.o: ELF 64-bit LSB relocatable, ARM aarch64, version 1 (SYSV), not stripped
```

We could argue whether some triples are more sane than others, but sadly, boost is too popular and widely used to ignore its preference.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsV0tv4zgS_jX0pSBDpvyQDz7Edns22EzS2GQ36FNAkSWL0xQpkFQcX_a3L0jJr9idmesCI3Q7Elkvsr76imTOya1GXJDJkkzWA9b6ythFw3bG1Qmz9aAwYr94qRAKY5wHJQvL7J7QFeA7avAVQh0mLHLUHpxpLUcX5ivm4jRXTG-Hf7AaSqkQdpXkFXBTN61HBww8s1v04K1sFAJz4FpekeyOpGuSHn6naf8vfirDmQLbKgSppU9KxbYu4dY4B4Tm4I1RDj2Q7A640UJ6aTQQehdHmOWV9Mh9axEIXXaDQlh0LqmNQHUc7WJLTDA770OZLbsXAIAukHfUwlgg2Rpa_VObnQaSXUm5vfuFiNtJzysgdExofnR59BhMXHgND2cOQTC7kzpGehYDa8JGkmx5dHmUu2VESd1-fLbR8AsDB5nleUTr_uN8E5KDRreYbpDQedJ9u31Y1qWh0tjexNt5Z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