diff --git a/concordium-consensus/package.yaml b/concordium-consensus/package.yaml index 6b3ecb0ddf..9bde75c3fc 100644 --- a/concordium-consensus/package.yaml +++ b/concordium-consensus/package.yaml @@ -90,24 +90,59 @@ library: extra-libraries: concordium_smart_contract_engine + # when: + # - condition: os(windows) + # then: + # #ghc-options: -threaded -static -shared lib.def -L../concordium-base/smart-contracts/lib -lconcordium_smart_contract_engine + # ghc-options: -threaded + # else: + # # -fPIC casues issues on Windows: https://gitlab.haskell.org/ghc/ghc/-/issues/24016 + # # However, it should not do anything on Windows anyway, so it's fine not to enable it there. + # ghc-options: -fPIC + # when: + # - condition: flag(dynamic) + # then: + # ghc-options: -shared -dynamic + # else: + # ghc-options: -static when: - - condition: os(windows) - then: - ghc-options: -threaded -static -shared lib.def -L../concordium-base/smart-contracts/lib -lconcordium_smart_contract_engine - else: - # -fPIC casues issues on Windows: https://gitlab.haskell.org/ghc/ghc/-/issues/24016 - # However, it should not do anything on Windows anyway, so it's fine not to enable it there. - ghc-options: -fPIC - when: - - condition: flag(dynamic) - then: - ghc-options: -shared -dynamic - else: - ghc-options: -static + - condition: "!(os(windows)) && !(flag(dynamic))" + ghc-options: -fPIC -static + src-dirs: src-lib # Other options might be needed, such has -dynamic -lHSrts or -lHSrts-ghc8.4.3 # Possibly this depends on the platform +verbatim: | + foreign-library concordium-consensus-lib + type: native-shared + if os(Windows) + options: standalone + mod-def-file: lib.def + ghc-options: -threaded + else + ghc-options; -fPIC + + other-modules: + Concordium.External + Concordium.External.DryRun + Concordium.External.Helpers + Concordium.External.GRPC2 + hs-source-dirs: src-lib + build-depends: aeson, proto-lens, cereal, containers, transformers, vector, microlens-platform, directory, filepath, base, text, bytestring, concordium-consensus, concordium-base + default-language: Haskell2010 + default-extensions: + FlexibleContexts + FlexibleInstances + FunctionalDependencies + GeneralizedNewtypeDeriving + KindSignatures + LambdaCase + MultiParamTypeClasses + RecordWildCards + TupleSections + TypeOperators + executables: Concordium-exe: main: Main.hs diff --git a/concordium-consensus/src/Concordium/External.hs b/concordium-consensus/src-lib/Concordium/External.hs similarity index 100% rename from concordium-consensus/src/Concordium/External.hs rename to concordium-consensus/src-lib/Concordium/External.hs diff --git a/concordium-consensus/src/Concordium/External/DryRun.hs b/concordium-consensus/src-lib/Concordium/External/DryRun.hs similarity index 100% rename from concordium-consensus/src/Concordium/External/DryRun.hs rename to concordium-consensus/src-lib/Concordium/External/DryRun.hs diff --git a/concordium-consensus/src/Concordium/External/GRPC2.hs b/concordium-consensus/src-lib/Concordium/External/GRPC2.hs similarity index 100% rename from concordium-consensus/src/Concordium/External/GRPC2.hs rename to concordium-consensus/src-lib/Concordium/External/GRPC2.hs diff --git a/concordium-consensus/src/Concordium/External/Helpers.hs b/concordium-consensus/src-lib/Concordium/External/Helpers.hs similarity index 100% rename from concordium-consensus/src/Concordium/External/Helpers.hs rename to concordium-consensus/src-lib/Concordium/External/Helpers.hs diff --git a/concordium-node/build.rs b/concordium-node/build.rs index 9825fc8128..e2cac22589 100644 --- a/concordium-node/build.rs +++ b/concordium-node/build.rs @@ -719,11 +719,11 @@ const DYLIB_EXTENSION: &str = "dylib"; #[cfg(all(not(feature = "static"), not(windows)))] /// Link with Haskell runtime libraries. -/// The RTS version defaults to the threaded one, but can be overridded by the +/// The RTS version defaults to the threaded one, but can be overridden by the /// HASKELL_RTS_VARIANT environment variable fn link_ghc_libs() -> std::io::Result { let rts_variant = - env::var("HASKELL_RTS_VARIANT").unwrap_or_else(|_| "libHSrts_thr-".to_owned()); + env::var("HASKELL_RTS_VARIANT").unwrap_or_else(|_| "libHSrts-1.0.2_thr-".to_owned()); let ghc_lib_dir = env::var("HASKELL_GHC_LIBDIR").unwrap_or_else(|_| { command_output(Command::new("stack").args([ "--stack-yaml", @@ -733,9 +733,6 @@ fn link_ghc_libs() -> std::io::Result { "--print-libdir", ])) }); - #[cfg(all(not(feature = "static"), target_os = "linux"))] - let rts_dir = Path::new(&ghc_lib_dir).join("rts"); - #[cfg(all(not(feature = "static"), target_os = "macos"))] let rts_dir = Path::new(&ghc_lib_dir).join(GHC_VARIANT); println!("cargo:rustc-link-search=native={}", rts_dir.to_string_lossy()); for item in std::fs::read_dir(&rts_dir)?.filter_map(Result::ok) {