vectorgraphics / asymptote

2D & 3D TeX-Aware Vector Graphics Language
https://asymptote.sourceforge.io/
GNU General Public License v3.0
555 stars 92 forks source link

Issues building with LSP on macOS #304

Closed perryprog closed 2 years ago

perryprog commented 2 years ago

on macOS 12.2 I'm having trouble getting Asymptote to compile with LSP support, with the following output during ./configure:

checking for pthread_attr_getdetachstate in -lboost_thread... no
configure: *** Could not find libboost_thread: will compile without optional Language Server Protocol. ***

I do, however, have boost version 1.76.0 installed, and I do see libboost_thread-mt.a under my include files. Let me know if any other debug information is needed.

One thing I did try is just bypassing the AC_CHECK_LIB([boost_thread],[pthread_attr_getdetachstate] check by commenting out lines 301 and 305 and removing the square brackets, but this just ends up giving a make compile error of make: *** No rule to make target `liblspcpp.a,', needed by `asy'. Stop. I'm not too familiar with autoconf, so the way I changed it may not have been actually correct.

https://github.com/vectorgraphics/asymptote/blob/e4ff24b20656652c0f4a4f340df6eed6e8b13c9c/configure.ac#L299-L307

johncbowman commented 2 years ago

If libboost_thread is installed in a nonstandard UNIX location, you will need to let configure know where to find it. For example, under MacOS X, you may need to configure with options like this:

./configure CC=clang CXX=clang++ CPPFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib

perryprog commented 2 years ago

@johncbowman sorry, I should've clarified: I do indeed have my CPP and LDFLAGS set correctly, and this does still give the same issue. Other libraries like readline (not the macOS-shipped one), gsl, and so on are found without problem.

perryprog commented 2 years ago

Ah, it looks like my boost installation came with only a lib/libboost_thread-mt.a and not a lib/libboost_thread.a.

Changing the AC_CHECK_LIB call to look for boost_thread-mt, as well as modifying LSPLIBS="-llspcpp -lnetwork-uri -lboost_filesystem -lboost_thread " to use -lboost_thread-mt does appear to work, but I'm not sure if there's differences between the thread-mt and thread that will matter when it comes to actual usage of the library. LspCpp also seems to compile and link fine.

johncbowman commented 2 years ago

Apparently mt stands for multithreaded (it's hard to imagine how libboost_thread would be of any use if it weren't thread safe already):

https://www.boost.org/doc/libs/1_78_0/more/getting_started/unix-variants.html#library-naming

perryprog commented 2 years ago

Worth noting that even with my above listed workaround, I am running into issues with getting asy -lsp to work with Emacs and lsp-mode—I have no clue if this is related, though.

I'm going to bed for now, but the best I can debug is that lsp-mode is sending Sending request 'initialize - (4)' to an asy -lsp process and asy just isn't responding. Asy will sometimes respond to messages like "shutdown" where there'll be an exchange like this:

[Trace - 11:07:03 PM] Sending request 'shutdown - (5)'.
Params: {
}

[Trace - 11:07:03 PM] Received response 'shutdown - (5)' in 1ms.
Result: null

[Trace - 11:07:03 PM] Sending notification 'exit'.
Params: null

Here's the full parameter dump of the "initialize" message if it's any help: https://gist.github.com/4e1c2f67a1fae3a2148425944104b492