1

Consider:

;;; a.el
(defun a () nil)
(provide 'a)
;;; b.el
(require 'a)
(defun b () nil)
(provide 'b)

In traditional Emacs this byte compiles fine:

;;; use.el
(require 'b)
(a) ;This is automatically available "transitively" (without native-comp)
(b)

But --with-native-comp complains that a is unknown; transitive requires are insufficient. Instead you must directly require everything, e.g.:

;;; use.el
(require 'a) ;NEW
(require 'b)
(a)
(b)

Alternatively I suppose b.el could (provide 'b) as well as (provide 'a)?


Presumably this is because each native compilation is isolated and inherits no state/environment from previous compilations?

Although this isn't necessarily a bad change (I can see the argument for it being an improvement) it's a significant change.

In searching (so far, maybe I've missed something) I haven't seen an explanation in quite these terms. For example: "Tip: To work with native compilation, you cannot rely on a require automatically providing features its has required. Either add direct requires, or, have the required file use multiple provides to supply the expected features.

  1. Is my understanding of the situation correct?
  2. Is my "Tip" correct?
Greg Hendershott
  • 1,483
  • 12
  • 17
  • Consider filing a bug report: `M-x report-emacs-bug`. – Drew Feb 17 '22 at 17:17
  • Are you using a current build? `--with-nativecomp` was renamed to `--with-native-compilation` six months ago. (You've written something in the middle, so it's hard to tell.) In either case, this is pre-release functionality, so I agree with Drew that you should report a bug, or otherwise ask on the mailing list. – phils Feb 18 '22 at 00:47
  • Thanks Drew and @phils for the suggestions how to follow up. This arose via https://github.com/greghendershott/racket-mode/pull/596 and I don't have all the details first-hand, Either I'll equip myself with those to follow up, or, ask the original reporter to do so. – Greg Hendershott Feb 18 '22 at 15:35
  • It took me awhile to get a `--with-native-compilation` build; using it I [can't repro with a simplified recipe](https://github.com/greghendershott/racket-mode/pull/596#issuecomment-1049930002). – Greg Hendershott Feb 24 '22 at 14:49

1 Answers1

1

It looks like this turned out to be just a bleeding edge problem:

  • The original report came from someone who built from source about 10 days ago.

  • By the time I tried myself a couple days ago --- and they tried again today, to confirm --- the problem no longer occurs.

Glancing at the commits in that time range, I have no idea which one was the fix. My W.A.G. is one of the commits making changes around current-load-list and load-history; maybe that could cause the native compiler not to know about already, transitively loaded functions??

So I'm posting that as a self-answer, but definitely not marking it as accepted. Maybe someone will post a definitive answer and salvage some value from my question. Otherwise, I apologize if this was a distraction.


As a TL;DR: Native compilation is not intended to change the semantics of transitive requires. If you've built Emacs from source --with-native-compilation and see errors like this, try rebuilding from source again. If you still see errors like this, report them.

Greg Hendershott
  • 1,483
  • 12
  • 17