From b9a71cee4e58f9d6766580735ba94fcd4a286572 Mon Sep 17 00:00:00 2001 From: Yvan Sraka Date: Tue, 12 Mar 2024 15:53:11 +0100 Subject: [PATCH] Fix the need of `staticlib` target to have a `build.rs` customization This intends to fix this GHC issue https://gitlab.haskell.org/ghc/ghc/-/issues/22564#note_469030 --- flake.lock | 78 ++++++++++++++++++++++++++++++++++++++-------------- src/cabal.rs | 9 ++++-- 2 files changed, 63 insertions(+), 24 deletions(-) diff --git a/flake.lock b/flake.lock index 059ff9b..2aa5a6f 100644 --- a/flake.lock +++ b/flake.lock @@ -1,12 +1,15 @@ { "nodes": { "flake-utils": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1676283394, - "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -16,12 +19,15 @@ } }, "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", "owner": "numtide", "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", "type": "github" }, "original": { @@ -35,11 +41,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1671096816, - "narHash": "sha256-ezQCsNgmpUHdZANDCILm3RvtO1xH8uujk/+EqNvzIOg=", + "lastModified": 1698420672, + "narHash": "sha256-/TdeHMPRjjdJub7p7+w55vyABrsJlt5QkznPYy55vKA=", "owner": "nix-community", "repo": "naersk", - "rev": "d998160d6a076cfe8f9741e56aeec7e267e3e114", + "rev": "aeb58d5e8faead8980a807c840232697982d47b9", "type": "github" }, "original": { @@ -50,11 +56,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1676150441, - "narHash": "sha256-Nfeua9Ua/dGHOQpzOjLtkyMyW/ysQCvZJ9Dd74QQSNk=", + "lastModified": 1710222005, + "narHash": "sha256-irXySffHz7b82dZIme6peyAu+8tTJr1zyxcfUPhqUrg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6d87734c880d704f6ee13e5c0fe835b98918c34e", + "rev": "9a9a7552431c4f1a3b2eee9398641babf7c30d0e", "type": "github" }, "original": { @@ -64,11 +70,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1676150441, - "narHash": "sha256-Nfeua9Ua/dGHOQpzOjLtkyMyW/ysQCvZJ9Dd74QQSNk=", + "lastModified": 1710222005, + "narHash": "sha256-irXySffHz7b82dZIme6peyAu+8tTJr1zyxcfUPhqUrg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6d87734c880d704f6ee13e5c0fe835b98918c34e", + "rev": "9a9a7552431c4f1a3b2eee9398641babf7c30d0e", "type": "github" }, "original": { @@ -80,11 +86,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1665296151, - "narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=", + "lastModified": 1706487304, + "narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "14ccaaedd95a488dd7ae142757884d8e125b3363", + "rev": "90f456026d284c22b3e3497be980b2e47d0b28ac", "type": "github" }, "original": { @@ -108,11 +114,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1676341851, - "narHash": "sha256-T8cmSiriXdpZfqlserNyJ1solTCR0DbD8A75epSDOVY=", + "lastModified": 1710209426, + "narHash": "sha256-A7bXK9k6RdBGsmqU4DxHqDBty7kKNkh8Pv+iGE2i1Ac=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "956ddb5047f98ea08b792b22004b94a9971932c4", + "rev": "405cdc2652fa89f2fcf392335d5b9364b0adc5c2", "type": "github" }, "original": { @@ -120,6 +126,36 @@ "repo": "rust-overlay", "type": "github" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/src/cabal.rs b/src/cabal.rs index 175da1a..8fe6804 100644 --- a/src/cabal.rs +++ b/src/cabal.rs @@ -11,13 +11,16 @@ custom-setup setup-depends: Cabal, base, directory, process" }; + let lib_name = name.replace('-', "_"); // In library generated by Cargo, '-' is replaced by '_' + let package_name = name.replace('_', "-"); // Cabal does not expect '_' for packages names + let extra = if enable_nix { format!( " -- `haskell.nix` tell GHC linker where to find the `libNAME.a` by setting -- automatically `extra-lib-dirs`: -- https://input-output-hk.github.io/haskell.nix/tutorials/pkg-map.html - extra-libraries: {name} + extra-libraries: {lib_name} -- Cross-compilation to target `x86_64-w64-mingw32-cc` thrown a lot of -- `undefined reference to 'X'` errors during linking stage ... @@ -32,7 +35,7 @@ custom-setup format!( " -- Libraries that are bundled with the package. - extra-bundled-libraries: {name}" + extra-bundled-libraries: {lib_name}" ) }; @@ -49,7 +52,7 @@ custom-setup -- documentation, see: http://haskell.org/cabal/users-guide/ -- -- The name of the package. -name: {name} +name: {package_name} -- The package version. -- See the Haskell package versioning policy (PVP) for standards