<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/62595>62595</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            LLDB 16.0.2: liblldbCore fails to link against curses
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          nikicoon
      </td>
    </tr>
</table>

<pre>
    ```
[ 87%] Building CXX object source/Plugins/Platform/MacOSX/CMakeFiles/lldbPluginPlatformMacOSX.dir/PlatformDarwin.cpp.o
[ 87%] Linking CXX executable ../../bin/lldb-server
[ 87%] Building CXX object source/Plugins/Process/minidump/CMakeFiles/lldbPluginProcessMinidump.dir/RegisterContextMinidump_x86_32.cpp.o
ld: ../../lib/liblldbCore.a(IOHandlerCursesGUI.cpp.o): undefined reference to symbol 'wattr_get'
ld: /usr/lib/libcurses.so.9: error adding symbols: DSO missing from command line
```

I'm in the process of updating the LLVM packages in pkgsrc on NetBSD to 16.0.2 from 15.0.7, and LLDB runs into the error above. I've tried adding something to have (-lcurses or -lncurses, depending on which curses is used) and -ledit in the linker phase for lldbCore and lldb-server.
We've found no solution with 2 people so far. We've tried something along those lines:
```
--- source/Core/CMakeLists.txt.orig     2023-04-19 03:08:51.000000000 +0200
+++ source/Core/CMakeLists.txt  2023-05-07 00:52:20.562536860 +0200
@@ -19,6 +19,24 @@
   endif()
 endif()
 
+set(LLDB_CURSES_LIB)
+set(LLDB_NCURSES_LIB)
+set(LLDB_LIBEDIT_LIB)
+set(LLDB_GPM_LIB)
+if (LLDB_ENABLE_CURSES)
+  if(CURSES_CURSES_LIBRARY AND NOT CURSES_NCURSES_LIBRARY)
+    list(APPEND LLDB_CURSES_LIB curses)
+ elseif(CURSES_NCURSES_LIBRARY AND NOT CURSES_CURSES_LIBRARY)
+ list(APPEND LLDB_NCURSES_LIB ncurses)
+  endif()
+ if(LLVM_ENABLE_TERMINFO)
+    list(APPEND LLDB_LIBEDIT_LIB edit)
+ endif()
+  if(LLVM_BUILD_STATIC)
+    list(APPEND LLDB_GPM_LIB gpm)
+  endif()
+endif()
+
 add_lldb_library(lldbCore
 Address.cpp
   AddressRange.cpp
@@ -87,6 +105,10 @@
 lldbPluginCPlusPlusLanguage
     lldbPluginObjCLanguage
 ${LLDB_CURSES_LIBS}
+    ${LLDB_CURSES_LIB}
+ ${LLDB_NCURSES_LIB}
+    ${LLDB_LIBEDIT_LIB}
+    ${LLDB_GPM_LIB}
 
   CLANG_LIBS
     clangDriver
```

```
--- tools/lldb-server/CMakeLists.txt.orig       2023-04-19 03:08:51.000000000 +0200
+++ tools/lldb-server/CMakeLists.txt    2023-05-07 01:31:43.068790470 +0200
@@ -37,6 +37,24 @@
   endif()
 endif()
 
+set(LLDB_CURSES_LIB)
+set(LLDB_NCURSES_LIB)
+set(LLDB_LIBEDIT_LIB)
+set(LLDB_GPM_LIB)
+if (LLDB_ENABLE_CURSES)
+  if(CURSES_CURSES_LIBRARY AND NOT CURSES_NCURSES_LIBRARY)
+    list(APPEND LLDB_CURSES_LIB curses)
+ elseif(CURSES_NCURSES_LIBRARY AND NOT CURSES_CURSES_LIBRARY)
+ list(APPEND LLDB_NCURSES_LIB ncurses)
+  endif()
+ if(LLVM_ENABLE_TERMINFO)
+    list(APPEND LLDB_LIBEDIT_LIB edit)
+ endif()
+  if(LLVM_BUILD_STATIC)
+    list(APPEND LLDB_GPM_LIB gpm)
+  endif()
+endif()
+
 add_lldb_tool(lldb-server
 Acceptor.cpp
     lldb-gdbserver.cpp
@@ -56,6 +74,10 @@
 lldbPluginInstructionMIPS64
       lldbPluginInstructionRISCV
 ${LLDB_SYSTEM_LIBS}
+      ${LLDB_CURSES_LIB}
+ ${LLDB_NCURSES_LIB}
+      ${LLDB_LIBEDIT_LIB}
+ ${LLDB_GPM_LIB}
 
     LINK_COMPONENTS
 Option
```

or this:
```
-+  if((CURSES_CURSES_LIBRARY) AND (NOT CURSES_NCURSES_LIBRARY))
++  if(CURSES_CURSES_LIBRARY AND NOT CURSES_NCURSES_LIBRARY)
 +    list(APPEND LLDB_CURSES_LIB curses)
-+ elseif((CURSES_NCURSES_LIBRARY) AND (NOT CURSES_CURSES_LIBRARY))
++ elseif(CURSES_NCURSES_LIBRARY AND NOT CURSES_CURSES_LIBRARY)
 + list(APPEND LLDB_NCURSES_LIB ncurses)
 +  endif()
```

and nothing brought us closer to a solution. LLDB is the last missing package to import the update in pkgsrc. How can we solve this?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWNty2rwWfhpxswaPkbExF1xw7M9sDpmQ_ru9YmRbNmqE5JHkJH37PfIBTAJJpu3dLkNdR_q0TlrrkxZEa5YJSkfInyB_1iGFOUg1EuyRxVKKTiSTnyMUuPXXnSF3jPwJhAOEfeTPYFIwnjCRwfTbN5DRDxob0LJQMUV4cceLjAldvhGTSnVEeLEm8Xb3DeHFdE0e6YJxagGcJ1EFb6AVzkmYaq2fEfXMhBPnuSOvWLNi4rExhr7QuDAk4hQcB-FF-YiYqJV1NVVPVP2GS0rGVNu3IxMsKY75Oz5V2HUNrJ26pxnThqqpFIa-mGZ2_xIGew-3neQJ8sYtNziLqqdVMZWKOgThcLn9h4iEUzUtlKb6y9dlLQMP7fJCJDRlgiagaEoVFTEFI0H_PEaSA8KDZ2KM2mfUIDxo60V4UWjVVhuXChwtnVIyVUoqIEkZtUqetuOz3RaOTGs7nCp5hFgej0QkwJmgdeRf5Vb5XCI8OAITYA4U8ip2IFMo8oQYK8yOr1b_riEn8SPJqLbg_DHTKgYpYEPNZDezzvUCx3VwpbznO64zQHgK1oTVajYBVQi71MhSYu1GJJ-oA9aGJwpGMZqcXJNHag6lARIO5IkCwmGXV9EAqaDLRfWH1ZLQnIpynRTwfGDxAWok01BomiA8LE3pcpow0_jLmXikCvID0RRSqaDZ4xLbSl2nCtZ_aWVpKguRgJCgJS8MszqZOQC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