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

gnm (binutils) fails on Mojave (and breaks gcc-8) #32516

Closed
ggouaillardet opened this issue Sep 28, 2018 · 11 comments
Closed

gnm (binutils) fails on Mojave (and breaks gcc-8) #32516

ggouaillardet opened this issue Sep 28, 2018 · 11 comments
Labels
10.14 Mojave is specifically affected outdated PR was locked due to age upstream issue An upstream issue report is needed xcode10 Xcode 10 is specifically affected

Comments

@ggouaillardet
Copy link
Contributor

When the binutils formula is not installed, gcc-8 works just fine

KA15-002: gilles$ cat conftest.c 
int main(int argc, char *argv[]) {
    return 0;
}
KA15-002:ompi-master-gcc8 gilles$ gcc-8 conftest.c 
KA15-002:ompi-master-gcc8 gilles$ gnm a.out 
-bash: gnm: command not found

now, after installing binutils, the same command fails

KA15-002: gilles$ brew install binutils
==> Downloading https://homebrew.bintray.com/bottles/binutils-2.31.1.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring binutils-2.31.1.mojave.bottle.tar.gz
🍺  /usr/local/Cellar/binutils/2.31.1: 114 files, 170.8MB
KA15-002: gilles$ gcc-8 conftest.c 
collect2: fatal error: /usr/local/bin/gnm returned 1 exit status
compilation terminated

Here is the error generated by manually invoking gnm

KA15-002: gilles$ /usr/local/bin/gnm a.out 
/usr/local/bin/gnm: a.out: unknown load command 0x32
/usr/local/bin/gnm: a.out: unknown load command 0x32
/usr/local/bin/gnm: a.out: unknown load command 0x32
/usr/local/bin/gnm: a.out: file format not recognized

Unsurprisingly, removing the binutils formula solves the issue.

KA15-002: gilles$ brew uninstall binutils
Uninstalling /usr/local/Cellar/binutils/2.31.1... (114 files, 170.8MB)
KA15-002:ompi-master-gcc8 gilles$ gcc-8 conftest.c 

I initially thought something was wrong with my system (I recently upgraded OS X from High Sierra to Mojave) so uninstalled brew and made a fresh install with just a few packages, and am still able to reproduce the very same issue.

@ggouaillardet ggouaillardet changed the title gnm (binutils) fails on Mojave gnm (binutils) fails on Mojave (and breaks gcc-8) Sep 28, 2018
@fxcoudert fxcoudert added the upstream issue An upstream issue report is needed label Sep 28, 2018
@fxcoudert
Copy link
Member

Indeed, it appears that binutils' gnm cannot read MachO files:

bli /tmp $ cat a.c
int main (void) { return 0; }
bli /tmp $ clang -c a.c 
bli /tmp $ file a.o    
a.o: Mach-O 64-bit object x86_64
bli /tmp $ gnm a.o
gnm: a.o: unknown load command 0x32
gnm: a.o: unknown load command 0x32
gnm: a.o: unknown load command 0x32
gnm: a.o: file format not recognized
bli /tmp $ gnm --version
GNU nm (GNU Binutils) 2.31.1
Copyright (C) 2018 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.

Could you report this bug to the binutils project? It does not appear to be specific to Homebrew.

@ggouaillardet
Copy link
Contributor Author

done

the bug report is available at https://sourceware.org/bugzilla/show_bug.cgi?id=23728

Meanwhile, should something been done for Mojave (such as not installing /usr/local/bin/gnm) in order not to break gcc-8 ?

@ghost

This comment has been minimized.

@ghost

This comment has been minimized.

@ggouaillardet
Copy link
Contributor Author

@dmarinescu your trolling is very unwelcome here, good speed.

@wukefe
Copy link

wukefe commented Oct 1, 2018

Hi @ggouaillardet, I have the same problem with Xcode 10, the latest version. (I don't think it is caused by the new OS Mojave because gcc works nicely with old Xcode 7 on Mojave.)

A temporary solution is to set nm to gnm as follows

mv /usr/local/bin/gnm /usr/local/bin/gnm-backup
ln -s /usr/bin/nm /usr/local/bin/gnm

@fxcoudert
Copy link
Member

We could introduce a conflict between the two packages, but in general that's not true. It's a case of bug in binutils, so I would suggest to simply uninstall the binutils until it is fixed in a new version.

@ggouaillardet
Copy link
Contributor Author

@fxcoudert I was something in between. For example, we could install nm in /usr/local/bin/gnm-binutils on Mojave/XCode 10

The benefits (to be tested) are :

  • gcc-8 works out of the box regardless binutils is installed or not
  • some other utils provided by binutils that might not be broken are available

@zbeekman
Copy link
Contributor

I'm going to open a PR to make binutils keg_only since it's so incredibly broken/janky on macOS.

@zbeekman zbeekman mentioned this issue Oct 26, 2018
4 tasks
@zbeekman zbeekman added 10.14 Mojave is specifically affected xcode10 Xcode 10 is specifically affected labels Oct 26, 2018
zbeekman added a commit to zbeekman/homebrew-core that referenced this issue Oct 29, 2018
`gnm` is broken with macOS 10.14 Mojave/XCode 10. This breaks gcc when
binutils is linked.

Fixes: Homebrew#32516

See also: https://sourceware.org/bugzilla/show_bug.cgi?id=23728
zbeekman added a commit that referenced this issue Oct 30, 2018
`gnm` is broken with macOS 10.14 Mojave/XCode 10. This breaks gcc when
binutils is linked.

Fixes: #32516

See also: https://sourceware.org/bugzilla/show_bug.cgi?id=23728
@roolebo
Copy link
Contributor

roolebo commented Nov 6, 2018

Patch series to address the issue has been sent upstream: https://sourceware.org/ml/binutils/2018-11/msg00031.html

@mistydemeo
Copy link
Member

This now-upstreamed patch fixes it: https://sourceware.org/bugzilla/show_bug.cgi?id=23728

I've added it in Homebrew/formula-patches#256

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
10.14 Mojave is specifically affected outdated PR was locked due to age upstream issue An upstream issue report is needed xcode10 Xcode 10 is specifically affected
Projects
None yet
Development

No branches or pull requests

6 participants