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 for lief-project/LIEF #21213

Closed
wants to merge 52 commits into from

Conversation

BehroozAbbassi
Copy link

Describe the pull request
Adds the lief library into the vcpkg ports

  • What does your PR fix?

    Fixes #...

  • Which triplets are supported/not supported? Have you updated the CI baseline?

    all, No

  • Does your PR follow the maintainer guide?

    Yes

  • If you have added/updated a port: Have you run ./vcpkg x-add-version --all and committed the result?

    Yes

@ghost
Copy link

ghost commented Nov 5, 2021

CLA assistant check
All CLA requirements met.

@JonLiu1993 JonLiu1993 self-assigned this Nov 8, 2021
@JonLiu1993 JonLiu1993 added the category:new-port The issue is requesting a new library to be added; consider making a PR! label Nov 8, 2021
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

You have modified or added at least one portfile where deprecated functions are used.

If you feel able to do so, please consider migrating them to the new functions:
vcpkg_install_cmake -> vcpkg_cmake_install (from port vcpkg-cmake)
vcpkg_build_cmake -> vcpkg_cmake_build (from port vcpkg-cmake)
vcpkg_configure_cmake -> vcpkg_cmake_configure (Please remove the option PREFER_NINJA) (from port vcpkg-cmake)
vcpkg_fixup_cmake_targets -> vcpkg_cmake_config_fixup (from port vcpkg-cmake-config)

In the ports that use the new function, you have to add the corresponding dependencies:

{
  "name": "vcpkg-cmake",
  "host": true
},
{
  "name": "vcpkg-cmake-config",
  "host": true
}

The following files are affected:

  • ports/lief/portfile.cmake

@JonLiu1993
Copy link
Member

ports/lief/portfile.cmake Outdated Show resolved Hide resolved
ports/lief/portfile.cmake Outdated Show resolved Hide resolved
ports/lief/portfile.cmake Outdated Show resolved Hide resolved
ports/lief/portfile.cmake Outdated Show resolved Hide resolved
ports/lief/vcpkg.json Outdated Show resolved Hide resolved
ports/lief/vcpkg.json Outdated Show resolved Hide resolved
@JonLiu1993
Copy link
Member

BehroozAbbassi and others added 10 commits November 20, 2021 10:02
Co-authored-by: JonLiu1993 <63675417+JonLiu1993@users.noreply.github.com>
Co-authored-by: JonLiu1993 <63675417+JonLiu1993@users.noreply.github.com>
Co-authored-by: JonLiu1993 <63675417+JonLiu1993@users.noreply.github.com>
Co-authored-by: JonLiu1993 <63675417+JonLiu1993@users.noreply.github.com>
Co-authored-by: JonLiu1993 <63675417+JonLiu1993@users.noreply.github.com>
Co-authored-by: JonLiu1993 <63675417+JonLiu1993@users.noreply.github.com>
@BehroozAbbassi
Copy link
Author

@JonLiu1993 Sorry for the delay :(

I'm new to VCPKG contribution and just can't figure out how to fix this problem
how exactly should I add en expected error to the .\scripts\ci.baseline.txt ? manually or it has a command?

REGRESSION: lief:x64-linux. If expected, add lief:x64-linux=fail to .\scripts\ci.baseline.txt.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This is a new experimental fast check for PR issues. Please let us know if this bot is helpful!

PRs must add only one version and must not modify any published versions

When making any changes to a library, the version or port-version in vcpkg.json or CONTROL must be modified.

Error: Local changes detected for lief but no changes to version or port version.
-- Version: 0.11.5
-- Old SHA: dd5f8edc575f08ba78998380c7e31e06da8e3023
-- New SHA: ae2b26b210826c46e6fafcec2b3c1f808a73d2dd
-- Did you remember to update the version or port version?
-- Pass `--overwrite-version` to bypass this check.
***No files were updated.***

@JonLiu1993
Copy link
Member

JonLiu1993 commented Nov 22, 2021

@JonLiu1993 Sorry for the delay :(

I'm new to VCPKG contribution and just can't figure out how to fix this problem how exactly should I add en expected error to the .\scripts\ci.baseline.txt ? manually or it has a command?

REGRESSION: lief:x64-linux. If expected, add lief:x64-linux=fail to .\scripts\ci.baseline.txt.

This is not a modification suggestion for you, I run the command "./vcpkg x-add-version lief --overwrite-version " and commit again

@BehroozAbbassi
Copy link
Author

I really confused, I used the vcpkg_fail_port_install to indicate that library can't be build with the static-md triplet, so definitely there will be an error with this triplet!
how should I pass the CI with this error?

if ("${VCPKG_LIBRARY_LINKAGE}" STREQUAL "static" )
    if ("${VCPKG_CRT_LINKAGE}" STREQUAL "dynamic" )
        vcpkg_fail_port_install(MESSAGE "${PORT} doesn't support static-md" ALWAYS)
    endif()
endif()

error message in failure logs for x64-windows-static-md

CMake Error at scripts/cmake/vcpkg_fail_port_install.cmake:96 (message):
  lief doesn't support static-md

Call Stack (most recent call first):
  ports/lief/portfile.cmake:5 (vcpkg_fail_port_install)
  scripts/ports.cmake:142 (include)

@PhoebeHui
Copy link
Contributor

@BehroozAbbassi, You can add lief:x64-windows-static-md=fail to https://github.com/microsoft/vcpkg/blob/master/scripts/ci.baseline.txt.

@JonLiu1993
Copy link
Member

@BehroozAbbassi ,Have you tried phoebe's review suggestions?

@JonLiu1993
Copy link
Member

@BehroozAbbassi ,Ping for response

@JonLiu1993 JonLiu1993 added the info:reviewed Pull Request changes follow basic guidelines label Mar 17, 2022
ports/lief/portfile.cmake Outdated Show resolved Hide resolved
@JonLiu1993 JonLiu1993 added requires:author-response and removed info:reviewed Pull Request changes follow basic guidelines labels Mar 17, 2022
@JonLiu1993
Copy link
Member

@BehroozAbbassi , I tested again the feature on my local machine, but failed:

command: ./vcpkg install lief[*]

PS F:\Feature-test\lief\vcpkg> ./vcpkg install lief[*]
Computing installation plan...
A suitable version of cmake was not found (required v3.22.2). Downloading portable cmake v3.22.2...
Downloading cmake...
  https://github.com/Kitware/CMake/releases/download/v3.22.2/cmake-3.22.2-windows-i386.zip -> F:\Feature-test\lief\vcpkg\downloads\cmake-3.22.2-windows-i386.zip
Extracting cmake...
The following packages will be built and installed:
    lief[art,asan,c-api,core,coverage,dex,disable-frozen,doc,elf,enable-json,examples,extra-warnings,force32,fuzzing,install-python,logging,logging-debug,lsan,macho,oat,pe,profiling,python-api,shared-lib,tests,tsan,usan,use-ccache,vdex]:x86-windows -> 0.11.5
  * vcpkg-cmake[core]:x64-windows -> 2022-01-19
Additional packages (*) will be modified to complete this operation.
Detecting compiler hash for triplet x64-windows...
A suitable version of powershell-core was not found (required v7.2.1). Downloading portable powershell-core v7.2.1...
Downloading powershell-core...
  https://github.com/PowerShell/PowerShell/releases/download/v7.2.1/PowerShell-7.2.1-win-x86.zip -> F:\Feature-test\lief\vcpkg\downloads\PowerShell-7.2.1-win-x86.zip
Extracting powershell-core...
Detecting compiler hash for triplet x86-windows...
A suitable version of 7zip was not found (required v21.7.0). Downloading portable 7zip v21.7.0...
Downloading 7zip...
  https://www.7-zip.org/a/7z2107-extra.7z -> F:\Feature-test\lief\vcpkg\downloads\7z2107-extra.7z
Extracting 7zip...
Restored 1 packages from C:\Users\vzhli17\AppData\Local\vcpkg\archives in 1.794 s. Use --debug to see more details.
Starting package 1/2: vcpkg-cmake:x64-windows
Installing package vcpkg-cmake[core]:x64-windows...
Elapsed time for package vcpkg-cmake:x64-windows: 83.55 ms
Starting package 2/2: lief:x86-windows
Building package lief[art,asan,c-api,core,coverage,dex,disable-frozen,doc,elf,enable-json,examples,extra-warnings,force32,fuzzing,install-python,logging,logging-debug,lsan,macho,oat,pe,profiling,python-api,shared-lib,tests,tsan,usan,use-ccache,vdex]:x86-windows...
-- Downloading https://github.com/lief-project/LIEF/archive/551ede538abeca63a158bd7c42b6b6337c92a26e.tar.gz -> lief-project-LIEF-551ede538abeca63a158bd7c42b6b6337c92a26e.tar.gz...
-- Extracting source F:/Feature-test/lief/vcpkg/downloads/lief-project-LIEF-551ede538abeca63a158bd7c42b6b6337c92a26e.tar.gz
-- Applying patch install_dir.patch
-- Using source at F:/Feature-test/lief/vcpkg/buildtrees/lief/src/337c92a26e-0a88e6d460.clean
-- Found external ninja('1.10.2').
-- Configuring x86-windows
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:128 (message):
    Command failed: ninja -v
    Working Directory: F:/Feature-test/lief/vcpkg/buildtrees/lief/x86-windows-rel/vcpkg-parallel-configure
    Error code: 1
    See logs for more information:
      F:\Feature-test\lief\vcpkg\buildtrees\lief\config-x86-windows-out.log

Call Stack (most recent call first):
  installed/x64-windows/share/vcpkg-cmake/vcpkg_cmake_configure.cmake:415 (vcpkg_execute_required_process)
  ports/lief/portfile.cmake:70 (vcpkg_cmake_configure)
  scripts/ports.cmake:145 (include)


Error: Building package lief:x86-windows failed with: BUILD_FAILED
Please ensure you're using the latest portfiles with `git pull` and `.\vcpkg update`.
Then check for known issues at:
  https://github.com/microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+lief
You can submit a new issue at:
  https://github.com/microsoft/vcpkg/issues/new?template=report-package-build-failure.md&title=[lief]+Build+error
including:
  package: lief[art,asan,c-api,core,coverage,dex,disable-frozen,doc,elf,enable-json,examples,extra-warnings,force32,fuzzing,install-python,logging,logging-debug,lsan,macho,oat,pe,profiling,python-api,shared-lib,tests,tsan,usan,use-ccache,vdex]:x86-windows -> 0.11.5
    vcpkg-tool version: 2022-03-09-1affd32f93b299d5a907816c328ca3ededb73a7e
    vcpkg-scripts version: 2a0565e2c 2022-03-17 (12 hours ago)

Additionally, attach any relevant sections from the log files above.

F:\Feature-test\lief\vcpkg\buildtrees\lief\config-x86-windows-out.log

-- Undefined sanitizer enabled
CMake Error at CMakeLists.txt:454 (target_link_libraries):
  The keyword signature for target_link_libraries has already been used with
  the target "LIB_LIEF".  All uses of target_link_libraries with a target
  must be either all-keyword or all-plain.

  The uses of the keyword signature are here:

   * CMakeLists.txt:398 (target_link_libraries)
   * CMakeLists.txt:410 (target_link_libraries)
   * CMakeLists.txt:422 (target_link_libraries)
   * CMakeLists.txt:434 (target_link_libraries)

@BehroozAbbassi
Copy link
Author

@BehroozAbbassi , I tested again the feature on my local machine, but failed:

command: ./vcpkg install lief[*]

PS F:\Feature-test\lief\vcpkg> ./vcpkg install lief[*]
Computing installation plan...
A suitable version of cmake was not found (required v3.22.2). Downloading portable cmake v3.22.2...
Downloading cmake...
  https://github.com/Kitware/CMake/releases/download/v3.22.2/cmake-3.22.2-windows-i386.zip -> F:\Feature-test\lief\vcpkg\downloads\cmake-3.22.2-windows-i386.zip
Extracting cmake...
The following packages will be built and installed:
    lief[art,asan,c-api,core,coverage,dex,disable-frozen,doc,elf,enable-json,examples,extra-warnings,force32,fuzzing,install-python,logging,logging-debug,lsan,macho,oat,pe,profiling,python-api,shared-lib,tests,tsan,usan,use-ccache,vdex]:x86-windows -> 0.11.5
  * vcpkg-cmake[core]:x64-windows -> 2022-01-19
Additional packages (*) will be modified to complete this operation.
Detecting compiler hash for triplet x64-windows...
A suitable version of powershell-core was not found (required v7.2.1). Downloading portable powershell-core v7.2.1...
Downloading powershell-core...
  https://github.com/PowerShell/PowerShell/releases/download/v7.2.1/PowerShell-7.2.1-win-x86.zip -> F:\Feature-test\lief\vcpkg\downloads\PowerShell-7.2.1-win-x86.zip
Extracting powershell-core...
Detecting compiler hash for triplet x86-windows...
A suitable version of 7zip was not found (required v21.7.0). Downloading portable 7zip v21.7.0...
Downloading 7zip...
  https://www.7-zip.org/a/7z2107-extra.7z -> F:\Feature-test\lief\vcpkg\downloads\7z2107-extra.7z
Extracting 7zip...
Restored 1 packages from C:\Users\vzhli17\AppData\Local\vcpkg\archives in 1.794 s. Use --debug to see more details.
Starting package 1/2: vcpkg-cmake:x64-windows
Installing package vcpkg-cmake[core]:x64-windows...
Elapsed time for package vcpkg-cmake:x64-windows: 83.55 ms
Starting package 2/2: lief:x86-windows
Building package lief[art,asan,c-api,core,coverage,dex,disable-frozen,doc,elf,enable-json,examples,extra-warnings,force32,fuzzing,install-python,logging,logging-debug,lsan,macho,oat,pe,profiling,python-api,shared-lib,tests,tsan,usan,use-ccache,vdex]:x86-windows...
-- Downloading https://github.com/lief-project/LIEF/archive/551ede538abeca63a158bd7c42b6b6337c92a26e.tar.gz -> lief-project-LIEF-551ede538abeca63a158bd7c42b6b6337c92a26e.tar.gz...
-- Extracting source F:/Feature-test/lief/vcpkg/downloads/lief-project-LIEF-551ede538abeca63a158bd7c42b6b6337c92a26e.tar.gz
-- Applying patch install_dir.patch
-- Using source at F:/Feature-test/lief/vcpkg/buildtrees/lief/src/337c92a26e-0a88e6d460.clean
-- Found external ninja('1.10.2').
-- Configuring x86-windows
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:128 (message):
    Command failed: ninja -v
    Working Directory: F:/Feature-test/lief/vcpkg/buildtrees/lief/x86-windows-rel/vcpkg-parallel-configure
    Error code: 1
    See logs for more information:
      F:\Feature-test\lief\vcpkg\buildtrees\lief\config-x86-windows-out.log

Call Stack (most recent call first):
  installed/x64-windows/share/vcpkg-cmake/vcpkg_cmake_configure.cmake:415 (vcpkg_execute_required_process)
  ports/lief/portfile.cmake:70 (vcpkg_cmake_configure)
  scripts/ports.cmake:145 (include)


Error: Building package lief:x86-windows failed with: BUILD_FAILED
Please ensure you're using the latest portfiles with `git pull` and `.\vcpkg update`.
Then check for known issues at:
  https://github.com/microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+lief
You can submit a new issue at:
  https://github.com/microsoft/vcpkg/issues/new?template=report-package-build-failure.md&title=[lief]+Build+error
including:
  package: lief[art,asan,c-api,core,coverage,dex,disable-frozen,doc,elf,enable-json,examples,extra-warnings,force32,fuzzing,install-python,logging,logging-debug,lsan,macho,oat,pe,profiling,python-api,shared-lib,tests,tsan,usan,use-ccache,vdex]:x86-windows -> 0.11.5
    vcpkg-tool version: 2022-03-09-1affd32f93b299d5a907816c328ca3ededb73a7e
    vcpkg-scripts version: 2a0565e2c 2022-03-17 (12 hours ago)

Additionally, attach any relevant sections from the log files above.

F:\Feature-test\lief\vcpkg\buildtrees\lief\config-x86-windows-out.log

-- Undefined sanitizer enabled
CMake Error at CMakeLists.txt:454 (target_link_libraries):
  The keyword signature for target_link_libraries has already been used with
  the target "LIB_LIEF".  All uses of target_link_libraries with a target
  must be either all-keyword or all-plain.

  The uses of the keyword signature are here:

   * CMakeLists.txt:398 (target_link_libraries)
   * CMakeLists.txt:410 (target_link_libraries)
   * CMakeLists.txt:422 (target_link_libraries)
   * CMakeLists.txt:434 (target_link_libraries)

hmm
I've the same problem by lief[*], It's because of dependencies of some features, for instance the doc feature depends on doxygen and if cmake can't find the doxygen then build will fail.

But this one is related to sanitizers, I've no idea how to use them with MSVC and CMAKE. I'm not sure if it's an error with cmake script or trying to use sanitizers on windows, maybe the author of library could help here, @romainthomas any idea?

-- Undefined sanitizer enabled
CMake Error at CMakeLists.txt:454 (target_link_libraries):
  The keyword signature for target_link_libraries has already been used with
  the target "LIB_LIEF".  All uses of target_link_libraries with a target
  must be either all-keyword or all-plain.

  The uses of the keyword signature are here:

   * CMakeLists.txt:398 (target_link_libraries)
   * CMakeLists.txt:410 (target_link_libraries)
   * CMakeLists.txt:422 (target_link_libraries)
   * CMakeLists.txt:434 (target_link_libraries)

By the way I've this error even after I edit the portfile.cmake and disable sanitizers manually.

# Set them OFF after the "vcpkg_check_features"

set(LIEF_ASAN OFF)
set(LIEF_LSAN OFF)
set(LIEF_TSAN OFF)
set(LIEF_USAN OFF)

@JonLiu1993
Copy link
Member

@romainthomas, Could you please take a look?

@JonLiu1993 JonLiu1993 added depends:upstream-changes Waiting on a change to the upstream project and removed requires:author-response labels Mar 29, 2022
@romainthomas
Copy link

I'll check but the error seems weird

@romainthomas
Copy link

Maybe you should first try with the latest release (0.12.0) that contains CMake refactoring (cc @ekilmer)

@ekilmer
Copy link
Contributor

ekilmer commented Mar 30, 2022

the latest release (0.12.0) that contains CMake refactoring

I have a Draft PR for that here #22957 (initially forked from @BehroozAbbassi's branch). The main issue is mbedtls major version upgrade in vcpkg (more details in the OP of the PR). I also haven't merged the latest changes (mostly need to just double-check that non-default features still work/should be removed) from this branch.

If the mbedtls version can't be updated for LIEF, then maybe LIEF will need to live in a separate registry along with mbedtls v3.

I don't have time to work on anything this week, but anyone is free to fork my branch, make the necessary changes, and open a new PR, create a registry, whatever. Just let me know if #22957 should be closed in favor of something else!

@JackBoosY
Copy link
Contributor

Just disable feature doc would be okay.

@JonLiu1993 JonLiu1993 added depends:different-pr This PR or Issue depends on a PR which has been filed and removed depends:upstream-changes Waiting on a change to the upstream project labels May 11, 2022
@JonLiu1993
Copy link
Member

@BehroozAbbassi, Is there any progress this pr?

@JonLiu1993 JonLiu1993 removed the depends:different-pr This PR or Issue depends on a PR which has been filed label May 11, 2022
@JonLiu1993
Copy link
Member

Draft this PR until it has any progress.

@JonLiu1993
Copy link
Member

Closing this PR since it seems that no progress is being made. Please reopen if work is still being done.

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.

None yet

6 participants