Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest update to Ubuntu 20.04 image breaks gcc compiler #6280

Closed
2 of 10 tasks
bobbrow opened this issue Sep 21, 2022 · 16 comments
Closed
2 of 10 tasks

Latest update to Ubuntu 20.04 image breaks gcc compiler #6280

bobbrow opened this issue Sep 21, 2022 · 16 comments

Comments

@bobbrow
Copy link

bobbrow commented Sep 21, 2022

Description

My VS Code extension's CI cannot run with the latest 20.04 image because CMake cannot configure our projects with the new way of acquiring the gcc compiler.

Runner Image
  Image: ubuntu-20.04
  Version: 20220920.2
  Included Software: https://github.com/actions/runner-images/blob/ubuntu20/20220920.2/images/linux/Ubuntu2004-Readme.md
  Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu20%2F20220920.2
Error: ools] 2022-09-21T19:09:34.498Z [error] [cmake] CMake Error at /home/runner/work/_temp/685782585/cmake-3.18.3-Linux-x86_64/share/cmake-3.18/Modules/CMakeTestCCompiler.cmake:66 (message):
Error: ools] 2022-09-21T19:09:34.499Z [error] [cmake]   The C compiler
Error: ools] 2022-09-21T19:09:34.499Z [error] [cmake] 
Error: ools] 2022-09-21T19:09:34.500Z [error] [cmake]     "/home/linuxbrew/.linuxbrew/bin/gcc-12"
Error: ools] 2022-09-21T19:09:34.501Z [error] [cmake] 
Error: ools] 2022-09-21T19:09:34.501Z [error] [cmake]   is not able to compile a simple test program.
Error: ools] 2022-09-21T19:09:34.501Z [error] [cmake] 
Error: ools] 2022-09-21T19:09:34.502Z [error] [cmake]   It fails with the following output:
Error: ools] 2022-09-21T19:09:34.502Z [error] [cmake] 
Error: ools] 2022-09-21T19:09:34.503Z [error] [cmake]     Change Dir: /home/runner/work/vscode-cmake-tools/vscode-cmake-tools/test/extension-tests/successful-build/project-folder/build/CMakeFiles/CMakeTmp
Error: ools] 2022-09-21T19:09:34.503Z [error] [cmake]     
Error: ools] 2022-09-21T19:09:34.503Z [error] [cmake]     Run Build Command(s):/home/runner/work/_temp/[68](https://github.com/Danielmelody/vscode-cmake-tools/actions/runs/3100401406/jobs/5020640848#step:12:69)5782585/ninja cmTC_21dc4 && [1/2] Building C object CMakeFiles/cmTC_21dc4.dir/testCCompiler.c.o
Error: ools] 2022-09-21T19:09:34.503Z [error] [cmake]     [2/2] Linking C executable cmTC_21dc4
Error: ools] 2022-09-21T19:09:34.503Z [error] [cmake]     FAILED: cmTC_21dc4 
Error: ools] 2022-09-21T19:09:34.503Z [error] [cmake]     : && /home/linuxbrew/.linuxbrew/bin/gcc-12  -rdynamic CMakeFiles/cmTC_21dc4.dir/testCCompiler.c.o -o cmTC_21dc4   && :
Error: ools] 2022-09-21T19:09:34.504Z [error] [cmake]     /usr/bin/ld: cannot find -lc
Error: ools] 2022-09-21T19:09:34.504Z [error] [cmake]     collect2: error: ld returned 1 exit status
Error: ools] 2022-09-21T19:09:34.504Z [error] [cmake]     ninja: build stopped: subcommand failed.
Error: ools] 2022-09-21T19:09:34.504Z [error] [cmake]     
Error: ools] 2022-09-21T19:09:34.504Z [error] [cmake]     
Error: ools] 2022-09-21T19:09:34.504Z [error] [cmake] 
Error: ools] 2022-09-21T19:09:34.504Z [error] [cmake]   
Error: ools] 2022-09-21T19:09:34.505Z [error] [cmake] 
Error: ools] 2022-09-21T19:09:34.505Z [error] [cmake]   CMake will not be able to correctly generate this project.
Error: ools] 2022-09-21T19:09:34.506Z [error] [cmake] Call Stack (most recent call first):
Error: ools] 2022-09-21T19:09:34.506Z [error] [cmake]   CMakeLists.txt:2 (project)
Error: ools] 2022-09-21T19:09:34.506Z [error] [cmake] 
Error: ools] 2022-09-21T19:09:34.507Z [error] [cmake]

Platforms affected

  • Azure DevOps
  • GitHub Actions

Runner images affected

  • Ubuntu 18.04
  • Ubuntu 20.04
  • Ubuntu 22.04
  • macOS 10.15
  • macOS 11
  • macOS 12
  • Windows Server 2019
  • Windows Server 2022

Image version and build link

Image: ubuntu-20.04
Version: 20220920.2

Failed build example: https://github.com/microsoft/vscode-cmake-tools/actions/runs/3100498232

Is it regression?

yes. version 20220905.1 works in this build: https://github.com/microsoft/vscode-cmake-tools/actions/runs/3100420383/jobs/5020681191

Expected behavior

CMake should be able to compile a test program without any additional configuration from my side

Actual behavior

The compilation test fails. Logs are in the description

Repro steps

Probably just have to try to configure a simple cmake project.

Write out the following files into a folder:
CMakeLists.txt

project(test)
add_executable(test main.cpp)

main.cpp

int main() {}

Open a terminal, navigate to the folder with those files in it and run:

cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=/home/linuxbrew/.linuxbrew/bin/gcc-12 -DCMAKE_CXX_COMPILER:FILEPATH=/home/linuxbrew/.linuxbrew/bin/g++-12 -G Ninja -B build/ -S .
@bobbrow
Copy link
Author

bobbrow commented Sep 21, 2022

#6258

@mikhailkoliada
Copy link
Contributor

@bobbrow Hello!

Do I understand correctly that you are using gcc-12? If so, you should either:

  • remove homebrew from your $PATH
  • change homebrew's place in $PATH to be less preferable
  • change the way your CMakeLists.txt acquires gcc

gcc dependency is now mandatory brew dependency on Ubuntu 18 and 20 so this can not be changed anyhow other than the ways I described above.

@bobbrow
Copy link
Author

bobbrow commented Sep 21, 2022

We use whatever version of gcc we find on the image. It used to be gcc 9.4, I believe. This new brew version seems to be found ahead of the version that ships with the LTS. We don't really care if a new version (e.g. 12) appears as long as it can compile. It seems that brew's version of the compiler is incorrectly configured and cannot be used, so it needs to be patched or removed.

@mikhailkoliada
Copy link
Contributor

I am not sure that brew's gcc is fully compatible with what cmake make do, but I guess @MikeMcQuaid can fix me, or at least he might know a person who can.

I am mainly concerned how you came with the

cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=/home/linuxbrew/.linuxbrew/bin/gcc-12 -DCMAKE_CXX_COMPILER:FILEPATH=/home/linuxbrew/.linuxbrew/

Invocation.

Is this auto-generated or whatever else, because if I explicitly call your command with gcc/g++ from /usr/bin - it works

@bobbrow
Copy link
Author

bobbrow commented Sep 21, 2022

Yes, I also noticed that when we don't specify a compiler explicitly that CMake will select the usual default /usr/bin/gcc and it works. The problem is that our extension has a feature that discovers compilers on the machine and lets our customers select the one they want. Some of our tests will attempt to configure with one of those. This normally just works because a compiler is a compiler and it doesn't matter which one we choose. But this brew compiler doesn't work AND it puts itself at the front of the list (in the $PATH, I guess). As a result our test selects it instead of the /usr/bin/gcc one that it used to pick.

My point is that /home/linuxbrew/.linuxbrew/bin/gcc-12 does not appear to be a working compiler so it needs to be patched or removed from the $PATH so that we don't end up picking it. If you fix the image so that the new compiler works, I am fine with it being the first compiler we discover.

@mikhailkoliada
Copy link
Contributor

@bobbrow I've glanced through your logs one more time and it does not look like a gcc's problem. In your logs it is clearly stated that it searches for -lc which is in fact (g)libc. gcc@12 from brew pulls both, glibc and binutils for everything to be compatible I suppose. Given that homebrew maintainers have marked glibc as keg-only recently it does not install its symlinks into /usr/local anymore,
but you can still force glibc to do so by calling brew link --force glibc.

The entire workflow of mine is looking that way:

trigger:
- main

pool:
  vmImage: ubuntu-20.04

steps:
- bash: |
   brew link --force glibc
   cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=/home/linuxbrew/.linuxbrew/bin/gcc-12 -DCMAKE_CXX_COMPILER:FILEPATH=/home/linuxbrew/.linuxbrew/bin/g++-12 -G Ninja -B build/ -S .

and it works with the snippets of code you provided.

The other question is, do you want to continue relying on the compiler and toolchain outside the standard repository, only you know the answer :).
I'd probably phase out homebrew from PATH in your specific case.

@bobbrow
Copy link
Author

bobbrow commented Sep 22, 2022

What I don't understand is why should I need to modify the image to get a basic compilation to work? Can you add this line to your image so that everyone can benefit from it? Or remove gcc-12 from your brew install because it doesn't work out of the box.

@bobbrow
Copy link
Author

bobbrow commented Sep 22, 2022

Does #6240 solve my problem by removing brew stuff from the $PATH?

@mikhailkoliada
Copy link
Contributor

@bobbrow yes, it will, and that is exactly what we are going to do

@bobbrow
Copy link
Author

bobbrow commented Sep 22, 2022

Thank you @mikhailkoliada!

@carlocab
Copy link
Contributor

Yes, this was broken by making glibc keg-only, which we did upon request of the GitHub Actions team (see Homebrew/homebrew-core#110877). Doing brew link --force glibc does make this work.

@rouson
Copy link

rouson commented Sep 27, 2022

@carlocab thank you so much for posting this! I've been plagued by this for a few days and just landed upon your solution, which works for me!

@carlocab
Copy link
Contributor

@rouson glad that helped you. We're working on a fix for that, so you shouldn't need the brew link --force workaround for too long.

@mikhailkoliada
Copy link
Contributor

brew is generally not in $PATH now.

@SaratDev
Copy link

SaratDev commented Nov 21, 2022

Can someone help me with the final thing that works
I tried brew link --force glibc but it still doesn't work

@carlocab @rouson

@vogt31337
Copy link

I currently have the same Issue...

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

No branches or pull requests

6 participants