summaryrefslogtreecommitdiff
blob: 6634cdebe351601e27b890c8e2248036c9c8e050 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
From aeddc35a35c55f487977d7609060225e03e2028b Mon Sep 17 00:00:00 2001
From: Michal Gorny <mgorny@gentoo.org>
Date: Tue, 4 Oct 2016 06:09:18 +0000
Subject: [PATCH] [cmake] Reintroduce (ldconfig-compatible) SOVERSIONs on
 shared libraries

Reintroduce versioning of shared libraries via SOVERSION, addressing
the issues with the previous design, since Gentoo is relying
on shared-split install of LLVM. The SOVERSIONs were originally
introduced in r229720 for all libraries, and removed in r252093 in favor
of custom SONAME. As far as I understand, the major concern with the old
versioning was that the used versions were incompatible with ldconfig.

Having considered that, this commit introduce SOVERSIONS with the
following considerations:

1. SOVERSIONs are formed of major & minor version concatenated -- i.e.
for 4.0 its .so.40. This matches the common practice where the first
version number indicates ABI breakage, and therefore fixes the issues
with ldconfig. Additionally, VERSION with the remaining verion
components appended is used, however this is not strictly necessary.

2. The versioning is only applied to libraries with no explicit SONAME
specified -- i.e. it won't apply to libLLVM but only to the split
libraries. It will also apply to libraries installed by the subprojects.

3. The versioning is only done on *nix systems, Darwin excluded. This
matches the current use of SONAME.

Differential Revision: https://reviews.llvm.org/D24757

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283189 91177308-0d34-0410-b5e6-96231b3b80d8
---
 cmake/modules/AddLLVM.cmake | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
index 37b3b80..7cb1b0c 100644
--- a/cmake/modules/AddLLVM.cmake
+++ b/cmake/modules/AddLLVM.cmake
@@ -450,6 +450,18 @@ function(llvm_add_library name)
         PREFIX ""
         )
     endif()
+
+    # Set SOVERSION on shared libraries that lack explicit SONAME
+    # specifier, on *nix systems that are not Darwin.
+    if(UNIX AND NOT APPLE AND NOT ARG_SONAME)
+      set_target_properties(${name}
+        PROPERTIES
+		# Concatenate the version numbers since ldconfig expects exactly
+		# one component indicating the ABI version, while LLVM uses
+		# major+minor for that.
+        SOVERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_MINOR}
+        VERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX})
+    endif()
   endif()
 
   if(ARG_MODULE OR ARG_SHARED)
-- 
2.10.0