diff --git a/default.nix b/default.nix index 441c9816d1d..bec85b8111d 100644 --- a/default.nix +++ b/default.nix @@ -407,7 +407,7 @@ rec { buildInputs = [ moc wasmtime haskellPackages.qc-motoko nixpkgs.drun ]; checkPhase = '' - export LANG=C.utf8 # for haskell + export LANG=C.utf8 # for haskell qc-motoko${nixpkgs.lib.optionalString (replay != 0) " --quickcheck-replay=${toString replay}"} ''; @@ -418,7 +418,7 @@ rec { buildInputs = [ moc haskellPackages.lsp-int ]; checkPhase = '' echo running lsp-int - export LANG=C.utf8 # for haskell + export LANG=C.utf8 # for haskell lsp-int ${mo-ide}/bin/mo-ide . ''; }; @@ -509,7 +509,7 @@ rec { run-deser = test_subdir "run-deser" [ deser ]; perf = perf_subdir "perf" [ moc nixpkgs.drun ]; bench = perf_subdir "bench" [ moc nixpkgs.drun ic-wasm ]; - viper = test_subdir "viper" [ moc nixpkgs.which nixpkgs.openjdk nixpkgs.z3 ]; + # viper = test_subdir "viper" [ moc nixpkgs.which nixpkgs.openjdk nixpkgs.z3 ]; inherit qc lsp unit candid profiling-graphs coverage; }) // { recurseForDerivations = true; }; @@ -576,8 +576,18 @@ rec { nixpkgs.rustPlatform.buildRustPackage { name = "ic-wasm"; src = nixpkgs.sources.ic-wasm; - cargoSha256 = "sha256-qw1MwjlhGftN9k2sOjlAYo9rDRvHnf0qYQFPHMu2v74="; + cargoSha256 = "sha256-a8iN/lTEVqdmogsSlT3+v3nivSG5VRhOz4/trmAsZLY="; doCheck = false; + patchPhase = '' + mkdir -p .cargo + cat > .cargo/config.toml << EOF +[target.x86_64-apple-darwin] +rustflags = [ "-C", "linker=c++" ] + +[target.aarch64-apple-darwin] +rustflags = [ "-C", "linker=c++" ] +EOF + ''; }; # gitMinimal is used by nix/gitSource.nix; building it here warms the nix cache diff --git a/nix/drun.nix b/nix/drun.nix index 055f5ff31d3..deeb992fbba 100644 --- a/nix/drun.nix +++ b/nix/drun.nix @@ -1,6 +1,6 @@ pkgs: { drun = - pkgs.rustPlatform_moz_stable.buildRustPackage { + pkgs.rustPlatform.buildRustPackage { name = "drun"; src = pkgs.sources.ic; @@ -28,7 +28,6 @@ pkgs: }; patchPhase = '' -pwd cd ../cargo-vendor-dir patch librocksdb-sys*/build.rs << EOF @@ -118,6 +118,10 @@ @@ -45,6 +44,15 @@ pwd EOF cd - + + mkdir -p .cargo + cat > .cargo/config.toml << EOF +[target.x86_64-apple-darwin] +rustflags = [ "-C", "linker=c++" ] + +[target.aarch64-apple-darwin] +rustflags = [ "-C", "linker=c++" ] +EOF ''; nativeBuildInputs = with pkgs; [ diff --git a/nix/sources.json b/nix/sources.json index afa81e18f9f..090aa55500b 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -52,10 +52,10 @@ "homepage": null, "owner": "dfinity", "repo": "ic-wasm", - "rev": "d8d3b438973784b3935e3e18a7ea8690859b3e24", - "sha256": "1sw7sqwyp63m0frjz744jd5nsli8np6gsc19z7l66h6f32pyhy2r", + "rev": "61692f44cf85b93d43311492283246bb443449d3", + "sha256": "1b06dphnj89qmyv4gxh8gqm1bgqfpivr4di2nl9hbvqqyx4vzb65", "type": "tarball", - "url": "https://github.com/dfinity/ic-wasm/archive/d8d3b438973784b3935e3e18a7ea8690859b3e24.tar.gz", + "url": "https://github.com/dfinity/ic-wasm/archive/61692f44cf85b93d43311492283246bb443449d3.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "libtommath": { @@ -109,16 +109,16 @@ "url_template": "https://github.com///archive/.tar.gz" }, "nixpkgs": { - "branch": "release-23.05", + "branch": "release-23.11", "builtin": true, "description": "Nixpkgs/NixOS branches that track the Nixpkgs/NixOS channels", "homepage": null, "owner": "NixOS", "repo": "nixpkgs", - "rev": "2f3b6b3fcd9fa0a4e6b544180c058a70890a7cc1", - "sha256": "0j0bv6550cv1n2qb7pbxbh4b0shz4hdkmh0fmz903jc2vjrbajm8", + "rev": "6a5b92486ae7826c07fbfad302f569ceb187b0eb", + "sha256": "058kf03v7yh1c4ns96af6jq3ymadv71s7ajv9s05ipl9bnkjfrhm", "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/2f3b6b3fcd9fa0a4e6b544180c058a70890a7cc1.tar.gz", + "url": "https://github.com/NixOS/nixpkgs/archive/6a5b92486ae7826c07fbfad302f569ceb187b0eb.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "nixpkgs-mozilla": { diff --git a/src/codegen/compile.ml b/src/codegen/compile.ml index eedfa6ab029..6a50a2eba71 100644 --- a/src/codegen/compile.ml +++ b/src/codegen/compile.ml @@ -4583,7 +4583,7 @@ module IC = struct | Flags.RefMode -> import_ic0 env | Flags.WASIMode -> - E.add_func_import env "wasi_unstable" "fd_write" [I32Type; I32Type; I32Type; I32Type] [I32Type]; + E.add_func_import env "wasi_snapshot_preview1" "fd_write" [I32Type; I32Type; I32Type; I32Type] [I32Type]; | Flags.WasmMode -> () let system_call env funcname = E.call_import env "ic0" funcname @@ -4631,14 +4631,14 @@ module IC = struct get_iovec_ptr ^^ compile_unboxed_const 1l (* one string segment (2 doesn't work) *) ^^ get_iovec_ptr ^^ compile_add_const 20l ^^ (* out for bytes written, we ignore that *) - E.call_import env "wasi_unstable" "fd_write" ^^ + E.call_import env "wasi_snapshot_preview1" "fd_write" ^^ G.i Drop ^^ compile_unboxed_const 1l (* stdout *) ^^ get_iovec_ptr ^^ compile_add_const 8l ^^ compile_unboxed_const 1l (* one string segment *) ^^ get_iovec_ptr ^^ compile_add_const 20l ^^ (* out for bytes written, we ignore that *) - E.call_import env "wasi_unstable" "fd_write" ^^ + E.call_import env "wasi_snapshot_preview1" "fd_write" ^^ G.i Drop) end); diff --git a/src/docs/.ocamlformat b/src/docs/.ocamlformat index ef8b3e4fd9d..1d231ca6adc 100644 --- a/src/docs/.ocamlformat +++ b/src/docs/.ocamlformat @@ -1,4 +1,4 @@ -version=0.24.1 +version=0.26.1 ocaml-version=4.12 break-infix=fit-or-vertical doc-comments=before diff --git a/src/languageServer/.ocamlformat b/src/languageServer/.ocamlformat index ef8b3e4fd9d..1d231ca6adc 100644 --- a/src/languageServer/.ocamlformat +++ b/src/languageServer/.ocamlformat @@ -1,4 +1,4 @@ -version=0.24.1 +version=0.26.1 ocaml-version=4.12 break-infix=fit-or-vertical doc-comments=before diff --git a/src/languageServer/definition.ml b/src/languageServer/definition.ml index 61a34016479..cd21258452a 100644 --- a/src/languageServer/definition.ml +++ b/src/languageServer/definition.ml @@ -77,8 +77,8 @@ let definition_handler index position file_contents project_root file_path = { location_uri = (if Source_file.is_non_file_path path then - Option.get (Source_file.uri_for_package path) - else Vfs.uri_from_file path); + Option.get (Source_file.uri_for_package path) + else Vfs.uri_from_file path); location_range = decl_range; } in diff --git a/test/browser-debug.js b/test/browser-debug.js index f49eb5379b5..7c7fb83f3f3 100644 --- a/test/browser-debug.js +++ b/test/browser-debug.js @@ -188,7 +188,7 @@ var motokoHashMap = null; function importWasmModule(moduleName, wasiPolyfill) { const moduleImports = { - wasi_unstable: wasiPolyfill, + wasi_snapshot_preview1: wasiPolyfill, env: {}, }; diff --git a/test/lsp-int/Main.hs b/test/lsp-int/Main.hs index 5eef7ebd1ba..96cf86f3648 100644 --- a/test/lsp-int/Main.hs +++ b/test/lsp-int/Main.hs @@ -1,6 +1,6 @@ {-# language OverloadedStrings, DuplicateRecordFields, ExplicitForAll, ScopedTypeVariables, BlockArguments, - LambdaCase #-} + LambdaCase, TypeOperators, ViewPatterns #-} module Main where @@ -15,9 +15,10 @@ import Data.Maybe (mapMaybe) import Data.Text (Text) import qualified Data.Text as Text import Language.LSP.Test hiding (message) -import Language.LSP.Types (TextDocumentIdentifier(..), Position(..), HoverContents(..), MarkupContent(..), MarkupKind(..), TextEdit(..), Range(..), DidSaveTextDocumentParams(..), SMethod(..), Diagnostic(..), Location(..), Uri(..), filePathToUri, CompletionDoc(..)) -import qualified Language.LSP.Types as LSP -import Language.LSP.Types.Lens (contents, label, detail, documentation, message, additionalTextEdits, newText) +import Language.LSP.Protocol.Types (TextDocumentIdentifier(..), Position(..), Hover(..), MarkupContent(..), MarkupKind(..), TextEdit(..), Range(..), DidSaveTextDocumentParams(..), Diagnostic(..), Location(..), Uri(..), filePathToUri, CompletionItem(..)) +import Language.LSP.Protocol.Message (SMethod(..)) +import qualified Language.LSP.Protocol.Types as LSP +import Language.LSP.Protocol.Lens (contents, label, detail, documentation, message, additionalTextEdits, newText) import System.Directory (setCurrentDirectory, makeAbsolute, removeFile) import System.Environment (getArgs) import System.Exit (exitFailure) @@ -34,7 +35,8 @@ completionTestCase -> Session () completionTestCase doc pos pred = do actual <- getCompletions doc pos - let unCompletionDoc (CompletionDocMarkup t) = unMarkup t + -- let unCompletionDoc (CompletionItem {_documentation = t}) = unMarkup t + let unCompletionDoc (Just -> t) = unMarkup t liftIO (pred (map (\c -> (c^.label, c^.detail, fmap unCompletionDoc (c^.documentation))) actual)) hoverTestCase @@ -44,11 +46,11 @@ hoverTestCase -> Session () hoverTestCase doc pos expected = do actual <- getHover doc pos - case fmap (^.contents) actual of + case (^.contents) <$> actual of Nothing | expected == Nothing -> pure () - Just (HoverContents (MarkupContent { _value = content})) + Just (LSP.InL MarkupContent { _value = content }) | Just expected' <- expected -> if Text.isInfixOf expected' content then pure () @@ -74,7 +76,9 @@ definitionsTestCase definitionsTestCase project doc pos expected = do LSP.InL response <- getDefinitions doc pos let expected' = map (first (filePathToUri . (project ))) expected - let actual = map (\(Location uri range) -> (uri, range)) response + let locations (LSP.Definition (LSP.InL loc)) = [loc] + locations (LSP.Definition (LSP.InR locs)) = locs + let actual = map (\(Location uri range) -> (uri, range)) (locations response) liftIO (shouldMatchList actual expected') -- | Discards all empty diagnostic reports (as those are merely used @@ -92,16 +96,21 @@ withDoc path action = do closeDoc doc pure res -plainMarkup :: Text -> Maybe HoverContents +plainMarkup :: Text -> Maybe Hover plainMarkup t = Just - (HoverContents MarkupContent - { _kind = MkPlainText - , _value = t - }) + (Hover { + _contents = LSP.InL MarkupContent + { _kind = MarkupKind_PlainText + , _value = t + }, + _range = Nothing + }) -unMarkup :: MarkupContent -> Text -unMarkup (MarkupContent { _kind = MkMarkdown, _value = t}) = t +unMarkup :: Maybe (Text LSP.|? MarkupContent) -> Text +unMarkup Nothing = "" +unMarkup (Just (LSP.InL t)) = t +unMarkup (Just (LSP.InR (MarkupContent { _kind = MarkupKind_Markdown, _value = t}))) = t expectationFailure :: String -> Expectation expectationFailure = Test.HUnit.assertFailure @@ -252,7 +261,7 @@ main = do liftIO do shouldBe (actual^.label) "print_hello" shouldBe (actual^.detail) (Just "() -> Text (import from \"mo:mydep/lib\")") - let Just (LSP.List [importEdit]) = actual^.additionalTextEdits + let Just [importEdit] = actual^.additionalTextEdits shouldContain (Text.lines (importEdit^.newText)) ["import MyDep \"mo:mydep/lib\";"] log "Completing on not-yet-imported actors" @@ -263,7 +272,7 @@ main = do liftIO do shouldBe (actual^.label) "add_counter" shouldBe (actual^.detail) (Just "shared Nat -> () (import from \"canister:counter\")") - let Just (LSP.List [importEdit]) = actual^.additionalTextEdits + let Just [importEdit] = actual^.additionalTextEdits shouldContain (Text.lines (importEdit^.newText)) ["import Counter \"canister:counter\";"] withDoc "ListClient.mo" \doc -> do @@ -271,7 +280,7 @@ main = do -- ==> 1 | ort List let edit = TextEdit (Range (Position 0 1) (Position 0 3)) "" _ <- applyEdit doc edit - sendNotification STextDocumentDidSave (DidSaveTextDocumentParams doc Nothing) + sendNotification SMethod_TextDocumentDidSave (DidSaveTextDocumentParams doc Nothing) (diagnostic:_) <- waitForDiagnostics liftIO (diagnostic^.message `shouldBe` "unexpected token 'import'") @@ -292,7 +301,7 @@ main = do let edit = TextEdit (Range (Position 0 1) (Position 0 3)) "" _ <- applyEdit doc edit withDoc "app.mo" \appDoc -> do - sendNotification STextDocumentDidSave (DidSaveTextDocumentParams appDoc Nothing) + sendNotification SMethod_TextDocumentDidSave (DidSaveTextDocumentParams appDoc Nothing) diagnostic:_ <- waitForActualDiagnostics liftIO (diagnostic^.message `shouldBe` "unexpected token 'import'") @@ -302,7 +311,7 @@ main = do -- for completions let edit = TextEdit (Range (Position 4 0) (Position 4 0)) "\nimport MyDep \"mo:mydep/broken\"" _ <- applyEdit doc edit - sendNotification STextDocumentDidSave (DidSaveTextDocumentParams doc Nothing) + sendNotification SMethod_TextDocumentDidSave (DidSaveTextDocumentParams doc Nothing) [diag] <- waitForActualDiagnostics liftIO (diag^.message `shouldBe` "operator is not defined for operand types\n Text\nand\n Nat") @@ -311,7 +320,7 @@ main = do -- Imports the non-broken dependency module let edit = TextEdit (Range (Position 4 0) (Position 4 0)) "\nimport MyDep \"mo:mydep/lib\"" _ <- applyEdit doc edit - sendNotification STextDocumentDidSave (DidSaveTextDocumentParams doc Nothing) + sendNotification SMethod_TextDocumentDidSave (DidSaveTextDocumentParams doc Nothing) let edit2 = TextEdit (Range (Position 5 0) (Position 5 0)) "\nMyDep." _ <- applyEdit doc edit2 completionTestCase @@ -324,7 +333,7 @@ main = do withDoc "app.mo" \doc -> do let edit = TextEdit (Range (Position 4 0) (Position 4 0)) "\nimport Doc \"doc_comments\"" _ <- applyEdit doc edit - sendNotification STextDocumentDidSave (DidSaveTextDocumentParams doc Nothing) + sendNotification SMethod_TextDocumentDidSave (DidSaveTextDocumentParams doc Nothing) let edit2 = TextEdit (Range (Position 5 0) (Position 5 0)) "\nDoc." _ <- applyEdit doc edit2 completionTestCase diff --git a/test/lsp-int/lsp-int.cabal b/test/lsp-int/lsp-int.cabal index 5a082387d1d..9218ec0763e 100644 --- a/test/lsp-int/lsp-int.cabal +++ b/test/lsp-int/lsp-int.cabal @@ -14,8 +14,8 @@ executable lsp-int main-is: Main.hs -- other-modules: other-extensions: OverloadedStrings, DuplicateRecordFields - build-depends: base ^>=4.16 - , text ^>=1.2 + build-depends: base ^>=4.17 + , text ^>=2.0 , hspec , HUnit , filepath diff --git a/test/random/Embedder.hs b/test/random/Embedder.hs index 21c28ed17c2..77c79fb2d84 100644 --- a/test/random/Embedder.hs +++ b/test/random/Embedder.hs @@ -36,7 +36,7 @@ addCompilerArgs (WasmTime _) = ("-wasi-system-api" :) addCompilerArgs Drun = id addEmbedderArgs Reference = id -addEmbedderArgs (WasmTime _) = ("--disable-cache" :) . ("--enable-cranelift-nan-canonicalization" :) . ("--wasm-features" :) . ("multi-memory,bulk-memory" :) +addEmbedderArgs (WasmTime _) = \args -> ["-C", "cache=n", "-W", "nan-canonicalization=y", "-W", "multi-memory", "-W", "bulk-memory"] <> args addEmbedderArgs Drun = ("--extra-batches" :) . ("10" :) embedderInvocation :: Embedder -> [Text] -> [Text] diff --git a/test/random/qc-motoko.cabal b/test/random/qc-motoko.cabal index 2a5dc30d477..a521f63e5db 100644 --- a/test/random/qc-motoko.cabal +++ b/test/random/qc-motoko.cabal @@ -15,8 +15,8 @@ executable qc-motoko other-modules: Embedder, Turtle.Pipe other-extensions: ConstraintKinds, StandaloneDeriving, DataKinds, KindSignatures, GADTs, MultiParamTypeClasses ghc-options: -O -threaded -with-rtsopts=-N2 - build-depends: base ^>=4.16 - , text ^>=1.2.3.1 + build-depends: base ^>=4.17 + , text ^>=2.0 , process , exceptions , managed diff --git a/test/run.sh b/test/run.sh index c98c25cd76c..f9cf1945f6d 100755 --- a/test/run.sh +++ b/test/run.sh @@ -26,7 +26,7 @@ DTESTS=no IDL=no PERF=no VIPER=no -WASMTIME_OPTIONS="--disable-cache --enable-cranelift-nan-canonicalization --wasm-features multi-memory,bulk-memory" +WASMTIME_OPTIONS="-C cache=n -W nan-canonicalization=y -W multi-memory -W bulk-memory" WRAP_drun=$(realpath $(dirname $0)/drun-wrapper.sh) WRAP_ic_ref_run=$(realpath $(dirname $0)/ic-ref-run-wrapper.sh) SKIP_RUNNING=${SKIP_RUNNING:-no} @@ -34,6 +34,8 @@ SKIP_VALIDATE=${SKIP_VALIDATE:-no} ONLY_TYPECHECK=no ECHO=echo +export WASMTIME_NEW_CLI=1 + while getopts "adpstirv" o; do case "${o}" in a) @@ -122,6 +124,7 @@ function run () { fi $ECHO -n " [$ext]" + $ECHO "$@" >& $out/$base.$ext "$@" >& $out/$base.$ext local ret=$? @@ -408,7 +411,7 @@ do run_if opt.wasm drun-run-opt $WRAP_drun $out/$base.opt.wasm $mangled fi else - run_if wasm wasm-run wasmtime $WASMTIME_OPTIONS $out/$base.wasm + run_if wasm wasm-run wasmtime run $WASMTIME_OPTIONS $out/$base.wasm fi fi diff --git a/wasm-profiler/src/instrumentation.rs b/wasm-profiler/src/instrumentation.rs index 3187824f122..e98face0787 100644 --- a/wasm-profiler/src/instrumentation.rs +++ b/wasm-profiler/src/instrumentation.rs @@ -112,7 +112,7 @@ fn inject_imports(for_ic : bool, module: Module) -> Module { ); builder.push_import( builder::import() - .module("wasi_unstable") + .module("wasi_snapshot_preview1") .field("fd_write") .external() .func(import_sig)