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

Cross-compilation support: don't report IWYU issues on std headers #9

Open
storypku opened this issue Jul 24, 2023 · 0 comments
Open

Comments

@storypku
Copy link
Owner

storypku commented Jul 24, 2023

When running IWYU for X-Compilation on J5, it failed with error msg:

bazel build --config=iwyu --config=j5 experimental/users/jiaming/toolchain_exp:atomic_test
INFO: Invocation ID: 57c8ec4d-a7e5-4159-8148-a380fbf15538
INFO: Analyzed target //experimental/users/jiaming/toolchain_exp:atomic_test (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /qcraft/experimental/users/jiaming/toolchain_exp/BUILD:15:10: Run include-what-you-use on experimental/users/jiaming/toolchain_exp/atomic_test.cc failed: (Exit 1): run_iwyu failed: error executing command (from target //experimental/users/jiaming/toolchain_exp:atomic_test) bazel-out/k8-fastbuild-j5/bin/external/com_github_storypku_bazel_iwyu/bazel/iwyu/run_iwyu bazel-out/k8-fastbuild-j5/bin/experimental/users/jiaming/toolchain_exp/atomic_test.atomic_test.cc.iwyu.txt ... (remaining 99 arguments skipped)
[ERROR] IWYU violation found. Fixes have been written to bazel-out/k8-fastbuild-j5/bin/experimental/users/jiaming/toolchain_exp/atomic_test.atomic_test.cc.iwyu.txt

external/aarch64_j5_sysroot/usr/include/c++/9/atomic should add these lines:
#include <stdint.h>            // for int16_t, int32_t, int64_t, int8_t, int_fast16_t, int_fast32_t, int_fast64_t, int_fast8_t
#include <cstddef>             // for ptrdiff_t, _GLIBCXX_USE_C99_STDINT_TR1, _GLIBCXX_BEGIN_NAMESPACE_VERSION, _GLIBCXX_EN...
#include <type_traits>         // for is_object
#include <utility>             // for __addressof

external/aarch64_j5_sysroot/usr/include/c++/9/atomic should remove these lines:
- #include <bits/move.h>  // lines 42-42
- namespace std { struct atomic; }  // lines 147-148
- namespace std { template <typename _Tp> struct atomic; }  // lines 57-58

The full include-list for external/aarch64_j5_sysroot/usr/include/c++/9/atomic:
#include <bits/atomic_base.h>  // for memory_order, __atomic_base, __cmpexch_failure_order, atomic_flag, atomic
#include <stdint.h>            // for int16_t, int32_t, int64_t, int8_t, int_fast16_t, int_fast32_t, int_fast64_t, int_fast8_t
#include <cstddef>             // for ptrdiff_t, _GLIBCXX_USE_C99_STDINT_TR1, _GLIBCXX_BEGIN_NAMESPACE_VERSION, _GLIBCXX_EN...
#include <type_traits>         // for is_object
#include <utility>             // for __addressof
---

(experimental/users/jiaming/toolchain_exp/atomic_test.cc has correct #includes/fwd-decls)
Aspect @com_github_storypku_bazel_iwyu//bazel/iwyu:iwyu.bzl%iwyu_aspect of //experimental/users/jiaming/toolchain_exp:atomic_test failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.508s, Critical Path: 0.36s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully

Where atomic_test.cc is something like:

#include <atomic>
#include <iostream>

int main() {
  struct Test {
    int val;
  };
  std::atomic<Test> s;
  std::cout << std::boolalpha << s.is_lock_free() << std::endl;
  std::atomic_int my_num;
  ++my_num;
  std::cout << "my_num: " << my_num << std::endl;
  return 0;
}

We need to address this issue.

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

1 participant