Skip to content

[Clang] Confusing diagnostic when using -fsanitize=function -mexecute-only flags together on ARM targets #117974

@Il-Capitano

Description

@Il-Capitano

When passing -fsanitize=function -mexecute-only to Clang on an ARM target, it prints the following error:

error: invalid argument '-fsanitize=function' not allowed with 'arm-unknown-linux-gnueabi'

The error happens because -fsanitize=function is incompatible with execute-only memory, but prints the target triple as the reason. I would expect the error message to be the following in this case:

error: invalid argument '-fsanitize=function' not allowed with '-mexecute-only'

The diagnostic is created here:

if (isExecuteOnlyTarget(Triple, Args)) {
if (SanitizerMask KindsToDiagnose =
Add & NotAllowedWithExecuteOnly & ~DiagnosedKinds) {
if (DiagnoseErrors) {
std::string Desc = describeSanitizeArg(Arg, KindsToDiagnose);
D.Diag(diag::err_drv_argument_not_allowed_with)
<< Desc << Triple.str();
}

I think a good solution would be to print -mexecute-only (or -mpure-code) as the reason for the incompatibility if it was passed to the compiler driver, and print the target triple otherwise.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:driver'clang' and 'clang++' user-facing binaries. Not 'clang-cl'

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions