[clang] 0ba9843 - [AIX] Emit error for -G option on AIX
Xiangling Liao via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 22 13:21:28 PDT 2020
Author: Xiangling Liao
Date: 2020-10-22T16:16:39-04:00
New Revision: 0ba98433971f6aa7cf4dc2befe7b5446d25d5956
URL: https://github.com/llvm/llvm-project/commit/0ba98433971f6aa7cf4dc2befe7b5446d25d5956
DIFF: https://github.com/llvm/llvm-project/commit/0ba98433971f6aa7cf4dc2befe7b5446d25d5956.diff
LOG: [AIX] Emit error for -G option on AIX
1. Emit error for -G driver option on AIX
2. Adjust cmake file to use -Wl,-G instead of -G
On AIX, legacy XL compiler uses -G to produce a shared object enabled
for use with the run-time linker, which has different meanings from what
it is used for in Clang. And in Clang, other targets do not have -G map
to another functionality in their legacy compiler. So this error is more
important when we are on AIX.
Differential Revision: https://reviews.llvm.org/D89897
Added:
clang/test/Driver/aix-err-options.c
Modified:
clang/lib/Driver/ToolChains/Clang.cpp
llvm/CMakeLists.txt
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 61e367bd835d..61b6af59e8b5 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4958,6 +4958,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
if (D.CCGenDiagnostics)
CmdArgs.push_back("-disable-pragma-debug-crash");
+ if (RawTriple.isOSAIX())
+ if (Arg *A = Args.getLastArg(options::OPT_G))
+ D.Diag(diag::err_drv_unsupported_opt_for_target)
+ << A->getSpelling() << RawTriple.str();
+
bool UseSeparateSections = isUseSeparateSections(Triple);
if (Args.hasFlag(options::OPT_ffunction_sections,
diff --git a/clang/test/Driver/aix-err-options.c b/clang/test/Driver/aix-err-options.c
new file mode 100644
index 000000000000..6ed8363c161f
--- /dev/null
+++ b/clang/test/Driver/aix-err-options.c
@@ -0,0 +1,7 @@
+// RUN: %clang -target powerpc32-ibm-aix-xcoff -### -S -emit-llvm -G 0 2>&1 %s | \
+// RUN: FileCheck --check-prefix=CHECK32 %s
+// RUN: %clang -target powerpc64-ibm-aix-xcoff -### -S -emit-llvm -G 0 2>&1 %s | \
+// RUN: FileCheck --check-prefix=CHECK64 %s
+
+// CHECK32: error: unsupported option '-G' for target 'powerpc32-ibm-aix-xcoff'
+// CHECK64: error: unsupported option '-G' for target 'powerpc64-ibm-aix-xcoff'
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 344ccb6fda2f..39d78c70c02e 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -930,7 +930,7 @@ if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
# Modules should be built with -G, so we can use runtime linking with
# plugins.
- string(APPEND CMAKE_MODULE_LINKER_FLAGS " -G")
+ string(APPEND CMAKE_MODULE_LINKER_FLAGS " -Wl,-G")
# Also set the correct flags for building shared libraries.
string(APPEND CMAKE_SHARED_LINKER_FLAGS " -shared")
More information about the cfe-commits
mailing list