aBothe/Mono-D — Issue #37: Shared Lib Linker not used
Author: RafBill
Created: 2012-01-25 15:38:29+00:00
State: open

When changing the program under Static Lib Linker for any compiler, the program used remains the same.

When implementing Ldc2 :with the following code,

public class Ldc2 :CompilerDefaultArgumentProvider
{
public Ldc2(DCompilerConfiguration cfg):base(cfg){}

public override void ResetCompilerConfiguration ()
{
Configuration.Vendor = DCompilerVendor.LDC2;
Configuration.DefaultLibraries.Clear ();

var ldc2 = "ldc2";

if (OS.IsWindows)
ldc2 += ".exe";

Configuration.SetAllCompilerCommands (ldc2);
Configuration.SetAllLinkerCommands (ldc2);

Configuration.GetTargetConfiguration (DCompileTarget.SharedLibrary).Compiler = ldc2;

Configuration.DefaultLibraries.Clear ();
if (OS.IsWindows)
Configuration.DefaultLibraries.Add ("phobos" + DCompiler.StaticLibraryExtension);
}

public override void ResetBuildArguments (DCompileTarget LinkTarget, bool IsDebug)
{
var args = Configuration.GetTargetConfiguration (LinkTarget).GetArguments (IsDebug);
var debugAppendix = IsDebug ? "-g" : "-O3 -release";

args.CompilerArguments = "-c \"$src\" -of=\"$obj\" $includes " + debugAppendix;
args.LinkerArguments = "-of=\"$target\" " + debugAppendix + " $objs $libs";

switch (LinkTarget) {
case DCompileTarget.ConsolelessExecutable:
if (Environment.OSVersion.Platform == PlatformID.MacOSX) {
} else if (Environment.OSVersion.Platform == PlatformID.Unix) {
} else
args.LinkerArguments += " -L/su:windows -L/exet:nt";
break;

case DCompileTarget.SharedLibrary:
args.CompilerArguments = "-relocation-model=pic " + args.CompilerArguments;
args.LinkerArguments += " -shared";
break;

case DCompileTarget.StaticLibrary:
args.LinkerArguments += " -lib";
break;
}
}
}

The command line for shared lib compilation (not linkage) doesn't include ldc2