Skip to content

zig relies too much on /usr/bin/env to detect dynamic-linker path #14577

Description

@mikdusan

Zig Version

0.11.0-dev.1580+a5b34a61a

Steps to Reproduce and Observed Behavior

  • on linux system with static /usr/bin/env try to produce hello.zig executable linked with -lc
  • we use stage2 exe to diagnose because stage3 cannot be built
  • tldr; missing command line option -dynamic-linker /lib/ld-musl-x86_64.so.1
$ zig2 build-exe hello.zig -lc --verbose-link
LLD Link... ld.lld --error-limit=0 -O0 -z stack-size=16777216 --gc-sections -znow -m elf_x86_64 -o hello /lib/crt1.o /lib/crti.o -L /lib hello.o --as-needed -lm -lpthread -lc -ldl -lrt -lutil /home/jerem
y/.cache/zig/o/78513c6bfd7c57d2aac0a0ce8d9f3e76/libcompiler_rt.a /lib/crtn.o

Expected Behavior

  • has command line option -dynamic-linker /lib/ld-musl-x86_64.so.1
$ zig2 build-exe hello.zig -lc --verbose-link
LLD Link... ld.lld --error-limit=0 -O0 -z stack-size=16777216 --gc-sections -znow -m elf_x86_64 -o hello /lib/crt1.o /lib/crti.o -L /lib hello.o -dynamic-linker /lib/ld-musl-x86_64.so.1 --as-needed -lm -lpthread -lc -ldl -lrt -lutil /home/jerem
y/.cache/zig/o/78513c6bfd7c57d2aac0a0ce8d9f3e76/libcompiler_rt.a /lib/crtn.o

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavioros-linuxLinuxzig build systemstd.Build, the build runner, `zig build` subcommand, package management

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions