@@ -1292,65 +1292,9 @@ void DarwinClang::addClangWarningOptions(ArgStringList &CC1Args) const {
1292
1292
1293
1293
void DarwinClang::addClangTargetOptions (
1294
1294
const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
1295
- Action::OffloadKind DeviceOffloadKind) const {
1295
+ Action::OffloadKind DeviceOffloadKind) const {
1296
1296
1297
1297
Darwin::addClangTargetOptions (DriverArgs, CC1Args, DeviceOffloadKind);
1298
-
1299
- // On arm64e, enable pointer authentication (for the return address and
1300
- // indirect calls), as well as usage of the intrinsics.
1301
- if (getArchName () == " arm64e" ) {
1302
- // The ptrauth ABI version is 0 by default, but can be overridden.
1303
- static const constexpr unsigned DefaultPtrauthABIVersion = 0 ;
1304
-
1305
- unsigned PtrAuthABIVersion = DefaultPtrauthABIVersion;
1306
- const Arg *A = DriverArgs.getLastArg (options::OPT_fptrauth_abi_version_EQ,
1307
- options::OPT_fno_ptrauth_abi_version);
1308
- bool HasVersionArg =
1309
- A && A->getOption ().matches (options::OPT_fptrauth_abi_version_EQ);
1310
- if (HasVersionArg) {
1311
- unsigned PtrAuthABIVersionArg;
1312
- if (StringRef (A->getValue ()).getAsInteger (10 , PtrAuthABIVersionArg))
1313
- getDriver ().Diag (diag::err_drv_invalid_value)
1314
- << A->getAsString (DriverArgs) << A->getValue ();
1315
- else
1316
- PtrAuthABIVersion = PtrAuthABIVersionArg;
1317
- }
1318
-
1319
- // Pass the ABI version to -cc1, regardless of its value, if the user asked
1320
- // for it or if the user didn't explicitly disable it.
1321
- if (HasVersionArg ||
1322
- !DriverArgs.hasArg (options::OPT_fno_ptrauth_abi_version)) {
1323
- CC1Args.push_back (DriverArgs.MakeArgString (
1324
- " -fptrauth-abi-version=" + llvm::utostr (PtrAuthABIVersion)));
1325
-
1326
- // -f(no-)ptrauth-kernel-abi-version can override -mkernel and
1327
- // -fapple-kext
1328
- if (DriverArgs.hasArg (options::OPT_fptrauth_kernel_abi_version,
1329
- options::OPT_mkernel, options::OPT_fapple_kext) &&
1330
- !DriverArgs.hasArg (options::OPT_fno_ptrauth_kernel_abi_version))
1331
- CC1Args.push_back (" -fptrauth-kernel-abi-version" );
1332
- }
1333
-
1334
- if (!DriverArgs.hasArg (options::OPT_fptrauth_returns,
1335
- options::OPT_fno_ptrauth_returns))
1336
- CC1Args.push_back (" -fptrauth-returns" );
1337
-
1338
- if (!DriverArgs.hasArg (options::OPT_fptrauth_intrinsics,
1339
- options::OPT_fno_ptrauth_intrinsics))
1340
- CC1Args.push_back (" -fptrauth-intrinsics" );
1341
-
1342
- if (!DriverArgs.hasArg (options::OPT_fptrauth_calls,
1343
- options::OPT_fno_ptrauth_calls))
1344
- CC1Args.push_back (" -fptrauth-calls" );
1345
-
1346
- if (!DriverArgs.hasArg (options::OPT_fptrauth_indirect_gotos,
1347
- options::OPT_fno_ptrauth_indirect_gotos))
1348
- CC1Args.push_back (" -fptrauth-indirect-gotos" );
1349
-
1350
- if (!DriverArgs.hasArg (options::OPT_fptrauth_auth_traps,
1351
- options::OPT_fno_ptrauth_auth_traps))
1352
- CC1Args.push_back (" -fptrauth-auth-traps" );
1353
- }
1354
1298
}
1355
1299
1356
1300
// / Take a path that speculatively points into Xcode and return the
@@ -3216,9 +3160,75 @@ bool Darwin::isSizedDeallocationUnavailable() const {
3216
3160
return TargetVersion < sizedDeallocMinVersion (OS);
3217
3161
}
3218
3162
3163
+ void MachO::addClangTargetOptions (
3164
+ const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
3165
+ Action::OffloadKind DeviceOffloadKind) const {
3166
+
3167
+ ToolChain::addClangTargetOptions (DriverArgs, CC1Args, DeviceOffloadKind);
3168
+
3169
+ // On arm64e, enable pointer authentication (for the return address and
3170
+ // indirect calls), as well as usage of the intrinsics.
3171
+ if (getArchName () == " arm64e" ) {
3172
+ // The ptrauth ABI version is 0 by default, but can be overridden.
3173
+ static const constexpr unsigned DefaultPtrauthABIVersion = 0 ;
3174
+
3175
+ unsigned PtrAuthABIVersion = DefaultPtrauthABIVersion;
3176
+ const Arg *A = DriverArgs.getLastArg (options::OPT_fptrauth_abi_version_EQ,
3177
+ options::OPT_fno_ptrauth_abi_version);
3178
+ bool HasVersionArg =
3179
+ A && A->getOption ().matches (options::OPT_fptrauth_abi_version_EQ);
3180
+ if (HasVersionArg) {
3181
+ unsigned PtrAuthABIVersionArg;
3182
+ if (StringRef (A->getValue ()).getAsInteger (10 , PtrAuthABIVersionArg))
3183
+ getDriver ().Diag (diag::err_drv_invalid_value)
3184
+ << A->getAsString (DriverArgs) << A->getValue ();
3185
+ else
3186
+ PtrAuthABIVersion = PtrAuthABIVersionArg;
3187
+ }
3188
+
3189
+ // Pass the ABI version to -cc1, regardless of its value, if the user asked
3190
+ // for it or if the user didn't explicitly disable it.
3191
+ if (HasVersionArg ||
3192
+ !DriverArgs.hasArg (options::OPT_fno_ptrauth_abi_version)) {
3193
+ CC1Args.push_back (DriverArgs.MakeArgString (
3194
+ " -fptrauth-abi-version=" + llvm::utostr (PtrAuthABIVersion)));
3195
+
3196
+ // -f(no-)ptrauth-kernel-abi-version can override -mkernel and
3197
+ // -fapple-kext
3198
+ if (DriverArgs.hasArg (options::OPT_fptrauth_kernel_abi_version,
3199
+ options::OPT_mkernel, options::OPT_fapple_kext) &&
3200
+ !DriverArgs.hasArg (options::OPT_fno_ptrauth_kernel_abi_version))
3201
+ CC1Args.push_back (" -fptrauth-kernel-abi-version" );
3202
+ }
3203
+
3204
+ if (!DriverArgs.hasArg (options::OPT_fptrauth_returns,
3205
+ options::OPT_fno_ptrauth_returns))
3206
+ CC1Args.push_back (" -fptrauth-returns" );
3207
+
3208
+ if (!DriverArgs.hasArg (options::OPT_fptrauth_intrinsics,
3209
+ options::OPT_fno_ptrauth_intrinsics))
3210
+ CC1Args.push_back (" -fptrauth-intrinsics" );
3211
+
3212
+ if (!DriverArgs.hasArg (options::OPT_fptrauth_calls,
3213
+ options::OPT_fno_ptrauth_calls))
3214
+ CC1Args.push_back (" -fptrauth-calls" );
3215
+
3216
+ if (!DriverArgs.hasArg (options::OPT_fptrauth_indirect_gotos,
3217
+ options::OPT_fno_ptrauth_indirect_gotos))
3218
+ CC1Args.push_back (" -fptrauth-indirect-gotos" );
3219
+
3220
+ if (!DriverArgs.hasArg (options::OPT_fptrauth_auth_traps,
3221
+ options::OPT_fno_ptrauth_auth_traps))
3222
+ CC1Args.push_back (" -fptrauth-auth-traps" );
3223
+ }
3224
+ }
3225
+
3219
3226
void Darwin::addClangTargetOptions (
3220
3227
const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
3221
3228
Action::OffloadKind DeviceOffloadKind) const {
3229
+
3230
+ MachO::addClangTargetOptions (DriverArgs, CC1Args, DeviceOffloadKind);
3231
+
3222
3232
// Pass "-faligned-alloc-unavailable" only when the user hasn't manually
3223
3233
// enabled or disabled aligned allocations.
3224
3234
if (!DriverArgs.hasArgNoClaim (options::OPT_faligned_allocation,
0 commit comments