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

Issue enabling layering_check #1221

Open
dotnwat opened this issue Jun 30, 2024 · 2 comments
Open

Issue enabling layering_check #1221

dotnwat opened this issue Jun 30, 2024 · 2 comments

Comments

@dotnwat
Copy link

dotnwat commented Jun 30, 2024

I'm using openssl via configure_make:

configure_make(
    name = "openssl",
    configure_command = "Configure",
    configure_options = [
        "--libdir=lib",
        "--release",
    ],
    lib_source = ":all_srcs",
    out_shared_libs = [
        "libssl.so",
        "libcrypto.so",
    ],
    visibility = [
        "//visibility:public",
    ],
)

And then enable the layering_check feature on a cc_library that depends on "@openssl":

cc_library(
    name = "crypto",
    srcs = [
        "ssl_utils.cc",
        "ssl_utils.h",
    ],
    hdrs = [
        "include/crypto/crypto.h",
    ],
    strip_include_prefix = "include",
    visibility = ["//visibility:public"],
    deps = [
        "@openssl",
    ],
    features = [
        "layering_check",
    ],
)

But layering_check does not seem to think that openssl is exporting certain header files:

src/crypto/ssl_utils.h:20:10: error: module //src/crypto:crypto does not depend on a module exporting 'openssl/evp.h'
#include <openssl/evp.h>

I can see these header files in the build cache include directories, so I'm just guessing that the rule for openssl doesn't have these headers declared?

Is this expected behavior, or how can I go about debugging this?

EDIT:

It does seem as though rules_foreign_cc disables layering checks. But I'm still a bit lost on how to deal with adding layering checks to libraries that depend on a library built with rules_foreign_cc as it doesn't appear to declare the output headers explicitly.

@jsharpe
Copy link
Member

jsharpe commented Jul 4, 2024

rules_foreign_cc disables layering checks because the flags that this feature set are not safe to pass to a third party build system.
@fmeum you've previously worked with getting layering checks working in the toolchain - is there something I can add to the generated CcInfo that would make this case work where one layer comes from a third party build system?

@fmeum
Copy link
Member

fmeum commented Jul 4, 2024

The API for creating and adding module maps is private, so the only thing you could try now is to split up the CcInfo: Populate the linking context from your custom starlark rule, but wrap it in a cc_library with the exported headers to provide the compilation context. The cc_library target should have features = ["-layering_check"] set to disable checks for it, but it will still generate a module map.

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

No branches or pull requests

3 participants