[PATCH] D58250: [AIX][CMake] Changes for building on AIX with XL and GCC
Hubert Tong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 15 14:26:02 PST 2019
hubert.reinterpretcast added inline comments.
================
Comment at: llvm/cmake/modules/HandleLLVMOptions.cmake:138
+if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+ append("-Wl,-bbigtoc"
+ CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
----------------
hubert.reinterpretcast wrote:
> sfertile wrote:
> > I'm interested in why you choose bigtoc linker option over using large code model? From the little I understand about the bigtoc option it seems that large code model would be the preferable solution when expecting to have a toc that is a lot bigger then 64K.
> `-fPIC` is already specified. Even if the code is generated using the large code model, TOC overflow is a hard error for the linker unless if `-bbigtoc` is specified. On linking, the XL compiler specifies `-bbigtoc` to the linker in response `-qpic=large`.
>
> You can see this for yourself if you compile the following with `-q64 -qpic=large` and link with only `-q64`:
> ```
> #define x2A( BASE ) BASE ## a, BASE ## b
> #define x2B( BASE ) x2A(BASE ## a), x2A(BASE ## b)
> #define x2C( BASE ) x2B(BASE ## a), x2B(BASE ## b)
> #define x2D( BASE ) x2C(BASE ## a), x2C(BASE ## b)
> #define x2E( BASE ) x2D(BASE ## a), x2D(BASE ## b)
> #define x2F( BASE ) x2E(BASE ## a), x2E(BASE ## b)
> #define x2G( BASE ) x2F(BASE ## a), x2F(BASE ## b)
> #define x2H( BASE ) x2G(BASE ## a), x2G(BASE ## b)
> #define x2I( BASE ) x2H(BASE ## a), x2H(BASE ## b)
> #define x2J( BASE ) x2I(BASE ## a), x2I(BASE ## b)
> #define x2K( BASE ) x2J(BASE ## a), x2J(BASE ## b)
>
> #define x2KA( BASE ) x2K(BASE ## a), x2K(BASE ## b)
> #define x2KB( BASE ) x2KA(BASE ## a), x2KA(BASE ## b)
> int x2KB( x );
>
> int main(void) { x2KB( ++x ); }
> ```
Okay, it seems `-fPIC` does not enable the large code model for GCC on AIX (but does for the new XL compilers). `-mcmodel=large` should be added for GCC; however, the linker option remains necessary.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58250/new/
https://reviews.llvm.org/D58250
More information about the llvm-commits
mailing list