Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/systems/doubles.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ let
"wasm64-wasi" "wasm32-wasi"

# Windows
"x86_64-windows" "i686-windows"
"aarch64-windows" "x86_64-windows" "i686-windows"
];

allParsed = map parse.mkSystemFromString all;
Expand Down
7 changes: 7 additions & 0 deletions lib/systems/examples.nix
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,13 @@ rec {
libc = "ucrt"; # This distinguishes the mingw (non posix) toolchain
};

# LLVM-based mingw-w64 for ARM
ucrtAarch64 = {
config = "aarch64-w64-mingw32";
libc = "ucrt";
useLLVM = true;
};

# BSDs

x86_64-freebsd = {
Expand Down
2 changes: 1 addition & 1 deletion lib/tests/systems.nix
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ lib.runTests (
testlinux = mseteq linux [ "aarch64-linux" "armv5tel-linux" "armv6l-linux" "armv7a-linux" "armv7l-linux" "i686-linux" "loongarch64-linux" "m68k-linux" "microblaze-linux" "microblazeel-linux" "mips-linux" "mips64-linux" "mips64el-linux" "mipsel-linux" "powerpc64-linux" "powerpc64le-linux" "riscv32-linux" "riscv64-linux" "s390-linux" "s390x-linux" "x86_64-linux" ];
testnetbsd = mseteq netbsd [ "aarch64-netbsd" "armv6l-netbsd" "armv7a-netbsd" "armv7l-netbsd" "i686-netbsd" "m68k-netbsd" "mipsel-netbsd" "powerpc-netbsd" "riscv32-netbsd" "riscv64-netbsd" "x86_64-netbsd" ];
testopenbsd = mseteq openbsd [ "i686-openbsd" "x86_64-openbsd" ];
testwindows = mseteq windows [ "i686-cygwin" "x86_64-cygwin" "i686-windows" "x86_64-windows" ];
testwindows = mseteq windows [ "i686-cygwin" "x86_64-cygwin" "aarch64-windows" "i686-windows" "x86_64-windows" ];
testunix = mseteq unix (linux ++ darwin ++ freebsd ++ openbsd ++ netbsd ++ illumos ++ cygwin ++ redox);
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ let
# use clean up the `cmakeFlags` rats nest below.
haveLibcxx = stdenv.cc.libcxx != null;
isDarwinStatic = stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isStatic && lib.versionAtLeast release_version "16";
inherit (stdenv.hostPlatform) isMusl isAarch64;
noSanitizers = !haveLibc || bareMetal || isMusl || isDarwinStatic;
inherit (stdenv.hostPlatform) isMusl isAarch64 isWindows;
noSanitizers = !haveLibc || bareMetal || isMusl || isDarwinStatic || isWindows;

baseName = "compiler-rt";
pname = baseName + lib.optionalString (haveLibc) "-libc";
Expand Down
6 changes: 5 additions & 1 deletion pkgs/development/compilers/llvm/common/libcxx/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ let
]) ++ lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXXABI_ENABLE_THREADS=OFF"
"-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optionals (!enableShared) [
] ++ lib.optionals (!enableShared || stdenv.hostPlatform.isWindows) [
# Required on Windows due to https://github.com/llvm/llvm-project/issues/55245
"-DLIBCXXABI_ENABLE_SHARED=OFF"
];

Expand Down Expand Up @@ -91,6 +92,9 @@ let
"-DLIBCXX_ENABLE_THREADS=OFF"
"-DLIBCXX_ENABLE_FILESYSTEM=OFF"
"-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
] ++ lib.optionals stdenv.hostPlatform.isWindows [
# https://github.com/llvm/llvm-project/issues/55245
"-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON"
] ++ lib.optionals (!enableShared) [
"-DLIBCXX_ENABLE_SHARED=OFF"
] ++ lib.optionals (cxxabi != null && cxxabi.libName == "cxxrt") [
Expand Down
48 changes: 37 additions & 11 deletions pkgs/os-specific/windows/cygwin-setup/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
{ lib, stdenv, fetchcvs, autoconf, automake, libtool, flex, bison, pkg-config
, zlib, bzip2, xz, libgcrypt
{
lib,
stdenv,
fetchcvs,
autoconf,
automake,
libtool,
flex,
bison,
pkg-config,
zlib,
bzip2,
xz,
libgcrypt,
}:

stdenv.mkDerivation rec {
Expand All @@ -13,16 +25,30 @@ stdenv.mkDerivation rec {
sha256 = "024wxaaxkf7p1i78bh5xrsqmfz7ss2amigbfl2r5w9h87zqn9aq3";
};

nativeBuildInputs = [ autoconf automake libtool flex bison pkg-config ];
nativeBuildInputs = [
autoconf
automake
libtool
flex
bison
pkg-config
];

buildInputs = let
mkStatic = lib.flip lib.overrideDerivation (o: {
dontDisableStatic = true;
configureFlags = lib.toList (o.configureFlags or []) ++ [ "--enable-static" ];
buildInputs = map mkStatic (o.buildInputs or []);
propagatedBuildInputs = map mkStatic (o.propagatedBuildInputs or []);
});
in map mkStatic [ zlib bzip2 xz libgcrypt ];
buildInputs =
let
mkStatic = lib.flip lib.overrideDerivation (o: {
dontDisableStatic = true;
configureFlags = lib.toList (o.configureFlags or [ ]) ++ [ "--enable-static" ];
buildInputs = map mkStatic (o.buildInputs or [ ]);
propagatedBuildInputs = map mkStatic (o.propagatedBuildInputs or [ ]);
});
in
map mkStatic [
zlib
bzip2
xz
libgcrypt
];

configureFlags = [ "--disable-shared" ];

Expand Down
70 changes: 38 additions & 32 deletions pkgs/os-specific/windows/default.nix
Original file line number Diff line number Diff line change
@@ -1,46 +1,52 @@
{ lib, stdenv, buildPackages
, newScope, overrideCC, stdenvNoLibc, libcCross
{
lib,
stdenv,
buildPackages,
newScope,
overrideCC,
stdenvNoLibc,
libcCross,
}:

lib.makeScope newScope (self: with self; {
lib.makeScope newScope (
self: with self; {

cygwinSetup = callPackage ./cygwin-setup { };
cygwinSetup = callPackage ./cygwin-setup { };

dlfcn = callPackage ./dlfcn { };
dlfcn = callPackage ./dlfcn { };

w32api = callPackage ./w32api { };
w32api = callPackage ./w32api { };

mingwrt = callPackage ./mingwrt { };
mingw_runtime = mingwrt;
mingwrt = callPackage ./mingwrt { };
mingw_runtime = mingwrt;

mingw_w64 = callPackage ./mingw-w64 {
stdenv = stdenvNoLibc;
};
mingw_w64 = callPackage ./mingw-w64 {
stdenv = stdenvNoLibc;
};

# FIXME untested with llvmPackages_16 was using llvmPackages_8
crossThreadsStdenv = overrideCC stdenvNoLibc
(if stdenv.hostPlatform.useLLVM or false
then buildPackages.llvmPackages.clangNoLibcxx
else buildPackages.gccWithoutTargetLibc.override (old: {
bintools = old.bintools.override {
libc = libcCross;
};
libc = libcCross;
}));
# FIXME untested with llvmPackages_16 was using llvmPackages_8
crossThreadsStdenv = overrideCC stdenvNoLibc (
if stdenv.hostPlatform.useLLVM or false then
buildPackages.llvmPackages.clangNoLibcxx
else
buildPackages.gccWithoutTargetLibc.override (old: {
bintools = old.bintools.override {
libc = libcCross;
};
libc = libcCross;
})
);

mingw_w64_headers = callPackage ./mingw-w64/headers.nix { };
mingw_w64_headers = callPackage ./mingw-w64/headers.nix { };

mingw_w64_pthreads = callPackage ./mingw-w64/pthreads.nix {
stdenv = crossThreadsStdenv;
};
mingw_w64_pthreads = callPackage ./mingw-w64/pthreads.nix { stdenv = crossThreadsStdenv; };

mcfgthreads = callPackage ./mcfgthreads {
stdenv = crossThreadsStdenv;
};
mcfgthreads = callPackage ./mcfgthreads { stdenv = crossThreadsStdenv; };

npiperelay = callPackage ./npiperelay { };
npiperelay = callPackage ./npiperelay { };

pthreads = callPackage ./pthread-w32 { };
pthreads = callPackage ./pthread-w32 { };

libgnurx = callPackage ./libgnurx { };
})
libgnurx = callPackage ./libgnurx { };
}
)
7 changes: 6 additions & 1 deletion pkgs/os-specific/windows/dlfcn/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{ stdenv, lib, fetchFromGitHub, cmake }:
{
stdenv,
lib,
fetchFromGitHub,
cmake,
}:

stdenv.mkDerivation rec {
pname = "dlfcn";
Expand Down
9 changes: 7 additions & 2 deletions pkgs/os-specific/windows/libgnurx/default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{ lib, stdenv, fetchurl }:
{
lib,
stdenv,
fetchurl,
}:

let
version = "2.5.1";
in stdenv.mkDerivation rec {
in
stdenv.mkDerivation rec {
pname = "libgnurx";
inherit version;
src = fetchurl {
Expand Down
18 changes: 10 additions & 8 deletions pkgs/os-specific/windows/mcfgthreads/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{ lib
, stdenv
, fetchFromGitHub
, autoreconfHook
{
lib,
stdenv,
fetchFromGitHub,
autoreconfHook,
}:

stdenv.mkDerivation rec {
Expand All @@ -15,12 +16,13 @@ stdenv.mkDerivation rec {
hash = "sha256-FrmeaQhwLrNewS0HDlbWgCvVQ5U1l0jrw0YVuQdt9Ck=";
};

outputs = [ "out" "dev" ];

nativeBuildInputs = [
autoreconfHook
outputs = [
"out"
"dev"
];

nativeBuildInputs = [ autoreconfHook ];

meta = {
description = "Threading support library for Windows 7 and above";
homepage = "https://github.com/lhmouse/mcfgthread/wiki";
Expand Down
39 changes: 28 additions & 11 deletions pkgs/os-specific/windows/mingw-w64/default.nix
Original file line number Diff line number Diff line change
@@ -1,26 +1,43 @@
{ lib
, stdenv
, windows
, autoreconfHook
, mingw_w64_headers
{
lib,
stdenv,
windows,
autoreconfHook,
mingw_w64_headers,
crt ? stdenv.hostPlatform.libc,
}:

assert lib.assertOneOf "crt" crt [
"msvcrt"
"ucrt"
];

stdenv.mkDerivation {
pname = "mingw-w64";
inherit (mingw_w64_headers) version src meta;

outputs = [ "out" "dev" ];
outputs = [
"out"
"dev"
];

configureFlags = [
"--enable-idl"
"--enable-secure-api"
] ++ lib.optionals (stdenv.targetPlatform.libc == "ucrt") [
"--with-default-msvcrt=ucrt"
(lib.enableFeature true "idl")
(lib.enableFeature true "secure-api")
(lib.withFeatureAs true "default-msvcrt" crt)

# Including other architectures causes errors with invalid asm
(lib.enableFeature stdenv.hostPlatform.isi686 "lib32")
(lib.enableFeature stdenv.hostPlatform.isx86_64 "lib64")
(lib.enableFeature stdenv.hostPlatform.isAarch64 "libarm64")
];

enableParallelBuilding = true;

nativeBuildInputs = [ autoreconfHook ];
buildInputs = [ windows.mingw_w64_headers ];
hardeningDisable = [ "stackprotector" "fortify" ];
hardeningDisable = [
"stackprotector"
"fortify"
];
}
10 changes: 7 additions & 3 deletions pkgs/os-specific/windows/mingw-w64/headers.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{ lib, stdenvNoCC, fetchurl }:
{
lib,
stdenvNoCC,
fetchurl,
}:

stdenvNoCC.mkDerivation (finalAttrs: {
pname = "mingw_w64-headers";
version = "11.0.1";
version = "12.0.0";

src = fetchurl {
url = "mirror://sourceforge/mingw-w64/mingw-w64-v${finalAttrs.version}.tar.bz2";
hash = "sha256-P2a84Gnui+10OaGhPafLkaXmfqYXDyExesf1eUYl7hA=";
hash = "sha256-zEGJiqxLbo3Vz/1zMbnZUVuRLfRCCjphK16ilVu+7S8=";
};

preConfigure = ''
Expand Down
15 changes: 9 additions & 6 deletions pkgs/os-specific/windows/mingw-w64/pthreads.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
{ stdenv, mingw_w64_headers }:
{
lib,
stdenv,
mingw_w64_headers,
# Rustc require 'libpthread.a' when targeting 'x86_64-pc-windows-gnu'.
# Enabling this makes it work out of the box instead of failing.
withStatic ? true,
}:

stdenv.mkDerivation {
pname = "mingw_w64-pthreads";
inherit (mingw_w64_headers) version src meta;

configureFlags = [
# Rustc require 'libpthread.a' when targeting 'x86_64-pc-windows-gnu'.
# Enabling this makes it work out of the box instead of failing.
"--enable-static"
];
configureFlags = [ (lib.enableFeature withStatic "static") ];

preConfigure = ''
cd mingw-w64-libraries/winpthreads
Expand Down
11 changes: 9 additions & 2 deletions pkgs/os-specific/windows/mingwrt/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{ stdenv, lib, fetchurl }:
{
stdenv,
lib,
fetchurl,
}:

stdenv.mkDerivation rec {
pname = "mingwrt";
Expand All @@ -14,5 +18,8 @@ stdenv.mkDerivation rec {
};

dontStrip = true;
hardeningDisable = [ "stackprotector" "fortify" ];
hardeningDisable = [
"stackprotector"
"fortify"
];
}
6 changes: 5 additions & 1 deletion pkgs/os-specific/windows/npiperelay/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{ lib, buildGoModule, fetchFromGitHub }:
{
lib,
buildGoModule,
fetchFromGitHub,
}:

buildGoModule rec {
pname = "npiperelay";
Expand Down
Loading