From 0f476b1de3c3e61467cff9536618d120873c47ab Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Fri, 10 May 2019 16:26:18 +0200 Subject: Move native C code into shared library --- src/Makefile.in | 50 +++++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 21 deletions(-) (limited to 'src/Makefile.in') diff --git a/src/Makefile.in b/src/Makefile.in index ab63b926272..423c5a3f929 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -33,7 +33,7 @@ top_srcdir = @top_srcdir@ abs_top_srcdir=@abs_top_srcdir@ VPATH = $(srcdir) CC = @CC@ -CFLAGS = @CFLAGS@ +CFLAGS = @CFLAGS@ -fPIC CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ EXEEXT = @EXEEXT@ @@ -463,7 +463,7 @@ FIRSTFILE_OBJ=@FIRSTFILE_OBJ@ ALLOBJS = $(FIRSTFILE_OBJ) $(VMLIMIT_OBJ) $(obj) $(otherobj) # Must be first, before dep inclusion! -all: emacs$(EXEEXT) $(pdmp) $(OTHER_FILES) +all: $(pdmp) $(OTHER_FILES) .PHONY: all dmpstruct_headers=$(srcdir)/lisp.h $(srcdir)/buffer.h \ @@ -642,25 +642,33 @@ else MAKE_PDUMPER_FINGERPRINT = endif -## We have to create $(etc) here because init_cmdargs tests its -## existence when setting Vinstallation_directory (FIXME?). -## This goes on to affect various things, and the emacs binary fails -## to start if Vinstallation_directory has the wrong value. -temacs$(EXEEXT): $(LIBXMENU) $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(EMACSRES) \ - $(charsets) $(charscript) $(MAKE_PDUMPER_FINGERPRINT) - $(AM_V_CCLD)$(CC) -o $@.tmp \ - $(ALL_CFLAGS) $(TEMACS_LDFLAGS) $(LDFLAGS) \ - $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(W32_RES_LINK) $(LIBES) -ifeq ($(HAVE_PDUMPER),yes) - $(AM_V_at)$(MAKE_PDUMPER_FINGERPRINT) $@.tmp -endif - $(AM_V_at)mv $@.tmp $@ - $(MKDIR_P) $(etc) -ifeq ($(DUMPING),unexec) - ifneq ($(PAXCTL_notdumped),) - $(PAXCTL_notdumped) $@ - endif -endif +## FIXME: dumper support totally missing here +libemacs.so: $(LIBXMENU) $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(EMACSRES) \ + $(charsets) $(charscript) $(MAKE_PDUMPER_FINGERPRINT) main.o + $(CC) --shared -o $@ $(ALLOBJS) -Wl,-Bstatic $(LIBEGNU_ARCHIVE) -Wl,-Bdynamic $(LIBES) + +temacs$(EXEEXT): libemacs.so main.o + $(CC) -L. main.o -o $@ $(TEMACS_LDFLAGS) $(LDFLAGS) \ + $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(W32_RES_LINK) $(LIBES) -lemacs -Wl,-rpath -Wl,$(shell pwd) + +# ## We have to create $(etc) here because init_cmdargs tests its +# ## existence when setting Vinstallation_directory (FIXME?). +# ## This goes on to affect various things, and the emacs binary fails +# ## to start if Vinstallation_directory has the wrong value. +# temacs$(EXEEXT): $(LIBXMENU) $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(EMACSRES) \ +# $(charsets) $(charscript) $(MAKE_PDUMPER_FINGERPRINT) +# $(AM_V_CCLD)$(CC) -o $@.tmp \ +# $(ALL_CFLAGS) $(TEMACS_LDFLAGS) $(LDFLAGS) \ +# $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(W32_RES_LINK) $(LIBES) +# ifeq ($(HAVE_PDUMPER),yes) +# $(AM_V_at)$(MAKE_PDUMPER_FINGERPRINT) $@.tmp +# endif +# $(AM_V_at)mv $@.tmp $@ +# $(MKDIR_P) $(etc) +# ifeq ($(DUMPING),unexec) +# ifneq ($(PAXCTL_notdumped),) +# $(PAXCTL_notdumped) $@ +# endif ## The following oldxmenu-related rules are only (possibly) used if ## HAVE_X11 && !USE_GTK, but there is no harm in always defining them. -- cgit v1.2.3 From ea622e321d500715238214db9d8b994cffe8568e Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Sat, 11 May 2019 14:56:56 +0200 Subject: Add nativecomp option to configure --- configure.ac | 13 +++++++++++++ src/Makefile.in | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src/Makefile.in') diff --git a/configure.ac b/configure.ac index 24d21c7afd9..d059b7d6724 100644 --- a/configure.ac +++ b/configure.ac @@ -463,6 +463,7 @@ OPTION_DEFAULT_ON([gnutls],[don't use -lgnutls for SSL/TLS support]) OPTION_DEFAULT_ON([zlib],[don't compile with zlib decompression support]) OPTION_DEFAULT_ON([modules],[compile with dynamic modules support]) OPTION_DEFAULT_ON([threads],[don't compile with elisp threading support]) +OPTION_DEFAULT_ON([nativecomp],[don't compile with emacs lisp native compiler support]) AC_ARG_WITH([file-notification],[AS_HELP_STRING([--with-file-notification=LIB], [use a file notification library (LIB one of: yes, inotify, kqueue, gfile, w32, no)])], @@ -3670,6 +3671,17 @@ if test "${HAVE_ZLIB}" = "yes"; then fi AC_SUBST(LIBZ) +HAVE_LIBGCCJIT=no +LIBGCCJIT_LIB= +if test "${with_nativecomp}" != "no"; then + AC_CHECK_LIB(gccjit, gcc_jit_context_acquire, HAVE_LIBGCCJIT=yes, , -lgccjit) + if test "${HAVE_LIBGCCJIT}" = "yes"; then + LIBGCCJIT_LIB=-lgccjit + AC_DEFINE([HAVE_LIBGCCJIT], 1, [Define to 1 if you have the libgccjit library (-lgccjit).]) + fi +fi +AC_SUBST([LIBGCCJIT_LIB]) + ### Dynamic modules support LIBMODULES= HAVE_MODULES=no @@ -5714,6 +5726,7 @@ AS_ECHO([" Does Emacs use -lXaw3d? ${HAVE_XAW3D Does Emacs support the portable dumper? ${with_pdumper} Does Emacs support legacy unexec dumping? ${with_unexec} Which dumping strategy does Emacs use? ${with_dumping} + Does Emacs have native lisp compiler? ${with_nativecomp} "]) if test -n "${EMACSDATA}"; then diff --git a/src/Makefile.in b/src/Makefile.in index 423c5a3f929..4a66016e976 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -326,6 +326,8 @@ GETLOADAVG_LIBS = @GETLOADAVG_LIBS@ GMP_LIB = @GMP_LIB@ GMP_OBJ = @GMP_OBJ@ +LIBGCCJIT = @LIBGCCJIT_LIB@ + RUN_TEMACS = ./temacs # Whether builds should contain details. '--no-build-details' or empty. @@ -531,7 +533,7 @@ LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \ $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(HARFBUZZ_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ $(LIBGNUTLS_LIBS) $(LIB_PTHREAD) $(GETADDRINFO_A_LIBS) $(LCMS2_LIBS) \ $(NOTIFY_LIBS) $(LIB_MATH) $(LIBZ) $(LIBMODULES) $(LIBSYSTEMD_LIBS) \ - $(JSON_LIBS) $(GMP_LIB) + $(JSON_LIBS) $(GMP_LIB) $(LIBGCCJIT) ## FORCE it so that admin/unidata can decide whether this file is ## up-to-date. Although since charprop depends on bootstrap-emacs, -- cgit v1.2.3 From 01442a9ac9c6e6a652b628cf18b90a7e30bff845 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Sat, 11 May 2019 21:12:21 +0200 Subject: Add native compiler comp.c --- src/Makefile.in | 2 +- src/comp.c | 1032 ++++++++++++++++++++++++++++++++++++++++++++++++ src/emacs.c | 15 + src/lisp.h | 6 + src/lread.c | 11 +- test/src/comp-tests.el | 86 ++++ 6 files changed, 1147 insertions(+), 5 deletions(-) create mode 100644 src/comp.c create mode 100644 test/src/comp-tests.el (limited to 'src/Makefile.in') diff --git a/src/Makefile.in b/src/Makefile.in index 4a66016e976..8e3712709e5 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -416,7 +416,7 @@ base_obj = dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \ cmds.o casetab.o casefiddle.o indent.o search.o regex-emacs.o undo.o \ alloc.o pdumper.o data.o doc.o editfns.o callint.o \ eval.o floatfns.o fns.o font.o print.o lread.o $(MODULES_OBJ) \ - syntax.o $(UNEXEC_OBJ) bytecode.o \ + syntax.o $(UNEXEC_OBJ) bytecode.o comp.o \ process.o gnutls.o callproc.o \ region-cache.o sound.o timefns.o atimer.o \ doprnt.o intervals.o textprop.o composite.o xml.o lcms.o $(NOTIFY_OBJ) \ diff --git a/src/comp.c b/src/comp.c new file mode 100644 index 00000000000..9713a6fd459 --- /dev/null +++ b/src/comp.c @@ -0,0 +1,1032 @@ +/* Compile byte code produced by bytecomp.el into native code. + Copyright (C) 2019 Free Software Foundation, Inc. + +This file is part of GNU Emacs. + +GNU Emacs 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. + +GNU Emacs 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 GNU Emacs. If not, see . */ + +#include + +#ifdef HAVE_LIBGCCJIT + +#include +#include +#include + +#include "lisp.h" +#include "buffer.h" +#include "bytecode.h" +#include "atimer.h" + +#define MAX_FUN_NAME 256 + +#define DISASS_FILE_NAME "emacs-asm.s" + +#define CHECK_STACK \ + eassert (stack >= stack_base && stack < stack_over) + +#define PUSH(obj) \ + do { \ + CHECK_STACK; \ + *stack = obj; \ + stack++; \ + } while (0) + +#define POP1 \ + do { \ + stack--; \ + CHECK_STACK; \ + args[0] = *stack; \ + } while (0) + +#define POP2 \ + do { \ + stack--; \ + CHECK_STACK; \ + args[1] = *stack; \ + stack--; \ + args[0] = *stack; \ + } while (0) + +#define POP3 \ + do { \ + stack--; \ + CHECK_STACK; \ + args[2] = *stack; \ + stack--; \ + args[1] = *stack; \ + stack--; \ + args[0] = *stack; \ + } while (0) + +/* Fetch the next byte from the bytecode stream. */ + +#define FETCH (bytestr_data[pc++]) + +/* Fetch two bytes from the bytecode stream and make a 16-bit number + out of them. */ + +#define FETCH2 (op = FETCH, op + (FETCH << 8)) + +/* The compiler context */ + +typedef struct { + gcc_jit_context *ctxt; + gcc_jit_type *lisp_obj; + gcc_jit_type *int_type; + gcc_jit_function *func; /* Current function being compiled */ + gcc_jit_block *block; /* Current basic block */ + Lisp_Object func_hash; /* f_name -> gcc_func */ +} comp_t; + +static comp_t comp; + +/* The result of one function compilation. */ + +typedef struct { + gcc_jit_result *gcc_res; + short min_args, max_args; +} comp_f_res_t; + +static gcc_jit_function *jit_func_declare (const char *f_name, unsigned nargs, + gcc_jit_rvalue **args, + enum gcc_jit_function_kind kind, + bool reusable); + +void emacs_native_compile (const char *lisp_f_name, const char *c_f_name, + Lisp_Object func, bool dump_asm); + +static gcc_jit_function * +jit_func_declare (const char *f_name, unsigned nargs, gcc_jit_rvalue **args, + enum gcc_jit_function_kind kind, + bool reusable) +{ + gcc_jit_param *param[4]; + gcc_jit_type *type[4]; + + /* If args are passed types are extracted from that otherwise assume params */ + /* are all lisp objs. */ + if (args) + for (int i = 0; i < nargs; i++) + type[i] = gcc_jit_rvalue_get_type (args[i]); + else + for (int i = 0; i < nargs; i++) + type[i] = comp.lisp_obj; + + switch (nargs) { + case 4: + param[3] = gcc_jit_context_new_param(comp.ctxt, + NULL, + type[3], + "c"); + /* Fall through */ + FALLTHROUGH; + case 3: + param[2] = gcc_jit_context_new_param(comp.ctxt, + NULL, + type[2], + "c"); + /* Fall through */ + FALLTHROUGH; + case 2: + param[1] = gcc_jit_context_new_param(comp.ctxt, + NULL, + type[1], + "b"); + /* Fall through */ + FALLTHROUGH; + case 1: + param[0] = gcc_jit_context_new_param(comp.ctxt, + NULL, + type[0], + "a"); + /* Fall through */ + FALLTHROUGH; + case 0: + break; + default: + /* Argnum not supported */ + eassert (0); + } + + gcc_jit_function *func = + gcc_jit_context_new_function(comp.ctxt, NULL, + kind, + comp.lisp_obj, + f_name, + nargs, + param, + 0); + + if (reusable) + { + Lisp_Object value; + Lisp_Object key = make_string (f_name, strlen (f_name)); + value = make_pointer_integer (XPL (func)); + + EMACS_UINT hash = 0; + struct Lisp_Hash_Table *ht = XHASH_TABLE (comp.func_hash); + ptrdiff_t i = hash_lookup (ht, key, &hash); + /* Don't want to declare the same function two times */ + eassert (i == -1); + hash_put (ht, key, value, hash); + } + + return func; +} + +static gcc_jit_lvalue * +jit_emit_call (const char *f_name, unsigned nargs, gcc_jit_rvalue **args) +{ + Lisp_Object key = make_string (f_name, strlen (f_name)); + EMACS_UINT hash = 0; + struct Lisp_Hash_Table *ht = XHASH_TABLE (comp.func_hash); + ptrdiff_t i = hash_lookup (ht, key, &hash); + + if (i == -1) + { + jit_func_declare(f_name, nargs, args, GCC_JIT_FUNCTION_IMPORTED, + true); + i = hash_lookup (ht, key, &hash); + eassert (i != -1); + } + + Lisp_Object value = HASH_VALUE (ht, hash_lookup (ht, key, &hash)); + gcc_jit_function *func = (gcc_jit_function *) XFIXNUMPTR (value); + + gcc_jit_lvalue *res = gcc_jit_function_new_local(comp.func, + NULL, + comp.lisp_obj, + "res"); + gcc_jit_block_add_assignment(comp.block, NULL, + res, + gcc_jit_context_new_call(comp.ctxt, + NULL, + func, + nargs, + args)); + return res; +} + +static comp_f_res_t +compile_f (const char *f_name, ptrdiff_t bytestr_length, + unsigned char *bytestr_data, + EMACS_INT stack_depth, Lisp_Object *vectorp, + ptrdiff_t vector_size, Lisp_Object args_template) +{ + gcc_jit_lvalue *res; + comp_f_res_t comp_res = { NULL, 0, 0 }; + ptrdiff_t pc = 0; + gcc_jit_rvalue *args[4]; + unsigned op; + + /* This is the stack we use to flat the bytecode written for push and pop + Emacs VM.*/ + gcc_jit_rvalue **stack_base, **stack, **stack_over; + stack_base = stack = + (gcc_jit_rvalue **) xmalloc (stack_depth * sizeof (gcc_jit_rvalue *)); + stack_over = stack_base + stack_depth; + + if (FIXNUMP (args_template)) + { + ptrdiff_t at = XFIXNUM (args_template); + bool rest = (at & 128) != 0; + int mandatory = at & 127; + ptrdiff_t nonrest = at >> 8; + + comp_res.min_args = mandatory; + + eassert (!rest); + + if (!rest && nonrest < SUBR_MAX_ARGS) + comp_res.max_args = nonrest; + } + else if (CONSP (args_template)) + /* FIXME */ + comp_res.min_args = comp_res.max_args = XFIXNUM (Flength (args_template)); + + else + eassert (SYMBOLP (args_template) && args_template == Qnil); + + + /* Current function being compiled. Return a lips obj. */ + comp.func = jit_func_declare (f_name, comp_res.max_args, NULL, + GCC_JIT_FUNCTION_EXPORTED, false); + + for (ptrdiff_t i = 0; i < comp_res.max_args; ++i) + PUSH (gcc_jit_param_as_rvalue (gcc_jit_function_get_param (comp.func, i))); + + comp.block = gcc_jit_function_new_block(comp.func, "foo_blk"); + + while (pc < bytestr_length) + { + op = FETCH; + printf ("pc %td\t%ud\n", pc, op); + switch (op) + { + case Bstack_ref1: + case Bstack_ref2: + case Bstack_ref3: + case Bstack_ref4: + case Bstack_ref5: + { + PUSH (stack_base[(stack - stack_base) - (op - Bstack_ref) - 1]); + break; + } + case Bstack_ref6: + { + PUSH (stack_base[(stack - stack_base) - FETCH - 1]); + break; + } + case Bstack_ref7: + { + PUSH (stack_base[(stack - stack_base) - FETCH2 - 1]); + break; + } + + case Bvarref7: + op = FETCH2; + goto varref; + + case Bvarref: + case Bvarref1: + case Bvarref2: + case Bvarref3: + case Bvarref4: + case Bvarref5: + op -= Bvarref; + goto varref; + + case Bvarref6: + op = FETCH; + varref: + { + args[0] = gcc_jit_context_new_rvalue_from_ptr(comp.ctxt, + comp.lisp_obj, + vectorp[op]); + res = jit_emit_call ("Fsymbol_value", 1, args); + PUSH (gcc_jit_lvalue_as_rvalue (res)); + break; + } + + case Bvarset: + case Bvarset1: + case Bvarset2: + case Bvarset3: + case Bvarset4: + case Bvarset5: + op -= Bvarset; + goto varset; + + case Bvarset7: + op = FETCH2; + goto varset; + + case Bvarset6: + op = FETCH; + varset: + { + POP1; + args[1] = args[0]; + args[0] = gcc_jit_context_new_rvalue_from_ptr(comp.ctxt, + comp.lisp_obj, + vectorp[op]); + args[2] = gcc_jit_context_new_rvalue_from_ptr(comp.ctxt, + comp.lisp_obj, + Qnil); + args[3] = gcc_jit_context_new_rvalue_from_int (comp.ctxt, + comp.int_type, + SET_INTERNAL_SET); + res = jit_emit_call ("set_internal", 4, args); + PUSH (gcc_jit_lvalue_as_rvalue (res)); + } + break; + + case Bvarbind: + printf("Bvarbind\n"); + break; + case Bvarbind1: + printf("Bvarbind1\n"); + break; + case Bvarbind2: + printf("Bvarbind2\n"); + break; + case Bvarbind3: + printf("Bvarbind3\n"); + break; + case Bvarbind4: + printf("Bvarbind4\n"); + break; + case Bvarbind5: + printf("Bvarbind5\n"); + break; + case Bvarbind6: + printf("Bvarbind6\n"); + break; + case Bvarbind7: + printf("Bvarbind7\n"); + break; + case Bcall: + printf("Bcall\n"); + break; + case Bcall1: + printf("Bcall1\n"); + break; + case Bcall2: + printf("Bcall2\n"); + break; + case Bcall3: + printf("Bcall3\n"); + break; + case Bcall4: + printf("Bcall4\n"); + break; + case Bcall5: + printf("Bcall5\n"); + break; + case Bcall6: + printf("Bcall6\n"); + break; + case Bcall7: + printf("Bcall7\n"); + break; + case Bunbind: + printf("Bunbind\n"); + break; + case Bunbind1: + printf("Bunbind1\n"); + break; + case Bunbind2: + printf("Bunbind2\n"); + break; + case Bunbind3: + printf("Bunbind3\n"); + break; + case Bunbind4: + printf("Bunbind4\n"); + break; + case Bunbind5: + printf("Bunbind5\n"); + break; + case Bunbind6: + printf("Bunbind6\n"); + break; + case Bunbind7: + printf("Bunbind7\n"); + break; + case Bpophandler: + printf("Bpophandler\n"); + break; + case Bpushconditioncase: + printf("Bpushconditioncase\n"); + break; + case Bpushcatch: + printf("Bpushcatch\n"); + break; + case Bnth: + printf("Bnth\n"); + break; + case Bsymbolp: + printf("Bsymbolp\n"); + break; + case Bconsp: + printf("Bconsp\n"); + break; + case Bstringp: + printf("Bstringp\n"); + break; + case Blistp: + printf("Blistp\n"); + break; + case Beq: + POP2; + res = jit_emit_call ("Feq", 2, args); + PUSH (gcc_jit_lvalue_as_rvalue (res)); + break; + case Bmemq: + POP1; + res = jit_emit_call ("Fmemq", 1, args); + PUSH (gcc_jit_lvalue_as_rvalue (res)); + break; + break; + case Bnot: + printf("Bnot\n"); + break; + case Bcar: + POP1; + res = jit_emit_call ("Fcar", 1, args); + PUSH (gcc_jit_lvalue_as_rvalue (res)); + break; + case Bcdr: + POP1; + res = jit_emit_call ("Fcdr", 1, args); + PUSH (gcc_jit_lvalue_as_rvalue (res)); + break; + case Bcons: + POP2; + res = jit_emit_call ("Fcons", 2, args); + PUSH (gcc_jit_lvalue_as_rvalue (res)); + break; + + case BlistN: + op = FETCH; + goto make_list; + + case Blist1: + case Blist2: + case Blist3: + case Blist4: + op = op - Blist1; + make_list: + { + POP1; + args[1] = gcc_jit_context_new_rvalue_from_ptr(comp.ctxt, + comp.lisp_obj, + Qnil); + res = jit_emit_call ("Fcons", 2, args); + PUSH (gcc_jit_lvalue_as_rvalue (res)); + for (int i = 0; i < op; ++i) + { + POP2; + res = jit_emit_call ("Fcons", 2, args); + PUSH (gcc_jit_lvalue_as_rvalue (res)); + } + break; + } + + case Blength: + printf("Blength\n"); + break; + case Baref: + printf("Baref\n"); + break; + case Baset: + printf("Baset\n"); + break; + case Bsymbol_value: + printf("Bsymbol_value\n"); + break; + case Bsymbol_function: + printf("Bsymbol_function\n"); + break; + case Bset: + printf("Bset\n"); + break; + case Bfset: + printf("Bfset\n"); + break; + case Bget: + printf("Bget\n"); + break; + case Bsubstring: + printf("Bsubstring\n"); + break; + case Bconcat2: + printf("Bconcat2\n"); + break; + case Bconcat3: + printf("Bconcat3\n"); + break; + case Bconcat4: + printf("Bconcat4\n"); + break; + case Bsub1: + printf("Bsub1\n"); + break; + case Badd1: + printf("Badd1\n"); + break; + case Beqlsign: + printf("Beqlsign\n"); + break; + case Bgtr: + printf("Bgtr\n"); + break; + case Blss: + printf("Blss\n"); + break; + case Bleq: + printf("Bleq\n"); + break; + case Bgeq: + printf("Bgeq\n"); + break; + case Bdiff: + printf("Bdiff\n"); + break; + case Bnegate: + printf("Bnegate\n"); + break; + case Bplus: + printf("Bplus\n"); + break; + case Bmax: + printf("Bmax\n"); + break; + case Bmin: + printf("Bmin\n"); + break; + case Bmult: + printf("Bmult\n"); + break; + case Bpoint: + printf("Bpoint\n"); + break; + case Bsave_current_buffer: + printf("Bsave_current_buffer\n"); + break; + case Bgoto_char: + printf("Bgoto_char\n"); + break; + case Binsert: + printf("Binsert\n"); + break; + case Bpoint_max: + printf("Bpoint_max\n"); + break; + case Bpoint_min: + printf("Bpoint_min\n"); + break; + case Bchar_after: + printf("Bchar_after\n"); + break; + case Bfollowing_char: + printf("Bfollowing_char\n"); + break; + case Bpreceding_char: + printf("Bpreceding_char\n"); + break; + case Bcurrent_column: + printf("Bcurrent_column\n"); + break; + case Bindent_to: + printf("Bindent_to\n"); + break; + case Beolp: + printf("Beolp\n"); + break; + case Beobp: + printf("Beobp\n"); + break; + case Bbolp: + printf("Bbolp\n"); + break; + case Bbobp: + printf("Bbobp\n"); + break; + case Bcurrent_buffer: + printf("Bcurrent_buffer\n"); + break; + case Bset_buffer: + printf("Bset_buffer\n"); + break; + case Bsave_current_buffer_1: + printf("Bsave_current_buffer_1\n"); + break; + case Binteractive_p: + printf("Binteractive_p\n"); + break; + case Bforward_char: + printf("Bforward_char\n"); + break; + case Bforward_word: + printf("Bforward_word\n"); + break; + case Bskip_chars_forward: + printf("Bskip_chars_forward\n"); + break; + case Bskip_chars_backward: + printf("Bskip_chars_backward\n"); + break; + case Bforward_line: + printf("Bforward_line\n"); + break; + case Bchar_syntax: + printf("Bchar_syntax\n"); + break; + case Bbuffer_substring: + printf("Bbuffer_substring\n"); + break; + case Bdelete_region: + printf("Bdelete_region\n"); + break; + case Bnarrow_to_region: + printf("Bnarrow_to_region\n"); + break; + case Bwiden: + printf("Bwiden\n"); + break; + case Bend_of_line: + printf("Bend_of_line\n"); + break; + case Bconstant2: + printf("Bconstant2\n"); + goto do_constant; + break; + case Bgoto: + printf("Bgoto\n"); + break; + case Bgotoifnil: + printf("Bgotoifnil\n"); + break; + case Bgotoifnonnil: + printf("Bgotoifnonnil\n"); + break; + case Bgotoifnilelsepop: + printf("Bgotoifnilelsepop\n"); + break; + case Bgotoifnonnilelsepop: + printf("Bgotoifnonnilelsepop\n"); + break; + case Breturn: + printf("Breturn\n"); + break; + case Bdiscard: + printf("Bdiscard\n"); + break; + case Bdup: + printf("Bdup\n"); + break; + case Bsave_excursion: + printf("Bsave_excursion\n"); + break; + case Bsave_window_excursion: + printf("Bsave_window_excursion\n"); + break; + case Bsave_restriction: + printf("Bsave_restriction\n"); + break; + case Bcatch: + printf("Bcatch\n"); + break; + case Bunwind_protect: + printf("Bunwind_protect\n"); + break; + case Bcondition_case: + printf("Bcondition_case\n"); + break; + case Btemp_output_buffer_setup: + printf("Btemp_output_buffer_setup\n"); + break; + case Btemp_output_buffer_show: + printf("Btemp_output_buffer_show\n"); + break; + case Bunbind_all: + printf("Bunbind_all\n"); + break; + case Bset_marker: + printf("Bset_marker\n"); + break; + case Bmatch_beginning: + printf("Bmatch_beginning\n"); + break; + case Bmatch_end: + printf("Bmatch_end\n"); + break; + case Bupcase: + printf("Bupcase\n"); + break; + case Bdowncase: + printf("Bdowncase\n"); + break; + case Bstringeqlsign: + printf("Bstringeqlsign\n"); + break; + case Bstringlss: + printf("Bstringlss\n"); + break; + case Bequal: + printf("Bequal\n"); + break; + case Bnthcdr: + printf("Bnthcdr\n"); + break; + case Belt: + printf("Belt\n"); + break; + case Bmember: + printf("Bmember\n"); + break; + case Bassq: + printf("Bassq\n"); + break; + case Bnreverse: + printf("Bnreverse\n"); + break; + case Bsetcar: + printf("Bsetcar\n"); + break; + case Bsetcdr: + printf("Bsetcdr\n"); + break; + case Bcar_safe: + printf("Bcar_safe\n"); + break; + case Bcdr_safe: + printf("Bcdr_safe\n"); + break; + case Bnconc: + printf("Bnconc\n"); + break; + case Bquo: + printf("Bquo\n"); + break; + case Brem: + printf("Brem\n"); + break; + case Bnumberp: + printf("Bnumberp\n"); + break; + case Bintegerp: + printf("Bintegerp\n"); + break; + case BRgoto: + printf("BRgoto\n"); + break; + case BRgotoifnil: + printf("BRgotoifnil\n"); + break; + case BRgotoifnonnil: + printf("BRgotoifnonnil\n"); + break; + case BRgotoifnilelsepop: + printf("BRgotoifnilelsepop\n"); + break; + case BRgotoifnonnilelsepop: + printf("BRgotoifnonnilelsepop\n"); + break; + case BconcatN: + printf("BconcatN\n"); + break; + case BinsertN: + printf("BinsertN\n"); + break; + case Bstack_set: + printf("Bstack_set\n"); + break; + case Bstack_set2: + printf("Bstack_set2\n"); + break; + case BdiscardN: + printf("BdiscardN\n"); + break; + case Bswitch: + printf("Bswitch\n"); + /* The cases of Bswitch that we handle (which in theory is + all of them) are done in Bconstant, below. This is done + due to a design issue with Bswitch -- it should have + taken a constant pool index inline, but instead looks for + a constant on the stack. */ + goto fail; + break; + default: + case Bconstant: + printf("Bconstant "); + { + if (op < Bconstant || op > Bconstant + vector_size) + goto fail; + + op -= Bconstant; + do_constant: + + /* See the Bswitch case for commentary. */ + if (pc >= bytestr_length || bytestr_data[pc] != Bswitch) + { + gcc_jit_rvalue *c = + gcc_jit_context_new_rvalue_from_ptr(comp.ctxt, + comp.lisp_obj, + vectorp[op]); + PUSH (c); + Fprint(vectorp[op], Qnil); + break; + } + + /* We're compiling Bswitch instead. */ + ++pc; + break; + } + } + } + + stack--; + gcc_jit_block_end_with_return(comp.block, + NULL, + *stack); + comp_res.gcc_res = gcc_jit_context_compile(comp.ctxt); + + goto exit; + + fail: + error ("Something went wrong"); + + exit: + xfree (stack_base); + return comp_res; +} + +void +emacs_native_compile (const char *lisp_f_name, const char *c_f_name, + Lisp_Object func, bool dump_asm) +{ + Lisp_Object bytestr = AREF (func, COMPILED_BYTECODE); + CHECK_STRING (bytestr); + + if (STRING_MULTIBYTE (bytestr)) + /* BYTESTR must have been produced by Emacs 20.2 or the earlier + because they produced a raw 8-bit string for byte-code and now + such a byte-code string is loaded as multibyte while raw 8-bit + characters converted to multibyte form. Thus, now we must + convert them back to the originally intended unibyte form. */ + bytestr = Fstring_as_unibyte (bytestr); + + ptrdiff_t bytestr_length = SBYTES (bytestr); + + Lisp_Object vector = AREF (func, COMPILED_CONSTANTS); + CHECK_VECTOR (vector); + Lisp_Object *vectorp = XVECTOR (vector)->contents; + + Lisp_Object maxdepth = AREF (func, COMPILED_STACK_DEPTH); + CHECK_FIXNAT (maxdepth); + + /* Gcc doesn't like being interrupted. */ + sigset_t oldset; + block_atimers (&oldset); + + comp_f_res_t comp_res = compile_f (c_f_name, bytestr_length, SDATA (bytestr), + XFIXNAT (maxdepth) + 1, + vectorp, ASIZE (vector), + AREF (func, COMPILED_ARGLIST)); + + union Aligned_Lisp_Subr *x = xmalloc (sizeof (union Aligned_Lisp_Subr)); + + x->s.header.size = PVEC_SUBR << PSEUDOVECTOR_AREA_BITS; + x->s.function.a0 = gcc_jit_result_get_code(comp_res.gcc_res, c_f_name); + x->s.min_args = comp_res.min_args; + x->s.max_args = comp_res.max_args; + x->s.symbol_name = lisp_f_name; + defsubr(x); + + if (dump_asm) + { + gcc_jit_context_compile_to_file(comp.ctxt, + GCC_JIT_OUTPUT_KIND_ASSEMBLER, + DISASS_FILE_NAME); + } + unblock_atimers (&oldset); +} + +DEFUN ("native-compile", Fnative_compile, Snative_compile, + 1, 2, 0, + doc: /* Compile as native code function FUNC and load it. */) /* FIXME doc */ + (Lisp_Object func, Lisp_Object disassemble) +{ + static char c_f_name[MAX_FUN_NAME]; + char *lisp_f_name; + + if (!SYMBOLP (func)) + error ("Not a symbol."); + + lisp_f_name = (char *) SDATA (SYMBOL_NAME (func)); + + int res = snprintf (c_f_name, MAX_FUN_NAME, "Fnative_comp_%s", lisp_f_name); + + if (res >= MAX_FUN_NAME) + error ("Function name too long"); + + /* FIXME how many other characters are not allowed in C? + This will introduce name clashs too. */ + for (int i; i < strlen(c_f_name); i++) + if (c_f_name[i] == '-') + c_f_name[i] = '_'; + + func = indirect_function (func); + if (!COMPILEDP (func)) + error ("Not a byte-compiled function"); + + emacs_native_compile (lisp_f_name, c_f_name, func, disassemble != Qnil); + + if (disassemble) + { + FILE *fd; + Lisp_Object str; + + if ((fd = fopen (DISASS_FILE_NAME, "r"))) + { + fseek (fd , 0L, SEEK_END); + long int size = ftell (fd); + fseek (fd , 0L, SEEK_SET); + char *buffer = xmalloc (size + 1); + ptrdiff_t nread = fread (buffer, 1, size, fd); + if (nread > 0) + { + size = nread; + buffer[size] = '\0'; + str = make_string (buffer, size); + fclose (fd); + } + else + str = empty_unibyte_string; + xfree (buffer); + return str; + } + else + { + error ("disassemble file could not be found"); + } + } + + return Qnil; +} + +void +init_comp (void) +{ + comp.ctxt = gcc_jit_context_acquire(); + +#if EMACS_INT_MAX <= LONG_MAX + /* 32-bit builds without wide ints, 64-bit builds on Posix hosts. */ + comp.lisp_obj = gcc_jit_context_get_type(comp.ctxt, GCC_JIT_TYPE_VOID_PTR); +#else + /* 64-bit builds on MS-Windows, 32-bit builds with wide ints. */ + comp.lisp_obj = gcc_jit_context_get_type(comp.ctxt, GCC_JIT_TYPE_LONG_LONG); +#endif + + comp.int_type = gcc_jit_context_get_type(comp.ctxt, GCC_JIT_TYPE_INT); + comp.func_hash = CALLN (Fmake_hash_table, QCtest, Qequal, QCweakness, Qt); + + /* gcc_jit_context_set_bool_option(comp.ctxt, */ + /* GCC_JIT_BOOL_OPTION_DUMP_EVERYTHING, */ + /* 1); */ + + gcc_jit_context_set_bool_option(comp.ctxt, + GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES, + 1); +} + +void +release_comp (void) +{ + if (comp.ctxt) + gcc_jit_context_release(comp.ctxt); +} + +void +syms_of_comp (void) +{ + defsubr (&Snative_compile); + comp.func_hash = Qnil; + staticpro (&comp.func_hash); +} + +#endif /* HAVE_LIBJIT */ diff --git a/src/emacs.c b/src/emacs.c index 81703b4660a..db6d54dff43 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1598,6 +1598,11 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem init_json (); #endif +#ifdef HAVE_LIBGCCJIT + if (!initialized) + syms_of_comp (); +#endif + no_loadup = argmatch (argv, argc, "-nl", "--no-loadup", 6, NULL, &skip_args); @@ -1773,6 +1778,12 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem xputenv ("LANG=C"); #endif + /* This is here because init_buffer can already call Lisp. */ +#ifdef HAVE_LIBGCCJIT + if (initialized) + init_comp(); +#endif + /* Init buffer storage and default directory of main buffer. */ init_buffer (); @@ -2389,6 +2400,10 @@ all of which are called before Emacs is actually killed. */ unlink (SSDATA (listfile)); } +#ifdef HAVE_LIBGCCJIT + release_comp(); +#endif + if (FIXNUMP (arg)) exit_code = (XFIXNUM (arg) < 0 ? XFIXNUM (arg) | INT_MIN diff --git a/src/lisp.h b/src/lisp.h index 04e70f592fe..5a563069df5 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4743,6 +4743,12 @@ extern bool profiler_memory_running; extern void malloc_probe (size_t); extern void syms_of_profiler (void); +/* Defined in comp.c. */ +#ifdef HAVE_LIBGCCJIT +extern void init_comp (void); +extern void release_comp (void); +extern void syms_of_comp (void); +#endif /* HAVE_LIBGCCJIT */ #ifdef DOS_NT /* Defined in msdos.c, w32.c. */ diff --git a/src/lread.c b/src/lread.c index 290b3d3d64e..bedb3d57cb5 100644 --- a/src/lread.c +++ b/src/lread.c @@ -4174,13 +4174,16 @@ intern_c_string_1 (const char *str, ptrdiff_t len) { Lisp_Object obarray = check_obarray (Vobarray); Lisp_Object tem = oblookup (obarray, str, len, len); + Lisp_Object string; if (!SYMBOLP (tem)) { - /* Creating a non-pure string from a string literal not implemented yet. - We could just use make_string here and live with the extra copy. */ - eassert (!NILP (Vpurify_flag)); - tem = intern_driver (make_pure_c_string (str, len), obarray, tem); + if NILP (Vpurify_flag) + string = make_string (str, len); + else + string = make_pure_c_string (str, len); + + tem = intern_driver (string, obarray, tem); } return tem; } diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el new file mode 100644 index 00000000000..5847d5cf85c --- /dev/null +++ b/test/src/comp-tests.el @@ -0,0 +1,86 @@ +;;; comp-tests.el --- unit tests for src/comp.c -*- lexical-binding: t; -*- + +;; Copyright (C) 2019 Free Software Foundation, Inc. + +;; Author: Andrea Corallo + +;; This file is part of GNU Emacs. + +;; GNU Emacs 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. + +;; GNU Emacs 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 GNU Emacs. If not, see . + +;;; Commentary: + +;; Unit tests for src/comp.c. + +;;; Code: + +(require 'ert) + +(setq garbage-collection-messages t) + +(defvar comp-tests-var1 3) + +(ert-deftest comp-tests-varref () + "Testing cons car cdr." + (defun comp-tests-varref-f () + comp-tests-var1) + + (byte-compile #'comp-tests-varref-f) + (native-compile #'comp-tests-varref-f) + + (should (= (comp-tests-varref-f) 3))) + +(ert-deftest comp-tests-list () + "Testing cons car cdr." + (defun comp-tests-list-f () + (list 1 2 3)) + + (byte-compile #'comp-tests-list-f) + (native-compile #'comp-tests-list-f) + + (should (equal (comp-tests-list-f) '(1 2 3)))) + +(ert-deftest comp-tests-cons-car-cdr () + "Testing cons car cdr." + (defun comp-tests-cons-car-f () + (car (cons 1 2))) + (byte-compile #'comp-tests-cons-car-f) + (native-compile #'comp-tests-cons-car-f) + + (defun comp-tests-cons-cdr-f (x) + (cdr (cons 'foo x))) + (byte-compile #'comp-tests-cons-cdr-f) + (native-compile #'comp-tests-cons-cdr-f) + + (should (= (comp-tests-cons-car-f) 1)) + (should (= (comp-tests-cons-cdr-f 3) 3))) + +(ert-deftest comp-tests-varset () + "Testing varset." + (defun comp-tests-varset-f () + (setq comp-tests-var1 55)) + (byte-compile #'comp-tests-varset-f) + (native-compile #'comp-tests-varset-f) + (comp-tests-varset-f) + + (should (= comp-tests-var1 55))) + +(ert-deftest comp-tests-gc () + "Try to do some longer computation to let the gc kick in." + (dotimes (_ 100000) + (comp-tests-cons-cdr-f 3)) + + (should (= (comp-tests-cons-cdr-f 3) 3))) + +;;; comp-tests.el ends here -- cgit v1.2.3 From 4c03c46946d95a7e9079a087b5e0e835f5a5beac Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Sun, 1 Sep 2019 11:06:27 +0200 Subject: Revert "Move native C code into shared library" This reverts commit 613f4156880bc6c3d56ebe0297e59f805d2a69ab. --- lib/Makefile.in | 4 +--- src/Makefile.in | 50 +++++++++++++++++++++----------------------------- src/emacs.c | 2 +- src/main.c | 26 -------------------------- 4 files changed, 23 insertions(+), 59 deletions(-) delete mode 100644 src/main.c (limited to 'src/Makefile.in') diff --git a/lib/Makefile.in b/lib/Makefile.in index ed3123885d2..06d8e56421b 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -26,8 +26,6 @@ abs_top_srcdir = @abs_top_srcdir@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -CFLAGS = -fPIC @CFLAGS@ - all: .PHONY: all @@ -52,7 +50,7 @@ am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = -ALL_CFLAGS= -fPIC \ +ALL_CFLAGS= \ $(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) $(DEPFLAGS) \ $(GNULIB_WARN_CFLAGS) $(WERROR_CFLAGS) $(PROFILING_CFLAGS) $(CFLAGS) \ -I. -I../src -I$(srcdir) -I$(srcdir)/../src \ diff --git a/src/Makefile.in b/src/Makefile.in index 8e3712709e5..5e0e36d8b4d 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -33,7 +33,7 @@ top_srcdir = @top_srcdir@ abs_top_srcdir=@abs_top_srcdir@ VPATH = $(srcdir) CC = @CC@ -CFLAGS = @CFLAGS@ -fPIC +CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ EXEEXT = @EXEEXT@ @@ -465,7 +465,7 @@ FIRSTFILE_OBJ=@FIRSTFILE_OBJ@ ALLOBJS = $(FIRSTFILE_OBJ) $(VMLIMIT_OBJ) $(obj) $(otherobj) # Must be first, before dep inclusion! -all: $(pdmp) $(OTHER_FILES) +all: emacs$(EXEEXT) $(pdmp) $(OTHER_FILES) .PHONY: all dmpstruct_headers=$(srcdir)/lisp.h $(srcdir)/buffer.h \ @@ -644,33 +644,25 @@ else MAKE_PDUMPER_FINGERPRINT = endif -## FIXME: dumper support totally missing here -libemacs.so: $(LIBXMENU) $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(EMACSRES) \ - $(charsets) $(charscript) $(MAKE_PDUMPER_FINGERPRINT) main.o - $(CC) --shared -o $@ $(ALLOBJS) -Wl,-Bstatic $(LIBEGNU_ARCHIVE) -Wl,-Bdynamic $(LIBES) - -temacs$(EXEEXT): libemacs.so main.o - $(CC) -L. main.o -o $@ $(TEMACS_LDFLAGS) $(LDFLAGS) \ - $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(W32_RES_LINK) $(LIBES) -lemacs -Wl,-rpath -Wl,$(shell pwd) - -# ## We have to create $(etc) here because init_cmdargs tests its -# ## existence when setting Vinstallation_directory (FIXME?). -# ## This goes on to affect various things, and the emacs binary fails -# ## to start if Vinstallation_directory has the wrong value. -# temacs$(EXEEXT): $(LIBXMENU) $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(EMACSRES) \ -# $(charsets) $(charscript) $(MAKE_PDUMPER_FINGERPRINT) -# $(AM_V_CCLD)$(CC) -o $@.tmp \ -# $(ALL_CFLAGS) $(TEMACS_LDFLAGS) $(LDFLAGS) \ -# $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(W32_RES_LINK) $(LIBES) -# ifeq ($(HAVE_PDUMPER),yes) -# $(AM_V_at)$(MAKE_PDUMPER_FINGERPRINT) $@.tmp -# endif -# $(AM_V_at)mv $@.tmp $@ -# $(MKDIR_P) $(etc) -# ifeq ($(DUMPING),unexec) -# ifneq ($(PAXCTL_notdumped),) -# $(PAXCTL_notdumped) $@ -# endif +## We have to create $(etc) here because init_cmdargs tests its +## existence when setting Vinstallation_directory (FIXME?). +## This goes on to affect various things, and the emacs binary fails +## to start if Vinstallation_directory has the wrong value. +temacs$(EXEEXT): $(LIBXMENU) $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(EMACSRES) \ + $(charsets) $(charscript) $(MAKE_PDUMPER_FINGERPRINT) + $(AM_V_CCLD)$(CC) -o $@.tmp \ + $(ALL_CFLAGS) $(TEMACS_LDFLAGS) $(LDFLAGS) \ + $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(W32_RES_LINK) $(LIBES) +ifeq ($(HAVE_PDUMPER),yes) + $(AM_V_at)$(MAKE_PDUMPER_FINGERPRINT) $@.tmp +endif + $(AM_V_at)mv $@.tmp $@ + $(MKDIR_P) $(etc) +ifeq ($(DUMPING),unexec) + ifneq ($(PAXCTL_notdumped),) + $(PAXCTL_notdumped) $@ + endif +endif ## The following oldxmenu-related rules are only (possibly) used if ## HAVE_X11 && !USE_GTK, but there is no harm in always defining them. diff --git a/src/emacs.c b/src/emacs.c index 1491ba5a479..c59a70988b7 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -924,7 +924,7 @@ load_pdump (int argc, char **argv) #endif /* HAVE_PDUMPER */ int -main1 (int argc, char **argv) +main (int argc, char **argv) { /* Variable near the bottom of the stack, and aligned appropriately for pointers. */ diff --git a/src/main.c b/src/main.c deleted file mode 100644 index 41e35534280..00000000000 --- a/src/main.c +++ /dev/null @@ -1,26 +0,0 @@ -/* Trampoline for GNU Emacs. - Copyright (C) 2019 Free Software - Foundation, Inc. - -This file is part of GNU Emacs. - -GNU Emacs 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. - -GNU Emacs 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 GNU Emacs. If not, see . */ - -extern int main1 (int argc, char **argv); - -int -main (int argc, char **argv) -{ - return main1(argc, argv); -} -- cgit v1.2.3 From 17259826f263f87d45eb98c8effe0ba7ee774f5d Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Sun, 8 Sep 2019 09:40:42 +0200 Subject: fix build system for native compiler option --- configure.ac | 10 +++++++--- src/Makefile.in | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src/Makefile.in') diff --git a/configure.ac b/configure.ac index 6213051a602..a36a2f32428 100644 --- a/configure.ac +++ b/configure.ac @@ -3671,18 +3671,22 @@ if test "${HAVE_ZLIB}" = "yes"; then fi AC_SUBST(LIBZ) +### Emacs Lisp native compiler support HAVE_LIBGCCJIT=no LIBGCCJIT_LIB= +COMP_OBJ= if test "${with_nativecomp}" != "no"; then AC_CHECK_LIB(gccjit, gcc_jit_context_acquire, HAVE_LIBGCCJIT=yes, , -lgccjit) if test "${HAVE_LIBGCCJIT}" = "yes"; then - LIBGCCJIT_LIB=-lgccjit - AC_DEFINE([HAVE_LIBGCCJIT], 1, [Define to 1 if you have the libgccjit library (-lgccjit).]) + LIBGCCJIT_LIB="-lgccjit -ldl" + COMP_OBJ="dynlib.o comp.o" + AC_DEFINE(HAVE_LIBGCCJIT, 1, [Define to 1 if you have the libgccjit library (-lgccjit).]) AC_DEFINE_UNQUOTED(NATIVE_ELISP_SUFFIX, ".eln", [System extension for native compiled elisp]) fi fi -AC_SUBST([LIBGCCJIT_LIB]) +AC_SUBST(LIBGCCJIT_LIB) +AC_SUBST(COMP_OBJ) ### Dynamic modules support LIBMODULES= diff --git a/src/Makefile.in b/src/Makefile.in index 5e0e36d8b4d..6c65275d6da 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -327,6 +327,8 @@ GMP_LIB = @GMP_LIB@ GMP_OBJ = @GMP_OBJ@ LIBGCCJIT = @LIBGCCJIT_LIB@ +## dynlib.o comp.o if native compiler is enabled, else empty +COMP_OBJ = @COMP_OBJ@ RUN_TEMACS = ./temacs @@ -416,7 +418,7 @@ base_obj = dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \ cmds.o casetab.o casefiddle.o indent.o search.o regex-emacs.o undo.o \ alloc.o pdumper.o data.o doc.o editfns.o callint.o \ eval.o floatfns.o fns.o font.o print.o lread.o $(MODULES_OBJ) \ - syntax.o $(UNEXEC_OBJ) bytecode.o comp.o \ + syntax.o $(UNEXEC_OBJ) bytecode.o $(COMP_OBJ) \ process.o gnutls.o callproc.o \ region-cache.o sound.o timefns.o atimer.o \ doprnt.o intervals.o textprop.o composite.o xml.o lcms.o $(NOTIFY_OBJ) \ -- cgit v1.2.3 From 4beb850efb99b881fb8b648ad7bb43c6539a2431 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Tue, 24 Dec 2019 20:48:49 +0100 Subject: add native support to the build system --- lisp/Makefile.in | 41 ++++++++++++++++++++++++++++++++++++++--- lisp/emacs-lisp/autoload.el | 2 +- src/Makefile.in | 20 ++++++++++++++++++-- 3 files changed, 57 insertions(+), 6 deletions(-) (limited to 'src/Makefile.in') diff --git a/lisp/Makefile.in b/lisp/Makefile.in index 57527bb5afc..91b44de46aa 100644 --- a/lisp/Makefile.in +++ b/lisp/Makefile.in @@ -32,6 +32,11 @@ XARGS_LIMIT = @XARGS_LIMIT@ # 'make' verbosity. AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AM_V_ELN = $(am__v_ELN_@AM_V@) +am__v_ELN_ = $(am__v_ELN_@AM_DEFAULT_V@) +am__v_ELN_0 = @echo " ELN " $@; +am__v_ELN_1 = + AM_V_ELC = $(am__v_ELC_@AM_V@) am__v_ELC_ = $(am__v_ELC_@AM_DEFAULT_V@) am__v_ELC_0 = @echo " ELC " $@; @@ -99,7 +104,8 @@ COMPILE_FIRST = \ $(lisp)/emacs-lisp/cconv.elc \ $(lisp)/emacs-lisp/byte-opt.elc \ $(lisp)/emacs-lisp/bytecomp.elc \ - $(lisp)/emacs-lisp/autoload.elc + $(lisp)/emacs-lisp/autoload.elc \ + $(lisp)/emacs-lisp/comp.elc # Files to compile early in compile-main. Works around bug#25556. MAIN_FIRST = ./emacs-lisp/eieio.el ./emacs-lisp/eieio-base.el \ @@ -127,7 +133,7 @@ SUBDIRS_SUBDIRS = $(filter-out ${srcdir}/cedet% ${srcdir}/leim%,${SUBDIRS}) # cus-load and finder-inf are not explicitly requested by anything, so # we add them here to make sure they get built. -all: compile-main $(lisp)/cus-load.el $(lisp)/finder-inf.el +all: compile-main compile-native-main $(lisp)/cus-load.el $(lisp)/finder-inf.el PHONY_EXTRAS = .PHONY: all custom-deps finder-data autoloads update-subdirs $(PHONY_EXTRAS) @@ -281,6 +287,13 @@ $(THEFILE)c: -l bytecomp -f byte-compile-refresh-preloaded \ -f batch-byte-compile $(THEFILE) +THEFILE = no-such-file +.PHONY: $(THEFILE)n +$(THEFILE)n: + $(AM_V_ELN)$(emacs) $(BYTE_COMPILE_FLAGS) \ + -l comp -f byte-compile-refresh-preloaded \ + -f batch-native-compile $(THEFILE) + # Files MUST be compiled one by one. If we compile several files in a # row (i.e., in the same instance of Emacs) we can't make sure that # the compilation environment is clean. We also set the load-path of @@ -288,13 +301,16 @@ $(THEFILE)c: # subdirectories, to make sure require's and load's in the files being # compiled find the right files. -.SUFFIXES: .elc .el +.SUFFIXES: .eln .elc .el # An old-fashioned suffix rule, which, according to the GNU Make manual, # cannot have prerequisites. .el.elc: $(AM_V_ELC)$(emacs) $(BYTE_COMPILE_FLAGS) -f batch-byte-compile $< +.el.eln: + $(AM_V_ELN)$(emacs) $(BYTE_COMPILE_FLAGS) -f batch-native-compile $< + .PHONY: compile-first compile-main compile compile-always compile-first: $(COMPILE_FIRST) @@ -329,6 +345,21 @@ compile-main: gen-lisp compile-clean $(MAKE) compile-targets TARGETS="$$chunk"; \ done +# Obsiusly copy pasted from above. Just do it on elns + ignoring errors... +compile-native-main: gen-lisp compile-clean + @(cd $(lisp) && \ + els=`echo "${SUBDIRS_REL} " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.el |g'`; \ + for el in ${MAIN_FIRST} $$els; do \ + test -f $$el || continue; \ + test ! -f $${el}c && \ + GREP_OPTIONS= grep '^;.*[^a-zA-Z]no-byte-compile: *t' $$el > /dev/null && \ + continue; \ + echo "$${el}n"; \ + done | xargs $(XARGS_LIMIT) echo) | \ + while read chunk; do \ + $(MAKE) -i compile-targets TARGETS="$$chunk"; \ + done + .PHONY: compile-clean # Erase left-over .elc files that do not have a corresponding .el file. compile-clean: @@ -338,6 +369,8 @@ compile-clean: if test -f "$$el" || test ! -f "$${el}c"; then :; else \ echo rm "$${el}c"; \ rm "$${el}c"; \ + echo rm "$${el}n"; \ + rm "$${el}n"; \ fi; \ done @@ -361,6 +394,8 @@ semantic: # Calling make recursively because suffix rule cannot have prerequisites. compile: $(LOADDEFS) autoloads compile-first $(MAKE) compile-main +# Ignore error for now cause we can't compile dynamic code + $(MAKE) -i compile-native-main # Compile all Lisp files. This is like 'compile' but compiles files # unconditionally. Some files don't actually get compiled because they diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 785e350e0e5..53d353858b3 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -1045,7 +1045,7 @@ write its autoloads into the specified file instead." ;; we don't want to depend on whether Emacs was ;; built with or without modules support, nor ;; what is the suffix for the underlying OS. - (unless (string-match "\\.\\(elc\\|so\\|dll\\)" suf) + (unless (string-match "\\.\\(elc\\|eln\\|so\\|dll\\)" suf) (push suf tmp))) (concat "^[^=.].*" (regexp-opt tmp t) "\\'"))) (files (apply #'nconc diff --git a/src/Makefile.in b/src/Makefile.in index 6c65275d6da..faf24802791 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -513,14 +513,26 @@ lisp.mk: $(lispsource)/loadup.el sed -e 's/$$/.elc \\/' -e 's/\.el\.elc/.el/'; \ echo "" ) > $@ +shortnativelisp = +native_lisp.mk: $(lispsource)/loadup.el + @rm -f $@ + ${AM_V_GEN}( printf 'shortnativelisp = \\\n'; \ + sed -n 's/^[ \t]*(load "\([^"]*\)".*/\1/p' $< | \ + sed -e 's/$$/.eln \\/' -e 's/\.el\.eln/.el/'; \ + echo "" ) > $@ + -include lisp.mk +-include native_lisp.mk shortlisp_filter = leim/leim-list.el site-load.elc site-init.elc shortlisp := $(filter-out ${shortlisp_filter},${shortlisp}) +shortnativelisp_filter = leim/leim-list.el site-load.eln site-init.eln +shortnativelisp := $(filter-out ${shortnativelisp_filter},${shortnativelisp}) ## Place loaddefs.el first, so it gets generated first, since it is on ## the critical path (relevant in parallel compilations). ## We don't really need to sort, but may as well use it to remove duplicates. shortlisp := loaddefs.el loadup.el $(sort ${shortlisp}) lisp = $(addprefix ${lispsource}/,${shortlisp}) +nativelisp = $(addprefix ${lispsource}/,${shortnativelisp}) ## Construct full set of libraries to be linked. LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \ @@ -571,7 +583,7 @@ ${lispintdir}/characters.elc: ${charscript:.el=.elc} ## since not all pieces are used on all platforms. But DOC depends ## on all of $lisp, and emacs depends on DOC, so it is ok to use $lisp here. emacs$(EXEEXT): temacs$(EXEEXT) \ - lisp.mk $(etc)/DOC $(lisp) \ + lisp.mk native_lisp.mk $(etc)/DOC $(lisp) $(nativelisp) \ $(lispsource)/international/charprop.el ${charsets} ifeq ($(DUMPING),unexec) LC_ALL=C $(RUN_TEMACS) -batch $(BUILD_DETAILS) -l loadup --temacs=dump @@ -721,7 +733,7 @@ bootstrap-clean: clean fi distclean: bootstrap-clean - rm -f Makefile lisp.mk + rm -f Makefile lisp.mk native_lisp.mk rm -fr $(DEPDIR) maintainer-clean: distclean @@ -788,6 +800,10 @@ tags: TAGS ../lisp/TAGS $(lwlibdir)/TAGS @$(MAKE) $(AM_V_NO_PD) -C ../lisp EMACS="$(bootstrap_exe)"\ THEFILE=$< $ Date: Sun, 29 Dec 2019 16:06:07 +0100 Subject: rework build system for one pass --- lisp/Makefile.in | 42 +++++++++++++----------------------------- src/Makefile.in | 17 +++-------------- 2 files changed, 16 insertions(+), 43 deletions(-) (limited to 'src/Makefile.in') diff --git a/lisp/Makefile.in b/lisp/Makefile.in index 91b44de46aa..5bcb85ff141 100644 --- a/lisp/Makefile.in +++ b/lisp/Makefile.in @@ -34,12 +34,12 @@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_V_ELN = $(am__v_ELN_@AM_V@) am__v_ELN_ = $(am__v_ELN_@AM_DEFAULT_V@) -am__v_ELN_0 = @echo " ELN " $@; +am__v_ELN_0 = @echo " ELC+ELN " $@; am__v_ELN_1 = AM_V_ELC = $(am__v_ELC_@AM_V@) am__v_ELC_ = $(am__v_ELC_@AM_DEFAULT_V@) -am__v_ELC_0 = @echo " ELC " $@; +am__v_ELC_0 = @echo " ELC+ELN " $@; am__v_ELC_1 = AM_V_GEN = $(am__v_GEN_@AM_V@) @@ -133,7 +133,7 @@ SUBDIRS_SUBDIRS = $(filter-out ${srcdir}/cedet% ${srcdir}/leim%,${SUBDIRS}) # cus-load and finder-inf are not explicitly requested by anything, so # we add them here to make sure they get built. -all: compile-main compile-native-main $(lisp)/cus-load.el $(lisp)/finder-inf.el +all: compile-main $(lisp)/cus-load.el $(lisp)/finder-inf.el PHONY_EXTRAS = .PHONY: all custom-deps finder-data autoloads update-subdirs $(PHONY_EXTRAS) @@ -280,19 +280,19 @@ TAGS: ${ETAGS} ${tagsfiles} # src/Makefile.in to rebuild a particular Lisp file, no questions asked. # Use byte-compile-refresh-preloaded to try and work around some of # the most common problems of not bootstrapping from a clean state. +# THEFILE = no-such-file +# .PHONY: $(THEFILE)c +# $(THEFILE)c: +# $(AM_V_ELC)$(emacs) $(BYTE_COMPILE_FLAGS) \ +# -l bytecomp -f byte-compile-refresh-preloaded \ +# -f batch-byte-compile $(THEFILE) + THEFILE = no-such-file .PHONY: $(THEFILE)c $(THEFILE)c: - $(AM_V_ELC)$(emacs) $(BYTE_COMPILE_FLAGS) \ - -l bytecomp -f byte-compile-refresh-preloaded \ - -f batch-byte-compile $(THEFILE) - -THEFILE = no-such-file -.PHONY: $(THEFILE)n -$(THEFILE)n: $(AM_V_ELN)$(emacs) $(BYTE_COMPILE_FLAGS) \ -l comp -f byte-compile-refresh-preloaded \ - -f batch-native-compile $(THEFILE) + -f batch-byte-native-compile-for-bootstrap $(THEFILE) # Files MUST be compiled one by one. If we compile several files in a # row (i.e., in the same instance of Emacs) we can't make sure that @@ -306,7 +306,8 @@ $(THEFILE)n: # An old-fashioned suffix rule, which, according to the GNU Make manual, # cannot have prerequisites. .el.elc: - $(AM_V_ELC)$(emacs) $(BYTE_COMPILE_FLAGS) -f batch-byte-compile $< + $(AM_V_ELC)$(emacs) $(BYTE_COMPILE_FLAGS) \ + -l comp -f batch-byte-native-compile-for-bootstrap $< .el.eln: $(AM_V_ELN)$(emacs) $(BYTE_COMPILE_FLAGS) -f batch-native-compile $< @@ -345,21 +346,6 @@ compile-main: gen-lisp compile-clean $(MAKE) compile-targets TARGETS="$$chunk"; \ done -# Obsiusly copy pasted from above. Just do it on elns + ignoring errors... -compile-native-main: gen-lisp compile-clean - @(cd $(lisp) && \ - els=`echo "${SUBDIRS_REL} " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.el |g'`; \ - for el in ${MAIN_FIRST} $$els; do \ - test -f $$el || continue; \ - test ! -f $${el}c && \ - GREP_OPTIONS= grep '^;.*[^a-zA-Z]no-byte-compile: *t' $$el > /dev/null && \ - continue; \ - echo "$${el}n"; \ - done | xargs $(XARGS_LIMIT) echo) | \ - while read chunk; do \ - $(MAKE) -i compile-targets TARGETS="$$chunk"; \ - done - .PHONY: compile-clean # Erase left-over .elc files that do not have a corresponding .el file. compile-clean: @@ -394,8 +380,6 @@ semantic: # Calling make recursively because suffix rule cannot have prerequisites. compile: $(LOADDEFS) autoloads compile-first $(MAKE) compile-main -# Ignore error for now cause we can't compile dynamic code - $(MAKE) -i compile-native-main # Compile all Lisp files. This is like 'compile' but compiles files # unconditionally. Some files don't actually get compiled because they diff --git a/src/Makefile.in b/src/Makefile.in index faf24802791..cc43cd9f319 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -513,26 +513,15 @@ lisp.mk: $(lispsource)/loadup.el sed -e 's/$$/.elc \\/' -e 's/\.el\.elc/.el/'; \ echo "" ) > $@ -shortnativelisp = -native_lisp.mk: $(lispsource)/loadup.el - @rm -f $@ - ${AM_V_GEN}( printf 'shortnativelisp = \\\n'; \ - sed -n 's/^[ \t]*(load "\([^"]*\)".*/\1/p' $< | \ - sed -e 's/$$/.eln \\/' -e 's/\.el\.eln/.el/'; \ - echo "" ) > $@ -include lisp.mk --include native_lisp.mk shortlisp_filter = leim/leim-list.el site-load.elc site-init.elc shortlisp := $(filter-out ${shortlisp_filter},${shortlisp}) -shortnativelisp_filter = leim/leim-list.el site-load.eln site-init.eln -shortnativelisp := $(filter-out ${shortnativelisp_filter},${shortnativelisp}) ## Place loaddefs.el first, so it gets generated first, since it is on ## the critical path (relevant in parallel compilations). ## We don't really need to sort, but may as well use it to remove duplicates. shortlisp := loaddefs.el loadup.el $(sort ${shortlisp}) lisp = $(addprefix ${lispsource}/,${shortlisp}) -nativelisp = $(addprefix ${lispsource}/,${shortnativelisp}) ## Construct full set of libraries to be linked. LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \ @@ -583,7 +572,7 @@ ${lispintdir}/characters.elc: ${charscript:.el=.elc} ## since not all pieces are used on all platforms. But DOC depends ## on all of $lisp, and emacs depends on DOC, so it is ok to use $lisp here. emacs$(EXEEXT): temacs$(EXEEXT) \ - lisp.mk native_lisp.mk $(etc)/DOC $(lisp) $(nativelisp) \ + lisp.mk $(etc)/DOC $(lisp) \ $(lispsource)/international/charprop.el ${charsets} ifeq ($(DUMPING),unexec) LC_ALL=C $(RUN_TEMACS) -batch $(BUILD_DETAILS) -l loadup --temacs=dump @@ -733,7 +722,7 @@ bootstrap-clean: clean fi distclean: bootstrap-clean - rm -f Makefile lisp.mk native_lisp.mk + rm -f Makefile lisp.mk rm -fr $(DEPDIR) maintainer-clean: distclean @@ -801,7 +790,7 @@ tags: TAGS ../lisp/TAGS $(lwlibdir)/TAGS THEFILE=$< $ Date: Tue, 31 Dec 2019 00:37:47 +0100 Subject: make build system configurable again --- configure.ac | 2 +- lisp/Makefile.in | 40 ++++++++++++++++++++++------------------ src/Makefile.in | 1 - 3 files changed, 23 insertions(+), 20 deletions(-) (limited to 'src/Makefile.in') diff --git a/configure.ac b/configure.ac index 03570bd6c90..2afa9572544 100644 --- a/configure.ac +++ b/configure.ac @@ -3760,10 +3760,10 @@ If you are sure you want Emacs compiled without elisp native compiler, pass to configure.]) fi fi +AC_SUBST(HAVE_NATIVE_COMP) AC_SUBST(LIBGCCJIT_LIB) AC_SUBST(COMP_OBJ) - ### Use -lpng if available, unless '--with-png=no'. HAVE_PNG=no LIBPNG= diff --git a/lisp/Makefile.in b/lisp/Makefile.in index 5bcb85ff141..cfc6f494991 100644 --- a/lisp/Makefile.in +++ b/lisp/Makefile.in @@ -32,14 +32,15 @@ XARGS_LIMIT = @XARGS_LIMIT@ # 'make' verbosity. AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_V_ELN = $(am__v_ELN_@AM_V@) -am__v_ELN_ = $(am__v_ELN_@AM_DEFAULT_V@) -am__v_ELN_0 = @echo " ELC+ELN " $@; -am__v_ELN_1 = +HAVE_NATIVE_COMP = @HAVE_NATIVE_COMP@ AM_V_ELC = $(am__v_ELC_@AM_V@) am__v_ELC_ = $(am__v_ELC_@AM_DEFAULT_V@) +ifeq ($(HAVE_NATIVE_COMP),yes) am__v_ELC_0 = @echo " ELC+ELN " $@; +else +am__v_ELC_0 = @echo " ELC " $@; +endif am__v_ELC_1 = AM_V_GEN = $(am__v_GEN_@AM_V@) @@ -103,9 +104,11 @@ COMPILE_FIRST = \ $(lisp)/emacs-lisp/macroexp.elc \ $(lisp)/emacs-lisp/cconv.elc \ $(lisp)/emacs-lisp/byte-opt.elc \ - $(lisp)/emacs-lisp/bytecomp.elc \ - $(lisp)/emacs-lisp/autoload.elc \ - $(lisp)/emacs-lisp/comp.elc + $(lisp)/emacs-lisp/bytecomp.elc +ifeq ($(HAVE_NATIVE_COMP),yes) +COMPILE_FIRST += $(lisp)/emacs-lisp/comp.elc +endif +COMPILE_FIRST += $(lisp)/emacs-lisp/autoload.elc # Files to compile early in compile-main. Works around bug#25556. MAIN_FIRST = ./emacs-lisp/eieio.el ./emacs-lisp/eieio-base.el \ @@ -280,19 +283,18 @@ TAGS: ${ETAGS} ${tagsfiles} # src/Makefile.in to rebuild a particular Lisp file, no questions asked. # Use byte-compile-refresh-preloaded to try and work around some of # the most common problems of not bootstrapping from a clean state. -# THEFILE = no-such-file -# .PHONY: $(THEFILE)c -# $(THEFILE)c: -# $(AM_V_ELC)$(emacs) $(BYTE_COMPILE_FLAGS) \ -# -l bytecomp -f byte-compile-refresh-preloaded \ -# -f batch-byte-compile $(THEFILE) - THEFILE = no-such-file .PHONY: $(THEFILE)c $(THEFILE)c: - $(AM_V_ELN)$(emacs) $(BYTE_COMPILE_FLAGS) \ +ifeq ($(HAVE_NATIVE_COMP),yes) + $(AM_V_ELC)$(emacs) $(BYTE_COMPILE_FLAGS) \ -l comp -f byte-compile-refresh-preloaded \ -f batch-byte-native-compile-for-bootstrap $(THEFILE) +else + $(AM_V_ELC)$(emacs) $(BYTE_COMPILE_FLAGS) \ + -l bytecomp -f byte-compile-refresh-preloaded \ + -f batch-byte-compile $(THEFILE) +endif # Files MUST be compiled one by one. If we compile several files in a # row (i.e., in the same instance of Emacs) we can't make sure that @@ -305,12 +307,14 @@ $(THEFILE)c: # An old-fashioned suffix rule, which, according to the GNU Make manual, # cannot have prerequisites. +ifeq ($(HAVE_NATIVE_COMP),yes) .el.elc: $(AM_V_ELC)$(emacs) $(BYTE_COMPILE_FLAGS) \ -l comp -f batch-byte-native-compile-for-bootstrap $< - -.el.eln: - $(AM_V_ELN)$(emacs) $(BYTE_COMPILE_FLAGS) -f batch-native-compile $< +else +.el.elc: + $(AM_V_ELC)$(emacs) $(BYTE_COMPILE_FLAGS) -f batch-byte-compile $< +endif .PHONY: compile-first compile-main compile compile-always diff --git a/src/Makefile.in b/src/Makefile.in index cc43cd9f319..6a151d18d02 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -513,7 +513,6 @@ lisp.mk: $(lispsource)/loadup.el sed -e 's/$$/.elc \\/' -e 's/\.el\.elc/.el/'; \ echo "" ) > $@ - -include lisp.mk shortlisp_filter = leim/leim-list.el site-load.elc site-init.elc shortlisp := $(filter-out ${shortlisp_filter},${shortlisp}) -- cgit v1.2.3 From dab8dd836cb7c714cebae155f41e21fd824acaea Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Sat, 14 Mar 2020 10:57:34 +0000 Subject: Fix make bootstrap for native compilation Add Makefile target native-compile-clean removing all eln output folders. This is also triggered by make bootstrap to perform a clean bootstrap. Also revert some modification of the build system against master not effective anymore with the new directory layout. --- lisp/Makefile.in | 17 ++++++++++------- src/Makefile.in | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'src/Makefile.in') diff --git a/lisp/Makefile.in b/lisp/Makefile.in index fdd39d5fd54..8ba619656d8 100644 --- a/lisp/Makefile.in +++ b/lisp/Makefile.in @@ -356,6 +356,13 @@ compile-main: gen-lisp compile-clean $(MAKE) compile-targets TARGETS="$$chunk"; \ done +.PHONY: native-compile-clean +native-compile-clean: +# Erase all eln output compilation folders. +ifeq ($(HAVE_NATIVE_COMP),yes) + find $(lisp) -regex ".*/eln-.*-[0-9a-z]+\\'" -type d | xargs rm -rf +endif + .PHONY: compile-clean # Erase left-over .elc files that do not have a corresponding .el file. compile-clean: @@ -366,10 +373,6 @@ compile-clean: echo rm "$${el}c"; \ rm "$${el}c"; \ fi; \ - if test -f "$$el" || test ! -f "$${el}n"; then :; else \ - echo rm "$${el}n"; \ - rm "$${el}n"; \ - fi; \ done .PHONY: gen-lisp leim semantic @@ -396,7 +399,7 @@ compile: $(LOADDEFS) autoloads compile-first # Compile all Lisp files. This is like 'compile' but compiles files # unconditionally. Some files don't actually get compiled because they # set the local variable no-byte-compile. -compile-always: +compile-always: native-compile-clean find $(lisp) -name '*.elc' $(FIND_DELETE) $(MAKE) compile @@ -486,8 +489,8 @@ $(CAL_DIR)/hol-loaddefs.el: $(CAL_SRC) $(CAL_DIR)/diary-loaddefs.el .PHONY: bootstrap-clean distclean maintainer-clean extraclean -bootstrap-clean: - find $(lisp) -regex '.*\.elc\|.*\.eln' $(FIND_DELETE) +bootstrap-clean: native-compile-clean + find $(lisp) -name '*.elc' $(FIND_DELETE) rm -f $(AUTOGENEL) distclean: diff --git a/src/Makefile.in b/src/Makefile.in index 52d8ddd4e5d..8d7fdb8a607 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -327,7 +327,7 @@ GMP_LIB = @GMP_LIB@ GMP_OBJ = @GMP_OBJ@ LIBGCCJIT = @LIBGCCJIT_LIB@ -## dynlib.o comp.o if native compiler is enabled, else empty +## dynlib.o comp.o if native compiler is enabled, otherwise empty. COMP_OBJ = @COMP_OBJ@ RUN_TEMACS = ./temacs -- cgit v1.2.3 From 3dd6cf813953ffda1a581243faa098f3b8f7c12b Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Sat, 11 Apr 2020 13:59:59 +0100 Subject: Implement working make install for native build. --- Makefile.in | 3 ++- lisp/loadup.el | 27 ++++++++++++++++++++------- src/Makefile.in | 3 ++- src/pdumper.c | 5 +++++ 4 files changed, 29 insertions(+), 9 deletions(-) (limited to 'src/Makefile.in') diff --git a/Makefile.in b/Makefile.in index 67e15cfecd2..2f6a68fd9d7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -421,7 +421,8 @@ lib lib-src lisp nt: Makefile dirstate = .git/logs/HEAD VCSWITNESS = $(if $(wildcard $(srcdir)/$(dirstate)),$$(srcdir)/../$(dirstate)) src: Makefile - $(MAKE) -C $@ VCSWITNESS='$(VCSWITNESS)' all + $(MAKE) -C $@ VCSWITNESS='$(VCSWITNESS)' BIN_DESTDIR='$(DESTDIR)${bindir}/' \ + LISP_DESTDIR='$(DESTDIR)${lispdir}/' all blessmail: Makefile src $(MAKE) -C lib-src maybe-blessmail diff --git a/lisp/loadup.el b/lisp/loadup.el index bda9919cbbc..3cc47bc91fa 100644 --- a/lisp/loadup.el +++ b/lisp/loadup.el @@ -449,19 +449,32 @@ lost after dumping"))) ;; At this point, we're ready to resume undo recording for scratch. (buffer-enable-undo "*scratch*") -(when (boundp 'comp-ctxt) ; FIXME better native-comp build discriminant? - ;; Set the filename for every compilation unit as realtive - ;; to obtain a position independent dump. - (let ((h (make-hash-table :test #'eq))) +(when (boundp 'comp-ctxt) ; FIXME better native-comp feature discriminant? + ;; Fix the compilation unit filename to have it working when + ;; when installed or if the source directory got moved. This is set to be + ;; a pair in the form: (rel-path-from-install-bin . rel-path-from-local-bin). + (let ((h (make-hash-table :test #'eq)) + (lisp-src-dir (expand-file-name (concat default-directory "../lisp"))) + (bin-dest-dir (cadr (member "--bin-dest" command-line-args))) + (lisp-dest-dir (cadr (member "--lisp-dest" command-line-args)))) (mapatoms (lambda (s) (let ((f (symbol-function s))) (when (subr-native-elisp-p f) (puthash (subr-native-comp-unit f) nil h))))) (maphash (lambda (cu _) - (native-comp-unit-set-file + (native-comp-unit-set-file cu - (file-relative-name (native-comp-unit-file cu) - invocation-directory))) + (cons + ;; Relative path from the installed binary. + (file-relative-name + (concat lisp-dest-dir + (replace-regexp-in-string + (regexp-quote lisp-src-dir) "" + (native-comp-unit-file cu))) + bin-dest-dir) + ;; Relative path from the built uninstalled binary. + (file-relative-name (native-comp-unit-file cu) + invocation-directory)))) h))) (when (hash-table-p purify-flag) diff --git a/src/Makefile.in b/src/Makefile.in index 429f7035443..7f86e96cdb4 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -588,7 +588,8 @@ endif ifeq ($(DUMPING),pdumper) $(pdmp): emacs$(EXEEXT) - LC_ALL=C $(RUN_TEMACS) -batch $(BUILD_DETAILS) -l loadup --temacs=pdump + LC_ALL=C $(RUN_TEMACS) -batch $(BUILD_DETAILS) -l loadup --temacs=pdump \ + --bin-dest $(BIN_DESTDIR) --lisp-dest $(LISP_DESTDIR) cp -f $@ $(bootstrap_pdmp) endif diff --git a/src/pdumper.c b/src/pdumper.c index 69594b51c59..490f357219d 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -5298,6 +5298,11 @@ dump_do_dump_relocation (const uintptr_t dump_base, { struct Lisp_Native_Comp_Unit *comp_u = dump_ptr (dump_base, reloc_offset); + if (!CONSP (comp_u->file)) + error ("Trying to load incoherent dumped .eln"); + comp_u->file = + NILP (Ffile_exists_p (XCAR (comp_u->file))) + ? XCDR (comp_u->file) : XCAR (comp_u->file); comp_u->handle = dynlib_open (SSDATA (concat2 (Vinvocation_directory, comp_u->file))); if (!comp_u->handle) -- cgit v1.2.3 From 483cdf7a7942c91f6691953c9fe4618194dd175b Mon Sep 17 00:00:00 2001 From: Nicolás Bértolo Date: Mon, 11 May 2020 20:43:06 -0300 Subject: Load libgccjit dynamically in Windows. * configure.ac: don't add linker flags if compiling on Windows. Compile dynlib.c if modules or native compilation are enabled. Always compile comp.c * lisp/term/w32-win.el: Map 'gccjit to "libgccjit.dll" in `dynamic-library-alist`. * src/Makefile.in: Update comments. Update to handle changes in configure.ac. * src/comp.c: Add declarations of used libgccjit functions using DEF_DLL_FN. Add calls to load_gccjit_if_necessary() where necessary. Add `native-comp-available-p` * src/comp.h: Remove Fnative_elisp_load. Add syms_of_comp(). * src/emacs.c (main): Always call syms_of_comp() * src/w32.c (globals_of_w32): Clear Vlibrary_cache when starting because the libraries loaded when dumping will not be loaded when starting. * src/w32fns.c: Add Qgccjit symbol. --- configure.ac | 19 ++- lisp/term/w32-win.el | 3 +- src/Makefile.in | 9 +- src/comp.c | 374 ++++++++++++++++++++++++++++++++++++++++++++++++++- src/comp.h | 6 +- src/emacs.c | 2 - src/w32.c | 4 + src/w32fns.c | 1 + 8 files changed, 398 insertions(+), 20 deletions(-) (limited to 'src/Makefile.in') diff --git a/configure.ac b/configure.ac index 23b94cf6ca1..ea0144f4048 100644 --- a/configure.ac +++ b/configure.ac @@ -3666,6 +3666,7 @@ AC_SUBST(LIBZ) LIBMODULES= HAVE_MODULES=no MODULES_OBJ= +NEED_DYNLIB=no case $opsys in cygwin|mingw32) MODULES_SUFFIX=".dll" ;; darwin) MODULES_SUFFIX=".dylib" ;; @@ -3701,7 +3702,8 @@ if test "${with_modules}" != "no"; then fi if test "${HAVE_MODULES}" = yes; then - MODULES_OBJ="dynlib.o emacs-module.o" + MODULES_OBJ="emacs-module.o" + NEED_DYNLIB=yes AC_DEFINE(HAVE_MODULES, 1, [Define to 1 if dynamic modules are enabled]) AC_DEFINE_UNQUOTED(MODULES_SUFFIX, "$MODULES_SUFFIX", [System extension for dynamic libraries]) @@ -3785,7 +3787,6 @@ Here instructions on how to compile and install libgccjit from source: HAVE_NATIVE_COMP=no LIBGCCJIT_LIB= -COMP_OBJ= if test "${with_nativecomp}" != "no"; then emacs_save_LIBS=$LIBS LIBS="-lgccjit" @@ -3793,8 +3794,11 @@ if test "${with_nativecomp}" != "no"; then [AC_LINK_IFELSE([libgccjit_smoke_test], [], [libgccjit_not_found])]) LIBS=$emacs_save_LIBS HAVE_NATIVE_COMP=yes - LIBGCCJIT_LIB="-lgccjit -ldl" - COMP_OBJ="comp.o" + # mingw32 loads the library dynamically. + if test "${opsys}" != "mingw32"; then + LIBGCCJIT_LIB="-lgccjit -ldl" + fi + NEED_DYNLIB=yes AC_DEFINE(HAVE_NATIVE_COMP, 1, [Define to 1 if you have the libgccjit library (-lgccjit).]) fi if test "${HAVE_NATIVE_COMP}" = yes && test "${HAVE_PDUMPER}" = no; then @@ -3804,7 +3808,12 @@ AC_DEFINE_UNQUOTED(NATIVE_ELISP_SUFFIX, ".eln", [System extension for native compiled elisp]) AC_SUBST(HAVE_NATIVE_COMP) AC_SUBST(LIBGCCJIT_LIB) -AC_SUBST(COMP_OBJ) + +DYNLIB_OBJ= +if test "${NEED_DYNLIB}" = yes; then + DYNLIB_OBJ="dynlib.o" +fi +AC_SUBST(DYNLIB_OBJ) ### Use -lpng if available, unless '--with-png=no'. HAVE_PNG=no diff --git a/lisp/term/w32-win.el b/lisp/term/w32-win.el index 5901e0295e1..6b9716ca307 100644 --- a/lisp/term/w32-win.el +++ b/lisp/term/w32-win.el @@ -289,7 +289,8 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.") '(libxml2 "libxml2-2.dll" "libxml2.dll") '(zlib "zlib1.dll" "libz-1.dll") '(lcms2 "liblcms2-2.dll") - '(json "libjansson-4.dll"))) + '(json "libjansson-4.dll") + '(gccjit "libgccjit.dll"))) ;;; multi-tty support (defvar w32-initialized nil diff --git a/src/Makefile.in b/src/Makefile.in index 63f909ae147..85709184da1 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -241,7 +241,7 @@ LIBZ = @LIBZ@ ## system-specific libs for dynamic modules, else empty LIBMODULES = @LIBMODULES@ -## dynlib.o emacs-module.o if modules enabled, else empty +## emacs-module.o if modules enabled, else empty MODULES_OBJ = @MODULES_OBJ@ XRANDR_LIBS = @XRANDR_LIBS@ @@ -327,8 +327,9 @@ GMP_LIB = @GMP_LIB@ GMP_OBJ = @GMP_OBJ@ LIBGCCJIT = @LIBGCCJIT_LIB@ -## dynlib.o comp.o if native compiler is enabled, otherwise empty. -COMP_OBJ = @COMP_OBJ@ + +## dynlib.o if necessary, else empty +DYNLIB_OBJ = @DYNLIB_OBJ@ RUN_TEMACS = ./temacs @@ -418,7 +419,7 @@ base_obj = dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \ cmds.o casetab.o casefiddle.o indent.o search.o regex-emacs.o undo.o \ alloc.o pdumper.o data.o doc.o editfns.o callint.o \ eval.o floatfns.o fns.o font.o print.o lread.o $(MODULES_OBJ) \ - syntax.o $(UNEXEC_OBJ) bytecode.o $(COMP_OBJ) \ + syntax.o $(UNEXEC_OBJ) bytecode.o comp.o $(DYNLIB_OBJ) \ process.o gnutls.o callproc.o \ region-cache.o sound.o timefns.o atimer.o \ doprnt.o intervals.o textprop.o composite.o xml.o lcms.o $(NOTIFY_OBJ) \ diff --git a/src/comp.c b/src/comp.c index 994bd7db934..d72fa927460 100644 --- a/src/comp.c +++ b/src/comp.c @@ -20,6 +20,8 @@ along with GNU Emacs. If not, see . */ #include +#include "lisp.h" + #ifdef HAVE_NATIVE_COMP #include @@ -28,7 +30,6 @@ along with GNU Emacs. If not, see . */ #include #include -#include "lisp.h" #include "puresize.h" #include "window.h" #include "dynlib.h" @@ -36,6 +37,347 @@ along with GNU Emacs. If not, see . */ #include "blockinput.h" #include "sha512.h" + +/********************************/ +/* Dynamic loading of libgccjit */ +/********************************/ + +#ifdef WINDOWSNT +# include "w32common.h" + +#undef gcc_jit_block_add_assignment +#undef gcc_jit_block_add_comment +#undef gcc_jit_block_add_eval +#undef gcc_jit_block_end_with_conditional +#undef gcc_jit_block_end_with_jump +#undef gcc_jit_block_end_with_return +#undef gcc_jit_block_end_with_void_return +#undef gcc_jit_context_acquire +#undef gcc_jit_context_compile_to_file +#undef gcc_jit_context_dump_reproducer_to_file +#undef gcc_jit_context_dump_to_file +#undef gcc_jit_context_get_builtin_function +#undef gcc_jit_context_get_first_error +#undef gcc_jit_context_get_int_type +#undef gcc_jit_context_get_type +#undef gcc_jit_context_new_array_access +#undef gcc_jit_context_new_array_type +#undef gcc_jit_context_new_binary_op +#undef gcc_jit_context_new_call +#undef gcc_jit_context_new_call_through_ptr +#undef gcc_jit_context_new_comparison +#undef gcc_jit_context_new_field +#undef gcc_jit_context_new_function +#undef gcc_jit_context_new_function_ptr_type +#undef gcc_jit_context_new_global +#undef gcc_jit_context_new_opaque_struct +#undef gcc_jit_context_new_param +#undef gcc_jit_context_new_rvalue_from_int +#undef gcc_jit_context_new_rvalue_from_long +#undef gcc_jit_context_new_rvalue_from_ptr +#undef gcc_jit_context_new_struct_type +#undef gcc_jit_context_new_unary_op +#undef gcc_jit_context_new_union_type +#undef gcc_jit_context_release +#undef gcc_jit_context_set_bool_option +#undef gcc_jit_context_set_int_option +#undef gcc_jit_context_set_logfile +#undef gcc_jit_function_get_param +#undef gcc_jit_function_new_block +#undef gcc_jit_function_new_local +#undef gcc_jit_lvalue_access_field +#undef gcc_jit_lvalue_as_rvalue +#undef gcc_jit_lvalue_get_address +#undef gcc_jit_param_as_lvalue +#undef gcc_jit_param_as_rvalue +#undef gcc_jit_rvalue_access_field +#undef gcc_jit_rvalue_dereference +#undef gcc_jit_rvalue_dereference_field +#undef gcc_jit_rvalue_get_type +#undef gcc_jit_struct_as_type +#undef gcc_jit_struct_set_fields +#undef gcc_jit_type_get_pointer + +/* In alphabetical order */ +DEF_DLL_FN (gcc_jit_rvalue *, gcc_jit_context_new_rvalue_from_int, + (gcc_jit_context *ctxt, gcc_jit_type *numeric_type, int value)); +DEF_DLL_FN (gcc_jit_rvalue *, gcc_jit_lvalue_as_rvalue, + (gcc_jit_lvalue *lvalue)); +DEF_DLL_FN (gcc_jit_rvalue *, gcc_jit_rvalue_access_field, + (gcc_jit_rvalue *struct_or_union, gcc_jit_location *loc, + gcc_jit_field *field)); +DEF_DLL_FN (void, gcc_jit_block_add_comment, + (gcc_jit_block *block, gcc_jit_location *loc, const char *text)); +DEF_DLL_FN (void, gcc_jit_context_release, (gcc_jit_context *ctxt)); +DEF_DLL_FN (const char *, gcc_jit_context_get_first_error, + (gcc_jit_context *ctxt)); +DEF_DLL_FN (gcc_jit_block *, gcc_jit_function_new_block, + (gcc_jit_function *func, const char *name)); +DEF_DLL_FN (gcc_jit_context *, gcc_jit_context_acquire, (void)); +DEF_DLL_FN (gcc_jit_field *, gcc_jit_context_new_field, + (gcc_jit_context *ctxt, gcc_jit_location *loc, gcc_jit_type *type, + const char *name)); +DEF_DLL_FN (gcc_jit_function *, gcc_jit_context_get_builtin_function, + (gcc_jit_context *ctxt, const char *name)); +DEF_DLL_FN (gcc_jit_function *, gcc_jit_context_new_function, + (gcc_jit_context *ctxt, gcc_jit_location *loc, + enum gcc_jit_function_kind kind, gcc_jit_type *return_type, + const char *name, int num_params, gcc_jit_param **params, + int is_variadic)); +DEF_DLL_FN (gcc_jit_lvalue *, gcc_jit_context_new_array_access, + (gcc_jit_context *ctxt, gcc_jit_location *loc, gcc_jit_rvalue *ptr, + gcc_jit_rvalue *index)); +DEF_DLL_FN (gcc_jit_lvalue *, gcc_jit_context_new_global, + (gcc_jit_context *ctxt, gcc_jit_location *loc, + enum gcc_jit_global_kind kind, gcc_jit_type *type, + const char *name)); +DEF_DLL_FN (gcc_jit_lvalue *, gcc_jit_function_new_local, + (gcc_jit_function *func, gcc_jit_location *loc, gcc_jit_type *type, + const char *name)); +DEF_DLL_FN (gcc_jit_lvalue *, gcc_jit_lvalue_access_field, + (gcc_jit_lvalue *struct_or_union, gcc_jit_location *loc, + gcc_jit_field *field)); +DEF_DLL_FN (gcc_jit_lvalue *, gcc_jit_param_as_lvalue, (gcc_jit_param *param)); +DEF_DLL_FN (gcc_jit_lvalue *, gcc_jit_rvalue_dereference, + (gcc_jit_rvalue *rvalue, gcc_jit_location *loc)); +DEF_DLL_FN (gcc_jit_lvalue *, gcc_jit_rvalue_dereference_field, + (gcc_jit_rvalue *ptr, gcc_jit_location *loc, gcc_jit_field *field)); +DEF_DLL_FN (gcc_jit_param *, gcc_jit_context_new_param, + (gcc_jit_context *ctxt, gcc_jit_location *loc, gcc_jit_type *type, + const char *name)); +DEF_DLL_FN (gcc_jit_param *, gcc_jit_function_get_param, + (gcc_jit_function *func, int index)); +DEF_DLL_FN (gcc_jit_rvalue *, gcc_jit_context_new_binary_op, + (gcc_jit_context *ctxt, gcc_jit_location *loc, + enum gcc_jit_binary_op op, gcc_jit_type *result_type, + gcc_jit_rvalue *a, gcc_jit_rvalue *b)); +DEF_DLL_FN (gcc_jit_rvalue *, gcc_jit_context_new_call, + (gcc_jit_context *ctxt, gcc_jit_location *loc, + gcc_jit_function *func, int numargs , gcc_jit_rvalue **args)); +DEF_DLL_FN (gcc_jit_rvalue *, gcc_jit_context_new_call_through_ptr, + (gcc_jit_context *ctxt, gcc_jit_location *loc, + gcc_jit_rvalue *fn_ptr, int numargs, gcc_jit_rvalue **args)); +DEF_DLL_FN (gcc_jit_rvalue *, gcc_jit_context_new_comparison, + (gcc_jit_context *ctxt, gcc_jit_location *loc, + enum gcc_jit_comparison op, gcc_jit_rvalue *a, gcc_jit_rvalue *b)); +DEF_DLL_FN (gcc_jit_rvalue *, gcc_jit_context_new_rvalue_from_long, + (gcc_jit_context *ctxt, gcc_jit_type *numeric_type, long value)); +DEF_DLL_FN (gcc_jit_rvalue *, gcc_jit_context_new_rvalue_from_ptr, + (gcc_jit_context *ctxt, gcc_jit_type *pointer_type, void *value)); +DEF_DLL_FN (gcc_jit_rvalue *, gcc_jit_context_new_unary_op, + (gcc_jit_context *ctxt, gcc_jit_location *loc, + enum gcc_jit_unary_op op, gcc_jit_type *result_type, + gcc_jit_rvalue *rvalue)); +DEF_DLL_FN (gcc_jit_rvalue *, gcc_jit_lvalue_get_address, + (gcc_jit_lvalue *lvalue, gcc_jit_location *loc)); +DEF_DLL_FN (gcc_jit_rvalue *, gcc_jit_param_as_rvalue, (gcc_jit_param *param)); +DEF_DLL_FN (gcc_jit_struct *, gcc_jit_context_new_opaque_struct, + (gcc_jit_context *ctxt, gcc_jit_location *loc, const char *name)); +DEF_DLL_FN (gcc_jit_struct *, gcc_jit_context_new_struct_type, + (gcc_jit_context *ctxt, gcc_jit_location *loc, const char *name, + int num_fields, gcc_jit_field **fields)); +DEF_DLL_FN (gcc_jit_type *, gcc_jit_context_get_int_type, + (gcc_jit_context *ctxt, int num_bytes, int is_signed)); +DEF_DLL_FN (gcc_jit_type *, gcc_jit_context_get_type, + (gcc_jit_context *ctxt, enum gcc_jit_types type_)); +DEF_DLL_FN (gcc_jit_type *, gcc_jit_context_new_array_type, + (gcc_jit_context *ctxt, gcc_jit_location *loc, + gcc_jit_type *element_type, int num_elements)); +DEF_DLL_FN (gcc_jit_type *, gcc_jit_context_new_function_ptr_type, + (gcc_jit_context *ctxt, gcc_jit_location *loc, + gcc_jit_type *return_type, int num_params, + gcc_jit_type **param_types, int is_variadic)); +DEF_DLL_FN (gcc_jit_type *, gcc_jit_context_new_union_type, + (gcc_jit_context *ctxt, gcc_jit_location *loc, const char *name, + int num_fields, gcc_jit_field **fields)); +DEF_DLL_FN (gcc_jit_type *, gcc_jit_rvalue_get_type, (gcc_jit_rvalue *rvalue)); +DEF_DLL_FN (gcc_jit_type *, gcc_jit_struct_as_type, + (gcc_jit_struct *struct_type)); +DEF_DLL_FN (gcc_jit_type *, gcc_jit_type_get_pointer, (gcc_jit_type *type)); +DEF_DLL_FN (void, gcc_jit_block_add_assignment, + (gcc_jit_block *block, gcc_jit_location *loc, gcc_jit_lvalue *lvalue, + gcc_jit_rvalue *rvalue)); +DEF_DLL_FN (void, gcc_jit_block_add_eval, + (gcc_jit_block *block, gcc_jit_location *loc, + gcc_jit_rvalue *rvalue)); +DEF_DLL_FN (void, gcc_jit_block_end_with_conditional, + (gcc_jit_block *block, gcc_jit_location *loc, + gcc_jit_rvalue *boolval, gcc_jit_block *on_true, + gcc_jit_block *on_false)); +DEF_DLL_FN (void, gcc_jit_block_end_with_jump, + (gcc_jit_block *block, gcc_jit_location *loc, + gcc_jit_block *target)); +DEF_DLL_FN (void, gcc_jit_block_end_with_return, + (gcc_jit_block *block, gcc_jit_location *loc, + gcc_jit_rvalue *rvalue)); +DEF_DLL_FN (void, gcc_jit_block_end_with_void_return, + (gcc_jit_block *block, gcc_jit_location *loc)); +DEF_DLL_FN (void, gcc_jit_context_compile_to_file, + (gcc_jit_context *ctxt, enum gcc_jit_output_kind output_kind, + const char *output_path)); +DEF_DLL_FN (void, gcc_jit_context_dump_reproducer_to_file, + (gcc_jit_context *ctxt, const char *path)); +DEF_DLL_FN (void, gcc_jit_context_dump_to_file, + (gcc_jit_context *ctxt, const char *path, int update_locations)); +DEF_DLL_FN (void, gcc_jit_context_set_bool_option, + (gcc_jit_context *ctxt, enum gcc_jit_bool_option opt, int value)); +DEF_DLL_FN (void, gcc_jit_context_set_int_option, + (gcc_jit_context *ctxt, enum gcc_jit_int_option opt, int value)); +DEF_DLL_FN (void, gcc_jit_context_set_logfile, + (gcc_jit_context *ctxt, FILE *logfile, int flags, int verbosity)); +DEF_DLL_FN (void, gcc_jit_struct_set_fields, + (gcc_jit_struct *struct_type, gcc_jit_location *loc, int num_fields, + gcc_jit_field **fields)); + +static bool +init_gccjit_functions (void) +{ + HMODULE library; + + if (!(library = w32_delayed_load (Qgccjit))) + { + return false; + } + + /* In alphabetical order */ + LOAD_DLL_FN(library, gcc_jit_block_add_assignment); + LOAD_DLL_FN(library, gcc_jit_block_add_comment); + LOAD_DLL_FN(library, gcc_jit_block_add_eval); + LOAD_DLL_FN(library, gcc_jit_block_end_with_conditional); + LOAD_DLL_FN(library, gcc_jit_block_end_with_jump); + LOAD_DLL_FN(library, gcc_jit_block_end_with_return); + LOAD_DLL_FN(library, gcc_jit_block_end_with_void_return); + LOAD_DLL_FN(library, gcc_jit_context_acquire); + LOAD_DLL_FN(library, gcc_jit_context_compile_to_file); + LOAD_DLL_FN(library, gcc_jit_context_dump_reproducer_to_file); + LOAD_DLL_FN(library, gcc_jit_context_dump_to_file); + LOAD_DLL_FN(library, gcc_jit_context_get_builtin_function); + LOAD_DLL_FN(library, gcc_jit_context_get_first_error); + LOAD_DLL_FN(library, gcc_jit_context_get_int_type); + LOAD_DLL_FN(library, gcc_jit_context_get_type); + LOAD_DLL_FN(library, gcc_jit_context_new_array_access); + LOAD_DLL_FN(library, gcc_jit_context_new_array_type); + LOAD_DLL_FN(library, gcc_jit_context_new_binary_op); + LOAD_DLL_FN(library, gcc_jit_context_new_call); + LOAD_DLL_FN(library, gcc_jit_context_new_call_through_ptr); + LOAD_DLL_FN(library, gcc_jit_context_new_comparison); + LOAD_DLL_FN(library, gcc_jit_context_new_field); + LOAD_DLL_FN(library, gcc_jit_context_new_function); + LOAD_DLL_FN(library, gcc_jit_context_new_function_ptr_type); + LOAD_DLL_FN(library, gcc_jit_context_new_global); + LOAD_DLL_FN(library, gcc_jit_context_new_opaque_struct); + LOAD_DLL_FN(library, gcc_jit_context_new_param); + LOAD_DLL_FN(library, gcc_jit_context_new_rvalue_from_int); + LOAD_DLL_FN(library, gcc_jit_context_new_rvalue_from_long); + LOAD_DLL_FN(library, gcc_jit_context_new_rvalue_from_ptr); + LOAD_DLL_FN(library, gcc_jit_context_new_struct_type); + LOAD_DLL_FN(library, gcc_jit_context_new_unary_op); + LOAD_DLL_FN(library, gcc_jit_context_new_union_type); + LOAD_DLL_FN(library, gcc_jit_context_release); + LOAD_DLL_FN(library, gcc_jit_context_set_bool_option); + LOAD_DLL_FN(library, gcc_jit_context_set_int_option); + LOAD_DLL_FN(library, gcc_jit_context_set_logfile); + LOAD_DLL_FN(library, gcc_jit_function_get_param); + LOAD_DLL_FN(library, gcc_jit_function_new_block); + LOAD_DLL_FN(library, gcc_jit_function_new_local); + LOAD_DLL_FN(library, gcc_jit_lvalue_access_field); + LOAD_DLL_FN(library, gcc_jit_lvalue_as_rvalue); + LOAD_DLL_FN(library, gcc_jit_lvalue_get_address); + LOAD_DLL_FN(library, gcc_jit_param_as_lvalue); + LOAD_DLL_FN(library, gcc_jit_param_as_rvalue); + LOAD_DLL_FN(library, gcc_jit_rvalue_access_field); + LOAD_DLL_FN(library, gcc_jit_rvalue_dereference); + LOAD_DLL_FN(library, gcc_jit_rvalue_dereference_field); + LOAD_DLL_FN(library, gcc_jit_rvalue_get_type); + LOAD_DLL_FN(library, gcc_jit_struct_as_type); + LOAD_DLL_FN(library, gcc_jit_struct_set_fields); + LOAD_DLL_FN(library, gcc_jit_type_get_pointer); + + return true; +} + +/* In alphabetical order */ +#define gcc_jit_block_add_assignment fn_gcc_jit_block_add_assignment +#define gcc_jit_block_add_comment fn_gcc_jit_block_add_comment +#define gcc_jit_block_add_eval fn_gcc_jit_block_add_eval +#define gcc_jit_block_end_with_conditional fn_gcc_jit_block_end_with_conditional +#define gcc_jit_block_end_with_jump fn_gcc_jit_block_end_with_jump +#define gcc_jit_block_end_with_return fn_gcc_jit_block_end_with_return +#define gcc_jit_block_end_with_void_return fn_gcc_jit_block_end_with_void_return +#define gcc_jit_context_acquire fn_gcc_jit_context_acquire +#define gcc_jit_context_compile_to_file fn_gcc_jit_context_compile_to_file +#define gcc_jit_context_dump_reproducer_to_file fn_gcc_jit_context_dump_reproducer_to_file +#define gcc_jit_context_dump_to_file fn_gcc_jit_context_dump_to_file +#define gcc_jit_context_get_builtin_function fn_gcc_jit_context_get_builtin_function +#define gcc_jit_context_get_first_error fn_gcc_jit_context_get_first_error +#define gcc_jit_context_get_int_type fn_gcc_jit_context_get_int_type +#define gcc_jit_context_get_type fn_gcc_jit_context_get_type +#define gcc_jit_context_new_array_access fn_gcc_jit_context_new_array_access +#define gcc_jit_context_new_array_type fn_gcc_jit_context_new_array_type +#define gcc_jit_context_new_binary_op fn_gcc_jit_context_new_binary_op +#define gcc_jit_context_new_call fn_gcc_jit_context_new_call +#define gcc_jit_context_new_call_through_ptr fn_gcc_jit_context_new_call_through_ptr +#define gcc_jit_context_new_comparison fn_gcc_jit_context_new_comparison +#define gcc_jit_context_new_field fn_gcc_jit_context_new_field +#define gcc_jit_context_new_function fn_gcc_jit_context_new_function +#define gcc_jit_context_new_function_ptr_type fn_gcc_jit_context_new_function_ptr_type +#define gcc_jit_context_new_global fn_gcc_jit_context_new_global +#define gcc_jit_context_new_opaque_struct fn_gcc_jit_context_new_opaque_struct +#define gcc_jit_context_new_param fn_gcc_jit_context_new_param +#define gcc_jit_context_new_rvalue_from_int fn_gcc_jit_context_new_rvalue_from_int +#define gcc_jit_context_new_rvalue_from_long fn_gcc_jit_context_new_rvalue_from_long +#define gcc_jit_context_new_rvalue_from_ptr fn_gcc_jit_context_new_rvalue_from_ptr +#define gcc_jit_context_new_struct_type fn_gcc_jit_context_new_struct_type +#define gcc_jit_context_new_unary_op fn_gcc_jit_context_new_unary_op +#define gcc_jit_context_new_union_type fn_gcc_jit_context_new_union_type +#define gcc_jit_context_release fn_gcc_jit_context_release +#define gcc_jit_context_set_bool_option fn_gcc_jit_context_set_bool_option +#define gcc_jit_context_set_int_option fn_gcc_jit_context_set_int_option +#define gcc_jit_context_set_logfile fn_gcc_jit_context_set_logfile +#define gcc_jit_function_get_param fn_gcc_jit_function_get_param +#define gcc_jit_function_new_block fn_gcc_jit_function_new_block +#define gcc_jit_function_new_local fn_gcc_jit_function_new_local +#define gcc_jit_lvalue_access_field fn_gcc_jit_lvalue_access_field +#define gcc_jit_lvalue_as_rvalue fn_gcc_jit_lvalue_as_rvalue +#define gcc_jit_lvalue_get_address fn_gcc_jit_lvalue_get_address +#define gcc_jit_param_as_lvalue fn_gcc_jit_param_as_lvalue +#define gcc_jit_param_as_rvalue fn_gcc_jit_param_as_rvalue +#define gcc_jit_rvalue_access_field fn_gcc_jit_rvalue_access_field +#define gcc_jit_rvalue_dereference fn_gcc_jit_rvalue_dereference +#define gcc_jit_rvalue_dereference_field fn_gcc_jit_rvalue_dereference_field +#define gcc_jit_rvalue_get_type fn_gcc_jit_rvalue_get_type +#define gcc_jit_struct_as_type fn_gcc_jit_struct_as_type +#define gcc_jit_struct_set_fields fn_gcc_jit_struct_set_fields +#define gcc_jit_type_get_pointer fn_gcc_jit_type_get_pointer + +#endif + +static bool +load_gccjit_if_necessary (bool mandatory) +{ +#ifdef WINDOWSNT + static bool tried_to_initialize_once; + static bool gccjit_initialized; + + if (!tried_to_initialize_once) + { + tried_to_initialize_once = true; + Lisp_Object status; + gccjit_initialized = init_gccjit_functions (); + status = gccjit_initialized ? Qt : Qnil; + Vlibrary_cache = Fcons (Fcons (Qgccjit, status), Vlibrary_cache); + } + + if (mandatory && !gccjit_initialized) + xsignal1(Qnative_compiler_error, build_string("libgccjit not found")); + + return gccjit_initialized; +#else + return true; +#endif +} + + /* C symbols emitted for the load relocation mechanism. */ #define CURRENT_THREAD_RELOC_SYM "current_thread_reloc" #define PURE_RELOC_SYM "pure_reloc" @@ -3295,6 +3637,8 @@ DEFUN ("comp--init-ctxt", Fcomp__init_ctxt, Scomp__init_ctxt, doc: /* Initialize the native compiler context. Return t on success. */) (void) { + load_gccjit_if_necessary(true); + if (comp.ctxt) { xsignal1 (Qnative_ice, @@ -3441,6 +3785,8 @@ DEFUN ("comp--release-ctxt", Fcomp__release_ctxt, Scomp__release_ctxt, doc: /* Release the native compiler context. */) (void) { + load_gccjit_if_necessary(true); + if (comp.ctxt) gcc_jit_context_release (comp.ctxt); @@ -3457,6 +3803,8 @@ DEFUN ("comp--compile-ctxt-to-file", Fcomp__compile_ctxt_to_file, doc: /* Compile as native code the current context to file. */) (Lisp_Object base_name) { + load_gccjit_if_necessary(true); + CHECK_STRING (base_name); gcc_jit_context_set_int_option (comp.ctxt, @@ -3626,6 +3974,9 @@ maybe_defer_native_compilation (Lisp_Object function_name, fflush (f); } #endif + if (!load_gccjit_if_necessary(false)) + return; + if (!comp_deferred_compilation || noninteractive || !NILP (Vpurify_flag) @@ -3975,10 +4326,26 @@ DEFUN ("native-elisp-load", Fnative_elisp_load, Snative_elisp_load, 1, 2, 0, return Qt; } +#endif /* HAVE_NATIVE_COMP */ + +DEFUN ("native-comp-available-p", Fnative_comp_available_p, + Snative_comp_available_p, 0, 0, 0, + doc: /* Returns t if native compilation of Lisp files is available in +this instance of Emacs. */) + (void) +{ +#ifdef HAVE_NATIVE_COMP + return load_gccjit_if_necessary(false) ? Qt : Qnil; +#else + return Qnil; +#endif +} + void syms_of_comp (void) { +#ifdef HAVE_NATIVE_COMP /* Compiler control customizes. */ DEFVAR_BOOL ("comp-deferred-compilation", comp_deferred_compilation, doc: /* If t compile asyncronously every .elc file loaded. */); @@ -4122,6 +4489,7 @@ syms_of_comp (void) doc: /* Hash table symbol-name -> function-value. For internal use during */); Vcomp_deferred_pending_h = CALLN (Fmake_hash_table, QCtest, Qeq); -} +#endif -#endif /* HAVE_NATIVE_COMP */ + defsubr (&Snative_comp_available_p); +} diff --git a/src/comp.h b/src/comp.h index b03a8055142..36e7cdf4413 100644 --- a/src/comp.h +++ b/src/comp.h @@ -90,11 +90,7 @@ maybe_defer_native_compilation (Lisp_Object function_name, Lisp_Object definition) {} -static inline Lisp_Object -Fnative_elisp_load (Lisp_Object file, Lisp_Object late_load) -{ - eassume (false); -} +extern void syms_of_comp (void); #endif diff --git a/src/emacs.c b/src/emacs.c index 2c908257422..e75cb588349 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1606,10 +1606,8 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem init_json (); #endif -#ifdef HAVE_NATIVE_COMP if (!initialized) syms_of_comp (); -#endif no_loadup = argmatch (argv, argc, "-nl", "--no-loadup", 6, NULL, &skip_args); diff --git a/src/w32.c b/src/w32.c index 0f69e652a57..d01a45029d8 100644 --- a/src/w32.c +++ b/src/w32.c @@ -10586,6 +10586,10 @@ globals_of_w32 (void) #endif w32_crypto_hprov = (HCRYPTPROV)0; + + /* We need to forget about libraries that were loaded during the + dumping process (e.g. libgccjit) */ + Vlibrary_cache = Qnil; } /* For make-serial-process */ diff --git a/src/w32fns.c b/src/w32fns.c index e595b0285a7..eeb73489dd5 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -10462,6 +10462,7 @@ syms_of_w32fns (void) DEFSYM (Qzlib, "zlib"); DEFSYM (Qlcms2, "lcms2"); DEFSYM (Qjson, "json"); + DEFSYM (Qgccjit, "gccjit"); Fput (Qundefined_color, Qerror_conditions, pure_list (Qundefined_color, Qerror)); -- cgit v1.2.3 From dbeafd34032797c5d743a741492a5d9b35dd8c7b Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Fri, 14 Aug 2020 09:05:31 +0200 Subject: Some Makefile updates and clean-up * Makefile.in (clean): Remove 'eln-cache' folder. * lisp/Makefile.in (.SUFFIXES): Remove .eln. (native-compile-clean): Target remove. (compile-always, bootstrap-clean): Remove 'native-compile-clean' prerequisite. * src/Makefile.in (%.eln): Remove rule. --- Makefile.in | 1 + lisp/Makefile.in | 13 +++---------- src/Makefile.in | 4 ---- 3 files changed, 4 insertions(+), 14 deletions(-) (limited to 'src/Makefile.in') diff --git a/Makefile.in b/Makefile.in index f28623ef565..253f7f7a54b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -863,6 +863,7 @@ clean: $(clean_dirs:=_clean) [ ! -d test ] || $(MAKE) -C test $@ -rm -f ./*.tmp etc/*.tmp* -rm -rf info-dir.* + -rm -rf eln-cache ### 'bootclean' ### Delete all files that need to be remade for a clean bootstrap. diff --git a/lisp/Makefile.in b/lisp/Makefile.in index 9bcceceb0ee..164e4a01f59 100644 --- a/lisp/Makefile.in +++ b/lisp/Makefile.in @@ -302,7 +302,7 @@ endif # subdirectories, to make sure require's and load's in the files being # compiled find the right files. -.SUFFIXES: .eln .elc .el +.SUFFIXES: .elc .el # An old-fashioned suffix rule, which, according to the GNU Make manual, # cannot have prerequisites. @@ -357,13 +357,6 @@ compile-main: gen-lisp compile-clean TARGETS="$$chunk"; \ done -.PHONY: native-compile-clean -native-compile-clean: -# Erase all eln output compilation folders. -ifeq ($(HAVE_NATIVE_COMP),yes) - find $(lisp) -regex ".*/eln-.*-[0-9a-z]+\\'" -type d | xargs rm -rf -endif - .PHONY: compile-clean # Erase left-over .elc files that do not have a corresponding .el file. compile-clean: @@ -400,7 +393,7 @@ compile: $(LOADDEFS) autoloads compile-first # Compile all Lisp files. This is like 'compile' but compiles files # unconditionally. Some files don't actually get compiled because they # set the local variable no-byte-compile. -compile-always: native-compile-clean +compile-always: find $(lisp) -name '*.elc' $(FIND_DELETE) $(MAKE) compile @@ -490,7 +483,7 @@ $(CAL_DIR)/hol-loaddefs.el: $(CAL_SRC) $(CAL_DIR)/diary-loaddefs.el .PHONY: bootstrap-clean distclean maintainer-clean extraclean -bootstrap-clean: native-compile-clean +bootstrap-clean: find $(lisp) -name '*.elc' $(FIND_DELETE) rm -f $(AUTOGENEL) diff --git a/src/Makefile.in b/src/Makefile.in index 63a4aa80e93..7380a87644b 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -790,10 +790,6 @@ tags: TAGS ../lisp/TAGS $(lwlibdir)/TAGS @$(MAKE) $(AM_V_NO_PD) -C ../lisp EMACS="$(bootstrap_exe)"\ THEFILE=$< $ Date: Sun, 16 Aug 2020 11:18:36 +0200 Subject: Make install target functional for new eln-cache directory arrangement * src/comp.h (fixup_eln_load_path): New extern. * src/comp.c (fixup_eln_load_path): New function. * src/pdumper.c (dump_do_dump_relocation): Update to make use of 'fixup_eln_load_path'. * lisp/loadup.el: Update to store in the compilation unit the correct eln-cache installed path. Rename --lisp-dest -> --eln-dest and. * Makefile.in: Pass the eln destination directory to src/Makefile. Rename LISP_DESTDIR -> ELN_DESTDIR. (ELN_DESTDIR): Define. (install-eln): New target. (install): Add install-eln as prerequisite. * src/Makefile.in: Rename --lisp-dest -> --eln-dest and LISP_DESTDIR -> ELN_DESTDIR. --- Makefile.in | 16 +++++++++++++--- lisp/loadup.el | 44 ++++++++++++++++++++++---------------------- src/Makefile.in | 2 +- src/comp.c | 21 +++++++++++++++++++++ src/comp.h | 2 ++ src/pdumper.c | 15 ++------------- 6 files changed, 61 insertions(+), 39 deletions(-) (limited to 'src/Makefile.in') diff --git a/Makefile.in b/Makefile.in index 253f7f7a54b..a15850d55ef 100644 --- a/Makefile.in +++ b/Makefile.in @@ -108,6 +108,8 @@ am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = +HAVE_NATIVE_COMP = @HAVE_NATIVE_COMP@ + # ==================== Where To Install Things ==================== # Location to install Emacs.app under GNUstep / macOS. @@ -330,6 +332,8 @@ CONFIG_STATUS_FILES_IN = \ COPYDIR = ${srcdir}/etc ${srcdir}/lisp COPYDESTS = "$(DESTDIR)${etcdir}" "$(DESTDIR)${lispdir}" +ELN_DESTDIR = "$(DESTDIR)${libexecdir}/emacs/${version}/${configuration}/" + all: ${SUBDIR} info .PHONY: all ${SUBDIR} blessmail epaths-force epaths-force-w32 etc-emacsver @@ -422,7 +426,7 @@ dirstate = .git/logs/HEAD VCSWITNESS = $(if $(wildcard $(srcdir)/$(dirstate)),$$(srcdir)/../$(dirstate)) src: Makefile $(MAKE) -C $@ VCSWITNESS='$(VCSWITNESS)' BIN_DESTDIR='$(DESTDIR)${bindir}/' \ - LISP_DESTDIR='$(DESTDIR)${lispdir}/' all + ELN_DESTDIR='$(ELN_DESTDIR)' all blessmail: Makefile src $(MAKE) -C lib-src maybe-blessmail @@ -462,14 +466,14 @@ $(srcdir)/configure: $(srcdir)/configure.ac $(srcdir)/m4/*.m4 # ==================== Installation ==================== .PHONY: install install-arch-dep install-arch-indep install-etcdoc install-info -.PHONY: install-man install-etc install-strip install-$(NTDIR) +.PHONY: install-man install-etc install-strip install-$(NTDIR) install-eln .PHONY: uninstall uninstall-$(NTDIR) ## If we let lib-src do its own installation, that means we ## don't have to duplicate the list of utilities to install in ## this Makefile as well. -install: all install-arch-indep install-etcdoc install-arch-dep install-$(NTDIR) blessmail +install: all install-arch-indep install-etcdoc install-arch-dep install-$(NTDIR) blessmail install-eln @true ## Ensure that $subdir contains a subdirs.el file. @@ -753,6 +757,12 @@ install-etc: done ; \ done +### Install native compiled Lisp files. +install-eln: +ifeq ($(HAVE_NATIVE_COMP),yes) + find eln-cache -type f -exec ${INSTALL_DATA} -D "{}" "$(ELN_DESTDIR){}" \; +endif + ### Build Emacs and install it, stripping binaries while installing them. install-strip: $(MAKE) INSTALL_STRIP=-s install diff --git a/lisp/loadup.el b/lisp/loadup.el index 31843fc24d1..aaa5888bf92 100644 --- a/lisp/loadup.el +++ b/lisp/loadup.el @@ -449,33 +449,33 @@ lost after dumping"))) ;; At this point, we're ready to resume undo recording for scratch. (buffer-enable-undo "*scratch*") -(when (native-comp-available-p) +(when (boundp 'comp-ctxt) ;; Fix the compilation unit filename to have it working when ;; when installed or if the source directory got moved. This is set to be ;; a pair in the form: (rel-path-from-install-bin . rel-path-from-local-bin). (let ((h (make-hash-table :test #'eq)) - (lisp-src-dir (expand-file-name (concat default-directory "../lisp"))) (bin-dest-dir (cadr (member "--bin-dest" command-line-args))) - (lisp-dest-dir (cadr (member "--lisp-dest" command-line-args)))) - (mapatoms (lambda (s) - (let ((f (symbol-function s))) - (when (subr-native-elisp-p f) - (puthash (subr-native-comp-unit f) nil h))))) - (maphash (lambda (cu _) - (native-comp-unit-set-file - cu - (cons - ;; Relative path from the installed binary. - (file-relative-name - (concat lisp-dest-dir - (replace-regexp-in-string - (regexp-quote lisp-src-dir) "" - (native-comp-unit-file cu))) - bin-dest-dir) - ;; Relative path from the built uninstalled binary. - (file-relative-name (native-comp-unit-file cu) - invocation-directory)))) - h))) + (eln-dest-dir (cadr (member "--eln-dest" command-line-args)))) + (when (and bin-dest-dir eln-dest-dir) + (setq eln-dest-dir + (concat eln-dest-dir "eln-cache/" comp-native-path-postfix "/")) + (mapatoms (lambda (s) + (let ((f (symbol-function s))) + (when (subr-native-elisp-p f) + (puthash (subr-native-comp-unit f) nil h))))) + (maphash (lambda (cu _) + (native-comp-unit-set-file + cu + (cons + ;; Relative path from the installed binary. + (file-relative-name (concat eln-dest-dir + (file-name-nondirectory + (native-comp-unit-file cu))) + bin-dest-dir) + ;; Relative path from the built uninstalled binary. + (file-relative-name (native-comp-unit-file cu) + invocation-directory)))) + h)))) (when (hash-table-p purify-flag) (let ((strings 0) diff --git a/src/Makefile.in b/src/Makefile.in index 7380a87644b..31a5a7e7709 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -587,7 +587,7 @@ endif ifeq ($(DUMPING),pdumper) $(pdmp): emacs$(EXEEXT) LC_ALL=C $(RUN_TEMACS) -batch $(BUILD_DETAILS) -l loadup --temacs=pdump \ - --bin-dest $(BIN_DESTDIR) --lisp-dest $(LISP_DESTDIR) + --bin-dest $(BIN_DESTDIR) --eln-dest $(ELN_DESTDIR) cp -f $@ $(bootstrap_pdmp) endif diff --git a/src/comp.c b/src/comp.c index b795afae351..d42bb4f8eb5 100644 --- a/src/comp.c +++ b/src/comp.c @@ -4529,6 +4529,27 @@ maybe_defer_native_compilation (Lisp_Object function_name, /* Functions used to load eln files. */ /**************************************/ +/* Fixup the system eln-cache dir. This is the last entry in + `comp-eln-load-path'. */ +void +fixup_eln_load_path (Lisp_Object directory) +{ + Lisp_Object last_cell = Qnil; + Lisp_Object tmp = Vcomp_eln_load_path; + FOR_EACH_TAIL (tmp) + if (CONSP (tmp)) + last_cell = tmp; + + Lisp_Object eln_cache_sys = + Ffile_name_directory (concat2 (Vinvocation_directory, + directory)); + /* One directory up... */ + eln_cache_sys = + Ffile_name_directory (Fsubstring (eln_cache_sys, Qnil, + make_fixnum (-1))); + Fsetcar (last_cell, eln_cache_sys); +} + typedef char *(*comp_lit_str_func) (void); /* Deserialize read and return static object. */ diff --git a/src/comp.h b/src/comp.h index 687e426b1ef..9270f8bf664 100644 --- a/src/comp.h +++ b/src/comp.h @@ -101,6 +101,8 @@ extern void dispose_all_remaining_comp_units (void); extern void clean_package_user_dir_of_old_comp_units (void); +extern void fixup_eln_load_path (Lisp_Object directory); + #else /* #ifdef HAVE_NATIVE_COMP */ static inline void diff --git a/src/pdumper.c b/src/pdumper.c index ca055a1327c..8172389a49b 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -5249,23 +5249,12 @@ dump_do_dump_relocation (const uintptr_t dump_base, { fclose (file); installation_state = INSTALLED; - /* FIXME Vcomp_eln_load_path = ?? */ + fixup_eln_load_path (XCAR (comp_u->file)); } else { installation_state = LOCAL_BUILD; - /* Fixup `comp-eln-load-path' so emacs can be invoked - position independently. */ - Lisp_Object eln_cache_sys = - Ffile_name_directory (concat2 (Vinvocation_directory, - XCDR (comp_u->file))); - /* One directory up... */ - eln_cache_sys = - Ffile_name_directory (Fsubstring (eln_cache_sys, Qnil, - make_fixnum (-1))); - /* FIXME for subsequent dumps we should fixup only the - last entry. */ - Vcomp_eln_load_path = Fcons (eln_cache_sys, Qnil); + fixup_eln_load_path (XCDR (comp_u->file)); } } -- cgit v1.2.3 From 8dacc9e8c52ce873f2b0a54e7ca67cffd2c7f4f7 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Fri, 2 Oct 2020 13:49:20 +0200 Subject: * Fix 'incoherent dumped eln file' error when DUMP-METHOD=pbootstrap * src/Makefile.in ($(bootstrap_pdmp)): Add missing --bin-dest --eln-dest flags. --- src/Makefile.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Makefile.in') diff --git a/src/Makefile.in b/src/Makefile.in index 31a5a7e7709..001f0c40722 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -820,7 +820,8 @@ endif ifeq ($(DUMPING),pdumper) $(bootstrap_pdmp): bootstrap-emacs$(EXEEXT) rm -f $@ - $(RUN_TEMACS) --batch $(BUILD_DETAILS) -l loadup --temacs=pbootstrap + $(RUN_TEMACS) --batch $(BUILD_DETAILS) -l loadup --temacs=pbootstrap \ + --bin-dest $(BIN_DESTDIR) --eln-dest $(ELN_DESTDIR) @: Compile some files earlier to speed up further compilation. $(MAKE) -C ../lisp compile-first EMACS="$(bootstrap_exe)" endif -- cgit v1.2.3 From 9cbdf20316e1cec835a7dfe28877142e437976f4 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Sat, 6 Mar 2021 11:37:11 -0800 Subject: * src/Makefile.in (base_obj): Remove GMP_OBJ, undefined since 202007. --- src/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Makefile.in') diff --git a/src/Makefile.in b/src/Makefile.in index 4100edf4712..a5ea5498a49 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -426,7 +426,7 @@ base_obj = dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \ thread.o systhread.o \ $(if $(HYBRID_MALLOC),sheap.o) \ $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) \ - $(W32_OBJ) $(WINDOW_SYSTEM_OBJ) $(XGSELOBJ) $(JSON_OBJ) $(GMP_OBJ) + $(W32_OBJ) $(WINDOW_SYSTEM_OBJ) $(XGSELOBJ) $(JSON_OBJ) obj = $(base_obj) $(NS_OBJC_OBJ) ## Object files used on some machine or other. -- cgit v1.2.3 From d632622b5aac5ff776e1b5048f29aeaf3ceaf553 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Sat, 6 Mar 2021 16:28:46 -0800 Subject: Simplify silent-rules build machinery * src/verbose.mk.in: New file. * configure.ac (AM_V, AM_DEFAULT_V): Remove output variables. (src/verbose.mk): New output file. * Makefile.in, admin/charsets/Makefile.in: * admin/grammars/Makefile.in, admin/unidata/Makefile.in: * doc/emacs/Makefile.in, doc/lispintro/Makefile.in: * doc/lispref/Makefile.in, doc/misc/Makefile.in, leim/Makefile.in: * lib-src/Makefile.in, lib/Makefile.in, lisp/Makefile.in: * lwlib/Makefile.in, nt/Makefile.in, oldXMenu/Makefile.in: * src/Makefile.in, src/verbose.mk.in, test/Makefile.in: Include src/verbose.mk rather than repeatedly defining AM_V_at etc. --- .gitignore | 1 + Makefile.in | 14 ++------------ admin/charsets/Makefile.in | 12 ++---------- admin/grammars/Makefile.in | 13 +------------ admin/unidata/Makefile.in | 18 +----------------- configure.ac | 8 +------- doc/emacs/Makefile.in | 10 +++------- doc/lispintro/Makefile.in | 9 ++------- doc/lispref/Makefile.in | 9 ++------- doc/misc/Makefile.in | 10 +++------- leim/Makefile.in | 14 ++------------ lib-src/Makefile.in | 29 ++--------------------------- lib/Makefile.in | 21 +-------------------- lisp/Makefile.in | 20 ++------------------ lwlib/Makefile.in | 19 ++----------------- nt/Makefile.in | 19 ++----------------- oldXMenu/Makefile.in | 19 ++----------------- src/Makefile.in | 36 +++--------------------------------- src/verbose.mk.in | 42 ++++++++++++++++++++++++++++++++++++++++++ test/Makefile.in | 26 ++------------------------ 20 files changed, 78 insertions(+), 271 deletions(-) create mode 100644 src/verbose.mk.in (limited to 'src/Makefile.in') diff --git a/.gitignore b/.gitignore index ba8a65547f3..b653ef215b9 100644 --- a/.gitignore +++ b/.gitignore @@ -76,6 +76,7 @@ lib/unistd.h src/buildobj.h src/globals.h src/lisp.mk +src/verbose.mk # Lisp-level sources built by 'make'. *cus-load.el diff --git a/Makefile.in b/Makefile.in index 46373190a6f..6acf9791ab9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -95,18 +95,8 @@ configuration=@configuration@ ### The nt/ subdirectory gets built only for MinGW NTDIR=@NTDIR@ -# 'make' verbosity. -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ - -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = - -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = +top_builddir = @top_builddir@ +-include ${top_builddir}/src/verbose.mk # ==================== Where To Install Things ==================== diff --git a/admin/charsets/Makefile.in b/admin/charsets/Makefile.in index 0fd130d346e..1fe029984b8 100644 --- a/admin/charsets/Makefile.in +++ b/admin/charsets/Makefile.in @@ -31,6 +31,7 @@ AWK = @AWK@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ charsetdir = ${top_srcdir}/etc/charsets lispintdir = ${top_srcdir}/lisp/international @@ -38,16 +39,7 @@ mapfiledir = ${srcdir}/mapfiles GLIBC_CHARMAPS = ${srcdir}/glibc -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = - -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = +-include ${top_builddir}/src/verbose.mk # Note: We can not prepend "ISO-" to these map files because of file # name limits on DOS. diff --git a/admin/grammars/Makefile.in b/admin/grammars/Makefile.in index 98c9c623abc..aa09d9edf94 100644 --- a/admin/grammars/Makefile.in +++ b/admin/grammars/Makefile.in @@ -28,18 +28,7 @@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ -# 'make' verbosity. -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ - -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = - -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = +-include ${top_builddir}/src/verbose.mk # Prevent any settings in the user environment causing problems. unexport EMACSDATA EMACSDOC EMACSPATH diff --git a/admin/unidata/Makefile.in b/admin/unidata/Makefile.in index f31e1bb09fd..183569fb9b6 100644 --- a/admin/unidata/Makefile.in +++ b/admin/unidata/Makefile.in @@ -36,23 +36,7 @@ emacs = "${EMACS}" -batch --no-site-file --no-site-lisp lparen = ( unifiles = $(addprefix ${unidir}/,$(sort $(shell sed -n 's/^[ \t][ \t]*${lparen}"\(uni-[^"]*\)"$$/\1/p' ${srcdir}/unidata-gen.el))) -# 'make' verbosity. -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ - -AM_V_ELC = $(am__v_ELC_@AM_V@) -am__v_ELC_ = $(am__v_ELC_@AM_DEFAULT_V@) -am__v_ELC_0 = @echo " ELC " $@; -am__v_ELC_1 = - -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = - -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = +-include ${top_builddir}/src/verbose.mk .PHONY: all diff --git a/configure.ac b/configure.ac index 385a126dd39..1802c1baa12 100644 --- a/configure.ac +++ b/configure.ac @@ -1184,9 +1184,6 @@ AC_DEFUN([AM_CONDITIONAL], dnl Prefer silent make output. For verbose output, use dnl 'configure --disable-silent-rules' or 'make V=1' . -dnl This code is adapted from Automake. -dnl Although it can be simplified now that GNU Make is assumed, -dnl the simplification hasn't been done yet. AC_ARG_ENABLE([silent-rules], [AS_HELP_STRING( [--disable-silent-rules], @@ -1196,11 +1193,8 @@ if test "$enable_silent_rules" = no; then else AM_DEFAULT_VERBOSITY=0 fi -AM_V='$(V)' -AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' -AC_SUBST([AM_V]) -AC_SUBST([AM_DEFAULT_V]) AC_SUBST([AM_DEFAULT_VERBOSITY]) +AC_CONFIG_FILES([src/verbose.mk]) dnl Some other nice autoconf tests. AC_PROG_INSTALL diff --git a/doc/emacs/Makefile.in b/doc/emacs/Makefile.in index 2a3f53f740d..4585b2e0ddc 100644 --- a/doc/emacs/Makefile.in +++ b/doc/emacs/Makefile.in @@ -28,6 +28,8 @@ srcdir=@srcdir@ top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ + version = @version@ ## Where the output files go. @@ -73,13 +75,7 @@ TEXI2DVI = texi2dvi TEXI2PDF = texi2pdf DVIPS = dvips -# 'make' verbosity. -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ - -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = +-include ${top_builddir}/src/verbose.mk ENVADD = $(AM_V_GEN)TEXINPUTS="$(srcdir):$(texinfodir):$(TEXINPUTS)" \ MAKEINFO="$(MAKEINFO) $(MAKEINFO_OPTS)" diff --git a/doc/lispintro/Makefile.in b/doc/lispintro/Makefile.in index d8b909c9c10..45b4fe7e3b7 100644 --- a/doc/lispintro/Makefile.in +++ b/doc/lispintro/Makefile.in @@ -20,6 +20,7 @@ SHELL = @SHELL@ srcdir = @srcdir@ +top_builddir = @top_builddir@ buildinfodir = $(srcdir)/../../info # Directory with the (customized) texinfo.tex file. @@ -55,13 +56,7 @@ TEXI2DVI = texi2dvi TEXI2PDF = texi2pdf DVIPS = dvips -# 'make' verbosity. -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ - -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = +-include ${top_builddir}/src/verbose.mk ENVADD = \ $(AM_V_GEN)TEXINPUTS="$(srcdir):$(texinfodir):$(emacsdir):$(TEXINPUTS)" \ diff --git a/doc/lispref/Makefile.in b/doc/lispref/Makefile.in index 271f06edddc..876303593ce 100644 --- a/doc/lispref/Makefile.in +++ b/doc/lispref/Makefile.in @@ -24,6 +24,7 @@ SHELL = @SHELL@ # Standard configure variables. srcdir = @srcdir@ +top_builddir = @top_builddir@ buildinfodir = $(srcdir)/../../info # Directory with the (customized) texinfo.tex file. @@ -59,13 +60,7 @@ TEXI2DVI = texi2dvi TEXI2PDF = texi2pdf DVIPS = dvips -# 'make' verbosity. -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ - -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = +-include ${top_builddir}/src/verbose.mk ENVADD = \ $(AM_V_GEN)TEXINPUTS="$(srcdir):$(texinfodir):$(emacsdir):$(TEXINPUTS)" \ diff --git a/doc/misc/Makefile.in b/doc/misc/Makefile.in index 87d87bf2005..5130650fefe 100644 --- a/doc/misc/Makefile.in +++ b/doc/misc/Makefile.in @@ -23,6 +23,8 @@ SHELL = @SHELL@ # of the source tree. This is set by configure's '--srcdir' option. srcdir=@srcdir@ +top_builddir = @top_builddir@ + ## Where the output files go. ## Note that all the Info targets build the Info files in srcdir. ## There is no provision for Info files to exist in the build directory. @@ -112,13 +114,7 @@ TEXI2DVI = texi2dvi TEXI2PDF = texi2pdf DVIPS = dvips -# 'make' verbosity. -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ - -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = +-include ${top_builddir}/src/verbose.mk ENVADD = $(AM_V_GEN)TEXINPUTS="$(srcdir):$(emacsdir):$(TEXINPUTS)" \ MAKEINFO="$(MAKEINFO) $(MAKEINFO_OPTS)" diff --git a/leim/Makefile.in b/leim/Makefile.in index f3e530a11de..c2f9cf5ab5f 100644 --- a/leim/Makefile.in +++ b/leim/Makefile.in @@ -25,24 +25,14 @@ SHELL = @SHELL@ # Here are the things that we expect ../configure to edit. srcdir=@srcdir@ +top_builddir = @top_builddir@ # Where the generated files go. leimdir = ${srcdir}/../lisp/leim EXEEXT = @EXEEXT@ -# 'make' verbosity. -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ - -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = - -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = +-include ${top_builddir}/src/verbose.mk # Prevent any settings in the user environment causing problems. unexport EMACSDATA EMACSDOC EMACSPATH diff --git a/lib-src/Makefile.in b/lib-src/Makefile.in index 0a6dd826c10..05eb524d19b 100644 --- a/lib-src/Makefile.in +++ b/lib-src/Makefile.in @@ -44,33 +44,8 @@ WERROR_CFLAGS = @WERROR_CFLAGS@ # Program name transformation. TRANSFORM = @program_transform_name@ -# 'make' verbosity. -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ - -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = - -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = - -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = - -AM_V_RC = $(am__v_RC_@AM_V@) -am__v_RC_ = $(am__v_RC_@AM_DEFAULT_V@) -am__v_RC_0 = @echo " RC " $@; -am__v_RC_1 = - -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = +top_builddir = @top_builddir@ +-include ${top_builddir}/src/verbose.mk # ==================== Where To Install Things ==================== diff --git a/lib/Makefile.in b/lib/Makefile.in index 91a6b5ff3f1..043ace29fd7 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -29,26 +29,7 @@ top_srcdir = @top_srcdir@ all: .PHONY: all -# 'make' verbosity. -AM_V_AR = $(am__v_AR_@AM_V@) -am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@) -am__v_AR_0 = @echo " AR " $@; -am__v_AR_1 = - -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = - -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = - -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = +-include ${top_builddir}/src/verbose.mk ALL_CFLAGS= \ $(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) $(DEPFLAGS) \ diff --git a/lisp/Makefile.in b/lisp/Makefile.in index 72f7f1676b7..8ea28415585 100644 --- a/lisp/Makefile.in +++ b/lisp/Makefile.in @@ -21,6 +21,7 @@ SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ lisp = $(srcdir) VPATH = $(srcdir) EXEEXT = @EXEEXT@ @@ -29,24 +30,7 @@ EXEEXT = @EXEEXT@ # limitation. XARGS_LIMIT = @XARGS_LIMIT@ -# 'make' verbosity. -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ - -AM_V_ELC = $(am__v_ELC_@AM_V@) -am__v_ELC_ = $(am__v_ELC_@AM_DEFAULT_V@) -am__v_ELC_0 = @echo " ELC " $@; -am__v_ELC_1 = - -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = - -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = - +-include ${top_builddir}/src/verbose.mk FIND_DELETE = @FIND_DELETE@ diff --git a/lwlib/Makefile.in b/lwlib/Makefile.in index 28c16acbabc..fb0ae0e1c21 100644 --- a/lwlib/Makefile.in +++ b/lwlib/Makefile.in @@ -26,6 +26,7 @@ all: liblw.a .PHONY: all srcdir=@srcdir@ +top_builddir=@top_builddir@ # MinGW CPPFLAGS may use this. abs_top_srcdir=@abs_top_srcdir@ VPATH=@srcdir@ @@ -56,23 +57,7 @@ TOOLKIT_OBJS = $(@X_TOOLKIT_TYPE@_OBJS) OBJS = lwlib.o $(TOOLKIT_OBJS) lwlib-utils.o -# 'make' verbosity. -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ - -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = - -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = - -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = +-include ${top_builddir}/src/verbose.mk AUTO_DEPEND = @AUTO_DEPEND@ DEPDIR = deps diff --git a/nt/Makefile.in b/nt/Makefile.in index aa3a76280ef..0d448903ba5 100644 --- a/nt/Makefile.in +++ b/nt/Makefile.in @@ -41,23 +41,8 @@ WERROR_CFLAGS = @WERROR_CFLAGS@ # Program name transformation. TRANSFORM = @program_transform_name@ -# 'make' verbosity. -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ - -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = - -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = - -AM_V_RC = $(am__v_RC_@AM_V@) -am__v_RC_ = $(am__v_RC_@AM_DEFAULT_V@) -am__v_RC_0 = @echo " RC " $@; -am__v_RC_1 = +top_builddir = @top_builddir@ +-include ${top_builddir}/src/verbose.mk # ==================== Where To Install Things ==================== diff --git a/oldXMenu/Makefile.in b/oldXMenu/Makefile.in index 7ae355b568d..39fd155735a 100644 --- a/oldXMenu/Makefile.in +++ b/oldXMenu/Makefile.in @@ -43,6 +43,7 @@ ### Code: srcdir=@srcdir@ +top_builddir = @top_builddir@ # MinGW CPPFLAGS may use this. abs_top_srcdir=@abs_top_srcdir@ VPATH=@srcdir@ @@ -93,23 +94,7 @@ OBJS = Activate.o \ all: libXMenu11.a .PHONY: all -# 'make' verbosity. -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ - -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = - -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = - -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = +-include ${top_builddir}/src/verbose.mk AUTO_DEPEND = @AUTO_DEPEND@ DEPDIR = deps diff --git a/src/Makefile.in b/src/Makefile.in index a5ea5498a49..f3c545dba9a 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -29,6 +29,7 @@ SHELL = @SHELL@ # We use $(srcdir) explicitly in dependencies so as not to depend on VPATH. srcdir = @srcdir@ top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ # MinGW CPPFLAGS may use this. abs_top_srcdir=@abs_top_srcdir@ VPATH = $(srcdir) @@ -340,33 +341,7 @@ HAVE_PDUMPER = @HAVE_PDUMPER@ ## invalidates the signature, we must re-sign to fix it. DO_CODESIGN=$(patsubst aarch64-apple-darwin%,yes,@configuration@) -# 'make' verbosity. -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ - -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = - -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = - -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = - -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = - -AM_V_NO_PD = $(am__v_NO_PD_@AM_V@) -am__v_NO_PD_ = $(am__v_NO_PD_@AM_DEFAULT_V@) -am__v_NO_PD_0 = --no-print-directory -am__v_NO_PD_1 = +-include ${top_builddir}/src/verbose.mk bootstrap_exe = ../src/bootstrap-emacs$(EXEEXT) ifeq ($(DUMPING),pdumper) @@ -621,11 +596,6 @@ buildobj.h: Makefile GLOBAL_SOURCES = $(base_obj:.o=.c) $(NS_OBJC_OBJ:.o=.m) -AM_V_GLOBALS = $(am__v_GLOBALS_@AM_V@) -am__v_GLOBALS_ = $(am__v_GLOBALS_@AM_DEFAULT_V@) -am__v_GLOBALS_0 = @echo " GEN " globals.h; -am__v_GLOBALS_1 = - gl-stamp: $(libsrc)/make-docfile$(EXEEXT) $(GLOBAL_SOURCES) $(AM_V_GLOBALS)$(libsrc)/make-docfile -d $(srcdir) -g $(obj) > globals.tmp $(AM_V_at)$(top_srcdir)/build-aux/move-if-change globals.tmp globals.h @@ -724,7 +694,7 @@ bootstrap-clean: clean fi distclean: bootstrap-clean - rm -f Makefile lisp.mk + rm -f Makefile lisp.mk verbose.mk rm -fr $(DEPDIR) maintainer-clean: distclean diff --git a/src/verbose.mk.in b/src/verbose.mk.in new file mode 100644 index 00000000000..e55fd63fc3c --- /dev/null +++ b/src/verbose.mk.in @@ -0,0 +1,42 @@ +### verbose.mk --- Makefile fragment for GNU Emacs + +## Copyright (C) 2021 Free Software Foundation, Inc. + +## This file is part of GNU Emacs. + +## GNU Emacs 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. +## +## GNU Emacs 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 GNU Emacs. If not, see . + +# 'make' verbosity. +V = @AM_DEFAULT_VERBOSITY@ +ifeq (${V},1) +AM_V_AR = +AM_V_at = +AM_V_CC = +AM_V_CCLD = +AM_V_ELC = +AM_V_GEN = +AM_V_GLOBALS = +AM_V_NO_PD = +AM_V_RC = +else +AM_V_AR = @echo " AR " $@; +AM_V_at = @ +AM_V_CC = @echo " CC " $@; +AM_V_CCLD = @echo " CCLD " $@; +AM_V_ELC = @echo " ELC " $@; +AM_V_GEN = @echo " GEN " $@; +AM_V_GLOBALS = @echo " GEN " globals.h; +AM_V_NO_PD = --no-print-directory +AM_V_RC = @echo " RC " $@; +endif diff --git a/test/Makefile.in b/test/Makefile.in index 48bbe8712b4..ba354289e28 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -32,6 +32,7 @@ SHELL = @SHELL@ srcdir = @srcdir@ abs_top_srcdir=@abs_top_srcdir@ +top_builddir = @top_builddir@ VPATH = $(srcdir) FIND_DELETE = @FIND_DELETE@ @@ -46,30 +47,7 @@ SO = @MODULES_SUFFIX@ SEPCHAR = @SEPCHAR@ - -# 'make' verbosity. -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ - -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = - -AM_V_ELC = $(am__v_ELC_@AM_V@) -am__v_ELC_ = $(am__v_ELC_@AM_DEFAULT_V@) -am__v_ELC_0 = @echo " ELC " $@; -am__v_ELC_1 = - -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = - -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = - +-include ${top_builddir}/src/verbose.mk # Load any GNU ELPA dependencies that are present, for optional tests. GNU_ELPA_DIRECTORY ?= $(srcdir)/../../elpa -- cgit v1.2.3 From 6f8ec1449197f1fcd730df91dddf6f7750284593 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Sun, 4 Apr 2021 17:10:08 +0200 Subject: Output native compiled preloaded files into the 'preloaded' subfolder * src/comp.c (fixup_eln_load_path): Account the fact that the file can be dumped in the 'preloaded' subfolder. * lisp/loadup.el: Likewise. * src/lread.c (maybe_swap_for_eln1): New function. (maybe_swap_for_eln): Handle 'preloaded' subfolder. * src/Makefile.in (LISP_PRELOADED): Export preloaded files. --- lisp/loadup.el | 30 +++++++++++++++--------- src/Makefile.in | 1 + src/comp.c | 29 +++++++++++++++++------ src/lread.c | 73 +++++++++++++++++++++++++++++++++++++-------------------- 4 files changed, 89 insertions(+), 44 deletions(-) (limited to 'src/Makefile.in') diff --git a/lisp/loadup.el b/lisp/loadup.el index 57058ac4aa1..c3948e465f2 100644 --- a/lisp/loadup.el +++ b/lisp/loadup.el @@ -465,17 +465,25 @@ lost after dumping"))) (when (subr-native-elisp-p f) (puthash (subr-native-comp-unit f) nil h))))) (maphash (lambda (cu _) - (native-comp-unit-set-file - cu - (cons - ;; Relative filename from the installed binary. - (file-relative-name (concat eln-dest-dir - (file-name-nondirectory - (native-comp-unit-file cu))) - bin-dest-dir) - ;; Relative filename from the built uninstalled binary. - (file-relative-name (native-comp-unit-file cu) - invocation-directory)))) + (let* ((file (native-comp-unit-file cu)) + (preloaded (equal (substring (file-name-directory file) + -10 -1) + "preloaded")) + (eln-dest-dir-eff (if preloaded + (expand-file-name "preloaded" + eln-dest-dir) + eln-dest-dir))) + (native-comp-unit-set-file + cu + (cons + ;; Relative filename from the installed binary. + (file-relative-name (expand-file-name + (file-name-nondirectory + file) + eln-dest-dir-eff) + bin-dest-dir) + ;; Relative filename from the built uninstalled binary. + (file-relative-name file invocation-directory))))) h)))) (when (hash-table-p purify-flag) diff --git a/src/Makefile.in b/src/Makefile.in index c6b1f556440..b8bad73b006 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -500,6 +500,7 @@ shortlisp := $(filter-out ${shortlisp_filter},${shortlisp}) ## the critical path (relevant in parallel compilations). ## We don't really need to sort, but may as well use it to remove duplicates. shortlisp := loaddefs.el loadup.el $(sort ${shortlisp}) +export LISP_PRELOADED = ${shortlisp} lisp = $(addprefix ${lispsource}/,${shortlisp}) ## Construct full set of libraries to be linked. diff --git a/src/comp.c b/src/comp.c index 67c8e39315b..9bad9b9667f 100644 --- a/src/comp.c +++ b/src/comp.c @@ -4091,6 +4091,7 @@ for new compilations. If BASE-DIR is nil use the first entry in `comp-eln-load-path'. */) (Lisp_Object filename, Lisp_Object base_dir) { + Lisp_Object source_filename = filename; filename = Fcomp_el_to_eln_rel_filename (filename); /* If base_dir was not specified search inside Vcomp_eln_load_path @@ -4129,9 +4130,18 @@ If BASE-DIR is nil use the first entry in `comp-eln-load-path'. */) if (!file_name_absolute_p (SSDATA (base_dir))) base_dir = Fexpand_file_name (base_dir, Vinvocation_directory); - return Fexpand_file_name (filename, - Fexpand_file_name (Vcomp_native_version_dir, - base_dir)); + /* In case the file being compiled is found in 'LISP_PRELOADED' + target for output the 'preloaded' subfolder. */ + Lisp_Object lisp_preloaded = + Fgetenv_internal (build_string ("LISP_PRELOADED"), Qnil); + base_dir = Fexpand_file_name (Vcomp_native_version_dir, base_dir); + if (!NILP (lisp_preloaded) + && !NILP (Fmember (CALL1I (file-name-base, source_filename), + Fmapcar (intern_c_string ("file-name-base"), + CALL1I (split-string, lisp_preloaded))))) + base_dir = Fexpand_file_name (build_string ("preloaded"), base_dir); + + return Fexpand_file_name (filename, base_dir); } DEFUN ("comp--install-trampoline", Fcomp__install_trampoline, @@ -4750,10 +4760,15 @@ fixup_eln_load_path (Lisp_Object directory) Lisp_Object eln_cache_sys = Ffile_name_directory (concat2 (Vinvocation_directory, directory)); - /* One directory up... */ - eln_cache_sys = - Ffile_name_directory (Fsubstring (eln_cache_sys, Qnil, - make_fixnum (-1))); + bool preloaded = + !NILP (Fequal (Fsubstring (eln_cache_sys, make_fixnum (-10), + make_fixnum (-1)), + build_string ("preloaded"))); + /* One or two directories up... */ + for (int i = 0; i < (preloaded ? 2 : 1); i++) + eln_cache_sys = + Ffile_name_directory (Fsubstring (eln_cache_sys, Qnil, + make_fixnum (-1))); Fsetcar (last_cell, eln_cache_sys); } diff --git a/src/lread.c b/src/lread.c index 156df73de82..e53e1f65ab9 100644 --- a/src/lread.c +++ b/src/lread.c @@ -1645,6 +1645,40 @@ directories, make sure the PREDICATE function returns `dir-ok' for them. */) return file; } +#ifdef HAVE_NATIVE_COMP +static bool +maybe_swap_for_eln1 (Lisp_Object src_name, Lisp_Object eln_name, + Lisp_Object *filename, int *fd, struct timespec mtime) +{ + struct stat eln_st; + int eln_fd = emacs_open (SSDATA (ENCODE_FILE (eln_name)), O_RDONLY, 0); + + if (eln_fd > 0) + { + if (fstat (eln_fd, &eln_st) || S_ISDIR (eln_st.st_mode)) + emacs_close (eln_fd); + else + { + struct timespec eln_mtime = get_stat_mtime (&eln_st); + if (timespec_cmp (eln_mtime, mtime) >= 0) + { + emacs_close (*fd); + *fd = eln_fd; + *filename = eln_name; + /* Store the eln -> el relation. */ + Fputhash (Ffile_name_nondirectory (eln_name), + src_name, Vcomp_eln_to_el_h); + return true; + } + else + emacs_close (eln_fd); + } + } + + return false; +} +#endif + /* Look for a suitable .eln file to be loaded in place of FILENAME. If found replace the content of FILENAME and FD. */ @@ -1653,7 +1687,6 @@ maybe_swap_for_eln (bool no_native, Lisp_Object *filename, int *fd, struct timespec mtime) { #ifdef HAVE_NATIVE_COMP - struct stat eln_st; if (no_native || load_no_native) @@ -1687,36 +1720,24 @@ maybe_swap_for_eln (bool no_native, Lisp_Object *filename, int *fd, } Lisp_Object eln_rel_name = Fcomp_el_to_eln_rel_filename (src_name); + Lisp_Object dir = Qnil; FOR_EACH_TAIL_SAFE (eln_path_tail) { + dir = XCAR (eln_path_tail); Lisp_Object eln_name = Fexpand_file_name (eln_rel_name, - Fexpand_file_name (Vcomp_native_version_dir, - XCAR (eln_path_tail))); - int eln_fd = emacs_open (SSDATA (ENCODE_FILE (eln_name)), O_RDONLY, 0); - - if (eln_fd > 0) - { - if (fstat (eln_fd, &eln_st) || S_ISDIR (eln_st.st_mode)) - emacs_close (eln_fd); - else - { - struct timespec eln_mtime = get_stat_mtime (&eln_st); - if (timespec_cmp (eln_mtime, mtime) >= 0) - { - *filename = eln_name; - emacs_close (*fd); - *fd = eln_fd; - /* Store the eln -> el relation. */ - Fputhash (Ffile_name_nondirectory (eln_name), - src_name, Vcomp_eln_to_el_h); - return; - } - else - emacs_close (eln_fd); - } - } + Fexpand_file_name (Vcomp_native_version_dir, dir)); + if (maybe_swap_for_eln1 (src_name, eln_name, filename, fd, mtime)) + return; } + + /* Look also in preloaded subfolder of the last entry in + `comp-eln-load-path'. */ + dir = Fexpand_file_name (build_string ("preloaded"), + Fexpand_file_name (Vcomp_native_version_dir, + dir)); + maybe_swap_for_eln1 (src_name, Fexpand_file_name (eln_rel_name, dir), + filename, fd, mtime); #endif } -- cgit v1.2.3 From 305e4807a42075dca2447c82499cbc2584700fe2 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Sun, 9 May 2021 18:14:12 -0700 Subject: Base the "extraclean" Make rule on "maintainer-clean" * Makefile.in (FIND_DELETE): New, set by configure. (extraclean_dirs): Remove. (extraclean): Make it just a small variation on maintainer-clean. * admin/charsets/Makefile.in (extraclean): * admin/grammars/Makefile.in (extraclean): * admin/unidata/Makefile.in (extraclean): * leim/Makefile.in (extraclean): * lib-src/Makefile.in (extraclean): * lisp/Makefile.in (extraclean): * lwlib/Makefile.in (extraclean): * nt/Makefile.in (extraclean): * src/Makefile.in (extraclean): Remove target. * lib/Makefile.in (extraclean): Merge into maintainer-clean. --- Makefile.in | 19 ++++++++----------- admin/charsets/Makefile.in | 3 +-- admin/grammars/Makefile.in | 3 +-- admin/unidata/Makefile.in | 3 +-- leim/Makefile.in | 4 +--- lib-src/Makefile.in | 4 +--- lib/Makefile.in | 1 - lisp/Makefile.in | 8 +------- lisp/vc/vc.el | 3 +++ lwlib/Makefile.in | 4 ++-- nt/Makefile.in | 5 +---- src/Makefile.in | 5 +---- 12 files changed, 21 insertions(+), 41 deletions(-) (limited to 'src/Makefile.in') diff --git a/Makefile.in b/Makefile.in index 8d52cb58575..6a5513124f6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -96,6 +96,8 @@ NTDIR=@NTDIR@ top_builddir = @top_builddir@ -include ${top_builddir}/src/verbose.mk +FIND_DELETE = @FIND_DELETE@ + HAVE_NATIVE_COMP = @HAVE_NATIVE_COMP@ # ==================== Where To Install Things ==================== @@ -932,19 +934,14 @@ maintainer-clean: bootstrap-clean $(maintainer_clean_dirs:=_maintainer-clean) ### says GCC supports it, and that's where the configuration part of ### the coding standards seem to come from. It's like distclean, but ### it deletes backup and autosave files too. -### Note that we abuse this in some subdirectories (eg leim), -### to delete some generated files that are slow to rebuild. -extraclean_dirs = ${NTDIR} lib-src src leim \ - admin/charsets admin/grammars admin/unidata lisp lib lwlib - -$(foreach dir,$(extraclean_dirs),$(eval $(call submake_template,$(dir),extraclean))) - -extraclean: $(extraclean_dirs:=_extraclean) - ${top_maintainer_clean} - -rm -f config-tmp-* aclocal.m4 configure - -rm -f ./*~ \#* etc/refcards/emacsver.tex doc/emacs/emacsver.texi +extraclean: maintainer-clean + -rm -f config-tmp-* aclocal.m4 configure src/config.in + -rm -f etc/refcards/emacsver.tex doc/emacs/emacsver.texi -rm -f info/*.info info/dir -rmdir info 2>/dev/null + -[ "${srcdir}" = "." ] || \ + find ${srcdir} '(' -name '*~' -o -name '#*' ')' ${FIND_DELETE} + -find . '(' -name '*~' -o -name '#*' ')' ${FIND_DELETE} # The src subdir knows how to do the right thing # even when the build directory and source dir are different. diff --git a/admin/charsets/Makefile.in b/admin/charsets/Makefile.in index 00424843bc4..f043077e318 100644 --- a/admin/charsets/Makefile.in +++ b/admin/charsets/Makefile.in @@ -297,7 +297,7 @@ ${charsetdir}/%.map: ${GLIBC_CHARMAPS}/%.gz ${mapconv} ${compact} ${AM_V_GEN}${run_mapconv} $< '/^<.*[ ]\/x/' GLIBC-1 ${compact} > $@ -.PHONY: clean bootstrap-clean distclean maintainer-clean extraclean gen-clean +.PHONY: clean bootstrap-clean distclean maintainer-clean gen-clean clean: @@ -312,4 +312,3 @@ gen-clean: maintainer-clean: gen-clean distclean -extraclean: maintainer-clean diff --git a/admin/grammars/Makefile.in b/admin/grammars/Makefile.in index 4172411e034..aaf95c08973 100644 --- a/admin/grammars/Makefile.in +++ b/admin/grammars/Makefile.in @@ -95,7 +95,7 @@ ${cedetdir}/srecode/srt-wy.el: ${srcdir}/srecode-template.wy ${grammar_wisent} $(AM_V_GEN)[ ! -f "$@" ] || chmod +w "$@" $(AM_V_at)${make_wisent} -o "$@" $< -.PHONY: distclean bootstrap-clean maintainer-clean extraclean gen-clean +.PHONY: distclean bootstrap-clean maintainer-clean gen-clean distclean: rm -f Makefile @@ -108,7 +108,6 @@ gen-clean: maintainer-clean: gen-clean distclean -extraclean: maintainer-clean # Makefile.in ends here diff --git a/admin/unidata/Makefile.in b/admin/unidata/Makefile.in index b7a927d1919..357b8126783 100644 --- a/admin/unidata/Makefile.in +++ b/admin/unidata/Makefile.in @@ -85,7 +85,7 @@ ${unidir}/charscript.el: ${srcdir}/Blocks.txt ${blocks} $(AM_V_GEN)$(AWK) -f ${blocks} < $< > $@ -.PHONY: clean bootstrap-clean distclean maintainer-clean extraclean gen-clean +.PHONY: clean bootstrap-clean distclean maintainer-clean gen-clean clean: rm -f ${srcdir}/*.elc unidata.txt @@ -107,4 +107,3 @@ gen-clean: maintainer-clean: gen-clean distclean -extraclean: maintainer-clean diff --git a/leim/Makefile.in b/leim/Makefile.in index 2646abcfff9..ce1029abcfa 100644 --- a/leim/Makefile.in +++ b/leim/Makefile.in @@ -137,7 +137,7 @@ ${srcdir}/../lisp/language/pinyin.el: ${srcdir}/MISC-DIC/pinyin.map $(AM_V_GEN)${RUN_EMACS} -l titdic-cnv -f pinyin-convert $< $@ -.PHONY: bootstrap-clean distclean maintainer-clean extraclean gen-clean +.PHONY: bootstrap-clean distclean maintainer-clean gen-clean ## Perhaps this should run gen-clean. bootstrap-clean: @@ -154,6 +154,4 @@ gen-clean: rm -f ${TIT_MISC} ${leimdir}/leim-list.el rm -rf ${leimdir}/ja-dic -extraclean: maintainer-clean - ### Makefile.in ends here diff --git a/lib-src/Makefile.in b/lib-src/Makefile.in index 923d0cf5e72..1beafafe0c1 100644 --- a/lib-src/Makefile.in +++ b/lib-src/Makefile.in @@ -315,7 +315,7 @@ $(DESTDIR)${archlibdir}: all fi .PHONY: install uninstall mostlyclean clean distclean maintainer-clean -.PHONY: bootstrap-clean extraclean check tags +.PHONY: bootstrap-clean check tags install: $(DESTDIR)${archlibdir} @echo @@ -350,8 +350,6 @@ distclean: clean bootstrap-clean maintainer-clean: distclean -extraclean: maintainer-clean - rm -f ./*~ \#* ## Test the contents of the directory. check: diff --git a/lib/Makefile.in b/lib/Makefile.in index 68a0247e9cb..825b3131d59 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -113,7 +113,6 @@ distclean bootstrap-clean: mostlyclean rm -fr $(DEPDIR) maintainer-clean: distclean rm -f TAGS gnulib.mk -extraclean: distclean -rmdir malloc sys 2>/dev/null .PHONY: mostlyclean clean distclean bootstrap-clean maintainer-clean diff --git a/lisp/Makefile.in b/lisp/Makefile.in index 052de266dcf..8e0d9c4e5be 100644 --- a/lisp/Makefile.in +++ b/lisp/Makefile.in @@ -467,7 +467,7 @@ $(CAL_DIR)/hol-loaddefs.el: $(CAL_SRC) $(CAL_DIR)/diary-loaddefs.el --eval "(setq generated-autoload-file (expand-file-name (unmsys--file-name \"$@\")))" \ -f batch-update-autoloads $(CAL_DIR) -.PHONY: bootstrap-clean distclean maintainer-clean extraclean +.PHONY: bootstrap-clean distclean maintainer-clean bootstrap-clean: find $(lisp) -name '*.elc' $(FIND_DELETE) @@ -479,12 +479,6 @@ distclean: maintainer-clean: distclean bootstrap-clean rm -f TAGS -extraclean: bootstrap-clean distclean - -for file in $(loaddefs); do rm -f $${file}~; done - -rm -f $(lisp)/loaddefs.el~ - -find $(lisp) -name '*~' $(FIND_DELETE) - -find $(lisp) -name '#*' $(FIND_DELETE) - .PHONY: check-declare check-declare: diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 95126fac100..9338b7191d0 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -979,6 +979,9 @@ be reported. If NO-ERROR is nil, signal an error that no VC backend is responsible for the given file." (or (and (not (file-directory-p file)) (vc-backend file)) + ;; FIXME it would be more efficient to walk up the directory tree, + ;; stopping the first time a backend is responsible. + ;; ;; First try: find a responsible backend. If this is for registration, ;; it must be a backend under which FILE is not yet registered. (let ((dirs (delq nil diff --git a/lwlib/Makefile.in b/lwlib/Makefile.in index ce77789db89..fb0ae0e1c21 100644 --- a/lwlib/Makefile.in +++ b/lwlib/Makefile.in @@ -93,9 +93,9 @@ globals_h = ../src/globals.h $(globals_h): $(MAKE) -C ../src globals.h -.PHONY: mostlyclean clean distclean bootstrap-clean maintainer-clean extraclean +.PHONY: mostlyclean clean distclean bootstrap-clean maintainer-clean -clean mostlyclean extraclean: +clean mostlyclean: rm -f ./*.o liblw.a \#* $(DEPDIR)/* distclean: clean diff --git a/nt/Makefile.in b/nt/Makefile.in index 0d448903ba5..3274ff924f9 100644 --- a/nt/Makefile.in +++ b/nt/Makefile.in @@ -170,7 +170,7 @@ $(DESTDIR)${archlibdir}: all fi .PHONY: install uninstall mostlyclean clean distclean maintainer-clean -.PHONY: bootstrap-clean extraclean check tags +.PHONY: bootstrap-clean check tags install: $(DESTDIR)${archlibdir} @echo @@ -203,9 +203,6 @@ distclean: clean bootstrap-clean maintainer-clean: distclean true -extraclean: maintainer-clean - -rm -f *~ \#* - ## Test the contents of the directory. check: @echo "We don't have any tests for the nt/ directory yet." diff --git a/src/Makefile.in b/src/Makefile.in index b8bad73b006..d9f65b5bd0e 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -671,7 +671,7 @@ ns-app: emacs$(EXEEXT) $(pdmp) $(MAKE) -C ../nextstep all .PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean -.PHONY: versionclean extraclean +.PHONY: versionclean mostlyclean: rm -f temacs$(EXEEXT) core ./*.core \#* ./*.o @@ -706,9 +706,6 @@ distclean: bootstrap-clean maintainer-clean: distclean rm -f TAGS -extraclean: distclean - rm -f ./*~ \#* TAGS config.in - ETAGS = ../lib-src/etags${EXEEXT} -- cgit v1.2.3 From a52f572e627dc8fdef17b77512cba0a3f56825e1 Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Fri, 28 May 2021 16:56:17 +0200 Subject: ; * src/Makefile.in: Fix typo. --- src/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Makefile.in') diff --git a/src/Makefile.in b/src/Makefile.in index d9f65b5bd0e..79cddb35b55 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -342,7 +342,7 @@ DUMPING=@DUMPING@ CHECK_STRUCTS = @CHECK_STRUCTS@ HAVE_PDUMPER = @HAVE_PDUMPER@ -## ARM Macs require that all code have a valid signature. Since pump +## ARM Macs require that all code have a valid signature. Since pdump ## invalidates the signature, we must re-sign to fix it. DO_CODESIGN=$(patsubst aarch64-apple-darwin%,yes,@configuration@) -- cgit v1.2.3 From 5dd2d50f3d5e65b85c87da86e2e8a6d087fe5767 Mon Sep 17 00:00:00 2001 From: Alan Third Date: Wed, 16 Jun 2021 21:28:10 +0100 Subject: Fix NS native compilation builds * Makefile.in (ns_applibexecdir): (ns_applibdir): (ns_appdir): New variables. (.PHONY): Include new rule. (epaths-force-ns-self-contained): Remove the app bundle directory from all paths. * configure.ac (NS_SELF_CONTAINED): Set the default site-lisp directory instead of hard-coding it in the ObjC code, and use the new epaths generating make rule. * src/callproc.c (init_callproc_1): (init_callproc): Remove all the NS specific code as the special cases are now handled by decode_env_path. * src/emacs.c (load_pdump): (decode_env_path): Use ns_relocate to find the correct directory after relocation. * src/lread.c (load_path_default): Remove all the NS specific code as the special cases are now handled by decode_env_path. * src/nsterm.h: Update function definitions. * src/nsterm.m (ns_etc_directory): (ns_exec_path): (ns_load_path): Remove functions that are no longer needed. (ns_relocate): New function to calculate paths within the NS app bundle. * nextstep/Makefile.in (ns_applibexecdir): New variable, and update anything relying on the libexec location. --- Makefile.in | 18 +++++++- configure.ac | 19 +++++--- nextstep/Makefile.in | 12 ++--- src/Makefile.in | 2 +- src/callproc.c | 36 ++------------- src/emacs.c | 16 ++++++- src/lread.c | 7 +-- src/nsterm.h | 4 +- src/nsterm.m | 125 +++++++++------------------------------------------ 9 files changed, 80 insertions(+), 159 deletions(-) (limited to 'src/Makefile.in') diff --git a/Makefile.in b/Makefile.in index b7502880230..420cb544a4d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -106,8 +106,11 @@ USE_STARTUP_NOTIFICATION = @USE_STARTUP_NOTIFICATION@ # Location to install Emacs.app under GNUstep / macOS. # Later values may use these. +ns_appdir=@ns_appdir@ ns_appbindir=@ns_appbindir@ +ns_applibexecdir=@ns_applibexecdir@ ns_appresdir=@ns_appresdir@ +ns_applibdir=@ns_applibdir@ # Either yes or no depending on whether this is a relocatable Emacs.app. ns_self_contained=@ns_self_contained@ @@ -330,12 +333,12 @@ BIN_DESTDIR='$(DESTDIR)${bindir}/' ELN_DESTDIR = $(DESTDIR)${libdir}/emacs/${version}/ else BIN_DESTDIR='${ns_appbindir}/' -ELN_DESTDIR = ${ns_appresdir}/ +ELN_DESTDIR = ${ns_applibdir}/emacs/${version}/ endif all: ${SUBDIR} info -.PHONY: all ${SUBDIR} blessmail epaths-force epaths-force-w32 etc-emacsver +.PHONY: all ${SUBDIR} blessmail epaths-force epaths-force-w32 epaths-force-ns-self-contained etc-emacsver # If configure were to just generate emacsver.tex from emacsver.tex.in # in the normal way, the timestamp of emacsver.tex would always be @@ -404,6 +407,17 @@ epaths-force-w32: -e "/^.*#/s|@SRC@|$${w32srcdir}|g") && \ ${srcdir}/build-aux/move-if-change epaths.h.$$$$ src/epaths.h +# A NextStep style app bundle is relocatable, so instead of +# hard-coding paths try to generate them at run-time. +# +# The paths are mostly the same, and the bundle paths are different +# between macOS and GNUstep, so just replace any references to the app +# bundle root itself with the relative path. +epaths-force-ns-self-contained: epaths-force + @(sed < ${srcdir}/src/epaths.h > epaths.h.$$$$ \ + -e 's;${ns_appdir}/;;') && \ + ${srcdir}/build-aux/move-if-change epaths.h.$$$$ src/epaths.h + lib-src src: $(NTDIR) lib src: lib-src diff --git a/configure.ac b/configure.ac index 830f33844b6..92527056b95 100644 --- a/configure.ac +++ b/configure.ac @@ -1891,10 +1891,11 @@ if test "${with_ns}" != no; then # so avoid NS_IMPL_COCOA if macuvs.h is absent. # Even a headless Emacs can build macuvs.h, so this should let you bootstrap. if test "${opsys}" = darwin && test -f "$srcdir/src/macuvs.h"; then - lispdirrel=Contents/Resources/lisp NS_IMPL_COCOA=yes ns_appdir=`pwd`/nextstep/Emacs.app ns_appbindir=${ns_appdir}/Contents/MacOS + ns_applibexecdir=${ns_appdir}/Contents/MacOS/libexec + ns_applibdir=${ns_appdir}/Contents/MacOS/lib ns_appresdir=${ns_appdir}/Contents/Resources ns_appsrc=Cocoa/Emacs.base ns_fontfile=macfont.o @@ -1952,6 +1953,8 @@ fail; if test $NS_IMPL_GNUSTEP = yes; then ns_appdir=`pwd`/nextstep/Emacs.app ns_appbindir=${ns_appdir} + ns_applibexecdir=${ns_appdir}/libexec + ns_applibdir=${ns_appdir}/lib ns_appresdir=${ns_appdir}/Resources ns_appsrc=GNUstep/Emacs.base ns_fontfile=nsfont.o @@ -2008,12 +2011,13 @@ if test "${HAVE_NS}" = yes; then window_system=nextstep # set up packaging dirs if test "${EN_NS_SELF_CONTAINED}" = yes; then + AC_DEFINE(NS_SELF_CONTAINED, 1, [Build an NS bundled app]) ns_self_contained=yes prefix=${ns_appresdir} exec_prefix=${ns_appbindir} dnl This one isn't really used, only archlibdir is. - libexecdir="\${ns_appbindir}/libexec" - archlibdir="\${ns_appbindir}/libexec" + libexecdir="\${ns_applibexecdir}" + archlibdir="\${ns_applibexecdir}" etcdocdir="\${ns_appresdir}/etc" etcdir="\${ns_appresdir}/etc" dnl FIXME maybe set datarootdir instead. @@ -2021,7 +2025,7 @@ if test "${HAVE_NS}" = yes; then infodir="\${ns_appresdir}/info" mandir="\${ns_appresdir}/man" lispdir="\${ns_appresdir}/lisp" - test "$locallisppathset" = no && locallisppath="" + test "$locallisppathset" = no && locallisppath="\${ns_appresdir}/site-lisp" INSTALL_ARCH_INDEP_EXTRA= fi @@ -5414,6 +5418,8 @@ AC_SUBST(CFLAGS) AC_SUBST(X_TOOLKIT_TYPE) AC_SUBST(ns_appdir) AC_SUBST(ns_appbindir) +AC_SUBST(ns_applibexecdir) +AC_SUBST(ns_applibdir) AC_SUBST(ns_appresdir) AC_SUBST(ns_appsrc) AC_SUBST(GNU_OBJC_CFLAGS) @@ -6014,10 +6020,13 @@ dnl the use of force in the 'epaths-force' rule in Makefile.in. AC_CONFIG_COMMANDS([src/epaths.h], [ if test "${opsys}" = "mingw32"; then ${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force-w32 +elif test "$EN_NS_SELF_CONTAINED" = "yes"; then + ${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force-ns-self-contained else ${MAKE-make} MAKEFILE_NAME=do-not-make-Makefile epaths-force fi || AC_MSG_ERROR(['src/epaths.h' could not be made.]) -], [GCC="$GCC" CPPFLAGS="$CPPFLAGS" opsys="$opsys"]) +], [GCC="$GCC" CPPFLAGS="$CPPFLAGS" opsys="$opsys" + EN_NS_SELF_CONTAINED="$EN_NS_SELF_CONTAINED"]) dnl NB we have to cheat and use the ac_... version because abs_top_srcdir dnl is not yet set, sigh. Or we could use ../$srcdir/src/.gdbinit, diff --git a/nextstep/Makefile.in b/nextstep/Makefile.in index 3168fee76c0..42b2ab2715d 100644 --- a/nextstep/Makefile.in +++ b/nextstep/Makefile.in @@ -36,6 +36,7 @@ MKDIR_P = @MKDIR_P@ ns_appdir = @ns_appdir@ ## GNUstep: ns_appdir; macOS: ns_appdir/Contents/MacOS ns_appbindir = @ns_appbindir@ +ns_applibexecdir = @ns_applibexecdir@ ## GNUstep/Emacs.base or Cocoa/Emacs.base. ns_appsrc = @ns_appsrc@ ## GNUstep: GNUstep/Emacs.base/Resources/Info-gnustep.plist @@ -44,7 +45,7 @@ ns_check_file = @ns_appdir@/@ns_check_file@ .PHONY: all -all: ${ns_appdir} ${ns_appbindir}/Emacs ${ns_appbindir}/Emacs.pdmp +all: ${ns_appdir} ${ns_appbindir}/Emacs ${ns_applibexecdir}/Emacs.pdmp ${ns_check_file} ${ns_appdir}: ${srcdir}/${ns_appsrc} ${ns_appsrc} rm -rf ${ns_appdir} @@ -63,8 +64,10 @@ ${ns_appbindir}/Emacs: ${ns_appdir} ${ns_check_file} ../src/emacs${EXEEXT} ${MKDIR_P} ${ns_appbindir} cp -f ../src/emacs${EXEEXT} $@ -${ns_appbindir}/Emacs.pdmp: ${ns_appdir} ${ns_check_file} ../src/emacs${EXEEXT}.pdmp - ${MKDIR_P} ${ns_appbindir} +# FIXME: Don't install the dump file into the app bundle when +# self-contained install is disabled. +${ns_applibexecdir}/Emacs.pdmp: ${ns_appdir} ${ns_check_file} ../src/emacs${EXEEXT}.pdmp + ${MKDIR_P} ${ns_applibexecdir} cp -f ../src/emacs${EXEEXT}.pdmp $@ .PHONY: FORCE @@ -85,9 +88,8 @@ links: ../src/emacs${EXEEXT} ln -s $(top_srcdir_abs)/info ${ns_appdir}/Contents/Resources ${MKDIR_P} ${ns_appbindir} ln -s $(abs_top_builddir)/src/emacs${EXEEXT} ${ns_appbindir}/Emacs - ln -s $(abs_top_builddir)/src/emacs${EXEEXT}.pdmp ${ns_appbindir}/Emacs.pdmp ln -s $(abs_top_builddir)/lib-src ${ns_appbindir}/bin - ln -s $(abs_top_builddir)/lib-src ${ns_appbindir}/libexec + ln -s $(abs_top_builddir)/lib-src ${ns_applibexecdir} ${MKDIR_P} ${ns_appdir}/Contents/Resources/etc for f in $(shell cd $(top_srcdir_abs)/etc; ls); do ln -s $(top_srcdir_abs)/etc/$$f ${ns_appdir}/Contents/Resources/etc; done ln -s $(abs_top_builddir)/etc/DOC ${ns_appdir}/Contents/Resources/etc diff --git a/src/Makefile.in b/src/Makefile.in index 79cddb35b55..22c7aeed5c6 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -55,7 +55,7 @@ lwlibdir = ../lwlib # Configuration files for .o files to depend on. config_h = config.h $(srcdir)/conf_post.h -## ns-app if HAVE_NS, else empty. +## ns-app if NS self contained app, else empty. OTHER_FILES = @OTHER_FILES@ ## Flags to pass for profiling builds diff --git a/src/callproc.c b/src/callproc.c index e44e243680d..aabc39313b8 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -1661,32 +1661,15 @@ make_environment_block (Lisp_Object current_dir) void init_callproc_1 (void) { -#ifdef HAVE_NS - const char *etc_dir = ns_etc_directory (); - const char *path_exec = ns_exec_path (); -#endif - - Vdata_directory = decode_env_path ("EMACSDATA", -#ifdef HAVE_NS - etc_dir ? etc_dir : -#endif - PATH_DATA, 0); + Vdata_directory = decode_env_path ("EMACSDATA", PATH_DATA, 0); Vdata_directory = Ffile_name_as_directory (Fcar (Vdata_directory)); - Vdoc_directory = decode_env_path ("EMACSDOC", -#ifdef HAVE_NS - etc_dir ? etc_dir : -#endif - PATH_DOC, 0); + Vdoc_directory = decode_env_path ("EMACSDOC", PATH_DOC, 0); Vdoc_directory = Ffile_name_as_directory (Fcar (Vdoc_directory)); /* Check the EMACSPATH environment variable, defaulting to the PATH_EXEC path from epaths.h. */ - Vexec_path = decode_env_path ("EMACSPATH", -#ifdef HAVE_NS - path_exec ? path_exec : -#endif - PATH_EXEC, 0); + Vexec_path = decode_env_path ("EMACSPATH", PATH_EXEC, 0); Vexec_directory = Ffile_name_as_directory (Fcar (Vexec_path)); /* FIXME? For ns, path_exec should go at the front? */ Vexec_path = nconc2 (decode_env_path ("PATH", "", 0), Vexec_path); @@ -1701,10 +1684,6 @@ init_callproc (void) char *sh; Lisp_Object tempdir; -#ifdef HAVE_NS - if (data_dir == 0) - data_dir = ns_etc_directory () != 0; -#endif if (!NILP (Vinstallation_directory)) { @@ -1716,15 +1695,8 @@ init_callproc (void) /* MSDOS uses wrapped binaries, so don't do this. */ if (NILP (Fmember (tem, Vexec_path))) { -#ifdef HAVE_NS - const char *path_exec = ns_exec_path (); -#endif /* Running uninstalled, so default to tem rather than PATH_EXEC. */ - Vexec_path = decode_env_path ("EMACSPATH", -#ifdef HAVE_NS - path_exec ? path_exec : -#endif - SSDATA (tem), 0); + Vexec_path = decode_env_path ("EMACSPATH", SSDATA (tem), 0); Vexec_path = nconc2 (decode_env_path ("PATH", "", 0), Vexec_path); } diff --git a/src/emacs.c b/src/emacs.c index 60a57a693ce..b7982ece646 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -835,7 +835,13 @@ load_pdump (int argc, char **argv) NULL #endif ; - const char *argv0_base = "emacs"; + const char *argv0_base = +#ifdef NS_SELF_CONTAINED + "Emacs" +#else + "emacs" +#endif + ; /* TODO: maybe more thoroughly scrub process environment in order to make this use case (loading a dump file in an unexeced emacs) @@ -912,6 +918,8 @@ load_pdump (int argc, char **argv) /* On MS-Windows, PATH_EXEC normally starts with a literal "%emacs_dir%", so it will never work without some tweaking. */ path_exec = w32_relocate (path_exec); +#elif defined (HAVE_NS) + path_exec = ns_relocate (path_exec); #endif /* Look for "emacs.pdmp" in PATH_EXEC. We hardcode "emacs" in @@ -929,6 +937,7 @@ load_pdump (int argc, char **argv) } sprintf (dump_file, "%s%c%s%s", path_exec, DIRECTORY_SEP, argv0_base, suffix); +#if !defined (NS_SELF_CONTAINED) /* Assume the Emacs binary lives in a sibling directory as set up by the default installation configuration. */ const char *go_up = "../../../../bin/"; @@ -943,6 +952,7 @@ load_pdump (int argc, char **argv) sprintf (emacs_executable, "%s%c%s%s%s", path_exec, DIRECTORY_SEP, go_up, argv0_base, strip_suffix ? strip_suffix : ""); +#endif result = pdumper_load (dump_file, emacs_executable); if (result == PDUMPER_LOAD_FILE_NOT_FOUND) @@ -2960,7 +2970,11 @@ decode_env_path (const char *evarname, const char *defalt, bool empty) path = 0; if (!path) { +#ifdef NS_SELF_CONTAINED + path = ns_relocate (defalt); +#else path = defalt; +#endif #ifdef WINDOWSNT defaulted = 1; #endif diff --git a/src/lread.c b/src/lread.c index 0b33fd0f254..4617ffd6265 100644 --- a/src/lread.c +++ b/src/lread.c @@ -4769,14 +4769,9 @@ load_path_default (void) return decode_env_path (0, PATH_DUMPLOADSEARCH, 0); Lisp_Object lpath = Qnil; - const char *normal = PATH_LOADSEARCH; const char *loadpath = NULL; -#ifdef HAVE_NS - loadpath = ns_load_path (); -#endif - - lpath = decode_env_path (0, loadpath ? loadpath : normal, 0); + lpath = decode_env_path (0, PATH_LOADSEARCH, 0); if (!NILP (Vinstallation_directory)) { diff --git a/src/nsterm.h b/src/nsterm.h index f64354b8a7b..b29e76cc63f 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -1190,9 +1190,7 @@ extern void ns_run_ascript (void); #define NSAPP_DATA2_RUNFILEDIALOG 11 extern void ns_run_file_dialog (void); -extern const char *ns_etc_directory (void); -extern const char *ns_exec_path (void); -extern const char *ns_load_path (void); +extern const char *ns_relocate (const char *epath); extern void syms_of_nsterm (void); extern void syms_of_nsfns (void); extern void syms_of_nsmenu (void); diff --git a/src/nsterm.m b/src/nsterm.m index e81a4cbc0dc..8497138039c 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -499,118 +499,35 @@ append2 (Lisp_Object list, Lisp_Object item) const char * -ns_etc_directory (void) -/* If running as a self-contained app bundle, return as a string the - filename of the etc directory, if present; else nil. */ -{ - NSBundle *bundle = [NSBundle mainBundle]; - NSString *resourceDir = [bundle resourcePath]; - NSString *resourcePath; - NSFileManager *fileManager = [NSFileManager defaultManager]; - BOOL isDir; +ns_relocate (const char *epath) +/* If we're running in a self-contained app bundle some hard-coded + paths are relative to the root of the bundle, so work out the full + path. - resourcePath = [resourceDir stringByAppendingPathComponent: @"etc"]; - if ([fileManager fileExistsAtPath: resourcePath isDirectory: &isDir]) - { - if (isDir) return [resourcePath UTF8String]; - } - return NULL; -} - - -const char * -ns_exec_path (void) -/* If running as a self-contained app bundle, return as a path string - the filenames of the libexec and bin directories, ie libexec:bin. - Otherwise, return nil. - Normally, Emacs does not add its own bin/ directory to the PATH. - However, a self-contained NS build has a different layout, with - bin/ and libexec/ subdirectories in the directory that contains - Emacs.app itself. - We put libexec first, because init_callproc_1 uses the first - element to initialize exec-directory. An alternative would be - for init_callproc to check for invocation-directory/libexec. -*/ + FIXME: I think this should be able to handle cases where multiple + directories are separated by colons. */ { +#ifdef NS_SELF_CONTAINED NSBundle *bundle = [NSBundle mainBundle]; - NSString *resourceDir = [bundle resourcePath]; - NSString *binDir = [bundle bundlePath]; - NSString *resourcePath, *resourcePaths; - NSRange range; - NSString *pathSeparator = [NSString stringWithFormat: @"%c", SEPCHAR]; + NSString *root = [bundle bundlePath]; + NSString *original = [NSString stringWithUTF8String:epath]; + NSString *fixedPath = [NSString pathWithComponents:@[root, original]]; NSFileManager *fileManager = [NSFileManager defaultManager]; - NSArray *paths; - NSEnumerator *pathEnum; - BOOL isDir; - range = [resourceDir rangeOfString: @"Contents"]; - if (range.location != NSNotFound) - { - binDir = [binDir stringByAppendingPathComponent: @"Contents"]; -#ifdef NS_IMPL_COCOA - binDir = [binDir stringByAppendingPathComponent: @"MacOS"]; -#endif - } + if (![original isAbsolutePath] + && [fileManager fileExistsAtPath:fixedPath isDirectory:NULL]) + return [fixedPath UTF8String]; - paths = [binDir stringsByAppendingPaths: - [NSArray arrayWithObjects: @"libexec", @"bin", nil]]; - pathEnum = [paths objectEnumerator]; - resourcePaths = @""; + /* If we reach here either the path is absolute and therefore we + don't need to complete it, or we're unable to relocate the + file/directory. If it's the latter it may be because the user is + trying to use a bundled app as though it's a Unix style install + and we have no way to guess what was intended, so return the + original string unaltered. */ - while ((resourcePath = [pathEnum nextObject])) - { - if ([fileManager fileExistsAtPath: resourcePath isDirectory: &isDir]) - if (isDir) - { - if ([resourcePaths length] > 0) - resourcePaths - = [resourcePaths stringByAppendingString: pathSeparator]; - resourcePaths - = [resourcePaths stringByAppendingString: resourcePath]; - } - } - if ([resourcePaths length] > 0) return [resourcePaths UTF8String]; - - return NULL; -} - - -const char * -ns_load_path (void) -/* If running as a self-contained app bundle, return as a path string - the filenames of the site-lisp and lisp directories. - Ie, site-lisp:lisp. Otherwise, return nil. */ -{ - NSBundle *bundle = [NSBundle mainBundle]; - NSString *resourceDir = [bundle resourcePath]; - NSString *resourcePath, *resourcePaths; - NSString *pathSeparator = [NSString stringWithFormat: @"%c", SEPCHAR]; - NSFileManager *fileManager = [NSFileManager defaultManager]; - BOOL isDir; - NSArray *paths = [resourceDir stringsByAppendingPaths: - [NSArray arrayWithObjects: - @"site-lisp", @"lisp", nil]]; - NSEnumerator *pathEnum = [paths objectEnumerator]; - resourcePaths = @""; - - /* Hack to skip site-lisp. */ - if (no_site_lisp) resourcePath = [pathEnum nextObject]; - - while ((resourcePath = [pathEnum nextObject])) - { - if ([fileManager fileExistsAtPath: resourcePath isDirectory: &isDir]) - if (isDir) - { - if ([resourcePaths length] > 0) - resourcePaths - = [resourcePaths stringByAppendingString: pathSeparator]; - resourcePaths - = [resourcePaths stringByAppendingString: resourcePath]; - } - } - if ([resourcePaths length] > 0) return [resourcePaths UTF8String]; +#endif - return NULL; + return epath; } -- cgit v1.2.3 From 8ce7a697ca8d654271021a9580ed1054df58100e Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sat, 7 Aug 2021 11:56:37 +0200 Subject: Allow building on MacOS with MacPorts and libgccjit * configure.ac: Check for the "port" command (MacPorts). Add the required lib/include directories for nativecomp. * src/Makefile.in (LIBGCCJIT_CFLAGS, LIBGCCJIT_LIBS): Split into two parts to allow including -L/-I for MacPorts. (LIBES): Adjust. (EMACS_CFLAGS): Ditto. --- configure.ac | 33 +++++++++++++++++++++++++++++---- src/Makefile.in | 7 ++++--- 2 files changed, 33 insertions(+), 7 deletions(-) (limited to 'src/Makefile.in') diff --git a/configure.ac b/configure.ac index 79cc56f9a73..be97d9c8a08 100644 --- a/configure.ac +++ b/configure.ac @@ -1334,6 +1334,9 @@ if test -n "$BREW"; then [`$BREW --prefix texinfo 2>/dev/null`/bin$PATH_SEPARATOR$PATH]) fi +# Check MacPorts on macOS. +AC_PATH_PROG(HAVE_MACPORTS, port) + ## Require makeinfo >= 4.13 (last of the 4.x series) to build the manuals. : ${MAKEINFO:=makeinfo} case `($MAKEINFO --version) 2>/dev/null` in @@ -3807,7 +3810,8 @@ source on this site: .])]) HAVE_NATIVE_COMP=no -LIBGCCJIT_LIB= +LIBGCCJIT_LIBS= +LIBGCCJIT_CFLAGS= if test "${with_native_compilation}" != "no"; then if test "${HAVE_PDUMPER}" = no; then AC_MSG_ERROR(['--with-nativecomp' requires '--with-dumping=pdumper']) @@ -3827,6 +3831,20 @@ if test "${with_native_compilation}" != "no"; then fi fi + # Ensure libgccjit installed by MacPorts can be found. + if test -n "$HAVE_MACPORTS"; then + # Determine which gcc version has been installed (gcc11, for + # instance). + PORT_PACKAGE=$(port installed active | grep '^ *gcc@<:@0-9@:>@* ' | \ + awk '{ print $1; }') + MACPORTS_LIBGCCJIT_INCLUDE=$(dirname $(port contents $PORT_PACKAGE | \ + grep libgccjit.h)) + MACPORTS_LIBGCCJIT_LIB=$(dirname $(port contents $PORT_PACKAGE | \ + grep libgccjit.dylib)) + CFLAGS="$CFLAGS -I${MACPORTS_LIBGCCJIT_INCLUDE}" + LDFLAGS="$LDFLAGS -L${MACPORTS_LIBGCCJIT_LIB}" + fi + # Check if libgccjit is available. AC_CHECK_LIB(gccjit, gcc_jit_context_acquire, [], [libgccjit_not_found]) AC_CHECK_HEADERS(libgccjit.h, [], [libgccjit_dev_not_found]) @@ -3841,17 +3859,24 @@ if test "${with_native_compilation}" != "no"; then mingw32) ;; # OpenBSD doesn't have libdl, all the functions are in libc netbsd|openbsd) - LIBGCCJIT_LIB="-lgccjit" ;; + LIBGCCJIT_LIBS="-lgccjit" ;; *) - LIBGCCJIT_LIB="-lgccjit -ldl" ;; + LIBGCCJIT_LIBS="-lgccjit -ldl" ;; esac NEED_DYNLIB=yes AC_DEFINE(HAVE_NATIVE_COMP, 1, [Define to 1 if native compiler is available.]) + + # Ensure libgccjit installed by MacPorts can be found. + if test -n "$HAVE_MACPORTS"; then + LIBGCCJIT_CFLAGS="$LIBGCCJIT_CFLAGS -I${MACPORTS_LIBGCCJIT_INCLUDE}" + LIBGCCJIT_LIBS="-L${MACPORTS_LIBGCCJIT_LIB} $LIBGCCJIT_LIBS" + fi fi AC_DEFINE_UNQUOTED(NATIVE_ELISP_SUFFIX, ".eln", [System extension for native compiled elisp]) AC_SUBST(HAVE_NATIVE_COMP) -AC_SUBST(LIBGCCJIT_LIB) +AC_SUBST(LIBGCCJIT_CFLAGS) +AC_SUBST(LIBGCCJIT_LIBS) DYNLIB_OBJ= if test "${NEED_DYNLIB}" = yes; then diff --git a/src/Makefile.in b/src/Makefile.in index 22c7aeed5c6..732cd8f0998 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -326,7 +326,8 @@ GETLOADAVG_LIBS = @GETLOADAVG_LIBS@ LIBGMP = @LIBGMP@ -LIBGCCJIT = @LIBGCCJIT_LIB@ +LIBGCCJIT_LIBS = @LIBGCCJIT_LIBS@ +LIBGCCJIT_CFLAGS = @LIBGCCJIT_CFLAGS@ ## dynlib.o if necessary, else empty DYNLIB_OBJ = @DYNLIB_OBJ@ @@ -367,7 +368,7 @@ EMACS_CFLAGS=-Demacs $(MYCPPFLAGS) -I. -I$(srcdir) \ -I$(lib) -I$(top_srcdir)/lib \ $(C_SWITCH_MACHINE) $(C_SWITCH_SYSTEM) $(C_SWITCH_X_SITE) \ $(GNUSTEP_CFLAGS) $(CFLAGS_SOUND) $(RSVG_CFLAGS) $(IMAGEMAGICK_CFLAGS) \ - $(PNG_CFLAGS) $(LIBXML2_CFLAGS) $(DBUS_CFLAGS) \ + $(PNG_CFLAGS) $(LIBXML2_CFLAGS) $(LIBGCCJIT_CFLAGS) $(DBUS_CFLAGS) \ $(XRANDR_CFLAGS) $(XINERAMA_CFLAGS) $(XFIXES_CFLAGS) $(XDBE_CFLAGS) \ $(WEBKIT_CFLAGS) $(LCMS2_CFLAGS) \ $(SETTINGS_CFLAGS) $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS) \ @@ -516,7 +517,7 @@ LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \ $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(HARFBUZZ_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ $(LIBGNUTLS_LIBS) $(LIB_PTHREAD) $(GETADDRINFO_A_LIBS) $(LCMS2_LIBS) \ $(NOTIFY_LIBS) $(LIB_MATH) $(LIBZ) $(LIBMODULES) $(LIBSYSTEMD_LIBS) \ - $(JSON_LIBS) $(LIBGMP) $(LIBGCCJIT) + $(JSON_LIBS) $(LIBGMP) $(LIBGCCJIT_LIBS) ## FORCE it so that admin/unidata can decide whether this file is ## up-to-date. Although since charprop depends on bootstrap-emacs, -- cgit v1.2.3