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

Unexpected binary is None in liefldd.py #4787

Closed
2 tasks done
h-vetinari opened this issue Feb 26, 2023 · 15 comments · Fixed by #4900
Closed
2 tasks done

Unexpected binary is None in liefldd.py #4787

h-vetinari opened this issue Feb 26, 2023 · 15 comments · Fixed by #4900
Labels
backlog issue has been triaged but has not been earmarked for any upcoming release good first issue great for new contributors, code change is envisioned to be trivial/relatively straight-forward locked [bot] locked due to inactivity severity::2 critical; broken functionality with an unacceptably complex workaround source::community catch-all for issues filed by community members type::bug describes erroneous operation, use severity::* to classify the type

Comments

@h-vetinari
Copy link
Contributor

h-vetinari commented Feb 26, 2023

Checklist

  • I added a descriptive title
  • I searched open reports and couldn't find a duplicate

What happened?

With the last conda-smithy release, conda-forge is now back to using lief 0.12.3, and failing in conda-forge/compiler-rt-feedstock#61 with:

  File "/Users/runner/miniforge3/lib/python3.10/site-packages/conda_build/os_utils/liefldd.py", line 406, in inspect_linkages_lief
    if binary.format == lief.EXE_FORMATS.ELF:
AttributeError: 'NoneType' object has no attribute 'format'

Conda Info

conda-forge CI for osx-64 / osx-arm64

Conda Config

conda-forge CI for osx-64 / osx-arm64

Conda list

host env:

environment location: /Users/runner/miniforge3/conda-bld/compiler-rt-packages_1677355103841/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol


The following NEW packages will be INSTALLED:

    clang:           16.0.0.rc3-h9d310f0_0         conda-forge/label/llvm_rc
    clang-16:        16.0.0.rc3-default_h5b99a12_0 conda-forge/label/llvm_rc
    clang-format:    16.0.0.rc3-default_h5b99a12_0 conda-forge/label/llvm_rc
    clang-format-16: 16.0.0.rc3-default_h5b99a12_0 conda-forge/label/llvm_rc
    clang-tools:     16.0.0.rc3-default_h5b99a12_0 conda-forge/label/llvm_rc
    clangdev:        16.0.0.rc3-default_h5b99a12_0 conda-forge/label/llvm_rc
    clangxx:         16.0.0.rc3-default_h5b99a12_0 conda-forge/label/llvm_rc
    icu:             70.1-h96cf925_0               conda-forge              
    libclang:        16.0.0.rc3-default_h5b99a12_0 conda-forge/label/llvm_rc
    libclang-cpp:    16.0.0.rc3-default_h5b99a12_0 conda-forge/label/llvm_rc
    libclang-cpp16:  16.0.0.rc3-default_h5b99a12_0 conda-forge/label/llvm_rc
    libclang13:      16.0.0.rc3-default_h4e9855e_0 conda-forge/label/llvm_rc
    libcxx:          14.0.6-hccf4f1f_0             conda-forge              
    libiconv:        1.17-hac89ed1_0               conda-forge              
    libllvm16:       16.0.0.rc3-h8456b07_1         conda-forge/label/llvm_rc
    libxml2:         2.10.3-hb9e07b5_0             conda-forge              
    libzlib:         1.2.13-hfd90126_4             conda-forge              
    llvm-tools:      16.0.0.rc3-h8456b07_1         conda-forge/label/llvm_rc
    llvmdev:         16.0.0.rc3-h8456b07_1         conda-forge/label/llvm_rc
    xz:              5.2.6-h775f41a_0              conda-forge              
    zlib:            1.2.13-hfd90126_4             conda-forge              
    zstd:            1.5.2-hbc0c0cd_6              conda-forge 

build env:

  environment location: /Users/runner/miniforge3/conda-bld/compiler-rt-packages_1677355103841/_build_env

The following NEW packages will be INSTALLED:

    bzip2:                  1.0.8-h0d85af4_4          conda-forge
    c-ares:                 1.18.1-h0d85af4_0         conda-forge
    ca-certificates:        2022.12.7-h033912b_0      conda-forge
    clang_bootstrap_osx-64: 14.0.6-h6ddedbb_4         conda-forge
    cmake:                  3.25.2-h4032537_0         conda-forge
    expat:                  2.5.0-hf0c8a7f_0          conda-forge
    krb5:                   1.20.1-h049b76e_0         conda-forge
    libcurl:                7.88.1-h6df9250_0         conda-forge
    libcxx:                 14.0.6-hccf4f1f_0         conda-forge
    libedit:                3.1.20191231-h0678c8f_2   conda-forge
    libev:                  4.33-haf1e3a3_1           conda-forge
    libffi:                 3.4.2-h0d85af4_5          conda-forge
    libnghttp2:             1.51.0-he2ab024_0         conda-forge
    libsqlite:              3.40.0-ha978bb4_0         conda-forge
    libssh2:                1.10.0-h47af595_3         conda-forge
    libuv:                  1.44.2-hac89ed1_0         conda-forge
    libzlib:                1.2.13-hfd90126_4         conda-forge
    ncurses:                6.3-h96cf925_1            conda-forge
    ninja:                  1.11.1-hb8565cd_0         conda-forge
    openssl:                3.0.8-hfd90126_0          conda-forge
    python:                 3.11.0-he7542f4_1_cpython conda-forge
    readline:               8.1.2-h3899abd_0          conda-forge
    rhash:                  1.4.3-hac89ed1_0          conda-forge
    tk:                     8.6.12-h5dbffcc_0         conda-forge
    tzdata:                 2022g-h191b570_0          conda-forge
    xz:                     5.2.6-h775f41a_0          conda-forge
    zlib:                   1.2.13-hfd90126_4         conda-forge
    zstd:                   1.5.2-hbc0c0cd_6          conda-forge

Additional Context

Failing CI run here

@h-vetinari h-vetinari added the type::bug describes erroneous operation, use severity::* to classify the type label Feb 26, 2023
@1player
Copy link

1player commented Feb 28, 2023

Welp, just hit this as well, when it worked on Linux and Windows. Is it possible to work around it by downgrading to an earlier version of conda-build?

@travishathaway travishathaway added backlog issue has been triaged but has not been earmarked for any upcoming release good first issue great for new contributors, code change is envisioned to be trivial/relatively straight-forward labels Mar 15, 2023
@travishathaway
Copy link
Contributor

Hi @h-vetinari,

Thanks for filing this bug. I dug a little deeper on this, and it turns out our usage of this particular library in conda-build is a bit fragile. In my opinion, I think it's probably to time refactor https://github.com/conda/conda-build/blob/main/conda_build/os_utils/liefldd.py and reconsider the way we use the lief package as a dependency in that module.

I've added the https://github.com/conda/conda-build/labels/good-first-issue label because this could be a reasonable task for someone new to the repository. Otherwise, we unfortunately cannot promise when this will be addressed.

@travishathaway
Copy link
Contributor

@1player,

I don't think it's possible to work around this with an earlier version of conda-build. After viewing a git blame, I could see this code was added five years ago.

I think the work around fix for this is to somehow force install the version of lief that conda-build works with. I am currently not aware of which version this is though. This is a very undesirable route to go though, in my opinion.

@travishathaway travishathaway added the severity::2 critical; broken functionality with an unacceptably complex workaround label Mar 15, 2023
@h-vetinari
Copy link
Contributor Author

Looks like there's an upstream bug to track for this: lief-project/LIEF#873

@isuruf
Copy link
Contributor

isuruf commented Mar 16, 2023

The easiest way to work-around this would be to skip files ending with .a at

if not codefile_type(path):

Collecting of dependencies of .a static libraries have never worked and is not expected to work as they do not have dependency info on them.

@h-vetinari
Copy link
Contributor Author

Thanks a lot for the insight @isuruf! I opened a PR: #4808

@1player
Copy link

1player commented Mar 16, 2023

The easiest way to work-around this would be to skip files ending with .a at

if not codefile_type(path):

Collecting of dependencies of .a static libraries have never worked and is not expected to work as they do not have dependency info on them.

I don't think that's a good approach.

I've been hitting this issue because we are packaging LLVM, and it is crucial the clang_rt-builtins.a file is present in the final package as it is needed for LLVM users. This issue affects only macOS, because we have no issues on Linux and that .a file.

@h-vetinari
Copy link
Contributor Author

I think you misunderstand (or I do!)... This is not a question whether we package static libs (there are cases that are unavoidable, like compiler-builtins that you mention), but whether we run the lief-machinery on them that inspects the artefacts for their dependencies (and fails).

@1player
Copy link

1player commented Mar 31, 2023

Any update? We're stuck because we need to build compiler-rt, and there are two PR that fix this exact issue.

@travishathaway travishathaway changed the title BUG: unexpected binary is None in liefldd.py Unexpected binary is None in liefldd.py May 8, 2023
@travishathaway travishathaway added the source::community catch-all for issues filed by community members label May 8, 2023
@katietz
Copy link
Contributor

katietz commented May 24, 2023

yes, I agree. I ran into same issue with llvm/clang 16 building ... I patched lief/conda-build for it

@katietz
Copy link
Contributor

katietz commented May 24, 2023

I will share a PR with conda-build on the changes I made to it. In general it would be pretty good to have a switch in conda-build, which could be used to turn off the lief checks

@1player
Copy link

1player commented May 24, 2023 via email

@katietz
Copy link
Contributor

katietz commented May 25, 2023

I just read through them. I think they both fix the issue here in particular, but there might be a way to resolve it more generic.
Actually we should try to stop to run on something binary is 'NoneType' . But yes, looking and filtering out specific file-endings would be good.

Btw why this filtering of file-endings was removed anyway. IIRC there was such a feature in the past, and now we attempt to run over any files in PREFIX with a lot of noise

@katietz
Copy link
Contributor

katietz commented May 25, 2023

see as suggestion to fix this the pull 4900, which does this in a more general way

@h-vetinari
Copy link
Contributor Author

Doesn't hurt to link it: #4900

Fine by me, whatever gets this resolved, thanks! :)

@github-actions github-actions bot added the locked [bot] locked due to inactivity label Jun 6, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backlog issue has been triaged but has not been earmarked for any upcoming release good first issue great for new contributors, code change is envisioned to be trivial/relatively straight-forward locked [bot] locked due to inactivity severity::2 critical; broken functionality with an unacceptably complex workaround source::community catch-all for issues filed by community members type::bug describes erroneous operation, use severity::* to classify the type
Projects
Archived in project
5 participants