aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Marcel Hlopko <hlopko@google.com>2016-12-16 16:45:54 +0000
committerGravatar John Cater <jcater@google.com>2016-12-16 17:08:00 +0000
commitbb984fd26f0fc9b519eb11fe330852f8d1b708a7 (patch)
treed3bc6fa6999b48a2f24083f7cfb43ce7f73b4b8e /src
parentd2997290078e9e5114d604a6cedefda0f0c6dec4 (diff)
*** Reason for rollback *** Rolling forward, cl fixing underlying issue is uploaded, will land this one as soon as I get lgtm to the fix from emscripten crosstool owners. *** Original change description *** Automated [] rollback of commit 2d87bf1937c81ef84358fd5f6a372875f6c6fabf. *** Reason for rollback *** We have to roll back unknown commit, on which this one depends. Will resubmit after I fix the underlying issue. *** Original change description *** Support versioned shared library targets for cc_binary linkshared=1 This change allows versioned shared libraries (e.g. "libfoo.so.1.2") to be built and linked. -- PiperOrigin-RevId: 142263653 MOS_MIGRATED_REVID=142263653
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java6
2 files changed, 9 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java
index f1146956d7..9b190eff72 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java
@@ -194,7 +194,9 @@ public abstract class CcBinary implements RuleConfiguredTargetFactory {
}
Artifact binary = ruleContext.getBinArtifact(binaryPath);
- if (isLinkShared(ruleContext) && !CppFileTypes.SHARED_LIBRARY.matches(binary.getFilename())) {
+ if (isLinkShared(ruleContext)
+ && !CppFileTypes.SHARED_LIBRARY.matches(binary.getFilename())
+ && !CppFileTypes.VERSIONED_SHARED_LIBRARY.matches(binary.getFilename())) {
ruleContext.attributeError("linkshared", "'linkshared' used in non-shared library");
return null;
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java
index 35f16bfbbc..2b0d081268 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java
@@ -1537,8 +1537,14 @@ public class CppLinkActionBuilder {
String name = inputArtifact.getFilename();
boolean inputIsWholeArchive = !isRuntimeLinkerInput && needWholeArchive;
if (CppFileTypes.SHARED_LIBRARY.matches(name)) {
+ // Use normal shared library resolution rules for shared libraries.
String libName = name.replaceAll("(^lib|\\.(so|dylib)$)", "");
librariesToLink.addValue(new LibraryToLinkValue("-l" + libName, inputIsWholeArchive));
+ } else if (CppFileTypes.VERSIONED_SHARED_LIBRARY.matches(name)) {
+ // Versioned shared libraries require the exact library filename, e.g.:
+ // -lfoo -> libfoo.so
+ // -l:libfoo.so.1 -> libfoo.so.1
+ librariesToLink.addValue(new LibraryToLinkValue("-l:" + name, inputIsWholeArchive));
} else {
// Interface shared objects have a non-standard extension
// that the linker won't be able to find. So use the