Skip to content

Commit

Permalink
Merge branch 'dlang:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
apbryan authored Jan 8, 2025
2 parents cc839a0 + f5d9aa9 commit 9672d9a
Show file tree
Hide file tree
Showing 38 changed files with 1,802 additions and 1,279 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
fail-fast: false
matrix:
# Latest stable version, update at will
os: [ macOS-12, ubuntu-20.04, windows-2019 ]
os: [ macOS-13, ubuntu-20.04, windows-2019 ]
dc:
# Always test latest as that is what we use to compile on release
- dmd-latest
Expand All @@ -65,12 +65,21 @@ jobs:
- dmd-2.099.1
- dmd-2.102.2
- dmd-2.105.3
- dmd-2.108.1
include:
- { do_test: false }
- { dc: dmd-latest, do_test: true }
- { dc: ldc-latest, do_test: true }
- { dc: dmd-master, do_test: true }
- { dc: ldc-master, do_test: true }
# Test on ARM64
- { os: macOS-14, dc: ldc-latest, do_test: true }
exclude:
# Error with those versions:
# ld: multiple errors: symbol count from symbol table and dynamic symbol table differ in [.../dub.o]; address=0x0 points to section(2) with no content in '[...]/osx/lib/libphobos2.a[3177](config_a68_4c3.o)'
- { os: macOS-13, dc: dmd-2.099.1 }
- { os: macOS-13, dc: dmd-2.102.2 }
- { os: macOS-13, dc: dmd-2.105.3 }

runs-on: ${{ matrix.os }}
steps:
Expand All @@ -79,7 +88,9 @@ jobs:
- name: '[OSX] Install dependencies'
if: runner.os == 'macOS'
run: |
brew install pkg-config coreutils
# We need to install GNU utils as the test-suite scripts expect it.
# Without them we may get slightly different behavior in tests and hard-to-track failures
brew install coreutils diffutils
echo "PKG_CONFIG_PATH=/usr/local/opt/[email protected]/lib/pkgconfig/" >> $GITHUB_ENV
- name: '[Linux] Install dependencies'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr_info_untrusted.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: '[Linux] Install dependencies'
if: runner.os == 'Linux'
run: |
sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev netcat
sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
# Compiler to test with
- name: Prepare compiler
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
echo ${{ github.event.number }} > ./pr/NR
- name: upload comment to high-trust action making the comment
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: pr
path: pr/
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ macOS-12, ubuntu-20.04, windows-2019 ]
os: [ macOS-13, ubuntu-20.04, windows-2019 ]
arch: [ x86_64 ]
include:
- { os: windows-2019, arch: i686 }
Expand Down
22 changes: 11 additions & 11 deletions dub.selections.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"fileVersion": 1,
"versions": {
"diet-ng": "1.8.1",
"eventcore": "0.9.32",
"mir-linux-kernel": "1.0.1",
"openssl": "3.3.3",
"diet-ng": "1.8.2",
"eventcore": "0.9.35",
"mir-linux-kernel": "1.2.1",
"openssl": "3.3.4",
"openssl-static": "1.0.5+3.0.8",
"stdx-allocator": "2.77.5",
"taggedalgebraic": "0.11.23",
"vibe-container": "1.3.1",
"vibe-core": "2.9.0",
"vibe-d": "0.10.0",
"vibe-http": "1.1.1",
"vibe-inet": "1.0.0",
"vibe-serialization": "1.0.4",
"vibe-stream": "1.1.0"
"vibe-container": "1.4.0",
"vibe-core": "2.9.6",
"vibe-d": "0.10.1",
"vibe-http": "1.2.1",
"vibe-inet": "1.1.0",
"vibe-serialization": "1.0.7",
"vibe-stream": "1.1.1"
}
}
36 changes: 19 additions & 17 deletions source/dub/compilers/compiler.d
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,24 @@ interface Compiler {
format("%s failed with exit code %s.", args[0], status));
}

/** Default compiler arguments for performing a probe. They should
be the D compiler equivalent of "don't output executables"
*/
protected string[] defaultProbeArgs() const;

/** Compiles platform probe file with the specified compiler and parses its output.
Params:
compiler_binary = binary to invoke compiler with
args = arguments for the probe compilation
arch_override = special handler for x86_mscoff
arch_flags = compiler specific flags derived from the user's arch override
*/
protected final BuildPlatform probePlatform(string compiler_binary, string[] args, string arch_override)
protected final BuildPlatform probePlatform(string compiler_binary, string[] arch_flags)
{
import dub.compilers.utils : generatePlatformProbeFile, readPlatformSDLProbe;
import std.string : format, strip;

NativePath fil = generatePlatformProbeFile();
immutable fileArg = generatePlatformProbeFile().toNativeString;

auto result = execute(compiler_binary ~ args ~ fil.toNativeString());
auto result = execute(compiler_binary ~ defaultProbeArgs ~ arch_flags ~ fileArg);
enforce!CompilerInvocationException(result.status == 0,
format("Failed to invoke the compiler %s to determine the build platform: %s",
compiler_binary, result.output));
Expand All @@ -200,22 +204,20 @@ interface Compiler {
build_platform.compilerVersion = ver;
}

// Skip the following check for LDC, emitting a warning if the specified `-arch`
// cmdline option does not lead to the same string being found among
// `build_platform.architecture`, as it's brittle and doesn't work with triples.
if (build_platform.compiler != "ldc") {
if (arch_override.length && !build_platform.architecture.canFind(arch_override) &&
!(build_platform.compiler == "dmd" && arch_override.among("x86_omf", "x86_mscoff")) // Will be fixed in determinePlatform
) {
logWarn(`Failed to apply the selected architecture %s. Got %s.`,
arch_override, build_platform.architecture);
}
}

return build_platform;
}

}

private {
Compiler[] s_compilers;
}

/// Adds the given flags to the build settings if desired, otherwise informs the user
package void maybeAddArchFlags(ref BuildSettings settings, bool keep_arch, string[] arch_flags, string arch_override) {
if (keep_arch)
settings.addDFlags(arch_flags);
else if (arch_override.length) {
logDebug("Ignoring arch_override '%s' for better caching because it doesn't affect the build", arch_override);
}
}
59 changes: 38 additions & 21 deletions source/dub/compilers/dmd.d
Original file line number Diff line number Diff line change
Expand Up @@ -110,34 +110,37 @@ config /etc/dmd.conf
{
// Set basic arch flags for the probe - might be revised based on the exact value + compiler version
string[] arch_flags;
if (arch_override.length)
arch_flags = [ arch_override != "x86_64" ? "-m32" : "-m64" ];
else
{
// Don't use Optlink by default on Windows
version (Windows) {
const is64bit = isWow64();
if (!is64bit.isNull)
arch_flags = [ is64bit.get ? "-m64" : "-m32" ];
}
}

BuildPlatform bp = probePlatform(
compiler_binary,
arch_flags ~ ["-quiet", "-c", "-o-", "-v"],
arch_override
);

switch (arch_override) {
default: throw new UnsupportedArchitectureException(arch_override);
case "": break;
case "":
// Don't use Optlink by default on Windows
version (Windows) {
const is64bit = isWow64();
if (!is64bit.isNull)
arch_flags = [ is64bit.get ? "-m64" : "-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;
}
settings.addDFlags(arch_flags);

auto bp = probePlatform(compiler_binary, arch_flags);

bool keep_arch;
if (arch_flags.length)
keep_arch = bp.architecture != probePlatform(compiler_binary, []).architecture;
settings.maybeAddArchFlags(keep_arch, arch_flags, arch_override);

if (arch_override.length
&& !bp.architecture.canFind(arch_override)
&& !arch_override.among("x86_omf", "x86_mscoff")
) {
logWarn(`Failed to apply the selected architecture %s. Got %s.`,
arch_override, bp.architecture);
}

return bp;
}
Expand Down Expand Up @@ -171,10 +174,20 @@ config /etc/dmd.conf
version (LDC) unittest {
import std.conv : to;

version (ARM)
enum isARM = true;
version (AArch64)
enum isARM = true;
else
enum isARM = false;

BuildSettings settings;
auto compiler = new DMDCompiler;
auto bp = compiler.determinePlatform(settings, "ldmd2", "x86");
assert(bp.architecture.canFind("x86"), bp.architecture.to!string);
static if (isARM)
assert(bp.architecture.canFind("arm"), bp.architecture.to!string);
else
assert(bp.architecture.canFind("x86"), 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);
Expand Down Expand Up @@ -396,4 +409,8 @@ config /etc/dmd.conf
|| arg.startsWith("-defaultlib=");
}
}

protected string[] defaultProbeArgs () const {
return ["-quiet", "-c", "-o-", "-v"];
}
}
18 changes: 12 additions & 6 deletions source/dub/compilers/gdc.d
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,15 @@ class GDCCompiler : Compiler {
case "x86": arch_flags = ["-m32"]; break;
case "x86_64": arch_flags = ["-m64"]; break;
}
settings.addDFlags(arch_flags);

return probePlatform(
compiler_binary,
arch_flags ~ ["-fsyntax-only", "-v"],
arch_override
);
auto bp = probePlatform(compiler_binary, arch_flags);

bool keep_arch;
if (arch_flags.length)
keep_arch = bp.architecture != probePlatform(compiler_binary, []).architecture;
settings.maybeAddArchFlags(keep_arch, arch_flags, arch_override);

return bp;
}

void prepareBuildSettings(ref BuildSettings settings, const scope ref BuildPlatform platform, BuildSetting fields = BuildSetting.all) const
Expand Down Expand Up @@ -266,6 +268,10 @@ class GDCCompiler : Compiler {

return dflags;
}

protected string[] defaultProbeArgs () const {
return ["-fsyntax-only", "-v"];
}
}

private string extractTarget(const string[] args) { auto i = args.countUntil("-o"); return i >= 0 ? args[i+1] : null; }
Expand Down
24 changes: 16 additions & 8 deletions source/dub/compilers/ldc.d
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ config /etc/ldc2.conf (x86_64-pc-linux-gnu)
BuildPlatform determinePlatform(ref BuildSettings settings, string compiler_binary, string arch_override)
{
string[] arch_flags;
bool arch_override_is_triple = false;
switch (arch_override) {
case "": break;
case "x86": arch_flags = ["-march=x86"]; break;
Expand All @@ -87,19 +88,22 @@ config /etc/ldc2.conf (x86_64-pc-linux-gnu)
case "aarch64": arch_flags = ["-march=aarch64"]; break;
case "powerpc64": arch_flags = ["-march=powerpc64"]; break;
default:
if (arch_override.canFind('-'))
if (arch_override.canFind('-')) {
arch_override_is_triple = true;
arch_flags = ["-mtriple="~arch_override];
else
} else
throw new UnsupportedArchitectureException(arch_override);
break;
}
settings.addDFlags(arch_flags);

return probePlatform(
compiler_binary,
arch_flags ~ ["-c", "-o-", "-v"],
arch_override
);
auto bp = probePlatform(compiler_binary, arch_flags);

bool keep_arch = arch_override_is_triple;
if (!keep_arch && arch_flags.length)
keep_arch = bp.architecture != probePlatform(compiler_binary, []).architecture;
settings.maybeAddArchFlags(keep_arch, arch_flags, arch_override);

return bp;
}

void prepareBuildSettings(ref BuildSettings settings, const scope ref BuildPlatform platform, BuildSetting fields = BuildSetting.all) const
Expand Down Expand Up @@ -335,4 +339,8 @@ config /etc/ldc2.conf (x86_64-pc-linux-gnu)
|| arg.startsWith("-mtriple=");
}
}

protected string[] defaultProbeArgs () const {
return ["-c", "-o-", "-v"];
}
}
24 changes: 19 additions & 5 deletions source/dub/dependencyresolver.d
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ class DependencyResolver(CONFIGS, CONFIG) {
ulong loop_counter = this.loop_limit;
constrain(root, context, loop_counter);

// Get best available results
foreach (base; context.configs.keys)
foreach (j, ref sc; context.configs[base])
if (sc.included){
context.result[base] = sc.config;
break;
}

// remove any non-default optional dependencies
purgeOptionalDependencies(root, context.result);

Expand Down Expand Up @@ -176,9 +184,6 @@ class DependencyResolver(CONFIGS, CONFIG) {
assert(base in context.configs);
if (context.isVisited(n.pack)) return;
context.setVisited(n.pack);
context.result[base] = n.config;
foreach (j, ref sc; context.configs[base])
sc.included = sc.config == n.config;

auto dependencies = getChildren(n);

Expand Down Expand Up @@ -316,10 +321,19 @@ class DependencyResolver(CONFIGS, CONFIG) {

auto failbase = failedNode.main;

// Get partial results
CONFIG[PackageName] partial_result;
foreach (base; context.configs.keys)
foreach (j, ref sc; context.configs[base])
if (sc.included){
partial_result[base] = sc.config;
break;
}

// get the list of all dependencies to the failed package
auto deps = context.visited.byKey
.filter!(p => !!(p.main in context.result))
.map!(p => TreeNode(p, context.result[p.main]))
.filter!(p => !!(p.main in partial_result))
.map!(p => TreeNode(p, partial_result[p.main]))
.map!(n => getChildren(n)
.filter!(d => d.pack.main == failbase)
.map!(d => tuple(n, d))
Expand Down
8 changes: 6 additions & 2 deletions source/dub/generators/build.d
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,12 @@ class BuildGenerator : ProjectGenerator {
allfiles ~= buildsettings.stringImportFiles;
allfiles ~= buildsettings.extraDependencyFiles;
// TODO: add library files
foreach (p; packages)
allfiles ~= (p.recipePath != NativePath.init ? p : p.basePackage).recipePath.toNativeString();
foreach (p; packages) {
if (p.recipePath != NativePath.init)
allfiles ~= p.recipePath.toNativeString();
else if (p.basePackage.recipePath != NativePath.init)
allfiles ~= p.basePackage.recipePath.toNativeString();
}
foreach (f; additional_dep_files) allfiles ~= f.toNativeString();
bool checkSelectedVersions = !settings.single;
if (checkSelectedVersions && main_pack is m_project.rootPackage && m_project.rootPackage.getAllDependencies().length > 0)
Expand Down
Loading

0 comments on commit 9672d9a

Please sign in to comment.