GNU bug report logs - #35644
emacs module support doesn't work

Previous Next

Package: guix;

Reported by: Caleb Ristvedt <caleb.ristvedt <at> cune.org>

Date: Thu, 9 May 2019 02:18:02 UTC

Severity: normal

Done: Marius Bakke <mbakke <at> fastmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 35644 in the body.
You can then email your comments to 35644 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#35644; Package guix. (Thu, 09 May 2019 02:18:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Caleb Ristvedt <caleb.ristvedt <at> cune.org>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Thu, 09 May 2019 02:18:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Caleb Ristvedt <caleb.ristvedt <at> cune.org>
To: bug-guix <at> gnu.org
Subject: emacs module support doesn't work
Date: Wed, 08 May 2019 21:16:48 -0500
While attempting to package libegit2
(https://github.com/magit/libegit2), I found that any attempt at loading
a dynamic module from emacs would seemingly work (it returns t), but not
actually work: no module api functions invoked from C seem to have any
effect, including defining functions and printing messages. Here's an
example


-------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <emacs-module.h>

int plugin_is_GPL_compatible;

static emacs_value
hello(emacs_env *env, ptrdiff_t nargs, emacs_value args[], void *data)
{
        const char str[] = "Hello Emacs";
        return env->make_string(env, str, sizeof(str) - 1);
}

/* Module init function.  */
int
emacs_module_init(struct emacs_runtime *ert)
{
        emacs_env *env = ert->get_environment(ert);

        emacs_value hellofn = env->make_function(env, 0, 0, hello, "return hello string", NULL);

        // Bind NAME to FUN.
        // (defalias 'hello-c '(lambda () "Hello Emacs"))
        emacs_value defalias_sym = env->intern(env, "defalias");
        emacs_value hello_sym = env->intern(env, "hello-c");
        emacs_value defalias_args[] = { hello_sym, hellofn };

        env->funcall(env, defalias_sym, 2, defalias_args);

        // Provide FEATURE to Emacs.
        // (provide 'hello-core)
        emacs_value feature_sym = env->intern(env, "hello-module");
        emacs_value provide_sym = env->intern(env, "provide");
        emacs_value provide_args[] = { feature_sym };

        env->funcall(env, provide_sym, 1, provide_args);

	char message[] = "TEST MESSAGE!";
	emacs_value message_str = env->make_string(env, message, sizeof(message) - 1);
	emacs_value message_sym = env->intern(env, "message");
	emacs_value message_args[] = {message_str};

	// spam a bit just to be sure
	env->funcall(env, message_sym, 1, message_args);
	env->funcall(env, message_sym, 1, message_args);
	env->funcall(env, message_sym, 1, message_args);

        return 0;
}
-------------------------------

Assuming the above file is named emacs-module-test.c:

-------------------------------
$ gcc -fPIC -shared emacs-module-test.c -o hello-module.so
$ emacs -Q -L . --batch -l hello-module --eval "(message (hello-c))"

=> Symbol's function definition is void: hello-c
-------------------------------

As far as I can tell, this should work. Our emacs is built with
'--with-modules', and 'MODULES' is in system-configuration-features. Any
idea what's going wrong?

- reepca




Information forwarded to bug-guix <at> gnu.org:
bug#35644; Package guix. (Tue, 10 Mar 2020 16:53:02 GMT) Full text and rfc822 format available.

Message #8 received at 35644 <at> debbugs.gnu.org (full text, mbox):

From: mike <at> rohleder.de
To: Caleb Ristvedt <caleb.ristvedt <at> cune.org>
Cc: 35644 <at> debbugs.gnu.org
Subject: Re: bug#35644: emacs module support doesn't work
Date: Tue, 10 Mar 2020 17:52:12 +0100
[Message part 1 (text/plain, inline)]
Caleb Ristvedt <caleb.ristvedt <at> cune.org> writes:
>
> Assuming the above file is named emacs-module-test.c:
>
> -------------------------------
> $ gcc -fPIC -shared emacs-module-test.c -o hello-module.so
> $ emacs -Q -L . --batch -l hello-module --eval "(message (hello-c))"
>
> => Symbol's function definition is void: hello-c
> -------------------------------
>
> As far as I can tell, this should work. Our emacs is built with
> '--with-modules', and 'MODULES' is in system-configuration-features. Any
> idea what's going wrong?

I cant reproduce this, it works for me:

$ guix environment -C bash --ad-hoc emacs gcc-toolchain
[env]$ gcc -fPIC -shared emacs-module-test.c -o hello-module.so
[env]$ emacs -Q -L . --batch -l hello-module --eval "(message (hello-c))"  
TEST MESSAGE!
TEST MESSAGE!
TEST MESSAGE!
Hello Emacs


-- 
Der Erfolg ist nicht danach zu beurteilen, was ein Mensch im Leben
erreicht hat, sondern nach den Hindernissen, die er auf dem Weg zum
Erfolg ueberwunden hat.
(Booker T. Washington)
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-guix <at> gnu.org:
bug#35644; Package guix. (Wed, 11 Mar 2020 05:56:02 GMT) Full text and rfc822 format available.

Message #11 received at 35644 <at> debbugs.gnu.org (full text, mbox):

From: Caleb Ristvedt <caleb.ristvedt <at> cune.org>
To: mike <at> rohleder.de
Cc: 35644 <at> debbugs.gnu.org
Subject: Re: bug#35644: emacs module support doesn't work
Date: Wed, 11 Mar 2020 05:55:04 +0000
[Message part 1 (text/plain, inline)]
I can confirm that it now works. I did a bit of looking through the commit
history and playing around with 'guix time-machine', and whatever changed
to fix
it, it wasn't a change that touched gnu/packages/emacs.scm. I know it fell
between 7ab5c4e0e8 and 5ce153b110, though.

Thanks for bringing this up, I guess we can close this now?

- reepca

On Tue, Mar 10, 2020 at 4:52 PM <mike <at> rohleder.de> wrote:

> Caleb Ristvedt <caleb.ristvedt <at> cune.org> writes:
> >
> > Assuming the above file is named emacs-module-test.c:
> >
> > -------------------------------
> > $ gcc -fPIC -shared emacs-module-test.c -o hello-module.so
> > $ emacs -Q -L . --batch -l hello-module --eval "(message (hello-c))"
> >
> > => Symbol's function definition is void: hello-c
> > -------------------------------
> >
> > As far as I can tell, this should work. Our emacs is built with
> > '--with-modules', and 'MODULES' is in system-configuration-features. Any
> > idea what's going wrong?
>
> I cant reproduce this, it works for me:
>
> $ guix environment -C bash --ad-hoc emacs gcc-toolchain
> [env]$ gcc -fPIC -shared emacs-module-test.c -o hello-module.so
> [env]$ emacs -Q -L . --batch -l hello-module --eval "(message (hello-c))"
> TEST MESSAGE!
> TEST MESSAGE!
> TEST MESSAGE!
> Hello Emacs
>
>
> --
> Der Erfolg ist nicht danach zu beurteilen, was ein Mensch im Leben
> erreicht hat, sondern nach den Hindernissen, die er auf dem Weg zum
> Erfolg ueberwunden hat.
> (Booker T. Washington)
>
[Message part 2 (text/html, inline)]

Reply sent to Marius Bakke <mbakke <at> fastmail.com>:
You have taken responsibility. (Fri, 20 Mar 2020 19:07:02 GMT) Full text and rfc822 format available.

Notification sent to Caleb Ristvedt <caleb.ristvedt <at> cune.org>:
bug acknowledged by developer. (Fri, 20 Mar 2020 19:07:02 GMT) Full text and rfc822 format available.

Message #16 received at 35644-done <at> debbugs.gnu.org (full text, mbox):

From: Marius Bakke <mbakke <at> fastmail.com>
To: Caleb Ristvedt <caleb.ristvedt <at> cune.org>, mike <at> rohleder.de
Cc: 35644-done <at> debbugs.gnu.org
Subject: Re: bug#35644: emacs module support doesn't work
Date: Fri, 20 Mar 2020 20:06:17 +0100
[Message part 1 (text/plain, inline)]
Caleb Ristvedt <caleb.ristvedt <at> cune.org> writes:

> I can confirm that it now works. I did a bit of looking through the commit
> history and playing around with 'guix time-machine', and whatever changed
> to fix
> it, it wasn't a change that touched gnu/packages/emacs.scm. I know it fell
> between 7ab5c4e0e8 and 5ce153b110, though.
>
> Thanks for bringing this up, I guess we can close this now?

Thank you both for the report and investigation.  Closing!
[signature.asc (application/pgp-signature, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 18 Apr 2020 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 6 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.