Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 511036 | Differences between
and this patch

Collapse All | Expand All

(-)a/src/engine/SCons/Tool/__init__.py (-3 / +3 lines)
Lines 256-262 Link Here
256
        if Verbose:
256
        if Verbose:
257
            print "VersionShLibLinkNames: linkname = ",linkname
257
            print "VersionShLibLinkNames: linkname = ",linkname
258
        linknames.append(linkname)
258
        linknames.append(linkname)
259
    elif platform == 'posix':
259
    elif platform == 'posix' or platform == 'aix':
260
        if sys.platform.startswith('openbsd'):
260
        if sys.platform.startswith('openbsd'):
261
            # OpenBSD uses x.y shared library versioning numbering convention
261
            # OpenBSD uses x.y shared library versioning numbering convention
262
            # and doesn't use symlinks to backwards-compatible libraries
262
            # and doesn't use symlinks to backwards-compatible libraries
Lines 305-311 Link Here
305
305
306
    if version:
306
    if version:
307
        # set the shared library link flags
307
        # set the shared library link flags
308
        if platform == 'posix':
308
        if platform == 'posix' or platform == 'aix':
309
            shlink_flags += [ '-Wl,-Bsymbolic' ]
309
            shlink_flags += [ '-Wl,-Bsymbolic' ]
310
            # OpenBSD doesn't usually use SONAME for libraries
310
            # OpenBSD doesn't usually use SONAME for libraries
311
            if not sys.platform.startswith('openbsd'):
311
            if not sys.platform.startswith('openbsd'):
Lines 741-747 Link Here
741
        ars = ['ar']
741
        ars = ['ar']
742
    elif str(platform) == 'aix':
742
    elif str(platform) == 'aix':
743
        "prefer AIX Visual Age tools on AIX"
743
        "prefer AIX Visual Age tools on AIX"
744
        linkers = ['aixlink', 'gnulink']
744
        linkers = ['aixlink'] # build SONAME enabled shared libs with either gcc or xlc
745
        c_compilers = ['aixcc', 'gcc', 'cc']
745
        c_compilers = ['aixcc', 'gcc', 'cc']
746
        cxx_compilers = ['aixc++', 'g++', 'c++']
746
        cxx_compilers = ['aixc++', 'g++', 'c++']
747
        assemblers = ['as', 'gas']
747
        assemblers = ['as', 'gas']
(-)a/src/engine/SCons/Tool/aixc++.py (+1 lines)
Lines 60-65 Link Here
60
60
61
    if 'CXX' not in env:
61
    if 'CXX' not in env:
62
        env['CXX'] = _cxx
62
        env['CXX'] = _cxx
63
        env['CXXVENDOR'] = 'XLC'
63
64
64
    cplusplus.generate(env)
65
    cplusplus.generate(env)
65
66
(-)a/src/engine/SCons/Tool/aixcc.py (+1 lines)
Lines 58-63 Link Here
58
58
59
    if version:
59
    if version:
60
        env['CCVERSION'] = version
60
        env['CCVERSION'] = version
61
        env['CCVENDOR'] = 'XLC'
61
62
62
def exists(env):
63
def exists(env):
63
    path, _cc, version = get_xlc(env)
64
    path, _cc, version = get_xlc(env)
(-)a/src/engine/SCons/Tool/aixlink.py (-4 / +169 lines)
Lines 34-39 Link Here
34
34
35
import os
35
import os
36
import os.path
36
import os.path
37
import subprocess
37
38
38
import SCons.Util
39
import SCons.Util
39
40
Lines 48-53 Link Here
48
            return '-qtempinc=' + os.path.join(build_dir, 'tempinc')
49
            return '-qtempinc=' + os.path.join(build_dir, 'tempinc')
49
    return ''
50
    return ''
50
51
52
def smart_rpath(target, source, env, for_signature):
53
    if not env.subst('$RPATH'):
54
        return None # let the -L arguments form the rpath
55
    # need the quotes, probably for issue#1123
56
    return '"${vWl}-blibpath:${RPATH}:/usr/lib:/lib"'
57
58
class vendor:
59
    def __init__(self, vendordict):
60
        self.vendordict = vendordict
61
        pass
62
    def __call__(self, target, source, env, for_signature = None):
63
        vendor = env.subst('$LINKVENDOR')
64
        result = self.vendordict.get(vendor,'')
65
        return result
66
    pass
67
68
def getBits(target, source, env):
69
    """Determine whether the first source object file this is 32 or 64 bits."""
70
    with open(str(source[0]), "rb") as s:
71
        magic = s.read(2)
72
        if magic == '\x01\xdf': return 32
73
        if magic == '\x01\xf7': return 64
74
    raise SCons.Errors.BuildError(
75
        errstr='Cannot infer bitness, magic='+magic,
76
        node = target, filename = source[0],
77
        exc_info = exc_info,
78
    )
79
80
def getShrBase(target, source, env, for_signature):
81
    """Get the bits (32 or 64) from the first source object file."""
82
    #if for_signature:
83
    #    return 'shr'
84
    bits = getBits(target, source, env)
85
    if bits == 64: return 'shr_64'
86
    return 'shr'
87
88
def parseLinkflags(flags, env):
89
    """Find the soname in the linker flags, and fix scons-hardcoded flags for AIX linker."""
90
91
    result = { 'soname': '', 'flags': SCons.Util.CLVar() }
92
    longopt = ''
93
    for flag in SCons.Util.CLVar(flags):
94
        if flag.startswith('"'):
95
            flag = flag.strip('"')
96
        if flag.startswith('-Wl,'):
97
            Wl = "${vWl}"
98
            ldflags = flag.split(',')[1:] # "-Wl,-flag1,-flag2"
99
        else:
100
            Wl = ''
101
            ldflags = [ flag ]
102
        for ldflag in ldflags:
103
            ldflag = longopt + ldflag
104
            longopt = ''
105
            if ldflag == '-soname':
106
                longopt = '-soname='
107
                continue
108
            if ldflag.startswith('-soname='):
109
                result['soname'] = ldflag[8:]
110
                continue
111
            if ldflag == '-Bsymbolic': # hardcoded in Tool/__init__.py
112
                ldflag = '-bsymbolic' # TODO: identify whether ld is GNU
113
            # need the quotes, probably for issue#1123
114
            result['flags'].append('"' + Wl + ldflag + '"')
115
    return result
116
117
class linkflagsFilter:
118
    def __init__(self, linkflagsvar):
119
        self.linkflagsvar = linkflagsvar
120
    def __call__(self, target, source, env, for_signature):
121
        return parseLinkflags(env.subst('$'+self.linkflagsvar, target=target, source=source), env).get('flags', '')
122
    pass
123
124
def createImportFile_str(importfile, linkflags, target, source, env):
125
    return 'CreateImportFile("%s")' % importfile
126
127
def createImportFile_func(importfile, linkflags, target, source, env):
128
129
    shrbase = env.subst('$SHR', target=SCons.Util.CLVar(target), source=SCons.Util.CLVar(source))
130
131
    bits = 32
132
    if '64' in shrbase:
133
        bits = 64
134
135
    soname = parseLinkflags(linkflags, env).get('soname', target)
136
137
    symbols = {}
138
    ignoreable = False
139
    # TODO: support GNU nm; this is native AIX nm
140
    symreader = SCons.Action._subproc(env,
141
        SCons.Util.CLVar("nm -X%d -PCpgl %s" % (bits, source)),
142
        error = 'raise',
143
        stdin = 'devnull',
144
        stderr = subprocess.PIPE,
145
        stdout = subprocess.PIPE)
146
    outlines, errlines = symreader.communicate()
147
    errors = ''
148
    for line in outlines.split('\n'):
149
        if not line or line.startswith('.') or line.endswith(':'):
150
            continue
151
        tokens = line.split() # symname type addr
152
        if len(tokens) < 3:
153
            continue
154
        if tokens[1] not in 'TDBWVZ':
155
            continue
156
        if tokens[1] in 'WVZ':
157
            tokens[0] += ' weak'
158
        symbols[tokens[0]] = None
159
    for line in errlines.split('\n'):
160
        if not line:
161
            continue
162
        if '0654-203' in line: # nm: lib.so[shr.imp]: 0654-203 Specify an XCOFF object module.
163
            ignoreable = True
164
            continue
165
        errors += line + '\n'
166
    if symreader.returncode and (not ignoreable or errors):
167
        # Import Files found as archive members trigger an error
168
        raise SCons.Errors.BuildError(
169
            errstr='Error %d from nm reading symbols from %s:\n%s' % ( symreader.returncode, source, errors ),
170
            node = target, filename = source[0],
171
        )
172
173
    with open(importfile, "wb") as imp:
174
        imp.write('#! %s(%s.o)\n# %d\n' % (soname, shrbase, bits))
175
        for sym in symbols.keys():
176
            imp.write(sym + '\n')
177
    pass
178
51
def generate(env):
179
def generate(env):
52
    """
180
    """
53
    Add Builders and construction variables for Visual Age linker to
181
    Add Builders and construction variables for Visual Age linker to
Lines 56-68 Link Here
56
    link.generate(env)
184
    link.generate(env)
57
185
58
    env['SMARTLINKFLAGS'] = smart_linkflags
186
    env['SMARTLINKFLAGS'] = smart_linkflags
59
    env['LINKFLAGS']      = SCons.Util.CLVar('$SMARTLINKFLAGS')
187
    env['_RPATH']         = smart_rpath
60
    env['SHLINKFLAGS']    = SCons.Util.CLVar('$LINKFLAGS -qmkshrobj -qsuppress=1501-218')
188
    env['SHR']            = getShrBase
61
    env['SHLIBSUFFIX']    = '.a'
189
    env['EXPSYMFILE']     = '${TARGET}.d/${SHR}.imp'
190
191
    env['vLINKFLAGS']     = vendor({ 'XLC': '$SMARTLINKFLAGS -qsuppress=1501-218' })
192
    env['vWl']            = vendor({ 'GNU': '-Wl,', '': '-Wl,' })
193
    env['vShared']        = vendor({ 'GNU': '-shared' })
194
195
    # need the quotes, probably for issue#1123
196
    env['LINKFLAGS']      = '${vLINKFLAGS}'
197
    env['LINKCOM']        = '$LINK "${vWl}-brtl" -o $TARGET $LINKFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS'
198
199
    env['SHLINKFLAGS']    = "${LINKFLAGS}"
200
201
    CreateImportFile = SCons.Action.ActionFactory(createImportFile_func, createImportFile_str)
202
203
    env['SHLINKFLAGSfiltered'] = linkflagsFilter('SHLINKFLAGS')
204
    env['SHLINKCOM']      = [
205
        SCons.Defaults.Delete('${TARGET}.d'),
206
        SCons.Defaults.Mkdir('${TARGET}.d'),
207
        CreateImportFile('$EXPSYMFILE', '$SHLINKFLAGS', '$TARGET', '$SOURCES', '$__env__'),
208
        # need the quotes, probably for issue#1123
209
        '${SHLINK} ${vShared} "${vWl}-G" -o ${TARGET}.d/${SHR}.o "${vWl}-bexport:${EXPSYMFILE}" $SHLINKFLAGSfiltered $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS',
210
        # SCons.Defaults.Move('${TARGET}.d/${SHR}.o', '$TARGET'),
211
        'strip -e ${TARGET}.d/${SHR}.o',
212
        '$AR $ARFLAGS $TARGET ${TARGET}.d/${SHR}.o ${TARGET}.d/${SHR}.imp',
213
        SCons.Defaults.Delete('${TARGET}.d'),
214
    ]
215
216
    env['LDMODULEFLAGSfiltered'] = linkflagsFilter('LDMODULEFLAGS')
217
    env['LDMODULECOM'] = [
218
        SCons.Defaults.Delete('${TARGET}.d'),
219
        SCons.Defaults.Mkdir('${TARGET}.d'),
220
        CreateImportFile('$EXPSYMFILE', '$LDMODULEFLAGS', '$TARGET', '$SOURCES', '$__env__'),
221
        # need the quotes, probably for issue#1123
222
        '$LDMODULE ${vShared} "${vWl}-G" -o ${TARGET}.d/${SHR}.o "${vWl}-bexport:${EXPSYMFILE}" $LDMODULEFLAGSfiltered $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS',
223
        'strip -e ${TARGET}.d/${SHR}.o',
224
        '$AR $ARFLAGS $TARGET ${TARGET}.d/${SHR}.o',
225
        SCons.Defaults.Delete('${TARGET}.d'),
226
    ]
62
227
63
def exists(env):
228
def exists(env):
64
    # TODO: sync with link.smart_link() to choose a linker
229
    # TODO: sync with link.smart_link() to choose a linker
65
    linkers = { 'CXX': ['aixc++'], 'CC': ['aixcc'] }
230
    linkers = { 'CXX': ['aixc++', 'g++'], 'CC': ['aixcc', 'gcc'] }
66
    alltools = []
231
    alltools = []
67
    for langvar, linktools in linkers.items():
232
    for langvar, linktools in linkers.items():
68
        if langvar in env: # use CC over CXX when user specified CC but not CXX
233
        if langvar in env: # use CC over CXX when user specified CC but not CXX
(-)a/src/engine/SCons/Tool/g++.py (-3 / +3 lines)
Lines 57-65 Link Here
57
57
58
    # platform specific settings
58
    # platform specific settings
59
    if env['PLATFORM'] == 'aix':
59
    if env['PLATFORM'] == 'aix':
60
        env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -mminimal-toc')
60
        env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -mminimal-toc -fPIC')
61
        env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1
61
        env['SHOBJSUFFIX'] = '.pic.o'
62
        env['SHOBJSUFFIX'] = '$OBJSUFFIX'
63
    elif env['PLATFORM'] == 'hpux':
62
    elif env['PLATFORM'] == 'hpux':
64
        env['SHOBJSUFFIX'] = '.pic.o'
63
        env['SHOBJSUFFIX'] = '.pic.o'
65
    elif env['PLATFORM'] == 'sunos':
64
    elif env['PLATFORM'] == 'sunos':
Lines 68-73 Link Here
68
    version = gcc.detect_version(env, env['CXX'])
67
    version = gcc.detect_version(env, env['CXX'])
69
    if version:
68
    if version:
70
        env['CXXVERSION'] = version
69
        env['CXXVERSION'] = version
70
        env['CXXVENDOR'] = 'GNU'
71
71
72
def exists(env):
72
def exists(env):
73
    # is executable, and is a GNU compiler (or accepts '--version' at least)
73
    # is executable, and is a GNU compiler (or accepts '--version' at least)
(-)a/src/engine/SCons/Tool/gcc.py (+1 lines)
Lines 58-63 Link Here
58
    version = detect_version(env, env['CC'])
58
    version = detect_version(env, env['CC'])
59
    if version:
59
    if version:
60
        env['CCVERSION'] = version
60
        env['CCVERSION'] = version
61
        env['CCVENDOR'] = 'GNU'
61
62
62
def exists(env):
63
def exists(env):
63
    # is executable, and is a GNU compiler (or accepts '--version' at least)
64
    # is executable, and is a GNU compiler (or accepts '--version' at least)
(-)a/src/engine/SCons/Tool/install.py (-2 / +2 lines)
Lines 149-155 Link Here
149
    """Check if dest is a version shared library name. Return version, libname, & install_dir if it is."""
149
    """Check if dest is a version shared library name. Return version, libname, & install_dir if it is."""
150
    Verbose = False
150
    Verbose = False
151
    platform = env.subst('$PLATFORM')
151
    platform = env.subst('$PLATFORM')
152
    if not (platform == 'posix'  or platform == 'darwin'):
152
    if not (platform == 'posix'  or platform == 'darwin' or platform == 'aix'):
153
        return (None, None, None)
153
        return (None, None, None)
154
154
155
    libname = os.path.basename(dest)
155
    libname = os.path.basename(dest)
Lines 160-166 Link Here
160
    
160
    
161
    version_re = re.compile("[0-9]+\\.[0-9]+\\.[0-9a-zA-Z]+")
161
    version_re = re.compile("[0-9]+\\.[0-9]+\\.[0-9a-zA-Z]+")
162
    version_File = None
162
    version_File = None
163
    if platform == 'posix':
163
    if platform == 'posix' or platform == 'aix':
164
        # handle unix names
164
        # handle unix names
165
        versioned_re = re.compile(re.escape(shlib_suffix + '.') + "[0-9]+\\.[0-9]+\\.[0-9a-zA-Z]+")
165
        versioned_re = re.compile(re.escape(shlib_suffix + '.') + "[0-9]+\\.[0-9]+\\.[0-9a-zA-Z]+")
166
        result = versioned_re.findall(libname)
166
        result = versioned_re.findall(libname)
(-)a/src/engine/SCons/Tool/link.py (-4 / +9 lines)
Lines 61-64 Link Here
61
            SCons.Warnings.warn(SCons.Warnings.FortranCxxMixWarning,
61
            SCons.Warnings.warn(SCons.Warnings.FortranCxxMixWarning,
62
                                msg % env.subst('$CXX'))
62
                                msg % env.subst('$CXX'))
63
            issued_mixed_link_warning = True
63
            issued_mixed_link_warning = True
64
        env['LINKVENDOR'] = '$CXXVENDOR'
64
        return '$CXX'
65
        return '$CXX'
65
    elif has_d:
66
    elif has_d:
66
        env['LINKCOM'] = env['DLINKCOM']
67
        env['LINKCOM'] = env['DLINKCOM']
67
        env['SHLINKCOM'] = env['SHDLINKCOM']
68
        env['SHLINKCOM'] = env['SHDLINKCOM']
69
        env['LINKVENDOR'] = '$DCVENDOR'
68
        return '$DC'
70
        return '$DC'
69
-- a/src/engine/SCons/Tool/link.py
71
++ b/src/engine/SCons/Tool/link.py
Lines 61-67 Link Here
61
    elif has_fortran:
61
    elif has_fortran:
62
        env['LINKVENDOR'] = '$FORTRANVENDOR'
62
        return '$FORTRAN'
63
        return '$FORTRAN'
63
    elif has_cplusplus:
64
    elif has_cplusplus:
65
        env['LINKVENDOR'] = '$CXXVENDOR'
64
        return '$CXX'
66
        return '$CXX'
67
    env['LINKVENDOR'] = '$CCVENDOR'
65
    return '$CC'
68
    return '$CC'
66
69
67
def shlib_emitter(target, source, env):
70
def shlib_emitter(target, source, env):
Lines 105-111 Link Here
105
            # We need a version of the form x.y.z to proceed
110
            # We need a version of the form x.y.z to proceed
106
            raise ValueError
111
            raise ValueError
107
        if version:
112
        if version:
108
            if platform == 'posix':
113
            if platform == 'posix' or platform == 'aix':
109
                versionparts = version.split('.')
114
                versionparts = version.split('.')
110
                name = target[0].name
115
                name = target[0].name
111
                # generate library name with the version number
116
                # generate library name with the version number
Lines 156-161 Link Here
156
    SCons.Tool.createProgBuilder(env)
161
    SCons.Tool.createProgBuilder(env)
157
162
158
    env['SHLINK']      = '$LINK'
163
    env['SHLINK']      = '$LINK'
164
    env['SHLINKVENDOR'] = '$LINKVENDOR'
159
    env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -shared')
165
    env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -shared')
160
    env['SHLINKCOM']   = '$SHLINK -o $TARGET $SHLINKFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS'
166
    env['SHLINKCOM']   = '$SHLINK -o $TARGET $SHLINKFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS'
161
    # don't set up the emitter, cause AppendUnique will generate a list
167
    # don't set up the emitter, cause AppendUnique will generate a list
Lines 174-187 Link Here
174
180
175
    if env['PLATFORM'] == 'hpux':
181
    if env['PLATFORM'] == 'hpux':
176
        env['SHLIBSUFFIX'] = '.sl'
182
        env['SHLIBSUFFIX'] = '.sl'
177
    elif env['PLATFORM'] == 'aix':
178
        env['SHLIBSUFFIX'] = '.a'
179
183
180
    # For most platforms, a loadable module is the same as a shared
184
    # For most platforms, a loadable module is the same as a shared
181
    # library.  Platforms which are different can override these, but
185
    # library.  Platforms which are different can override these, but
182
    # setting them the same means that LoadableModule works everywhere.
186
    # setting them the same means that LoadableModule works everywhere.
183
    SCons.Tool.createLoadableModuleBuilder(env)
187
    SCons.Tool.createLoadableModuleBuilder(env)
184
    env['LDMODULE'] = '$SHLINK'
188
    env['LDMODULE'] = '$SHLINK'
189
    env['LDMODULEVENDOR'] = '$SHLINKVENDOR'
185
    # don't set up the emitter, cause AppendUnique will generate a list
190
    # don't set up the emitter, cause AppendUnique will generate a list
186
    # starting with None :-(
191
    # starting with None :-(
187
    env.Append(LDMODULEEMITTER='$SHLIBEMITTER')
192
    env.Append(LDMODULEEMITTER='$SHLIBEMITTER')

Return to bug 511036