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

add fallback curl config #1917

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

zaucy
Copy link
Contributor

@zaucy zaucy commented Apr 30, 2024

several C/C++ packages define HAVE_CONFIG_H which leaks into curl causing an error

this adds the default curl_config.h header to avoid this issue

alternatively we could update several other packages in the BCR to not define HAVE_CONFIG_H

@bazel-io
Copy link
Member

Hello @keith, modules you maintain (curl) have been updated in this PR. Please review the changes.

@keith
Copy link
Member

keith commented May 3, 2024

wouldn't it have to be patches that are in the curl dependency tree and setting that as defines to cause this issue?

@zaucy
Copy link
Contributor Author

zaucy commented May 3, 2024

I don't think so. I believe if you have a target that depends on @curl and some other package that defines HAVE_CONFIG_H then it will leak to curls compilation.

from bazel docs about defines

[...] added to the compile command line to this target, as well as to every rule that depends on it. Be very careful, since this may have far-reaching effects.

This goes for copts as well, I believe.

@zaucy
Copy link
Contributor Author

zaucy commented May 3, 2024

these are the modules that currently set HAVE_CONFIG_H in the bcr which I think would affect the curl module if compiled together:

  • c-ares
  • libarchive
  • xz
  • ncurses
  • nasm
  • snappy

In my project I believe mine was caused by utilising curl and libarchive. I only tested on Windows using msvc though.

@keith
Copy link
Member

keith commented May 3, 2024

as well as to every rule that depends on it

meaning curl would have to depend on the libraries that have it for it to cause an issue.

note that I'm actually working on making curl use HAVE_CONFIG_H which i think is safer than what we're doing now

@keith
Copy link
Member

keith commented May 3, 2024

should be fixed by #1943

@zaucy
Copy link
Contributor Author

zaucy commented May 4, 2024

meaning curl would have to depend on the libraries that have it for it to cause an issue.

I see what you're saying, but I assumed the opposite was true as well. I've been able to reproduce it here: https://github.com/ecsact-dev/ecsact_cli/actions/runs/8947494955/job/24579495333#step:4:270

cc_binary(
    name = "ecsact_cli",
    # ...
    deps = [
        "//ecsact/cli/commands:codegen",
        "//ecsact/cli/commands:command",
        "//ecsact/cli/commands:config",
        "//ecsact/cli/commands:build",
        "//ecsact/cli/commands:recipe-bundle", # offending target with @curl + @libarchive
    ],
)
ERROR: D:/a/ecsact_cli/ecsact_cli/ecsact/cli/commands/recipe-bundle/BUILD.bazel:6:11: Compiling ecsact/cli/commands/recipe-bundle/build_recipe_bundle.cc failed: (Exit 2): cl.exe failed: error executing CppCompile command (from target //ecsact/cli/commands/recipe-bundle:build_recipe_bundle) 
C:\Users\runneradmin\_bazel_runneradmin\uybixras\execroot\_main\external\curl~\lib\curl_setup.h(82): fatal error C1083: Cannot open include file: 'curl_config.h': No such file or directory

When I comment out @libarchive//libarchive in the target that uses @curl (and remove the libarchive related code) I compile successfully. I can't help but think that the HAVE_CONFIG_H is leaking directly or indirectly due to @libarchive//libarchive 🤔

I'm trying to make a smaller repro, but I haven't successfully done so.

@keith
Copy link
Member

keith commented May 6, 2024

interesting. as long as HAVE_CONFIG_H is still in the local_defines it shouldn't leak into curl there.

@zaucy
Copy link
Contributor Author

zaucy commented May 8, 2024

several packages have it in defines or copts which I believe is the issue, but not all of them can use local_defines since the config header is used in public headers.

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

Successfully merging this pull request may close these issues.

None yet

3 participants