Commits

Gary Oberbrunner committed 0ff1849 Merge

Merged in russel/scons (pull request #130) - D language fixes

Fix Issues 2939 and 2940

Comments (0)

Files changed (31)

src/engine/SCons/Platform/posix.py

     # This platform supports RPATH specifications.
     env['__RPATH'] = '$_RPATH'
 
+    # GDC is GCC family, but DMD and LDC have different options.
+    # Must be able to have GCC and DMD work in the same build, so:
+    env['__DRPATH'] = '$_DRPATH'
+
 # Local Variables:
 # tab-width:4
 # indent-tabs-mode:nil

src/engine/SCons/Tool/dmd.py

     env['DVERSIONS'] = []
     env['DDEBUG'] = []
 
-    #env['SHOBJSUFFIX'] = '.os'
-    #env['OBJSUFFIX'] = '.o'
     env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 0
 
     if env['DC']:
     env['DFILESUFFIX'] = '.d'
 
     env['DLINK'] = '$DC'
-    env['DLINKCOM'] = '$DLINK -of$TARGET $SOURCES $DFLAGS $DLINKFLAGS $_DLINKLIBFLAGS'
-    env['SHDLINKCOM'] = '$DLINK -shared -defaultlib=libphobos2.so -of$TARGET $SOURCES $DFLAGS $DLINKFLAGS $_DLINKLIBFLAGS'
+    env['DLINKFLAGS'] = SCons.Util.CLVar('')
+    env['DLINKCOM'] = '$DLINK -of$TARGET $DLINKFLAGS $__DRPATH $SOURCES $_DLIBDIRFLAGS $_DLIBFLAGS'
+
+    env['DSHLINK'] = '$DC'
+    env['DSHLINKFLAGS'] = SCons.Util.CLVar('$DLINKFLAGS -shared -defaultlib=libphobos2.so')
+    env['SHDLINKCOM'] = '$DLINK -of$TARGET $DSHLINKFLAGS $__DRPATH $SOURCES $_DLIBDIRFLAGS $_DLIBFLAGS'
+
+    env['DLIBLINKPREFIX'] = '' if env['PLATFORM'] == 'win32' else '-L-l'
+    env['DLIBLINKSUFFIX'] = '.lib' if env['PLATFORM'] == 'win32' else ''
+    env['_DLIBFLAGS'] = '${_stripixes(DLIBLINKPREFIX, LIBS, DLIBLINKSUFFIX, LIBPREFIXES, LIBSUFFIXES,  __env__)}'
+
+    env['DLIBDIRPREFIX'] = '-L-L'
+    env['DLIBDIRSUFFIX'] = ''
+    env['_DLIBDIRFLAGS'] = '$( ${_concat(DLIBDIRPREFIX, LIBPATH, DLIBDIRSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
+
 
     env['DLIB'] = 'lib' if env['PLATFORM'] == 'win32' else 'ar cr'
-    env['DLIBCOM'] = '$DLIB $_DLIBFLAGS {} $TARGET $SOURCES $_DLINKLIBFLAGS'.format('-c' if env['PLATFORM'] == 'win32' else '')
+    env['DLIBCOM'] = '$DLIB $_DLIBFLAGS {} $TARGET $SOURCES $_DLIBFLAGS'.format('-c' if env['PLATFORM'] == 'win32' else '')
 
-    env['_DLINKLIBFLAGS'] = '$( ${_concat(DLIBLINKPREFIX, LIBS, DLIBLINKSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
-    env['_DLIBFLAGS'] = '$( ${_concat(DLIBFLAGPREFIX, DLIBFLAGS, DLIBFLAGSUFFIX, __env__)} $)'
-    env['DLINKFLAGS'] = ['-L-L.']
-    env['DLIBLINKPREFIX'] = '' if env['PLATFORM'] == 'win32' else '-L-l'
-    env['DLIBLINKSUFFIX'] = '.lib' if env['PLATFORM'] == 'win32' else ''
+    #env['_DLIBFLAGS'] = '$( ${_concat(DLIBFLAGPREFIX, DLIBFLAGS, DLIBFLAGSUFFIX, __env__)} $)'
+
     env['DLIBFLAGPREFIX'] = '-'
     env['DLIBFLAGSUFFIX'] = ''
-    env['DLINKFLAGPREFIX'] = '-'
-    env['DLINKFLAGSUFFIX'] = ''
+
+    # __RPATH is set to $_RPATH in the platform specification if that
+    # platform supports it.
+    env['DRPATHPREFIX'] = '-L-rpath='
+    env['DRPATHSUFFIX'] = ''
+    env['_DRPATH'] = '${_concat(DRPATHPREFIX, RPATH, DRPATHSUFFIX, __env__)}'
 
     SCons.Tool.createStaticLibBuilder(env)
 

src/engine/SCons/Tool/dmd.xml

 
 <sconsdoc xmlns="http://www.scons.org/dbxsd/v1.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-          xsi:schemaLocation="http://www.scons.org/dbxsd/v1.0 http://www.scons.org/dbxsd/v1.0/scons.xsd">
+          xsi:schemaLocation="http://www.scons.org/dbxsd/v1.0/scons.xsd">
 
 <tool name="dmd">
 <summary>
 <para>
-Sets construction variables for D language compilers
-(the Digital Mars D compiler, or GDC).
+Sets construction variables for D language compiler DMD.
 </para>
 </summary>
 <sets>
 <item>DDEBUGSUFFIX</item>
 <item>DFLAGPREFIX</item>
 <item>DFLAGSUFFIX</item>
-<item>DFLESUFFIX</item>
+<item>DFILESUFFIX</item>
 <item>DLINK</item>
+<item>DLINKFLAGS</item>
 <item>DLINKCOM</item>
+<item>SHDLINK</item>
+<item>SHDLINKFLAGS</item>
 <item>SHDLINKCOM</item>
+<item>DLIBLINKPREFIX</item>
+<item>DLIBLINKSUFFIX</item>
+<item>_DLIBFLAGS</item>
+<item>DLIBDIRPREFIX</item>
+<item>DLIBDIRSUFFIX</item>
+<item>_DLIBDIRFLAGS</item>
 <item>DLIB</item>
 <item>DLIBCOM</item>
-<item>_DLINKLIBFLAGS</item>
 <item>_DLIBFLAGS</item>
-<item>DLINKFLAGS</item>
-<item>DLIBLINKPREFIX</item>
-<item>DLIBLINKSUFFIX</item>
 <item>DLIBFLAGPREFIX</item>
 <item>DLIBFLAGSUFFIX</item>
-<item>DLINKFLAGPREFIX</item>
-<item>DLINKFLAGSUFFIX</item>
+<item>RPATHPREFIX</item>
+<item>RPATHSUFFIX</item>
+<item>_RPATH</item>
 </sets>
 <uses>
 </uses>

src/engine/SCons/Tool/gdc.py

     env['DFILESUFFIX'] = '.d'
 
     env['DLINK'] = '$DC'
-    env['DLINKCOM'] = '$DLINK -o $TARGET $SOURCES $DFLAGS $DLINKFLAGS $_DLINKLIBFLAGS'
-    env['SHDLINKCOM'] = '$DLINK -o $TARGET $SOURCES $DFLAGS $DLINKFLAGS $_DLINKLIBFLAGS'
+    env['DLINKFLAGS'] = SCons.Util.CLVar('')
+    env['DLINKCOM'] = '$DLINK -o $TARGET $DLINKFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS'
+
+    env['SHDLINK'] = '$DC'
+    env['SHDLINKFLAGS'] = SCons.Util.CLVar('$DLINKFLAGS -shared')
+    env['SHDLINKCOM'] = '$DLINK -o $TARGET $DLINKFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS'
 
     env['DLIB'] = 'lib' if env['PLATFORM'] == 'win32' else 'ar cr'
     env['DLIBCOM'] = '$DLIB $_DLIBFLAGS {} $TARGET $SOURCES $_DLINKLIBFLAGS'.format('-c' if env['PLATFORM'] == 'win32' else '')
 
-    env['_DLINKLIBFLAGS'] = '$( ${_concat(DLIBLINKPREFIX, LIBS, DLIBLINKSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
     env['_DLIBFLAGS'] = '$( ${_concat(DLIBFLAGPREFIX, DLIBFLAGS, DLIBFLAGSUFFIX, __env__)} $)'
-    env['DLINKFLAGS'] = ['-L.']
-    env['DLIBLINKPREFIX'] = '' if env['PLATFORM'] == 'win32' else '-l'
-    env['DLIBLINKSUFFIX'] = '.lib' if env['PLATFORM'] == 'win32' else ''
+
     env['DLIBFLAGPREFIX'] = '-'
     env['DLIBFLAGSUFFIX'] = ''
     env['DLINKFLAGPREFIX'] = '-'
     env['DLINKFLAGSUFFIX'] = ''
 
+    # __RPATH is set to $_RPATH in the platform specification if that
+    # platform supports it.
+    env['RPATHPREFIX'] = '-Wl,-rpath='
+    env['RPATHSUFFIX'] = ''
+    env['_RPATH'] = '${_concat(RPATHPREFIX, RPATH, RPATHSUFFIX, __env__)}'
+
     SCons.Tool.createStaticLibBuilder(env)
 
 

src/engine/SCons/Tool/gdc.xml

 
 <sconsdoc xmlns="http://www.scons.org/dbxsd/v1.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-          xsi:schemaLocation="http://www.scons.org/dbxsd/v1.0/scons.xsd scons.xsd">
+          xsi:schemaLocation="http://www.scons.org/dbxsd/v1.0/scons.xsd">
 
 <tool name="gdc">
 <summary>
 <item>DDEBUGSUFFIX</item>
 <item>DFLAGPREFIX</item>
 <item>DFLAGSUFFIX</item>
-<item>DFLESUFFIX</item>
+<item>DFILESUFFIX</item>
 <item>DLINK</item>
+<item>DLINKFLAGS</item>
 <item>DLINKCOM</item>
+<item>SHDLINK</item>
+<item>SHDLINKFLAGS</item>
 <item>SHDLINKCOM</item>
 <item>DLIB</item>
 <item>DLIBCOM</item>
-<item>_DLINKLIBFLAGS</item>
 <item>_DLIBFLAGS</item>
-<item>DLINKFLAGS</item>
-<item>DLIBLINKPREFIX</item>
-<item>DLIBLINKSUFFIX</item>
 <item>DLIBFLAGPREFIX</item>
 <item>DLIBFLAGSUFFIX</item>
 <item>DLINKFLAGPREFIX</item>
 <item>DLINKFLAGSUFFIX</item>
+<item>RPATHPREFIX</item>
+<item>RPATHSUFFIX</item>
+<item>_RPATH</item>
 </sets>
 <uses>
 </uses>
 </tool>
+
+</sconsdoc>

src/engine/SCons/Tool/ldc.py

     env['DFILESUFFIX'] = '.d'
 
     env['DLINK'] = '$DC'
-    env['DLINKCOM'] = '$DLINK -of=$TARGET $SOURCES $DFLAGS $DLINKFLAGS $_DLINKLIBFLAGS'
-    env['SHDLINKCOM'] = '$DLINK -shared -of=$TARGET $SOURCES $DFLAGS $DLINKFLAGS $_DLINKLIBFLAGS'
+    env['DLINKFLAGS'] = SCons.Util.CLVar('')
+    env['DLINKCOM'] = '$DLINK -of=$TARGET $DLINKFLAGS $__DRPATH $SOURCES $_DLIBDIRFLAGS $_DLIBFLAGS'
+
+    env['DSHLINK'] = '$DC'
+    env['DSHLINKFLAGS'] = SCons.Util.CLVar('$DLINKFLAGS -shared')
+    env['SHDLINKCOM'] = '$DLINK -of=$TARGET $DSHLINKFLAGS $__DRPATH $SOURCES $_DLIBDIRFLAGS $_DLIBFLAGS'
+
+    env['DLIBLINKPREFIX'] = '' if env['PLATFORM'] == 'win32' else '-L-l'
+    env['DLIBLINKSUFFIX'] = '.lib' if env['PLATFORM'] == 'win32' else ''
+    #env['_DLIBFLAGS'] = '$( ${_concat(DLIBLINKPREFIX, LIBS, DLIBLINKSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
+    env['_DLIBFLAGS'] = '${_stripixes(DLIBLINKPREFIX, LIBS, DLIBLINKSUFFIX, LIBPREFIXES, LIBSUFFIXES,  __env__)}'
+
+    env['DLIBDIRPREFIX'] = '-L-L'
+    env['DLIBDIRSUFFIX'] = ''
+    env['_DLIBDIRFLAGS'] = '$( ${_concat(DLIBDIRPREFIX, LIBPATH, DLIBDIRSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
+
 
     env['DLIB'] = 'lib' if env['PLATFORM'] == 'win32' else 'ar cr'
-    env['DLIBCOM'] = '$DLIB $_DLIBFLAGS {} $TARGET $SOURCES $_DLINKLIBFLAGS'.format('-c' if env['PLATFORM'] == 'win32' else '')
+    env['DLIBCOM'] = '$DLIB $_DLIBFLAGS {} $TARGET $SOURCES $_DLIBFLAGS'.format('-c' if env['PLATFORM'] == 'win32' else '')
 
-    env['_DLINKLIBFLAGS'] = '$( ${_concat(DLIBLINKPREFIX, LIBS, DLIBLINKSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
-    env['_DLIBFLAGS'] = '$( ${_concat(DLIBFLAGPREFIX, DLIBFLAGS, DLIBFLAGSUFFIX, __env__)} $)'
-    env['DLINKFLAGS'] = ['-L-L.']
-    env['DLIBLINKPREFIX'] = '' if env['PLATFORM'] == 'win32' else '-L-l'
-    env['DLIBLINKSUFFIX'] = '.lib' if env['PLATFORM'] == 'win32' else ''
+    #env['_DLIBFLAGS'] = '$( ${_concat(DLIBFLAGPREFIX, DLIBFLAGS, DLIBFLAGSUFFIX, __env__)} $)'
+
     env['DLIBFLAGPREFIX'] = '-'
     env['DLIBFLAGSUFFIX'] = ''
-    env['DLINKFLAGPREFIX'] = '-'
-    env['DLINKFLAGSUFFIX'] = ''
+
+    # __RPATH is set to $_RPATH in the platform specification if that
+    # platform supports it.
+    env['DRPATHPREFIX'] = '-L-rpath='
+    env['DRPATHSUFFIX'] = ''
+    env['_RPATH'] = '${_concat(DRPATHPREFIX, RPATH, DRPATHSUFFIX, __env__)}'
 
     SCons.Tool.createStaticLibBuilder(env)
 

src/engine/SCons/Tool/ldc.xml

 This file is processed by the bin/SConsDoc.py module.
 See its __doc__ string for a discussion of the format.
 -->
-<tool name="dmd">
+
+<!DOCTYPE sconsdoc [
+<!ENTITY % scons SYSTEM '../../../../doc/scons.mod'>
+%scons;
+<!ENTITY % builders-mod SYSTEM '../../../../doc/generated/builders.mod'>
+%builders-mod;
+<!ENTITY % functions-mod SYSTEM '../../../../doc/generated/functions.mod'>
+%functions-mod;
+<!ENTITY % tools-mod SYSTEM '../../../../doc/generated/tools.mod'>
+%tools-mod;
+<!ENTITY % variables-mod SYSTEM '../../../../doc/generated/variables.mod'>
+%variables-mod;
+]>
+
+<sconsdoc xmlns="http://www.scons.org/dbxsd/v1.0"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://www.scons.org/dbxsd/v1.0/scons.xsd">
+
+<tool name="ldc">
 <summary>
+<para>
 Sets construction variables for the D language compiler LDC2.
+</para>
 </summary>
 <sets>
 <item>DC</item>
 <item>DDEBUGSUFFIX</item>
 <item>DFLAGPREFIX</item>
 <item>DFLAGSUFFIX</item>
-<item>DFLESUFFIX</item>
+<item>DFILESUFFIX</item>
 <item>DLINK</item>
+<item>DLINKFLAGS</item>
 <item>DLINKCOM</item>
+<item>SHDLINK</item>
+<item>SHDLINKFLAGS</item>
 <item>SHDLINKCOM</item>
+<item>DLIBLINKPREFIX</item>
+<item>DLIBLINKSUFFIX</item>
+<item>_DLIBFLAGS</item>
+<item>DLIBDIRPREFIX</item>
+<item>DLIBDIRSUFFIX</item>
+<item>_DLIBDIRFLAGS</item>
 <item>DLIB</item>
 <item>DLIBCOM</item>
-<item>_DLINKLIBFLAGS</item>
 <item>_DLIBFLAGS</item>
-<item>DLINKFLAGS</item>
-<item>DLIBLINKPREFIX</item>
-<item>DLIBLINKSUFFIX</item>
 <item>DLIBFLAGPREFIX</item>
 <item>DLIBFLAGSUFFIX</item>
 <item>DLINKFLAGPREFIX</item>
 <item>DLINKFLAGSUFFIX</item>
+<item>RPATHPREFIX</item>
+<item>RPATHSUFFIX</item>
+<item>_RPATH</item>
 </sets>
 <uses>
 </uses>
 </tool>
+
+</sconsdoc>

test/D/Issues/2939_Ariovistus/Common/__init__.py

Empty file added.

test/D/Issues/2939_Ariovistus/Common/correctLinkOptions.py

+"""
+These tests check a problem with the linker options setting.
+"""
+
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+from SCons.Environment import Base
+
+from os.path import abspath, dirname, join
+
+import sys
+sys.path.insert(1, abspath(dirname(__file__) + '/../../../Support'))
+
+from executablesSearch import isExecutableOfToolAvailable
+
+def testForTool(tool):
+
+    test = TestSCons.TestSCons()
+
+    if not isExecutableOfToolAvailable(test, tool) :
+        test.skip_test("Required executable for tool '{}' not found, skipping test.\n".format(tool))
+
+    test.dir_fixture('Project')
+    test.write('SConstruct', open('SConstruct_template', 'r').read().format('tools=["{}", "link"]'.format(tool)))
+
+    test.run()
+
+    for f in ('libstuff.so', 'stuff.os', 'test1', 'test1.o', 'test2', 'test2.o'):
+        test.must_exist(test.workpath(join('test', 'test1', f)))
+
+    test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:

test/D/Issues/2939_Ariovistus/Common/sconstest.skip

Empty file added.

test/D/Issues/2939_Ariovistus/Project/SConstruct_template

+from os.path import join
+
+environment = Environment({})
+
+Export('environment')
+
+environment.SConscript([
+    join("test","test1", "SConscript"),
+]);

test/D/Issues/2939_Ariovistus/Project/test/test1/SConscript

+Import('environment')
+
+env = Environment()
+env.SharedLibrary(target='stuff', source=['stuff.cpp'])
+
+env = Environment()
+env.Append(LIBPATH=['.'])
+env.Append(LIBS=['stuff'])
+env.Program(target='test1', source=['test1.cpp'])
+
+env = environment.Clone()
+env.Append(LIBPATH=['.'])
+env.Append(LIBS=['stuff'])
+env.Program(target='test2', source=['test2.d'])

test/D/Issues/2939_Ariovistus/Project/test/test1/stuff.cpp

+#include "stuff.h"
+
+X::X() {
+    this->i = 1;
+}
+int X::y(){
+    return this->i;
+}
+
+X *SomeX() {
+    return new X(); 
+}

test/D/Issues/2939_Ariovistus/Project/test/test1/stuff.h

+
+class X {
+    public:
+        int i;
+
+        X();
+        int y();
+};
+
+X *SomeX();

test/D/Issues/2939_Ariovistus/Project/test/test1/test1.cpp

+#include "stuff.h"
+
+int main() {
+    X *x = SomeX();
+}

test/D/Issues/2939_Ariovistus/Project/test/test1/test2.d

+import std.stdio;
+
+struct X {
+}
+
+extern(C) int _ZN1X1yEv(X* _this);
+extern(C) X* _Z5SomeXv();
+
+void main() {
+    X *x = _Z5SomeXv();
+    int i = _ZN1X1yEv(x);
+    writeln("i: ", i);
+}

test/D/Issues/2939_Ariovistus/sconstest-correctLinkOptions_dmd.py

+"""
+Test compiling and executing using the gdc tool.
+"""
+
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+from Common.correctLinkOptions import testForTool
+testForTool('dmd')
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:

test/D/Issues/2939_Ariovistus/sconstest-correctLinkOptions_gdc.py

+"""
+Test compiling and executing using the gdc tool.
+"""
+
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+from Common.correctLinkOptions import testForTool
+testForTool('gdc')
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:

test/D/Issues/2939_Ariovistus/sconstest-correctLinkOptions_ldc.py

+"""
+Test compiling and executing using the gdc tool.
+"""
+
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+from Common.correctLinkOptions import testForTool
+testForTool('ldc')
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:

test/D/Issues/2940_Ariovistus/Common/__init__.py

Empty file added.

test/D/Issues/2940_Ariovistus/Common/correctLinkOptions.py

+"""
+These tests check a problem with the linker options setting.
+"""
+
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+from SCons.Environment import Base
+
+from os.path import abspath, dirname, join
+
+import sys
+sys.path.insert(1, abspath(dirname(__file__) + '/../../../Support'))
+
+from executablesSearch import isExecutableOfToolAvailable
+
+def testForTool(tool):
+
+    test = TestSCons.TestSCons()
+
+    if not isExecutableOfToolAvailable(test, tool) :
+        test.skip_test("Required executable for tool '{}' not found, skipping test.\n".format(tool))
+
+    test.dir_fixture('Project')
+    test.write('SConstruct', open('SConstruct_template', 'r').read().format('tools=["{}", "link"]'.format(tool)))
+
+    test.run()
+
+    for f in ('libstuff.so', 'stuff.os', 'test1', 'test1.o', 'test2', 'test2.o'):
+        test.must_exist(test.workpath(join('test', 'test1', f)))
+
+    test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:

test/D/Issues/2940_Ariovistus/Common/sconstest.skip

Empty file added.

test/D/Issues/2940_Ariovistus/Project/SConstruct_template

+from os.path import join
+
+environment = Environment({})
+
+Export('environment')
+
+environment.SConscript([
+    join("test","test1", "SConscript"),
+]);

test/D/Issues/2940_Ariovistus/Project/test/test1/SConscript

+Import('environment')
+
+env = Environment()
+env.SharedLibrary(target='stuff', source=['stuff.cpp'])
+
+env = Environment()
+env.Append(LIBPATH=['.'])
+env.Append(LIBS=['stuff'])
+env.Append(RPATH=['.'])
+env.Program(target='test1', source=['test1.cpp'])
+
+env = environment.Clone()
+env.Append(LIBPATH=['.'])
+env.Append(LIBS=['stuff'])
+env.Append(RPATH=['.'])
+env.Program(target='test2', source=['test2.d'])

test/D/Issues/2940_Ariovistus/Project/test/test1/stuff.cpp

+#include "stuff.h"
+
+X::X() {
+    this->i = 1;
+}
+int X::y(){
+    return this->i;
+}
+
+X *SomeX() {
+    return new X(); 
+}

test/D/Issues/2940_Ariovistus/Project/test/test1/stuff.h

+
+class X {
+    public:
+        int i;
+
+        X();
+        int y();
+};
+
+X *SomeX();

test/D/Issues/2940_Ariovistus/Project/test/test1/test1.cpp

+#include "stuff.h"
+
+int main() {
+    X *x = SomeX();
+}

test/D/Issues/2940_Ariovistus/Project/test/test1/test2.d

+import std.stdio;
+
+struct X {
+}
+
+extern(C) int _ZN1X1yEv(X* _this);
+extern(C) X* _Z5SomeXv();
+
+void main() {
+    X *x = _Z5SomeXv();
+    int i = _ZN1X1yEv(x);
+    writeln("i: ", i);
+}

test/D/Issues/2940_Ariovistus/sconstest-correctLinkOptions_dmd.py

+"""
+Test compiling and executing using the gdc tool.
+"""
+
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+from Common.correctLinkOptions import testForTool
+testForTool('dmd')
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:

test/D/Issues/2940_Ariovistus/sconstest-correctLinkOptions_gdc.py

+"""
+Test compiling and executing using the gdc tool.
+"""
+
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+from Common.correctLinkOptions import testForTool
+testForTool('gdc')
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:

test/D/Issues/2940_Ariovistus/sconstest-correctLinkOptions_ldc.py

+"""
+Test compiling and executing using the gdc tool.
+"""
+
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+from Common.correctLinkOptions import testForTool
+testForTool('ldc')
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4: