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

[lief] add new port LIEF-0.16.0 #42374

Draft
wants to merge 84 commits into
base: master
Choose a base branch
from
Draft

Conversation

luadebug
Copy link
Contributor

@luadebug luadebug commented Nov 26, 2024

This PR tends to learn possibility of porting LIEF.

  • Build succeed cloning and building from src by MSVC toolchain.
  • Build succeed on local machine by vcpkg install.
  • Build succeed on Azure DevOps CI.
  • Tested locally x64-windows target.

Feel free to propose changes or change.

D:\b\lief\src\a347b80778-bfb5f1935f.clean\src\OAT\utils.cpp(107): error C2039: 'lower_bound': is not a member of 'std::unordered_map<LIEF::OAT::oat_version_t,LIEF::Android::ANDROID_VERSIONS,std::hash<uint32_t>,std::equal_to<uint32_t>,std::allocator<std::pair<const LIEF::OAT::oat_version_t,LIEF::Android::ANDROID_VERSIONS>>>'

lower_bound usage in code.
It should be frozen::map but not std::unordered_map I believe. So this approach should enforce frozen to be ON.
I tried to enforce frozen to be ON. It made some progress, but for now I do not understand logs.
For UWP or Windows shared library build

Asset cache hit for lief-project-LIEF-0d087c03936977cb7019d7ca52f761a347b80778.tar.gz; downloaded from: https://vcpkgassetcachewus.blob.core.windows.net/cache/b1c59a504cef4a300e6e5e788b87252ab4ff5f2c373170fcb4b91aaf4ac122733ab677684fa2e1a7ffcaacf9fc9ae061157aec4ff821e1f5306bdff1dcb7c630?*** SECRET ***
-- Extracting source D:/downloads/lief-project-LIEF-0d087c03936977cb7019d7ca52f761a347b80778.tar.gz
-- Using source at D:/b/lief/src/a347b80778-bfb5f1935f.clean
-- Found external ninja('1.11.0').
-- Configuring arm64-uwp
-- Building arm64-uwp-dbg
-- Building arm64-uwp-rel
-- Fixing pkgconfig file: D:/p/lief_arm64-uwp/lib/pkgconfig/LIEF.pc
Asset cache hit for msys2-mingw-w64-x86_64-pkgconf-1~2.3.0-1-any.pkg.tar.zst; downloaded from: https://vcpkgassetcachewus.blob.core.windows.net/cache/5373f050060678166968e09a4dd8ad30324c5dc37842c3517ebc9eb7be7e09d37d2873ff9dc4831c283556b68a0776f06fa6f91d799020b04282b4a3f378a2c4?*** SECRET ***
Asset cache hit for msys2-msys2-runtime-3.5.4-2-x86_64.pkg.tar.zst; downloaded from: https://vcpkgassetcachewus.blob.core.windows.net/cache/070aeb43385beb0e3f8d5fb28909469765116c222d53c2614f5f080be879eef0b78258334b35e8cda7625d8704efc89133f8b8fa78f309c5d680ae270efdaba8?*** SECRET ***
-- Using msys root at D:/downloads/tools/msys2/21caed2f81ec917b
-- Fixing pkgconfig file: D:/p/lief_arm64-uwp/debug/lib/pkgconfig/LIEF.pc
-- Installing: D:/p/lief_arm64-uwp/share/lief/copyright
-- Performing post-build validation
D:\a\_work\1\s\ports\lief\portfile.cmake: warning: The following dlls were found in ${CURRENT_PACKAGES_DIR}/lib or ${CURRENT_PACKAGES_DIR}/debug/lib. Please move them to ${CURRENT_PACKAGES_DIR}/bin or ${CURRENT_PACKAGES_DIR}/debug/bin, respectively.
D:\p\lief_arm64-uwp: note: the DLLs are relative to ${CURRENT_PACKAGES_DIR} here
note: debug/lib/LIEF.dll
note: lib/LIEF.dll
D:\a\_work\1\s\ports\lief\portfile.cmake: warning: Found 1 post-build check problem(s). These are usually caused by bugs in portfile.cmake or the upstream build system. Please correct these before submitting this port to the curated registry.

Most likely shared builds need some fix, but I honestly do not know how to fix them up so it wont conflict with vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/${PORT}") call.
During shared build.
vcpkg\installed\x86-windows\lib\LIEF.dll
Meanwhile no issue persist during static build.
vcpkg\installed\x86-windows-static\lib\LIEF.lib
For Linux

                 from /mnt/vcpkg-ci/b/lief/src/a347b80778-bfb5f1935f.clean/src/BinaryStream/BinaryStream.cpp:18:
/mnt/vcpkg-ci/installed/x64-linux/include/utf8cpp/utf8/checked.h: In instantiation of ‘octet_iterator utf8::append(utf8::utfchar32_t, octet_iterator) [with octet_iterator = std::back_insert_iterator<std::__cxx11::basic_string<char> >; utf8::utfchar32_t = char32_t]’:
/mnt/vcpkg-ci/installed/x64-linux/include/utf8cpp/utf8/checked.h:84:15:   required from here
/mnt/vcpkg-ci/installed/x64-linux/include/utf8cpp/utf8/checked.h:77:13: error: exception handling disabled, use ‘-fexceptions’ to enable
   77 |             throw invalid_code_point(cp);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
[15/308] /usr/bin/c++ -DJSON_HAS_CPP_11 -DJSON_NOEXCEPTION -DLIEF_STATIC -DSPDLOG_COMPILED_LIB -DSPDLOG_DISABLE_DEFAULT_LOGGER -DSPDLOG_FMT_EXTERNAL -DSPDLOG_FUNCTION="" -DSPDLOG_NO_EXCEPTIONS -D_GLIBCXX_USE_CXX11_ABI=1 -I/mnt/vcpkg-ci/b/lief/src/a347b80778-bfb5f1935f.clean/include -I/mnt/vcpkg-ci/b/lief/src/a347b80778-bfb5f1935f.clean/api/c/include -I/mnt/vcpkg-ci/b/lief/x64-linux-dbg/include -I/mnt/vcpkg-ci/b/lief/src/a347b80778-bfb5f1935f.clean/src -I/mnt/vcpkg-ci/b/lief/x64-linux-dbg -isystem /mnt/vcpkg-ci/installed/x64-linux/include -isystem /mnt/vcpkg-ci/installed/x64-linux/share -isystem /mnt/vcpkg-ci/installed/x64-linux/include/utf8cpp -fPIC -g -std=gnu++17 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -Wall -Wextra -Wpedantic -Wno-expansion-to-defined -Werror=return-type -fdiagnostics-color=always -fno-exceptions -MD -MT CMakeFiles/LIB_LIEF.dir/src/BinaryStream/MemoryStream.cpp.o -MF CMakeFiles/LIB_LIEF.dir/src/BinaryStream/MemoryStream.cpp.o.d -o CMakeFiles/LIB_LIEF.dir/src/BinaryStream/MemoryStream.cpp.o -c /mnt/vcpkg-ci/b/lief/src/a347b80778-bfb5f1935f.clean/src/BinaryStream/MemoryStream.cpp
[16/308] /usr/bin/c++ -DJSON_HAS_CPP_11 -DJSON_NOEXCEPTION -DLIEF_STATIC -DSPDLOG_COMPILED_LIB -DSPDLOG_DISABLE_DEFAULT_LOGGER -DSPDLOG_FMT_EXTERNAL -DSPDLOG_FUNCTION="" -DSPDLOG_NO_EXCEPTIONS -D_GLIBCXX_USE_CXX11_ABI=1 -I/mnt/vcpkg-ci/b/lief/src/a347b80778-bfb5f1935f.clean/include -I/mnt/vcpkg-ci/b/lief/src/a347b80778-bfb5f1935f.clean/api/c/include -I/mnt/vcpkg-ci/b/lief/x64-linux-dbg/include -I/mnt/vcpkg-ci/b/lief/src/a347b80778-bfb5f1935f.clean/src -I/mnt/vcpkg-ci/b/lief/x64-linux-dbg -isystem /mnt/vcpkg-ci/installed/x64-linux/include -isystem /mnt/vcpkg-ci/installed/x64-linux/share -isystem /mnt/vcpkg-ci/installed/x64-linux/include/utf8cpp -fPIC -g -std=gnu++17 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -Wall -Wextra -Wpedantic -Wno-expansion-to-defined -Werror=return-type -fdiagnostics-color=always -fno-exceptions -MD -MT CMakeFiles/LIB_LIEF.dir/src/utils.cpp.o -MF CMakeFiles/LIB_LIEF.dir/src/utils.cpp.o.d -o CMakeFiles/LIB_LIEF.dir/src/utils.cpp.o -c /mnt/vcpkg-ci/b/lief/src/a347b80778-bfb5f1935f.clean/src/utils.cpp
FAILED: CMakeFiles/LIB_LIEF.dir/src/utils.cpp.o 
/usr/bin/c++ -DJSON_HAS_CPP_11 -DJSON_NOEXCEPTION -DLIEF_STATIC -DSPDLOG_COMPILED_LIB -DSPDLOG_DISABLE_DEFAULT_LOGGER -DSPDLOG_FMT_EXTERNAL -DSPDLOG_FUNCTION="" -DSPDLOG_NO_EXCEPTIONS -D_GLIBCXX_USE_CXX11_ABI=1 -I/mnt/vcpkg-ci/b/lief/src/a347b80778-bfb5f1935f.clean/include -I/mnt/vcpkg-ci/b/lief/src/a347b80778-bfb5f1935f.clean/api/c/include -I/mnt/vcpkg-ci/b/lief/x64-linux-dbg/include -I/mnt/vcpkg-ci/b/lief/src/a347b80778-bfb5f1935f.clean/src -I/mnt/vcpkg-ci/b/lief/x64-linux-dbg -isystem /mnt/vcpkg-ci/installed/x64-linux/include -isystem /mnt/vcpkg-ci/installed/x64-linux/share -isystem /mnt/vcpkg-ci/installed/x64-linux/include/utf8cpp -fPIC -g -std=gnu++17 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -Wall -Wextra -Wpedantic -Wno-expansion-to-defined -Werror=return-type -fdiagnostics-color=always -fno-exceptions -MD -MT CMakeFiles/LIB_LIEF.dir/src/utils.cpp.o -MF CMakeFiles/LIB_LIEF.dir/src/utils.cpp.o.d -o CMakeFiles/LIB_LIEF.dir/src/utils.cpp.o -c /mnt/vcpkg-ci/b/lief/src/a347b80778-bfb5f1935f.clean/src/utils.cpp
In file included from /mnt/vcpkg-ci/installed/x64-linux/include/utf8cpp/utf8.h:43,
                 from /mnt/vcpkg-ci/b/lief/src/a347b80778-bfb5f1935f.clean/src/utils.cpp:26:
/mnt/vcpkg-ci/installed/x64-linux/include/utf8cpp/utf8/checked.h: In instantiation of ‘octet_iterator utf8::append(utf8::utfchar32_t, octet_iterator) [with octet_iterator = std::back_insert_iterator<std::__cxx11::basic_string<char> >; utf8::utfchar32_t = char32_t]’:
/mnt/vcpkg-ci/installed/x64-linux/include/utf8cpp/utf8/checked.h:84:15:   required from here
/mnt/vcpkg-ci/installed/x64-linux/include/utf8cpp/utf8/checked.h:77:13: error: exception handling disabled, use ‘-fexceptions’ to enable
   77 |             throw invalid_code_point(cp);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

So this approach should enforce Exceptions to be ON.

Still yet I can't find IMPLIB.

D:\zzzz\vcpkg\ports\lief\portfile.cmake: warning: Import libraries for installed DLLs appear to be missing. If this is intended, add set(VCPKG_POLICY_DLLS_WITHOUT_LIBS enabled)
D:\zzzz\vcpkg\ports\lief\portfile.cmake: warning: Found 1 post-build check problem(s). These are usually caused by bugs in portfile.cmake or the upstream build system. Please correct these before submitting this port to the curated registry.

Yet doing

vcpkg_replace_string("${SOURCE_PATH}/CMakeLists.txt"
    "ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}"
    "ARCHIVE DESTINATION lib"
)

Just placed IMPLIB into liblib, so I could store & use it. vcpkg_cmake_config_fixup still yet does not find moved files, so I helped it to find files & use them.

@luadebug luadebug marked this pull request as draft November 26, 2024 23:37
@WangWeiLin-MV WangWeiLin-MV added the category:new-port The issue is requesting a new library to be added; consider making a PR! label Nov 27, 2024
@WangWeiLin-MV WangWeiLin-MV changed the title TEST Lief-0.15.1-dev [lief] TEST Lief-0.15.1-dev Nov 27, 2024
@luadebug luadebug marked this pull request as ready for review November 28, 2024 03:41
@luadebug
Copy link
Contributor Author

luadebug commented Dec 6, 2024

Hi @everyone

Two important information:

  1. The release of LIEF 0.16.0 is scheduled for next week.
  2. The portal to download LIEF Python extended packages is now available to everyone (no longer need approval): https://extended.lief.re

There is some chance that LIEF going to push new tag on next week, so I'll draft PR & trying to retarget over 0.16 release once it's been pushed over.

@luadebug luadebug marked this pull request as draft December 7, 2024 12:57
@luadebug luadebug changed the title [lief] add new port LIEF-0.15.1-dev [lief] add new port LIEF-0.16.0 Dec 10, 2024
@luadebug luadebug marked this pull request as ready for review December 10, 2024 15:57
versions/l-/lief.json Outdated Show resolved Hide resolved
},
"objc": {
"description": "Build LIEF with ObjC metadata support",
"supports": "!(windows & !static)"
Copy link
Contributor Author

@luadebug luadebug Dec 10, 2024

Choose a reason for hiding this comment

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

Yet extended features wont work for Windows/UWP Shared
https://lief.re/doc/latest/extended/intro.html

@WangWeiLin-MV
Copy link
Contributor

Note: I will be converting your PR to draft status. Please feel free to mark 'Ready for review' when it's working and you're happy with it.

@WangWeiLin-MV WangWeiLin-MV marked this pull request as draft December 11, 2024 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:new-port The issue is requesting a new library to be added; consider making a PR!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants