18 Commits

Author SHA1 Message Date
Ian Anderson
dd90057d9e
[clang][driver][darwin] Prefer DarwinSDKInfo for platform identification and compatibility over the -isysroot path (#176541)
Using the file system path to identify the SDK platform, and determine
which platforms the SDK supports, is unreliable. In particular, the
SDK's file name prefix is usually significant, and dropping it usually
gives incorrect results. Instead, use information from SDKinfo to
positively identify its platform/environment, and to identify which
triples are compatible.
2026-01-29 14:00:21 -08:00
Ian Anderson
be0907b108
[clang][driver][darwin] Switch back to using CanonicalName to identify the SDK instead of SupportedTargets (#178115)
The SDK's SupportedTarget for its CanonicalName doesn't necessarily have
an LLVMTargetTripleSys/LLVMTargetTripleEnvironment that matches the
CanonicalName. e.g. sometimes new SDKs use arm64-apple-ios1.0 during
bringup, but their CanonicalName is set to the new platform. Go back to
using CanonicalName to identify the SDK as a Triple::OSType, and expose
the Triple::EnvironmentType used to build the SDKPlatformInfo when
SupportedTargets isn't present.
2026-01-27 21:39:12 -08:00
Ian Anderson
aba18cf1cc
macCatalyst: add SDKSettings.json as a dependency file if its potentially needed by the compiler (#178077)
Co-authored-by: Alex Lorenz <arphaman@gmail.com>
2026-01-26 20:14:22 -08:00
Ian Anderson
c71f944d81
Revert "macCatalyst: add SDKSettings.json as a dependency file if its potentially needed by the compiler (#177748)" (#178075)
This reverts commit 7b917b9a08e2dac495fd9e83dc8cf152c8df6fde.
2026-01-26 15:04:26 -08:00
Ian Anderson
7b917b9a08
macCatalyst: add SDKSettings.json as a dependency file if its potentially needed by the compiler (#177748)
Co-authored-by: Alex Lorenz <arphaman@gmail.com>
2026-01-26 13:17:18 -08:00
Ian Anderson
3fd745f73d
[clang][driver][darwin] Report bad SDKSettings as a fatal error rather than unreachable (#175073)
Fatal error is more appropriate than unreachable when the SDKSettings is
not in a recognized form (encountered in a few tests with incomplete
SDKSettings.json).
2026-01-08 14:33:00 -08:00
Ian Anderson
33275d0a08
[clang][driver][darwin] Base the platform prefix on the SDK, not the target (#171970)
The search path prefix is really a property of the SDK, and not the
target triple. The target is just being used as a proxy for the SDK.
That's problematic when the SDK being used doesn't match the target
assumption, and the prefix should be taken from the SDK rather than hard
coded.

Parse the SupportedTargets, which is what holds the platform prefix, in
DarwinSDKInfo. SupportedTargets contains an entry for the SDK's
canonical name, and that entry holds a valid OS value so use that
instead of the hard coded map. Include the environment which is also
relevant in some situations, and the vendor and object format in case
they're useful later. Skip architectures because they typically aren't
used for doing platform matching.
2026-01-05 23:42:32 +00:00
Ian Anderson
bd197ca003
[clang][modules] Determine if the SDK supports builtin modules independent of the target (#134005)
Whether the SDK supports builtin modules is a property of the SDK
itself, and really has nothing to do with the target. This was already
worked around for Mac Catalyst, but there are some other more esoteric
non-obvious target-to-sdk mappings that aren't handled. Have the SDK
parse its OS out of CanonicalName and use that instead of the target to
determine if builtin modules are supported.
2025-04-03 16:09:57 -07:00
Kazu Hirata
6ad0788c33 [clang] Use std::optional instead of llvm::Optional (NFC)
This patch replaces (llvm::|)Optional< with std::optional<.  I'll post
a separate patch to remove #include "llvm/ADT/Optional.h".

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-14 12:31:01 -08:00
Kazu Hirata
a12b82adb8 [Basic] Use std::optional in DarwinSDKInfo.cpp (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-09 22:48:14 -08:00
Kazu Hirata
35b4fbb559 [clang] Use std::nullopt instead of None in comments (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-04 15:57:24 -08:00
Fangrui Song
2c5d49cffc [Driver] llvm::Optional => std::optional
and change a few referenced Basic and llvm/lib/WindowsDriver API
2022-12-03 20:17:05 +00:00
Kazu Hirata
eeee3fee37 [Basic] Use std::nullopt instead of None (NFC)
This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-03 11:34:27 -08:00
Egor Zhdan
809c6a5a1d [Clang] Extract availability mapping from VersionMap for watchOS/tvOS
This change makes it possible to extract iOS-to-another-platform version mappings from `VersionMap` in the `SDKSettings.json` file in Darwin SDKs, for example, `iOS_watchOS` and `iOS_tvOS`.

This code was originally authored by Alex Lorenz.

rdar://81491680

Differential Revision: https://reviews.llvm.org/D116615
2022-01-05 17:00:03 -08:00
Alex Lorenz
2542c1a5a1 [clang][driver][darwin] Add driver support for Mac Catalyst
This commit adds driver support for the Mac Catalyst target,
as supported by the Apple clang compile

Differential Revision: https://reviews.llvm.org/D105960
2021-07-22 10:20:19 -07:00
Alex Lorenz
eb26ba9da8 [clang][darwin] add support for remapping macOS availability to Mac Catalyst availability
This commit adds supports for clang to remap macOS availability attributes that have introduced,
deprecated or obsoleted versions to appropriate Mac Catalyst availability attributes. This
mapping is done using the version mapping provided in the macOS SDK, in the SDKSettings.json file.
The mappings in the SDKSettings json file will also be used in the clang driver for the driver
Mac Catalyst patch, and they could also be used in the future for other platforms as well.

Differential Revision: https://reviews.llvm.org/D105257
2021-07-21 11:32:25 -07:00
Alex Lorenz
808bbc2c47 [clang][darwin] Add support for macOS -> Mac Catalyst
version remapping to the Darwin SDK Info

Differential Revision: https://reviews.llvm.org/D105958
2021-07-20 14:25:33 -07:00
Alex Lorenz
05a6d74c48 [clang] NFC, move DarwinSDKInfo to lib/Basic
This is a preparation commit for https://reviews.llvm.org/D105958
2021-07-20 13:22:48 -07:00