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

    <tr>
        <th>Summary</th>
        <td>
            Building 16.0.6 fails on macOS 10.13 due to incompatible 'optional' header
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          ilg-ul
      </td>
    </tr>
</table>

<pre>
    While trying to build 16.0.6 on an older macOS, I got this:

```console
$ /usr/bin/clang++ -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/Users/ilg/Work/xpack-dev-tools/clang-xpack.git/build/darwin-x64/x86_64-apple-darwin17.7.0/build/llvm-16.0.6/lib/Support -I/Users/ilg/Work/xpack-dev-tools/clang-xpack.git/build/darwin-x64/sources/llvm-project-16.0.6.src/llvm/lib/Support -I/Users/ilg/Work/xpack-dev-tools/clang-xpack.git/build/darwin-x64/x86_64-apple-darwin17.7.0/build/llvm-16.0.6/include -I/Users/ilg/Work/xpack-dev-tools/clang-xpack.git/build/darwin-x64/sources/llvm-project-16.0.6.src/llvm/include -I/Users/ilg/Work/xpack-dev-tools/clang-xpack.git/build/darwin-x64/x86_64-apple-darwin17.7.0/install/include  -ffunction-sections -fdata-sections -pipe -O2  -w -stdlib=libc++ -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -w -fdiagnostics-color  -O3 -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -mmacosx-version-min=10.13 -std=c++17 -MD -MT lib/Support/CMakeFiles/LLVMSupport.dir/Program.cpp.o -MF lib/Support/CMakeFiles/LLVMSupport.dir/Program.cpp.o.d -o lib/Support/CMakeFiles/LLVMSupport.dir/Program.cpp.o -c /Users/ilg/Work/xpack-dev-tools/clang-xpack.git/build/darwin-x64/sources/llvm-project-16.0.6.src/llvm/lib/Support/Program.cpp -v


Apple LLVM version 10.0.0 (clang-1000.10.44.4)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
 "/Library/Developer/CommandLineTools/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.13.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -disable-free -disable-llvm-verifier -discard-value-names -main-file-name Program.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -fno-strict-return -masm-verbose -munwind-tables -target-cpu penryn -dwarf-column-info -debugger-tuning=lldb -target-linker-version 409.12 -v -ffunction-sections -fdata-sections -coverage-notes-file /Users/ilg/Work/xpack-dev-tools/clang-xpack.git/build/darwin-x64/x86_64-apple-darwin17.7.0/build/llvm-16.0.6/lib/Support/CMakeFiles/LLVMSupport.dir/Program.cpp.gcno -resource-dir /Library/Developer/CommandLineTools/usr/lib/clang/10.0.0 -dependency-file lib/Support/CMakeFiles/LLVMSupport.dir/Program.cpp.o.d -skip-unused-modulemap-deps -sys-header-deps -MT lib/Support/CMakeFiles/LLVMSupport.dir/Program.cpp.o -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I /Users/ilg/Work/xpack-dev-tools/clang-xpack.git/build/darwin-x64/x86_64-apple-darwin17.7.0/build/llvm-16.0.6/lib/Support -I /Users/ilg/Work/xpack-dev-tools/clang-xpack.git/build/darwin-x64/sources/llvm-project-16.0.6.src/llvm/lib/Support -I /Users/ilg/Work/xpack-dev-tools/clang-xpack.git/build/darwin-x64/x86_64-apple-darwin17.7.0/build/llvm-16.0.6/include -I /Users/ilg/Work/xpack-dev-tools/clang-xpack.git/build/darwin-x64/sources/llvm-project-16.0.6.src/llvm/include -I /Users/ilg/Work/xpack-dev-tools/clang-xpack.git/build/darwin-x64/x86_64-apple-darwin17.7.0/install/include -D NDEBUG -stdlib=libc++ -O3 -Werror=date-time -Werror=unguarded-availability-new -w -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /Users/ilg/Work/xpack-dev-tools/clang-xpack.git/build/darwin-x64/x86_64-apple-darwin17.7.0/build/llvm-16.0.6 -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -stack-protector 1 -fblocks -fencode-extended-block-signature -fobjc-runtime=macosx-10.13.0 -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -o lib/Support/CMakeFiles/LLVMSupport.dir/Program.cpp.o -x c++ /Users/ilg/Work/xpack-dev-tools/clang-xpack.git/build/darwin-x64/sources/llvm-project-16.0.6.src/llvm/lib/Support/Program.cpp
clang -cc1 version 10.0.0 (clang-1000.10.44.4) default target x86_64-apple-darwin17.7.0
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/v1"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/local/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 /Users/ilg/Work/xpack-dev-tools/clang-xpack.git/build/darwin-x64/x86_64-apple-darwin17.7.0/build/llvm-16.0.6/lib/Support
 /Users/ilg/Work/xpack-dev-tools/clang-xpack.git/build/darwin-x64/sources/llvm-project-16.0.6.src/llvm/lib/Support
 /Users/ilg/Work/xpack-dev-tools/clang-xpack.git/build/darwin-x64/x86_64-apple-darwin17.7.0/build/llvm-16.0.6/include
 /Users/ilg/Work/xpack-dev-tools/clang-xpack.git/build/darwin-x64/sources/llvm-project-16.0.6.src/llvm/include
 /Users/ilg/Work/xpack-dev-tools/clang-xpack.git/build/darwin-x64/x86_64-apple-darwin17.7.0/install/include
 /Library/Developer/CommandLineTools/usr/include/c++/v1
 /Library/Developer/CommandLineTools/usr/lib/clang/10.0.0/include
 /Library/Developer/CommandLineTools/usr/include
 /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include
 /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks (framework directory)
End of search list.
/Users/ilg/Work/xpack-dev-tools/clang-xpack.git/build/darwin-x64/sources/llvm-project-16.0.6.src/llvm/lib/Support/Program.cpp:46:49: error: no viable constructor or deduction guide for deduction of template arguments of 'optional'
        PI, SecondsToWait == 0 ? std::nullopt : std::optional(SecondsToWait),
                                                ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/optional:684:41: note: candidate template ignored: couldn't infer template argument '_Tp'
    _LIBCPP_INLINE_VISIBILITY constexpr optional(nullopt_t) noexcept {}
                                        ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/optional:690:24: note: candidate template ignored: couldn't infer template argument '_Tp'
    constexpr explicit optional(in_place_t, _Args&&... __args)
                       ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/optional:704:15: note: candidate template ignored: couldn't infer template argument '_Tp'
    constexpr optional(_Up&& __v)
              ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/optional:711:24: note: candidate template ignored: couldn't infer template argument '_Tp'
    constexpr explicit optional(_Up&& __v)
                       ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/optional:580:7: note: candidate template ignored: could not match 'optional<_Tp>' against 'unsigned int'
class optional
      ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/optional:682:41: note: candidate template ignored: could not match 'optional<_Tp>' against 'unsigned int'
    _LIBCPP_INLINE_VISIBILITY constexpr optional(const optional&) = default;
                                        ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/optional:683:41: note: candidate template ignored: could not match 'optional<_Tp>' against 'unsigned int'
    _LIBCPP_INLINE_VISIBILITY constexpr optional(optional&&) = default;
                                        ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/optional:719:5: note: candidate template ignored: could not match 'optional<type-parameter-0-1>' against 'unsigned int'
    optional(const optional<_Up>& __v)
    ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/optional:727:14: note: candidate template ignored: could not match 'optional<type-parameter-0-1>' against 'unsigned int'
    explicit optional(const optional<_Up>& __v)
             ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/optional:737:5: note: candidate template ignored: could not match 'optional<type-parameter-0-1>' against 'unsigned int'
    optional(optional<_Up>&& __v)
    ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/optional:745:14: note: candidate template ignored: could not match 'optional<type-parameter-0-1>' against 'unsigned int'
    explicit optional(optional<_Up>&& __v)
             ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/optional:681:41: note: candidate function template not viable: requires 0 arguments, but 1 was provided
    _LIBCPP_INLINE_VISIBILITY constexpr optional() noexcept {}
                                        ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/optional:697:24: note: candidate function template not viable: requires at least 2 arguments, but 1 was provided
    constexpr explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args)
                       ^
1 error generated.
```

Apparently some new changes introduced in 16.x require a newer version of the `optional` header than the one provided by clang 10.

The same build scripts pass on Intel macOS 12, and Apple Silicon macOS 11.

I know that macOS 10.13 is quite old, but it is more or less the de-facto build platform for standalone binary distributions for Intel macOS, including the [xPack 3rd Party Development Tools](https://github.com/xpack-dev-tools/).

To be totally fair, for me this was not a show stopper, since in my build environment I have the luxury to easily switch between tools versions, and so I compiled 16.0.6 using 15.0.7, even on the old macOS 10.13, but sometimes I still need to calibrate my builds using the system toolchains, and having the LLVM source files compatible with macOS 10.13 would be a useful feature.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUWltz46jW_TXKyy5UuvgSP-TBsdtfub6ku2uSmT7nyYVhS2aCQAPIl_n1p0C-Tndy4qSTzunqckqAYLHYe-0NglorSoV4FXWvo-74gjZuoc2VkCVp5MVc883Vt4WQCM5shCrBaZg3QnJIe3ES90AroAq05GigouzLXZSNYAq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