From mboxrd@z Thu Jan 1 00:00:00 1970 From: Caleb Ristvedt Subject: bug#35644: emacs module support doesn't work Date: Wed, 08 May 2019 21:16:48 -0500 Message-ID: <87o94cid7z.fsf@cune.org> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([209.51.188.92]:43569) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOYdI-0002Jm-4G for bug-guix@gnu.org; Wed, 08 May 2019 22:18:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hOYdG-0003aD-Va for bug-guix@gnu.org; Wed, 08 May 2019 22:18:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:49119) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hOYdG-0003a4-QD for bug-guix@gnu.org; Wed, 08 May 2019 22:18:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hOYdG-00012U-J1 for bug-guix@gnu.org; Wed, 08 May 2019 22:18:02 -0400 Sender: "Debbugs-submit" Resent-Message-ID: Received: from eggs.gnu.org ([209.51.188.92]:43404) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOYcI-0002Gc-C5 for bug-guix@gnu.org; Wed, 08 May 2019 22:17:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hOYcG-0002zH-DE for bug-guix@gnu.org; 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 ) id 1hOYcD-0002vY-Qv for bug-guix@gnu.org; Wed, 08 May 2019 22:16:58 -0400 Received: by mail-it1-x134.google.com with SMTP id l7so937623ite.2 for ; Wed, 08 May 2019 19:16:54 -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 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 May 2019 19:16:52 -0700 (PDT) List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: 35644@debbugs.gnu.org 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 #include #include 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