From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mario Lang Newsgroups: gmane.emacs.devel Subject: RFC: Cross compiling Emacs with qemu-user Date: Tue, 12 Dec 2017 18:32:32 +0100 Message-ID: <87mv2nc0nj.fsf@home.blind.guru> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1513100028 30080 195.159.176.226 (12 Dec 2017 17:33:48 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 12 Dec 2017 17:33:48 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 12 18:33:42 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 1eOoR4-0007YA-8w for ged-emacs-devel@m.gmane.org; Tue, 12 Dec 2017 18:33:42 +0100 Original-Received: from localhost ([::1]:59713 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eOoR9-00087z-Tk for ged-emacs-devel@m.gmane.org; Tue, 12 Dec 2017 12:33:47 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55851) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eOoQ5-00082A-W9 for emacs-devel@gnu.org; Tue, 12 Dec 2017 12:32:43 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eOoQ1-0002im-V7 for emacs-devel@gnu.org; Tue, 12 Dec 2017 12:32:41 -0500 Original-Received: from familiekainz.at ([37.187.20.171]:44380 helo=ns3035380.ip-37-187-20.eu) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eOoQ1-0002g8-L4 for emacs-devel@gnu.org; Tue, 12 Dec 2017 12:32:37 -0500 Original-Received: from fx.tugraz.at (84-115-55-45.cable.dynamic.surfer.at [84.115.55.45]) by ns3035380.ip-37-187-20.eu (Postfix) with ESMTPS id 0A55A3FC6D for ; Tue, 12 Dec 2017 18:32:35 +0100 (CET) Original-Received: from mlang by fx.tugraz.at with local (Exim 4.89) (envelope-from ) id 1eOoPw-0007UB-JX for emacs-devel@gnu.org; Tue, 12 Dec 2017 18:32:32 +0100 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 37.187.20.171 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:220935 Archived-At: Hi. It appears cross compilation of Emacs (tested on ARM) can be done with the help of qemu-user. If you have binfmt support of qemu-user installed properly, you can actually cross-compile Emacs without any modifications at all. However, this usually requires some tinkering with the global state on the build host, which is undesireable. To avoid going through binfmt support, I just whipped up a very crude patch to prefix calling of built binaries. I know this isn't ready for inclusion, however, I'd like to post this here to solicit comments. * In principle, would this be something Emacs would want to support? * What would need to be done to make the patch below acceptable? I needed to replace some of the relative executable paths since qemu-user apparently has a problem with ./foo and ../foo alike paths. I am using this patch in an experimental buildroot package for Emacs. EMACS_CONF_OPTS +=3D --with-emulator=3D"$(QEMU_USER) -L $(TARGET_DIR)" And voila! I get a fully working Emacs for ARM built on x86_64. diff --git a/admin/grammars/Makefile.in b/admin/grammars/Makefile.in index 740168fc73..43fe11eaee 100644 --- a/admin/grammars/Makefile.in +++ b/admin/grammars/Makefile.in @@ -45,7 +45,7 @@ am__v_at_1 =3D unexport EMACSDATA EMACSDOC EMACSPATH =20 EMACS =3D ${top_builddir}/src/emacs -emacs =3D EMACSLOADPATH=3D "${EMACS}" -batch --no-site-file --no-site-lisp +emacs =3D EMACSLOADPATH=3D ${EMACS} -batch --no-site-file --no-site-lisp =20 make_bovine =3D ${emacs} -l semantic/bovine/grammar -f bovine-batch-make-p= arser make_wisent =3D ${emacs} -l semantic/wisent/grammar -f wisent-batch-make-p= arser diff --git a/admin/unidata/Makefile.in b/admin/unidata/Makefile.in index c389cb3f53..66d7587a58 100644 --- a/admin/unidata/Makefile.in +++ b/admin/unidata/Makefile.in @@ -31,7 +31,7 @@ top_builddir =3D =20 EMACS =3D ${top_builddir}/src/emacs unidir =3D ${top_srcdir}/lisp/international -emacs =3D "${EMACS}" -batch --no-site-file --no-site-lisp +emacs =3D ${EMACS} -batch --no-site-file --no-site-lisp =20 lparen =3D ( unifiles =3D $(addprefix ${unidir}/,$(sort $(shell sed -n 's/^[ \t][ \t]*$= {lparen}"\(uni-[^"]*\)"$$/\1/p' ${srcdir}/unidata-gen.el))) diff --git a/configure.ac b/configure.ac index 562b19afe6..df2fc99836 100644 --- a/configure.ac +++ b/configure.ac @@ -298,6 +298,11 @@ AC_DEFUN [string giving default POP mail host])], AC_DEFINE_UNQUOTED(MAILHOST, ["$withval"], [String giving fallback POP= mail host.])) =20 +AC_ARG_WITH([emulator],[AS_HELP_STRING([--with-emulator=3DEMULATOR], + [Emulator to use when executing target binaries])], + EMULATOR=3D"$withval" + AC_SUBST(EMULATOR)) + AC_ARG_WITH([sound],[AS_HELP_STRING([--with-sound=3DVALUE], [compile with sound support (VALUE one of: yes, alsa, oss, bsd-ossaudio,= no; default yes). Only for GNU/Linux, FreeBSD, NetBSD, MinGW, Cygwin.])], diff --git a/leim/Makefile.in b/leim/Makefile.in index f18010af60..af55e3fc4b 100644 --- a/leim/Makefile.in +++ b/leim/Makefile.in @@ -53,7 +53,7 @@ EMACS =3D =20 # How to run Emacs. # Prevent any setting of EMACSLOADPATH in user environment causing problem= s. -RUN_EMACS =3D EMACSLOADPATH=3D '$(EMACS)' -batch --no-site-file --no-site-= lisp +RUN_EMACS =3D EMACSLOADPATH=3D $(EMACS) -batch --no-site-file --no-site-li= sp =20 MKDIR_P =3D @MKDIR_P@ =20 diff --git a/lisp/Makefile.in b/lisp/Makefile.in index de3dc18617..884417d3c1 100644 --- a/lisp/Makefile.in +++ b/lisp/Makefile.in @@ -56,7 +56,7 @@ FIND_DELETE =3D # We never change directory before running Emacs, so a relative file # name is fine, and makes life easier. If we need to change # directory, we can use emacs --chdir. -EMACS =3D ../src/emacs${EXEEXT} +EMACS =3D @EMULATOR@ $(CURDIR)/../src/emacs${EXEEXT} =20 # Command line flags for Emacs. =20 @@ -106,7 +106,7 @@ COMPILE_FIRST =3D =20 # The actual Emacs command run in the targets below. # Prevent any setting of EMACSLOADPATH in user environment causing problem= s. -emacs =3D EMACSLOADPATH=3D '$(EMACS)' $(EMACSOPT) +emacs =3D EMACSLOADPATH=3D $(EMACS) $(EMACSOPT) =20 ## Subdirectories, relative to builddir. SUBDIRS =3D $(sort $(shell find ${srcdir} -type d -print)) diff --git a/src/Makefile.in b/src/Makefile.in index b395627893..d397dc4080 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -54,7 +54,7 @@ lwlibdir =3D # Configuration files for .o files to depend on. config_h =3D config.h $(srcdir)/conf_post.h =20 -bootstrap_exe =3D ../src/bootstrap-emacs$(EXEEXT) +bootstrap_exe =3D $(CURDIR)/bootstrap-emacs$(EXEEXT) =20 ## ns-app if HAVE_NS, else empty. OTHER_FILES =3D @OTHER_FILES@ @@ -320,7 +320,9 @@ INTERVALS_H =3D =20 GETLOADAVG_LIBS =3D @GETLOADAVG_LIBS@ =20 -RUN_TEMACS =3D ./temacs +RUN_TEMACS =3D temacs + +EMULATOR =3D @EMULATOR@ =20 # Whether builds should contain details. '--no-build-details' or empty. BUILD_DETAILS =3D @BUILD_DETAILS@ @@ -506,7 +508,7 @@ LIBES =3D ## in practice this rule was always run anyway. $(srcdir)/macuvs.h $(lispsource)/international/charprop.el: \ bootstrap-emacs$(EXEEXT) FORCE - $(MAKE) -C ../admin/unidata all EMACS=3D"../$(bootstrap_exe)" + $(MAKE) -C ../admin/unidata all EMACS=3D"$(EMULATOR) $(bootstrap_exe)" =20 ## We require charprop.el to exist before ucs-normalize.el is ## byte-compiled, because ucs-normalize.el needs to load 2 uni-*.el files. @@ -539,7 +541,7 @@ emacs$(EXEEXT): ifeq ($(CANNOT_DUMP),yes) ln -f temacs$(EXEEXT) $@ else - LC_ALL=3DC $(RUN_TEMACS) -batch $(BUILD_DETAILS) -l loadup dump + LC_ALL=3DC $(EMULATOR) $(RUN_TEMACS) -batch $(BUILD_DETAILS) -l loadup du= mp ifneq ($(PAXCTL_dumped),) $(PAXCTL_dumped) $@ endif @@ -560,9 +562,9 @@ emacs$(EXEEXT): $(etc)/DOC: lisp.mk $(libsrc)/make-docfile$(EXEEXT) $(obj) $(lisp) $(AM_V_GEN)$(MKDIR_P) $(etc) -$(AM_V_at)rm -f $(etc)/DOC - $(AM_V_at)$(libsrc)/make-docfile -d $(srcdir) \ + $(AM_V_at)$(EMULATOR) $(libsrc)/make-docfile -d $(srcdir) \ $(SOME_MACHINE_OBJECTS) $(obj) > $(etc)/DOC - $(AM_V_at)$(libsrc)/make-docfile -a $(etc)/DOC -d $(lispsource) \ + $(AM_V_at)$(EMULATOR) $(libsrc)/make-docfile -a $(etc)/DOC -d $(lispsourc= e) \ $(shortlisp) =20 $(libsrc)/make-docfile$(EXEEXT): $(lib)/libgnu.a @@ -583,7 +585,7 @@ am__v_GLOBALS_0 =3D am__v_GLOBALS_1 =3D =20 gl-stamp: $(libsrc)/make-docfile$(EXEEXT) $(GLOBAL_SOURCES) - $(AM_V_GLOBALS)$(libsrc)/make-docfile -d $(srcdir) -g $(obj) > globals.tmp + $(AM_V_GLOBALS)$(EMULATOR) $(libsrc)/make-docfile -d $(srcdir) -g $(obj) = > globals.tmp $(AM_V_at)$(top_srcdir)/build-aux/move-if-change globals.tmp globals.h $(AM_V_at)echo timestamp > $@ =20 @@ -726,7 +728,7 @@ .PHONY: ## bootstrap-emacs$(EXEEXT) as an order-only prerequisite. =20 %.elc: %.el | bootstrap-emacs$(EXEEXT) - @$(MAKE) -C ../lisp EMACS=3D"$(bootstrap_exe)" THEFILE=3D$< $