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

Compile error on ARMv8 aarch64 Ubuntu platform. #156

Closed
esharkwang opened this issue Jan 9, 2023 · 5 comments
Closed

Compile error on ARMv8 aarch64 Ubuntu platform. #156

esharkwang opened this issue Jan 9, 2023 · 5 comments

Comments

@esharkwang
Copy link

Hi,

When I use bazel 5.4.0 to compile the goolge fleetbench for aarch64 on Ubuntu server 20.04. I hit a compile failure with external dependency tcmalloc code.
Error log:

bazel build -c opt fleetbench/tcmalloc:all --spawn_strategy=local --sandbox_debug
INFO: Analyzed 8 targets (0 packages loaded, 0 targets configured).
INFO: Found 8 targets...
ERROR: /root/.cache/bazel/_bazel_root/0bce1989468318c371f4348e6ac4d902/external/com_google_tcmalloc/tcmalloc/BUILD:297:11: Compiling tcmalloc/global_stats.cc failed: (Exit 1): gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 32 arguments skipped)
In file included from external/com_google_tcmalloc/tcmalloc/cpu_cache.h:39,
from external/com_google_tcmalloc/tcmalloc/global_stats.cc:21:
external/com_google_tcmalloc/tcmalloc/internal/percpu_tcmalloc.h: In function 'int tcmalloc::tcmalloc_internal::subtle::percpu::TcmallocSlab_Internal_Push(typename tcmalloc::tcmalloc_internal::subtle::percpu::TcmallocSlab::Slabs*, size_t, void*, tcmalloc::tcmalloc_internal::subtle::percpu::Shift, tcmalloc::tcmalloc_internal::subtle::percpu::OverflowHandler, void*, size_t)':
external/com_google_tcmalloc/tcmalloc/internal/percpu_tcmalloc.h:667:9: error: expected ':' or '::' before '[' token
667 | : [end_ptr] "=&r"(end_ptr), [cpu_id] "=&r"(cpu_id),

| ^
INFO: Elapsed time: 2.486s, Critical Path: 1.92s
INFO: 39 processes: 37 internal, 2 local.

here is the tcmalloc version referenced by fleetbench workspace.

http_archive( [
name = "com_google_tcmalloc",
urls = ["https://github.com/google/tcmalloc/archive/48808681a9f38e974b49619a126f6f949ff59520.zip"],
strip_prefix = "tcmalloc-48808681a9f38e974b49619a126f6f949ff59520",
sha256 = "18bde75174866059a8db37dc42a921192b9182f57e7900a66d9f26cdd72599af",
)

@bendeguzvarju
Copy link

Hi, I have the exact same problem. If you got a solution, please share.

@ckennelly
Copy link
Collaborator

This appears to be an issue with GCC 10.3, but not GCC 11.1. Lifting most of percpu_tcmalloc.h into a reproduction with Godbolt: https://godbolt.org/z/K3j1rGazM

Checking locally (aarch64, gcc 9.4.0, bazel 5.4.0), this build error seems to go back to e89f1bf, when this code was first imported from #65

Turning off the asm goto path seems to work in 10.3 on Godbolt, but locally (on 9.4) or with Godbolt (on 9.4), the build fails with "impossible constraint in asm": https://godbolt.org/z/GzT57hazP so there's a limit to how far back that workaround would suffice.

@esharkwang
Copy link
Author

Hi @ckennelly ,
Could we upgrade the gcc in bazel to GCC 11.1? I will try to use bazel 6.0.0 as a workaround.

@ckennelly
Copy link
Collaborator

Bazel doesn't ship a particular compiler.

If you have another version of GCC available, you could specify it with the CC=/path/to/compiler.. environment variable to see if that fixes the compilation error.

@esharkwang
Copy link
Author

Yes, after I upgrade the gcc to gcc11 as the default. The issue was fixed. I can compile the binary now.

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