replacement in elpe/lib/rust/rust.ml at line 188
[2.18932]→[2.18932:18985](∅→∅) − ~dependencies ~features ~opt_level ~is_top_level =
+ ~dependencies ~features ~opt_level ~is_top_level ~extra_crate_dependencies =
edit in elpe/lib/rust/rust.ml at line 199
+
+ method description =
+ try package |> member "description" |> to_string with _ -> ""
+
edit in elpe/lib/rust/rust.ml at line 206
+
+ method lib_name =
+ try
+ Some
+ (List.find
+ (fun x ->
+ let kind = x |> member "kind" |> to_list |> filter_string in
+ kind = [ "lib" ] || kind = [ "proc-macro" ])
+ self#targets
+ |> member "name" |> to_string)
+ with Not_found -> None
edit in elpe/lib/rust/rust.ml at line 239
+ export CC_ENABLE_DEBUG_OUTPUT=1
+ export CC=$(command -v clang)
edit in elpe/lib/rust/rust.ml at line 243
replacement in elpe/lib/rust/rust.ml at line 304
[2.20494]→[2.20494:20523](∅→∅) + (* rustc wants a single (or few) `-L dependency=` flag, else it
+ seems to ignore some of them. That's why we copy deps and
+ transitive deps to target/deps. *)
+ let dependencies_str, target_deps =
replacement in elpe/lib/rust/rust.ml at line 309
[2.20546]→[2.20546:20891](∅→∅) − (fun acc (rename, name, h, is_proc_macro, b) ->
− acc ^ " --extern " ^ underscorize rename ^ "=" ^ List.hd b.destdir
− ^ "/lib/lib" ^ underscorize name ^ "-" ^ h
− ^
− if is_proc_macro then ".so"
− else if kind = "lib" then ".rmeta"
− else ".rlib")
− "" dependencies
+ (fun (acc_extern, acc_ln) (rename, lib_name, h, is_proc_macro, b) ->
+ let acc_extern =
+ acc_extern ^ " --extern " ^ underscorize rename
+ ^ "=target/deps/lib" ^ underscorize lib_name ^ "-" ^ h
+ ^ if is_proc_macro then ".so" else ".rlib"
+ in
+ let acc_ln =
+ acc_ln ^ "ln -sf " ^ List.hd b.destdir ^ "/lib/* target/deps\n"
+ in
+ (acc_extern, acc_ln))
+ ("", "mkdir -p target/deps\n")
+ dependencies
replacement in elpe/lib/rust/rust.ml at line 322
[2.20900]→[2.20900:20930](∅→∅) −
− let dependencies_str =
replacement in elpe/lib/rust/rust.ml at line 324
[2.20951]→[2.20951:21082](∅→∅) − (fun _ v acc -> acc ^ " -L dependency=" ^ List.hd v.destdir ^ "/lib")
− transitive_dependencies dependencies_str
+ (fun _ v acc ->
+ acc ^ "ln -sf " ^ List.hd v.destdir ^ "/lib/* target/deps\n")
+ transitive_dependencies target_deps
edit in elpe/lib/rust/rust.ml at line 329
edit in elpe/lib/rust/rust.ml at line 331
+ let local =
+ match self#lib_name with
+ | Some l ->
+ "--extern " ^ underscorize l ^ "=$DESTDIR/lib/lib"
+ ^ underscorize l ^ "-" ^ self#hash ^ ".rlib"
+ | None -> ""
+ in
edit in elpe/lib/rust/rust.ml at line 341
replacement in elpe/lib/rust/rust.ml at line 343
[2.21201]→[2.21201:21489](∅→∅) − set -x
− rustc --crate-name %{under} %{edition} %{src_path} %{target} --crate-type bin -C linker=gcc $RUSTC_FLAGS %{features_args} -C metadata=%{hash} --out-dir %{out} %{dependencies_str} -L dependency=../lib --cap-lints allow
− { set +x; } 2>/dev/null
+ mkdir -p target %{out} $DESTDIR
+ touch target/rustc.opt
+ RUSTC_FLAGS=$(cat target/rustc.opt)
+ find $DESTDIR
+ %{target_deps}
+ rustc --crate-name %{under} %{edition} %{src_path} %{target} --crate-type bin --emit=link -C linker=gcc $RUSTC_FLAGS %{features_args} -C metadata=%{hash}-bin --out-dir %{out} %{dependencies_str} %{local} -L dependency=target/deps --cap-lints allow
edit in elpe/lib/rust/rust.ml at line 354
replacement in elpe/lib/rust/rust.ml at line 356
[2.21564]→[2.21564:22049](∅→∅) − set -x
− rustc --crate-name %{under} %{edition} %{src_path} --crate-type %{kind} %{target} --emit=dep-info,metadata,link -C linker=gcc -C embed-bitcode=no -C debuginfo=2 $RUSTC_FLAGS %{if kind = "proc-macro" then " -C prefer-dynamic" else ""} %{features_args} -C metadata=%{hash} --out-dir %{out} -C extra-filename=-%{hash} %{dependencies_str} %{if kind = "proc-macro" then " --extern proc_macro" else ""} --cap-lints allow
− { set +x; } 2>/dev/null
+ mkdir -p target %{out}
+ touch target/rustc.opt
+ RUSTC_FLAGS=$(cat target/rustc.opt)
+ %{target_deps}
+ rustc --crate-name %{under} %{edition} %{src_path} --crate-type %{kind} %{target} --emit=link -C linker=gcc -C embed-bitcode=no -C debuginfo=2 $RUSTC_FLAGS %{if kind = "proc-macro" then " -C prefer-dynamic" else ""} %{features_args} -C metadata=%{hash} --out-dir %{out} -C extra-filename=-%{hash} %{dependencies_str} %{if kind = "proc-macro" then " --extern proc_macro" else ""} -L dependency=target/deps --cap-lints allow
replacement in elpe/lib/rust/rust.ml at line 380
[2.22573]→[2.22573:22613](∅→∅) − Hashtbl.add h d#name d;
+ Hashtbl.add h d#hash d;
edit in elpe/lib/rust/rust.ml at line 414
+ let x_lib_name = Option.get x#lib_name in
edit in elpe/lib/rust/rust.ml at line 426
replacement in elpe/lib/rust/rust.ml at line 448
[2.24645]→[2.24645:24714](∅→∅) − r := (name, x_name, x_hash, is_proc_macro, b) :: !r;
+ r := (name, x_lib_name, x_hash, is_proc_macro, b) :: !r;
edit in elpe/lib/rust/rust.ml at line 464
+ method extra_deps =
+ List.fold_left
+ (fun acc dep ->
+ let* acc = acc in
+ let* extra = dep#extra_deps in
+ Lwt.return (extra @ acc))
+ (Lwt.return (extra_crate_dependencies self#name self#version))
+ dependencies
+
edit in elpe/lib/rust/rust.ml at line 474
+ let* extra = self#extra_deps in
edit in elpe/lib/rust/rust.ml at line 480
+ ubuntu "clang";
+ ubuntu "libc6-dev";
edit in elpe/lib/rust/rust.ml at line 484
replacement in elpe/lib/rust/rust.ml at line 487
[2.25203]→[2.25203:25262](∅→∅) − @ extra_crate_dependencies self#name self#version)
replacement in elpe/lib/rust/rust.ml at line 493
[3.7481]→[2.25263:25336](∅→∅) − ref ("mkdir -p target/build-" ^ hash ^ "\nexport RUSTC=rustc\n")
+ ref
+ ("mkdir -p target/build-" ^ hash
+ ^ "\nexport RUSTC=rustc\ntouch target/rustc.opt\n")
edit in elpe/lib/rust/rust.ml at line 503
+ let links =
+ try Some (package |> member "links" |> to_string)
+ with Not_found | Yojson.Basic.Util.Type_error _ -> None
+ in
edit in elpe/lib/rust/rust.ml at line 512
+ let description =
+ Str.global_replace
+ (Str.regexp "\"\\|`\\|\\$\\|\\")
+ "\\\\\\0" self#description
+ in
replacement in elpe/lib/rust/rust.ml at line 521
[2.25505]→[2.25505:25547](∅→∅) − {|export OUT_DIR=$DESTDIR/lib
+ {|
+ export OUT_DIR=$DESTDIR/lib
+ export CC_ENABLE_DEBUG_OUTPUT=1
edit in elpe/lib/rust/rust.ml at line 526
+ export CARGO_PKG_DESCRIPTION="%{description}"
replacement in elpe/lib/rust/rust.ml at line 530
[2.25805]→[2.25805:25880](∅→∅) − export CARGO_PKG_VERSION_PATCH=%{Option.value v4 ~default:""}
+ export CARGO_PKG_VERSION_PRE=%{Option.value v4 ~default:""}
+ export CARGO_MANIFEST_DIR=$(pwd)/%{name}-%{version}
+ export CARGO_MANIFEST_LINKS=%{Option.value links ~default: ""}
edit in elpe/lib/rust/rust.ml at line 576
+ echo Running build script for %{name}-%{version}
replacement in elpe/lib/rust/rust.ml at line 604
[2.27418]→[2.27418:27492](∅→∅) − d.transitive_dependencies d.dependencies "$OUT_DIR"
+ d.transitive_dependencies d.dependencies "$DESTDIR/lib"
replacement in elpe/lib/rust/rust.ml at line 611
[2.27633]→[2.27633:27740](∅→∅) − d.transitive_dependencies d.dependencies
− "$OUT_DIR/../bin"
+ d.transitive_dependencies d.dependencies "$DESTDIR/bin"
replacement in elpe/lib/rust/rust.ml at line 655
[2.28847]→[2.28847:28882](∅→∅) − ?(host = !Platform.host) src =
+ ?(host = !Platform.host)
+ ?(extra_crate_dependencies = extra_crate_dependencies) src =
replacement in elpe/lib/rust/rust.ml at line 705
[3.7236]→[2.29085:29200](∅→∅) − let is_top_level = List.exists (fun w -> w = name) workspace_members in
− let cc = (cc :> derivation) in
+ let is_top_level = List.exists (fun w -> w = id) workspace_members in
+ let cc = (cc Clang :> derivation) in
replacement in elpe/lib/rust/rust.ml at line 710
[2.29274]→[2.29274:29337](∅→∅) − ~dependencies ~features ~opt_level:"3" ~is_top_level
+ ~extra_crate_dependencies ~dependencies ~features ~opt_level:"3"
+ ~is_top_level
replacement in elpe/lib/rust/run_build_script.sh at line 2
[2.29517]→[2.29517:29628](∅→∅) −
− eval $(echo $cargo | sed -ne 's/cargo:rustc-link-arg=\(.*\)/RUSTC_FLAGS="-C link_arg=\1 $RUSTC_FLAGS"/p')
+ echo $cargo # | grep -v "^\(#\|cargo:\)"
+ echo $cargo | sed -ne 's/cargo:rustc-link-arg=\(.*\)/-C link_arg=\1/p' >> target/rustc.opt
replacement in elpe/lib/rust/run_build_script.sh at line 5
[2.29629]→[2.29629:29729](∅→∅) − eval $(echo $cargo | sed -ne 's/cargo:rustc-link-lib=\(.*\)/RUSTC_FLAGS="-l\1 $RUSTC_FLAGS"/p')
+ echo $cargo | sed -ne 's/cargo:rustc-link-lib=\(.*\)/-l \1/p' >> target/rustc.opt
replacement in elpe/lib/rust/run_build_script.sh at line 7
[2.29730]→[2.29730:29833](∅→∅) − eval $(echo $cargo | sed -ne 's/cargo:rustc-link-search=\(.*\)/RUSTC_FLAGS="-L\1 $RUSTC_FLAGS"/p')
+ echo $cargo | sed -ne 's/cargo:rustc-link-search=\(.*\)/-L \1/p' >> target/rustc.opt
replacement in elpe/lib/rust/run_build_script.sh at line 9
[2.29834]→[2.29834:29933](∅→∅) − eval $(echo $cargo | sed -ne "s/cargo:rustc-cfg=\(.*\)/RUSTC_FLAGS='--cfg \1 $RUSTC_FLAGS'/p")
+ echo $cargo | sed -ne 's/cargo:rustc-cfg=\(.*\)/--cfg \1/p' >> target/rustc.opt
replacement in elpe/lib/rust/run_build_script.sh at line 11
[2.29934]→[2.29934:30029](∅→∅) − eval $(echo $cargo | sed -ne 's/cargo:rustc-flags=\(.*\)/RUSTC_FLAGS="\1 $RUSTC_FLAGS"/p')
+ echo $cargo | sed -ne 's/cargo:rustc-flags=\(.*\)/\1/p' >> target/rustc.opt
replacement in elpe/lib/dune at line 7
[2.36392]→[2.36392:36439](∅→∅) − (preprocessor_deps (file run_build_script.sh))
+ (preprocessor_deps (file rust/run_build_script.sh))
replacement in elpe/lib/derivation.ml at line 76
[3.16526]→[3.16526:16587](∅→∅) − let link_extra = [ ("libstd-rust-.*-dev", "libstd-rust.*") ]
+ let link_extra =
+ [ ("libstd-rust-.*-dev", "libstd-rust.*"); ("clang", "clang-.*") ]
+
replacement in elpe/lib/derivation.ml at line 150
[3.10575]→[3.10575:10856](∅→∅),
[3.10856]→[2.40576:40623](∅→∅),
[2.40623]→[3.10894:11695](∅→∅),
[3.10894]→[3.10894:11695](∅→∅) − let c =
− match !backend_conn with
− | None -> failwith "no conn"
− | Some c -> c
− in
− let* index =
− Lwt_list.map_p
− (fun repository ->
− let arch =
− match platform.arch with
− | Amd64 -> Elpegrpc.Elpe.Arch.Amd64
− | Aarch64 -> Elpegrpc.Elpe.Arch.Aarch64
− in
− let* res = ubuntu_release c ~release ~arch ~repository in
− let res, _ = Result.get_ok res in
− match res with
− | `Ok r -> Lwt.return r.destdir
− | `Error e -> raise (DerivationError e)
− | _ -> assert false)
− [ "main"; "universe" ]
− in
− let index = List.concat index in
− let* res = ubuntu_package c ~index ~name in
− let r = Result.get_ok res in
− let x = { destdir = r.destdir; paths = r.paths } in
− cached_build := Some x;
− Lwt.return x)
+ match !cached_build with
+ | Some x -> Lwt.return x
+ | None ->
+ let c =
+ match !backend_conn with
+ | None -> failwith "no conn"
+ | Some c -> c
+ in
+ let* index =
+ Lwt_list.map_p
+ (fun repository ->
+ let arch =
+ match platform.arch with
+ | Amd64 -> Elpegrpc.Elpe.Arch.Amd64
+ | Aarch64 -> Elpegrpc.Elpe.Arch.Aarch64
+ in
+ let* res =
+ ubuntu_release c ~release ~arch ~repository
+ in
+ let res, _ = Result.get_ok res in
+ match res with
+ | `Ok r -> Lwt.return r.destdir
+ | `Error e -> raise (DerivationError e)
+ | _ -> assert false)
+ [ "main"; "universe" ]
+ in
+ let index = List.concat index in
+ let* res = ubuntu_package c ~index ~name in
+ let r = Result.get_ok res in
+ let x = { destdir = r.destdir; paths = r.paths } in
+ cached_build := Some x;
+ Lwt.return x)
replacement in elpe/lib/derivation.ml at line 429
[2.41008]→[2.41008:41017](∅→∅) + type cc = Gcc | Clang
+
+ let cc x =
+ let x = match x with Gcc -> "gcc" | Clang -> "clang" in
replacement in elpe/lib/derivation.ml at line 436
[2.41083]→[2.41083:41158](∅→∅) − method! build_inputs = Lwt.return [ ubuntu "coreutils"; ubuntu "gcc" ]
+ method! build_inputs = Lwt.return [ ubuntu "coreutils"; ubuntu x ]
replacement in elpe/lib/derivation.ml at line 440
[2.41226]→[2.41226:41310](∅→∅) − let* gcc = (ubuntu "gcc")#build in
− List.iter self#add_path gcc.destdir;
+ let* cc = (ubuntu x)#build in
+ List.iter self#add_path cc.destdir;
replacement in elpe/lib/derivation.ml at line 443
[2.41327]→[2.41327:41439](∅→∅) − ("mkdir -p $DESTDIR/usr/bin; ln -s " ^ List.hd gcc.destdir
− ^ "/usr/bin/gcc $DESTDIR/usr/bin/cc")
+ ("mkdir -p $DESTDIR/usr/bin; ln -s " ^ List.hd cc.destdir ^ "/usr/bin/"
+ ^ x ^ " $DESTDIR/usr/bin/cc")