This is an archive of the discontinued LLVM Phabricator instance.

llvm-config: fix --libs on Linux
ClosedPublic

Authored by rivanvx on Feb 16 2016, 11:24 AM.

Details

Summary

llvm-config --libs does not produce correct output since commit r260263
(llvm-config: Add preliminary Windows support) changed naming format of
the libraries. This patch updates llvm-config to recognize new naming
format and output correct linker flags.

Ref: https://llvm.org/bugs/show_bug.cgi?id=26581

Diff Detail

Repository
rL LLVM

Event Timeline

rivanvx updated this revision to Diff 48088.Feb 16 2016, 11:24 AM
rivanvx retitled this revision from to llvm-config: fix --libs on Linux.
rivanvx updated this object.
rivanvx added a reviewer: rnk.
rnk accepted this revision.Feb 16 2016, 11:36 AM
rnk edited edge metadata.

lgtm, I'll go ahead and land this.

This revision is now accepted and ready to land.Feb 16 2016, 11:36 AM
rnk requested changes to this revision.Feb 16 2016, 11:45 AM
rnk edited edge metadata.

I suspect that this does not do the right thing on Windows. Now --libs prints Unix style -l options, instead of paths as it was made to do in the revision you're pointing at.

This revision now requires changes to proceed.Feb 16 2016, 11:45 AM

Ehsan, what did you intend the behavior of --libs on Windows to be? We definitely want to use -l flags on Unix, like we did before.

It does not do anything special on any OS, but I guess it should. I'm happy to adjust it for Windows if you give me the specification.

rivanvx updated this revision to Diff 48175.Feb 17 2016, 5:18 AM
rivanvx edited edge metadata.

Handle Windows first, output full path. Elsewhere, output -l and library name.

rnk, ehsan, any comments? Anything else I should do?

ehsan edited edge metadata.Feb 22 2016, 12:37 PM

(Sorry for the delay, I just got back from vacation!)

In D17300#353762, @rnk wrote:

Ehsan, what did you intend the behavior of --libs on Windows to be? We definitely want to use -l flags on Unix, like we did before.

The right behavior on Windows would be to print the path to the library so that the linker picks it up, as this patch does.

tools/llvm-config/llvm-config.cpp
674 ↗(On Diff #48175)

Nit: you can hoist this own into the else branch.

675 ↗(On Diff #48175)

This will do the wrong thing on Cygwin/Mingw (see the code around line 359.)

I think you should check isWindowsMSVCEnvironment() here instead.

ehsan accepted this revision.Feb 22 2016, 12:37 PM
ehsan edited edge metadata.
rivanvx updated this revision to Diff 49626.Mar 2 2016, 8:07 AM
rivanvx edited edge metadata.
rivanvx marked 2 inline comments as done.

Sorry for the delay, I only read "ehsan accepted this revision" and did not notice there were comments.

pxli168 accepted this revision.Mar 7 2016, 6:53 PM
pxli168 added a reviewer: pxli168.
pxli168 added a subscriber: pxli168.

LGTM!
It fixed the problem that our project could not built with llvm 3.9.
Hope this fix can merge in soon.
Thanks.

@rnk can you re-review?

rnk accepted this revision.Mar 14 2016, 2:39 PM
rnk edited edge metadata.

lgtm, committing

This revision is now accepted and ready to land.Mar 14 2016, 2:39 PM
This revision was automatically updated to reflect the committed changes.