conda-forge / ctng-compiler-activation-feedstock

A conda-smithy repository for ctng-compiler-activation.
BSD 3-Clause "New" or "Revised" License
13 stars 26 forks source link

gfortran compiler activate/deactivate round-trip leaves LDFLAGS set #16

Closed duncanmmacleod closed 4 years ago

duncanmmacleod commented 4 years ago

Issue:

When you create an environment that includes gfortran_linux-64 (via fortran-compiler), then activate it, LDFLAGS gets set along with a few other variables. However, when you then deactivate again, the LDFLAGS remains:

$ env | grep FLAGS
$ conda create --name test fortran-compiler --quiet

Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##

  environment location: /home/duncan.macleod/.conda/envs/test

  added / updated specs:
    - fortran-compiler

The following NEW packages will be INSTALLED:

  _libgcc_mutex      conda-forge/linux-64::_libgcc_mutex-0.1-conda_forge
  _openmp_mutex      conda-forge/linux-64::_openmp_mutex-4.5-0_gnu
  binutils-meta      conda-forge/linux-64::binutils-meta-1.0.4-0
  binutils_impl_lin~ conda-forge/linux-64::binutils_impl_linux-64-2.33.1-h53a641e_8
  binutils_linux-64  conda-forge/linux-64::binutils_linux-64-2.33.1-h9595d00_16
  fortran-compiler   conda-forge/linux-64::fortran-compiler-1.0.4-he991be0_0
  gcc_impl_linux-64  conda-forge/linux-64::gcc_impl_linux-64-7.3.0-hd420e75_4
  gcc_linux-64       conda-forge/linux-64::gcc_linux-64-7.3.0-h553295d_16
  gfortran_impl_lin~ conda-forge/linux-64::gfortran_impl_linux-64-7.3.0-hdf63c60_4
  gfortran_linux-64  conda-forge/linux-64::gfortran_linux-64-7.3.0-h553295d_16
  ld_impl_linux-64   conda-forge/linux-64::ld_impl_linux-64-2.33.1-h53a641e_8
  libgcc-ng          conda-forge/linux-64::libgcc-ng-9.2.0-h24d8f2e_2
  libgfortran-ng     conda-forge/linux-64::libgfortran-ng-7.3.0-hdf63c60_4
  libgomp            conda-forge/linux-64::libgomp-9.2.0-h24d8f2e_2
  libstdcxx-ng       conda-forge/linux-64::libstdcxx-ng-9.2.0-hdf63c60_2

Proceed ([y]/n)? y

Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
$ conda activate test
(test) $ env | grep FLAGS
LDFLAGS=-Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,-rpath,/home/duncan.macleod/.conda/envs/test/lib -Wl,-rpath-link,/home/duncan.macleod/.conda/envs/test/lib -L/home/duncan.macleod/.conda/envs/test/lib
CPPFLAGS=-DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/duncan.macleod/.conda/envs/test/include
DEBUG_FORTRANFLAGS=-fopenmp -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/duncan.macleod/.conda/envs/test/include -fopenmp -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-all -fno-plt -Og -g -Wall -Wextra -fcheck=all -fbacktrace -fimplicit-none -fvar-tracking-assignments -ffunction-sections -pipe
CONDA_BACKUP_LDFLAGS=-Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,-rpath,/home/duncan.macleod/.conda/envs/test/lib -Wl,-rpath-link,/home/duncan.macleod/.conda/envs/test/lib -L/home/duncan.macleod/.conda/envs/test/lib
DEBUG_FFLAGS=-fopenmp -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/duncan.macleod/.conda/envs/test/include -fopenmp -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-all -fno-plt -Og -g -Wall -Wextra -fcheck=all -fbacktrace -fimplicit-none -fvar-tracking-assignments -ffunction-sections -pipe
FORTRANFLAGS=-fopenmp -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/duncan.macleod/.conda/envs/test/include
DEBUG_CPPFLAGS=-D_DEBUG -D_FORTIFY_SOURCE=2 -Og -isystem /home/duncan.macleod/.conda/envs/test/include
CFLAGS=-march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/duncan.macleod/.conda/envs/test/include
DEBUG_CFLAGS=-march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-all -fno-plt -Og -g -Wall -Wextra -fvar-tracking-assignments -ffunction-sections -pipe -isystem /home/duncan.macleod/.conda/envs/test/include
FFLAGS=-fopenmp -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/duncan.macleod/.conda/envs/test/include
(test) $ conda deactivate
$ env | grep FLAGS
LDFLAGS=-Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,-rpath,/home/duncan.macleod/.conda/envs/test/lib -Wl,-rpath-link,/home/duncan.macleod/.conda/envs/test/lib -L/home/duncan.macleod/.conda/envs/test/lib
CONDA_BACKUP_FORTRANFLAGS=-fopenmp -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/duncan.macleod/.conda/envs/test/include
CONDA_BACKUP_FFLAGS=-fopenmp -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/duncan.macleod/.conda/envs/test/include
CONDA_BACKUP_DEBUG_CPPFLAGS=-D_DEBUG -D_FORTIFY_SOURCE=2 -Og -isystem /home/duncan.macleod/.conda/envs/test/include
CONDA_BACKUP_LDFLAGS=-Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,-rpath,/home/duncan.macleod/.conda/envs/test/lib -Wl,-rpath-link,/home/duncan.macleod/.conda/envs/test/lib -L/home/duncan.macleod/.conda/envs/test/lib
CONDA_BACKUP_DEBUG_FFLAGS=-fopenmp -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/duncan.macleod/.conda/envs/test/include
CONDA_BACKUP_DEBUG_CFLAGS=-march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-all -fno-plt -Og -g -Wall -Wextra -fvar-tracking-assignments -ffunction-sections -pipe -isystem /home/duncan.macleod/.conda/envs/test/include
CONDA_BACKUP_DEBUG_FORTRANFLAGS=-fopenmp -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/duncan.macleod/.conda/envs/test/include
CONDA_BACKUP_CFLAGS=-march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/duncan.macleod/.conda/envs/test/include
CONDA_BACKUP_CPPFLAGS=-DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/duncan.macleod/.conda/envs/test/include


Environment (conda list):

``` $ conda list # packages in environment at /home/duncan.macleod/.conda/envs/test: # # Name Version Build Channel _libgcc_mutex 0.1 conda_forge conda-forge _openmp_mutex 4.5 0_gnu conda-forge binutils-meta 1.0.4 0 conda-forge binutils_impl_linux-64 2.33.1 h53a641e_8 conda-forge binutils_linux-64 2.33.1 h9595d00_16 conda-forge fortran-compiler 1.0.4 he991be0_0 conda-forge gcc_impl_linux-64 7.3.0 hd420e75_4 conda-forge gcc_linux-64 7.3.0 h553295d_16 conda-forge gfortran_impl_linux-64 7.3.0 hdf63c60_4 conda-forge gfortran_linux-64 7.3.0 h553295d_16 conda-forge ld_impl_linux-64 2.33.1 h53a641e_8 conda-forge libgcc-ng 9.2.0 h24d8f2e_2 conda-forge libgfortran-ng 7.3.0 hdf63c60_4 conda-forge libgomp 9.2.0 h24d8f2e_2 conda-forge libstdcxx-ng 9.2.0 hdf63c60_2 conda-forge ```


Details about conda and system ( conda info ):

``` $ conda info active environment : test active env location : /home/duncan.macleod/.conda/envs/test shell level : 1 user config file : /home/duncan.macleod/.condarc populated config files : /cvmfs/oasis.opensciencegrid.org/ligo/sw/conda/.condarc /home/duncan.macleod/.condarc conda version : 4.8.1 conda-build version : 3.18.11 python version : 3.7.4.final.0 virtual packages : __glibc=2.17 base environment : /cvmfs/oasis.opensciencegrid.org/ligo/sw/conda (read only) channel URLs : https://conda.anaconda.org/conda-forge/linux-64 https://conda.anaconda.org/conda-forge/noarch https://repo.anaconda.com/pkgs/main/linux-64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/r/linux-64 https://repo.anaconda.com/pkgs/r/noarch https://conda.anaconda.org/igwn/linux-64 https://conda.anaconda.org/igwn/noarch package cache : /var/tmp/duncan.macleod/conda/pkgs /cvmfs/oasis.opensciencegrid.org/ligo/sw/conda/pkgs envs directories : /home/duncan.macleod/.conda/envs /cvmfs/oasis.opensciencegrid.org/ligo/sw/conda/envs platform : linux-64 user-agent : conda/4.8.1 requests/2.22.0 CPython/3.7.4 Linux/3.10.0-957.12.2.el7.x86_64 rhel/7.6 glibc/2.17 UID:GID : 100002171:100002171 netrc file : None offline mode : False ```

This doesn't seem to happen when I install only the c-compiler (gcc_linux-64) or the cxx-compiler (gxx_linux-64) packages.

isuruf commented 4 years ago

This happens because both gfortran_linux-64 and gcc_liunx-64 tries to set LDFLAGS, but gcc_linux-64 is a dependency of gfortran_linux-64. We can remove setting of LDFLAGS in activate-gfortran.sh and deactivate-gfortran.sh. Can you send a PR?