domq / homebrew-gdb

Backported 8.0.1 gdb
9 stars 4 forks source link

macOS Big Sur and Xcode/CLT 12.5 does not compile/build #2

Open paulmadejong opened 3 years ago

paulmadejong commented 3 years ago

Thanks for these fixes. Would be great if gdb is functional again after all this time.

However, compiling gdb failed for me on Big Sur 11.4. I first had to remove CommandLineTools (10.15 from my previous Catalina install) to reinstall it again to get rid of the warning that a newer version was available. Once CLT were reinstalled, homebrew attempted to compile gdb using the brew command of this post but it fails with a few errors:

Last 15 lines from /Users/jong/Library/Logs/Homebrew/gdb/02.make:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:331:9: error: no member named 'islessgreater' in the global namespace
using ::islessgreater;
      ~~^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:332:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:333:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
  CXX    xtensa-linux-tdep.o
13 errors generated.
make[2]: *** [xml-tdesc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [all-gdb] Error 2
make: *** [all] Error 2

From the created logfile I can see that homebrew uses the following CLT and Xcode versions (also reported by brew doctor):

CLT: 12.5.1.0.1.1623191612
Xcode: 12.5.1
HOMEBREW_SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

Currently xcrun uses the Xcode.APP SDK which doesn't affect HOMEBREW_SDKROOT apparently:

xcrun --show-sdk-path
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk

However, I've also tried setting it the the CLT SDK but the error persist. I have no idea how to change HOMEBREW_SDKROOT.

Another attempt to resolve this was by upgrading gcc and g++ through homebrew since the previously installed versions had the old sysroot when running gcc/g++ -v. The new versions of gcc and g++ (11+) did not resolve the error though.

Anyone any other ideas?

srwarner commented 3 years ago

Hey Paul, Dominque, turns out Simon (GDB guy) is asking me to merge your changes into my pool - so I can get the combined set of fixes into 11.0 GDB. I'm about to "git am" your changes '21 04-08 into my tree.

Ultimately my goal is to get Eclipse/CDT reliable, having seen the 2020/06 Eclipse/CDT to have instability issues on start-up of a debug session. I noticed that when I gdb'd gdb (debugged gdb using gdb) that the system would often hang too, which apparently your changes resolve. So, maybe I can help save some time by merging the changes into my tree, and build/share for your use.

I also reached out the Homebrew and Macports -which to get the net result updated on their distributions sites.

Hi Paul, I created a build environment first using gcc, and gdb 10.2 sources (sent the info on that mike Myers spot). I have all the versions of the tools I used documented. I think if you repro to use exactly the same tools you'll resolve your build environment. I saved this in a Parallel's guest.

After I had working gdb built from these tools I copied the Paralle's guest, then installed the beta Xcode. The build still functions if I am careful to mimic the 1st guests environment. Yet, doing so removes many of the SDKs content supplied when installing Xcode. For the moment, I tabled the effort of getting the Xcode build to function - but I intend to get this working. Perhaps we can collaborate more.

phil-blain commented 2 years ago

I think the core of the issue is that Homebrew always builds with clang/clang++, and so uses libc++, but almost nobody that develops GDB works on macOS (or another systems whose default C++ standard library is libc++), and so the codebase just does not work with lib++ (only with libsdc++). I don't think there is any way to convince Homebrew to use GCC (the real one, not /usr/bin/gcc which really is clang).

So, as @srwarner describes, it's really easier to download the GDB tarball, apply the patches in https://github.com/domq/homebrew-gdb/blob/master/Formula/gdb.rb manually, then ./configure CC=gcc-$VERSION CXX=g++-$VERSION etc.

phil-blain commented 2 years ago

And for anyone wondering, "that Mike Myers spot" that @swarner mentions is https://gist.github.com/mike-myers-tob/9a6013124bad7ff074d3297db2c98247