在 AIX 上构建 git 时 TOC 溢出

TOC overflow when building git on AIX

尝试在 AIX 6.1 上以 64 位编译 git 时出现以下链接错误:

$ ./configure "CFLAGS=-maix64" "CXXFLAGS=-maix64" "LDFLAGS=-maix64" && /usr/opt/freeware/bin/make

<compilation/linking output>

ld: 0711-781 ERROR: TOC overflow. TOC size: 90720       Maximum size: 65536
collect2: error: ld returned 12 exit status
make: *** [git] Error 1

您必须根据 ld: 0711-781 ERROR: TOC overflow

指定 -bbigtoc 链接器选项以避免此问题

正确的编译行是:

$ ./configure "CFLAGS=-maix64" "CXXFLAGS=-maix64" "LDFLAGS=-maix64 -Wl,-bbigtoc" && /usr/opt/freeware/bin/make

其他解决方案包括:

  • 将大段代码分解成较小的编译单元
  • 减少编译单元中的变量数量