llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

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

Open Il-Capitano opened this issue 2 years ago • 1 comments

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: https://github.com/llvm/llvm-project/blob/69d66fafec968b17f84e30bc09faffb3dc8e5f15/clang/lib/Driver/SanitizerArgs.cpp#L416-L423

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.

Il-Capitano avatar Nov 28 '24 07:11 Il-Capitano

@llvm/issue-subscribers-clang-driver

Author: Csanád Hajdú (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: https://github.com/llvm/llvm-project/blob/69d66fafec968b17f84e30bc09faffb3dc8e5f15/clang/lib/Driver/SanitizerArgs.cpp#L416-L423

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.

llvmbot avatar Nov 28 '24 15:11 llvmbot