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

pybind_libraries get compiled twice #47

Open
matte1 opened this issue Dec 8, 2022 · 3 comments
Open

pybind_libraries get compiled twice #47

matte1 opened this issue Dec 8, 2022 · 3 comments

Comments

@matte1
Copy link

matte1 commented Dec 8, 2022

    Compiling foo/bar/target__pybind.cc; 1s remote-cache, linux-sandbox
    Compiling foo/bar/target__pybind.cc; 1s remote-cache, linux-sandbox

I'm not sure if I'm using the rule correctly or if this is intended behavior but I seem to be getting two compilations for my pybind targets w/ very slightly different compiler options.

19,21c19,20
< bazel-out/k8-opt/bin/foo/bar/target__pybind.pic.d
< '-frandom-seed=bazel-out/k8-opt/bin/foo/bar/target__pybind_cc/target__pybind.pic.o'
< -fPIC
---
> bazel-out/k8-opt/bin/foo/bar/target__pybind_cc/target__pybind.d
> '-frandom-seed=bazel-out/k8-opt/foo/bar/target__pybind_cc/target__pybind.o'
163c162
< bazel-out/k8-opt/bin/foo/bar/target__pybind_cc/target__pybind.pic.o)
---
> bazel-out/k8-opt/bin/foo/bar/target__pybind_cc/target__pybind.o)
@rwgk
Copy link
Collaborator

rwgk commented Dec 8, 2022

How much trouble is it to provide a reproducer (something that I could git clone unzip or similar, then run some commands you give me)?

I'm not a blaze expert myself, but I'm pretty sure there are valid situations in which there are multiple compilations for the same sources, but without a reproducer it's difficult to tell if that's a situation you have. It could also happen by accident.

@matte1
Copy link
Author

matte1 commented Dec 9, 2022

Hmmm it seems like this might be on me. I'm using pybind_library and then using that as a srcs in pybind_extension. If I just use the pybind_extension it seems like things only get compiled once. Sorry I don't have a good reproduction for you, this is pretty tightly embedded in our code base and would be non-trivial to get a minimal reproduction. Happy to close it though as this seems to solve my issue.

@rwgk
Copy link
Collaborator

rwgk commented Dec 9, 2022

pybind_library and then using that as a srcs in pybind_extension

Did you already try using that as deps?

That's how we do it internally. I'm not very familiar with the external side myself, which is a lot less developed than the internal adaption of the same core tool.

For reasons I don't know, here cc_binary is used instead of pybind_extension:

https://github.com/pybind/pybind11_abseil/blob/d5d078954491d227bfbb4c528e0645453ef4032c/pybind11_abseil/BUILD

What I know though is that that works.

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

2 participants