# zig ld: handle \`\-\-library :path/to/lib.so\` · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/ac9f72d87e8eeb4a9d0dead80b61420485279ddd)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: ac9f72d87e8eeb4a9d0dead80b61420485279ddd

Requested commit: ac9f72d87e8eeb4a9d0dead80b61420485279ddd

Commit: ac9f72d87e8eeb4a9d0dead80b61420485279ddd

Tree: 63046c79edfb445d0eef7092d695ab1646655061

Author: Motiejus Jakštys

Committer: Jakub Konka

## Message

```
zig ld: handle `--library :path/to/lib.so`

`-l :path/to/lib.so` behavior on gcc/clang is:

- the path is recorded as-is: no paths, exact filename (`libX.so.Y`).
- no rpaths.

The previous version removed the `:` and pretended it's a positional
argument to the linker. That works in almost all cases, except in how
rules_go[1] does things (the Bazel wrapper for Go).

Test case in #15743, output:

    gcc rpath:
     0x0000000000000001 (NEEDED)     Shared library: [libversioned.so.2]
     0x000000000000001d (RUNPATH)    Library runpath: [$ORIGIN/x]
    gcc plain:
     0x0000000000000001 (NEEDED)     Shared library: [libversioned.so.2]
    zig cc rpath:
     0x0000000000000001 (NEEDED)     Shared library: [libversioned.so.2]
     0x000000000000001d (RUNPATH)    Library runpath: [$ORIGIN/x]
    zig cc plain:
     0x0000000000000001 (NEEDED)     Shared library: [libversioned.so.2]

Fixes #15743

[1]: https://github.com/bazelbuild/rules_go

```

## Parents

- [706bdf6512aec9f5d003cc2ec64ba16ac0a202dc](https://git.cafe/gitcafe/zig/commit/706bdf6512aec9f5d003cc2ec64ba16ac0a202dc?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/ac9f72d87e8eeb4a9d0dead80b61420485279ddd?format=markdown)
