Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Env variables left in cache causes gcc-11 builds on ubuntu to fail #222

Open
marques-bruno opened this issue May 12, 2022 · 5 comments
Open

Comments

@marques-bruno
Copy link

marques-bruno commented May 12, 2022

Hey!
I freshly forked your template on my github account, but the initial commit doesn't pass the CI checks for ubuntu with gcc-11.

It seems that some cached env variables are resurfacing during the "Configure CMake" step of the workflow, causing gcc to try to use clang includes, thus causing compile errors because of non-existent preprocessor defs (like __has_include())

"7_Configure CMake.txt" logs:
2022-05-12T15:26:59.9540894Z` LLVM_PATH: /opt/hostedtoolcache/llvm/13.0.0/x64
2022-05-12T15:26:59.9541186Z LD_LIBRARY_PATH: /opt/hostedtoolcache/llvm/13.0.0/x64/lib:
2022-05-12T15:26:59.9541494Z DYLD_LIBRARY_PATH: /opt/hostedtoolcache/llvm/13.0.0/x64/lib:
2022-05-12T15:26:59.9541805Z CPATH: /opt/hostedtoolcache/llvm/13.0.0/x64/lib/clang/13.0.0/include
2022-05-12T15:26:59.9542101Z LDFLAGS: -L/opt/hostedtoolcache/llvm/13.0.0/x64/lib
2022-05-12T15:26:59.9542388Z CPPFLAGS: -I/opt/hostedtoolcache/llvm/13.0.0/x64/include
2022-05-12T15:26:59.9542677Z LIBRARY_PATH: /opt/hostedtoolcache/llvm/13.0.0/x64/lib

Sadly that's as far as my (non-existing) github actions skills could take me and I couldn't find what sets those environment variables...

Thanks a lot for your templates, they are amazing!

@SK83RJOSH
Copy link

SK83RJOSH commented Sep 17, 2022

Having the same issue after forking this project. Causing half the test runs to fail and me a lot of misery. I hate to ping you directly, @lefticus but any chance this could be investigated?

edit: seems related to this.

@SK83RJOSH
Copy link

SK83RJOSH commented Sep 17, 2022

A very nasty fix for this is to override the environment variables. Change your .github/workflows/ci.yml build step to this and it should resolve compilation issues related to using incorrect headers:

      - name: Build
        # Clear out LLVM environment to avoid issues with GCC.
        env:
          LLVM_PATH: ""
          LD_LIBRARY_PATH: ""
          DYLD_LIBRARY_PATH: ""
          LDFLAGS: ""
          CPPFLAGS: ""
          LIBRARY_PATH: ""
          CPATH: ""
        # Execute the build. You can specify a specific target with "--target <NAME>"
        run: |
          cmake --build ./build --config ${{matrix.build_type}}

I didn't notice any regression with LLVM builds, so these environment variables are generally not required it seems. These appear to be introduced by setup-cpp when installing LLVM. So this may be something that @aminya might want to look at. I imagine it should be easy enough to clear these after the install on unix within setup-cpp itself.

This would also explain why these issues appeared suddenly with no relevant changes to this repository. The use of aminya/setup-cpp@v1 means a more recent pre-release got picked up that introduced this I guess?

@aminya
Copy link
Contributor

aminya commented Sep 18, 2022

Just pushed a patch to setup-cpp. Please try building again and see if the error persists.
aminya/setup-cpp@a8d76c6

@SK83RJOSH
Copy link

I haven't tested this just yet, but just a heads up that these pages (#1, #2) seem to indicate that you may want to unset LIBRARY_PATH, CPATH, CPPFLAGS at a minimum to avoid GCC issues. Then CMake uses LDFLAGS at link time as well. I think just about the only things that are safe to keep around are LD_LIBRARY_PATH/DYLD_LIBRARY_PATH, as they affect where the system searches for shared libraries (.dynlib/.so) from - but even that I'm a bit skeptical about. 🙂

@aminya
Copy link
Contributor

aminya commented Sep 19, 2022

CPPFLAGS is the only one that might cause issues because LLVM ships its own incompatible C headers.

I agree that setup-cpp should not set necessary flags when only clang-tidy and clang-format are installed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants