Skip to content

Detect compilers from environment variables #529

@awvwgk

Description

@awvwgk

Build systems like CMake and meson can read the compiler from the FC and CC environment variables or detect the archiver from the AR environment variable. Similarly the FFLAGS and CFLAGS variables can be used to pass flags for the compilation.

For example, below are environment variables usually set in a conda-build process:

ADDR2LINE=$BUILD_PREFIX/bin/x86_64-conda-linux-gnu-addr2line
AR=$BUILD_PREFIX/bin/x86_64-conda-linux-gnu-ar
AS=$BUILD_PREFIX/bin/x86_64-conda-linux-gnu-as
CXXFILT=$BUILD_PREFIX/bin/x86_64-conda-linux-gnu-c++filt
CC=$BUILD_PREFIX/bin/x86_64-conda-linux-gnu-cc
CFLAGS=-march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem $PREFIX/include -fdebug-prefix-map=$SRC_DIR=/usr/local/src/conda/fpm-0.3.0 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix
CPPFLAGS=-DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem $PREFIX/include
CPP=$BUILD_PREFIX/bin/x86_64-conda-linux-gnu-cpp
# ...
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
INFO: activate-gfortran_linux-64.sh made the following environmental changes:
F77=$BUILD_PREFIX/bin/x86_64-conda-linux-gnu-gfortran
F90=$BUILD_PREFIX/bin/x86_64-conda-linux-gnu-gfortran
F95=$BUILD_PREFIX/bin/x86_64-conda-linux-gnu-f95
FC=$BUILD_PREFIX/bin/x86_64-conda-linux-gnu-gfortran
FFLAGS=-fopenmp -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem $PREFIX/include -fdebug-prefix-map=$SRC_DIR=/usr/local/src/conda/fpm-0.3.0 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix
FORTRANFLAGS=-fopenmp -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem $PREFIX/include -fdebug-prefix-map=$SRC_DIR=/usr/local/src/conda/fpm-0.3.0 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix
GFORTRAN=$BUILD_PREFIX/bin/x86_64-conda-linux-gnu-gfortran

Automatically picking up some of this information would reduce the packaging of any fpm project for conda to just:

fpm install --prefix $PREFIX

Metadata

Metadata

Assignees

No one assigned

    Labels

    easyDifficulty level is easy and good for starting into this projectenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions