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