Commits

dirkbaechle committed 303b85f

- fix for #2916, "Issues with versioned SharedLibrary under OpenBSD"

  • Participants
  • Parent commits 4170735

Comments (0)

Files changed (3)

 
 RELEASE 2.3.1.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE
 
+  From Stefan Sperling:
+    - Fixed the setup of linker flags for a versioned SharedLibrary
+      under OpenBSD (#2916).
+
   From David Rothenberger:
     - Added cyglink linker that uses Cygwin naming conventions for
       shared libraries and automatically generates import libraries.

src/engine/SCons/Tool/__init__.py

             print "VersionShLibLinkNames: linkname = ",linkname
         linknames.append(linkname)
     elif platform == 'posix':
+        if sys.platform.startswith('openbsd'):
+            # OpenBSD uses x.y shared library versioning numbering convention
+            # and doesn't use symlinks to backwards-compatible libraries
+            return []
         # For libfoo.so.x.y.z, linknames libfoo.so libfoo.so.x.y libfoo.so.x
         suffix_re = re.escape(shlib_suffix + '.' + version)
         # First linkname has no version number
     if version:
         # set the shared library link flags
         if platform == 'posix':
-            suffix_re = re.escape(shlib_suffix + '.' + version)
-            (major, age, revision) = version.split(".")
-            # soname will have only the major version number in it
-            soname = re.sub(suffix_re, shlib_suffix, libname) + '.' + major
-            shlink_flags += [ '-Wl,-Bsymbolic', '-Wl,-soname=%s' % soname ]
-            if Verbose:
-                print " soname ",soname,", shlink_flags ",shlink_flags
+            shlink_flags += [ '-Wl,-Bsymbolic' ]
+            # OpenBSD doesn't usually use SONAME for libraries
+            if not sys.platform.startswith('openbsd'):
+                # continue setup of shlink flags for all other POSIX systems
+                suffix_re = re.escape(shlib_suffix + '.' + version)
+                (major, age, revision) = version.split(".")
+                # soname will have only the major version number in it
+                soname = re.sub(suffix_re, shlib_suffix, libname) + '.' + major
+                shlink_flags += [ '-Wl,-soname=%s' % soname ]
+                if Verbose:
+                    print " soname ",soname,", shlink_flags ",shlink_flags
         elif platform == 'cygwin':
             shlink_flags += [ '-Wl,-Bsymbolic',
                               '-Wl,--out-implib,${TARGET.base}.a' ]

test/Libs/SharedLibrary.py

 Default(env.Library(target = 'foo', source = obj))
 """)
 
+test.write('SConstructBaz', """
+env=Environment()
+env['SHLIBVERSION'] = '1.0.0'
+obj = env.SharedObject('baz', 'foo.c')
+Default(env.SharedLibrary(target = 'baz', source = obj))
+""")
+
 test.write('foo.c', r"""
 #include <stdio.h>
 
     test.run(program = test.workpath('progbar'),
              stdout = "f4.c\nprogbar.c\n")
 
+if sys.platform.startswith('openbsd'):
+    # Make sure we don't link libraries with -Wl,-soname on OpenBSD.
+    test.run(arguments = '-f SConstructBaz')
+    for line in test.stdout().split('\n'):
+        test.fail_test(line.find('-Wl,-soname=libbaz.so') != -1)
+
 test.pass_test()
 
 # Local Variables: