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

Environment dependent conda-build #7

Closed pearu closed 2 years ago

pearu commented 5 years ago

Issue:

Consider an example conda recipe with the following build.sh script:

echo "LDFLAGS=$LDFLAGS"

When running LDFLAGS= conda-build /path/to/example/recipe, the output will be

LDFLAGS=-Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,-rpath,$PREFIX/lib -Wl,-rpath-link,$PREFIX/lib -L$PREFIX/lib

However, when LDFLAGS is not empty, for instance, run LDFLAGS="-L/path/to/foo" conda-build /path/to/example/recipe, the output is

LDFLAGS=-Lpath/to/foo

I am not sure if this is a bug or not but the result of building a conda recipe from an environment that defines LDFLAGS will be different from the result of the build the recipe where LDFLAGS is not defined. And it's not obvious to figure it out when there are some build issues because of this.

Possible options to resolve this issue:

  1. When LDFLAGS is defined, conda-build should prepend its flags to LDFLAGS.
  2. When LDFLAGS is defined, conda-build should warn that it will use LDFLAGS as it is without adding its flags to LDFLAGS.
  3. When LDFLAGS is defined, raise an exception.
  4. When LDFLAGS is defined, issue a warning that LDFLAGS in an environment will be ignored.

All the above applies also for environment variables CFLAGS, CXXFLAGS, etc.

isuruf commented 4 years ago

I'm fine with 1. PRs welcome.

isuruf commented 2 years ago

cc @beckermr

beckermr commented 2 years ago

Thanks for the pointer @isuruf!