From mboxrd@z Thu Jan 1 00:00:00 1970 From: Martin Becze Subject: Re: Overhauling the cargo-build-system Date: Fri, 15 Nov 2019 22:31:34 -0800 Message-ID: References: <20191010155056.GD1301@E5400> <87d0f4p6xd.fsf@gnu.org> <20191011141342.GC13364@E5400> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:46768) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVrcX-0008Sr-FK for guix-devel@gnu.org; Sat, 16 Nov 2019 01:31:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iVrcU-00056m-OR for guix-devel@gnu.org; Sat, 16 Nov 2019 01:31:44 -0500 In-Reply-To: <20191011141342.GC13364@E5400> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Efraim Flashner Cc: guix-devel@gnu.org, Guix-devel Sorry for digging up and old issue, but i just saw commit 86e443c71d4d19e6f80cad9ca15b9c3a301c738c > It makes for a very large package definition, but we wouldn't have to ensure thousands of other rust libraries built so we The whole point of package management is that you can use module building blocks. By having to specify the sub-dependencies in a top level definition kinda breaks the whole modular thing. In commit 86e443c71d4d19e6f80cad9ca15b9c3a301c738c all the inputs got removed for all the libraries. So if I'm trying to use guix as package manager for a rust project and I want to use one of the rust libraries in crates-io.scm, how am i suppose to do this? I can't just include it as an input to my project because now I have to look up all of it dependencies as well? > > PROPOSAL: > > Change all the rust packages we have now to be source-only. Rename th= em > > from rust-foo to rust-foo-src or rust-src-foo. Is there no way we can do this and keep the have a dependancy graph? =20 On 2019-10-11 14:13, Efraim Flashner wrote: > On Fri, Oct 11, 2019 at 12:33:18AM +0200, Ludovic Court=C3=A8s wrote: >> Hello! >> >> Efraim Flashner skribis: >> >> > I'd like to challenge the assumption that packages are both librarie= s >> > and source. A 'library' in rust compiles into one of three types: a >> > static library (libfoo.a), a shared library (libfoo.so), or a >> > 'rust-library' (libfoo.rlib). >> >> Why don=E2=80=99t we create .so files, then? They have NEEDED and RUN= PATH, so >> that could work like for C, no? >> >=20 > It is possible to force a library to produce .so files, but then we'd > have to force all the other packages to link against them, and then at > that point we're basically rewriting 'cargo build'. For some packages, > like icecat, that does seem to be what they do. >=20 >> > Let me repeat that. We have 192 rust packages that no one needs or >> > wants, except in source form. >> >> Ouch! So the rlib file is never actually used?! >> >=20 > As I understand it, it gets treated as a build artifact. It'll be > compiled as libfoo_XXXXXXXXX.rlib and then, if some other program comes > around as asks for "foo with feature baz" it'll be reused. At some poin= t > it gets compiled directly into the final binary, so it's really more of > an intermediary stage. >=20 >> You said =E2=80=9Cit is not possible to link an rlib to another rlib=E2= =80=9D, but >> that=E2=80=99s not necessarily a problem, it=E2=80=99s like .a librari= es, no? >> >=20 > if libfoo depends on libbar, then pre-building libbar_XXXXX.rlib doesn'= t > allow us to call "rustc --crate-name foo src/lib.rs --crate-type lib > --extern (string-append bar=3D(assoc-ref %build-inputs bar) > /lib/libbar.rlib)" (note the --crate-type lib in there), it'll just not > work and want to recompile libbar for just the few functions it uses > from it. The only difference I've seen is if our foo is also a "binary > crate", ie produces a binary, then it'll sometimes accept rlibs for its > own rlib lib output. >=20 > Going back to forcing it to produce .so files, if we changed the > crate-type to dylib then we'd get libfoo.so. The two parts of the > problem is now we need to change all the other libraries and programs > that depend on foo to take our libfoo.so and not expect an rlib, and > that if foo has 3 options then we have to decide how to build libfoo so > it's useful for everything (obviously all 3) but without dragging in > everything (easiest with none of the 3), or to have some combination, > which becomes a nightmare very quickly. >=20 > That sentence was way too long. >=20 >> > PROPOSAL: >> > Change all the rust packages we have now to be source-only. Rename t= hem >> > from rust-foo to rust-foo-src or rust-src-foo. >> >> In the current scheme, can you actually do, say: >> >> guix environment --ad-hoc rust rust-foo rust-bar >> >> and then (pseudo syntax): >> >> rustc mystuff.rust -lfoo -lbar >> >> ? >=20 > Ignoring that we don't actually install the libraries here's a copy of > a check phase I wrote trying to use installed libraries. I think in the > end it did consume the rlibs as requested, but it never did link to > them, it just absorbed them into the final binary. >=20 > (replace 'check > (lambda* (#:key inputs #:allow-other-keys) > (let ((ndarray (assoc-ref inputs "ndarray")) > (rand (assoc-ref inputs "rand")) > (rayon (assoc-ref inputs "rayon")) > (serde (assoc-ref inputs "serde")) > (serde-json (assoc-ref inputs "serde-json")) > (structopt (assoc-ref inputs "structopt"))) > (invoke "rustc" "--edition=3D2018" "--crate-name" "qtlreaper" > "src/lib.rs" > "-C" "opt-level=3D3" > "--test" "-C" "metadata=3Dtest" "-C" "extra-filename=3D-t= est" > "--out-dir" "target/release/deps" > "--extern" (string-append "ndarray=3D" ndarray > "/lib/libndarray.rlib") > "--extern" (string-append "rand=3D" rand "/lib/librand.rl= ib") > "--extern" (string-append "rayon=3D" rayon "/lib/librayon= .rlib") > "--extern" (string-append "serde=3D" serde "/lib/libserde= .rlib") > "--extern" (string-append "serde_json=3D" serde-json > "/lib/libserde_json.rlib") > "--extern" (string-append "structopt=3D" structopt > "/lib/structopt.rlib") > "--cap-lints" "allow" "-C" "rpath" "-C" "prefer-dynamic") > (invoke "rustc" "--edition=3D2018" "--crate-name" "qtlreaper" > "src/main.rs" > "-C" "opt-level=3D3" > "--test" "-C" "metadata=3Dtest" "-C" "extra-filename=3D-t= est" > "--out-dir" "target/release/deps" > "--extern" "qtlreaper=3Dtarget/release/deps/libqtlreaper-= test.rlib" > "--extern" (string-append "ndarray=3D" ndarray > "/lib/libndarray.rlib") > "--extern" (string-append "rand=3D" rand "/lib/librand.rl= ib") > "--extern" (string-append "rayon=3D" rayon "/lib/librayon= .rlib") > "--extern" (string-append "serde=3D" serde "/lib/libserde= .rlib") > "--extern" (string-append "serde_json=3D" serde-json > "/lib/libserde_json.rlib") > "--extern" (string-append "structopt=3D" structopt > "/lib/structopt.rlib") > "--cap-lints" "allow" "-C" "rpath" "-C" "prefer-dynamic") > (invoke "./target/release/deps/qtlreaper-test") > (invoke "rustdoc" "--edition=3D2018" "--test" "src/lib" > "--crate-name" "qtlreaper" > "--extern" "qtlreaper=3Dtarget/release/deps/libqtlreaper-= test.rlib" > "--extern" (string-append "ndarray=3D" ndarray "/libndarr= ay.rlib") > "--extern" (string-append "rand=3D" rand "/librand.rlib") > "--extern" (string-append "rayon=3D" rayon "/lib/librayon= .rlib") > "--extern" (string-append "serde=3D" serde "/lib/libserde= .rlib") > "--extern" (string-append "serde_json=3D" serde-json > "/lib/libserde_json.rlib") > "--extern" (string-append "structopt=3D" structopt > "/lib/structopt.rlib")))))))) >=20 >> >> Thanks, >> Ludo=E2=80=99. >=20 > I was thinking of making the build phases for the cargo-build-system us= e > the --verbose flag, I found it very informative to see what it was doin= g > along the way.