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

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix; Reported by: Caleb Ristvedt <caleb.ristvedt@HIDDEN>; dated Thu, 9 May 2019 02:18:02 UTC; Maintainer for guix is bug-guix@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 9 May 2019 02:17:16 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed May 08 22:17:16 2019
Received: from localhost ([127.0.0.1]:34430 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hOYcV-00011Q-MC
	for submit <at> debbugs.gnu.org; Wed, 08 May 2019 22:17:15 -0400
Received: from eggs.gnu.org ([209.51.188.92]:57277)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <caleb.ristvedt@HIDDEN>) id 1hOYcT-00011D-0B
 for submit <at> debbugs.gnu.org; Wed, 08 May 2019 22:17:14 -0400
Received: from lists.gnu.org ([209.51.188.17]:60388)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <caleb.ristvedt@HIDDEN>)
 id 1hOYcL-00032b-BQ
 for submit <at> debbugs.gnu.org; Wed, 08 May 2019 22:17:06 -0400
Received: from eggs.gnu.org ([209.51.188.92]:43404)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <caleb.ristvedt@HIDDEN>) id 1hOYcI-0002Gc-C5
 for bug-guix@HIDDEN; Wed, 08 May 2019 22:17:05 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_40 autolearn=disabled
 version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <caleb.ristvedt@HIDDEN>) id 1hOYcG-0002zH-DE
 for bug-guix@HIDDEN; Wed, 08 May 2019 22:17:02 -0400
Received: from mail-it1-x134.google.com ([2607:f8b0:4864:20::134]:37597)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <caleb.ristvedt@HIDDEN>)
 id 1hOYcD-0002vY-Qv
 for bug-guix@HIDDEN; Wed, 08 May 2019 22:16:58 -0400
Received: by mail-it1-x134.google.com with SMTP id l7so937623ite.2
 for <bug-guix@HIDDEN>; Wed, 08 May 2019 19:16:54 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=cune-org.20150623.gappssmtp.com; s=20150623;
 h=from:to:subject:date:message-id:user-agent:mime-version;
 bh=Z6WWmlK5KT557pS4KSY0QfWxKw+uPEbd6bsQ1N36MhM=;
 b=kmhpkV3D0hC1nFWYpb9oyuiv5rS9MaPNosFMqVCaLW57Nbv+FkAHG8JwUE1YJTHoNC
 M4HsmWeKe3UO9DP0FlhxzAyk2jzj2V1MxNlE6x/vv2trZkAAs6e03FHm7KlV1BTB5Ozc
 erKL/yxl1qFZWmWc5NY/kz8YecyAIXfcwZZXlfUFrAy8VmKvNZL93E9TP3XI9o/d58GL
 r+A3AbPWFjpdYnaHWLCziytSmdqwaHLGJRGfdU3HRCm7gFl+RU1TwgPcPsT3hYqLUTtl
 XGLsztSp+49JCPF66ACZWJu6RfQQwbG1I4/XsvfnGojf4FJ9bKNbnuLTVqmE+fYc+jhP
 cgNw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:subject:date:message-id:user-agent
 :mime-version;
 bh=Z6WWmlK5KT557pS4KSY0QfWxKw+uPEbd6bsQ1N36MhM=;
 b=JYPDA4QqK79mcsZMnUBuBLXGtkGodZBOJ7Pu8DCsj92nrUtw1x9A9TCeMMfJDQXp5Y
 /pYIttww1OvoMz8gDWsBX2/A1sFCm17oVnUd6ooeBip9pwXry9QZZFEXkn3A5k5Lv5+/
 mJjBLB5aiSFHIOzJqJnHFBkB7U6xyyJiIItoAZm5okTDoinjducz//sMKFsojLw7CcZJ
 OKl64EJNeCyzHTLbmNsU7sS0zh7sU8prxfpcLGcWZIIbCC21VyBc8y7iJ9yOJGJaIFuw
 I45dmAAxCfDUMubnc7xsLAF7G9aWQA4VXYvtKfTkBQDubJTPSWK/qXAFie2MZ9IX8q1l
 lvxw==
X-Gm-Message-State: APjAAAUJ622n+S7fdsyBniM2GGgILaXaADCJJ31g+po/xIxHPGna2nTS
 tU0hFPElRYvYD8ZR6ygy2bHGr3Kfsa7iSQ==
X-Google-Smtp-Source: APXvYqysY3ci8FA89N7WUFIA/4w7vaUpUOSa0NTXO86dBrpxted7ogPB58K9N7J/jasrVQTfoH1d+A==
X-Received: by 2002:a24:6b92:: with SMTP id v140mr958889itc.161.1557368213516; 
 Wed, 08 May 2019 19:16:53 -0700 (PDT)
Received: from GuixPotato ([208.89.170.37])
 by smtp.gmail.com with ESMTPSA id b12sm375955ioq.31.2019.05.08.19.16.52
 for <bug-guix@HIDDEN>
 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
 Wed, 08 May 2019 19:16:52 -0700 (PDT)
From: Caleb Ristvedt <caleb.ristvedt@HIDDEN>
To: bug-guix@HIDDEN
Subject: emacs module support doesn't work
Date: Wed, 08 May 2019 21:16:48 -0500
Message-ID: <87o94cid7z.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-Received-From: 2607:f8b0:4864:20::134
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

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




Acknowledgement sent to Caleb Ristvedt <caleb.ristvedt@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-guix@HIDDEN. Full text available.
Report forwarded to bug-guix@HIDDEN:
bug#35644; Package guix. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

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