Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide vendored tarball #126

Closed
eszlari opened this issue Mar 21, 2019 · 16 comments
Closed

Provide vendored tarball #126

eszlari opened this issue Mar 21, 2019 · 16 comments

Comments

@eszlari
Copy link

eszlari commented Mar 21, 2019

I'm the maintainer of the OpenShot (https://www.openshot.org) flatpak (https://flatpak.org):

https://flathub.org/apps/details/org.openshot.OpenShot
https://github.com/flathub/org.openshot.OpenShot

In version 2.4.4 of OpenShot, a dependency on resvg was added.

While building the flatpak, no network access is permitted. To make compiling with cargo possible, other flatpaks like e.g. GNOME Fractal (https://gitlab.gnome.org/GNOME/fractal) use cargo vendor (https://crates.io/crates/cargo-vendor) to offer tarballs that bundle all rust dependencies:

https://gitlab.gnome.org/GNOME/fractal/uploads/ad6a483327c3e9ef5bb926b89fb26e2b/fractal-4.0.0.tar.xz

@RazrFalcon
Copy link
Collaborator

I newer used cargo-vendor, so I'm not sure what exactly should I do.

  1. I have to add a separate tarball to the release tag, which will contain all Rust crates used by resvg?
  2. cairo/Qt dependency isn't a problem?

Something like this?

@eszlari
Copy link
Author

eszlari commented Mar 21, 2019

Compiling now works until this point:

[...]
   Compiling euclid_macros v0.1.0                                                                                                                                                                                                            
     Running `rustc --crate-name euclid_macros /run/build/resvg/vendor/euclid_macros/lib.rs --color always --crate-type proc-macro --emit=dep-info,link -C prefer-dynamic -C opt-level=3 -C metadata=492af2c26de40ac6 -C extra-filename=-492af2c26de40ac6 --out-dir /run/build/resvg/target/release/deps -L dependency=/run/build/resvg/target/release/deps --extern proc_macro2=/run/build/resvg/target/release/deps/libproc_macro2-01ab4669e720bbdd.rlib --extern quote=/run/build/resvg/target/release/deps/libquote-787eea0605cb663e.rlib --extern syn=/run/build/resvg/target/release/deps/libsyn-0cde59c65051af0b.rlib --cap-lints allow`
   Compiling euclid v0.19.6                                                                                                                                                                                                                  
     Running `rustc --crate-name euclid /run/build/resvg/vendor/euclid/src/lib.rs --color always --crate-type lib --emit=dep-info,link -C opt-level=3 -C metadata=2c10fde69c06e77f -C extra-filename=-2c10fde69c06e77f --out-dir /run/build/resvg/target/release/deps -L dependency=/run/build/resvg/target/release/deps --extern euclid_macros=/run/build/resvg/target/release/deps/libeuclid_macros-492af2c26de40ac6.so --extern num_traits=/run/build/resvg/target/release/deps/libnum_traits-07c7e753498587c6.rlib --cap-lints allow`
   Compiling lyon_geom v0.12.4                                                                                                                                                                                                               
     Running `rustc --crate-name lyon_geom /run/build/resvg/vendor/lyon_geom/src/lib.rs --color always --crate-type lib --emit=dep-info,link -C opt-level=3 -C metadata=d0155b414ce2aea7 -C extra-filename=-d0155b414ce2aea7 --out-dir /run/build/resvg/target/release/deps -L dependency=/run/build/resvg/target/release/deps --extern arrayvec=/run/build/resvg/target/release/deps/libarrayvec-91b3bc707600b937.rlib --extern euclid=/run/build/resvg/target/release/deps/libeuclid-2c10fde69c06e77f.rlib --extern num_traits=/run/build/resvg/target/release/deps/libnum_traits-07c7e753498587c6.rlib --cap-lints allow`
   Compiling usvg v0.6.1 (/run/build/resvg/usvg)                                                                                                                                                                                             
     Running `rustc --crate-name usvg usvg/src/lib.rs --color always --crate-type lib --emit=dep-info,link -C opt-level=3 -C metadata=fee7d37f78f97121 -C extra-filename=-fee7d37f78f97121 --out-dir /run/build/resvg/target/release/deps -L dependency=/run/build/resvg/target/release/deps --extern base64=/run/build/resvg/target/release/deps/libbase64-bc17d158c15e6510.rlib --extern libflate=/run/build/resvg/target/release/deps/liblibflate-6f3376e23af2d52b.rlib --extern log=/run/build/resvg/target/release/deps/liblog-337b8efa621b8035.rlib --extern lyon_geom=/run/build/resvg/target/release/deps/liblyon_geom-d0155b414ce2aea7.rlib --extern rctree=/run/build/resvg/target/release/deps/librctree-dc3aa5ab1c79dd6b.rlib --extern svgdom=/run/build/resvg/target/release/deps/libsvgdom-e60e8a85504d4d91.rlib`
   Compiling resvg v0.6.1 (/run/build/resvg)                                                                                                                                                                                                 
     Running `rustc --crate-name resvg src/lib.rs --color always --crate-type lib --emit=dep-info,link -C opt-level=3 --cfg 'feature="qt-backend"' --cfg 'feature="resvg-qt"' -C metadata=78b50b98c1f2b773 -C extra-filename=-78b50b98c1f2b773 --out-dir /run/build/resvg/target/release/deps -L dependency=/run/build/resvg/target/release/deps --extern log=/run/build/resvg/target/release/deps/liblog-337b8efa621b8035.rlib --extern resvg_qt=/run/build/resvg/target/release/deps/libresvg_qt-1dedf2638b014b0b.rlib --extern rgb=/run/build/resvg/target/release/deps/librgb-c012f1dc0181cc07.rlib --extern usvg=/run/build/resvg/target/release/deps/libusvg-fee7d37f78f97121.rlib -L native=/run/build/resvg/target/release/build/resvg-qt-282e21ccb88be742/out`
   Compiling resvg-capi v0.6.1 (/run/build/resvg/capi)                                                                                                                                                                                       
     Running `rustc --crate-name resvg capi/src/lib.rs --color always --crate-type cdylib --crate-type staticlib --emit=dep-info,link -C opt-level=3 -C lto --cfg 'feature="qt-backend"' --cfg 'feature="resvg"' -C metadata=80faaf7f7056507f --out-dir /run/build/resvg/target/release/deps -L dependency=/run/build/resvg/target/release/deps --extern fern=/run/build/resvg/target/release/deps/libfern-c45cf50ed2131c43.rlib --extern log=/run/build/resvg/target/release/deps/liblog-337b8efa621b8035.rlib --extern resvg=/run/build/resvg/target/release/deps/libresvg-78b50b98c1f2b773.rlib -L native=/run/build/resvg/target/release/build/resvg-qt-282e21ccb88be742/out`
error: Could not compile `resvg-capi`.                                                                                                                                                                                                       

Caused by:
  process didn't exit successfully: `rustc --crate-name resvg capi/src/lib.rs --color always --crate-type cdylib --crate-type staticlib --emit=dep-info,link -C opt-level=3 -C lto --cfg 'feature="qt-backend"' --cfg 'feature="resvg"' -C metadata=80faaf7f7056507f --out-dir /run/build/resvg/target/release/deps -L dependency=/run/build/resvg/target/release/deps --extern fern=/run/build/resvg/target/release/deps/libfern-c45cf50ed2131c43.rlib --extern log=/run/build/resvg/target/release/deps/liblog-337b8efa621b8035.rlib --extern resvg=/run/build/resvg/target/release/deps/libresvg-78b50b98c1f2b773.rlib -L native=/run/build/resvg/target/release/build/resvg-qt-282e21ccb88be742/out` (signal: 11, SIGSEGV: invalid memory reference)
Error: module resvg: Child process exited with code 101

Rust: 1.33.0
Qt: 5.12.2

@eszlari
Copy link
Author

eszlari commented Mar 21, 2019

RUST_LOG=debug output:

[...]
 INFO 2019-03-21T19:12:33Z: rustc_codegen_llvm::back::lto: linking "resvg.bvsuca1m-cgu.12"                                                                                                                                                   
 INFO 2019-03-21T19:12:33Z: rustc_codegen_llvm::back::lto: linking "resvg.bvsuca1m-cgu.6"                                                                                                                                                    
 INFO 2019-03-21T19:12:33Z: rustc_codegen_llvm::back::lto: linking "resvg.bvsuca1m-cgu.11"                                                                                                                                                   
 INFO 2019-03-21T19:12:33Z: rustc_codegen_llvm::back::lto: linking "resvg.bvsuca1m-cgu.7"                                                                                                                                                    
 INFO 2019-03-21T19:12:33Z: rustc_codegen_llvm::back::lto: linking "resvg.bvsuca1m-cgu.8"                                                                                                                                                    
 INFO 2019-03-21T19:12:33Z: rustc_codegen_llvm::back::lto: linking "resvg.bvsuca1m-cgu.13"                                                                                                                                                   
 INFO 2019-03-21T19:12:33Z: rustc_codegen_llvm::back::lto: linking "resvg.bvsuca1m-cgu.2"                                                                                                                                                    
 INFO 2019-03-21T19:12:40Z: cargo::core::compiler::job_queue: end: resvg-capi v0.6.1 (/run/build/resvg/capi) => Target(lib)/Profile(release) => Host                                                                                         
 INFO 2019-03-21T19:12:40Z: cargo::util::rustc: updated rustc info cache                                                                                                                                                                     
DEBUG 2019-03-21T19:12:40Z: cargo: exit_with_error; err=CliError { error: Some(ProcessError { desc: "process didn\'t exit successfully: `rustc --crate-name resvg capi/src/lib.rs --color always --crate-type cdylib --crate-type staticlib --emit=dep-info,link -C opt-level=3 -C lto --cfg \'feature=\"qt-backend\"\' --cfg \'feature=\"resvg\"\' -C metadata=80faaf7f7056507f --out-dir /run/build/resvg/target/release/deps -L dependency=/run/build/resvg/target/release/deps --extern fern=/run/build/resvg/target/release/deps/libfern-c45cf50ed2131c43.rlib --extern log=/run/build/resvg/target/release/deps/liblog-337b8efa621b8035.rlib --extern resvg=/run/build/resvg/target/release/deps/libresvg-78b50b98c1f2b773.rlib -L native=/run/build/resvg/target/release/build/resvg-qt-282e21ccb88be742/out` (signal: 11, SIGSEGV: invalid memory reference)", exit: Some(ExitStatus(ExitStatus(139))), output: None }

Could not compile `resvg-capi`.), unknown: false, exit_code: 101 }
error: Could not compile `resvg-capi`.

Caused by:
  process didn't exit successfully: `rustc --crate-name resvg capi/src/lib.rs --color always --crate-type cdylib --crate-type staticlib --emit=dep-info,link -C opt-level=3 -C lto --cfg 'feature="qt-backend"' --cfg 'feature="resvg"' -C metadata=80faaf7f7056507f --out-dir /run/build/resvg/target/release/deps -L dependency=/run/build/resvg/target/release/deps --extern fern=/run/build/resvg/target/release/deps/libfern-c45cf50ed2131c43.rlib --extern log=/run/build/resvg/target/release/deps/liblog-337b8efa621b8035.rlib --extern resvg=/run/build/resvg/target/release/deps/libresvg-78b50b98c1f2b773.rlib -L native=/run/build/resvg/target/release/build/resvg-qt-282e21ccb88be742/out` (signal: 11, SIGSEGV: invalid memory reference)

@eszlari
Copy link
Author

eszlari commented Mar 21, 2019

command used for compilation:

cargo build --verbose --release --frozen --manifest-path capi/Cargo.toml --features "qt-backend"

@RazrFalcon
Copy link
Collaborator

Looks like a rustc bug. Not sure what I can do here. Here is the same issue.

How can I reproduce it? The last command works fine on my machine. What environment do you have?

@RazrFalcon
Copy link
Collaborator

Also, try disabling lto in Cargo.toml. The last line.

There was a similar bug: #110

@eszlari
Copy link
Author

eszlari commented Mar 21, 2019

Disabling LTO made it compile and the resulting OpenShot build can import SVG files successfully, thank you!

I have to add a separate tarball to the release tag, which will contain all Rust crates used by resvg?

Yes, please do that, and also fix the tarball directory structure and maybe use tar.xz!

@RazrFalcon
Copy link
Collaborator

fix the tarball directory structure

What do you mean?

use tar.xz

GitHub doesn't allow it in comments, but I will be able to publish it.

@RazrFalcon
Copy link
Collaborator

Also, can you provide more info about your environment to fill the rustc bug?

@eszlari
Copy link
Author

eszlari commented Mar 21, 2019

What do you mean?

There is no directory resvg in https://github.com/RazrFalcon/resvg/files/2993541/resvg.tar.gz - all file are at the top level.

@RazrFalcon
Copy link
Collaborator

There is no directory resvg

Should it be there? Archive is a "directory" by itself. Not sure why we need this.

@eszlari
Copy link
Author

eszlari commented Mar 21, 2019

Should it be there? Archive is a "directory" by itself. Not sure why we need this.

Just download some random tarball from the internet (e.g. https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.0.3.tar.xz) and you will see that this is standard behavior.

@eszlari
Copy link
Author

eszlari commented Mar 21, 2019

Also, can you provide more info about your environment to fill the rustc bug?

Put the following in a file called org.flatpaktest.resvg.yaml:

app-id: org.flatpaktest.resvg
runtime: org.kde.Platform
runtime-version: '5.12'
sdk: org.kde.Sdk
sdk-extensions:
  - org.freedesktop.Sdk.Extension.rust-stable
command: echo
build-options:
  append-path: /usr/lib/sdk/rust-stable/bin
modules:
  - name: resvg
    buildsystem: simple
    build-commands:
      - cargo build --verbose --release --frozen --manifest-path capi/Cargo.toml --features "qt-backend"
      - install -Dm644 target/release/libresvg.so -t /app/lib
      - install -Dm644 capi/include/*.h -t /app/include/resvg
    sources:
      - type: archive
        url: https://github.com/RazrFalcon/resvg/releases/download/v0.6.1/resvg-0.6.1.tar.xz
        sha256: 7206f79f67b4c8610353134c375ed3ff9c5eb63b16fae267b94730c23ebe4ee1

Now execute the following commands:

$ flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
$ flatpak install flathub org.kde.Platform//5.12
$ flatpak install flathub org.kde.Sdk//5.12
$ flatpak install flathub org.freedesktop.Sdk.Extension.rust-stable//18.08
$ flatpak-builder --install build_dir org.flatpaktest.resvg.yaml
$ flatpak run --devel --command=sh org.flatpaktest.resvg
(now inside the flatpak sandbox)
$ rustc --version

@RazrFalcon
Copy link
Collaborator

Good, will test it tomorrow.

I've added a new archive to the release tag. It's pretty big, mainly because of useless winapi dependencies. Will see what can be done here.

Also, I've disabled lto.

@eszlari
Copy link
Author

eszlari commented Mar 21, 2019

I have updated the YAML build manifest above to use the new tarball (and also CARGO_HOME doesn't need to be set anymore apparently).

@RazrFalcon
Copy link
Collaborator

Flatpak installation on Gentoo is a bit troublesome, so I will do this later.

For now, a vendored archive is in place and I've disabled the LTO by default, so we can close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants