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

brew install gcc: postinstall broken (gcc-13) #137991

Closed
jwhite007 opened this issue Jul 29, 2023 · 47 comments
Closed

brew install gcc: postinstall broken (gcc-13) #137991

jwhite007 opened this issue Jul 29, 2023 · 47 comments
Labels
bug Reproducible Homebrew/homebrew-core bug outdated PR was locked due to age stale No recent activity

Comments

@jwhite007
Copy link

brew gist-logs <formula> link OR brew config AND brew doctor output

$ brew config
HOMEBREW_VERSION: 4.1.2
ORIGIN: https://github.com/Homebrew/brew
HEAD: 3db1acf3e38e270af4e1c3f214622bbfb18f830e
Last commit: 2 days ago
Core tap JSON: 29 Jul 14:51 UTC
HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: /usr/bin/env vim
HOMEBREW_GITHUB_API_TOKEN: set
HOMEBREW_LOGS: /home/linuxbrew/.logs/Homebrew
HOMEBREW_MAKE_JOBS: 48
HOMEBREW_TEMP: /home/linuxbrew/.temp
Homebrew Ruby: 2.6.10 => /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.10_1/bin/ruby
CPU: 48-core 64-bit broadwell
Clang: N/A
Git: 2.39.3 => /bin/git
Curl: 7.61.1 => /bin/curl
Kernel: Linux 4.18.0-477.15.1.el8_8.x86_64 x86_64 GNU/Linux
OS: Red Hat Enterprise Linux release 8.8 (Ootpa) (Ootpa)
Host glibc: 2.28
/usr/bin/gcc: 8.5.0
/usr/bin/ruby: N/A
glibc: N/A
gcc@11: N/A
gcc: N/A
xorg: N/A
$ brew dr
Your system is ready to brew.


### Verification

- [X] My "`brew doctor` output" says `Your system is ready to brew.` and am still able to reproduce my issue.
- [X] I ran `brew update` and am still able to reproduce my issue.
- [X] I have resolved all warnings from `brew doctor` and that did not fix my problem.
- [X] I searched for recent similar issues at https://github.com/Homebrew/homebrew-core/issues?q=is%3Aissue and found no duplicates.

### What were you trying to do (and why)?

```$ brew install gcc``` because that is suggested by the output after installing homebrew (linuxbrew).

### What happened (include all command output)?

$ brew postinstall --debug gcc
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading gcc from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading glibc from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading linux-headers@5.15 from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading gcc from API
/usr/bin/env /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/shims/shared/git --version
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading gmp from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading m4 from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading isl from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading libmpc from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading mpfr from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading zstd from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading lz4 from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading xz from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading cmake from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading openssl@3 from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading ca-certificates from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading ncurses from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading pkg-config from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading gpatch from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading zlib from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading binutils from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading bison from API
==> Postinstalling gcc
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FromPathLoader): loading /home/linuxbrew/.linuxbrew/opt/gcc/.brew/gcc.rb
Warning: The post-install step did not complete successfully
You can try again using:
brew postinstall gcc
==> An exception occurred within a child process:
ErrorDuringExecution: Failure while executing; /home/linuxbrew/.linuxbrew/Cellar/gcc/13.1.0/bin/gcc-13 -print-libgcc-file-name was terminated by uncaught signal SEGV. Here's the output:

/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/utils/popen.rb:12:in popen_read' /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/utils/popen.rb:16:in safe_popen_read'
/home/linuxbrew/.linuxbrew/opt/gcc/.brew/gcc.rb:151:in post_install' /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:1255:in block (2 levels) in run_post_install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:1055:in with_logging' /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:1254:in block in run_post_install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/extend/kernel.rb:499:in with_env' /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:1250:in run_post_install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/postinstall.rb:24:in `

'


### What did you expect to happen?

clean installation of gcc

### Step-by-step reproduction instructions (by running `brew` commands)

```shell
$ brew install gcc```
@jwhite007 jwhite007 added the bug Reproducible Homebrew/homebrew-core bug label Jul 29, 2023
@jwhite007
Copy link
Author

Additional information:

$ gcc-13 --version
Segmentation fault

@fxcoudert
Copy link
Member

Reminding me of this: #132852

@jwhite007
Copy link
Author

@fxcoudert, It's very much like #132852. In fact, there is a link to one of my older issues on that issue. I was under the impression that all of that had been resolved, so I created this issue thinking it unrelated.

@osalbahr
Copy link
Sponsor Contributor

osalbahr commented Aug 1, 2023

Might be related:

I think this happens on systems where gcc is missing or doesn’t work. What’s the output of which -a gcc? Does the systems’s gcc work?


$ brew install gcc because that is suggested by the output after installing homebrew (linuxbrew).

That’s fair. I don’t know why install.sh recommends.


Side note: odds are, gcc is the only formula that you can’t install and your Homebrew installation is fine. I’m not aware of another formula that breaks for a similar reason.

@osalbahr
Copy link
Sponsor Contributor

osalbahr commented Aug 1, 2023

If you have a working gcc then this might be the issue of having old glibc:

Host glibc: 2.28

I recommend taking a look at this issue:

@jwhite007
Copy link
Author

@osalbahr,

Thanks, but I think that is an unrelated issue. The one I'm posting about is due to a SEGV, segmentation violation.

@osalbahr
Copy link
Sponsor Contributor

osalbahr commented Aug 1, 2023

@osalbahr,

Thanks, but I think that is an unrelated issue. The one I'm posting about is due to a SEGV, segmentation violation.

I think the segmentation fault will go away once the postinstall goes through.

@jwhite007
Copy link
Author

jwhite007 commented Aug 4, 2023

@osalbahr,

glibc v2.28 should be fine. brew dr does not complain about it.

Update: After reading thoroughly through #135068 to which you link above, maybe you're onto something. glibc was installed to my linuxbrew, glibc@2.35_1; however, as can be seen in my brew config output above it's reported as N/A. I'll tinker with some things this weekend. Thanks.

@jwhite007
Copy link
Author

Does anyone know if this is due to the known patchelf issue or is this something else? I had assumed that the patchelf issue had been fixed.

@osalbahr
Copy link
Sponsor Contributor

osalbahr commented Aug 4, 2023

@osalbahr,

glibc v2.28 should be fine. brew dr does not complain about it.

You’re right, v2.28 is higher than Homebrew’s requirement. Though to rule it out, I’d try to link binutils and see if that fixes it. I don’t know if brew doctor checks the glibc version to begin with.

Update: After reading thoroughly through #135068 to which you link above, maybe you're onto something. glibc was installed to my linuxbrew, glibc@2.35_1; however, as can be seen in my brew config output above it's reported as N/A. I'll tinker with some things this weekend. Thanks.

I’m not sure what the N/A means. That might just be a minor bug in brew config itself and if so then the config output is not related. Having old glibc is an edge case that is best-effort maintained by Homebrew afaik.

All I know is that:

  1. brew postinstall gcc fails in systems where glibc is “too old” (I don’t know the specific version where the gcc postinstall fails)
  2. The old host glibc can be worked around by linking binutils (since it’s keg only)

Does anyone know if this is due to the known patchelf issue or is this something else? I had assumed that the patchelf issue had been fixed.

To the best of my knowledge, yes the patchelf issue was fixed, but not 100% sure. Though I’d assume the error message due to the patchelf issue was different than the error that happens when the host glibc is old.

@jwhite007
Copy link
Author

jwhite007 commented Aug 5, 2023

@osalbahr,

Well, I tried the brew postinstall --debug gcc after doing brew link --force binutils, and I'm facing the same error.

I'm experiencing a different issue than that reported at #135068.

From #135068:

$ touch test.c
$ gcc-13 test.c
/usr/bin/ld: /home/linuxbrew/.linuxbrew/Cellar/gcc/13.1.0/bin/../libexec/gcc/x86_64-pc-linux-gnu/13/liblto_plugin.so: error loading plugin: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /home/linuxbrew/.linuxbrew/Cellar/gcc/13.1.0/bin/../libexec/gcc/x86_64-pc-linux-gnu/13/liblto_plugin.so)
collect2: error: ld returned 1 exit status

From my machine (even after linking binutils):

$ touch test.c
$ gcc-13 test.c
Segmentation fault

That's what was happening with the patchelf issue.

@osalbahr
Copy link
Sponsor Contributor

osalbahr commented Aug 5, 2023

Yeah, I think this confirms it’s not the old glibc issue.

CC @carlocab @Bo98 looks like the patchelf.rb issue mentioned in #126054 might’ve resurfaced? To the best of my knowledge it was fixed, I could be misremembering.

@osalbahr
Copy link
Sponsor Contributor

osalbahr commented Aug 5, 2023

@jwhite007 do you still get the error with several formulae just like back in

or just with gcc?

@jwhite007
Copy link
Author

@osalbahr,

Of the applications that I mention on #116841, interestingly only ccat results in a segmentation fault. R and more from util-linux are seemingly fine. So could it be that the patchelf issue has been rectified, but there are certain stragglers that have yet to be re-built using it? Could that be the case with ccat and gcc@13?

@jwhite007 jwhite007 changed the title brew install gcc: postinstall broken brew install gcc: postinstall broken (gcc-13) Aug 6, 2023
@osalbahr
Copy link
Sponsor Contributor

osalbahr commented Aug 6, 2023

Are you able to get any logs that might be of help? I’d try to run ccat under ltrace and strace to see how far down the line the crash happens. And gdb (or GEF) for a possible backtrace. It’s hard to tell what the issue might be without knowing how to replicate it.

(I’m assuming brew doctor doesn’t complain)

@osalbahr
Copy link
Sponsor Contributor

osalbahr commented Aug 6, 2023

... interestingly only ccat results in a segmentation fault. ... So could it be that the patchelf issue has been rectified, but there are certain stragglers that have yet to be re-built using it? Could that be the case with ccat and gcc@13?

Maybe so for ccat, but not gcc@13:
https://github.com/Homebrew/homebrew-core/commits/master/Formula/ccat.rb - last bottled on Nov 21, 2022
https://github.com/Homebrew/homebrew-core/commits/master/Formula/gcc.rb - last bottled on Apr 30 (2023)

@osalbahr
Copy link
Sponsor Contributor

osalbahr commented Aug 6, 2023

@jwhite007 does building from source (as a workaround) fix it?

HOMEBREW_NO_INSTALL_FROM_API=1 brew install -s ccat

@jwhite007
Copy link
Author

@osalbahr,

$ brew dr
Your system is ready to brew.

$ ltrace ccat test.txt
enable_breakpoint pid=437411, addr=0x469c60, symbol=(null): Input/output error
enable_breakpoint pid=437411, addr=0x52f920, symbol=sigismember: Input/output error
enable_breakpoint pid=437411, addr=0x52f910, symbol=sigaction: Input/output error
enable_breakpoint pid=437411, addr=0x52f900, symbol=sigaddset: Input/output error
enable_breakpoint pid=437411, addr=0x52f8f0, symbol=sigemptyset: Input/output error
enable_breakpoint pid=437411, addr=0x52f8e0, symbol=unsetenv: Input/output error
enable_breakpoint pid=437411, addr=0x52f8d0, symbol=setenv: Input/output error
enable_breakpoint pid=437411, addr=0x52f8c0, symbol=munmap: Input/output error
enable_breakpoint pid=437411, addr=0x52f8b0, symbol=mmap: Input/output error
enable_breakpoint pid=437411, addr=0x52f8a0, symbol=pthread_sigmask: Input/output error
enable_breakpoint pid=437411, addr=0x52f890, symbol=sigfillset: Input/output error
enable_breakpoint pid=437411, addr=0x52f880, symbol=__errno_location: Input/output error
enable_breakpoint pid=437411, addr=0x52f870, symbol=pthread_attr_destroy: Input/output error
enable_breakpoint pid=437411, addr=0x52f860, symbol=pthread_attr_getstacksize: Input/output error
enable_breakpoint pid=437411, addr=0x52f850, symbol=pthread_attr_init: Input/output error
enable_breakpoint pid=437411, addr=0x52f840, symbol=malloc: Input/output error
enable_breakpoint pid=437411, addr=0x52f830, symbol=free: Input/output error
enable_breakpoint pid=437411, addr=0x52f820, symbol=__fprintf_chk: Input/output error
enable_breakpoint pid=437411, addr=0x52f810, symbol=strerror: Input/output error
enable_breakpoint pid=437411, addr=0x52f800, symbol=pthread_detach: Input/output error
enable_breakpoint pid=437411, addr=0x52f7f0, symbol=nanosleep: Input/output error
enable_breakpoint pid=437411, addr=0x52f7e0, symbol=pthread_create: Input/output error
enable_breakpoint pid=437411, addr=0x52f7d0, symbol=pthread_cond_broadcast: Input/output error
enable_breakpoint pid=437411, addr=0x52f7c0, symbol=__stack_chk_fail: Input/output error
enable_breakpoint pid=437411, addr=0x52f7b0, symbol=pthread_mutex_unlock: Input/output error
enable_breakpoint pid=437411, addr=0x52f7a0, symbol=pthread_cond_wait: Input/output error
enable_breakpoint pid=437411, addr=0x52f790, symbol=pthread_mutex_lock: Input/output error
enable_breakpoint pid=437411, addr=0x52f780, symbol=abort: Input/output error
enable_breakpoint pid=437411, addr=0x52f770, symbol=fputc: Input/output error
enable_breakpoint pid=437411, addr=0x52f760, symbol=__vfprintf_chk: Input/output error
enable_breakpoint pid=437411, addr=0x52f750, symbol=fwrite: Input/output error
--- SIGSEGV (Segmentation fault) ---
+++ killed by SIGSEGV +++

$ strace ccat test.txt
execve("/home/linuxbrew/.linuxbrew/bin/ccat", ["ccat", "test.txt"], 0x7fff5a3c36c8 /* 58 vars */) = -1 EEXIST (File exists)
+++ killed by SIGSEGV +++
Segmentation fault (core dumped)

@osalbahr
Copy link
Sponsor Contributor

osalbahr commented Aug 7, 2023

execve("/home/linuxbrew/.linuxbrew/bin/ccat", ["ccat", "test.txt"], 0x7fff5a3c36c8 /* 58 vars */) = -1 EEXIST (File exists)
+++ killed by SIGSEGV +++
Segmentation fault (core dumped)

What does file /home/linuxbrew/.linuxbrew/bin/ccat tell you?

@jwhite007
Copy link
Author

@osalbahr,

Attempting to build ccat from source, as you suggest, results in a seg fault from go, on of ccat's build dependencies.

==> ./script/build
Last 15 lines from /home/linuxbrew/.logs/Homebrew/ccat/01.build:
2023-08-07 11:29:24 +0000

./script/build

./script/build: line 12: 442071 Segmentation fault      go build -o ccat

@osalbahr
Copy link
Sponsor Contributor

osalbahr commented Aug 7, 2023

execve("/home/linuxbrew/.linuxbrew/bin/ccat", ["ccat", "test.txt"], 0x7fff5a3c36c8 /* 58 vars */) = -1 EEXIST (File exists)
+++ killed by SIGSEGV +++
Segmentation fault (core dumped)

What does file /home/linuxbrew/.linuxbrew/bin/ccat tell you?

The reason I think this might be useful is through a quick search I found it might have to do with the loader? Also try to ld (ldd?) the executable, that might indicate what’s happening.

@jwhite007
Copy link
Author

jwhite007 commented Aug 7, 2023

@osalbahr,

Well, during the week I have to revert to my old installation of Linuxbrew as others on my team depend on it; however, I can do the following.

$ file $(readlink -f /home/linuxbrew/linuxbrew_20230806/bin/ccat)
/home/linuxbrew/.linuxbrew_20230806/Cellar/ccat/1.1.0/bin/ccat: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /home/linuxbrew/.linuxbrew/lib/ld.so, not stripped

$ ldd /home/linuxbrew/.linuxbrew_20230806/Cellar/ccat/1.1.0/bin/ccat
        linux-vdso.so.1 (0x00007ffdc65fc000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f57e3653000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f57e328e000)
        /home/linuxbrew/.linuxbrew/lib/ld.so => /lib64/ld-linux-x86-64.so.2 (0x00007f57e3873000)

@osalbahr
Copy link
Sponsor Contributor

osalbahr commented Aug 7, 2023

@osalbahr,

Well, during the week I have to revert to my old installation of Linuxbrew as others on my team depend on it; however, I can do the following.

$ file $(readlink -f /home/linuxbrew/linuxbrew_20230806/bin/ccat)
/home/linuxbrew/.linuxbrew_20230806/Cellar/ccat/1.1.0/bin/ccat: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /home/linuxbrew/.linuxbrew/lib/ld.so, not stripped

$ ldd /home/linuxbrew/.linuxbrew_20230806/Cellar/ccat/1.1.0/bin/ccat
        linux-vdso.so.1 (0x00007ffdc65fc000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f57e3653000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f57e328e000)
        /home/linuxbrew/.linuxbrew/lib/ld.so => /lib64/ld-linux-x86-64.so.2 (0x00007f57e3873000)

Do the files referenced in these two commands all exist?

@jwhite007
Copy link
Author

@osalbahr,

Well, I cannot find linux-vdso.so.1 anywhere, but the other files are there; however, I wouldn't suspect this to be a problem as the ldd output from ccat which works in my older Linuxbrew instance is exactly the same as can be seen below.

$ /home/linuxbrew/.linuxbrew/Cellar/ccat/1.1.0/bin/ccat test.txt
testing

$ ldd /home/linuxbrew/.linuxbrew/Cellar/ccat/1.1.0/bin/ccat
        linux-vdso.so.1 (0x00007ffe574f7000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f26123cd000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f2612008000)
        /home/linuxbrew/.linuxbrew/lib/ld.so => /lib64/ld-linux-x86-64.so.2 (0x00007f26125ed000)

Interestingly, ccat in both the older, functional Linuxbrew instance and the latest, dysfuctional instance appear to be the same version, 1.1.0, so it's probably some updated dep version that's causing the seg fault. brew deps ccat --installed returns nothing. In the output of brew info ccat is Required: gcc ✔, glibc ✔

@osalbahr
Copy link
Sponsor Contributor

osalbahr commented Aug 8, 2023

I wouldn't suspect this to be a problem as the ldd output from ccat which works in my older Linuxbrew instance is exactly the same as can be seen below

Is the *.so file missing too in your other system?

brew deps ccat --installed returns nothing. In the output of brew info ccat is Required: gcc ✔, glibc ✔

If you get this output, it is likely that ccat just doesn’t have dependencies. I think brew info always shows gcc and glibc for all formulae in systems deemed outdated.

@jwhite007
Copy link
Author

@osalbahr,

To be clear, I'm switching between two different Linuxbrew instances on the same system, so all of the system libs are the same. The only libs that would be different would be the Linuxbrew-installed libs and linux-vdso.so.1 is found in neither of those.

$ ls .linuxbrew/lib/linux-vdso.so.1
ls: cannot access '.linuxbrew/lib/linux-vdso.so.1': No such file or directory

$ ls .linuxbrew_20230806/lib/linux-vdso.so.1
ls:` cannot access '.linuxbrew_20230806/lib/linux-vdso.so.1': No such file or directory

@jwhite007
Copy link
Author

@osalbahr,

My impression is that, going forward, Linuxbrew just isn't going to work all that well on RHEL or CentOS.

@osalbahr
Copy link
Sponsor Contributor

osalbahr commented Aug 16, 2023

@osalbahr,

My impression is that, going forward, Linuxbrew just isn't going to work all that well on RHEL or CentOS.

You might be correct. It’s hard to tell without being able to replicate the error on my end. Like I said above, I have been using Homebrew on CentOS 7 just fine. Both in an HPC computing cluster and in containers.

Let me know if you’re able to replicate the error in a VM such as VirtualBox or in a fresh install of a certain ISO.

@jwhite007
Copy link
Author

@osalbahr,

Well, I suppose it may be time to start looking into using the Nix package manager.

@osalbahr
Copy link
Sponsor Contributor

@osalbahr,

Well, I suppose it may be time to start looking into using the Nix package manager.

This is getting a little off-topic, but yeah nix might work for your use case. Good luck!

@cloudvii27
Copy link

I have this same issue. Any updates? I know there was a suggested workaround to revert the patchelf.rb update. Wondering if there is a permanent fix in the works

@osalbahr
Copy link
Sponsor Contributor

@cloudvii27 could you paste brew config and brew postinstall -vd gcc?

To the best of my understanding, the mentioned patchelf.rb error was resolved but the postinstall gcc fails in some systems and I don’t know if it’s for a related reason. It might help if it’s a reproducible bug by minimally replicating your environment on a different machine.

@cloudvii27
Copy link

@osalbahr, below is the output from brew config

$ brew config
HOMEBREW_VERSION: 4.1.7
ORIGIN: https://github.com/Homebrew/brew
HEAD: d4444b563e24ac7c05a93121c464c02dfa04d44f
Last commit: 18 hours ago
Core tap JSON: 28 Aug 13:08 UTC
HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_CURLRC: 1
HOMEBREW_DISPLAY: :0
HOMEBREW_MAKE_JOBS: 4
Homebrew Ruby: 2.6.10 => /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.10_1/bin/ruby
CPU: quad-core 64-bit skylake
Clang: N/A
Git: 2.42.0 => /home/linuxbrew/.linuxbrew/bin/git
Curl: 7.61.1 => /bin/curl
Kernel: Linux 4.18.0-477.21.1.el8_8.x86_64 x86_64 GNU/Linux
OS: Red Hat Enterprise Linux release 8.8 (Ootpa) (Ootpa)
Host glibc: 2.28
/usr/bin/gcc: 8.5.0
/usr/bin/ruby: N/A
glibc: 2.35_1
gcc@11: N/A
gcc: 13.1.0
xorg: N/A

and brew postinstall -vd gcc

$ brew postinstall -vd gcc
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading gcc from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading glibc from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading linux-headers@5.15 from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading gcc from API
/usr/bin/env /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/shims/shared/git --version
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading gmp from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading m4 from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading isl from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading libmpc from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading mpfr from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading zstd from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading lz4 from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading xz from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading cmake from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading openssl@3 from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading ca-certificates from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading ncurses from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading pkg-config from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading gpatch from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading zlib from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading binutils from API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading bison from API
==> Postinstalling gcc
Warning: The post-install step did not complete successfully
You can try again using:
  brew postinstall gcc
==> An exception occurred within a child process:
  ErrorDuringExecution: Failure while executing; `/home/linuxbrew/.linuxbrew/Cellar/gcc/13.1.0/bin/gcc-13 -print-libgcc-file-name` was terminated by uncaught signal SEGV. Here's the output:


/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/utils/popen.rb:12:in `popen_read'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/utils/popen.rb:16:in `safe_popen_read'
/home/linuxbrew/.linuxbrew/opt/gcc/.brew/gcc.rb:151:in `post_install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:1254:in `block (2 levels) in run_post_install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:1054:in `with_logging'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:1253:in `block in run_post_install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/extend/kernel.rb:499:in `with_env'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:1249:in `run_post_install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/postinstall.rb:24:in `<main>'

@osalbahr
Copy link
Sponsor Contributor

Not sure if this is the patchelf.rb error, CC @carlocab is this related?


@cloudvii27 I'm assuming brew doctor doesn't complain, forgot to ask about that.

I tried to replicate your error in a rockylinux:8.8 container (the closest I can think of) and got different behavior. If you are able to replicate in a VM, let me know.

==> Installing gcc
==> Pouring gcc--13.1.0.x86_64_linux.bottle.tar.gz
==> Creating the GCC specs file: /home/linuxbrew/.linuxbrew/Cellar/gcc/13.1.0/bin/../lib/gcc/current/gcc/x86_64-pc-linux-gnu/13
🍺  /home/linuxbrew/.linuxbrew/Cellar/gcc/13.1.0: 1,668 files, 320.0MB
==> Running `brew cleanup gcc`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
[linuxbrew@13329514f7e9 ~]$ cat > hello.c
#include <stdio.h>

int main() {
  puts("Hello, RockyLinux8.8");
}
[linuxbrew@13329514f7e9 ~]$ /home/linuxbrew/.linuxbrew/bin/gcc-13 hello.c -o hello
/usr/bin/ld: /home/linuxbrew/.linuxbrew/Cellar/gcc/13.1.0/bin/../libexec/gcc/x86_64-pc-linux-gnu/13/liblto_plugin.so: error loading plugin: /usr/lib64/libc.so.6: version `GLIBC_2.33' not found (required by /home/linuxbrew/.linuxbrew/Cellar/gcc/13.1.0/bin/../libexec/gcc/x86_64-pc-linux-gnu/13/liblto_plugin.so)
collect2: error: ld returned 1 exit status
[linuxbrew@13329514f7e9 ~]$ brew link --force binutils
Linking /home/linuxbrew/.linuxbrew/Cellar/binutils/2.41... 87 symlinks created.

If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/home/linuxbrew/.linuxbrew/opt/binutils/bin:$PATH"' >> /home/linuxbrew/.bash_profile
[linuxbrew@13329514f7e9 ~]$ /home/linuxbrew/.linuxbrew/bin/gcc-13 hello.c -o hello
[linuxbrew@13329514f7e9 ~]$ ./hello 
Hello, RockyLinux8.8
[linuxbrew@13329514f7e9 ~]$ brew doctor
Your system is ready to brew.
[linuxbrew@13329514f7e9 ~]$ brew config
HOMEBREW_VERSION: 4.1.7
ORIGIN: https://github.com/Homebrew/brew
HEAD: d4444b563e24ac7c05a93121c464c02dfa04d44f
Last commit: 20 hours ago
Core tap JSON: 28 Aug 16:10 UTC
HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 1
Homebrew Ruby: 2.6.10 => /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.10_1/bin/ruby
CPU: single-core 64-bit skylake
Clang: N/A
Git: 2.39.3 => /bin/git
Curl: 7.61.1 => /bin/curl
Kernel: Linux 6.4.11-200.fc38.x86_64 x86_64 GNU/Linux
OS: Rocky Linux release 8.8 (Green Obsidian)
Host glibc: 2.28
/usr/bin/gcc: 8.5.0
/usr/bin/ruby: N/A
glibc: 2.35_1
gcc@11: N/A
gcc: 13.1.0
xorg: N/A

Container info:

[linuxbrew@13329514f7e9 ~]$ brew install -q fastfetch
==> Fetching fastfetch
==> Caveats
Bash completion has been installed to:
  /home/linuxbrew/.linuxbrew/etc/bash_completion.d
==> Summary
🍺  /home/linuxbrew/.linuxbrew/Cellar/fastfetch/2.0.5: 38 files, 1.6MB
==> Running `brew cleanup fastfetch`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
[linuxbrew@13329514f7e9 ~]$ fastfetch
          __wgliliiligw_,              linuxbrew@13329514f7e9
       _williiiiiiliilililw,           ----------------------
     _%iiiiiilililiiiiiiiiiii_         OS: Rocky Linux 8.8 x86_64
   .Qliiiililiiiiiiililililiilm.       Host: KVM/QEMU Standard PC (Q35 + ICH9, 2009) (pc-q35-8.1)
  _iiiiiliiiiiililiiiiiiiiiiliil,      Kernel: 6.4.11-200.fc38.x86_64
 .lililiiilililiiiilililililiiiii,     Uptime: 28 mins
_liiiiiiliiiiiiiliiiiiF{iiiiiilili,    Packages: 13 (brew)
jliililiiilililiiili@`  ~ililiiiiiL    Shell: bash 4.4.20
iiiliiiiliiiiiiili>`      ~liililii    Display (QEMU Monitor): 1280x800
liliiiliiilililii`         -9liiiil    Cursor: Adwaita
iiiiiliiliiiiii~             "4lili    Terminal: xterm
4ililiiiiilil~|      -w,       )4lf    Terminal Font: fixed (8.0pt)
-liiiiililiF'       _liig,       )'    CPU: 06/8e @ 2.304037 GHz
 )iiiliii@`       _QIililig,           Memory: 286.90 MiB / 1.91 GiB (15%)
  )iiii>`       .Qliliiiililw          Locale: C.UTF-8
   )<>~       .mliiiiiliiiiiil,    
            _gllilililiililii~         ████████████████████████
           giliiiiiiiiiiiiT`           ████████████████████████
          -^~$ililili@~~'    

@cloudvii27
Copy link

@osalbahr No worries, here's the output from brew doctor

$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Putting non-prefixed coreutils in your path can cause GMP builds to fail.

could this warning about coreutils be related to the problem I'm experiencing?

Thanks for the suggestion about trying to replicate the problem in a container. I'm not experienced with containers, but I'll follow the steps you performed above and see what happens.

@osalbahr
Copy link
Sponsor Contributor

could this warning about coreutils be related to the problem I'm experiencing?

Not sure. I haven’t seen this error before.

@lewis6991
Copy link
Contributor

lewis6991 commented Sep 11, 2023

Sorry for a potentially unrelated drive-by but I'm getting similar glibc problems on by rhe7 machine.

I've recently started gettng this with a bunch of recipes:

==> Upgrading gnutls
  3.8.0 -> 3.8.1

==> ./configure --disable-silent-rules --disable-static --sysconfdir=/devtools/linuxbrew/etc --with-default-trust-store-file=/devtools/linuxbrew/etc/gnutls/cert.pem --disable-heartbeat-support --with-p11-kit
==> make install
Last 15 lines from /home/lewrus01/.cache/Homebrew/Logs/gnutls/02.make:
make[2]: *** [psktool] Error 1
make[2]: *** Waiting for unfinished jobs....
libtool: link: gcc-13 -fanalyzer -fno-common -Wall -Wbad-function-cast -Wcast-align=strict -Wdate-time -Wdisabled-optimization -Wdouble-promotion -Wduplicated-branches -Wduplicated-cond -Wextra -Winit-self -Winvalid-pch -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wmissing-prototypes -Wnested-externs -Wnull-dereference -Wold-style-definition -Wopenmp-simd -Wpacked -Wpointer-arith -Wshadow -Wstrict-prototypes -Wsuggest-attribute=cold -Wsuggest-attribute=format -Wsuggest-attribute=malloc -Wsuggest-final-methods -Wsuggest-final-types -Wsync-nand -Wtrampolines -Wuninitialized -Wunknown-pragmas -Wunused-macros -Wvariadic-macros -Wvector-operation-performance -Wwrite-strings -Warray-bounds=2 -Wattribute-alias=2 -Wbidi-chars=any,ucn -Wformat-overflow=2 -Wformat=2 -Wformat-truncation=2 -Wimplicit-fallthrough=5 -Wshift-overflow=2 -Wuse-after-free=3 -Wunused-const-variable=2 -Wvla-larger-than=4031 -Wno-analyzer-malloc-leak -Wno-missing-field-initializers -Wno-unused-parameter -Wno-format-truncation -Wimplicit-fallthrough=2 -Wabi=11 -fdiagnostics-show-option -fno-builtin-strcmp -g -O2 -o .libs/ocsptool ocsptool.o ocsptool-common.o certtool-common.o socket.o common.o  ../lib/.libs/libgnutls.so -L/devtools/linuxbrew/Cellar/p11-kit/0.25.0/lib -L/devtools/linuxbrew/Cellar/brotli/1.1.0/lib -L/devtools/linuxbrew/Cellar/zstd/1.5.5/lib -L/devtools/linuxbrew/Cellar/libidn2/2.3.4_1/lib -L/devtools/linuxbrew/Cellar/libtasn1/4.19.0/lib -L/devtools/linuxbrew/Cellar/nettle/3.9.1/lib -lz -lp11-kit -lbrotlienc -lbrotlidec -lzstd -lidn2 -lunistring -ltasn1 -lnettle -lhogweed -lgmp ./.libs/libcmd-ocsp.a ../gl/.libs/libgnu.a gl/.libs/libgnu_gpl.a -Wl,-rpath -Wl,/devtools/linuxbrew/Cellar/gnutls/3.8.1/lib
/devtools/linuxbrew/bin/ld: warning: libm.so.6, needed by /devtools/linuxbrew/lib/libbrotlienc.so, not found (try using -rpath or -rpath-link)
/devtools/linuxbrew/bin/ld: /devtools/linuxbrew/lib/libbrotlienc.so: undefined reference to `log2@GLIBC_2.29'
/devtools/linuxbrew/bin/ld: warning: libm.so.6, needed by /devtools/linuxbrew/lib/libbrotlienc.so, not found (try using -rpath or -rpath-link)
collect2: error: ld returned 1 exit status
make[2]: *** [gnutls-cli-debug] Error 1
/devtools/linuxbrew/bin/ld: /devtools/linuxbrew/lib/libbrotlienc.so: undefined reference to `log2@GLIBC_2.29'
collect2: error: ld returned 1 exit status
make[2]: *** [ocsptool] Error 1
make[2]: Leaving directory `/tmp/gnutls-20230911-24024-6xjjj6/gnutls-3.8.1/src'
make[1]: *** [install] Error 2
make[1]: Leaving directory `/tmp/gnutls-20230911-24024-6xjjj6/gnutls-3.8.1/src'
make: *** [install-recursive] Error 1

Which is weird since my system glibc is 2.17 and homebrew's version is 2.35, so I don't know where log2@GLIBC_2.29 is coming from.

@jwhite007
Copy link
Author

@lewis6991,

If you are ever experiencing the same problems as reported on a specific github issue, it's best to not only show your error output but also your output of "brew gist-logs link OR brew config AND brew doctor output"and the output of brew dr.

@osalbahr
Copy link
Sponsor Contributor

Which is weird since my system glibc is 2.17 and homebrew's version is 2.35, so I don't know where log2@GLIBC_2.29 is coming from.

@lewis6991 Looking at the output, I am assuming you are building from source due to using non-default prefix. You will know if you run brew doctor(and brew config output would be useful too). If that's the case, the error probably means compiling that formula from source wanted to use a glibc that you do not have, but it should work fine at runtime regardless since Homebrew requires glibc >= 2.13. Btw, do you get an error when using gcc too? I am curious if the error is related

Regardless, my advice, as a workaround, is to use the same prefix on an Ubuntu machine (virtualized or bare metal) then rsync -au the Homebrew directory over to your current machine (or your favorite sync method). So far this workaround has been working fine for me on Rocky Linux 8.8 (and earlier this year with CentOS 7)

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the stale No recent activity label Oct 18, 2023
@cloudvii27
Copy link

I'm still having this issue on a clean RHEL8 install. @jwhite007 were you able to resolve this with a permanent fix?

@github-actions github-actions bot removed the stale No recent activity label Oct 21, 2023
@jwhite007
Copy link
Author

@cloudvii27, I have mostly given up on using Linuxbrew in RHEL8. I'll keep using Homebrew on my Macs, of course, on which the Framework works very well. I don't expect the maintainers of Linuxbrew, to whom I already owe a lot of respect for what they do, to put in a whole lot of effort into this as seemingly those of us who want to use Linuxbrew in RHEL8 are surely a minority, a small minority.

I'm currently exploring other options for RHEL8 such as the Nix package manager; however, that appears to be quite some effort for what I need. I think the best bet for the use cases at my company, is to use a Conda env. We already use Conda envs for our production bioinformatics pipelines. We do switch into Conda using pyenv which is currently now installed via Linuxbrew. I'll probably install pyenv or possibly just Conda without using a package manager.

If I do get some sort of idea about the problem popping into my head, and I somehow stumble upon a fix, I'll post a comment here about the solution.

@cloudvii27
Copy link

@jwhite007 I tried installing gcc on a RHEL9 machine and it did not cause this error. Haven't thoroughly used Linuxbrew on RHEL9, but I'll probably move to it if it continues to work.

@jwhite007
Copy link
Author

@cloudvii27, thanks so much for that information. That's good news; however, now I have to convince our IT to upgrade to RHEL 9.

@jwhite007
Copy link
Author

@cloudvii27, have you been testing on RHEL 9.2, the latest stable?

@cloudvii27
Copy link

I wasn't sure, so I checked and it is indeed RHEL 9.2. I haven't done too much testing on it, but the install of gcc at least worked

Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the stale No recent activity label Nov 15, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 22, 2023
@github-actions github-actions bot added the outdated PR was locked due to age label Dec 23, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Reproducible Homebrew/homebrew-core bug outdated PR was locked due to age stale No recent activity
Projects
None yet
Development

No branches or pull requests

6 participants
@fxcoudert @jwhite007 @lewis6991 @osalbahr @cloudvii27 and others