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

"this include generates a translation unit too large for Clang to process" error with debug build #16

Open
takuro-sato opened this issue Aug 15, 2024 · 0 comments
Assignees

Comments

@takuro-sato
Copy link

Building services with debug flag --compilation_mode=dbg with the latest commit (Release 3.10.0) ends up with an error.

$ builders/tools/bazel-debian build --compilation_mode=dbg -- //services/bidding_service:server 
ERROR: /bazel_root/build_ubuntu_b77b7d5/115e6fbdee486fb5f001bf53a8dcf4c0/external/google_privacysandbox_servers_common/src/roma/sandbox/worker_api/sapi/BUILD.bazel:81:13: Compiling external/google_privacysandbox_servers_common/src/roma/sandbox/worker_api/sapi/worker_wrapper-sapi_embed.cc failed: (Exit 1): clang failed: error executing command (from target @google_privacysandbox_servers_common//src/roma/sandbox/worker_api/sapi:worker_wrapper-sapi_embed) 
  (cd /bazel_root/build_ubuntu_b77b7d5/115e6fbdee486fb5f001bf53a8dcf4c0/sandbox/processwrapper-sandbox/2/execroot/__main__ && \
  exec env - \
    PATH=/root/.cache/bazelisk/downloads/sha256/d64606c17e6b6a7fc119150420b4c109315982319ff3229587e200c47bf36946/bin:/opt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin \
    PWD=/proc/self/cwd \
    TOOLCHAINS_HASH=b77b7d50a6527337035ce8d9d8a4a32218c32a5c0c431f28d4ca1a4bf767e384 \
  /usr/lib/llvm-15/bin/clang -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer -g '-std=c++17' -MD -MF bazel-out/k8-dbg/bin/external/google_privacysandbox_servers_common/src/roma/sandbox/worker_api/sapi/_objs/worker_wrapper-sapi_embed/worker_wrapper-sapi_embed.pic.d '-frandom-seed=bazel-out/k8-dbg/bin/external/google_privacysandbox_servers_common/src/roma/sandbox/worker_api/sapi/_objs/worker_wrapper-sapi_embed/worker_wrapper-sapi_embed.pic.o' -fPIC '-DBAZEL_CURRENT_REPOSITORY="google_privacysandbox_servers_common"' -iquote external/google_privacysandbox_servers_common -iquote bazel-out/k8-dbg/bin/external/google_privacysandbox_servers_common -iquote external/com_google_absl -iquote bazel-out/k8-dbg/bin/external/com_google_absl -Werror '-Werror=thread-safety' -DENABLE_LOGS_PREVIEW '-fbracket-depth=512' '-std=c++17' -fsized-deallocation '-fnew-alignment=8' -Wno-error -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c bazel-out/k8-dbg/bin/external/google_privacysandbox_servers_common/src/roma/sandbox/worker_api/sapi/worker_wrapper-sapi_embed.cc -o bazel-out/k8-dbg/bin/external/google_privacysandbox_servers_common/src/roma/sandbox/worker_api/sapi/_objs/worker_wrapper-sapi_embed/worker_wrapper-sapi_embed.pic.o)
# Configuration: 2cb773209b0df85c0ed032d8a5fe1fb3a795258d06089010c0c712bae6334ce8
# Execution platform: @local_config_platform//:host

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
fatal error: sorry, this include generates a translation unit too large for Clang to process.
1 error generated.
Target //services/bidding_service:server failed to build
INFO: Elapsed time: 59.723s, Critical Path: 49.16s
INFO: 15 processes: 14 internal, 1 processwrapper-sandbox.
FAILED: Build did NOT complete successfully

Since debug build (--compilation_mode=dbg) gives a better debugging experience and I can run the services with DCHECK enabled, I
would like to be able to build services with --compilation_mode=dbg.
I haven't faced this error with 3.4.0 release.
Is there any expected way to use --compilation_mode=dbg for building services?
Or if this error is not expected I think it would be nice if it's fixed.

Details

The size of the problematic .cc code worker_wrapper-sapi_embed.cc is around 2.2G while without dbg it's 197M.

$ du -h bazel-out/k8-dbg/bin/external/google_privacysandbox_servers_common/src/roma/sandbox/worker_api/sapi/worker_wrapper-sapi_embed.cc
2.2G    bazel-out/k8-dbg/bin/external/google_privacysandbox_servers_common/src/roma/sandbox/worker_api/sapi/worker_wrapper-sapi_embed.cc

This file is generated as an output of worker_wrapper-sapi in google_privacysandbox_servers_common/src/roma/sandbox/worker_api/sapi/BUILD.bazel
as the error message suggests.

From the BUILD.bazel it looks like compiled worker_wrapper library (bazel-out/k8-dbg/bin/external/google_privacysandbox_servers_common/src/roma/sandbox/worker_api/sapi/worker_wrapper-sapi.bin) is embedded into worker_wrapper-sapi_embed.cc as text.
Looks like the binary is very large because it includes large dependencies like V8.

If you provide --per_file_copt=.*/v8/.*@-g0 --per_file_copt=.*/v8/.*@-DNDEBUG to change the size of one of the worker_wrapper's dependency, the worker_wrapper-sapi_embed.cc is actually smaller (808M).

builders/tools/bazel-debian build --compilation_mode=dbg --per_file_copt=.*/v8/.*@-g0 --per_file_copt=.*/v8/.*@-DNDEBUG -- //services/bidding_service:server
$ du -h bazel-out/k8-dbg/bin/external/google_privacysandbox_servers_common/src/roma/sandbox/worker_api/sapi/worker_wrapper-sapi_embed.cc
808M    bazel-out/k8-dbg/bin/external/google_privacysandbox_servers_common/src/roma/sandbox/worker_api/sapi/worker_wrapper-sapi_embed.cc

Workaraound

I can do debug build with --compilation_mode=dbg --per_file_copt=.*/v8/.*@-g0 --per_file_copt=.*/v8/.*@-DNDEBUG but I think it's better if just --compilation_mode=dbg 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

3 participants