From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Vibhav Pant 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: Mon, 4 Jul 2022 17:54:58 +0530 Message-ID: References: <1b07c68a-873e-83c8-246d-423bc83a3881@gmail.com> <83y3xg4ldw.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40228"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Tino Calancha , =?UTF-8?Q?Cl=C3=A9ment_Pit=2DClaudel?= , Emacs developers , Eli Zaretskii , Stefan Monnier To: Richard Copley Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Jul 04 14:33:12 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o8LGK-000AMf-LD for ged-emacs-devel@m.gmane-mx.org; Mon, 04 Jul 2022 14:33:12 +0200 Original-Received: from localhost ([::1]:46718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o8LGJ-0007DW-Mu for ged-emacs-devel@m.gmane-mx.org; Mon, 04 Jul 2022 08:33:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51628) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8L8d-00051U-31 for emacs-devel@gnu.org; Mon, 04 Jul 2022 08:25:15 -0400 Original-Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]:45699) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o8L8b-0000uc-HS; Mon, 04 Jul 2022 08:25:14 -0400 Original-Received: by mail-ej1-x633.google.com with SMTP id h23so16399952ejj.12; Mon, 04 Jul 2022 05:25:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1Yz1/FaTlGJaOpCygfqn9uhBAPfPHFVOozdZ133fi1g=; b=LpwQ+pV3Fu4TL7TojO080WrfIhyijmJ/oDiIldFT22Q8Mu9Jiu7zMon2b1W2NqkCN6 CWEvhAydsA/RBoJF+oc3aTL3kmsSpEpPOBIzeGsxWxsUJjJrA4ghyOM9jU4whNRwiS4T pAbiKo50bW8CDMkPNZJ5eyQq15PCntVaoO6B2Er1qugl8SAXRjXLKZw8c9A9pd+E0byt iTXa5UiR7e4m3C4xgFluMHZJVb9u2hx8sp/eAMIS5CkQk6t+AUJgfEZAqtTSYycCYvPv wqh7XgowomvJFjcOCvwoLSCVs8GylTjPPRmQjhKQbk3hqeV4iXzi185OoMoVWEiWQStg BllQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1Yz1/FaTlGJaOpCygfqn9uhBAPfPHFVOozdZ133fi1g=; b=BsaX73Gvks/ceO2n3MbzPOxg5eYOd4FJvK8jJ+XARE9cHzo4unqaVGI5/3is6p9Pfy DavdLmv1O6e1GBGoPZQDYu5RPx+ooU/mfmDux9ocEJNk7CB2Lt+glSYT6gjpNORSQ4cM 4mHEntal5ABc18VN5n8ZvS1E77MPlX3moObDrBWkjIds+ZU6Uuu6+SzMJugjtef6mYEn TTOAWZNu08H6TBVdLC0/+gRkBZhSXaOd+lNdLT+WROgiT46viDnOv9NDs3fyHwFLdJ8j 0pfZM1amfptqMKXpzBvzHai722bS6KEokCDu75iWDCuGBNEi4wWmLS3Hcu4s4Ljt4vZe /APg== X-Gm-Message-State: AJIora8OY4yugot+mr+dxdVVqExz1Msy8oD4FFiE8DVihDBIc6g0Xyyj OFRuXdEWerKvZUuPOju+hXmXEf3CpUSNWNVegpM= X-Google-Smtp-Source: AGRyM1tx3SFXEhzFSG2alGTepM35KRoDkcdwSvGxfxbIp1Fj3e0BEQrt66Et/oIUHZBnORYo/pWaNKP1OrbMEpY8Fns= X-Received: by 2002:a17:906:846b:b0:72a:9097:a511 with SMTP id hx11-20020a170906846b00b0072a9097a511mr16736444ejc.670.1656937509804; Mon, 04 Jul 2022 05:25:09 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=vibhavp@gmail.com; helo=mail-ej1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:291818 Archived-At: On Thu, Feb 23, 2017 at 2:06 PM Richard Copley wrote: > > 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 > Alternatively, in this case, you could compile your code with `byte-compile-cond-use-jump-table' to nil. > 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. -- Vibhav Pant vibhavp@gmail.com GPG: 7ED1 D48C 513C A024 BE3A 785F E3FB 28CB 6AB5 9598