用 GitHub Actions 每日于 macOS 构建的静态链接外部依赖的 Emacs

报错 Symbol’s function definition is void: make-mutex

查了下,似乎是因为

(featurep 'threads) ; ==> nil

有几个插件用到了里面的 make-mutex 函数。

嘶 --without-all 也把 --with-threads 关了

稍等(

你build的是mps分支的代码啊,我clone一个你的repo,改成main分支加上ns-mac-input-source.patchns-alpha-background.patch这2个patch。另外我也不喜欢native-comp,速度快不了多少。

  1. mps功能是好,但是对我16G的小本子不太友好。
  2. ns-alpha-background.patch 背景透明
  3. ns-mac-input-source.patch 输入法切换

对,README 里说了

This repository automatically builds GNU Emacs with the Memory Pool System for Darwin every day at UTC 0:00, directly from upstream git sources.

我觉得没必要去省这点内存,这是开了两个 C project 两个 OCaml project (eglot LSP + magit)加 Wanderlust 的占用,还不如浏览器少开一个 tab

MSYS2编译用这个似乎没效果,编译出来的emacs依旧有一堆动态链接的dll

$ ldd emacs.exe
        ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x7ff853e50000)
        KERNEL32.DLL => /c/Windows/System32/KERNEL32.DLL (0x7ff852d10000)
        KERNELBASE.dll => /c/Windows/System32/KERNELBASE.dll (0x7ff851730000)
        ADVAPI32.dll => /c/Windows/System32/ADVAPI32.dll (0x7ff852c20000)
        msvcrt.dll => /c/Windows/System32/msvcrt.dll (0x7ff852300000)
        sechost.dll => /c/Windows/System32/sechost.dll (0x7ff853cc0000)
        RPCRT4.dll => /c/Windows/System32/RPCRT4.dll (0x7ff852ec0000)
        bcrypt.dll => /c/Windows/System32/bcrypt.dll (0x7ff851bc0000)
        comdlg32.dll => /c/Windows/System32/comdlg32.dll (0x7ff852de0000)
        COMCTL32.dll => /c/Windows/WinSxS/amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.6456_none_60b8a6cb71f64256/COMCTL32.dll (0x7ff840cc0000)
        combase.dll => /c/Windows/System32/combase.dll (0x7ff851e70000)
        GDI32.dll => /c/Windows/System32/GDI32.dll (0x7ff853de0000)
        ucrtbase.dll => /c/Windows/System32/ucrtbase.dll (0x7ff851580000)
        win32u.dll => /c/Windows/System32/win32u.dll (0x7ff851b90000)
        gdi32full.dll => /c/Windows/System32/gdi32full.dll (0x7ff851c80000)
        msvcp_win.dll => /c/Windows/System32/msvcp_win.dll (0x7ff8514e0000)
        shcore.dll => /c/Windows/System32/shcore.dll (0x7ff8521d0000)
        USER32.dll => /c/Windows/System32/USER32.dll (0x7ff853750000)
        user32.dll => /c/Windows/System32/user32.dll (0x1dea26d0000)
        SHLWAPI.dll => /c/Windows/System32/SHLWAPI.dll (0x7ff852280000)
        SHELL32.dll => /c/Windows/System32/SHELL32.dll (0x7ff852fe0000)
        ole32.dll => /c/Windows/System32/ole32.dll (0x7ff853980000)
        MPR.dll => /c/Windows/SYSTEM32/MPR.dll (0x7ff841930000)
        libgmp-10.dll => /mingw64/bin/libgmp-10.dll (0x7ff8308b0000)
        WINSPOOL.DRV => /c/Windows/SYSTEM32/WINSPOOL.DRV (0x7ff828900000)
        WINMM.dll => /c/Windows/SYSTEM32/WINMM.dll (0x7ff846810000)
        libwinpthread-1.dll => /mingw64/bin/libwinpthread-1.dll (0x7ff84b260000)

但是其实msys2是有libgmp.a和libwpthread.a的,如果这两个能静态链接进去应该就够了吧,system32那些dll应该必须动态链接

pkg-config -static 只是输出这个库的全部依赖,对强制静态链接这个行为没有任何意义

似乎再加上make的时候LDFLAGS= "-static"就可以了,很神奇的是静态链接的emacs可执行文件居然之比动态链接的只多几百KB

难道说、只有 macOS 不能用 -static :innocent:

换成macos-15-intel编译x86版本,怎么都编译不了libnettle,真是奇怪啊

感谢楼主贡献的这个项目,太舒服了。

1 个赞

看你的报错

gcc -g -O2 -ggdb3 -Wall -W -Wno-sign-compare   -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes   -Wpointer-arith -Wbad-function-cast -Wnested-externs -L..  pkcs1-conv.o misc.o ../getopt.o ../getopt1.o -lhogweed -lnettle -lgmp  -o pkcs1-conv
Illegal text-relocations:
  text-relocation in '___gmpn_mod_34lsub1'+0x98 (/usr/local/lib/libgmp.a[311](mod_34lsub1.o)) to '___gmpn_mod_34lsub1'
  text-relocation in '___gmpn_mod_34lsub1'+0xA0 (/usr/local/lib/libgmp.a[311](mod_34lsub1.o)) to '___gmpn_mod_34lsub1'
  text-relocation in '___gmpn_mod_34lsub1'+0xA8 (/usr/local/lib/libgmp.a[311](mod_34lsub1.o)) to '___gmpn_mod_34lsub1'
  text-relocation in '___gmpn_mod_34lsub1'+0xB0 (/usr/local/lib/libgmp.a[311](mod_34lsub1.o)) to '___gmpn_mod_34lsub1'
  text-relocation in '___gmpn_mod_34lsub1'+0xB8 (/usr/local/lib/libgmp.a[311](mod_34lsub1.o)) to '___gmpn_mod_34lsub1'
  text-relocation in '___gmpn_mod_34lsub1'+0xC0 (/usr/local/lib/libgmp.a[311](mod_34lsub1.o)) to '___gmpn_mod_34lsub1'
  text-relocation in '___gmpn_mod_34lsub1'+0xC8 (/usr/local/lib/libgmp.a[311](mod_34lsub1.o)) to '___gmpn_mod_34lsub1'
  text-relocation in '___gmpn_mod_34lsub1'+0xD0 (/usr/local/lib/libgmp.a[311](mod_34lsub1.o)) to '___gmpn_mod_34lsub1'
  text-relocation in '___gmpn_mod_34lsub1'+0xD8 (/usr/local/lib/libgmp.a[311](mod_34lsub1.o)) to '___gmpn_mod_34lsub1'
  text-relocation in '___gmpn_bdiv_q_1'+0x19 (/usr/local/lib/libgmp.a[428](bdiv_q_1.o)) to '___gmp_binvert_limb_table'
ld: Found illegal text-relocations
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [pkcs1-conv] Error 1
make: *** [all] Error 2

是因为 illegal text-relocations,那试试编译 libgmp 的时候编译成 position independent code

# for libgmp
./configure CFLAGS="-fPIC" --disable-shared

编译出来启动速度啥的有变化吗?

如果还不行,再试试给 libgmp 加上 --disable-assembly

我试试,已经被折磨得不想改了,编译一次就30分钟。

只有这2个dylib了,已经是静态链接了吧?在macos-15-intel的规格下编译一次要1个多小时。

启动速度比动态链接的emacs快一点点。

我又把 elisp threading support 去掉了

因为 macOS 上的实现有仍然是有问题的

是的

如果是 Wanderlust 卡了,把 wl 的选项设一下就行了,没有多线程 lsp mode 就完全用不了了

感觉没有,不推荐使用,因为我发现tree-sitter实际上用不了,可能还有别的bug

ok 加回去了

也不知道什么时候有人会去修它(