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

[feature] Conan 2.0 - Add configuration policy to control fPIC + shared behavior #7530

Closed
1 task done
solvingj opened this issue Aug 10, 2020 · 2 comments
Closed
1 task done

Comments

@solvingj
Copy link
Contributor

Currently, the following codeblock exists. It is active by default in Conan V2 mode. It performs nice validation logic for the common case of Linux shared libraries. However, that validation logic is not desirable in all cases, for example, @SSE4 has stated that Android Kernel modules must be compiled with -shared but without -fPIC. Also, the same is true for many embedded and legacy platforms.

So First, if we choose to keep this validation logic in the codebase, users should have a way to opt out of it. I suggest a configuration item.

Second, assuming we add a configuration item for this behavior, I suggest the default be "enabled". I would prefer it to be opt-in, but I can understand why making it opt-out is more practical as a default.

Third, I don't understand the error message. The function seems to indicate that it's an error that the fPIC option is even defined on the package. To me, it seems that it should indicate that the problem is that fPIC option has a value of False. Perhaps it's just my personal interpretation of the message that is wrong, but I thought I would raise the question.

https://github.com/conan-io/conan/blob/develop/conans/client/conanfile/configure.py#L48

def _validate_fpic(conanfile):
    ...
    fpic = conanfile.options.get_safe("fPIC")
    if fpic is None:
        return
    ...
    shared = conanfile.options.get_safe("shared")
    if shared:
        if v2_mode:
            raise ConanInvalidConfiguration("fPIC option defined for a shared library")
        conanfile.output.error("fPIC option defined for a shared library")
    ...
@memsharded
Copy link
Member

Moving to 2.X roadmap, current #13066 would be standardizing some common practice in ConanCenter.

The feature proposed for 2.X is:

  • Declare options = {"shared": [True, False], "fPIC": [True, False]}, probably change default_options to fPIC=False.
  • Propose a new simple configure_shared(self) helper, that can be called in configure() method that does:
    • Default to Removal of fPIC if shared
    • Removal of fPIC if Windows
    • Define *:fPIC=True for dependencies if shared

To validate:

  • That all transitivity works correctly with the right priorities
  • It might be necessary to split the functionality in config_options and configure

@memsharded memsharded modified the milestones: 2.0, 2.X Feb 7, 2023
@memsharded
Copy link
Member

This got implemented and released in 2.0.9 with the implements feature with auto_shared_fpic: https://github.com/conan-io/docs/pull/3303/files

@memsharded memsharded modified the milestones: 2.X, 2.0.9 Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants