From a7c1541a214591999403654f083d8fb85ada38b4 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sat, 9 Aug 2014 18:57:08 +0200 Subject: [PATCH] emacs: Fix building on Darwin with recent versions of GCC This gets rid of the "unexec: unrecognized section __static_data in __DATA segment" error while dumping Emacs. --- .../emacs-24/darwin-new-sections.patch | 50 +++++++++++++++++++ .../applications/editors/emacs-24/default.nix | 2 + pkgs/top-level/all-packages.nix | 5 -- 3 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 pkgs/applications/editors/emacs-24/darwin-new-sections.patch diff --git a/pkgs/applications/editors/emacs-24/darwin-new-sections.patch b/pkgs/applications/editors/emacs-24/darwin-new-sections.patch new file mode 100644 index 00000000000..dfd72fe3f51 --- /dev/null +++ b/pkgs/applications/editors/emacs-24/darwin-new-sections.patch @@ -0,0 +1,50 @@ +http://bazaar.launchpad.net/~naesten/emacs/nextstep-stuff/revision/108961 + +diff -ru emacs-24.3-orig/src/unexmacosx.c emacs-24.3/src/unexmacosx.c +--- emacs-24.3-orig/src/unexmacosx.c 2013-01-01 21:37:17.000000000 +0100 ++++ emacs-24.3/src/unexmacosx.c 2014-08-09 18:39:52.000000000 +0200 +@@ -838,7 +838,7 @@ + if (!(sectp->addr <= (unsigned long)my_edata + && my_size <= sectp->size)) + unexec_error ("my_edata is not in section %s", SECT_DATA); +- if (!unexec_write (sectp->offset, (void *) sectp->addr, my_size)) ++ if (!unexec_write (sectp->offset, (void *) sectp->addr, sectp->size)) + unexec_error ("cannot write section %s", SECT_DATA); + if (!unexec_copy (sectp->offset + my_size, old_file_offset + my_size, + sectp->size - my_size)) +@@ -880,6 +880,27 @@ + if (!unexec_write (header_offset, sectp, sizeof (struct section))) + unexec_error ("cannot write section %.16s's header", sectp->sectname); + } ++ else if (strncmp (sectp->sectname, "__bss", 5) == 0 ++ || strncmp (sectp->sectname, "__pu_bss", 8) == 0) ++ { ++ sectp->flags = S_REGULAR; ++ ++ /* These sections are produced by GCC 4.6+. ++ ++ FIXME: We possibly ought to clear uninitialized local ++ variables in statically linked libraries like for ++ SECT_BSS (__bss) above, but setting up the markers we ++ need in lastfile.c would be rather messy. See ++ darwin_output_aligned_bss () in gcc/config/darwin.c for ++ the root of the problem, keeping in mind that the ++ sections are numbered by their alignment in GCC 4.6, but ++ by log2(alignment) in GCC 4.7. */ ++ ++ if (!unexec_write (sectp->offset, (void *) sectp->addr, sectp->size)) ++ unexec_error ("cannot copy section %.16s", sectp->sectname); ++ if (!unexec_write (header_offset, sectp, sizeof (struct section))) ++ unexec_error ("cannot write section %.16s's header", sectp->sectname); ++ } + else if (strncmp (sectp->sectname, "__la_symbol_ptr", 16) == 0 + || strncmp (sectp->sectname, "__nl_symbol_ptr", 16) == 0 + || strncmp (sectp->sectname, "__got", 16) == 0 +@@ -891,6 +912,7 @@ + || strncmp (sectp->sectname, "__program_vars", 16) == 0 + || strncmp (sectp->sectname, "__mod_init_func", 16) == 0 + || strncmp (sectp->sectname, "__mod_term_func", 16) == 0 ++ || strncmp (sectp->sectname, "__static_data", 16) == 0 + || strncmp (sectp->sectname, "__objc_", 7) == 0) + { + if (!unexec_copy (sectp->offset, old_file_offset, sectp->size)) diff --git a/pkgs/applications/editors/emacs-24/default.nix b/pkgs/applications/editors/emacs-24/default.nix index 6ecee37d21e..2df240beb94 100644 --- a/pkgs/applications/editors/emacs-24/default.nix +++ b/pkgs/applications/editors/emacs-24/default.nix @@ -18,6 +18,8 @@ stdenv.mkDerivation rec { sha256 = "1385qzs3bsa52s5rcncbrkxlydkw0ajzrvfxgv8rws5fx512kakh"; }; + patches = [ ./darwin-new-sections.patch ]; + buildInputs = [ ncurses gconf libxml2 gnutls alsaLib pkgconfig texinfo ] ++ stdenv.lib.optional stdenv.isLinux dbus diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index c7f4e270076..8bb65fc3b11 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -8397,11 +8397,6 @@ let librsvg = null; alsaLib = null; imagemagick = null; - - # resolve unrecognized section __static_data in __DATA segment - stdenv = if stdenv.isDarwin - then clangStdenv - else stdenv; }; emacs24-nox = lowPrio (appendToName "nox" (emacs24.override {