@@ -1337,65 +1337,9 @@ void DarwinClang::addClangWarningOptions(ArgStringList &CC1Args) const {
1337
1337
1338
1338
void DarwinClang::addClangTargetOptions (
1339
1339
const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
1340
- Action::OffloadKind DeviceOffloadKind) const {
1340
+ Action::OffloadKind DeviceOffloadKind) const {
1341
1341
1342
1342
Darwin::addClangTargetOptions (DriverArgs, CC1Args, DeviceOffloadKind);
1343
-
1344
- // On arm64e, enable pointer authentication (for the return address and
1345
- // indirect calls), as well as usage of the intrinsics.
1346
- if (getArchName () == " arm64e" ) {
1347
- // The ptrauth ABI version is 0 by default, but can be overridden.
1348
- static const constexpr unsigned DefaultPtrauthABIVersion = 0 ;
1349
-
1350
- unsigned PtrAuthABIVersion = DefaultPtrauthABIVersion;
1351
- const Arg *A = DriverArgs.getLastArg (options::OPT_fptrauth_abi_version_EQ,
1352
- options::OPT_fno_ptrauth_abi_version);
1353
- bool HasVersionArg =
1354
- A && A->getOption ().matches (options::OPT_fptrauth_abi_version_EQ);
1355
- if (HasVersionArg) {
1356
- unsigned PtrAuthABIVersionArg;
1357
- if (StringRef (A->getValue ()).getAsInteger (10 , PtrAuthABIVersionArg))
1358
- getDriver ().Diag (diag::err_drv_invalid_value)
1359
- << A->getAsString (DriverArgs) << A->getValue ();
1360
- else
1361
- PtrAuthABIVersion = PtrAuthABIVersionArg;
1362
- }
1363
-
1364
- // Pass the ABI version to -cc1, regardless of its value, if the user asked
1365
- // for it or if the user didn't explicitly disable it.
1366
- if (HasVersionArg ||
1367
- !DriverArgs.hasArg (options::OPT_fno_ptrauth_abi_version)) {
1368
- CC1Args.push_back (DriverArgs.MakeArgString (
1369
- " -fptrauth-abi-version=" + llvm::utostr (PtrAuthABIVersion)));
1370
-
1371
- // -f(no-)ptrauth-kernel-abi-version can override -mkernel and
1372
- // -fapple-kext
1373
- if (DriverArgs.hasArg (options::OPT_fptrauth_kernel_abi_version,
1374
- options::OPT_mkernel, options::OPT_fapple_kext) &&
1375
- !DriverArgs.hasArg (options::OPT_fno_ptrauth_kernel_abi_version))
1376
- CC1Args.push_back (" -fptrauth-kernel-abi-version" );
1377
- }
1378
-
1379
- if (!DriverArgs.hasArg (options::OPT_fptrauth_returns,
1380
- options::OPT_fno_ptrauth_returns))
1381
- CC1Args.push_back (" -fptrauth-returns" );
1382
-
1383
- if (!DriverArgs.hasArg (options::OPT_fptrauth_intrinsics,
1384
- options::OPT_fno_ptrauth_intrinsics))
1385
- CC1Args.push_back (" -fptrauth-intrinsics" );
1386
-
1387
- if (!DriverArgs.hasArg (options::OPT_fptrauth_calls,
1388
- options::OPT_fno_ptrauth_calls))
1389
- CC1Args.push_back (" -fptrauth-calls" );
1390
-
1391
- if (!DriverArgs.hasArg (options::OPT_fptrauth_indirect_gotos,
1392
- options::OPT_fno_ptrauth_indirect_gotos))
1393
- CC1Args.push_back (" -fptrauth-indirect-gotos" );
1394
-
1395
- if (!DriverArgs.hasArg (options::OPT_fptrauth_auth_traps,
1396
- options::OPT_fno_ptrauth_auth_traps))
1397
- CC1Args.push_back (" -fptrauth-auth-traps" );
1398
- }
1399
1343
}
1400
1344
1401
1345
// / Take a path that speculatively points into Xcode and return the
@@ -3270,9 +3214,75 @@ bool Darwin::isSizedDeallocationUnavailable() const {
3270
3214
return TargetVersion < sizedDeallocMinVersion (OS);
3271
3215
}
3272
3216
3217
+ void MachO::addClangTargetOptions (
3218
+ const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
3219
+ Action::OffloadKind DeviceOffloadKind) const {
3220
+
3221
+ ToolChain::addClangTargetOptions (DriverArgs, CC1Args, DeviceOffloadKind);
3222
+
3223
+ // On arm64e, enable pointer authentication (for the return address and
3224
+ // indirect calls), as well as usage of the intrinsics.
3225
+ if (getArchName () == " arm64e" ) {
3226
+ // The ptrauth ABI version is 0 by default, but can be overridden.
3227
+ static const constexpr unsigned DefaultPtrauthABIVersion = 0 ;
3228
+
3229
+ unsigned PtrAuthABIVersion = DefaultPtrauthABIVersion;
3230
+ const Arg *A = DriverArgs.getLastArg (options::OPT_fptrauth_abi_version_EQ,
3231
+ options::OPT_fno_ptrauth_abi_version);
3232
+ bool HasVersionArg =
3233
+ A && A->getOption ().matches (options::OPT_fptrauth_abi_version_EQ);
3234
+ if (HasVersionArg) {
3235
+ unsigned PtrAuthABIVersionArg;
3236
+ if (StringRef (A->getValue ()).getAsInteger (10 , PtrAuthABIVersionArg))
3237
+ getDriver ().Diag (diag::err_drv_invalid_value)
3238
+ << A->getAsString (DriverArgs) << A->getValue ();
3239
+ else
3240
+ PtrAuthABIVersion = PtrAuthABIVersionArg;
3241
+ }
3242
+
3243
+ // Pass the ABI version to -cc1, regardless of its value, if the user asked
3244
+ // for it or if the user didn't explicitly disable it.
3245
+ if (HasVersionArg ||
3246
+ !DriverArgs.hasArg (options::OPT_fno_ptrauth_abi_version)) {
3247
+ CC1Args.push_back (DriverArgs.MakeArgString (
3248
+ " -fptrauth-abi-version=" + llvm::utostr (PtrAuthABIVersion)));
3249
+
3250
+ // -f(no-)ptrauth-kernel-abi-version can override -mkernel and
3251
+ // -fapple-kext
3252
+ if (DriverArgs.hasArg (options::OPT_fptrauth_kernel_abi_version,
3253
+ options::OPT_mkernel, options::OPT_fapple_kext) &&
3254
+ !DriverArgs.hasArg (options::OPT_fno_ptrauth_kernel_abi_version))
3255
+ CC1Args.push_back (" -fptrauth-kernel-abi-version" );
3256
+ }
3257
+
3258
+ if (!DriverArgs.hasArg (options::OPT_fptrauth_returns,
3259
+ options::OPT_fno_ptrauth_returns))
3260
+ CC1Args.push_back (" -fptrauth-returns" );
3261
+
3262
+ if (!DriverArgs.hasArg (options::OPT_fptrauth_intrinsics,
3263
+ options::OPT_fno_ptrauth_intrinsics))
3264
+ CC1Args.push_back (" -fptrauth-intrinsics" );
3265
+
3266
+ if (!DriverArgs.hasArg (options::OPT_fptrauth_calls,
3267
+ options::OPT_fno_ptrauth_calls))
3268
+ CC1Args.push_back (" -fptrauth-calls" );
3269
+
3270
+ if (!DriverArgs.hasArg (options::OPT_fptrauth_indirect_gotos,
3271
+ options::OPT_fno_ptrauth_indirect_gotos))
3272
+ CC1Args.push_back (" -fptrauth-indirect-gotos" );
3273
+
3274
+ if (!DriverArgs.hasArg (options::OPT_fptrauth_auth_traps,
3275
+ options::OPT_fno_ptrauth_auth_traps))
3276
+ CC1Args.push_back (" -fptrauth-auth-traps" );
3277
+ }
3278
+ }
3279
+
3273
3280
void Darwin::addClangTargetOptions (
3274
3281
const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
3275
3282
Action::OffloadKind DeviceOffloadKind) const {
3283
+
3284
+ MachO::addClangTargetOptions (DriverArgs, CC1Args, DeviceOffloadKind);
3285
+
3276
3286
// Pass "-faligned-alloc-unavailable" only when the user hasn't manually
3277
3287
// enabled or disabled aligned allocations.
3278
3288
if (!DriverArgs.hasArgNoClaim (options::OPT_faligned_allocation,
0 commit comments