mesonbuild / meson

The Meson Build System

Home Page:http://mesonbuild.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AIXDynamicLinker not taking blibpath via LDFLAGS environment variable

KamathForAIX opened this issue · comments

If an AIX user, uses the export LDFLAGS="-Wl,-blibpath:/opt/freeware/lib/pthread:/opt/freeware/lib64" for a '.so' file built with the shared module function, then the blibpath is not the same in the '.so' file. Currently meson relies on the compiler's blibpath to get the blibpath to be added for a '.so' file. We want to enable LDFLAGS way to pass blibpath as well via the AIXDynamicLinker in meson.

This is usually the case in GNU's configure and make.

One place where this will be useful in AIX is:-

When an attempt to import a python module in a C program is made, a core dump happens, since Meson currently adds /opt/freeware/lib to blibpath. But we want the 64-bit libpython3.9.a to be loaded, which is at /opt/freeware/lib64.

The root cause of the issue is we have two libpython. One at /opt/freeware/lib and the other at /opt/freeware/lib64 where the 64 bit python library exists. We need to get the '.so' in 64 bit, to link to the '/opt/freeware/lib64' libpython.

To Reproduce
One can build pandas or scipy on AIX.

Then run an embedded C program; one example is below.

cat /customer_exp/bar.c

#include "Python.h"
void bar(void)
{
    Py_Initialize();
    if ( !Py_IsInitialized() )
    {
        return;
    }
 
    printf("doing import scipy:\n");
    PyRun_SimpleString("import scipy");
    PyRun_SimpleString("print('hello from python')");
    printf("import done\n");
 
    Py_Finalize();
} 

Expected behavior
The imports should happen even when one imports a Python module from a C program.

system parameters

  • Is this a cross build or just a plain native build (for the same computer)?
    Native AIX build
  • what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.)
    AIX
  • what Python version are you using e.g. 3.8.0
    3.9/3.11
  • what `meson --version
    1.4.0

In order to fix the same,, we are proposing to add the blibpath provided by the LDFLAGS environment variable to what meson is currently adding. We can do this in AIXDynamicLinker.

Requesting the community to share their thoughts and suggestions for the issue.