[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
This commit is contained in:
Xiangling Liao
2020-10-21 16:50:36 -04:00
parent 2b372570ee
commit 0ba9843397
3 changed files with 13 additions and 1 deletions

View File

@@ -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,

View File

@@ -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'

View File

@@ -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")