Skip to content

Commit

Permalink
gdb: Flexible target matching for darwin
Browse files Browse the repository at this point in the history
Outside of the nix-build the target is `x86_64-apple-darwin17.4.0`,
while inside the target is `x86_64-apple-darwin`. This difference
causes the fallback target configuration for darwin, which disables
gdb. Add a patch to make the target matching more flexible.
  • Loading branch information
thefloweringash committed Mar 7, 2018
1 parent dc1e064 commit 4c76a21
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions pkgs/development/tools/misc/gdb/darwin-target-match.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/configure 2017-06-05 00:51:26.000000000 +0900
+++ b/configure 2018-03-06 23:12:58.000000000 +0900
@@ -3603,7 +3603,7 @@
noconfigdirs="$noconfigdirs ld gprof"
noconfigdirs="$noconfigdirs sim target-rda"
;;
- x86_64-*-darwin[912]*)
+ x86_64-*-darwin*)
noconfigdirs="$noconfigdirs ld gas gprof"
noconfigdirs="$noconfigdirs sim target-rda"
;;
3 changes: 2 additions & 1 deletion pkgs/development/tools/misc/gdb/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ stdenv.mkDerivation rec {
sha256 = "0d2bpqk58fqlx21rbnk8mbcjlggzc9kb5sjirrfrrrjq70ka0qdg";
};

patches = [ ./debug-info-from-env.patch ];
patches = [ ./debug-info-from-env.patch ]
++ stdenv.lib.optional stdenv.isDarwin ./darwin-target-match.patch;

nativeBuildInputs = [ pkgconfig texinfo perl setupDebugInfoDirs ]
# TODO(@Ericson2314) not sure if should be host or target
Expand Down

2 comments on commit 4c76a21

@matthewbauer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If anyone has the time, could they report this upstream? I think because GDB and GCC share the source tree this will come up again next time we update GCC.

@thefloweringash
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if there's a bug here.

gdb's ./config.guess incorporates the result of uname -r in the host variable, which the configure script expects to match on with x86_64-*-darwin[912]*.

$ ./gdb-8.1/config.guess
x86_64-apple-darwin17.4.0

Nix is explicitly setting the host to without a suffix.

nix-repl> gdb.configureFlags
[ ... "--build=x86_64-apple-darwin" "--host=x86_64-apple-darwin" ]

These need to be aligned somehow. The patch makes x86_64-apple-darwin a valid platform for gdb.

Please sign in to comment.