forked from M-Labs/nac3
Merge branch 'windows'
This commit is contained in:
commit
4526c28edb
|
@ -2,17 +2,17 @@
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1638279546,
|
"lastModified": 1637328665,
|
||||||
"narHash": "sha256-1KCwN7twjp1dBdp0jPgVdYFztDkCR8+roo0B34J9oBY=",
|
"narHash": "sha256-z6ufVwquLM0IiNZxd5oT1M33Lv0aB3WICpk8ZKwpxjw=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "96b4157790fc96e70d6e6c115e3f34bba7be490f",
|
"rev": "0f4b4b85d959200f52c16bbb74036994e7db5f74",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"ref": "nixos-21.11",
|
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
|
"rev": "0f4b4b85d959200f52c16bbb74036994e7db5f74",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
67
flake.nix
67
flake.nix
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
description = "The third-generation ARTIQ compiler";
|
description = "The third-generation ARTIQ compiler";
|
||||||
|
|
||||||
inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-21.11;
|
inputs.nixpkgs.url = github:NixOS/nixpkgs/0f4b4b85d959200f52c16bbb74036994e7db5f74;
|
||||||
|
|
||||||
outputs = { self, nixpkgs }:
|
outputs = { self, nixpkgs }:
|
||||||
let
|
let
|
||||||
|
@ -10,9 +10,35 @@
|
||||||
nixpkgs-patched = pkgs-orig.applyPatches {
|
nixpkgs-patched = pkgs-orig.applyPatches {
|
||||||
name = "nixpkgs";
|
name = "nixpkgs";
|
||||||
src = nixpkgs;
|
src = nixpkgs;
|
||||||
patches = [ ./llvm-future-riscv-abi.diff ./llvm-restrict-targets.diff ];
|
patches = [ ./llvm-future-riscv-abi.diff ./llvm-restrict-targets.diff ./llvm-mingw-crosscompile.diff ./llvm-unbreak-static-cross.diff ];
|
||||||
};
|
};
|
||||||
pkgs = import nixpkgs-patched { system = "x86_64-linux"; };
|
pkgs = import nixpkgs-patched { system = "x86_64-linux"; };
|
||||||
|
pkgs-mingw = import nixpkgs-patched { system = "x86_64-linux"; crossSystem = { config = "x86_64-w64-mingw32"; libc = "msvcrt"; }; };
|
||||||
|
cargoSha256 = "sha256-otKLhr58HYMjVXAof6AdObNpggPnvK6qOl7I+4LWIP8=";
|
||||||
|
msys2-python-tar = pkgs.fetchurl {
|
||||||
|
url = "https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-python-3.9.7-4-any.pkg.tar.zst";
|
||||||
|
sha256 = "0iwlgbk4b457yn9djwqswid55xhyyi35qymz1lfh42xwdpxdm47c";
|
||||||
|
};
|
||||||
|
msys2-python = pkgs.runCommand "msys2-python" { buildInputs = [ pkgs.gnutar pkgs.zstd ]; }
|
||||||
|
''
|
||||||
|
mkdir $out
|
||||||
|
tar xvf ${msys2-python-tar} -C $out
|
||||||
|
'';
|
||||||
|
pyo3-mingw-config = pkgs.writeTextFile {
|
||||||
|
name = "pyo3-mingw-config";
|
||||||
|
text =
|
||||||
|
''
|
||||||
|
implementation=CPython
|
||||||
|
version=3.9
|
||||||
|
shared=true
|
||||||
|
abi3=false
|
||||||
|
lib_name=python3.9
|
||||||
|
lib_dir=${msys2-python}/mingw64/lib
|
||||||
|
pointer_width=64
|
||||||
|
build_flags=WITH_THREAD
|
||||||
|
suppress_build_script_link_lines=false
|
||||||
|
'';
|
||||||
|
};
|
||||||
in rec {
|
in rec {
|
||||||
inherit nixpkgs-patched;
|
inherit nixpkgs-patched;
|
||||||
|
|
||||||
|
@ -21,7 +47,7 @@
|
||||||
pkgs.rustPlatform.buildRustPackage {
|
pkgs.rustPlatform.buildRustPackage {
|
||||||
name = "nac3artiq";
|
name = "nac3artiq";
|
||||||
src = self;
|
src = self;
|
||||||
cargoSha256 = "sha256-otKLhr58HYMjVXAof6AdObNpggPnvK6qOl7I+4LWIP8=";
|
inherit cargoSha256;
|
||||||
nativeBuildInputs = [ pkgs.python3 pkgs.llvm_12 ];
|
nativeBuildInputs = [ pkgs.python3 pkgs.llvm_12 ];
|
||||||
buildInputs = [ pkgs.python3 pkgs.libffi pkgs.libxml2 pkgs.llvm_12 ];
|
buildInputs = [ pkgs.python3 pkgs.libffi pkgs.libxml2 pkgs.llvm_12 ];
|
||||||
cargoBuildFlags = [ "--package" "nac3artiq" ];
|
cargoBuildFlags = [ "--package" "nac3artiq" ];
|
||||||
|
@ -36,6 +62,41 @@
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
packages.x86_64-w64-mingw32 = {
|
||||||
|
nac3artiq = pkgs-mingw.python3Packages.toPythonModule (
|
||||||
|
pkgs-mingw.rustPlatform.buildRustPackage {
|
||||||
|
name = "nac3artiq";
|
||||||
|
src = self;
|
||||||
|
inherit cargoSha256;
|
||||||
|
buildInputs = [ pkgs-mingw.libffi pkgs-mingw.zlib ];
|
||||||
|
configurePhase =
|
||||||
|
''
|
||||||
|
export PYO3_CONFIG_FILE=${pyo3-mingw-config}
|
||||||
|
|
||||||
|
mkdir llvm-cfg
|
||||||
|
cat << EOF > llvm-cfg/llvm-config
|
||||||
|
#!${pkgs.bash}/bin/bash
|
||||||
|
set -e
|
||||||
|
# Gross hack to work around llvm-config asking for the wrong system libraries.
|
||||||
|
exec ${pkgs-mingw.llvm_12.dev}/bin/llvm-config-native \$@ | ${pkgs.gnused}/bin/sed s/-lrt\ -ldl\ -lpthread\ -lm//
|
||||||
|
EOF
|
||||||
|
chmod +x llvm-cfg/llvm-config
|
||||||
|
export PATH=$PATH:`pwd`/llvm-cfg
|
||||||
|
|
||||||
|
export CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUSTFLAGS="-C link-arg=-lz -C link-arg=-luuid -C link-arg=-lole32 -C link-arg=-lmcfgthread"
|
||||||
|
'';
|
||||||
|
cargoBuildFlags = [ "--package" "nac3artiq" ];
|
||||||
|
doCheck = false;
|
||||||
|
installPhase =
|
||||||
|
''
|
||||||
|
mkdir -p $out
|
||||||
|
cp target/x86_64-pc-windows-gnu/release/nac3artiq.dll $out/nac3artiq.pyd
|
||||||
|
'';
|
||||||
|
meta.platforms = ["x86_64-windows"];
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
devShell.x86_64-linux = pkgs.mkShell {
|
devShell.x86_64-linux = pkgs.mkShell {
|
||||||
name = "nac3-dev-shell";
|
name = "nac3-dev-shell";
|
||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
diff --git a/pkgs/development/compilers/llvm/12/llvm/default.nix b/pkgs/development/compilers/llvm/12/llvm/default.nix
|
||||||
|
index 30a1a7a16df..4f9435d1819 100644
|
||||||
|
--- a/pkgs/development/compilers/llvm/12/llvm/default.nix
|
||||||
|
+++ b/pkgs/development/compilers/llvm/12/llvm/default.nix
|
||||||
|
@@ -15,10 +15,11 @@
|
||||||
|
, buildLlvmTools
|
||||||
|
, debugVersion ? false
|
||||||
|
, enableManpages ? false
|
||||||
|
-, enableSharedLibraries ? !stdenv.hostPlatform.isStatic
|
||||||
|
+, enableSharedLibraries ? (!stdenv.hostPlatform.isStatic && !stdenv.targetPlatform.isMinGW)
|
||||||
|
, enablePFM ? !(stdenv.isDarwin
|
||||||
|
|| stdenv.isAarch64 # broken for Ampere eMAG 8180 (c2.large.arm on Packet) #56245
|
||||||
|
|| stdenv.isAarch32 # broken for the armv7l builder
|
||||||
|
+ || stdenv.targetPlatform.isMinGW
|
||||||
|
)
|
||||||
|
, enablePolly ? false
|
||||||
|
}:
|
||||||
|
@@ -120,7 +121,7 @@ in stdenv.mkDerivation (rec {
|
||||||
|
"-DLLVM_INSTALL_CMAKE_DIR=${placeholder "dev"}/lib/cmake/llvm/"
|
||||||
|
"-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}"
|
||||||
|
"-DLLVM_INSTALL_UTILS=ON" # Needed by rustc
|
||||||
|
- "-DLLVM_BUILD_TESTS=ON"
|
||||||
|
+ "-DLLVM_BUILD_TESTS=${if stdenv.targetPlatform.isMinGW then "OFF" else "ON"}"
|
||||||
|
"-DLLVM_ENABLE_FFI=ON"
|
||||||
|
"-DLLVM_ENABLE_RTTI=ON"
|
||||||
|
"-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
|
||||||
|
@@ -134,7 +135,7 @@ in stdenv.mkDerivation (rec {
|
||||||
|
"-DSPHINX_OUTPUT_MAN=ON"
|
||||||
|
"-DSPHINX_OUTPUT_HTML=OFF"
|
||||||
|
"-DSPHINX_WARNINGS_AS_ERRORS=OFF"
|
||||||
|
- ] ++ optionals (!isDarwin) [
|
||||||
|
+ ] ++ optionals (!isDarwin && !stdenv.targetPlatform.isMinGW) [
|
||||||
|
"-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
|
||||||
|
] ++ optionals isDarwin [
|
||||||
|
"-DLLVM_ENABLE_LIBCXX=ON"
|
|
@ -0,0 +1,44 @@
|
||||||
|
diff --git a/pkgs/development/compilers/llvm/12/llvm/default.nix b/pkgs/development/compilers/llvm/12/llvm/default.nix
|
||||||
|
index 30a1a7a16df..bb5676b9d48 100644
|
||||||
|
--- a/pkgs/development/compilers/llvm/12/llvm/default.nix
|
||||||
|
+++ b/pkgs/development/compilers/llvm/12/llvm/default.nix
|
||||||
|
@@ -74,7 +74,7 @@ in stdenv.mkDerivation (rec {
|
||||||
|
--replace 'set(_install_rpath "@loader_path/../''${CMAKE_INSTALL_LIBDIR}''${LLVM_LIBDIR_SUFFIX}" ''${extra_libdir})' ""
|
||||||
|
''
|
||||||
|
# Patch llvm-config to return correct library path based on --link-{shared,static}.
|
||||||
|
- + optionalString (enableSharedLibraries) ''
|
||||||
|
+ + ''
|
||||||
|
substitute '${./outputs.patch}' ./outputs.patch --subst-var lib
|
||||||
|
patch -p1 < ./outputs.patch
|
||||||
|
'' + ''
|
||||||
|
diff --git a/pkgs/development/compilers/llvm/12/llvm/outputs.patch b/pkgs/development/compilers/llvm/12/llvm/outputs.patch
|
||||||
|
index 40096fa3497..878460e05b8 100644
|
||||||
|
--- a/pkgs/development/compilers/llvm/12/llvm/outputs.patch
|
||||||
|
+++ b/pkgs/development/compilers/llvm/12/llvm/outputs.patch
|
||||||
|
@@ -2,23 +2,13 @@ diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.c
|
||||||
|
index 94d426b..37f7794 100644
|
||||||
|
--- a/tools/llvm-config/llvm-config.cpp
|
||||||
|
+++ b/tools/llvm-config/llvm-config.cpp
|
||||||
|
-@@ -333,6 +333,21 @@ int main(int argc, char **argv) {
|
||||||
|
+@@ -333,6 +333,11 @@ int main(int argc, char **argv) {
|
||||||
|
ActiveIncludeOption = "-I" + ActiveIncludeDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
-+ /// Nix-specific multiple-output handling: override ActiveLibDir if --link-shared
|
||||||
|
++ /// Nix-specific multiple-output handling: override ActiveLibDir
|
||||||
|
+ if (!IsInDevelopmentTree) {
|
||||||
|
-+ bool WantShared = true;
|
||||||
|
-+ for (int i = 1; i < argc; ++i) {
|
||||||
|
-+ StringRef Arg = argv[i];
|
||||||
|
-+ if (Arg == "--link-shared")
|
||||||
|
-+ WantShared = true;
|
||||||
|
-+ else if (Arg == "--link-static")
|
||||||
|
-+ WantShared = false; // the last one wins
|
||||||
|
-+ }
|
||||||
|
-+
|
||||||
|
-+ if (WantShared)
|
||||||
|
-+ ActiveLibDir = std::string("@lib@") + "/lib" + LLVM_LIBDIR_SUFFIX;
|
||||||
|
++ ActiveLibDir = std::string("@lib@") + "/lib" + LLVM_LIBDIR_SUFFIX;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
/// We only use `shared library` mode in cases where the static library form
|
|
@ -10,8 +10,13 @@ crate-type = ["cdylib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
pyo3 = { version = "0.14", features = ["extension-module"] }
|
pyo3 = { version = "0.14", features = ["extension-module"] }
|
||||||
inkwell = { git = "https://github.com/TheDan64/inkwell", branch = "master", features = ["llvm12-0"] }
|
|
||||||
parking_lot = "0.11"
|
parking_lot = "0.11"
|
||||||
tempfile = "3"
|
tempfile = "3"
|
||||||
nac3parser = { path = "../nac3parser" }
|
nac3parser = { path = "../nac3parser" }
|
||||||
nac3core = { path = "../nac3core" }
|
nac3core = { path = "../nac3core" }
|
||||||
|
|
||||||
|
[dependencies.inkwell]
|
||||||
|
git = "https://github.com/TheDan64/inkwell"
|
||||||
|
branch = "master"
|
||||||
|
default-features = false
|
||||||
|
features = ["llvm12-0", "target-x86", "target-arm", "target-riscv"]
|
||||||
|
|
|
@ -7,13 +7,18 @@ edition = "2018"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
num-bigint = "0.3"
|
num-bigint = "0.3"
|
||||||
num-traits = "0.2"
|
num-traits = "0.2"
|
||||||
inkwell = { git = "https://github.com/TheDan64/inkwell", branch = "master", features = ["llvm12-0"] }
|
|
||||||
itertools = "0.10.1"
|
itertools = "0.10.1"
|
||||||
crossbeam = "0.8.1"
|
crossbeam = "0.8.1"
|
||||||
parking_lot = "0.11.1"
|
parking_lot = "0.11.1"
|
||||||
rayon = "1.5.1"
|
rayon = "1.5.1"
|
||||||
nac3parser = { path = "../nac3parser" }
|
nac3parser = { path = "../nac3parser" }
|
||||||
|
|
||||||
|
[dependencies.inkwell]
|
||||||
|
git = "https://github.com/TheDan64/inkwell"
|
||||||
|
branch = "master"
|
||||||
|
default-features = false
|
||||||
|
features = ["llvm12-0", "target-x86", "target-arm", "target-riscv"]
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
test-case = "1.2.0"
|
test-case = "1.2.0"
|
||||||
indoc = "1.0"
|
indoc = "1.0"
|
||||||
|
|
|
@ -5,7 +5,12 @@ authors = ["M-Labs"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
inkwell = { git = "https://github.com/TheDan64/inkwell", branch = "master", features = ["llvm12-0"] }
|
|
||||||
parking_lot = "0.11.1"
|
parking_lot = "0.11.1"
|
||||||
nac3parser = { path = "../nac3parser" }
|
nac3parser = { path = "../nac3parser" }
|
||||||
nac3core = { path = "../nac3core" }
|
nac3core = { path = "../nac3core" }
|
||||||
|
|
||||||
|
[dependencies.inkwell]
|
||||||
|
git = "https://github.com/TheDan64/inkwell"
|
||||||
|
branch = "master"
|
||||||
|
default-features = false
|
||||||
|
features = ["llvm12-0", "target-x86", "target-arm", "target-riscv"]
|
||||||
|
|
Loading…
Reference in New Issue