Index: include/clang/Basic/DiagnosticCommonKinds.td =================================================================== --- include/clang/Basic/DiagnosticCommonKinds.td +++ include/clang/Basic/DiagnosticCommonKinds.td @@ -123,6 +123,8 @@ def err_target_unknown_fpmath : Error<"unknown FP unit '%0'">; def err_target_unsupported_fpmath : Error< "the '%0' unit is not supported with this instruction set">; +def err_target_unsupported_unaligned : Error< + "the %0 sub-architecture does not support unaligned accesses">; // Source manager def err_cannot_open_file : Error<"cannot open file '%0': %1">, DefaultFatal; Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -806,8 +806,12 @@ CmdArgs.push_back("-backend-option"); if (A->getOption().matches(options::OPT_mno_unaligned_access)) CmdArgs.push_back("-arm-strict-align"); - else + else { + if (getToolChain().getTriple().getSubArch() == + llvm::Triple::SubArchType::ARMSubArch_v6m) + D.Diag(diag::err_target_unsupported_unaligned) << "v6m"; CmdArgs.push_back("-arm-no-strict-align"); + } } }