https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89093
--- Comment #53 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to Bernd Edlinger from comment #52) > I digged a bit, and found a D syntax for the target attribute, > it is a bit of a complication since D does not have a pre-processor, > but an empty target attribute does seem to be ignored without warnings. > > > --- libphobos/libdruntime/gcc/deh.d 2019-01-01 13:31:55.000000000 +0100 > +++ libphobos/libdruntime/gcc/deh.d 2019-04-17 11:24:24.171579381 +0200 > @@ -28,6 +28,7 @@ import gcc.unwind; > import gcc.unwind.pe; > import gcc.builtins; > import gcc.config; > +import gcc.attribute; > > extern(C) > { > @@ -519,10 +520,19 @@ extern(C) void _d_throw(Throwable object > terminate("unwind error", __LINE__); > } > > +static if (GNU_ARM_EABI_Unwinder) > +{ > + enum TARGET_ATTRIBUTE = "general-regs-only"; > +} > +else > +{ > + enum TARGET_ATTRIBUTE = ""; > +} > > /** > * Read and extract information from the LSDA (.gcc_except_table section). > */ > +@attribute("target", (TARGET_ATTRIBUTE)) > _Unwind_Reason_Code scanLSDA(const(ubyte)* lsda, _Unwind_Exception_Class > exceptionClass, > _Unwind_Action actions, _Unwind_Exception* > unwindHeader, > _Unwind_Context* context, _Unwind_Word cfa, > @@ -772,6 +782,7 @@ int actionTableLookup(_Unwind_Action act > * Called when the personality function has found neither a cleanup or > handler. > * To support ARM EABI personality routines, that must also unwind the > stack. > */ > +@attribute("target", (TARGET_ATTRIBUTE)) > _Unwind_Reason_Code CONTINUE_UNWINDING(_Unwind_Exception* unwindHeader, > _Unwind_Context* context) > { > static if (GNU_ARM_EABI_Unwinder) > @@ -814,6 +825,7 @@ else > static if (GNU_ARM_EABI_Unwinder) > { > pragma(mangle, PERSONALITY_FUNCTION) > + @attribute("target", (TARGET_ATTRIBUTE)) > extern(C) _Unwind_Reason_Code gdc_personality(_Unwind_State state, > _Unwind_Exception* > unwindHeader, > _Unwind_Context* context) > @@ -873,6 +885,7 @@ else > } > } > > +@attribute("target", (TARGET_ATTRIBUTE)) > private _Unwind_Reason_Code __gdc_personality(_Unwind_Action actions, > _Unwind_Exception_Class > exceptionClass, > _Unwind_Exception* > unwindHeader, That is not going to work I'm afraid, many targets don't support target attribute at all. default_target_option_valid_attribute_p will then just complain. Only i386, rs6000, s390, arm, aarch64 and nios2 backends do support those. On the other side, given the above, I thought all you want to ensure is that the attribute is on the personality routine, not on the other ones, and the gdc_personality definition is in static if (GNU_ARM_EABI_Unwinder) { pragma(mangle, PERSONALITY_FUNCTION) extern(C) _Unwind_Reason_Code gdc_personality(_Unwind_State state, so can't you just stick @attribute("target", "general-regs-only") to there?