From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Richard Copley Newsgroups: gmane.emacs.devel Subject: Re: Compiled code in Emacs-26 will fail in Emacs-25 if use pcase [was: Add new bytecode op `switch' for implementing branch tables.] Date: Thu, 23 Feb 2017 08:36:14 +0000 Message-ID: References: <1b07c68a-873e-83c8-246d-423bc83a3881@gmail.com> <83y3xg4ldw.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1487839078 12356 195.159.176.226 (23 Feb 2017 08:37:58 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 23 Feb 2017 08:37:58 +0000 (UTC) Cc: cpitclaudel@gmail.com, Stefan Monnier , Eli Zaretskii , Vibhav Pant , Emacs developers To: Tino Calancha Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Feb 23 09:37:54 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cgouP-0002lt-PB for ged-emacs-devel@m.gmane.org; Thu, 23 Feb 2017 09:37:53 +0100 Original-Received: from localhost ([::1]:57251 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgouV-0001Kl-Av for ged-emacs-devel@m.gmane.org; Thu, 23 Feb 2017 03:37:59 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42836) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgotK-00004t-J7 for emacs-devel@gnu.org; Thu, 23 Feb 2017 03:36:47 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgotJ-0001Nc-Lk for emacs-devel@gnu.org; Thu, 23 Feb 2017 03:36:46 -0500 Original-Received: from mail-ua0-x22e.google.com ([2607:f8b0:400c:c08::22e]:36742) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cgotJ-0001NQ-Hx; Thu, 23 Feb 2017 03:36:45 -0500 Original-Received: by mail-ua0-x22e.google.com with SMTP id g30so17550656uac.3; Thu, 23 Feb 2017 00:36:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=5q1guXhle+B2FH4bhoSygL+827cyrPAHC8YcbbBzRPk=; b=iW1DtMRTagdysyuKSN6Nige9d7AxxMB8kGTU6KtyJcHhBoPz56TsKGTmi7zLor8bh4 F29KaEVx0/ekNiLaDZ9w38Dpu5ksur78ABRFUyEVb+gshyed1GjhAkRwwTD4Tf3tO2T8 R3XPzA9y7Spcvf7Henab9B39jIMpkxyTvuKGGPs5Z0IFAQhNb6Q+CWcdcEaif0TLFT1t RwggnQtZTNEintDNnStk5PIgw2KQt8jKlcjc2JCd3xVzCmhzgrqtuQuTZoQ03p9FBWuN oB6oTppg686St+CdOvO1yexLNGXuDv5d2JhFTrgEQJux5akm+zseKEabnK6LrsYiiwKb Ed9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=5q1guXhle+B2FH4bhoSygL+827cyrPAHC8YcbbBzRPk=; b=efoFAlqKYPONrvKQG3qk9/BdbWSdPPp7TB8QZeXvEelICYxPN4EVGzWd6Z7FLh4GVc n+f2GC7sbkFN/ApJ/jvUhpg0WuInkP+2sYu244BBejvlOP8s5JbDQUdINxM+MUF8b7FT N4K8pW0lECgvwGZTZrX28Ci+Ns2/eS15s9si42E/EGJA9uX8YNFKji0GgapC0HgadvEz GmBQh2g8WBKxOuh6o3BrsQk8dhMiP2MLyI8HNbZkTH4J/B/UDRbewcWe9XOBd8fgRX27 wTXooUwxOOg2bu0WMw/9Jq7M99oQTArN2B9rZR5lUUPNWUOItAZjr5/PjFwOFY4ngQ10 rlsg== X-Gm-Message-State: AMke39n0NHNR4VFaCmq1JQI2hb3atwoNpcfVAWu1GTEW5CsYGGvDZ9dnSdlXfHFPkFwm2ixpq2IgQop9b/WZdw== X-Received: by 10.159.48.147 with SMTP id j19mr18958783uab.6.1487839004928; Thu, 23 Feb 2017 00:36:44 -0800 (PST) Original-Received: by 10.159.37.33 with HTTP; Thu, 23 Feb 2017 00:36:14 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400c:c08::22e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:212541 Archived-At: On 23 February 2017 at 04:35, Tino Calancha wrote: > > Sorry if this is obvious, then just ignore. > > I have a custom lib using `pcase' somewhere. That lib is > compatible with Emacs25. > Usually i compile this lib against the master branch. Then, i load > that very same resulting .elc in Emacs-25 and runs same as in Emacs-26. > (Maybe this is just wrong and i must keep separated .elc) > > After the new bytecode those parts of the lib using pcase fail. > For instance, put the following in a file: > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > (defun test-case () > (let ((val "foo")) > (pcase val > ("foo" "foo") > ("bar" "bar") > (_ (error "Neither 'foo' nor 'bar'"))))) > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > I) Compile under master branch. > II) Load the resultant .elc with Emacs-25 > II) M-: (test-case) > ;; Signal error: Invalid byte opcode: op=183, ptr=4 > > So, in conclusion: > From now on, we need to keep two separated .elc in such custom libs, right? Yes, ideally. You need to arrange not to run byte-compiled libs in an earlier version of Emacs than where they were compiled. This isn't a new requirement. There has never been a guarantee that newer versions' bytecode will run on older versions, but in reality incompatible changes don't happen every day so at times you could get away with ignoring the issue. There are various options that avoid the problem. * keep your `load-path' entries version specific * don't byte compile libs that are shared between versions * byte compile them with the earliest Emacs you'll use * don't use different versions of Emacs Eli recommended the first option (the same one you suggested) to me, see #14513. In `emacs -Q' by default all `load-path' entries are in a version-specific subdirectory.