Skip to content

Commit

Permalink
Merge pull request #3940 from bdbaddog/fix_3933
Browse files Browse the repository at this point in the history
Fix Issue #3933 and applelink's versioned shared library file and symlink naming.
  • Loading branch information
bdbaddog authored May 3, 2021
2 parents 61cda1d + 75871f6 commit 269df48
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
IMPLIBNOVERSIONSYMLINKS and LDMODULENOVERSIONSYMLINKS to True.
- Added --experimental flag, to enable various experimental features/tools. You can specify
'all', 'none', or any combination of available experimental features.
- Fix Issue #3933 - Remove unguarded print of debug information in SharedLibrary logic when
SHLIBVERSION is specified.
- Fix versioned shared library naming for MacOS platform. (Previously was libxyz.dylib.1.2.3,
has been fixed to libxyz.1.2.3.dylib. Additionally the sonamed symlink had the same issue,
that is now resolved as well)

From David H:
- Fix Issue #3906 - `IMPLICIT_COMMAND_DEPENDENCIES` was not properly disabled when
Expand Down
22 changes: 21 additions & 1 deletion SCons/Tool/applelink.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
# Even though the Mac is based on the GNU toolchain, it doesn't understand
# the -rpath option, so we use the "link" tool instead of "gnulink".
from SCons.Util import CLVar

from SCons.Errors import UserError
from . import link

# User programmatically describes how SHLIBVERSION maps to values for compat/current.
Expand Down Expand Up @@ -141,6 +141,24 @@ def _applelib_compatVersionFromSoVersion(source, target, env, for_signature):

return "-Wl,-compatibility_version,%s" % version_string

def _applelib_soname(target, source, env, for_signature):
"""
Override default _soname() function from SCons.Tools.linkCommon.SharedLibrary.
Apple's file naming for versioned shared libraries puts the version string before
the shared library suffix (.dylib), instead of after.
"""
if "SONAME" in env:
# Now verify that SOVERSION is not also set as that is not allowed
if "SOVERSION" in env:
raise UserError(
"Ambiguous library .so naming, both SONAME: %s and SOVERSION: %s are defined. "
"Only one can be defined for a target library."
% (env["SONAME"], env["SOVERSION"])
)
return "$SONAME"
else:
return "$SHLIBPREFIX$_get_shlib_stem$_SHLIBSOVERSION${SHLIBSUFFIX}"


def generate(env):
"""Add Builders and construction variables for applelink to an
Expand Down Expand Up @@ -178,6 +196,8 @@ def generate(env):
env['__LDMODULEVERSIONFLAGS'] = '${__lib_either_version_flag(__env__,' \
'"LDMODULEVERSION","_APPLELINK_CURRENT_VERSION", "_LDMODULEVERSIONFLAGS")}'

env["_SHLIBSONAME"] = _applelib_soname


def exists(env):
return env['PLATFORM'] == 'darwin'
Expand Down
6 changes: 5 additions & 1 deletion SCons/Tool/linkCommon/SharedLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,12 @@ def _get_shlib_dir(target, source, env, for_signature: bool) -> str:
Returns:
the directory the library will be in (empty string if '.')
"""
verbose = False

if target.dir and str(target.dir) != ".":
print("target.dir:%s" % target.dir)
if verbose:
print("_get_shlib_dir: target.dir:%s" % target.dir)

return "%s/" % str(target.dir)
else:
return ""
Expand Down
4 changes: 2 additions & 2 deletions test/LINK/SHLIBVERSIONFLAGS.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
soname = 'libfoo.so.4'
sonameVersionFlags = r".+ -h %s( .+)+" % soname
elif 'applelink' in tool_list:
versionflags = r" 'libfoo.1.dylib'->'libfoo.1.2.3.dylib'"
versionflags = r".+ -Wl,-current_version,1.2.3( .+)+"
soname = 'libfoo.4.dylib'
sonameVersionFlags = r" '%s'->'libfoo.1.2.3.dylib'(.+)+" % soname
sonameVersionFlags = r".+ -Wl,-compatibility_version,1.2.0(.+)+"
else:
test.skip_test('No testable linkers found, skipping the test\n')

Expand Down

0 comments on commit 269df48

Please sign in to comment.