LuaSnip icon indicating copy to clipboard operation
LuaSnip copied to clipboard

Is LuaSnip supported on FreeBSD?

Open vermaden opened this issue 1 year ago • 2 comments

The reason I ask because it fails to build - for nvim(1) does not matter if I use BSD make(1) or GNU make(1).

BSD make(1) error: vermaden_2024-03-11_07-21-18

GNU make(1) error: vermaden_2024-03-11_07-20-34

Regards, vermaden

vermaden avatar Mar 11 '24 06:03 vermaden

I will try to make 'gcc' link to 'gcc13' ...

vermaden avatar Mar 11 '24 06:03 vermaden

OK, solved.

Two things are needed to use/build this on FreeBSD.

  1. Temporary change from BSD make(1) to GNU make(1).
% cd /usr/bin
# mv make make.FreeBSD
# ln -s /usr/local/bin/gmake make
  1. Create a link to some recent GCC version in PATH.
# ln -s /usr/local/bin/gcc13 /usr/local/bin/gcc

Could this be covered in future LuaSnip versions Makefile?

To use gmake(1) instead of make(1) on FreeBSD and to search for gcc12 or gcc13 compiler in PATH?

Regards, vermaden

vermaden avatar Mar 11 '24 06:03 vermaden

Hey, could you try the non-gcc-makefile-branch? As long as gmake is used, it should work

AFAICT for adapting to bsd-make, we'd need to maintain two makefiles, one that uses bsd-if-syntax, another with gnu-if.

L3MON4D3 avatar Apr 01 '24 20:04 L3MON4D3

Hi,

its probably not what I meant :)

using GNU make is more then OK - it would just need some 'check' to use/require gmake instead of make on FreeBSD.

IMHO its pointless to create another BSD make compatible Makefile as You already have created and tested GNU make one.

vermaden avatar Apr 01 '24 21:04 vermaden

Ah, okay :) I think we already should be using gmake for recursive make, or am I missing something? Or are you proposing to document the gmake-requirement?

L3MON4D3 avatar Apr 02 '24 07:04 L3MON4D3

the issue is, how to invoke make. On linux & MacOS, gmake === make. On *BSD, make is bsd make, so we need to call gmake.

dch avatar Apr 02 '24 09:04 dch

I am not a Makefile expert - but I was thinking about something like that.

OS := $(shell uname)

ifeq ($(OS),FreeBSD)
    MAKE=gmake
endif

vermaden avatar Apr 02 '24 11:04 vermaden

Oh, I was under the impression that this is exactly what $(MAKE) is for (https://www.gnu.org/software/make/manual/html_node/MAKE-Variable.html)

Does, for example gmake install_jsregexp, not work currently?

L3MON4D3 avatar Apr 02 '24 12:04 L3MON4D3

Like I said - I am not a Makefile expert :)

vermaden avatar Apr 02 '24 14:04 vermaden

:D I'd assumed that did not work and was a bit surprised :)

Could you try if it works without any further changes on non-gcc-makefile?

L3MON4D3 avatar Apr 02 '24 17:04 L3MON4D3

Just did that.

Seems to work OK I suppose?

~/_LUA % unzip LuaSnip-non-gcc-makefile.zip

~/_LUA % ls -l                        
drwxr-xr-x vermaden vermaden  19 B  2024/04/02 23:05  LuaSnip-non-gcc-makefile
.rw-r--r-- vermaden vermaden 384 KB 2024/04/02 23:02  LuaSnip-non-gcc-makefile.zip

~/_LUA % cd LuaSnip-non-gcc-makefile          

~/_LUA/LuaSnip-non-gcc-makefile % make                                                                    
make: "/home/vermaden/_LUA/LuaSnip-non-gcc-makefile/Makefile" line 37: Invalid line type
make: "/home/vermaden/_LUA/LuaSnip-non-gcc-makefile/Makefile" line 42: Invalid line type
make: Fatal errors encountered -- cannot continue
make: stopped in /home/vermaden/_LUA/LuaSnip-non-gcc-makefile

~/_LUA/LuaSnip-non-gcc-makefile % gmake 
# fetch current master and 0.7.0 (the minimum version we support) and 0.9.0
# (the minimum version for treesitter-postfix to work).
git clone --bare --depth 1 https://github.com/neovim/neovim deps/nvim_multiversion
Cloning into bare repository 'deps/nvim_multiversion'...
remote: Enumerating objects: 3533, done.
remote: Counting objects: 100% (3533/3533), done.
remote: Compressing objects: 100% (3208/3208), done.
remote: Total 3533 (delta 312), reused 1336 (delta 237), pack-reused 0
Receiving objects: 100% (3533/3533), 12.08 MiB | 603.00 KiB/s, done.
Resolving deltas: 100% (312/312), done.
git -C deps/nvim_multiversion fetch --depth 1 origin tag v0.7.0
remote: Enumerating objects: 3387, done.
remote: Counting objects: 100% (3387/3387), done.
remote: Compressing objects: 100% (1891/1891), done.
remote: Total 2001 (delta 1122), reused 357 (delta 53), pack-reused 0
Receiving objects: 100% (2001/2001), 3.77 MiB | 576.00 KiB/s, done.
Resolving deltas: 100% (1122/1122), completed with 1058 local objects.
From https://github.com/neovim/neovim
 * [new tag]         v0.7.0     -> v0.7.0
git -C deps/nvim_multiversion fetch --depth 1 origin tag v0.9.0
remote: Enumerating objects: 3361, done.
remote: Counting objects: 100% (3361/3361), done.
remote: Compressing objects: 100% (1208/1208), done.
remote: Total 1343 (delta 1091), reused 207 (delta 115), pack-reused 0
Receiving objects: 100% (1343/1343), 1.26 MiB | 323.00 KiB/s, done.
Resolving deltas: 100% (1091/1091), completed with 1049 local objects.
From https://github.com/neovim/neovim
 * [new tag]         v0.9.0     -> v0.9.0
# create one worktree for master, and one for 0.7.
# The rationale behind this is that switching from 0.7 to master (and
# vice-versa) requires a `make distclean`, and full clean build, which takes
# a lot of time.
# The most straightforward solution seems to be too keep two worktrees, one
# for master, one for 0.7, and one for 0.9 which are used for the
# respective builds/tests.
git -C deps/nvim_multiversion worktree add worktree_master master
Preparing worktree (checking out 'master')
HEAD is now at d9235ef refactor(lsp): move workspace folder logic into the client
git -C deps/nvim_multiversion worktree add worktree_0.7 v0.7.0
Preparing worktree (detached HEAD 333ba65)
HEAD is now at 333ba65 NVIM 0.7
git -C deps/nvim_multiversion worktree add worktree_0.9 v0.9.0
Preparing worktree (detached HEAD 040f145)
Updating files: 100% (3123/3123), done.
HEAD is now at 040f145 NVIM v0.9.0

~/_LUA/LuaSnip-non-gcc-makefile % ls -ltra
drwxr-xr-x vermaden vermaden   4 B  2024/04/02 23:05  ..
drwxr-xr-x vermaden vermaden   4 B  2024/04/02 23:05  .github
drwxr-xr-x vermaden vermaden   3 B  2024/04/02 23:05  Examples
drwxr-xr-x vermaden vermaden   3 B  2024/04/02 23:05  doc
drwxr-xr-x vermaden vermaden   3 B  2024/04/02 23:05  ftplugin
drwxr-xr-x vermaden vermaden   3 B  2024/04/02 23:05  lua
drwxr-xr-x vermaden vermaden   4 B  2024/04/02 23:05  plugin
drwxr-xr-x vermaden vermaden   3 B  2024/04/02 23:05  syntax
drwxr-xr-x vermaden vermaden  19 B  2024/04/02 23:05  .
drwxr-xr-x vermaden vermaden   8 B  2024/04/02 23:05  tests
drwxr-xr-x vermaden vermaden   6 B  2024/04/02 23:06  deps
.rw-r--r-- vermaden vermaden  12 KB 2024/04/01 22:52  README.md
.rw-r--r-- vermaden vermaden 3.7 KB 2024/04/01 22:52  Makefile
.rw-r--r-- vermaden vermaden  11 KB 2024/04/01 22:52  LICENSE
.rw-r--r-- vermaden vermaden 142 KB 2024/04/01 22:52  DOC.md
.rw-r--r-- vermaden vermaden   6 B  2024/04/01 22:52  .styluaignore
.rw-r--r-- vermaden vermaden 111 B  2024/04/01 22:52  .stylua.toml
.rw-r--r-- vermaden vermaden 166 B  2024/04/01 22:52  .gitmodules
.rw-r--r-- vermaden vermaden 122 B  2024/04/01 22:52  .gitignore

vermaden avatar Apr 02 '24 21:04 vermaden

Looks correct so far, could you also try gmake install_jsregexp? That's the one where the compiler matters

L3MON4D3 avatar Apr 04 '24 05:04 L3MON4D3

(ping)

L3MON4D3 avatar Apr 16 '24 17:04 L3MON4D3

Oh, sorry, forgot, gonna try that in a moment.

vermaden avatar Apr 16 '24 17:04 vermaden

I got that:

~/_LUA/LuaSnip-non-gcc-makefile % gmake install_jsregexp
git submodule init
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
gmake: *** [Makefile:47: jsregexp] Error 128

vermaden avatar Apr 16 '24 17:04 vermaden

That was quick, thanks! Ah, is it possible you extracted a tar of luasnips source (or got just the source without .git in some other way)? I think install_jsregexp needs the cloned repo, could you try that?

L3MON4D3 avatar Apr 16 '24 17:04 L3MON4D3

Sure, but please paste me here the git clone command to clone the non-gcc-makefile repo please.

vermaden avatar Apr 16 '24 17:04 vermaden

Oh, yeah sure: git clone https://github.com/L3MON4D3/LuaSnip.git && git c origin/non-gcc-makefile

L3MON4D3 avatar Apr 16 '24 17:04 L3MON4D3

A typo?

% git clone [email protected]:L3MON4D3/LuaSnip.git && git c origin/non-gcc-makefile
Cloning into 'LuaSnip'...
remote: Enumerating objects: 12925, done.
remote: Counting objects: 100% (2174/2174), done.
remote: Compressing objects: 100% (504/504), done.
remote: Total 12925 (delta 1728), reused 1866 (delta 1571), pack-reused 10751
Receiving objects: 100% (12925/12925), 7.50 MiB | 459.00 KiB/s, done.
Resolving deltas: 100% (7862/7862), done.
git: 'c' is not a git command. See 'git --help'.

The most similar commands are
        clone
        commit
        gc


vermaden avatar Apr 16 '24 17:04 vermaden

Ha, srry, I have a alias setup, s/c/checkout :sweat_smile:

L3MON4D3 avatar Apr 16 '24 17:04 L3MON4D3

Thank You.

Seems it worked OK?


~/_LUA % git clone [email protected]:L3MON4D3/LuaSnip.git
Cloning into 'LuaSnip'...
remote: Enumerating objects: 12925, done.
remote: Counting objects: 100% (2174/2174), done.
remote: Compressing objects: 100% (504/504), done.
remote: Total 12925 (delta 1728), reused 1868 (delta 1571), pack-reused 10751
Receiving objects: 100% (12925/12925), 7.50 MiB | 500.00 KiB/s, done.
Resolving deltas: 100% (7862/7862), done.

~/_LUA % cd LuaSnip                 

~/_LUA/LuaSnip % git checkout origin/non-gcc-makefile
Note: switching to 'origin/non-gcc-makefile'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 939d52b default jsregexp-CC to system-CC.

~/_LUA/LuaSnip % ls -la
drwxr-xr-x vermaden vermaden  20 B  2024/04/16 19:58  .
drwxr-xr-x vermaden vermaden   3 B  2024/04/16 19:57  ..
drwxr-xr-x vermaden vermaden  13 B  2024/04/16 19:58  .git
drwxr-xr-x vermaden vermaden   4 B  2024/04/16 19:58  .github
drwxr-xr-x vermaden vermaden   5 B  2024/04/16 19:58  deps
drwxr-xr-x vermaden vermaden   3 B  2024/04/16 19:58  doc
drwxr-xr-x vermaden vermaden   3 B  2024/04/16 19:58  Examples
drwxr-xr-x vermaden vermaden   3 B  2024/04/16 19:58  ftplugin
drwxr-xr-x vermaden vermaden   3 B  2024/04/16 19:58  lua
drwxr-xr-x vermaden vermaden   4 B  2024/04/16 19:58  plugin
drwxr-xr-x vermaden vermaden   3 B  2024/04/16 19:58  syntax
drwxr-xr-x vermaden vermaden   8 B  2024/04/16 19:58  tests
.rw-r--r-- vermaden vermaden 122 B  2024/04/16 19:58  .gitignore
.rw-r--r-- vermaden vermaden 166 B  2024/04/16 19:58  .gitmodules
.rw-r--r-- vermaden vermaden 111 B  2024/04/16 19:58  .stylua.toml
.rw-r--r-- vermaden vermaden   6 B  2024/04/16 19:58  .styluaignore
.rw-r--r-- vermaden vermaden 142 KB 2024/04/16 19:58  DOC.md
.rw-r--r-- vermaden vermaden  11 KB 2024/04/16 19:58  LICENSE
.rw-r--r-- vermaden vermaden 3.7 KB 2024/04/16 19:58  Makefile
.rw-r--r-- vermaden vermaden  12 KB 2024/04/16 19:58  README.md

~/_LUA/LuaSnip % gmake                               
# fetch current master and 0.7.0 (the minimum version we support) and 0.9.0
# (the minimum version for treesitter-postfix to work).
git clone --bare --depth 1 https://github.com/neovim/neovim deps/nvim_multiversion
Cloning into bare repository 'deps/nvim_multiversion'...
remote: Enumerating objects: 3548, done.
remote: Counting objects: 100% (3548/3548), done.
remote: Compressing objects: 100% (3185/3185), done.
remote: Total 3548 (delta 343), reused 1233 (delta 275), pack-reused 0
Receiving objects: 100% (3548/3548), 12.15 MiB | 539.00 KiB/s, done.
Resolving deltas: 100% (343/343), done.
git -C deps/nvim_multiversion fetch --depth 1 origin tag v0.7.0
remote: Enumerating objects: 3635, done.
remote: Counting objects: 100% (3635/3635), done.
remote: Compressing objects: 100% (2002/2002), done.
remote: Total 2142 (delta 1225), reused 392 (delta 83), pack-reused 0
Receiving objects: 100% (2142/2142), 3.86 MiB | 883.00 KiB/s, done.
Resolving deltas: 100% (1225/1225), completed with 1129 local objects.
From https://github.com/neovim/neovim
 * [new tag]         v0.7.0     -> v0.7.0
git -C deps/nvim_multiversion fetch --depth 1 origin tag v0.9.0
remote: Enumerating objects: 3406, done.
remote: Counting objects: 100% (3406/3406), done.
remote: Compressing objects: 100% (1240/1240), done.
remote: Total 1365 (delta 1108), reused 199 (delta 105), pack-reused 0
Receiving objects: 100% (1365/1365), 1.27 MiB | 457.00 KiB/s, done.
Resolving deltas: 100% (1108/1108), completed with 1064 local objects.
From https://github.com/neovim/neovim
 * [new tag]         v0.9.0     -> v0.9.0
# create one worktree for master, and one for 0.7.
# The rationale behind this is that switching from 0.7 to master (and
# vice-versa) requires a `make distclean`, and full clean build, which takes
# a lot of time.
# The most straightforward solution seems to be too keep two worktrees, one
# for master, one for 0.7, and one for 0.9 which are used for the
# respective builds/tests.
git -C deps/nvim_multiversion worktree add worktree_master master
Preparing worktree (checking out 'master')
HEAD is now at 20b3867 feat(defaults): use ripgrep (rg) for 'grepprg' if available
git -C deps/nvim_multiversion worktree add worktree_0.7 v0.7.0
Preparing worktree (detached HEAD 333ba65)
HEAD is now at 333ba65 NVIM 0.7
git -C deps/nvim_multiversion worktree add worktree_0.9 v0.9.0
Preparing worktree (detached HEAD 040f145)
HEAD is now at 040f145 NVIM v0.9.0

~/_LUA/LuaSnip % gmake install_jsregexp
git submodule init
Submodule 'deps/jsregexp' ([email protected]:kmarius/jsregexp) registered for path 'deps/jsregexp'
Submodule 'deps/jsregexp005' ([email protected]:kmarius/jsregexp) registered for path 'deps/jsregexp005'
git submodule update
Cloning into '/home/vermaden/_LUA/LuaSnip/deps/jsregexp'...
Cloning into '/home/vermaden/_LUA/LuaSnip/deps/jsregexp005'...
Submodule path 'deps/jsregexp': checked out 'b5a81e21d0875667ba2458ac8ae903afd5568698'
Submodule path 'deps/jsregexp005': checked out 'dd65498ae2c29b882d6c02c0a30577b08d660b94'
gmake "CC=cc" "INCLUDE_DIR=-I'/home/vermaden/_LUA/LuaSnip/deps/lua51_include/'" LDLIBS="" -C "deps/jsregexp"
gmake[1]: Entering directory '/home/vermaden/_LUA/LuaSnip/deps/jsregexp'
cc -I'/home/vermaden/_LUA/LuaSnip/deps/lua51_include/' -O2 -fPIC -c jsregexp.c -o jsregexp.o
cc -I'/home/vermaden/_LUA/LuaSnip/deps/lua51_include/' -O2 -fPIC -c cutils.c -o cutils.o
cc -I'/home/vermaden/_LUA/LuaSnip/deps/lua51_include/' -O2 -fPIC -c libregexp.c -o libregexp.o
cc -I'/home/vermaden/_LUA/LuaSnip/deps/lua51_include/' -O2 -fPIC -c libunicode.c -o libunicode.o
cc -shared jsregexp.o cutils.o libregexp.o libunicode.o  -o jsregexp.so
gmake[1]: Leaving directory '/home/vermaden/_LUA/LuaSnip/deps/jsregexp'
gmake "CC=cc" "INCLUDE_DIR=-I'/home/vermaden/_LUA/LuaSnip/deps/lua51_include/'" LDLIBS="" -C "deps/jsregexp005"
gmake[1]: Entering directory '/home/vermaden/_LUA/LuaSnip/deps/jsregexp005'
cc -I'/home/vermaden/_LUA/LuaSnip/deps/lua51_include/' -O2 -fPIC -c jsregexp.c -o jsregexp.o
cc -I'/home/vermaden/_LUA/LuaSnip/deps/lua51_include/' -O2 -fPIC -c cutils.c -o cutils.o
cc -I'/home/vermaden/_LUA/LuaSnip/deps/lua51_include/' -O2 -fPIC -c libregexp.c -o libregexp.o
cc -I'/home/vermaden/_LUA/LuaSnip/deps/lua51_include/' -O2 -fPIC -c libunicode.c -o libunicode.o
cc -shared jsregexp.o cutils.o libregexp.o libunicode.o  -o jsregexp.so
gmake[1]: Leaving directory '/home/vermaden/_LUA/LuaSnip/deps/jsregexp005'
# remove old binary.
rm "/home/vermaden/_LUA/LuaSnip/lua/luasnip-jsregexp.so" || true
rm: /home/vermaden/_LUA/LuaSnip/lua/luasnip-jsregexp.so: No such file or directory
# there is some additional trickery to make this work with jsregexp-0.0.6 in
# util/jsregexp.lua.
cp "/home/vermaden/_LUA/LuaSnip/deps/jsregexp/jsregexp.lua" "/home/vermaden/_LUA/LuaSnip/lua/luasnip-jsregexp.lua"
# just move out of jsregexp-directory, so it is not accidentially deleted.
cp "/home/vermaden/_LUA/LuaSnip/deps/jsregexp/jsregexp.so" "/home/vermaden/_LUA/LuaSnip/deps/luasnip-jsregexp.so"

~/_LUA/LuaSnip % echo $?
0

vermaden avatar Apr 16 '24 18:04 vermaden

Nice, yeah that looks good :) It's using cc by default, but that can be changed via export CC=gcc/clang/whatever, so fine :) Thanks for testing :D

L3MON4D3 avatar Apr 16 '24 18:04 L3MON4D3

Welcome. Happy to help. Regards :)

vermaden avatar Apr 16 '24 18:04 vermaden