Skip to content

bpo-35198 Fix C++ extension compilation on AIX#10437

Merged
vstinner merged 2 commits into
python:masterfrom
kadler:issue35198
Mar 4, 2019
Merged

bpo-35198 Fix C++ extension compilation on AIX#10437
vstinner merged 2 commits into
python:masterfrom
kadler:issue35198

Conversation

@kadler

@kadler kadler commented Nov 9, 2018

Copy link
Copy Markdown
Contributor

For C++ extensions, distutils tries to replace the C compiler with the
C++ compiler, but it assumes that C compiler is the first element after
any environment variables set. On AIX, linking goes through ld_so_aix,
so it is the first element and the compiler is the next element. Thus
the replacement is faulty:

ld_so_aix gcc ... -> g++ gcc ...

Also, it assumed that self.compiler_cxx had only 1 element or that
there were the same number of elements as the linker has and in the
same order. This might not be the case, so instead concatenate
everything together.

https://bugs.python.org/issue35198

For C++ extensions, distutils tries to replace the C compiler with the
C++ compiler, but it assumes that C compiler is the first element after
any environment variables set. On AIX, linking goes through ld_so_aix,
so it is the first element and the compiler is the next element. Thus
the replacement is faulty:

ld_so_aix gcc ... -> g++ gcc ...

Also, it assumed that self.compiler_cxx had only 1 element or that
there were the same number of elements as the linker has and in the
same order. This might not be the case, so instead concatenate
everything together.
@ayappanec

Copy link
Copy Markdown
Contributor

This PR fixed the issue which we are facing with building of pandas-0.23.4.
g++ gcc -maix64 -pthread -bI:/opt/freeware/lib/python3.6/config-3.6m/python.exp -L. -L/usr/include -L/opt/freeware/include -L/usr/lib/threads -L/opt/freeware/lib64 -L/opt/freeware/lib -L/usr/lib64 -L/usr/lib -L. -L/usr/include -L/opt/freeware/include -L/usr/lib/threads -L/opt/freeware/lib64 -L/opt/freeware/lib -L/usr/lib64 -L/usr/lib build/temp.aix-7.2-3.6/pandas/_libs/window.o -L/opt/freeware/lib64 -o build/lib.aix-7.2-3.6/pandas/_libs/window.so
g++: error: gcc: No such file or directory
g++: error: unrecognized command line option '-bI:/opt/freeware/lib/python3.6/config-3.6m/python.exp'
error: command 'g++' failed with exit status 1

Comment thread Lib/distutils/unixccompiler.py Outdated
@kadler

kadler commented Mar 2, 2019

Copy link
Copy Markdown
Contributor Author

@vstinner I've greatly simplified the fix and it should only affect AIX platforms now. Let me know if you have further thoughts/concerns.

I can squash the commits, if desired.

@vstinner
vstinner merged commit 800d5cd into python:master Mar 4, 2019
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @kadler for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 4, 2019
For C++ extensions, distutils tries to replace the C compiler with the
C++ compiler, but it assumes that C compiler is the first element after
any environment variables set. On AIX, linking goes through ld_so_aix,
so it is the first element and the compiler is the next element. Thus
the replacement is faulty:

ld_so_aix gcc ... -> g++ gcc ...

Also, it assumed that self.compiler_cxx had only 1 element or that
there were the same number of elements as the linker has and in the
same order. This might not be the case, so instead concatenate
everything together.
(cherry picked from commit 800d5cd)

Co-authored-by: Kevin Adler <kadler@us.ibm.com>
@bedevere-bot

Copy link
Copy Markdown

GH-12162 is a backport of this pull request to the 3.7 branch.

@vstinner

vstinner commented Mar 4, 2019

Copy link
Copy Markdown
Member

Even if I don't know anything about AIX, I trust @kadler to have tested his change. Since the new version of his change doesn't affect other platforms, I'm now fine with it.

miss-islington added a commit that referenced this pull request Mar 4, 2019
For C++ extensions, distutils tries to replace the C compiler with the
C++ compiler, but it assumes that C compiler is the first element after
any environment variables set. On AIX, linking goes through ld_so_aix,
so it is the first element and the compiler is the next element. Thus
the replacement is faulty:

ld_so_aix gcc ... -> g++ gcc ...

Also, it assumed that self.compiler_cxx had only 1 element or that
there were the same number of elements as the linker has and in the
same order. This might not be the case, so instead concatenate
everything together.
(cherry picked from commit 800d5cd)

Co-authored-by: Kevin Adler <kadler@us.ibm.com>
@kadler

kadler commented Mar 4, 2019

Copy link
Copy Markdown
Contributor Author

Yes, I tested on both an AIX and a Linux environment to verify the new change worked and did not affect other platforms.

@kadler
kadler deleted the issue35198 branch March 4, 2019 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants