From a02f964d4cda4ead48814e21136490646eee41f7 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Wed, 3 Jul 2024 19:24:38 +0000 Subject: [PATCH 1/2] ldc: split includes to separate output --- pkgs/by-name/ld/ldc/package.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/by-name/ld/ldc/package.nix b/pkgs/by-name/ld/ldc/package.nix index a807831ec435..2c4e1dc99776 100644 --- a/pkgs/by-name/ld/ldc/package.nix +++ b/pkgs/by-name/ld/ldc/package.nix @@ -73,8 +73,12 @@ stdenv.mkDerivation (finalAttrs: { buildInputs = [ curl tzdata ]; + outputs = [ "out" "include" ]; + outputInclude = "include"; + cmakeFlags = [ "-DD_FLAGS=-d-version=TZDatabaseDir;-d-version=LibcurlPath;-J${pathConfig}" + "-DINCLUDE_INSTALL_DIR=${placeholder "include"}/include/d" ]; postConfigure = '' From 2ac637b098b148d9b399cd6482da406a0fd65c02 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Thu, 4 Jul 2024 11:05:17 +0000 Subject: [PATCH 2/2] ldc: add disallowedReferences test --- pkgs/by-name/ld/ldc/package.nix | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/pkgs/by-name/ld/ldc/package.nix b/pkgs/by-name/ld/ldc/package.nix index 2c4e1dc99776..b2c59a208183 100644 --- a/pkgs/by-name/ld/ldc/package.nix +++ b/pkgs/by-name/ld/ldc/package.nix @@ -15,6 +15,7 @@ , callPackage , makeWrapper , runCommand +, writeText , targetPackages , ldcBootstrap ? callPackage ./bootstrap.nix { } @@ -146,4 +147,35 @@ stdenv.mkDerivation (finalAttrs: { maintainers = with maintainers; [ lionello jtbx ]; platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; }; + + passthru.tests = let + ldc = finalAttrs.finalPackage; + helloWorld = stdenv.mkDerivation (finalAttrs: { + name = "ldc-hello-world"; + src = writeText "hello_world.d" '' + module hello_world; + import std.stdio; + void main() { + writeln("Hello, world!"); + } + ''; + dontUnpack = true; + buildInputs = [ ldc ]; + dFlags = []; + buildPhase = '' + ldc2 ${lib.escapeShellArgs finalAttrs.dFlags} -of=test $src + ''; + installPhase = '' + mkdir -p $out/bin + mv test $out/bin + ''; + }); + in { + # Without -shared, built binaries should not contain + # references to the compiler binaries. + no-references-to-compiler = helloWorld.overrideAttrs { + disallowedReferences = [ ldc ]; + dFlags = ["-g"]; + }; + }; })