Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libdwarf: Add 0.9.0 and 0.9.1 #22629

Merged
merged 10 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 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 @@ -12,6 +18,14 @@ sources:
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 Down
6 changes: 6 additions & 0 deletions recipes/libdwarf/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
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"
Expand All @@ -20,11 +21,13 @@ class LibdwarfConan(ConanFile):
"shared": [True, False],
"fPIC": [True, False],
"with_dwarfgen": [True, False],
"with_dwarfdump": [True, False],
franramirez688 marked this conversation as resolved.
Show resolved Hide resolved
}
default_options = {
"shared": False,
"fPIC": True,
"with_dwarfgen": False,
"with_dwarfdump": False,
}

def export_sources(self):
Expand All @@ -50,6 +53,8 @@ def requirements(self):
if self.options.with_dwarfgen or self.version == "20191104":
self.requires("libelf/0.8.13")
self.requires("zlib/[>=1.2.11 <2]")
if self.version != "20191104" and Version(self.version) >= Version("0.9.0"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we might want to remove this 20191104 version by now if upstream is releasing official ones. Wdyt @uilianries?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please!!! 👍

@jeremy-rifkin Could you please remove the version 20191104 from config.yml, conandata.yml and update the conanfile.py as well? I know it's not related to this PR, but it would help a lot.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be my pleasure!

self.requires("zstd/1.5.5")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
Expand All @@ -60,6 +65,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 Down
93 changes: 93 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,93 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f444af27..b4124c19 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -189,6 +189,12 @@ if (ZLIB_FOUND AND ZSTD_FOUND )
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..65305211 100644
--- a/src/lib/libdwarf/CMakeLists.txt
+++ b/src/lib/libdwarf/CMakeLists.txt
@@ -108,10 +108,9 @@ target_include_directories(dwarf PUBLIC
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
if(ZLIB_FOUND AND ZSTD_FOUND)
- target_link_libraries(dwarf PRIVATE ZLIB::ZLIB ZSTD::ZSTD )
+ 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
77 changes: 77 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,77 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 70839abd..04b0f86f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -196,6 +196,12 @@ if (ENABLE_DECOMPRESSION)
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} )

# DW_FWALLXX are gnu C++ options.
diff --git a/src/lib/libdwarf/CMakeLists.txt b/src/lib/libdwarf/CMakeLists.txt
index 7500c9f4..2cb66e72 100644
--- a/src/lib/libdwarf/CMakeLists.txt
+++ b/src/lib/libdwarf/CMakeLists.txt
@@ -105,7 +105,7 @@ target_include_directories(dwarf PUBLIC
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
if(ZLIB_FOUND AND ZSTD_FOUND)
- target_link_libraries(dwarf PRIVATE ZLIB::ZLIB ZSTD::ZSTD )
+ 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
4 changes: 2 additions & 2 deletions recipes/libdwarf/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ find_package(libdwarf REQUIRED)
add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE libdwarf::libdwarf)

if(NOT libdwarf_VERSION MATCHES "^[0-9]*$")
target_compile_definitions(${PROJECT_NAME} PRIVATE "LIBDWARF_NEW_STRUCTURE")
if(NOT ${libdwarf_VERSION} MATCHES "^[0-9]*$" AND ${libdwarf_VERSION} VERSION_LESS "0.9.1")
target_compile_definitions(${PROJECT_NAME} PRIVATE "LIBDWARF_NESTED_INCLUDE")
endif()
8 changes: 4 additions & 4 deletions recipes/libdwarf/all/test_package/test_package.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#include <string.h>
#include <fcntl.h>

#ifndef LIBDWARF_NEW_STRUCTURE
#include "dwarf.h"
#include "libdwarf.h"
#else
#ifdef LIBDWARF_NESTED_INCLUDE
#include "libdwarf/dwarf.h"
#include "libdwarf/libdwarf.h"
#else
#include "dwarf.h"
#include "libdwarf.h"
#endif

void example1(Dwarf_Die somedie) {
Expand Down
4 changes: 4 additions & 0 deletions recipes/libdwarf/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
versions:
"0.9.1":
folder: all
"0.9.0":
folder: all
"0.8.0":
folder: all
"0.7.0":
Expand Down
Loading