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

fix build against libstdc++ 12 #193

Closed

Conversation

jvgutierrez
Copy link

While attempting to compile katran on Debian Bullseye and Bookworm I've realized that it compiled as expected on Bullseye with clang-13 but failed on Bookworm with the same compiler issuing the following error:

/tmp/fbcode_builder_getdeps-ZrootZkatranZbuildZfbcode_builder-root/repos/git.luolix.top-facebookincubator-katran.git/katran/lib/BpfLoader.cpp:46:25:
 error: implicit instantiation of undefined template 'std::array<char, 128>'
 std::array<char, 128> buf{};

Debugging the issue with clang++ -H I've noticed that BpfLoader.h:21: #include <unordered_map>
implicitly includes array when using libstdc++ 10:

.. /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/unordered_map
... /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/hashtable.h
.... /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/hashtable_policy.h
..... /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/tuple
...... /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/array
...... /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/uses_allocator.h
...... /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/invoke.h
..... /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/limits
... /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/unordered_map.h

but this doesn't happen with libstdc++ 12:

.. /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/unordered_map
... /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/hashtable.h
.... /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/hashtable_policy.h
..... /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/tuple
...... /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/uses_allocator.h
.... /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/enable_special_members.h
... /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/unordered_map.h

Adding a explicit #include <array> fixes the error

While attempting to compile katran on Debian Bullseye and Bookworm
I've realized that it compiled as expected on Bullseye with clang-13
but failed on Bookworm with the same compiler issuing the following
error:
/tmp/fbcode_builder_getdeps-ZrootZkatranZbuildZfbcode_builder-root/repos/git.luolix.top-facebookincubator-katran.git/katran/lib/BpfLoader.cpp:46:25:
 error: implicit instantiation of undefined template 'std::array<char, 128>'
 std::array<char, 128> buf{};

Debugging the issue with clang++ -H I've noticed that BpfLoader.h:21:
\#include <unordered_map>
implictily includes array when using libstdc++ 10:
.. /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/unordered_map
... /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/hashtable.h
.... /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/hashtable_policy.h
..... /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/tuple
...... /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/array
...... /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/uses_allocator.h
...... /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/invoke.h
..... /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/limits
... /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/unordered_map.h

but this doesn't happen with libstdc++ 12:
.. /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/unordered_map
... /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/hashtable.h
.... /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/hashtable_policy.h
..... /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/tuple
...... /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/uses_allocator.h
.... /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/enable_special_members.h
... /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/unordered_map.h
@facebook-github-bot
Copy link
Contributor

Hi @jvgutierrez!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. If you'd still like this PR merged, please comment on the PR, make sure you've addressed reviewer comments, and rebase on the latest main. Thank you for your contributions!

@github-actions github-actions bot added the Stale label Oct 10, 2023
@github-actions
Copy link

This pull request has been automatically closed it has not had recent activity. If you'd still like this PR merged, please feel free to reopen it, make sure you've addressed reviewer comments, and rebase on the latest main. Thank you for your contributions!

@jdoupe
Copy link

jdoupe commented Oct 23, 2024

This is still an issue (and a simple fix).

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

Successfully merging this pull request may close these issues.

3 participants