Skip to content

[Bug] kuromoji_build_dict fails to link on arm64: B/BL out of range (__TEXT exceeds 128MB) #67448

Description

@morningman

Search before asking

  • I had searched in the issues and found no similar issues.

Version

master (ddbaaab1388), macOS 26.5 arm64, Homebrew clang 20.1.8, DISABLE_BUILD_UI=ON sh build.sh --fe --be

What's Wrong?

Linking bin/kuromoji_build_dict fails on arm64 because the binary's __TEXT segment exceeds the AArch64 ±128 MB branch range:

FAILED: [code=1] bin/kuromoji_build_dict
ld: fixup error (kind=arm64_b26) at '__ZN8tcmallocL14memalign_pagesEmmbb'+0x1DC
    from libtcmalloc.a[2](libtcmalloc_la-tcmalloc.o), B/BL out of range
    (displacement=-135691464, max is +/-128MB), from 0x10816EF18 to 0x100007250 ('___clang_call_terminate')
final section layout:
    __TEXT               addr=0x100000000, size=0x008310000   <-- 137 MB
        __text           ... size=0x0059254bc
        google_malloc    addr=0x10816da40, ...
        malloc_hook      addr=0x10816ef3c, ...

The linker normally inserts branch islands, but it can only do that inside __text. gperftools puts its allocator in the custom sections google_malloc and malloc_hook, which the linker places after __text, so a branch from there back to ___clang_call_terminate at the start of __TEXT cannot be relaxed.

doris_be itself links fine — ninja doris_be succeeds. Only kuromoji_build_dict is over the limit.

The failure also blocks the install step, which hard-fails when the generated dictionary is absent:

CMake Error at cmake_install.cmake:96 (message):
  kuromoji dictionary file .../be/dict/kuromoji/system.bin is missing; build the
  'kuromoji_dict' target (stage mecab-ipadic via thirdparty) before packaging.

so output/ is never produced.

What You Expected?

sh build.sh --be completes on arm64.

How to Reproduce?

On an Apple Silicon host:

DISABLE_BUILD_UI=ON sh build.sh --fe --be

Anything Else?

kuromoji_build_dict is defined under if (NOT MAKE_TEST) in be/CMakeLists.txt and kuromoji_dict is an ALL target, so a normal --be build links it. be-ut-mac.yml runs ./build.sh --be on runs-on: macos-15 (arm64) with -DMAKE_TEST=OFF, so that CI job should build this target too — worth checking whether it is currently green, since my margin was only ~1.4 MB over the limit and could easily differ with another linker version or flag set.

Ideas, roughly in order of appeal:

  • the tool only needs the dictionary builder, not the whole BE; trimming its target_link_libraries(${DORIS_LINK_LIBS}) down to what kuromoji_build_dict.cpp actually uses would take it far under the limit;
  • link the tool against jemalloc (or no custom allocator) so gperftools' custom sections are not in play;
  • ship the generated dictionary as a thirdparty artifact instead of building it during the BE build.

Found while building BE for #67366; worked around locally by dropping ALL from kuromoji_dict and skipping the install-time check.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions