Skip to content

statik(true) doesn't do anything on macOS #38

Closed
@kornelski

Description

@kornelski

In macOS passing --static to pkg-config is not enough to get the library linked statically. For almost all packages both .a and .dylib exist, and names specified by pkg-config are ambiguous.

$ pkg-config --static --libs lcms2
-L/usr/local/Cellar/little-cms2/2.8/lib -llcms2 -lm
$ pkg-config --libs lcms2
-L/usr/local/Cellar/little-cms2/2.8/lib -llcms2

Instructions printed by pkg-config don't specify that static linking was requested:

cargo:rustc-link-search=native=/usr/local/Cellar/little-cms2/2.8/lib
cargo:rustc-link-lib=lcms2
cargo:rustc-link-lib=m

So rustc invocation switches to dynamic linking:

Running rustc -l z -l lcms2 -l m

otool -L target/release/test
    /usr/local/opt/little-cms2/lib/liblcms2.2.dylib (compatibility version 3.0.0, current version 3.8.0)

I think this library should be printing rustc-link-lib=static=lcms2 when .statik(true) was specified (but only for the probed library, e.g. don't statically link libz if libpng was probed)

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