Skip to content

[SR-6317] Package Manager's .pc parsing makes it difficult to selectively shadow system libraries #4927

Open
@Lukasa

Description

@Lukasa
Previous ID SR-6317
Radar rdar://problem/40235197
Original Reporter @Lukasa
Type Bug
Environment

Linux 1779df4f8699 4.9.49-moby #1 SMP Wed Sep 27 23:17:17 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Swift version 4.0.2 (swift-4.0.2-RELEASE)

Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Bug
Assignee None
Priority Medium

md5: e849c854eac92b5e5de3cdf3e167fa11

Issue Description:

I'm running a Swift project where I want to link mostly against system libraries (e.g. the system copy of icu-uc), but want to selectively shadow one or two other system libraries with different versions. This should be something that can mostly be solved by using pkg-config, as pkg-config allows us to give SwiftPM library search paths. This means, for example, if you're using icu-uc.pc you should expect to see the following flags added:

$ pkg-config --libs icu-uc
-licuuc -licudata

However, SwiftPM's parsing of .pc files doesn't behave exactly like that. Instead it behaves like pkg-config with the optional PKG_CONFIG_ALLOW_SYSTEM_LIBS flags set:

$ env PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 pkg-config --libs icu-uc
-L/usr/lib/x86_64-linux-gnu -licuuc -licudata

This means that if some libraries are being added that shadow system libraries, and some are not, you will get both -L/my/shadow/path and -L/usr/lib/x86_64-linux-gnu in the command line. Depending on the order in which they appear this may mean that the attempt to shadow the system libraries fails, as the system library path may end up first in the search path again.

I'd propose that SwiftPM should behave more like pkg-config without the PKG_CONFIG_ALLOW_SYSTEM_LIBS environment variable set, and refuse to put the system library path in a -L flag.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions