Skip to content

$LINK_ERR -> $STUBS_C generation is broken on Linux #1

Closed

Description

@superboum

Error

When running ./bin/compile on Linux, compilation fails on step 4 with [4/5] link seed -> /tmp/seed/manticore_seed.
The error looks like that:

...
/nix/store/39lyf5g2iz4jd2r6q4g5whk9vw09zglj-binutils-2.46/bin/ld.bfd : /tmp/seed/seed.o : dans la fonction « manticore_preg_replace » :
mir:(.text+0x3fb7bb) : référence indéfinie vers « pcre2_match_data_create_from_pattern_8 »
/nix/store/39lyf5g2iz4jd2r6q4g5whk9vw09zglj-binutils-2.46/bin/ld.bfd : mir:(.text+0x3fb811) : référence indéfinie vers « pcre2_match_data_create_from_pattern_8 »
/nix/store/39lyf5g2iz4jd2r6q4g5whk9vw09zglj-binutils-2.46/bin/ld.bfd : mir:(.text+0x3fbb45) : référence indéfinie vers « pcre2_match_data_free_8 »
/nix/store/39lyf5g2iz4jd2r6q4g5whk9vw09zglj-binutils-2.46/bin/ld.bfd : /tmp/seed/seed.o : dans la fonction « manticore_preg_replace_callback » :
mir:(.text+0x3fbce4) : référence indéfinie vers « pcre2_match_data_create_from_pattern_8 »
/nix/store/39lyf5g2iz4jd2r6q4g5whk9vw09zglj-binutils-2.46/bin/ld.bfd : mir:(.text+0x3fbd36) : référence indéfinie vers « pcre2_match_data_create_from_pattern_8 »
/nix/store/39lyf5g2iz4jd2r6q4g5whk9vw09zglj-binutils-2.46/bin/ld.bfd : mir:(.text+0x3fc1a7) : référence indéfinie vers « pcre2_match_data_free_8 »
/nix/store/39lyf5g2iz4jd2r6q4g5whk9vw09zglj-binutils-2.46/bin/ld.bfd : /tmp/seed/seed.o : dans la fonction « manticore_preg_split » :
mir:(.text+0x3fc537) : référence indéfinie vers « pcre2_match_data_create_from_pattern_8 »
/nix/store/39lyf5g2iz4jd2r6q4g5whk9vw09zglj-binutils-2.46/bin/ld.bfd : mir:(.text+0x3fc591) : référence indéfinie vers « pcre2_match_data_create_from_pattern_8 »
/nix/store/39lyf5g2iz4jd2r6q4g5whk9vw09zglj-binutils-2.46/bin/ld.bfd : mir:(.text+0x3fca9d) : référence indéfinie vers « pcre2_match_data_free_8 »
collect2: erreur: ld a retourné le statut de sortie 1

Expected

Compilation should succeed.

Reproduce

Build the official Linux container:

docker build -t manticore --file tools/docker/Dockerfile.debian ./bin

Get a shell in it:

docker run --rm -it -v `pwd`:/build manticore

Try to bootstrap manticore:

./bin/compile

It will fail on step 4

Reason

This call is broken on Linux:

# Probe the linker without the runtime lib — every symbol it still can't find
# gets a void* fallback. macOS underscores names in errors; strip it defensively.
set +e
LINK_ERR="$(cc "$OBJ" -o /dev/null 2>&1)"
set -e
echo "$LINK_ERR" \
    | grep '^  "_' \
    | awk -F'"' '{print $2}' \
    | sort -u \
    | grep -vE '^_(main|manticore_cli_argc|manticore_cli_argv)$' \
    | awk '{name=$1; sub(/^_/, "", name); print "void* "name"() { return 0; }"}' >> "$STUBS_C" \
    || true

On Linux, errors are not prefixed with underscore, and double quotes are not used.
On a container set without locales, we get a backtick:

$ clang /tmp/seed/seed.o -o /dev/null
/usr/bin/ld: /tmp/seed/seed.o: in function `manticore_Runtime_Pcre_compile':
mir:(.text+0x36ae22): undefined reference to `pcre2_compile_8'
/usr/bin/ld: /tmp/seed/seed.o: in function `manticore_Runtime_Pcre_matchDataCreate':
mir:(.text+0x36ae32): undefined reference to `pcre2_match_data_create_from_pattern_8'
/usr/bin/ld: /tmp/seed/seed.o: in function `manticore_Runtime_Pcre_exec':
mir:(.text+0x36ae4b): undefined reference to `pcre2_match_8'
/usr/bin/ld: /tmp/seed/seed.o: in function `manticore_Runtime_Pcre_ovectorPtr':
mir:(.text+0x36ae62): undefined reference to `pcre2_get_ovector_pointer_8'
/usr/bin/ld: /tmp/seed/seed.o: in function `manticore_Runtime_Pcre_ovectorCount':
mir:(.text+0x36ae72): undefined reference to `pcre2_get_ovector_count_8'
/usr/bin/ld: /tmp/seed/seed.o: in function `manticore_Runtime_Pcre_matchDataFree':
mir:(.text+0x36ae82): undefined reference to `pcre2_match_data_free_8'
/usr/bin/ld: /tmp/seed/seed.o: in function `manticore_Runtime_Pcre_codeFree':
mir:(.text+0x36ae92): undefined reference to `pcre2_code_free_8'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

With french locales, we get french quotes:

$ clang seed.o -o /dev/null
/nix/store/39lyf5g2iz4jd2r6q4g5whk9vw09zglj-binutils-2.46/bin/ld.bfd : seed.o : dans la fonction « manticore_Runtime_Pcre_compile » :
mir:(.text+0x3f0651) : référence indéfinie vers « pcre2_compile_8 »
/nix/store/39lyf5g2iz4jd2r6q4g5whk9vw09zglj-binutils-2.46/bin/ld.bfd : seed.o : dans la fonction « manticore_Runtime_Pcre_matchDataCreate » :
mir:(.text+0x3f0661) : référence indéfinie vers « pcre2_match_data_create_from_pattern_8 »
/nix/store/39lyf5g2iz4jd2r6q4g5whk9vw09zglj-binutils-2.46/bin/ld.bfd : seed.o : dans la fonction « manticore_Runtime_Pcre_exec » :
mir:(.text+0x3f0671) : référence indéfinie vers « pcre2_match_8 »
/nix/store/39lyf5g2iz4jd2r6q4g5whk9vw09zglj-binutils-2.46/bin/ld.bfd : seed.o : dans la fonction « manticore_Runtime_Pcre_ovectorPtr » :
mir:(.text+0x3f0681) : référence indéfinie vers « pcre2_get_ovector_pointer_8 »
/nix/store/39lyf5g2iz4jd2r6q4g5whk9vw09zglj-binutils-2.46/bin/ld.bfd : seed.o : dans la fonction « manticore_Runtime_Pcre_ovectorCount » :
mir:(.text+0x3f0691) : référence indéfinie vers « pcre2_get_ovector_count_8 »
/nix/store/39lyf5g2iz4jd2r6q4g5whk9vw09zglj-binutils-2.46/bin/ld.bfd : seed.o : dans la fonction « manticore_Runtime_Pcre_matchDataFree » :
mir:(.text+0x3f06a2) : référence indéfinie vers « pcre2_match_data_free_8 »
/nix/store/39lyf5g2iz4jd2r6q4g5whk9vw09zglj-binutils-2.46/bin/ld.bfd : seed.o : dans la fonction « manticore_Runtime_Pcre_codeFree » :
mir:(.text+0x3f06b2) : référence indéfinie vers « pcre2_code_free_8 »
...

Workaround

An alternative way to generate the stub that should work when locales are not set (or set to ~english):

echo "$LINK_ERR" \
    | grep 'undefined reference to' \
    | grep -Po "[a-zA-Z0-9_]+'$" \
    | sed 's/.$//' \
    | sort -u \
    | grep -vE '^_(main|manticore_cli_argc|manticore_cli_argv)$' \
    | awk '{name=$1; print "void* "name"() { return 0; }"}' > "$STUBS_C" \
    || true

Files that must be updated:

  • ./bin/compile
  • ./tools/selfhost.sh
  • ./tools/link_stubs.sh

Activity

  1. changed the title [-]Bootstrapping on Linux is broken because seed_stubs.c is not properly generated[/-] [+]`$STUBS_C` generation is broken on Linux[/+] on Jul 19, 2026
  2. changed the title [-]`$STUBS_C` generation is broken on Linux[/-] [+]`$LINK_ERR` -> `$STUBS_C` generation is broken on Linux[/+] on Jul 19, 2026
  3. self-assigned this
    on Jul 20, 2026
  4. added
    bug
    on Jul 20, 2026
  5. blacktrs commented on Jul 20, 2026

    @blacktrs
    Contributor

    Thanks for the report and suggestion. I plan to fix Docker builds soon

  6. added theissue type on Jul 20, 2026
  7. blacktrs commented on Jul 24, 2026

    @blacktrs
    Contributor

    Linux should be mostly fixed now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions