llvm-project/clang/lib
Nathan Chancellor be8180af58
[clang][driver] Warn when '-mno-outline-atomics' is used with a non-AArch64 triple
The Linux kernel has a make macro called cc-option that invokes the
compiler with an option in isolation to see if it is supported before
adding it to CFLAGS. The exit code of the compiler is used to determine
if the flag is supported and should be added to the compiler invocation.

A call to cc-option with '-mno-outline-atomics' was added to prevent
linking errors with newer GCC versions but this call succeeds with a
non-AArch64 target because there is no warning from clang with
'-mno-outline-atomics', just '-moutline-atomics'. Because the call
succeeds and adds '-mno-outline-atomics' to the compiler invocation,
there is a warning from LLVM because the 'outline-atomics target
feature is only supported by the AArch64 backend.

$ echo | clang -target x86_64 -moutline-atomics -Werror -x c -c -o /dev/null -
clang-14: error: The 'x86_64' architecture does not support -moutline-atomics; flag ignored [-Werror,-Woption-ignored]

$ echo $?
1

$ echo | clang -target x86_64 -mno-outline-atomics -Werror -x c -c -o /dev/null -
'-outline-atomics' is not a recognized feature for this target (ignoring feature)

$ echo $?
0

This does not match GCC's behavior, which errors when the flag is added
to a non-AArch64 target.

$ echo | gcc -moutline-atomics -x c -c -o /dev/null -
gcc: error: unrecognized command-line option ‘-moutline-atomics’; did you mean ‘-finline-atomics’?

$ echo | gcc -mno-outline-atomics -x c -c -o /dev/null -
gcc: error: unrecognized command-line option ‘-mno-outline-atomics’; did you mean ‘-fno-inline-atomics’?

$ echo | aarch64-linux-gnu-gcc -moutline-atomics -x c -c -o /dev/null -

$ echo | aarch64-linux-gnu-gcc -mno-outline-atomics -x c -c -o /dev/null -

To get closer to  GCC's behavior, issue a warning when
'-mno-outline-atomics' is used without an AArch64 triple and do not add
'{-,+}outline-atomic" to the list of target features in these cases.

Link: https://github.com/ClangBuiltLinux/linux/issues/1552

Reviewed By: melver, nickdesaulniers

Differential Revision: https://reviews.llvm.org/D116128
2021-12-23 12:36:42 -07:00
..
APINotes [clang][APINotes] Fix -Wunused-function warning (NFC) 2021-04-01 09:52:43 +08:00
ARCMigrate Revert "Revert "Use VersionTuple for parsing versions in Triple, fixing issues that caused the original change to be reverted. This makes it possible to distinguish between "16" and "16.0" after parsing, which previously was not possible."" 2021-12-07 23:15:21 +00:00
AST [JSONNodeDumper] Do not print mangled names for local variables (PR49111) 2021-12-23 08:55:41 +01:00
ASTMatchers Reland "[AST] Add UsingType: a sugar type for types found via UsingDecl" 2021-12-20 18:03:15 +01:00
Analysis Revert "Revert "[clang][dataflow] Add framework for testing analyses."" 2021-12-11 23:16:59 +00:00
Basic [Hexagon] Driver/preprocessor options for Hexagon v69 2021-12-23 10:17:08 -08:00
CodeGen [OpenMP] Remove no-op cast (NFC) 2021-12-23 15:15:26 +01:00
CrossTU Revert "[analyzer][ctu] Fix wrong 'multiple definitions' errors caused by space characters in lookup names when parsing the ctu index file" 2021-12-16 20:46:51 -05:00
DirectoryWatcher [clang] [DirectoryWatcher] Remove leading \\?\ from GetFinalPathNameByHandleW 2021-11-08 22:21:30 +02:00
Driver [clang][driver] Warn when '-mno-outline-atomics' is used with a non-AArch64 triple 2021-12-23 12:36:42 -07:00
Edit [clang] Use llvm::is_contained (NFC) 2021-10-13 20:41:55 -07:00
Format [clang-format] Fix wrong indentation after trailing requires clause. 2021-12-23 08:22:12 +01:00
Frontend [Clang] Own the CommandLineArgs in CodeGenOptions 2021-12-21 17:41:35 -05:00
FrontendTool [clang] Add plugin ActionType to run command line plugin before main action 2021-10-20 08:58:20 -07:00
Headers [Hexagon] Driver/preprocessor options for Hexagon v69 2021-12-23 10:17:08 -08:00
Index [clang] Visit enum base specifiers in libIndex 2021-10-25 13:16:14 +02:00
IndexSerialization
Interpreter [clang-repl] Allow Interpreter::getSymbolAddress to take a mangled name. 2021-11-10 12:52:05 +00:00
Lex [clang] Use llvm::reverse (NFC) 2021-12-17 16:51:42 -08:00
Parse Fix crash on invalid code involving late parsed inline methods 2021-12-16 07:58:51 -05:00
Rewrite [NFC][clang] Return underlying strings directly instead of OS.str() 2021-12-09 16:05:46 -08:00
Sema [C++20] [Modules] Mark imported module as imported if not exported 2021-12-23 21:14:13 +08:00
Serialization Reland "[AST] Add UsingType: a sugar type for types found via UsingDecl" 2021-12-20 18:03:15 +01:00
StaticAnalyzer [Clang] Add __builtin_function_start 2021-12-20 12:55:33 -08:00
Testing
Tooling [clang][deps] NFC: Unify ErrorOr patterns 2021-12-17 14:00:20 +01:00
CMakeLists.txt [clang-repl] Recommit "Land initial infrastructure for incremental parsing" 2021-05-13 06:30:29 +00:00