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

[bug] settings_target no longer exists for toolchain packages in compatible-binary mode #14823

Closed
DoDoENT opened this issue Sep 26, 2023 · 1 comment · Fixed by #14825
Closed

Comments

@DoDoENT
Copy link
Contributor

DoDoENT commented Sep 26, 2023

Environment details

  • Operating System+version: Linux
  • Compiler+version: clang 16.0.5
  • Conan version: 2.0.11
  • Python version: 3.11.3

Steps to reproduce

I have a package based on android-ndk package from conan-center. The difference is that my package additionally in its package_info method that defines some additional flags for the target system, based on the target. Most importantly, it uses self.settings_target.get_safe('') function.

On Linux, I'm having a distinction between two different architectures: x86_64 and x86_64_haswell, and the global compatibility method is defined to allow running x86_64 on x86_64_haswell machines, but not vice versa:

def compatibility(conanfile):
    """Haswell CPUs can run generic x64 binaries, but not vice versa"""
    result = []
    arch = conanfile.settings.get_safe('arch')
    if arch == 'x86_64_haswell':
        result.append({'settings': [('arch', 'x86_64')]})
    return result

My android_ndk package is built for x86_64 architecture, as this is the arch that the official NDK distribution is built for.

Now, if I run conan install --tool-requires android_ndk/r25c@company/main -pr android-profile -pr:b haswell-profile, it works correctly with conan 2.0.10, but fails on conan 2.0.11.

Here is the output on 2.0.10, where it works:

$ conan install --tool-requires android_ndk/r25c@microblink/main -pr android-ndk-base -s arch=armv8 -of ./ -s:b arch=x86_64_haswell

======== Input profiles ========
Profile host:
[settings]
arch=armv8
build_type=Release
compiler=clang
compiler.libcxx=c++_static
compiler.libcxx.version=2
os=Android
os.api_level=19
[conf]
tools.cmake.cmake_layout:build_folder_vars=['settings.os', 'settings.os.sdk', 'settings.arch', 'settings.compiler', 'settings.compiler.version', 'settings.compiler.sanitizers', 'settings.compiler.link_time_optimization']
tools.files.download:retry=25
tools.files.download:retry_wait=2
tools.cmake.cmaketoolchain:generator=Ninja

Profile build:
[settings]
arch=x86_64_haswell
build_type=Release
compiler=clang
compiler.libcxx=libc++v2
compiler.version=16.0.5
os=Linux
[tool_requires]
*: mb_foundation/1.0.0@microblink/main
[conf]
tools.cmake.cmake_layout:build_folder_vars=['settings.os', 'settings.os.sdk', 'settings.arch', 'settings.compiler', 'settings.compiler.version', 'settings.compiler.sanitizers', 'settings.compiler.link_time_optimization']
tools.files.download:retry=25
tools.files.download:retry_wait=2
tools.cmake.cmaketoolchain:generator=Ninja
tools.build:compiler_executables={'c': '/usr/bin/clang', 'cpp': '/usr/bin/clang++'}
tools.cmake.cmaketoolchain:system_name=Linux
tools.cmake.cmaketoolchain:system_processor=x86_64
tools.gnu:host_triplet=x86_64-pc-linux-gnu
tools.build:cflags=['-mavx', '-march=haswell', '-mtune=haswell', '-mavx2']
tools.build:cxxflags=['-mavx', '-march=haswell', '-mtune=haswell', '-mavx2']
tools.build:sharedlinkflags=['-Wl,-rpath,/usr/local/lib/x86_64-unknown-linux-gnu']
tools.build:exelinkflags=['-Wl,-rpath,/usr/local/lib/x86_64-unknown-linux-gnu']


======== Computing dependency graph ========
Graph root
    cli
Build requirements
    android_ndk/r25c@microblink/main#937ed38bb07ccdabf6f621fe7e5dff4f - Cache
    mb_foundation/1.0.0@microblink/main#35c07845b5016aa7915b8d7df86ae8b9 - Cache

======== Computing necessary packages ========
android_ndk/r25c@microblink/main: Checking 1 compatible configurations:
android_ndk/r25c@microblink/main: '63fead0844576fc02943e16909f08fcdddd6f44b':
android_ndk/r25c@microblink/main: Main binary package 'f8da2d2d1af868e90384529932ffe9297cc1e8d7' missing. Using compatible package '63fead0844576fc02943e16909f08fcdddd6f44b'
Build requirements
    android_ndk/r25c@microblink/main#937ed38bb07ccdabf6f621fe7e5dff4f:63fead0844576fc02943e16909f08fcdddd6f44b#0ef88b189bb24d2bcd77ae5de1a8a4f4 - Cache
Skipped binaries
    mb_foundation/1.0.0@microblink/main

======== Installing packages ========
android_ndk/r25c@microblink/main: Already installed! (1 of 1)
android_ndk/r25c@microblink/main: Creating CC environment variable: /home/dodo/.conan2/p/androf682ffe8097f5/p/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android19-clang
android_ndk/r25c@microblink/main: Creating CXX environment variable: /home/dodo/.conan2/p/androf682ffe8097f5/p/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android19-clang++
android_ndk/r25c@microblink/main: Creating LD environment variable: /home/dodo/.conan2/p/androf682ffe8097f5/p/toolchains/llvm/prebuilt/linux-x86_64/bin/ld
android_ndk/r25c@microblink/main: Creating AR environment variable: /home/dodo/.conan2/p/androf682ffe8097f5/p/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar
android_ndk/r25c@microblink/main: Creating AS environment variable: /home/dodo/.conan2/p/androf682ffe8097f5/p/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-as
android_ndk/r25c@microblink/main: Creating RANLIB environment variable: /home/dodo/.conan2/p/androf682ffe8097f5/p/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib
android_ndk/r25c@microblink/main: Creating STRIP environment variable: /home/dodo/.conan2/p/androf682ffe8097f5/p/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip
android_ndk/r25c@microblink/main: Creating ADDR2LINE environment variable: /home/dodo/.conan2/p/androf682ffe8097f5/p/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-addr2line
android_ndk/r25c@microblink/main: Creating NM environment variable: /home/dodo/.conan2/p/androf682ffe8097f5/p/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-nm
android_ndk/r25c@microblink/main: Creating OBJCOPY environment variable: /home/dodo/.conan2/p/androf682ffe8097f5/p/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-objcopy
android_ndk/r25c@microblink/main: Creating OBJDUMP environment variable: /home/dodo/.conan2/p/androf682ffe8097f5/p/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-objdump
android_ndk/r25c@microblink/main: Creating READELF environment variable: /home/dodo/.conan2/p/androf682ffe8097f5/p/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-readelf

======== Finalizing install (deploy, generators) ========
cli: Generating aggregated env files
cli: Generated aggregated env files: ['conanbuild.sh', 'conanrun.sh']
Install finished successfully

And, the same command with conan 2.0.11:

$ conan install --tool-requires android_ndk/r25c@microblink/main -pr android-ndk-base -s arch=armv8 -of ./ -s:b arch=x86_64_haswell                                              12:26:05 [13/13]

======== Input profiles ========
Profile host:
[settings]
arch=armv8
build_type=Release
compiler=clang
compiler.libcxx=c++_static
compiler.libcxx.version=2
os=Android
os.api_level=19
[conf]
tools.cmake.cmake_layout:build_folder_vars=['settings.os', 'settings.os.sdk', 'settings.arch', 'settings.compiler', 'settings.compiler.version', 'settings.compiler.sanitizers', 'settings.compiler.link_time_optimization']
tools.files.download:retry=25
tools.files.download:retry_wait=2
tools.cmake.cmaketoolchain:generator=Ninja

Profile build:
[settings]
arch=x86_64_haswell
build_type=Release
compiler=clang
compiler.libcxx=libc++v2
compiler.version=16.0.5
os=Linux
[tool_requires]
*: mb_foundation/1.0.0@microblink/main
[conf]
tools.cmake.cmake_layout:build_folder_vars=['settings.os', 'settings.os.sdk', 'settings.arch', 'settings.compiler', 'settings.compiler.version', 'settings.compiler.sanitizers', 'settings.compiler.link_time_optimization']
tools.files.download:retry=25
tools.files.download:retry_wait=2
tools.cmake.cmaketoolchain:generator=Ninja
tools.build:compiler_executables={'c': '/usr/bin/clang', 'cpp': '/usr/bin/clang++'}
tools.cmake.cmaketoolchain:system_name=Linux
tools.cmake.cmaketoolchain:system_processor=x86_64
tools.gnu:host_triplet=x86_64-pc-linux-gnu
tools.build:cflags=['-mavx', '-march=haswell', '-mtune=haswell', '-mavx2']
tools.build:cxxflags=['-mavx', '-march=haswell', '-mtune=haswell', '-mavx2']
tools.build:sharedlinkflags=['-Wl,-rpath,/usr/local/lib/x86_64-unknown-linux-gnu']
tools.build:exelinkflags=['-Wl,-rpath,/usr/local/lib/x86_64-unknown-linux-gnu']


======== Computing dependency graph ========
Graph root
    cli
Build requirements
    android_ndk/r25c@microblink/main#937ed38bb07ccdabf6f621fe7e5dff4f - Cache
    mb_foundation/1.0.0@microblink/main#35c07845b5016aa7915b8d7df86ae8b9 - Cache

======== Computing necessary packages ========
android_ndk/r25c@microblink/main: Checking 1 compatible configurations:
android_ndk/r25c@microblink/main: '63fead0844576fc02943e16909f08fcdddd6f44b':
android_ndk/r25c@microblink/main: Main binary package 'f8da2d2d1af868e90384529932ffe9297cc1e8d7' missing. Using compatible package '63fead0844576fc02943e16909f08fcdddd6f44b'
Build requirements
    android_ndk/r25c@microblink/main#937ed38bb07ccdabf6f621fe7e5dff4f:63fead0844576fc02943e16909f08fcdddd6f44b#0ef88b189bb24d2bcd77ae5de1a8a4f4 - Cache
Skipped binaries
    mb_foundation/1.0.0@microblink/main

======== Installing packages ========
android_ndk/r25c@microblink/main: Already installed! (1 of 1)
ERROR: android_ndk/r25c@microblink/main: Error in package_info() method, line 151
        self._mb_setup_lto()
while calling '_mb_setup_lto', line 336
        lto = self.settings_target.get_safe('compiler.link_time_optimization')
        AttributeError: 'NoneType' object has no attribute 'get_safe'

However, with conan 2.0.11, if I use -s:b arch=x86_64, it works, as conan does not need to use a compatible android_ndk package. I can use that as a workaround for the time being.

My hunch is that this PR introduced the issue, but I'm not familiar enough with the conan internals to understand what it actually does.

Logs

No response

@memsharded
Copy link
Member

Thanks very much @DoDoENT for reporting this.

You are right, this was a bug introduced in that PR. The overlook in that PR was basically to restore the settings_target after the compatibility analysis, it is being fixed in #14825, hopefully for today 2.0.12 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants