Skip to content

Commit

Permalink
(#22629) libdwarf: Add 0.9.0 and 0.9.1
Browse files Browse the repository at this point in the history
* Add libdwarf 0.9.0 and 0.9.1

* Correction for the test package

* Try to fix 0.9.0

* comment out remaining 0.9.1 references temporarily

* Patch off_t

* Try to get 0.9.1 good to go

* Update recipes/libdwarf/all/conanfile.py

Co-authored-by: Uilian Ries <uilianries@gmail.com>

* Remove libdwarf 20191104

* Handle dwarfdump license

* Update patches to use lowercasae zstd

---------

Co-authored-by: Uilian Ries <uilianries@gmail.com>
  • Loading branch information
jeremy-rifkin and uilianries authored Feb 19, 2024
1 parent e6d41d3 commit 04f9866
Show file tree
Hide file tree
Showing 8 changed files with 236 additions and 213 deletions.
21 changes: 14 additions & 7 deletions recipes/libdwarf/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
sources:
"0.9.1":
url: "https://github.com/davea42/libdwarf-code/archive/refs/tags/v0.9.1.tar.gz"
sha256: "6da3f46a9f92b4e284c97c733851879d9b91b16642bede90c7614860a946824e"
"0.9.0":
url: "https://github.com/davea42/libdwarf-code/archive/refs/tags/v0.9.0.tar.gz"
sha256: "6d4c0ee8a869e68dfeb15c99b869cafca7a5f715ecfc699cbf4fd30729b33226"
"0.8.0":
url: "https://github.com/davea42/libdwarf-code/archive/refs/tags/v0.8.0.tar.gz"
sha256: "8ef0dbfb0816b02aac97b87426689ebaa4efb8ec2ca2c759ea34c5e4678dff3f"
Expand All @@ -8,10 +14,15 @@ sources:
"0.5.0":
url: "https://www.prevanders.net/libdwarf-0.5.0.tar.xz"
sha256: "11fa822c60317fa00e1a01a2ac9e8388f6693e8662ab72d352c5f50c7e0112a9"
"20191104":
url: "https://www.prevanders.net/libdwarf-20191104.tar.gz"
sha256: "45f50a966314421b7dab525859853616df6c9680f0ccf2f44b030c505236eaba"
patches:
"0.9.1":
- patch_file: "patches/0.9.1-0001-fixes.patch"
patch_description: "fix DW_API definition and cmake"
patch_type: "portability"
"0.9.0":
- patch_file: "patches/0.9.0-0001-fixes.patch"
patch_description: "fix DW_API definition and cmake"
patch_type: "portability"
"0.8.0":
- patch_file: "patches/0.8.0-0001-fixes.patch"
patch_description: "fix DW_API definition and cmake"
Expand All @@ -30,7 +41,3 @@ patches:
- patch_file: "patches/0.5.0-0001-fix-DW_API.patch"
patch_description: "fix DW_API definition"
patch_type: "portability"
"20191104":
- patch_file: "patches/20191104-0001-patch.patch"
patch_description: "use cci package, remove lib64/bin64 install folders"
patch_type: "conan"
41 changes: 21 additions & 20 deletions recipes/libdwarf/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rmdir, rename
from conan.tools.build import cross_building
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.scm import Version
import os

required_conan_version = ">=1.53.0"

class LibdwarfConan(ConanFile):
name = "libdwarf"
description = "A library and a set of command-line tools for reading and writing DWARF2"
license = ("LGPL-2.1-only", "BSD-2-Clause-Views")
license = ("LGPL-2.1-only", "BSD-2-Clause-Views", "GPL-2.0-only")
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://www.prevanders.net/dwarf.html"
topics = ("debug", "dwarf", "dwarf2", "elf")
Expand All @@ -20,11 +21,13 @@ class LibdwarfConan(ConanFile):
"shared": [True, False],
"fPIC": [True, False],
"with_dwarfgen": [True, False],
"with_dwarfdump": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_dwarfgen": False,
"with_dwarfdump": False,
}

def export_sources(self):
Expand All @@ -41,15 +44,19 @@ def configure(self):
self.settings.rm_safe("compiler.cppstd")

if not self.options.with_dwarfgen:
self.license = "LGPL-2.1-only"
self.license = (l for l in self.license if l != "BSD-2-Clause-Views")
if not self.options.with_dwarfdump:
self.license = (l for l in self.license if l != "GPL-2.0-only")

def layout(self):
cmake_layout(self, src_folder="src")

def requirements(self):
if self.options.with_dwarfgen or self.version == "20191104":
if self.options.with_dwarfgen:
self.requires("libelf/0.8.13")
self.requires("zlib/[>=1.2.11 <2]")
if Version(self.version) >= Version("0.9.0"):
self.requires("zstd/1.5.5")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
Expand All @@ -60,6 +67,7 @@ def generate(self):
tc.variables["BUILD_NON_SHARED"] = not self.options.shared
tc.variables["BUILD_SHARED"] = self.options.shared
tc.variables["BUILD_DWARFGEN"] = self.options.with_dwarfgen
tc.variables["BUILD_DWARFDUMP"] = self.options.with_dwarfdump
tc.variables["BUILD_DWARFEXAMPLE"] = False
if cross_building(self):
tc.variables["HAVE_UNUSED_ATTRIBUTE_EXITCODE"] = "0"
Expand All @@ -76,20 +84,15 @@ def build(self):
cmake.build()

def package(self):
if self.version == "20191104":
copy(self, pattern="COPYING", dst=os.path.join(self.package_folder, "licenses"), src=os.path.join(self.source_folder, "libdwarf"))
rename(self, os.path.join(self.package_folder, "licenses", "COPYING"), os.path.join(self.package_folder, "licenses", "COPYING-libdwarf"))
if self.options.with_dwarfgen:
copy(self, pattern="COPYING", dst=os.path.join(self.package_folder, "licenses"), src=os.path.join(self.source_folder, "dwarfgen"))
rename(self, os.path.join(self.package_folder, "licenses", "COPYING"), os.path.join(self.package_folder, "licenses", "COPYING-dwarfgen"))
copy(self, pattern="COPYING", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
else:
copy(self, pattern="COPYING", dst=os.path.join(self.package_folder, "licenses"), src=os.path.join(self.source_folder, "src", "lib", "libdwarf"))
rename(self, os.path.join(self.package_folder, "licenses", "COPYING"), os.path.join(self.package_folder, "licenses", "COPYING-libdwarf"))
if self.options.with_dwarfgen:
copy(self, pattern="COPYING", dst=os.path.join(self.package_folder, "licenses"), src=os.path.join(self.source_folder, "src", "bin", "dwarfgen"))
rename(self, os.path.join(self.package_folder, "licenses", "COPYING"), os.path.join(self.package_folder, "licenses", "COPYING-dwarfgen"))
copy(self, pattern="COPYING", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
copy(self, pattern="COPYING", dst=os.path.join(self.package_folder, "licenses"), src=os.path.join(self.source_folder, "src", "lib", "libdwarf"))
rename(self, os.path.join(self.package_folder, "licenses", "COPYING"), os.path.join(self.package_folder, "licenses", "COPYING-libdwarf"))
if self.options.with_dwarfgen:
copy(self, pattern="COPYING", dst=os.path.join(self.package_folder, "licenses"), src=os.path.join(self.source_folder, "src", "bin", "dwarfgen"))
rename(self, os.path.join(self.package_folder, "licenses", "COPYING"), os.path.join(self.package_folder, "licenses", "COPYING-dwarfgen"))
if self.options.with_dwarfdump:
copy(self, pattern="GPL.txt", dst=os.path.join(self.package_folder, "licenses"), src=os.path.join(self.source_folder, "src", "bin", "dwarfdump"))
rename(self, os.path.join(self.package_folder, "licenses", "GPL.txt"), os.path.join(self.package_folder, "licenses", "COPYING-dwarfdump"))
copy(self, pattern="COPYING", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)

cmake = CMake(self)
cmake.install()
Expand All @@ -103,6 +106,4 @@ def package_info(self):
bindir = os.path.join(self.package_folder, "bin")
self.output.info(f'Appending PATH environment variable: {bindir}')
self.env_info.PATH.append(bindir)

if self.version != "20191104":
self.cpp_info.libs.append("dwarfp")
self.cpp_info.libs.append("dwarfp")
105 changes: 105 additions & 0 deletions recipes/libdwarf/all/patches/0.9.0-0001-fixes.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f444af27..5c9390d1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -181,14 +181,20 @@ endif()

# Zlib and ZSTD need to be found otherwise disable it
find_package(ZLIB)
-find_package(ZSTD)
-if (ZLIB_FOUND AND ZSTD_FOUND )
+find_package(zstd)
+if (ZLIB_FOUND AND zstd_FOUND )
set(HAVE_ZLIB TRUE)
set(HAVE_ZLIB_H TRUE)
set(HAVE_ZSTD TRUE)
set(HAVE_ZSTD_H TRUE)
endif()

+if(TARGET zstd::libzstd_shared)
+ set(ZSTD_LIB zstd::libzstd_shared)
+else()
+ set(ZSTD_LIB zstd::libzstd_static)
+endif()
+
message(STATUS "CMAKE_SIZEOF_VOID_P ... " ${CMAKE_SIZEOF_VOID_P} )

# DW_FWALLXX are gnu C++ options.
diff --git a/src/bin/dwarfdump/CMakeLists.txt b/src/bin/dwarfdump/CMakeLists.txt
index 6d2c328b..bc105813 100644
--- a/src/bin/dwarfdump/CMakeLists.txt
+++ b/src/bin/dwarfdump/CMakeLists.txt
@@ -68,7 +68,7 @@ target_compile_options(dwarfdump PRIVATE ${DW_FWALL})

target_link_libraries(dwarfdump PRIVATE dwarf)

-if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
+if(0)
set(SUFFIX 64)
endif()
set(LIBDIR lib${SUFFIX})
diff --git a/src/lib/libdwarf/CMakeLists.txt b/src/lib/libdwarf/CMakeLists.txt
index 4ad5c4fb..052208a1 100644
--- a/src/lib/libdwarf/CMakeLists.txt
+++ b/src/lib/libdwarf/CMakeLists.txt
@@ -107,11 +107,10 @@ target_include_directories(dwarf PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
-if(ZLIB_FOUND AND ZSTD_FOUND)
- target_link_libraries(dwarf PRIVATE ZLIB::ZLIB ZSTD::ZSTD )
+if(ZLIB_FOUND AND zstd_FOUND)
+ target_link_libraries(dwarf PRIVATE ZLIB::ZLIB ${ZSTD_LIB} )
endif()

-set(SUFFIX $<$<EQUAL:${CMAKE_SIZEOF_VOID_P},8>:64>)
set(LIBDIR lib${SUFFIX})
set(BINDIR bin${SUFFIX})

@@ -120,7 +119,7 @@ install(TARGETS dwarf
LIBRARY DESTINATION ${LIBDIR}
ARCHIVE DESTINATION ${LIBDIR})

-configure_file(libdwarf.pc.cmake libdwarf.pc @ONLY )
+# configure_file(libdwarf.pc.cmake libdwarf.pc @ONLY )

# The install has to be here, not in
# another CMakeLists.txt to make install work properly
@@ -145,6 +144,8 @@ install(
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/dwarf.h
DESTINATION include/libdwarf)
+if(0)
install( FILES ${PROJECT_BINARY_DIR}/src/lib/libdwarf/libdwarf.pc
DESTINATION lib/pkgconfig
)
+endif()
diff --git a/src/lib/libdwarf/libdwarf.h b/src/lib/libdwarf/libdwarf.h
index ed3d1d0b..91f2fd8b 100644
--- a/src/lib/libdwarf/libdwarf.h
+++ b/src/lib/libdwarf/libdwarf.h
@@ -51,7 +51,7 @@
#endif /* DW_API */

#ifndef LIBDWARF_STATIC
-# if defined(_WIN32) || defined(__CYGWIN__)
+# if defined(LIBDWARF_SHARED) && (defined(_WIN32) || defined(__CYGWIN__))
# ifdef LIBDWARF_BUILD
# define DW_API __declspec(dllexport)
# else /* !LIBDWARF_BUILD */
diff --git a/src/lib/libdwarf/libdwarf_private.h b/src/lib/libdwarf/libdwarf_private.h
index b37ae994..7fa89256 100644
--- a/src/lib/libdwarf/libdwarf_private.h
+++ b/src/lib/libdwarf/libdwarf_private.h
@@ -26,11 +26,7 @@
#ifdef _MSC_VER /* Macro to select VS compiler */
#include <windows.h>
typedef SSIZE_T ssize_t;
-#ifdef _WIN64
-typedef long long off_t;
-#else
typedef long off_t;
-#endif
#endif /* _MSC_VER */

#ifndef TRUE
86 changes: 86 additions & 0 deletions recipes/libdwarf/all/patches/0.9.1-0001-fixes.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 70839abd..972a2b9e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -188,14 +188,20 @@ if (ENABLE_DECOMPRESSION)
find_package(ZLIB)
endif()
if(NOT TARGET ZSTD::ZSTD)
- find_package(ZSTD)
+ find_package(zstd)
endif()
- if (ZLIB_FOUND AND ZSTD_FOUND )
+ if (ZLIB_FOUND AND zstd_FOUND )
set(HAVE_ZLIB TRUE)
set(HAVE_ZLIB_H TRUE)
set(HAVE_ZSTD TRUE)
set(HAVE_ZSTD_H TRUE)
endif()
+ find_package(zstd CONFIG REQUIRED)
+ if(TARGET zstd::libzstd_shared)
+ set(ZSTD_LIB zstd::libzstd_shared)
+ else()
+ set(ZSTD_LIB zstd::libzstd_static)
+ endif()
endif ()

message(STATUS "CMAKE_SIZEOF_VOID_P ... " ${CMAKE_SIZEOF_VOID_P} )
diff --git a/src/lib/libdwarf/CMakeLists.txt b/src/lib/libdwarf/CMakeLists.txt
index 7500c9f4..ce1461fb 100644
--- a/src/lib/libdwarf/CMakeLists.txt
+++ b/src/lib/libdwarf/CMakeLists.txt
@@ -104,8 +104,8 @@ target_include_directories(dwarf PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
-if(ZLIB_FOUND AND ZSTD_FOUND)
- target_link_libraries(dwarf PRIVATE ZLIB::ZLIB ZSTD::ZSTD )
+if(ZLIB_FOUND AND zstd_FOUND)
+ target_link_libraries(dwarf PRIVATE ZLIB::ZLIB ${ZSTD_LIB} )
endif()
set_target_properties(dwarf PROPERTIES PUBLIC_HEADER "libdwarf.h;dwarf.h")

@@ -116,7 +116,7 @@ install(TARGETS dwarf
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)

-configure_file(libdwarf.pc.cmake libdwarf.pc @ONLY)
+# configure_file(libdwarf.pc.cmake libdwarf.pc @ONLY)

# The install has to be here, not in
# another CMakeLists.txt to make install work properly
@@ -131,4 +131,4 @@ install(EXPORT libdwarfTargets
NAMESPACE libdwarf::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/libdwarf")
install(FILES cmake/libdwarf-config.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/libdwarf")
-install(FILES "${PROJECT_BINARY_DIR}/src/lib/libdwarf/libdwarf.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
+# install(FILES "${PROJECT_BINARY_DIR}/src/lib/libdwarf/libdwarf.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
diff --git a/src/lib/libdwarf/libdwarf.h b/src/lib/libdwarf/libdwarf.h
index 380d2ef7..8c62ee7e 100644
--- a/src/lib/libdwarf/libdwarf.h
+++ b/src/lib/libdwarf/libdwarf.h
@@ -51,7 +51,7 @@
#endif /* DW_API */

#ifndef LIBDWARF_STATIC
-# if defined(_WIN32) || defined(__CYGWIN__)
+# if defined(LIBDWARF_SHARED) && (defined(_WIN32) || defined(__CYGWIN__))
# ifdef LIBDWARF_BUILD
# define DW_API __declspec(dllexport)
# else /* !LIBDWARF_BUILD */
diff --git a/src/lib/libdwarf/libdwarf_private.h b/src/lib/libdwarf/libdwarf_private.h
index b37ae994..7fa89256 100644
--- a/src/lib/libdwarf/libdwarf_private.h
+++ b/src/lib/libdwarf/libdwarf_private.h
@@ -26,11 +26,7 @@
#ifdef _MSC_VER /* Macro to select VS compiler */
#include <windows.h>
typedef SSIZE_T ssize_t;
-#ifdef _WIN64
-typedef long long off_t;
-#else
typedef long off_t;
-#endif
#endif /* _MSC_VER */

#ifndef TRUE
Loading

0 comments on commit 04f9866

Please sign in to comment.