Skip to content

Conversation

@mzacho
Copy link

@mzacho mzacho commented Sep 18, 2025

Building internal/new on a system where __cpp_aligned_new isn't set (i.e. Darwin) fails with

➜  cel-cpp-0.13.0 bazel build //internal:new --sandbox_debug
INFO: Analyzed target //internal:new (0 packages loaded, 2892 targets configured).
ERROR: /private/tmp/cel-cpp-0.13.0/internal/BUILD:44:11: Compiling internal/new.cc failed: (Exit 1): sandbox-exec failed: error executing CppCompile command
  (cd /private/var/tmp/_bazel_martin/f51b858526a01daed3ad3e4aaed921d1/sandbox/darwin-sandbox/103/execroot/_main && \
  exec env - \
    PATH=/Users/martin/Library/Caches/bazelisk/downloads/sha256/79e4d2401b1c969d2b57babd0c50b0ca61b719689d8b029c919525744f52872c/bin:/Users/martin/.sdkman/candidates/java/current/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/martin/.nix-profile/bin:/etc/profiles/per-user/martin/bin:/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin \
    PWD=/proc/self/cwd \
    TMPDIR=/var/folders/xq/0kq1jwf943z1kntx09dcxlvc0000gn/T/ \
  /usr/bin/sandbox-exec -f /private/var/tmp/_bazel_martin/f51b858526a01daed3ad3e4aaed921d1/sandbox/darwin-sandbox/103/sandbox.sb /var/tmp/_bazel_martin/install/5b64cfdb8a44c51dfff6cba1c4581101/process-wrapper '--timeout=0' '--kill_delay=15' '--stats=/private/var/tmp/_bazel_martin/f51b858526a01daed3ad3e4aaed921d1/sandbox/darwin-sandbox/103/stats.out' external/rules_cc~~cc_configure_extension~local_config_cc/cc_wrapper.sh -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer '-std=c++17' '-frandom-seed=bazel-out/darwin_arm64-fastbuild/bin/internal/_objs/new/new.o' '-mmacosx-version-min=10.11' -MD -MF bazel-out/darwin_arm64-fastbuild/bin/internal/_objs/new/new.d -iquote . -iquote bazel-out/darwin_arm64-fastbuild/bin -iquote external/abseil-cpp~ -iquote bazel-out/darwin_arm64-fastbuild/bin/external/abseil-cpp~ -Wno-deprecated-declarations '-std=c++17' -fsized-deallocation -c internal/new.cc -o bazel-out/darwin_arm64-fastbuild/bin/internal/_objs/new/new.o -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"')
internal/new.cc:71:15: warning: 'aligned_alloc' is only available on macOS 10.15 or newer [-Wunguarded-availability-new]
   71 |   void* ptr = std::aligned_alloc(static_cast<size_t>(alignment), size);
      |               ^~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/malloc/_malloc.h:65:35: note: 'aligned_alloc' has been marked as being introduced in macOS 10.15 here, but the deployment target is macOS 10.11.0
   65 | void * __sized_by_or_null(__size) aligned_alloc(size_t __alignment, size_t __size) __result_use_check __alloc_align(1) __alloc_size(2) _MALLOC_TYPED(malloc_type_aligned_alloc, 2) __OSX_AVAILABLE(10.15) __IOS_AVAILABLE(13.0) __TVOS_AVAILABLE(13.0) __WATCHOS_AVAILABLE(6.0);
      |                                   ^
internal/new.cc:71:15: note: enclose 'aligned_alloc' in a __builtin_available check to silence this warning
   71 |   void* ptr = std::aligned_alloc(static_cast<size_t>(alignment), size);
      |               ^~~~~~~~~~~~~~~~~~
   72 |   if (ABSL_PREDICT_FALSE(size != 0 && ptr == nullptr)) {
   73 |     ThrowStdBadAlloc();
   74 |   }
   75 |   return ptr;
      |
internal/new.cc:110:17: error: use of undeclared identifier 'size'
  110 |     Delete(ptr, size);
      |                 ^
1 warning and 1 error generated.
Target //internal:new failed to build

I'm not a cpp programmer, but it seems like a trivial bug, since Delete only takes ptr as an argument.

@mzacho mzacho changed the title Don't pass alignment to Delete internal/new: Don't pass alignment to Delete when __cpp_aligned_new isn't set Sep 18, 2025
@mzacho
Copy link
Author

mzacho commented Sep 18, 2025

cc @jcking

@u5surf
Copy link

u5surf commented Sep 27, 2025

Hi, I have same issue for building the https://github.com/envoyproxy/envoy which seems to use google/cel-cpp internal.
Here is a build fail logs.

% bazel build -c opt envoy --verbose_failures
INFO: Analyzed target //:envoy (1 packages loaded, 36 targets configured).
INFO: From GoLink external/com_envoyproxy_protoc_gen_validate/protoc-gen-validate_/protoc-gen-validate [for tool]:
ld: warning: ignoring duplicate libraries: '-lm'
INFO: From Linking external/com_google_protobuf/src/google/protobuf/io/libio_win32.a:
warning: /Library/Developer/CommandLineTools/usr/bin/libtool: archive library: bazel-out/darwin_arm64-opt/bin/external/com_google_protobuf/src/google/protobuf/io/libio_win32.a the table of contents is empty (no object file members in the library define global symbols)
INFO: From Linking external/com_google_protobuf/src/google/protobuf/io/libio_win32.a [for tool]:
warning: /Library/Developer/CommandLineTools/usr/bin/libtool: archive library: bazel-out/darwin_arm64-opt-exec-ST-a828a81199fe/bin/external/com_google_protobuf/src/google/protobuf/io/libio_win32.a the table of contents is empty (no object file members in the library define global symbols)
INFO: From Linking external/com_google_protobuf/src/google/protobuf/libdescriptor_proto.upb.a [for tool]:
warning: /Library/Developer/CommandLineTools/usr/bin/libtool: archive library: bazel-out/darwin_arm64-opt-exec-ST-a828a81199fe/bin/external/com_google_protobuf/src/google/protobuf/libdescriptor_proto.upb.a the table of contents is empty (no object file members in the library define global symbols)
ERROR: /private/var/tmp/_bazel_u5/8fbcd3295816604c295774e14efb0586/external/com_google_cel_cpp/internal/BUILD:44:11: Compiling internal/new.cc failed: (Exit 1): cc_wrapper.sh failed: error executing CppCompile command (from target @@com_google_cel_cpp//internal:new)
  (cd /private/var/tmp/_bazel_u5/8fbcd3295816604c295774e14efb0586/sandbox/darwin-sandbox/5466/execroot/envoy && \
  exec env - \
    PATH=/opt/homebrew/bin:/opt/local/bin:/usr/local/bin:/usr/bin:/bin \
    PWD=/proc/self/cwd \
  external/local_config_cc/cc_wrapper.sh -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections -fdata-sections '-std=c++14' -MD -MF bazel-out/darwin_arm64-opt/bin/external/com_google_cel_cpp/internal/_objs/new/new.d '-frandom-seed=bazel-out/darwin_arm64-opt/bin/external/com_google_cel_cpp/internal/_objs/new/new.o' -iquote external/com_google_cel_cpp -iquote bazel-out/darwin_arm64-opt/bin/external/com_google_cel_cpp -iquote external/com_google_absl -iquote bazel-out/darwin_arm64-opt/bin/external/com_google_absl '-mmacosx-version-min=10.11' '-DABSL_MIN_LOG_LEVEL=4' -Wno-deprecated-declarations '-std=c++20' -Wno-nullability-completeness -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c external/com_google_cel_cpp/internal/new.cc -o bazel-out/darwin_arm64-opt/bin/external/com_google_cel_cpp/internal/_objs/new/new.o)
# Configuration: a8a21d93286812c5abf32fab801d01585ced2c1ced24e004647f8138359be6b2
# Execution platform: @@internal_platforms_do_not_use//host:host

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
external/com_google_cel_cpp/internal/new.cc:71:15: warning: 'aligned_alloc' is only available on macOS 10.15 or newer [-Wunguarded-availability-new]
  void* ptr = std::aligned_alloc(static_cast<size_t>(alignment), size);
              ^~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.0.sdk/usr/include/malloc/_malloc.h:65:35: note: 'aligned_alloc' has been marked as being introduced in macOS 10.15 here, but the deployment target is macOS 10.11.0
void * __sized_by_or_null(__size) aligned_alloc(size_t __alignment, size_t __size) __result_use_check __alloc_align(1) __alloc_size(2) _MALLOC_TYPED(malloc_type_aligned_alloc, 2) __OSX_AVAILABLE(10.15) __IOS_AVAILABLE(13.0) __TVOS_AVAILABLE(13.0) __WATCHOS_AVAILABLE(6.0);
                                  ^
external/com_google_cel_cpp/internal/new.cc:71:15: note: enclose 'aligned_alloc' in a __builtin_available check to silence this warning
  void* ptr = std::aligned_alloc(static_cast<size_t>(alignment), size);
              ^~~~~~~~~~~~~~~~~~
external/com_google_cel_cpp/internal/new.cc:110:17: error: use of undeclared identifier 'size'
    Delete(ptr, size);
                ^
1 warning and 1 error generated.
Target //source/exe:envoy-static failed to build
INFO: Elapsed time: 37.550s, Critical Path: 34.29s
INFO: 794 processes: 72 internal, 722 darwin-sandbox.
ERROR: Build did NOT complete successfully

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

Successfully merging this pull request may close these issues.

2 participants