Skip to content

Commit 0ba9843

Browse files
committed
[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
1 parent 2b37257 commit 0ba9843

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4958,6 +4958,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
49584958
if (D.CCGenDiagnostics)
49594959
CmdArgs.push_back("-disable-pragma-debug-crash");
49604960

4961+
if (RawTriple.isOSAIX())
4962+
if (Arg *A = Args.getLastArg(options::OPT_G))
4963+
D.Diag(diag::err_drv_unsupported_opt_for_target)
4964+
<< A->getSpelling() << RawTriple.str();
4965+
49614966
bool UseSeparateSections = isUseSeparateSections(Triple);
49624967

49634968
if (Args.hasFlag(options::OPT_ffunction_sections,

clang/test/Driver/aix-err-options.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %clang -target powerpc32-ibm-aix-xcoff -### -S -emit-llvm -G 0 2>&1 %s | \
2+
// RUN: FileCheck --check-prefix=CHECK32 %s
3+
// RUN: %clang -target powerpc64-ibm-aix-xcoff -### -S -emit-llvm -G 0 2>&1 %s | \
4+
// RUN: FileCheck --check-prefix=CHECK64 %s
5+
6+
// CHECK32: error: unsupported option '-G' for target 'powerpc32-ibm-aix-xcoff'
7+
// CHECK64: error: unsupported option '-G' for target 'powerpc64-ibm-aix-xcoff'

llvm/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
930930

931931
# Modules should be built with -G, so we can use runtime linking with
932932
# plugins.
933-
string(APPEND CMAKE_MODULE_LINKER_FLAGS " -G")
933+
string(APPEND CMAKE_MODULE_LINKER_FLAGS " -Wl,-G")
934934

935935
# Also set the correct flags for building shared libraries.
936936
string(APPEND CMAKE_SHARED_LINKER_FLAGS " -shared")

0 commit comments

Comments
 (0)