How do I inject my own desired C++ compiler flags into a conda-build
flow?
I tried this, in my conda_build_config.yaml
file:
cxx_compiler:
- gxx # [linux]
- clangxx -Wno-c++11-narrowing # [osx]
- vs2019 # [win]
And I got:
conda.exceptions.InvalidVersionSpec: Invalid version '-Wno-c++11-narrowing_osx-64': invalid character(s)
Then I tried this:
CXXFLAGS="-Wno-c++11-narrowing" conda build ...
but I got the same error I was getting originally:
kiva/agg/src/kiva_graphics_context_base.cpp:637:27: error: non-constant-expression cannot be narrowed from type 'int' to 'double' in initializer list [-Wc++11-narrowing]
double tmp[] = {0, 0, img->width(), img->height()};
So, I'm guessing my explicit setting of the CXXFLAGS
environment variable is just being ignored by conda-build
.
(Is that correct?)
Then, I tried this, in the meta.yaml
file:
build:
number: 3
script: "CXXFLAGS='-Wno-c++11-narrowing' {{ PYTHON }} -m pip install . --no-deps --ignore-installed -vv "
But, I still got the same original error.
Digging deeper, I found the Inherited Environment Variables section of the conda-build
documentation, which suggests doing this:
build:
{snip}
script_env:
- CXXFLAGS=-Wno-c++11-narrowing
But, I still get the same error when I try this.
How does one get a custom compiler flag inserted into a conda-build
flow?
I think my last attempt above is actually doing what it's supposed to, because I find this line in my ~/miniconda3/conda-bld/enable_1680434176391/work/build_env_setup.sh
file:
export CXXFLAGS="-Wno-c++11-narrowing"
So, is the problem really that my build command:
python -m pip install . --no-deps --ignore-installed -vv
is ignoring the setting of the CXXFLAGS
environment variable?
D'oh! This (in the meta.yaml
file) worked:
build:
{snip}
script_env:
- CFLAGS=-Wno-c++11-narrowing
Sure enough, buried in the conda-build
documentation (Scroll to the end of the section.) I find this:
The environment variables listed in the following table are defined only on macOS.
CFLAGS | -arch flag |
CXXFLAGS | Same as CFLAGS |
{snip}
If ever there was a candidate for a top-of-the-page "quick alert". :(