diff options
author | Marge Bot <marge-bot@gnome.org> | 2022-09-27 16:21:06 +0000 |
---|---|---|
committer | Marge Bot <marge-bot@gnome.org> | 2022-09-27 16:21:06 +0000 |
commit | d54d730b9840720577da5d81fb38ae587d0d7bf6 (patch) | |
tree | b6029774da65839e982e414412fdd3ab0339a464 | |
parent | 0bc2076e7550bd8815ca34cd6f517f22d9f468fe (diff) | |
parent | 93a357cb9174ee75387a62c80de381b0b53f19ac (diff) | |
download | librsvg-d54d730b9840720577da5d81fb38ae587d0d7bf6.tar.gz |
Merge branch 'bump-rust-1.64' into 'main'
Bump the rust-stable version to 1.64.0
Closes #904
See merge request GNOME/librsvg!754
-rw-r--r-- | .gitlab-ci.yml | 60 | ||||
-rw-r--r-- | ci/build-with-coverage.sh | 22 | ||||
-rw-r--r-- | ci/container_builds.yml | 23 | ||||
-rw-r--r-- | src/util.rs | 20 | ||||
-rw-r--r-- | src/xml/attributes.rs | 4 | ||||
-rw-r--r-- | src/xml/xml2_load.rs | 6 |
6 files changed, 83 insertions, 52 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e43eaf5f..c3fa9122 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -79,6 +79,19 @@ test_rust_gdk_pixbuf_loader: - cd gdk-pixbuf-loader - cargo test +.cargo-test: + extends: '.cache' + stage: build + script: + - cargo test + artifacts: + when: 'on_failure' + paths: + - _build/tests/output + expire_in: 1 day + variables: + OUT_DIR: "${CI_PROJECT_DIR}/tests/output" + .build-rsvg-no-docs: extends: '.cache' stage: build @@ -111,7 +124,7 @@ test_rust_gdk_pixbuf_loader: - _build/tests/*.log expire_in: 1 day -build-rsvg-opensuse@x86_64.stable: +autotools build - opensuse@x86_64.stable: extends: - '.container.opensuse@x86_64.stable' - .fdo.distribution-image@opensuse @@ -124,54 +137,51 @@ build-rsvg-opensuse@x86_64.stable: - job: check artifacts: false -build-rsvg-opensuse@x86_64.minimum: +cargo test - opensuse@x86_64.minimum: extends: - '.container.opensuse@x86_64.minimum' - .fdo.distribution-image@opensuse - - .build-rsvg-no-docs + - .cargo-test needs: - job: opensuse-container@x86_64.minimum artifacts: false - job: check artifacts: false -build-rsvg-opensuse@x86_64.nightly: +cargo test - opensuse@x86_64.nightly: extends: - '.container.opensuse@x86_64.nightly' - .fdo.distribution-image@opensuse - - .build-rsvg-no-docs + - .cargo-test needs: - job: opensuse-container@x86_64.nightly artifacts: false - job: check artifacts: false -.build-rsvg-opensuse@aarch64: +cargo test - opensuse@aarch64: extends: - .container.opensuse@aarch64 - .fdo.distribution-image@opensuse - - .build-rsvg-no-docs + - .cargo-test needs: - job: opensuse-container@aarch64 artifacts: false - job: check artifacts: false + # The tests fail on aarch64 - some rendering differences. Needs diagnosis. + allow_failure: true -build-rsvg-fedora@x86_64: +cargo test - fedora@x86_64: extends: - .container.fedora@x86_64 - .fdo.distribution-image@fedora - - .build-rsvg-no-docs + - .cargo-test needs: - job: fedora-container@x86_64 artifacts: false - job: check artifacts: false - rules: - - if: '$CI_PIPELINE_SOURCE == "push"' - when: manual - allow_failure: true - - if: '$CI_PIPELINE_SOURCE == "schedule"' .build-rsvg-fedora@aarch64: extends: @@ -302,25 +312,9 @@ coverage: - job: opensuse-container@x86_64.stable - job: check artifacts: false - variables: - # Mixed gcc and Rust/LLVM coverage for the C API tests: - # https://searchfox.org/mozilla-central/source/browser/config/mozconfigs/linux64/code-coverage#15 - CC: "clang" - CFLAGS: "-coverage -ftest-coverage -fprofile-arcs" - # RUSTFLAGS: "-Cinstrument-coverage" - RUSTDOCFLAGS: "-Cinstrument-coverage" - LLVM_PROFILE_FILE: "coverage-profiles/coverage-%p-%m.profraw" - LDFLAGS: "--coverage -L/usr/lib64/clang/14.0.6/lib/linux" - LIBS: "-lclang_rt.profile-x86_64" - RUSTC_BOOTSTRAP: "1" # hack to make -Zprofile work on the non-nightly compiler - CARGO_INCREMENTAL: "0" # -Zprofile (gcov) doesn't like incremental compilation - RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Clink-dead-code -Coverflow-checks=off" script: - - mkdir -p _build - - cd _build - - ../autogen.sh --disable-gtk-doc --disable-vala --enable-debug - - make - - make -k check + - source ./ci/env.sh + - bash -x ./ci/build-with-coverage.sh after_script: - source ./ci/env.sh - bash -x ./ci/gen-coverage.sh @@ -412,7 +406,7 @@ distcheck: reference: stage: docs needs: - - job: build-rsvg-opensuse@x86_64.stable + - job: autotools build - opensuse@x86_64.stable artifacts: true script: - mkdir -p public/ diff --git a/ci/build-with-coverage.sh b/ci/build-with-coverage.sh new file mode 100644 index 00000000..9d4dea73 --- /dev/null +++ b/ci/build-with-coverage.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +set -eux -o pipefail + +# Mixed gcc and Rust/LLVM coverage for the C API tests: +# https://searchfox.org/mozilla-central/source/browser/config/mozconfigs/linux64/code-coverage#15 +export CC="clang" +export CFLAGS="-coverage -ftest-coverage -fprofile-arcs" +# RUSTFLAGS: "-Cinstrument-coverage" +export RUSTDOCFLAGS="-Cinstrument-coverage" +export LLVM_PROFILE_FILE="coverage-profiles/coverage-%p-%m.profraw" +export LDFLAGS="--coverage -L/usr/lib64/clang/14.0.6/lib/linux" +export LIBS="-lclang_rt.profile-x86_64" +export RUSTC_BOOTSTRAP="1" # hack to make -Zprofile work on the non-nightly compiler +export CARGO_INCREMENTAL="0" # -Zprofile (gcov) doesn't like incremental compilation +export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Clink-dead-code -Coverflow-checks=off" + +mkdir -p _build +cd _build +../autogen.sh --disable-gtk-doc --disable-vala --enable-debug +make +make -k check diff --git a/ci/container_builds.yml b/ci/container_builds.yml index 63c6a777..9ddcf692 100644 --- a/ci/container_builds.yml +++ b/ci/container_builds.yml @@ -6,8 +6,8 @@ include: variables: # When branching change the suffix to avoid conflicts with images # from the main branch - BASE_TAG: "2022-09-15.1-main" - RUST_STABLE: "1.63.0" + BASE_TAG: "2022-09-26.4-main" + RUST_STABLE: "1.64.0" RUST_MINIMUM: "1.58.1" .container.opensuse@common: @@ -21,7 +21,6 @@ variables: autoconf automake cairo-devel - ccache clang clang-tools curl @@ -102,7 +101,7 @@ opensuse-container@x86_64.nightly: - .container.opensuse@x86_64.nightly stage: "container-build" -.opensuse-container@aarch64: +opensuse-container@aarch64: extends: - .fdo.container-build@opensuse@aarch64 - .container.opensuse@aarch64 @@ -112,13 +111,13 @@ opensuse-container@x86_64.nightly: before_script: - source ./ci/env.sh variables: - FDO_DISTRIBUTION_VERSION: "33" + FDO_DISTRIBUTION_VERSION: "36" FDO_UPSTREAM_REPO: "gnome/librsvg" FDO_DISTRIBUTION_PACKAGES: >- autoconf automake cairo-devel - ccache + cairo-gobject-devel curl gcc gdk-pixbuf2-devel @@ -144,16 +143,14 @@ opensuse-container@x86_64.nightly: variables: FDO_DISTRIBUTION_TAG: "x86_64-${RUST_STABLE}-${BASE_TAG}" FDO_DISTRIBUTION_EXEC: >- - bash ci/install-rust.sh ${RUST_STABLE} x86_64-unknown-linux-gnu && - pip3 install gi-docgen + bash ci/install-rust.sh ${RUST_STABLE} x86_64-unknown-linux-gnu .container.fedora@aarch64: extends: .container.fedora@common variables: FDO_DISTRIBUTION_TAG: "aarch64-${RUST_STABLE}-${BASE_TAG}" FDO_DISTRIBUTION_EXEC: >- - bash ci/install-rust.sh ${RUST_STABLE} aarch64-unknown-linux-gnu && - pip3 install gi-docgen + bash ci/install-rust.sh ${RUST_STABLE} aarch64-unknown-linux-gnu tags: - aarch64 @@ -209,16 +206,14 @@ fedora-container@x86_64: variables: FDO_DISTRIBUTION_TAG: "x86_64-${RUST_STABLE}-${BASE_TAG}" FDO_DISTRIBUTION_EXEC: >- - bash ci/install-rust.sh ${RUST_STABLE} x86_64-unknown-linux-gnu && - pip3 install gi-docgen + bash ci/install-rust.sh ${RUST_STABLE} x86_64-unknown-linux-gnu .container.debian@aarch64: extends: .container.debian@common variables: FDO_DISTRIBUTION_TAG: "aarch64-${RUST_STABLE}-${BASE_TAG}" FDO_DISTRIBUTION_EXEC: >- - bash ci/install-rust.sh ${RUST_STABLE} aarch64-unknown-linux-gnu && - pip3 install gi-docgen + bash ci/install-rust.sh ${RUST_STABLE} aarch64-unknown-linux-gnu tags: - aarch64 diff --git a/src/util.rs b/src/util.rs index e308359a..1375b860 100644 --- a/src/util.rs +++ b/src/util.rs @@ -2,6 +2,7 @@ use std::borrow::Cow; use std::ffi::CStr; +use std::mem::transmute; use std::str; /// Converts a `char *` which is known to be valid UTF-8 into a `&str` @@ -32,6 +33,25 @@ pub unsafe fn cstr<'a>(s: *const libc::c_char) -> Cow<'a, str> { CStr::from_ptr(s).to_string_lossy() } +/// Casts a pointer to `c_char` to a pointer to `u8`. +/// +/// The obvious `p as *const u8` or `p as *const _` produces a +/// trivial_casts warning when compiled on aarch64, where `c_char` is +/// unsigned (on Intel, it is signed, so the cast works). +/// +/// We do this here with a `transmute`, which is awkward to type, +/// so wrap it in a function. +pub unsafe fn c_char_as_u8_ptr(p: *const libc::c_char) -> *const u8 { + transmute::<_, *const u8>(p) +} + +/// Casts a pointer to `c_char` to a pointer to mutable `u8`. +/// +/// See [`c_char_as_u8_ptr`] for the reason for this. +pub unsafe fn c_char_as_u8_ptr_mut(p: *mut libc::c_char) -> *mut u8 { + transmute::<_, *mut u8>(p) +} + pub fn clamp<T: PartialOrd>(val: T, low: T, high: T) -> T { if val < low { low diff --git a/src/xml/attributes.rs b/src/xml/attributes.rs index 9c8ebe96..844066cd 100644 --- a/src/xml/attributes.rs +++ b/src/xml/attributes.rs @@ -10,7 +10,7 @@ use string_cache::DefaultAtom; use crate::error::{ImplementationLimit, LoadingError}; use crate::limits; -use crate::util::{opt_utf8_cstr, utf8_cstr}; +use crate::util::{c_char_as_u8_ptr, opt_utf8_cstr, utf8_cstr}; /// Type used to store attribute values. /// @@ -103,7 +103,7 @@ impl Attributes { let end = value_end as usize; let len = end - start; - let value_slice = slice::from_raw_parts(value_start as *const u8, len); + let value_slice = slice::from_raw_parts(c_char_as_u8_ptr(value_start), len); let value_str = str::from_utf8_unchecked(value_slice); let value_atom = DefaultAtom::from(value_str); diff --git a/src/xml/xml2_load.rs b/src/xml/xml2_load.rs index c916c4f7..9dcdac4e 100644 --- a/src/xml/xml2_load.rs +++ b/src/xml/xml2_load.rs @@ -16,7 +16,7 @@ use glib::translate::*; use markup5ever::{namespace_url, ns, LocalName, Namespace, Prefix, QualName}; use crate::error::LoadingError; -use crate::util::{cstr, opt_utf8_cstr, utf8_cstr}; +use crate::util::{c_char_as_u8_ptr, c_char_as_u8_ptr_mut, cstr, opt_utf8_cstr, utf8_cstr}; use super::xml2::*; use super::Attributes; @@ -267,7 +267,7 @@ unsafe extern "C" fn sax_characters_cb( // libxml2 already validated the incoming string as UTF-8. Note that // it is *not* nul-terminated; this is why we create a byte slice first. - let bytes = std::slice::from_raw_parts(unterminated_text as *const u8, len as usize); + let bytes = std::slice::from_raw_parts(c_char_as_u8_ptr(unterminated_text), len as usize); let utf8 = str::from_utf8_unchecked(bytes); xml2_parser.state.characters(utf8); @@ -347,7 +347,7 @@ unsafe extern "C" fn stream_ctx_read( return -1; } - let buf: &mut [u8] = slice::from_raw_parts_mut(buffer as *mut u8, len as usize); + let buf: &mut [u8] = slice::from_raw_parts_mut(c_char_as_u8_ptr_mut(buffer), len as usize); match ctx.stream.read(buf, ctx.cancellable.as_ref()) { Ok(size) => size as libc::c_int, |