Skip to content

Commit

Permalink
Remove support for OMF, make MsCOFF be x86
Browse files Browse the repository at this point in the history
Now that OMF support is being removed, dmd-latest is broken in the CI.
Since DMD no longer supports it, and we are mostly concerned about
supporting the latest 10 releases, we're keeping x86_omf and x86_mscoff
available but making them aliases to x86.
  • Loading branch information
Geod24 authored and dlang-bot committed Jun 3, 2024
1 parent bd72917 commit 270c8a3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 61 deletions.
55 changes: 5 additions & 50 deletions source/dub/compilers/dmd.d
Original file line number Diff line number Diff line change
Expand Up @@ -128,46 +128,14 @@ config /etc/dmd.conf
arch_override
);

/// Replace architecture string in `bp.architecture`
void replaceArch(const string from, const string to)
{
const idx = bp.architecture.countUntil(from);
if (idx != -1)
bp.architecture[idx] = to;
}

// DMD 2.099 changed the default for -m32 from OMF to MsCOFF
const m32IsCoff = bp.frontendVersion >= 2_099;

switch (arch_override) {
default: throw new UnsupportedArchitectureException(arch_override);
case "": break;
case "x86": arch_flags = ["-m32"]; break;
// DMD 2.099 made MsCOFF the default, and DMD v2.109 removed OMF
// support. Default everything to MsCOFF, people wanting to use OMF
// should use an older DMD / dub.
case "x86", "x86_omf", "x86_mscoff": arch_flags = ["-m32"]; break;
case "x86_64": arch_flags = ["-m64"]; break;

case "x86_omf":
if (m32IsCoff)
{
arch_flags = [ "-m32omf" ];
replaceArch("x86_mscoff", "x86_omf"); // Probe used the wrong default
}
else // -m32 is OMF
{
arch_flags = [ "-m32" ];
}
break;

case "x86_mscoff":
if (m32IsCoff)
{
arch_flags = [ "-m32" ];
}
else // -m32 is OMF
{
arch_flags = [ "-m32mscoff" ];
replaceArch("x86_omf", "x86_mscoff"); // Probe used the wrong default
}
break;
}
settings.addDFlags(arch_flags);

Expand All @@ -181,33 +149,22 @@ config /etc/dmd.conf
auto bp = compiler.determinePlatform(settings, "dmd", "x86");
assert(bp.isWindows());
assert(bp.architecture.canFind("x86"));
const defaultOMF = (bp.frontendVersion < 2_099);
assert(bp.architecture.canFind("x86_omf") == defaultOMF);
assert(bp.architecture.canFind("x86_mscoff") != defaultOMF);
settings = BuildSettings.init;
bp = compiler.determinePlatform(settings, "dmd", "x86_omf");
assert(bp.isWindows());
assert(bp.architecture.canFind("x86"));
assert(bp.architecture.canFind("x86_omf"));
assert(!bp.architecture.canFind("x86_mscoff"));
settings = BuildSettings.init;
bp = compiler.determinePlatform(settings, "dmd", "x86_mscoff");
assert(bp.isWindows());
assert(bp.architecture.canFind("x86"));
assert(!bp.architecture.canFind("x86_omf"));
assert(bp.architecture.canFind("x86_mscoff"));
settings = BuildSettings.init;
bp = compiler.determinePlatform(settings, "dmd", "x86_64");
assert(bp.isWindows());
assert(bp.architecture.canFind("x86_64"));
assert(!bp.architecture.canFind("x86"));
assert(!bp.architecture.canFind("x86_omf"));
assert(!bp.architecture.canFind("x86_mscoff"));
settings = BuildSettings.init;
bp = compiler.determinePlatform(settings, "dmd", "");
if (!isWow64.isNull && !isWow64.get) assert(bp.architecture.canFind("x86"));
if (!isWow64.isNull && !isWow64.get) assert(bp.architecture.canFind("x86_mscoff"));
if (!isWow64.isNull && !isWow64.get) assert(!bp.architecture.canFind("x86_omf"));
if (!isWow64.isNull && isWow64.get) assert(bp.architecture.canFind("x86_64"));
}

Expand All @@ -218,11 +175,9 @@ config /etc/dmd.conf
auto compiler = new DMDCompiler;
auto bp = compiler.determinePlatform(settings, "ldmd2", "x86");
assert(bp.architecture.canFind("x86"), bp.architecture.to!string);
assert(!bp.architecture.canFind("x86_omf"), bp.architecture.to!string);
bp = compiler.determinePlatform(settings, "ldmd2", "");
version (X86) assert(bp.architecture.canFind("x86"), bp.architecture.to!string);
version (X86_64) assert(bp.architecture.canFind("x86_64"), bp.architecture.to!string);
assert(!bp.architecture.canFind("x86_omf"), bp.architecture.to!string);
}

void prepareBuildSettings(ref BuildSettings settings, const scope ref BuildPlatform platform,
Expand Down Expand Up @@ -433,7 +388,7 @@ config /etc/dmd.conf
static bool isLinkerDFlag(string arg)
{
switch (arg) {
case "-g", "-gc", "-m32", "-m64", "-shared", "-lib", "-m32omf", "-m32mscoff", "-betterC":
case "-g", "-gc", "-m32", "-m64", "-shared", "-lib", "-betterC":
return true;
default:
return arg.startsWith("-L")
Expand Down
11 changes: 1 addition & 10 deletions test/win32_default.d
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
"name": "Default",
"versions": [ "Default" ]
},
{
"name": "OMF",
"versions": [ "OMF" ]
},
{
"name": "MsCoff",
"versions": [ "MsCoff" ]
Expand All @@ -25,12 +21,7 @@ module dynlib.app;
pragma(msg, "Frontend: ", __VERSION__);

// Object format should match the expectation
version (OMF)
{
enum expSize = 4;
enum expFormat = "omf";
}
else version (MsCoff)
version (MsCoff)
{
// Should be a 32 bit build
version (Is64) enum expSize = 8;
Expand Down
2 changes: 1 addition & 1 deletion test/win32_default.script.d
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int main()
// Test with different --arch
const string[2][] tests = [
[ "x86", "Default" ],
[ "x86_omf", "OMF" ],
[ "x86_omf", "MsCoff" ],
[ "x86_mscoff", "MsCoff" ],
[ "x86_64", "MsCoff64" ],
];
Expand Down

0 comments on commit 270c8a3

Please sign in to comment.