Skip to content

Compiling With Local Environment Variables (PATH, LD_LIBRARY, PKG_CONFIG_PATH) #40

Closed

Description

@grammy-jiang

Currently the compiling step uses a pure environment variables (

def xenv_CPATH(self):
), and ignore the local environment variables.

For example, I want to compile Python with a custom GCC, like use devtoolset-11 in centos 7.9:

foo@bar:~$ scl enable devtoolset-11 rh-python38 -- portable-python build 3.7.17

SCL will introduce the GCC to PATH and LD_LIBRARY, and for now portable-python will ignore these environment variable.

Is this design in purpose? If not, I would like to create a pull request to fix.

Activity

  1. grammy-jiang commented on Feb 26, 2024

    @grammy-jiang
    ContributorAuthor

    The scl enable devtoolset-11 executes the following:

    # General environment variables
    export PATH=/opt/rh/devtoolset-11/root/usr/bin${PATH:+:${PATH}}
    export MANPATH=/opt/rh/devtoolset-11/root/usr/share/man${MANPATH:+:${MANPATH}}
    export INFOPATH=/opt/rh/devtoolset-11/root/usr/share/info${INFOPATH:+:${INFOPATH}}
    export PCP_DIR=/opt/rh/devtoolset-11/root
    # bz847911 workaround:
    # we need to evaluate rpm's installed run-time % { _libdir }, not rpmbuild time
    # or else /etc/ld.so.conf.d files?
    rpmlibdir=$(rpm --eval "%{_libdir}")
    # bz1017604: On 64-bit hosts, we should include also the 32-bit library path.
    # bz1873882: On 32-bit hosts, we should include also the 64-bit library path.
    # bz2027377: Avoid unbound variables
    if [ "$rpmlibdir" != "${rpmlibdir/lib64/}" ]; then
      rpmlibdir32=":/opt/rh/devtoolset-11/root${rpmlibdir/lib64/lib}"
      dynpath32="$rpmlibdir32/dyninst"
      rpmlibdir64=
      dynpath64=
    else
      rpmlibdir64=":/opt/rh/devtoolset-11/root${rpmlibdir/lib/lib64}"
      dynpath64="$rpmlibdir64/dyninst"
      rpmlibdir32=
      dynpath32=
    fi
    # Add SCL dyninst to LD_LIBRARY_PATH, both 64- and 32-bit paths.
    export LD_LIBRARY_PATH=/opt/rh/devtoolset-11/root$rpmlibdir/dyninst$dynpath64$dynpath32${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
    # Now prepend the usual /opt/.../usr/lib{64,}.
    export LD_LIBRARY_PATH=/opt/rh/devtoolset-11/root$rpmlibdir$rpmlibdir64$rpmlibdir32${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
    export PKG_CONFIG_PATH=/opt/rh/devtoolset-11/root/usr/lib64/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}
  2. zsimic commented on Feb 28, 2024

    @zsimic
    Contributor

    The idea was to not rely on env vars on build host, but conservatively set them so that a build would be as portable as possible.

    We can review that yes, thinking here you'd want to use existing LD_LIBRARY_PATH and PKG_CONFIG_PATH?

    PR welcome, I think the current one is too conservative perhaps + it is trivial to ensure env vars clean on builder with an export LD_LIBRARY_PATH= if need be.

  3. grammy-jiang commented on Apr 3, 2024

    @grammy-jiang
    ContributorAuthor

    I just made a simple pull request for this feature, #44.

    Maybe a setting can be added to portable-python.yaml to enable/disable this feature, how do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions