# Are downstream projects meant to turn off IGRAPH\_WARNINGS\_AS\_ERRORS themselves?

**URL:** <https://igraph.discourse.group/t/are-downstream-projects-meant-to-turn-off-igraph-warnings-as-errors-themselves/860>\
**Category:** Installation\
**Tags:** C\
**Created:** [13 September 2021 00:55 UTC](https://igraph.discourse.group/t/are-downstream-projects-meant-to-turn-off-igraph-warnings-as-errors-themselves/860 "2021-09-13T00:55:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aaron](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/aaron/32/570_2.png) [@Aaron](https://igraph.discourse.group/u/Aaron)\
**Post date:** [13 September 2021 00:55 UTC](https://igraph.discourse.group/t/are-downstream-projects-meant-to-turn-off-igraph-warnings-as-errors-themselves/860/1 "2021-09-13T00:55:02Z")

</div>

I’m pulling down igraph as a dependency in one of my CMake projects (with `FetchContent`, though that’s not really relevant) and compiling it with clang 13.0.0, and I’m getting errors such as:

```auto
[5%] Building C object _deps/igraph-build/vendor/cs/CMakeFiles/cxsparse_vendored.dir/cs_qr.c.o
/home/luna/Code/JSscran/wasm/build/_deps/igraph-src/vendor/cs/cs_qr.c:7:21: error: variable 'm' set but not used [-Werror,-Wunused-but-set-variable]
    CS_INT i, k, p, m, n, vnz, p1, top, m2, len, col, rnz, *s, *leftmost, *Ap, *Ai,
                    ^
1 error generated.

```

Inspection of `cs_qr.c` in the current **igraph** master indicates that, indeed, `m` is set and assigned to but never used. There’s a few similar warnings-promoted-to-errors elsewhere in the code base that I won’t list here for the sake of brevity. I eventually worked around this by adding this to my CMakeLists:

```auto
set(IGRAPH_WARNINGS_AS_ERRORS OFF CACHE BOOL "" FORCE)

```

It seems that `IGRAPH_WARNINGS_AS_ERRORS` should default to OFF in the release tarball (I’m using the 0.9.4 release) to avoid these build problems. However, if downstream projects expected to set this themselves, then it should be listed in the installation instructions somewhere.

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [13 September 2021 07:52 UTC](https://igraph.discourse.group/t/are-downstream-projects-meant-to-turn-off-igraph-warnings-as-errors-themselves/860/2 "2021-09-13T07:52:21Z")

</div>

I would say that handling this is still under discussion on our side, so any input is welcome.

For future reference, as of today Clang 13 is not yet released. Nevertheless, I will give this a try with the version of Clang 13 I do have access to (may not be the same as your version). Please let me know what system you are using exactly (what Linux distro of macOS version), and where you got this prerelease version of Clang from.

Out of curiosity, what is your project? It helps us to be aware of downstream users, so we can better address their needs.

---

<div class="post-metadata">

**Author:** ![tamas](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/tamas/32/1261_2.png) [@tamas](https://igraph.discourse.group/u/tamas)\
**Post date:** [13 September 2021 09:35 UTC](https://igraph.discourse.group/t/are-downstream-projects-meant-to-turn-off-igraph-warnings-as-errors-themselves/860/3 "2021-09-13T09:35:07Z")

</div>

This is a recurrent topic 🙂 We try to keep igraph’s source code clean to a point when there are no warnings emitted by the compiler during compilation so we can easily spot any new warnings that are accidentally introduced when modifying the code. That’s why `-Werror` is on by default (it is all too easy to hastily run `mkdir build && cd build && cmake ..` and lose the benefits of `-Werror` if it is not on by default). On the other hand, maintainers of downstream packages may find this annoying and/or they could be working with a compiler that emits _more_ warnings than the ones we use, so we provide an option to turn this off.

The particular warning that you see comes from a vendored library (CXSparse), and, incidentally, I have started receiving warnings from OSS-Fuzz about our build failing there due to the very same warning. It started a few days ago so I strongly suspect that Clang new started flagging something with a warning. We try to refrain from modifying vendored source code and prefer to turn off warnings explicitly for certain vendored dependencies instead. I tried to add a [patch](https://github.com/igraph/igraph/commit/4d96a7796153314e5734a39bcf1611ac9646ee70) to prevent the warning, but I had to use `-Wno-unused-variable` instead of `-Wno-unused-but-set-variable` because older versions of Clang do not understand `-Wno-unused-but-set-variable`; let’s hope that it will be enough.

Apparently, this is a hot topic not only for us but also for far larger projects (e.g., [the Linux kernel itself](https://www.theregister.com/2021/09/08/compromise_linux_kernel_compiler_warnings/)). I’m open to suggestions about how to make this more convenient to everyone, but at the moment I’m still leaning towards enabling `-Werror` by default as this particular breakage 1) was caused by a toolchain that newly introduced a warning (i.e. we could not have anticipated the warning in advance), 2) is easy to work around in the downstream project, 3) will be fixed in the next patch release on igraph’s side as well. Constructive ideas are welcome. One option would be to turn off `-Werror` by default but then turn it on in all CI tests; the downside would be that sometimes the builds would pass locally on a dev’s machine but fail in CI, which leads to a longer iteration time.

---

<div class="post-metadata">

**Author:** ![Aaron](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/aaron/32/570_2.png) [@Aaron](https://igraph.discourse.group/u/Aaron)\
**Post date:** [14 September 2021 05:48 UTC](https://igraph.discourse.group/t/are-downstream-projects-meant-to-turn-off-igraph-warnings-as-errors-themselves/860/4 "2021-09-14T05:48:52Z")

</div>

Thanks @szhorvat, @tamas.

> [@szhorvat](#):
>
> Out of curiosity, what is your project? It helps us to be aware of downstream users, so we can better address their needs.

I’m using the Emscripten toolchain to compile igraph’s C core to Webassembly, so that I can run igraph’s methods in browser applications. It works pretty well; if you want to know more, we have a functional app at [https://www.jkanche.com/scran.js/app/app/](https://www.jkanche.com/scran.js/app/app/) that uses igraph’s multi-level community detection functionality for identifying clusters in single-cell RNA sequencing data.

Incidentally, this is where I’m getting the pre-release Clang; it’s bundled with the later versions of Emscripten.

> [@tamas](#):
>
> I’m open to suggestions about how to make this more convenient to everyone, but at the moment I’m still leaning towards enabling `-Werror` by default as this particular breakage 1) was caused by a toolchain that newly introduced a warning (i.e. we could not have anticipated the warning in advance), 2) is easy to work around in the downstream project, 3) will be fixed in the next patch release on igraph’s side as well.

I’ll add that point 2 can be made even easier if the installation instructions could mention that the `IGRAPH_WARNINGS_AS_ERRORS` option exists, and also provide some code to turn it off. I recall having to dig around in the CMakeLists to figure out what to do here.

---

<div class="post-metadata">

**Author:** ![tamas](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/tamas/32/1261_2.png) [@tamas](https://igraph.discourse.group/u/tamas)\
**Post date:** [14 September 2021 09:16 UTC](https://igraph.discourse.group/t/are-downstream-projects-meant-to-turn-off-igraph-warnings-as-errors-themselves/860/5 "2021-09-14T09:16:46Z")

</div>

> I’ll add that point 2 can be made even easier if the installation instructions could mention that the `IGRAPH_WARNINGS_AS_ERRORS` option exists, and also provide some code to turn it off.

That’s a good idea; there are tons of options in `CMakeLists.txt` that can be used to tweak the build, and as far as I know they are not documented anywhere. I’ll add an issue for it in the issue tracker.

---

<div class="post-metadata">

**Author:** ![tamas](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/tamas/32/1261_2.png) [@tamas](https://igraph.discourse.group/u/tamas)\
**Post date:** [14 September 2021 21:05 UTC](https://igraph.discourse.group/t/are-downstream-projects-meant-to-turn-off-igraph-warnings-as-errors-themselves/860/6 "2021-09-14T21:05:47Z")

</div>

Discussion continues on the issue tracker [here](https://github.com/igraph/igraph/issues/1812).
