Page MenuHomePhabricator

Fix NetBSD build with CMake 3.5.2
ClosedPublic

Authored by krytarowski on Apr 28 2016, 1:24 PM.

Details

Summary

Building HEAD of LLDB fails in linking against DebugInfoPDB. It also prints the following warning:

CMake Warning (dev) in source/Plugins/SymbolFile/PDB/CMakeLists.txt:
  Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link
  interface.  Run "cmake --help-policy CMP0022" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  Target "lldbPluginSymbolFilePDB" has an INTERFACE_LINK_LIBRARIES property.
  This should be preferred as the source of the link interface for this
  library but because CMP0022 is not set CMake is ignoring the property and
  using the link implementation as the link interface instead.

  INTERFACE_LINK_LIBRARIES:

    LLVMDebugInfoPDB

  Link implementation:

    (empty)

CMP0022 was introduced in CMake-2.8.11, bump minimal required version from 2.8 to 3.0 to gain more useful features like libexecinfo(3) detection on NetBSD.

Diff Detail

Repository
rL LLVM

Event Timeline

krytarowski retitled this revision from to Fix NetBSD build with CMake 3.5.2.
krytarowski updated this object.
krytarowski added reviewers: emaste, labath, clayborg.
krytarowski set the repository for this revision to rL LLVM.
krytarowski added a subscriber: joerg.

cmake 2.8 is still widely used (Ubuntu 14.04 LTS for one, but there are people around using even longer lived versions of RedHat). I don't think we should bump the version over a tiny detail like this. I'm pretty sure there is a way to rewrite the target rules to be compatible with both cmake 2.8 and 3+. Adding zachary for more insight.

A couple of other random thoughts:

  • LLVM specifies the minimum version as 2.8.12.2. I think it's safe to go up to that point. Would that make any difference in this case?
  • For the NetBSD target, I think you are free to choose whichever minimal version of cmake you like (although I would suggest to not go too far). However, you still need to make sure the build works with cmake 2.8 for others. Is it possible to fix your libexecinfo problem by conditionally changing the minimum version, or setting setting some policy?
labath requested changes to this revision.Apr 29 2016, 1:39 AM
labath edited edge metadata.
This revision now requires changes to proceed.Apr 29 2016, 1:39 AM
zturner edited edge metadata.Apr 29 2016, 7:24 AM
zturner added a subscriber: zturner.

Agree, the build should work with 2.8.12, but feel free to take advantage
of newer cmake features if they're present

clayborg resigned from this revision.Apr 29 2016, 10:55 AM
clayborg removed a reviewer: clayborg.

I will the unix / cmake experts make the decision here.

I had this working with 2.8:

--- source/Plugins/SymbolFile/PDB/CMakeLists.txt.orig   2016-04-27 00:55:50.000000000 +0000
+++ source/Plugins/SymbolFile/PDB/CMakeLists.txt
@@ -1,7 +1,11 @@
-set(LLVM_PRIVATE_LINK_COMPONENTS
-    DebugInfoPDB)
+#set(LLVM_PRIVATE_LINK_COMPONENTS
+#    DebugInfoPDB)
 
 add_lldb_library(lldbPluginSymbolFilePDB
   PDBASTParser.cpp
   SymbolFilePDB.cpp
   )
+
+target_link_libraries(lldbPluginSymbolFilePDB
+LINK_PRIVATE
+LLVMDebugInfoPDB)

I'm going to test build lldb with 2.8.12.2.

I don't think we should be adding more CMake hacks in lldb when llvm is
supposed to handle this. Why don't the existing lines work?

krytarowski added a comment.EditedApr 30 2016, 4:52 PM

I don't think we should be adding more CMake hacks in lldb when llvm is
supposed to handle this. Why don't the existing lines work?

I don't know. Perhaps LLVM and Clang require newer cmake than 2.8.11.

I tested locally with setting the minimal required version to 2.8.12.2 and LLDB builds.

krytarowski edited edge metadata.

Set minimal required CMake to 2.8.12.2 - fixes build on NetBSD with CMake 3.5.2

Can't you just remove that line and let it inherit the minimum version from
LLVM?

Can't you just remove that line and let it inherit the minimum version from
LLVM?

It doesn't work.

CMake Warning (dev) in CMakeLists.txt:
  No cmake_minimum_required command is present.  A line of code such as

    cmake_minimum_required(VERSION 3.5)

  should be added at the top of the file.  The version specified may be lower
  if you wish to support older CMake versions for this project.  For more
  information run "cmake --help-policy CMP0000".
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring done
CMake Warning (dev) at /usr/pkg/lib/cmake/llvm/AddLLVM.cmake:403 (add_library):
  Policy CMP0003 should be set before this line.  Add code such as

    if(COMMAND cmake_policy)
      cmake_policy(SET CMP0003 NEW)
    endif(COMMAND cmake_policy)

  as early as possible but after the most recent call to
  cmake_minimum_required or cmake_policy(VERSION).  This warning appears
  because target "liblldb" links to some libraries for which the linker must
  search:

    edit, execinfo, kvm, rt, terminfo, pthread, z, m, execinfo

  and other libraries with known full path:

    /tmp/pkgsrc-tmp/wip/lldb-git/work/build/lib/liblldbBase.a
    /usr/lib/libcurses.so
    /tmp/pkgsrc-tmp/wip/lldb-git/work/.buildlink/lib/libpython2.7.so

  CMake is adding directories in the second list to the linker search path in
  case they are needed to find libraries from the first list (for backwards
  compatibility with CMake 2.4).  Set policy CMP0003 to OLD or NEW to enable
  or disable this behavior explicitly.  Run "cmake --help-policy CMP0003" for
  more information.
Call Stack (most recent call first):
  cmake/modules/AddLLDB.cmake:59 (llvm_add_library)
  source/API/CMakeLists.txt:9 (add_lldb_library)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning at /usr/pkg/lib/cmake/llvm/AddLLVM.cmake:403 (add_library):
  Cannot generate a safe linker search path for target liblldb because files
  in some directories may conflict with libraries in implicit directories:

    link library [libform.so] in /usr/lib may be hidden by files in:
      /usr/pkg/lib

  Some of these libraries may not be found correctly.
Call Stack (most recent call first):
  cmake/modules/AddLLDB.cmake:59 (llvm_add_library)
  source/API/CMakeLists.txt:9 (add_lldb_library)


CMake Warning at /usr/pkg/lib/cmake/llvm/AddLLVM.cmake:636 (add_executable):
  Cannot generate a safe linker search path for target lldb-server because
  files in some directories may conflict with libraries in implicit
  directories:

    link library [libform.so] in /usr/lib may be hidden by files in:
      /usr/pkg/lib

and many similar warnings...

Ahh ok. Well setting it to 2.8.12 is still fine, if that fixes the problem
with no other changes then that seems like the best fix.

Ahh ok. Well setting it to 2.8.12 is still fine, if that fixes the problem
with no other changes then that seems like the best fix.

No other changes are needed.

labath accepted this revision.May 1 2016, 12:39 AM
labath edited edge metadata.

I like this solution.

This revision is now accepted and ready to land.May 1 2016, 12:39 AM

Thanks, since it has been accepted. I will commit it and move to LLDBStandalone.

krytarowski closed this revision.May 1 2016, 3:29 AM