From 57af576dfc553bc777abc13c5677255ddd3f0aed Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Sat, 18 May 2013 16:13:31 +2000 Subject: [PATCH] [PATCH] emacs: Compute build dependencies to fix byte compile issues --- 7d/56df8668a15688a5b4510328040d78151c1134 | 190 ++++++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 7d/56df8668a15688a5b4510328040d78151c1134 diff --git a/7d/56df8668a15688a5b4510328040d78151c1134 b/7d/56df8668a15688a5b4510328040d78151c1134 new file mode 100644 index 000000000..84eec8040 --- /dev/null +++ b/7d/56df8668a15688a5b4510328040d78151c1134 @@ -0,0 +1,190 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 18AD1431FC9 + for ; Fri, 17 May 2013 13:13:50 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id vo4gRRxCiyal for ; + Fri, 17 May 2013 13:13:42 -0700 (PDT) +Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU + [18.9.25.14]) + by olra.theworths.org (Postfix) with ESMTP id DC1BF431FC7 + for ; Fri, 17 May 2013 13:13:41 -0700 (PDT) +X-AuditID: 1209190e-b7f4f6d000005142-85-51968f75759e +Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) + by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP + id 3F.92.20802.57F86915; Fri, 17 May 2013 16:13:41 -0400 (EDT) +Received: from outgoing.mit.edu (OUTGOING-AUTH-1.MIT.EDU [18.9.28.11]) + by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id r4HKDct6013850; + Fri, 17 May 2013 16:13:38 -0400 +Received: from drake.dyndns.org (26-4-182.dynamic.csail.mit.edu [18.26.4.182]) + (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r4HKDaMa004347 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Fri, 17 May 2013 16:13:37 -0400 +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1UdR20-0006Hn-BQ; Fri, 17 May 2013 16:13:36 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH] emacs: Compute build dependencies to fix byte compile issues +Date: Fri, 17 May 2013 16:13:31 -0400 +Message-Id: <1368821611-24110-1-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.7.10.4 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFnrNIsWRmVeSWpSXmKPExsUixCmqrVvaPy3Q4Mw7SYvrN2cyOzB6PFt1 + izmAMYrLJiU1J7MstUjfLoErY8HcdWwFm1QqjjQfYGxgnCfbxcjJISFgIvHp3TdGCFtM4sK9 + 9WwgtpDAPkaJObMtuxi5gOyNjBILTvayQThHmCSaTm5ngaiayyixeFIhiM0moCGxbf9ysEki + AtISO+/OZu1i5OBgFlCT+NOlAhIWFiiUOLf+PDOIzSKgKjF55xWwMbwCDhKNVxezQByhKNH9 + bAIbRFxQ4uTMJywQY9Ql1s8TAgkzC8hLNG+dzTyBUWAWkqpZCFWzkFQtYGRexSibklulm5uY + mVOcmqxbnJyYl5dapGusl5tZopeaUrqJERyOknw7GL8eVDrEKMDBqMTD+8F1WqAQa2JZcWXu + IUZJDiYlUV6HbqAQX1J+SmVGYnFGfFFpTmrxIUYJDmYlEd7nxUA53pTEyqrUonyYlDQHi5I4 + 75WUm/5CAumJJanZqakFqUUwWRkODiUJ3ug+oEbBotT01Iq0zJwShDQTByfIcB6g4aIgNbzF + BYm5xZnpEPlTjLocbV8nv2MUYsnLz0uVEud1BikSACnKKM2DmwNLI68YxYHeEuaNAKniAaYg + uEmvgJYwAS1hvTYVZElJIkJKqoExegbzzKctLEe4vqeKJdx6GVjpFBSW16X0W3T/alWOtDPR + IY+OaSxhXu9xsXSVTJbmrs1/ONMDqw/M1Ntt3nZWredbQINs2RMjTp1Jd73TnZafnSiXHGn+ + Ma3x8z2TV99nqiks/xGzxCDSzvZ7+cag/0IJH2t4+sQOLLia3sEjEf688MTURYxKLMUZiYZa + zEXFiQC79NZG/gIAAA== +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Fri, 17 May 2013 20:13:50 -0000 + +Previously, we simply byte compiled each Elisp source file +independently. This is actually the wrong thing to do and can lead to +issues with macros and performance issues with substitutions because +1) when the byte compiler encounters a (require 'x) form, it will load +x.elc in preference to x.el, even if x.el is newer, and as a result +may load old macro and substitution definitions and 2) if we update a +macro or substitution definition in one file, we currently won't +re-compile other files that depend on the file containing the +definition. + +This patch addresses these problems by computing make dependency rules +from the (require 'x) forms in the Elisp source files, which we inject +into make's dependency database. +--- + emacs/Makefile.local | 12 +++++++++ + emacs/make-deps.el | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 78 insertions(+) + create mode 100644 emacs/make-deps.el + +diff --git a/emacs/Makefile.local b/emacs/Makefile.local +index fb82247..456700a 100644 +--- a/emacs/Makefile.local ++++ b/emacs/Makefile.local +@@ -22,6 +22,18 @@ emacs_images := \ + + emacs_bytecode = $(emacs_sources:.el=.elc) + ++# Because of defmacro's and defsubst's, we have to account for load ++# dependencies between Elisp files when byte compiling. Otherwise, ++# the byte compiler may load an old .elc file when processing a ++# "require" or we may fail to rebuild a .elc that depended on a macro ++# from an updated file. ++$(dir)/.eldeps: $(dir)/Makefile.local $(dir)/make-deps.el $(emacs_sources) ++ $(call quiet,EMACS) --directory emacs -batch -l make-deps.el \ ++ -f batch-make-deps $(emacs_sources) > $@.tmp && \ ++ (cmp -s $@.tmp $@ || mv $@.tmp $@) ++-include $(dir)/.eldeps ++CLEAN+=$(dir)/.eldeps $(dir)/.eldeps.tmp ++ + %.elc: %.el $(global_deps) + $(call quiet,EMACS) --directory emacs -batch -f batch-byte-compile $< + +diff --git a/emacs/make-deps.el b/emacs/make-deps.el +new file mode 100644 +index 0000000..a1cd731 +--- /dev/null ++++ b/emacs/make-deps.el +@@ -0,0 +1,66 @@ ++;; make-deps.el --- compute make dependencies for Elisp sources ++;; ++;; Copyright © Austin Clements ++;; ++;; This file is part of Notmuch. ++;; ++;; Notmuch is free software: you can redistribute it and/or modify it ++;; under the terms of the GNU General Public License as published by ++;; the Free Software Foundation, either version 3 of the License, or ++;; (at your option) any later version. ++;; ++;; Notmuch is distributed in the hope that it will be useful, but ++;; WITHOUT ANY WARRANTY; without even the implied warranty of ++;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++;; General Public License for more details. ++;; ++;; You should have received a copy of the GNU General Public License ++;; along with Notmuch. If not, see . ++;; ++;; Authors: Austin Clements ++ ++(defun batch-make-deps () ++ "Invoke `make-deps' for each file on the command line." ++ ++ (setq debug-on-error t) ++ (dolist (file command-line-args-left) ++ (let ((default-directory command-line-default-directory)) ++ (find-file-literally file)) ++ (make-deps command-line-default-directory)) ++ (kill-emacs)) ++ ++(defun make-deps (&optional dir) ++ "Print make dependencies for the current buffer. ++ ++This prints make dependencies to `standard-output' based on the ++top-level `require' expressions in the current buffer. Paths in ++rules will be given relative to DIR, or `default-directory'." ++ ++ (setq dir (or dir default-directory)) ++ (save-excursion ++ (goto-char (point-min)) ++ (condition-case nil ++ (while t ++ (let ((form (read (current-buffer)))) ++ ;; Is it a (require 'x) form? ++ (when (and (listp form) (= (length form) 2) ++ (eq (car form) 'require) ++ (listp (cadr form)) (= (length (cadr form)) 2) ++ (eq (car (cadr form)) 'quote) ++ (symbolp (cadr (cadr form)))) ++ ;; Find the required library ++ (let* ((name (cadr (cadr form))) ++ (fname (locate-library (symbol-name name)))) ++ ;; Is this file and the library in the same directory? ++ ;; If not, assume it's a system library and don't ++ ;; bother depending on it. ++ (when (and fname ++ (string= (file-name-directory (buffer-file-name)) ++ (file-name-directory fname))) ++ ;; Print the dependency ++ (princ (format "%s.elc: %s.elc\n" ++ (file-name-sans-extension ++ (file-relative-name (buffer-file-name) dir)) ++ (file-name-sans-extension ++ (file-relative-name fname dir))))))))) ++ (end-of-file nil)))) +-- +1.7.10.4 + -- 2.26.2