emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Reproducible work with natively compiled Emacs
@ 2024-03-10 11:49 Pedro A. Aranda
  2024-03-11  9:11 ` Pedro Andres Aranda Gutierrez
  0 siblings, 1 reply; 16+ messages in thread
From: Pedro A. Aranda @ 2024-03-10 11:49 UTC (permalink / raw)
  To: Org Mode List

[-- Attachment #1: Type: text/plain, Size: 514 bytes --]

Hi,

I have been experiencing some inconsistencies with org-mode, which I 
have been able to trace own to using native compilation and not knowing 
where the files from main were.

Attached is a patch in four parts to make natively compiled orgmode more 
consistent.

This is a first step and I would like reactions to it, before submitting 
a unified patch.

I hope that splitting it up helps understanding the different parts of 
my "solution". Maybe some parts can be cherry picked better this way...

best /PA

[-- Attachment #2: 0001-Add-native-option-to-make-help.patch --]
[-- Type: text/x-patch, Size: 875 bytes --]

From e47289a60f225a0fa6d05efec9d38119d886f4a3 Mon Sep 17 00:00:00 2001
From: "Pedro A. Aranda" <paaguti@gmail.com>
Date: Sun, 10 Mar 2024 11:23:09 +0100
Subject: [PATCH 1/4] Add 'native' option to 'make help'

---
 Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Makefile b/Makefile
index f476a3ea7..35250eed0 100644
--- a/Makefile
+++ b/Makefile
@@ -27,6 +27,7 @@ help helpall::
 	$(info make all            - ditto)
 	$(info make compile        - build Org ELisp files)
 	$(info make single         - build Org ELisp files, single Emacs per source)
+	$(info make native         - build Org natively compiled ELisp)
 	$(info make autoloads      - create org-loaddefs.el to load Org in-place)
 	$(info make test           - build Org ELisp files and run test suite)
 	$(info make vanilla        - run Emacs with this Org-mode and no personal config)
-- 
2.34.1


[-- Attachment #3: 0002-Store-.eln-files-alongside-the-lisp-files.patch --]
[-- Type: text/x-patch, Size: 646 bytes --]

From 2d3c6b45d435a6356f198c421d71743d9b09efca Mon Sep 17 00:00:00 2001
From: "Pedro A. Aranda" <paaguti@gmail.com>
Date: Sun, 10 Mar 2024 11:26:46 +0100
Subject: [PATCH 2/4] Store .eln files alongside the lisp files

---
 mk/default.mk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mk/default.mk b/mk/default.mk
index b75aac345..312dbc6aa 100644
--- a/mk/default.mk
+++ b/mk/default.mk
@@ -158,6 +158,7 @@ ELC	= $(BATCHL) \
 
 # How to native-compile a single file
 ELN	= $(BATCHL) \
+	  --eval "(startup-redirect-eln-cache \"$(PWD)/lisp\")" \
 	  --eval '(batch-native-compile)'
 
 # How to make a pdf file from a texinfo file
-- 
2.34.1


[-- Attachment #4: 0003-A-short-doc-for-reproducible-native-compilations-whe.patch --]
[-- Type: text/x-patch, Size: 1792 bytes --]

From 34787b58add09decbf31e0e583fd315a207ce88d Mon Sep 17 00:00:00 2001
From: "Pedro A. Aranda" <paaguti@gmail.com>
Date: Sun, 10 Mar 2024 11:44:38 +0100
Subject: [PATCH 3/4] A short doc for reproducible native compilations when
 developing

---
 doc/native-devel.org | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 doc/native-devel.org

diff --git a/doc/native-devel.org b/doc/native-devel.org
new file mode 100644
index 000000000..0cc18a6fe
--- /dev/null
+++ b/doc/native-devel.org
@@ -0,0 +1,33 @@
+#+title: A reproducible natively compiled org-mode
+#+subtitle:  Release {{{version}}}
+#+author:    The Org Mode Developers
+#+language:  en
+
+* Introduction
+
+In order to develop and test ~org-mode~ when your Emacs editor
+supports native compilation, there are two things to take into
+account:
+
+1. you will need to =make native= to generate the =.eln= files. These
+   will be stored under the ~lisp/~ directory of your development
+   ~org-mode~ directory.
+2. Add the following code in your Emacs ~early-init.el~ file:
+
+#+BEGIN_SRC emacs-lisp
+(let ((org-devel-path (expand-file-name "<org-mode development dir>/lisp")))
+  (when (file-directory-p org-devel-path)
+    (when (native-comp-available-p)
+      (let ((first (pop native-comp-eln-load-path)))
+        ;; put in second place
+        (add-to-list 'native-comp-eln-load-path org-devel-path t)
+        (add-to-list 'native-comp-eln-load-path first t)))
+    (add-to-list 'load-path  org-devel-path)))
+#+END_SRC
+
+putting the correct path for your org-mode development directory. In
+my case, it is =~/Devel/org-mode=, so the first =let= looks like this:
+
+#+BEGIN_SRC emacs-lisp
+(let ((org-devel-path (expand-file-name "~/Devel/org-mode/lisp")))
+#+END_SRC
-- 
2.34.1


[-- Attachment #5: 0004-Add-cleaning-native-compilation.patch --]
[-- Type: text/x-patch, Size: 1905 bytes --]

From 0f10451eef8d826ffb31f70f8a6c2db36ebc16a5 Mon Sep 17 00:00:00 2001
From: "Pedro A. Aranda" <paaguti@gmail.com>
Date: Sun, 10 Mar 2024 12:06:28 +0100
Subject: [PATCH 4/4] Add cleaning native compilation

---
 lisp/Makefile | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/lisp/Makefile b/lisp/Makefile
index c570d9cfa..1f03539c2 100644
--- a/lisp/Makefile
+++ b/lisp/Makefile
@@ -10,13 +10,16 @@ LISPB 	:= $(LISPA:%el=%elc) org-install.elc
 LISPF 	:= $(filter-out $(LISPA),$(sort $(wildcard *.el)))
 LISPC 	:= $(filter-out $(LISPB) $(LISPN:%el=%elc),$(LISPF:%el=%elc))
 LISPN 	:= $(filter-out $(LISPB) $(LISPN:%el=%eln),$(LISPF:%el=%eln))
+# Should not be empty if lisp/<version>/org-lint<hash>.eln exists
+# like after a make native
+ELNDIR  := $(shell find . -name org-lint\*.eln -exec dirname {} \;)
 _ORGCM_ := dirall single native source slint1 slint2
 -include local.mk
 
 .PHONY:	all compile compile-dirty \
 	$(_ORGCM_) $(_ORGCM_:%=compile-%) \
 	autoloads \
-	install clean cleanauto cleanall cleanelc clean-install
+	install clean cleanauto cleanall cleanelc cleaneln clean-install
 
 # do not clean here, done in toplevel make
 all compile compile-dirty::	 | autoloads
@@ -41,7 +44,7 @@ single:
 	@$(info ==================== $@ ====================)
 native:
 	@$(info ==================== $@ ====================)
-source: cleanelc
+source: cleanelc cleaneln
 	@$(info ==================== $@ ====================)
 	@$(foreach elc,$(LISPC),$(MAKE) $(elc) && $(RM) $(elc);)
 slint1:
@@ -78,6 +81,14 @@ cleanauto clean cleanall::
 	$(RM) $(LISPA) $(LISPB)
 clean cleanall cleanelc::
 	$(RM) *.elc
+ifeq ($(ELNDIR),)
+cleaneln::
+	@-echo "No previous native compilation "
+else
+clean cleanall cleaneln::
+	@-echo "Removing previous native compilation"
+	@$(RM) -rf $(ELNDIR)
+endif
 
 clean-install:
 	if [ -d $(DESTDIR)$(lispdir) ] ; then \
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2024-03-17 14:27 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-10 11:49 Reproducible work with natively compiled Emacs Pedro A. Aranda
2024-03-11  9:11 ` Pedro Andres Aranda Gutierrez
2024-03-13 12:50   ` Ihor Radchenko
2024-03-13 16:52     ` Pedro Andres Aranda Gutierrez
2024-03-13 17:17       ` Ihor Radchenko
     [not found]         ` <CAO48Bk8v7f3ajv1P3QMvZOuLCBn8f1qp5VQKeUByX0hbKqeEmQ@mail.gmail.com>
2024-03-14  7:50           ` Pedro Andres Aranda Gutierrez
2024-03-15 14:08             ` Ihor Radchenko
2024-03-15 11:17               ` Pedro Andres Aranda Gutierrez
     [not found]                 ` <CAO48Bk9TgysKrAGmhiyR5NZ_4LYj9GMZf-LUo=fjREJYsuXFFg@mail.gmail.com>
2024-03-15 17:08                   ` Ihor Radchenko
2024-03-16  6:16                     ` Pedro Andres Aranda Gutierrez
2024-03-16 10:20                       ` Ihor Radchenko
2024-03-17  6:13                         ` Pedro Andres Aranda Gutierrez
2024-03-17  8:19                           ` Max Nikulin
2024-03-17 10:16                           ` Ihor Radchenko
2024-03-17 10:30                             ` Pedro Andres Aranda Gutierrez
2024-03-17 14:26                               ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).